|
Nugget
Bare-metal libraries and examples for the original PlayStation
|
#include <stdint.h>#include "common/hardware/counters.h"#include "common/hardware/gpu.h"#include "common/hardware/hwregs.h"#include "common/syscalls/syscalls.h"#include "exotic/cester.h"
Macros | |
| #define | CESTER_NO_SIGNAL |
| #define | CESTER_NO_TIME |
| #define | EXIT_SUCCESS 0 |
| #define | EXIT_FAILURE 1 |
| #define | FIELDS 6 |
| #define | NONE 0xffff |
Functions | |
| CESTER_BODY (#define FIELDS #define NONE struct Field { uint32_t firstStat;uint16_t lines;uint16_t b31Rise, b31Fall, b13Rise, b13Fall;};static struct Field s_fields;static int s_interruptsWereEnabled;static void record(void) { GPU_STATUS=0x00000000;GPU_STATUS=0x06000000|0x260|(0xc60<< 12);GPU_STATUS=0x07000000|0x010|(0x100<< 10);GPU_STATUS=0x05000000;GPU_STATUS=0x08000027;GPU_STATUS=0x03000000;COUNTERS[1].mode=0x0100;IREG=~1u;while(!(IREG &1));IREG=~1u;uint16_t vbl=COUNTERS[1].value;for(int f=0;f< FIELDS;f++) { struct Field *p=&s_fields[f];p->b31Rise=p->b31Fall=p->b13Rise=p->b13Fall=NONE;uint32_t prev=GPU_STATUS;p->firstStat=prev;while(1) { uint32_t s=GPU_STATUS;uint16_t line=COUNTERS[1].value - vbl;if(IREG &1) { IREG=~1u;p->lines=line;vbl=COUNTERS[1].value;break;} uint32_t rise=s &~prev, fall=prev &~s;if((rise &0x80000000) &&p->b31Rise==NONE) p->b31Rise=line;if((fall &0x80000000) &&p->b31Fall==NONE) p->b31Fall=line;if((rise &0x2000) &&p->b13Rise==NONE) p->b13Rise=line;if((fall &0x2000) &&p->b13Fall==NONE) p->b13Fall=line;prev=s;} } for(int f=0;f< FIELDS;f++) { struct Field *p=&s_fields[f];ramsyscall_printf("field %d: lines=%d first=%08x b31 rise=%d fall=%d b13 rise=%d fall=%d\n", f, p->lines, p->firstStat, p->b31Rise, p->b31Fall, p->b13Rise, p->b13Fall);} } static int isLong(const struct Field *p) { return p->b31Rise !=NONE;}[FIELDS]) | |
| #define CESTER_NO_SIGNAL |
| #define CESTER_NO_TIME |
| #define EXIT_FAILURE 1 |
| #define EXIT_SUCCESS 0 |
| #define FIELDS 6 |
| #define NONE 0xffff |
| CESTER_BODY | ( | #define FIELDS #define NONE struct Field { uint32_t firstStat;uint16_t lines;uint16_t b31Rise, b31Fall, b13Rise, b13Fall;};static struct Field s_fields;static int s_interruptsWereEnabled;static void record(void) { GPU_STATUS=0x00000000;GPU_STATUS=0x06000000|0x260|(0xc60<< 12);GPU_STATUS=0x07000000|0x010|(0x100<< 10);GPU_STATUS=0x05000000;GPU_STATUS=0x08000027;GPU_STATUS=0x03000000;COUNTERS[1].mode=0x0100;IREG=~1u;while(!(IREG &1));IREG=~1u;uint16_t vbl=COUNTERS[1].value;for(int f=0;f< FIELDS;f++) { struct Field *p=&s_fields[f];p->b31Rise=p->b31Fall=p->b13Rise=p->b13Fall=NONE;uint32_t prev=GPU_STATUS;p->firstStat=prev;while(1) { uint32_t s=GPU_STATUS;uint16_t line=COUNTERS[1].value - vbl;if(IREG &1) { IREG=~1u;p->lines=line;vbl=COUNTERS[1].value;break;} uint32_t rise=s &~prev, fall=prev &~s;if((rise &0x80000000) &&p->b31Rise==NONE) p->b31Rise=line;if((fall &0x80000000) &&p->b31Fall==NONE) p->b31Fall=line;if((rise &0x2000) &&p->b13Rise==NONE) p->b13Rise=line;if((fall &0x2000) &&p->b13Fall==NONE) p->b13Fall=line;prev=s;} } for(int f=0;f< FIELDS;f++) { struct Field *p=&s_fields[f];ramsyscall_printf("field %d: lines=%d first=%08x b31 rise=%d fall=%d b13 rise=%d fall=%d\n", f, p->lines, p->firstStat, p->b31Rise, p->b31Fall, p->b13Rise, p->b13Fall);} } static int isLong(const struct Field *p) { return p->b31Rise !=NONE;} | [FIELDS] | ) |