cdd.lba = 0;
/* reset status */
- cdd.status = cdd.loaded ? CD_STOP : NO_DISC;
-
+ cdd.status = NO_DISC;
+
/* reset CD-DA fader (full volume) */
cdd.volume = 0x400;
/* CD loaded */
cdd.loaded = 1;
+
+ /* disc not scanned yet */
+ cdd.status = NO_DISC;
+
return 0;
}
/* CD unloaded */
cdd.loaded = 0;
+
+ if (cdd.status != CD_OPEN)
+ cdd.status = NO_DISC;
}
/* reset TOC */
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;
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 */
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
/* 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)
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;
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);
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);
}
}
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);
case 0x02: /* Read TOC */
{
+ if (cdd.status == NO_DISC)
+ cdd.status = cdd.loaded ? CD_STOP : NO_DISC;
+
/* 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) */
{
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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)
#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;
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;
}
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, */
#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;
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;
}
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;
}
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;
}
/* 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;
if (PicoMCDcloseTray)
PicoMCDcloseTray();
+
return;
}
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;
#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