38static inline uint32_t rgb24(uint8_t
r, uint8_t
g, uint8_t
b) {
39 return (uint32_t)
r | ((uint32_t)
g << 8) | ((uint32_t)
b << 16);
45static void drawDitherConstTri(uint32_t color24, int16_t x0, int16_t y0) {
47 rasterClearTestRegion(0, 0, 64, 64);
49 rasterGouraudTri(color24, x0, y0,
50 color24, (int16_t)(x0 + 31), y0,
51 color24, x0, (int16_t)(y0 + 31));
52 rasterFlushPrimitive();
60static void drawCanonicalAt(uint32_t color24) {
61 drawDitherConstTri(color24, 0, 0);
189 drawDitherConstTri(rgb24(128, 128, 128), 0, 0);
193 drawDitherConstTri(rgb24(128, 128, 128), 0, 4);
197 drawDitherConstTri(rgb24(128, 128, 128), 4, 0);
201 drawDitherConstTri(rgb24(128, 128, 128), 4, 4);
235CESTER_TEST(dt_sat_cross_under_r3_8_8, gpu_raster_phase11,
237 drawCanonicalAt(rgb24(0x03, 0, 0));
240CESTER_TEST(dt_sat_cross_under_r3_10_10, gpu_raster_phase11,
241 drawCanonicalAt(rgb24(0x03, 0, 0));
244CESTER_TEST(dt_sat_cross_land_r4_8_8, gpu_raster_phase11,
246 drawCanonicalAt(rgb24(0x04, 0, 0));
249CESTER_TEST(dt_sat_cross_over_r255_10_9, gpu_raster_phase11,
251 drawCanonicalAt(rgb24(0xff, 0, 0));
254CESTER_TEST(dt_sat_cross_over_r255_8_11, gpu_raster_phase11,
255 drawCanonicalAt(rgb24(0xff, 0, 0));
258CESTER_TEST(dt_sat_cross_land_r252_10_9, gpu_raster_phase11,
260 drawCanonicalAt(rgb24(0xfc, 0, 0));
CESTER_TEST(cddaLevelHalf, test_instances, static const uint8_t atv[4]={0x40, 0x00, 0x40, 0x00};unsigned changes=0;int peak=cddaPeak(atv, 1, &changes);ramsyscall_printf("CD-DA level at half ATV: peak %i, %u sign changes\n", peak, changes);cester_assert_int_ge(peak, 11300);cester_assert_int_le(peak, 11800);cester_assert_uint_ge(changes, 4);) CESTER_TEST(cddaLevelClipped
CESTER_BODY(static uint16_t s_cddaCapture;static int cddaSpuDma(uint32_t spuAddr, void *buf, uint32_t bytes, int isRead) { const uint16_t tsa=spuAddr > > 3;const uint16_t mode=isRead ? 0x30 :0x20;SPU_RAM_DTA=tsa;for(int i=0;i< 0xf01 &&SPU_RAM_DTA !=tsa;i++);SPU_CTRL=(SPU_CTRL &~0x30)|mode;for(volatile int i=0;i< 60;i++);for(int i=0;i< 0xf01 &&(SPU_STATUS &0x30) !=mode;i++);CDDA_SPU_DELAY=(CDDA_SPU_DELAY &0xf0ffffff)|(isRead ? 0x22000000 :0x20000000);DMA_CTRL[DMA_SPU].MADR=(uint32_t) buf &0x1fffffff;DMA_CTRL[DMA_SPU].BCR=((bytes > > 6)<< 16)|0x10;DMA_CTRL[DMA_SPU].CHCR=isRead ? 0x01000200 :0x01000201;int ok=0;for(unsigned t=0;t< 4000000u;t++) { if((DMA_CTRL[DMA_SPU].CHCR &0x01000000)==0) { ok=1;break;} } SPU_CTRL=SPU_CTRL &~0x30;for(volatile int i=0;i< 60;i++);return ok;} static int cddaSimpleCmd(uint8_t cmd) { uint8_t response[16];CDROM_REG0=0;CDROM_REG1=cmd;uint32_t timeout=2000000;int ok=waitCDRomIRQWithTimeout(&timeout);ackCDRomCause();readResponse(response);return ok;} static void cddaWaitPauseComplete() { initializeTime();uint32_t elapsed=0;while(elapsed< 5000000u) { uint32_t budget=200000u;int ok=waitCDRomIRQWithTimeout(&budget);elapsed=budget;if(!ok) continue;uint8_t cause=ackCDRomCause();uint8_t response[16];readResponse(response);if(cause==2) return;} } static int cddaAudioSetup(const uint8_t atv[4], int demute) { if(!resetCDRom()) return 0;DPCR|=0x000b0000;SPU_CTRL=0;for(volatile int i=0;i< 20000;i++);SPU_VOL_MAIN_LEFT=0;SPU_VOL_MAIN_RIGHT=0;SPU_KEY_OFF_LOW=0xffff;SPU_KEY_OFF_HIGH=0xffff;SPU_RAM_DTC=4;SPU_CTRL=0x8001;for(volatile int i=0;i< 20000;i++);for(int i=0;i< 0x400;i++) s_cddaCapture[i]=CDDA_MARKER;if(!cddaSpuDma(0x000, s_cddaCapture, 0x800, 0)) return 0;if(!cddaSimpleCmd(demute ? CDL_DEMUTE :CDL_MUTE)) return 0;CDROM_REG0=2;CDROM_REG2=atv[0];CDROM_REG3=atv[1];CDROM_REG0=3;CDROM_REG1=atv[2];CDROM_REG2=atv[3];CDROM_REG0=3;CDROM_REG3=0x20;CDROM_REG0=0;SPU_VOL_CD_LEFT=0x7fff;SPU_VOL_CD_RIGHT=0x7fff;SPU_CTRL=SPU_CTRL|0x8001;return 1;} static int cddaBufferPeak(unsigned *signChanges) { int peak=0;unsigned changes=0;int prev=0;for(int i=0;i< 0x200;i++) { int v=(int16_t) s_cddaCapture[i];int a=v< 0 ? -v :v;if(a > peak) peak=a;int sign=v >=0 ? 1 :-1;if(i &&sign !=prev) changes++;prev=sign;} *signChanges=changes;return peak;} static int cddaCapturePeak(unsigned *signChanges) { int peak=0;for(unsigned attempt=0;attempt< 8;attempt++) { if(attempt) { initializeTime();while(updateTime()< 250000u);} if(!cddaSpuDma(0x000, s_cddaCapture, 0x800, 1)) return -1;peak=cddaBufferPeak(signChanges);if(peak) { if(attempt) ramsyscall_printf("capture was empty %u time(s) before audio\n", attempt);break;} } return peak;} static int cddaPeak(const uint8_t atv[4], int demute, unsigned *signChanges) { if(!cddaAudioSetup(atv, demute)) return -1;if(!setMode(0)) return -1;CDROM_REG0=0;CDROM_REG2=0x02;if(!cddaSimpleCmd(CDL_PLAY)) return -1;initializeTime();while(updateTime()< 1500000u);int peak=cddaCapturePeak(signChanges);CDROM_REG0=0;CDROM_REG1=CDL_PAUSE;cddaWaitPauseComplete();CDROM_REG0=0;CDROM_REG2=0x00;CDROM_REG2=0x02;CDROM_REG2=0x16;if(cddaSimpleCmd(CDL_SETLOC) &&cddaSimpleCmd(CDL_SEEKL)) cddaWaitPauseComplete();return peak;}[0x400])
Definition cdda.c:37
uint32_t r
Definition cpu.c:310
uint8_t g
Definition gte-depthcue.c:40
uint8_t b
Definition gte-depthcue.c:41
#define DT_BAYER_MID_8_11
Definition raster-expected-phase11.h:94
#define DT_BASE_RC0_11_11
Definition raster-expected-phase11.h:155
#define DT_BAYER_MID_10_8
Definition raster-expected-phase11.h:84
#define DT_SAT_HIGH_RFC_8_8
Definition raster-expected-phase11.h:213
#define DT_BAYER_MID_11_11
Definition raster-expected-phase11.h:97
#define DT_POS_04_AT_16_16
Definition raster-expected-phase11.h:191
#define DT_SAT_CROSS_LAND_R252_10_9
Definition raster-expected-phase11.h:240
#define DT_BAYER_MID_10_11
Definition raster-expected-phase11.h:96
#define DT_CHAN_B80_11_8
Definition raster-expected-phase11.h:171
#define DT_BASE_R80_11_11
Definition raster-expected-phase11.h:138
#define DT_BASE_R40_8_11
Definition raster-expected-phase11.h:118
#define DT_BASE_R40_9_10
Definition raster-expected-phase11.h:115
#define DT_BAYER_MID_10_9
Definition raster-expected-phase11.h:88
#define DT_BASE_R40_9_9
Definition raster-expected-phase11.h:111
#define DT_BAYER_MID_10_10
Definition raster-expected-phase11.h:92
#define DT_BASE_R80_8_9
Definition raster-expected-phase11.h:127
#define DT_SAT_CROSS_UNDER_R3_8_8
Definition raster-expected-phase11.h:235
#define DT_BASE_R80_10_9
Definition raster-expected-phase11.h:129
#define DT_BASE_R40_10_9
Definition raster-expected-phase11.h:112
#define DT_BASE_R80_10_11
Definition raster-expected-phase11.h:137
#define DT_BASE_R40_9_11
Definition raster-expected-phase11.h:119
#define DT_BAYER_MID_9_8
Definition raster-expected-phase11.h:83
#define DT_BASE_R80_11_8
Definition raster-expected-phase11.h:126
#define DT_BASE_R40_11_11
Definition raster-expected-phase11.h:121
#define DT_BAYER_MID_11_8
Definition raster-expected-phase11.h:85
#define DT_BASE_R80_10_10
Definition raster-expected-phase11.h:133
#define DT_SAT_CROSS_UNDER_R3_10_10
Definition raster-expected-phase11.h:236
#define DT_SAT_HIGH_RFC_9_8
Definition raster-expected-phase11.h:214
#define DT_CHAN_G80_11_8
Definition raster-expected-phase11.h:166
#define DT_BASE_RC0_8_11
Definition raster-expected-phase11.h:152
#define DT_BASE_R40_11_10
Definition raster-expected-phase11.h:117
#define DT_BAYER_MID_8_9
Definition raster-expected-phase11.h:86
#define DT_BASE_R80_10_8
Definition raster-expected-phase11.h:125
#define DT_BASE_R40_10_11
Definition raster-expected-phase11.h:120
#define DT_BASE_R80_8_11
Definition raster-expected-phase11.h:135
#define DT_SAT_LOW_R04_8_8
Definition raster-expected-phase11.h:205
#define DT_BASE_RC0_9_8
Definition raster-expected-phase11.h:141
#define DT_BASE_R80_9_9
Definition raster-expected-phase11.h:128
#define DT_SAT_CROSS_OVER_R255_8_11
Definition raster-expected-phase11.h:239
#define DT_POS_40_AT_16_16
Definition raster-expected-phase11.h:192
#define DT_BASE_R40_11_9
Definition raster-expected-phase11.h:113
#define DT_CHAN_G80_8_8
Definition raster-expected-phase11.h:163
#define DT_BASE_R40_8_8
Definition raster-expected-phase11.h:106
#define DT_CHAN_G80_10_8
Definition raster-expected-phase11.h:165
#define DT_BAYER_MID_8_10
Definition raster-expected-phase11.h:90
#define DT_BASE_RC0_11_8
Definition raster-expected-phase11.h:143
#define DT_SAT_CROSS_OVER_R255_10_9
Definition raster-expected-phase11.h:238
#define DT_BASE_RC0_9_10
Definition raster-expected-phase11.h:149
#define DT_BASE_R40_11_8
Definition raster-expected-phase11.h:109
#define DT_BAYER_MID_9_9
Definition raster-expected-phase11.h:87
#define DT_BASE_RC0_10_9
Definition raster-expected-phase11.h:146
#define DT_CHAN_B80_10_8
Definition raster-expected-phase11.h:170
#define DT_SAT_HIGH_RFC_10_8
Definition raster-expected-phase11.h:215
#define DT_BASE_R40_8_10
Definition raster-expected-phase11.h:114
#define DT_BASE_RC0_8_9
Definition raster-expected-phase11.h:144
#define DT_BASE_R80_11_10
Definition raster-expected-phase11.h:134
#define DT_BASE_R40_10_8
Definition raster-expected-phase11.h:108
#define DT_BASE_R40_10_10
Definition raster-expected-phase11.h:116
#define DT_BAYER_MID_11_9
Definition raster-expected-phase11.h:89
#define DT_BASE_RC0_9_11
Definition raster-expected-phase11.h:153
#define DT_BASE_RC0_11_9
Definition raster-expected-phase11.h:147
#define DT_BASE_RC0_10_11
Definition raster-expected-phase11.h:154
#define DT_CHAN_B80_9_8
Definition raster-expected-phase11.h:169
#define DT_BASE_R80_9_11
Definition raster-expected-phase11.h:136
#define DT_SAT_LOW_R04_11_8
Definition raster-expected-phase11.h:208
#define DT_SAT_HIGH_RFC_11_8
Definition raster-expected-phase11.h:216
#define DT_CHAN_G80_9_8
Definition raster-expected-phase11.h:164
#define DT_BASE_RC0_10_8
Definition raster-expected-phase11.h:142
#define DT_CHAN_B80_8_8
Definition raster-expected-phase11.h:168
#define DT_BASE_R80_11_9
Definition raster-expected-phase11.h:130
#define DT_BASE_R40_9_8
Definition raster-expected-phase11.h:107
#define DT_POS_44_AT_16_16
Definition raster-expected-phase11.h:193
#define DT_BASE_RC0_11_10
Definition raster-expected-phase11.h:151
#define DT_SAT_CROSS_LAND_R4_8_8
Definition raster-expected-phase11.h:237
#define DT_BASE_R80_8_8
Definition raster-expected-phase11.h:123
#define DT_BASE_R80_8_10
Definition raster-expected-phase11.h:131
#define DT_BASE_RC0_9_9
Definition raster-expected-phase11.h:145
#define DT_BAYER_MID_9_10
Definition raster-expected-phase11.h:91
#define DT_BASE_R80_9_10
Definition raster-expected-phase11.h:132
#define DT_BAYER_MID_8_8
Definition raster-expected-phase11.h:82
#define DT_BASE_RC0_8_8
Definition raster-expected-phase11.h:140
#define DT_BASE_R40_8_9
Definition raster-expected-phase11.h:110
#define DT_BASE_RC0_8_10
Definition raster-expected-phase11.h:148
#define DT_SAT_LOW_R04_10_8
Definition raster-expected-phase11.h:207
#define DT_BAYER_MID_11_10
Definition raster-expected-phase11.h:93
#define DT_BAYER_MID_9_11
Definition raster-expected-phase11.h:95
#define DT_BASE_RC0_10_10
Definition raster-expected-phase11.h:150
#define DT_POS_00_AT_16_16
Definition raster-expected-phase11.h:190
#define DT_BASE_R80_9_8
Definition raster-expected-phase11.h:124
#define DT_SAT_LOW_R04_9_8
Definition raster-expected-phase11.h:206
#define ASSERT_PIXEL_EQ(expected, x_, y_)
Definition raster-helpers.h:473