From: notaz Date: Sun, 6 Oct 2013 22:39:53 +0000 (+0300) Subject: cd: hacks.. X-Git-Tag: v1.91~15 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=picodrive.git;a=commitdiff_plain;h=7b3ddc11dc21025f2a64116d664c745c07c54984 cd: hacks.. --- diff --git a/pico/cd/cdd.c b/pico/cd/cdd.c index 58a6053..2e37b60 100644 --- a/pico/cd/cdd.c +++ b/pico/cd/cdd.c @@ -163,8 +163,8 @@ void cdd_reset(void) 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; @@ -426,6 +426,10 @@ int cdd_load(const char *filename, int type) /* CD loaded */ cdd.loaded = 1; + + /* disc not scanned yet */ + cdd.status = NO_DISC; + return 0; } @@ -473,6 +477,9 @@ int cdd_unload(void) /* CD unloaded */ cdd.loaded = 0; + + if (cdd.status != CD_OPEN) + cdd.status = NO_DISC; } /* reset TOC */ @@ -927,6 +934,9 @@ void cdd_process(void) 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) @@ -1287,6 +1297,7 @@ void cdd_process(void) if (PicoMCDcloseTray) PicoMCDcloseTray(); + return; } diff --git a/pico/cd/mcd.c b/pico/cd/mcd.c index cad03e9..a20b01d 100644 --- a/pico/cd/mcd.c +++ b/pico/cd/mcd.c @@ -42,10 +42,8 @@ PICO_INTERNAL void PicoPowerMCD(void) memset(Pico_mcd->s68k_regs, 0, sizeof(Pico_mcd->s68k_regs)); memset(&Pico_mcd->pcm, 0, sizeof(Pico_mcd->pcm)); memset(&Pico_mcd->m, 0, sizeof(Pico_mcd->m)); - Pico_mcd->s68k_regs[0x38+9] = 0x0f; // default checksum cdc_init(); - cdd_reset(); gfx_init(); // cold reset state (tested) @@ -57,7 +55,7 @@ PICO_INTERNAL void PicoPowerMCD(void) void pcd_soft_reset(void) { - // Reset_CD(); // breaks Fahrenheit CD swap + elprintf(EL_CD, "cd: soft reset"); Pico_mcd->m.s68k_pend_ints = 0; cdc_reset(); @@ -66,6 +64,9 @@ void pcd_soft_reset(void) //PicoMemResetCDdecode(1); // don't have to call this in 2M mode #endif + memset(&Pico_mcd->s68k_regs[0x38], 0, 9); + Pico_mcd->s68k_regs[0x38+9] = 0x0f; // default checksum + pcd_event_schedule_s68k(PCD_EVENT_CDC, 12500000/75); // TODO: test if register state/timers change diff --git a/pico/cd/memory.c b/pico/cd/memory.c index 7d838fc..0551078 100644 --- a/pico/cd/memory.c +++ b/pico/cd/memory.c @@ -434,8 +434,23 @@ void s68k_reg_write8(u32 a, u32 d) return; } case 0x4b: - Pico_mcd->s68k_regs[a] = (u8) d; + Pico_mcd->s68k_regs[a] = 0; // (u8) d; ? cdd_process(); + { + static const char *nm[] = + { "stat", "stop", "read_toc", "play", + "seek", "???", "pause", "resume", + "ff", "fr", "tjump", "???", + "close","open", "???", "???" }; + u8 *c = &Pico_mcd->s68k_regs[0x42]; + u8 *s = &Pico_mcd->s68k_regs[0x38]; + elprintf(EL_CD, + "CDD command: %02x %02x %02x %02x %02x %02x %02x %02x %12s", + c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], nm[c[0] & 0x0f]); + elprintf(EL_CD, + "CDD status: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x", + s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8], s[9]); + } return; case 0x58: return; diff --git a/platform/common/menu_pico.c b/platform/common/menu_pico.c index 0f04bc4..306326b 100644 --- a/platform/common/menu_pico.c +++ b/platform/common/menu_pico.c @@ -1019,6 +1019,8 @@ static int main_menu_handler(int id, int keys) break; case MA_MAIN_CHANGE_CD: if (PicoAHW & PAHW_MCD) { + // if cd is loaded, cdd_unload() triggers eject and + // returns 1, else we'll select and load new CD here if (!cdd_unload()) menu_loop_tray(); return 1;