X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fcd%2Fcdd.c;h=35edaa80ff4db97c8ac204e398384fb329ab6e98;hb=fda2f31020bf0d6cf7b5dd70ec01cf390b7e1483;hp=2e37b60e55e205a4dfd7d254aa77bcd348d85f01;hpb=7b3ddc11dc21025f2a64116d664c745c07c54984;p=picodrive.git diff --git a/pico/cd/cdd.c b/pico/cd/cdd.c index 2e37b60..35edaa8 100644 --- a/pico/cd/cdd.c +++ b/pico/cd/cdd.c @@ -122,12 +122,14 @@ static const uint32 toc_ffightj[29] = 14553, 9834, 10542, 1699, 1792, 1781, 3783, 3052 }; +#if 0 /* supported WAVE file header (16-bit stereo samples @44.1kHz) */ static const unsigned char waveHeader[32] = { 0x57,0x41,0x56,0x45,0x66,0x6d,0x74,0x20,0x10,0x00,0x00,0x00,0x01,0x00,0x02,0x00, 0x44,0xac,0x00,0x00,0x10,0xb1,0x02,0x00,0x04,0x00,0x10,0x00,0x64,0x61,0x74,0x61 }; +#endif #ifdef USE_LIBTREMOR #ifdef DISABLE_MANY_OGG_OPEN_FILES @@ -519,7 +521,7 @@ void cdd_read_audio(unsigned int samples) samples = blip_clocks_needed(blip[0], samples); /* audio track playing ? */ - if (!Pico_mcd->regs[0x36>>1].byte.h && cdd.toc.tracks[cdd.index].fd) + if (!Pico_mcd->s68k_regs[0x36+0] && cdd.toc.tracks[cdd.index].fd) { int i, mul, delta; @@ -720,7 +722,7 @@ void cdd_update(void) if (cdd.lba >= cdd.toc.tracks[cdd.index].start) { /* audio track playing */ - Pico_mcd->regs[0x36>>1].byte.h = 0x00; + Pico_mcd->s68k_regs[0x36+0] = 0x00; } /* audio blocks are still sent to CDC as well as CD DAC/Fader */ @@ -752,7 +754,7 @@ void cdd_update(void) cdd.index++; /* PAUSE between tracks */ - Pico_mcd->regs[0x36>>1].byte.h = 0x01; + Pico_mcd->s68k_regs[0x36+0] = 0x01; /* seek to next audio track start */ #ifdef USE_LIBTREMOR @@ -806,7 +808,7 @@ void cdd_update(void) /* AUDIO track playing ? */ if (cdd.status == CD_PLAY) { - Pico_mcd->regs[0x36>>1].byte.h = 0x00; + Pico_mcd->s68k_regs[0x36+0] = 0x00; } } else if (cdd.lba < cdd.toc.tracks[cdd.index].start) @@ -837,7 +839,7 @@ void cdd_update(void) else if (cdd.index >= cdd.toc.last) { /* no AUDIO track playing */ - Pico_mcd->regs[0x36>>1].byte.h = 0x01; + Pico_mcd->s68k_regs[0x36+0] = 0x01; /* end of disc */ cdd.index = cdd.toc.last; @@ -850,7 +852,7 @@ void cdd_update(void) if (!cdd.index) { /* no AUDIO track playing */ - Pico_mcd->regs[0x36>>1].byte.h = 0x01; + Pico_mcd->s68k_regs[0x36+0] = 0x01; /* DATA track */ pm_seek(cdd.toc.tracks[0].fd, cdd.lba * cdd.sectorSize, SEEK_SET); @@ -894,21 +896,21 @@ void cdd_update(void) void cdd_process(void) { /* Process CDD command */ - switch (Pico_mcd->regs[0x42>>1].byte.h & 0x0f) + switch (Pico_mcd->s68k_regs[0x42+0] & 0x0f) { case 0x00: /* Drive Status */ { /* RS1-RS8 normally unchanged */ - Pico_mcd->regs[0x38>>1].byte.h = cdd.status; + Pico_mcd->s68k_regs[0x38+0] = cdd.status; /* unless RS1 indicated invalid track infos */ - if (Pico_mcd->regs[0x38>>1].byte.l == 0x0f) + if (Pico_mcd->s68k_regs[0x38+1] == 0x0f) { /* and SEEK has ended */ if (cdd.status != CD_SEEK) { /* then return valid track infos, e.g current track number in RS2-RS3 (fixes Lunar - The Silver Star) */ - Pico_mcd->regs[0x38>>1].byte.l = 0x02; + Pico_mcd->s68k_regs[0x38+1] = 0x02; set_reg16(0x3a, (cdd.index < cdd.toc.last) ? lut_BCD_16[cdd.index + 1] : 0x0A0A); } } @@ -921,7 +923,7 @@ void cdd_process(void) cdd.status = cdd.loaded ? CD_STOP : NO_DISC; /* no audio track playing */ - Pico_mcd->regs[0x36>>1].byte.h = 0x01; + Pico_mcd->s68k_regs[0x36+0] = 0x01; /* RS1-RS8 ignored, expects 0x0 ("no disc" ?) in RS0 once */ set_reg16(0x38, 0x0000); @@ -939,7 +941,7 @@ void cdd_process(void) /* Infos automatically retrieved by CDD processor from Q-Channel */ /* commands 0x00-0x02 (current block) and 0x03-0x05 (Lead-In) */ - switch (Pico_mcd->regs[0x44>>1].byte.l) + switch (Pico_mcd->s68k_regs[0x44+1]) { case 0x00: /* Current Absolute Time (MM:SS:FF) */ { @@ -948,7 +950,7 @@ void cdd_process(void) set_reg16(0x3a, lut_BCD_16[(lba/75)/60]); set_reg16(0x3c, lut_BCD_16[(lba/75)%60]); set_reg16(0x3e, lut_BCD_16[(lba%75)]); - Pico_mcd->regs[0x40>>1].byte.h = cdd.index ? 0x00 : 0x04; /* Current block flags in RS8 (bit0 = mute status, bit1: pre-emphasis status, bit2: track type) */ + Pico_mcd->s68k_regs[0x40+0] = cdd.index ? 0x00 : 0x04; /* Current block flags in RS8 (bit0 = mute status, bit1: pre-emphasis status, bit2: track type) */ break; } @@ -959,7 +961,7 @@ void cdd_process(void) set_reg16(0x3a, lut_BCD_16[(lba/75)/60]); set_reg16(0x3c, lut_BCD_16[(lba/75)%60]); set_reg16(0x3e, lut_BCD_16[(lba%75)]); - Pico_mcd->regs[0x40>>1].byte.h = cdd.index ? 0x00 : 0x04; /* Current block flags in RS8 (bit0 = mute status, bit1: pre-emphasis status, bit2: track type) */ + Pico_mcd->s68k_regs[0x40+0] = cdd.index ? 0x00 : 0x04; /* Current block flags in RS8 (bit0 = mute status, bit1: pre-emphasis status, bit2: track type) */ break; } @@ -969,7 +971,7 @@ void cdd_process(void) set_reg16(0x3a, (cdd.index < cdd.toc.last) ? lut_BCD_16[cdd.index + 1] : 0x0A0A); set_reg16(0x3c, 0x0000); set_reg16(0x3e, 0x0000); /* Disk Control Code (?) in RS6 */ - Pico_mcd->regs[0x40>>1].byte.h = 0x00; + Pico_mcd->s68k_regs[0x40+0] = 0x00; break; } @@ -980,7 +982,7 @@ void cdd_process(void) set_reg16(0x3a, lut_BCD_16[(lba/75)/60]); set_reg16(0x3c, lut_BCD_16[(lba/75)%60]); set_reg16(0x3e, lut_BCD_16[(lba%75)]); - Pico_mcd->regs[0x40>>1].byte.h = 0x00; + Pico_mcd->s68k_regs[0x40+0] = 0x00; break; } @@ -990,23 +992,23 @@ void cdd_process(void) set_reg16(0x3a, 0x0001); set_reg16(0x3c, lut_BCD_16[cdd.toc.last]); set_reg16(0x3e, 0x0000); /* Drive Version (?) in RS6-RS7 */ - Pico_mcd->regs[0x40>>1].byte.h = 0x00; /* Lead-In flags in RS8 (bit0 = mute status, bit1: pre-emphasis status, bit2: track type) */ + Pico_mcd->s68k_regs[0x40+0] = 0x00; /* Lead-In flags in RS8 (bit0 = mute status, bit1: pre-emphasis status, bit2: track type) */ break; } case 0x05: /* Track Start Time (MM:SS:FF) */ { - int track = Pico_mcd->regs[0x46>>1].byte.h * 10 + Pico_mcd->regs[0x46>>1].byte.l; + int track = Pico_mcd->s68k_regs[0x46+0] * 10 + Pico_mcd->s68k_regs[0x46+1]; int lba = cdd.toc.tracks[track-1].start + 150; set_reg16(0x38, (cdd.status << 8) | 0x05); set_reg16(0x3a, lut_BCD_16[(lba/75)/60]); set_reg16(0x3c, lut_BCD_16[(lba/75)%60]); set_reg16(0x3e, lut_BCD_16[(lba%75)]); - Pico_mcd->regs[0x40>>1].byte.h = track % 10; /* Track Number (low digit) */ + Pico_mcd->s68k_regs[0x40+0] = track % 10; /* Track Number (low digit) */ if (track == 1) { /* RS6 bit 3 is set for the first (DATA) track */ - Pico_mcd->regs[0x3e>>1].byte.h |= 0x08; + Pico_mcd->s68k_regs[0x3e + 0] |= 0x08; } break; } @@ -1014,7 +1016,7 @@ void cdd_process(void) default: { #ifdef LOG_ERROR - error("Unknown CDD Command %02X (%X)\n", Pico_mcd->regs[0x44>>1].byte.l, s68k.pc); + error("Unknown CDD Command %02X (%X)\n", Pico_mcd->s68k_regs[0x44+1], s68k.pc); #endif return; } @@ -1028,9 +1030,9 @@ void cdd_process(void) int index = 0; /* new LBA position */ - int lba = ((Pico_mcd->regs[0x44>>1].byte.h * 10 + Pico_mcd->regs[0x44>>1].byte.l) * 60 + - (Pico_mcd->regs[0x46>>1].byte.h * 10 + Pico_mcd->regs[0x46>>1].byte.l)) * 75 + - (Pico_mcd->regs[0x48>>1].byte.h * 10 + Pico_mcd->regs[0x48>>1].byte.l) - 150; + int lba = ((Pico_mcd->s68k_regs[0x44+0] * 10 + Pico_mcd->s68k_regs[0x44+1]) * 60 + + (Pico_mcd->s68k_regs[0x46+0] * 10 + Pico_mcd->s68k_regs[0x46+1])) * 75 + + (Pico_mcd->s68k_regs[0x48+0] * 10 + Pico_mcd->s68k_regs[0x48+1]) - 150; /* CD drive latency */ if (!cdd.latency) @@ -1119,7 +1121,7 @@ void cdd_process(void) #endif /* no audio track playing (yet) */ - Pico_mcd->regs[0x36>>1].byte.h = 0x01; + Pico_mcd->s68k_regs[0x36+0] = 0x01; /* update status */ cdd.status = CD_PLAY; @@ -1129,7 +1131,7 @@ void cdd_process(void) set_reg16(0x3a, (cdd.index < cdd.toc.last) ? lut_BCD_16[index + 1] : 0x0A0A); set_reg16(0x3c, 0x0000); set_reg16(0x3e, 0x0000); - Pico_mcd->regs[0x40>>1].byte.h = 0x00; + Pico_mcd->s68k_regs[0x40+0] = 0x00; break; } @@ -1139,9 +1141,9 @@ void cdd_process(void) int index = 0; /* new LBA position */ - int lba = ((Pico_mcd->regs[0x44>>1].byte.h * 10 + Pico_mcd->regs[0x44>>1].byte.l) * 60 + - (Pico_mcd->regs[0x46>>1].byte.h * 10 + Pico_mcd->regs[0x46>>1].byte.l)) * 75 + - (Pico_mcd->regs[0x48>>1].byte.h * 10 + Pico_mcd->regs[0x48>>1].byte.l) - 150; + int lba = ((Pico_mcd->s68k_regs[0x44+0] * 10 + Pico_mcd->s68k_regs[0x44+1]) * 60 + + (Pico_mcd->s68k_regs[0x46+0] * 10 + Pico_mcd->s68k_regs[0x46+1])) * 75 + + (Pico_mcd->s68k_regs[0x48+0] * 10 + Pico_mcd->s68k_regs[0x48+1]) - 150; /* CD drive seek time */ /* We are using similar linear model as above, although still not exactly accurate, */ @@ -1213,7 +1215,7 @@ void cdd_process(void) #endif /* no audio track playing */ - Pico_mcd->regs[0x36>>1].byte.h = 0x01; + Pico_mcd->s68k_regs[0x36+0] = 0x01; /* update status */ cdd.status = CD_SEEK; @@ -1230,17 +1232,17 @@ void cdd_process(void) case 0x06: /* Pause */ { /* no audio track playing */ - Pico_mcd->regs[0x36>>1].byte.h = 0x01; + Pico_mcd->s68k_regs[0x36+0] = 0x01; /* update status (RS1-RS8 unchanged) */ - cdd.status = Pico_mcd->regs[0x38>>1].byte.h = CD_READY; + cdd.status = Pico_mcd->s68k_regs[0x38+0] = CD_READY; break; } case 0x07: /* Resume */ { /* update status (RS1-RS8 unchanged) */ - cdd.status = Pico_mcd->regs[0x38>>1].byte.h = CD_PLAY; + cdd.status = Pico_mcd->s68k_regs[0x38+0] = CD_PLAY; break; } @@ -1250,7 +1252,7 @@ void cdd_process(void) cdd.scanOffset = CD_SCAN_SPEED; /* update status (RS1-RS8 unchanged) */ - cdd.status = Pico_mcd->regs[0x38>>1].byte.h = CD_SCAN; + cdd.status = Pico_mcd->s68k_regs[0x38+0] = CD_SCAN; break; } @@ -1260,7 +1262,7 @@ void cdd_process(void) cdd.scanOffset = -CD_SCAN_SPEED; /* update status (RS1-RS8 unchanged) */ - cdd.status = Pico_mcd->regs[0x38>>1].byte.h = CD_SCAN; + cdd.status = Pico_mcd->s68k_regs[0x38+0] = CD_SCAN; break; } @@ -1273,17 +1275,17 @@ void cdd_process(void) /* also see US Patent nr. 5222054 for a detailled description of seeking operation using Track Jump */ /* no audio track playing */ - Pico_mcd->regs[0x36>>1].byte.h = 0x01; + Pico_mcd->s68k_regs[0x36+0] = 0x01; /* update status (RS1-RS8 unchanged) */ - cdd.status = Pico_mcd->regs[0x38>>1].byte.h = CD_READY; + cdd.status = Pico_mcd->s68k_regs[0x38+0] = CD_READY; break; } case 0x0c: /* Close Tray */ { /* no audio track playing */ - Pico_mcd->regs[0x36>>1].byte.h = 0x01; + Pico_mcd->s68k_regs[0x36+0] = 0x01; /* update status */ cdd.status = cdd.loaded ? CD_STOP : NO_DISC; @@ -1295,8 +1297,8 @@ void cdd_process(void) set_reg16(0x3e, 0x0000); set_reg16(0x40, 0x000f); - if (PicoMCDcloseTray) - PicoMCDcloseTray(); + if (PicoIn.mcdTrayClose) + PicoIn.mcdTrayClose(); return; } @@ -1304,7 +1306,7 @@ void cdd_process(void) case 0x0d: /* Open Tray */ { /* no audio track playing */ - Pico_mcd->regs[0x36>>1].byte.h = 0x01; + Pico_mcd->s68k_regs[0x36+0] = 0x01; /* update status (RS1-RS8 ignored) */ cdd.status = CD_OPEN; @@ -1314,8 +1316,8 @@ void cdd_process(void) set_reg16(0x3e, 0x0000); set_reg16(0x40, ~CD_OPEN & 0x0f); - if (PicoMCDopenTray) - PicoMCDopenTray(); + if (PicoIn.mcdTrayOpen) + PicoIn.mcdTrayOpen(); return; } @@ -1323,17 +1325,17 @@ void cdd_process(void) #ifdef LOG_CDD error("Unknown CDD Command !!!\n"); #endif - Pico_mcd->regs[0x38>>1].byte.h = cdd.status; + Pico_mcd->s68k_regs[0x38+0] = cdd.status; break; } /* only compute checksum when necessary */ - Pico_mcd->regs[0x40>>1].byte.l = - ~(Pico_mcd->regs[0x38>>1].byte.h + Pico_mcd->regs[0x38>>1].byte.l + - Pico_mcd->regs[0x3a>>1].byte.h + Pico_mcd->regs[0x3a>>1].byte.l + - Pico_mcd->regs[0x3c>>1].byte.h + Pico_mcd->regs[0x3c>>1].byte.l + - Pico_mcd->regs[0x3e>>1].byte.h + Pico_mcd->regs[0x3e>>1].byte.l + - Pico_mcd->regs[0x40>>1].byte.h) & 0x0f; + Pico_mcd->s68k_regs[0x40 + 1] = + ~(Pico_mcd->s68k_regs[0x38 + 0] + Pico_mcd->s68k_regs[0x38 + 1] + + Pico_mcd->s68k_regs[0x3a + 0] + Pico_mcd->s68k_regs[0x3a + 1] + + Pico_mcd->s68k_regs[0x3c + 0] + Pico_mcd->s68k_regs[0x3c + 1] + + Pico_mcd->s68k_regs[0x3e + 0] + Pico_mcd->s68k_regs[0x3e + 1] + + Pico_mcd->s68k_regs[0x40 + 0]) & 0x0f; } // vim:shiftwidth=2:ts=2:expandtab