X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fcd%2Fmcd.c;h=cad03e9f72969672aa10b2b0d38251157b6b0963;hb=274fcc35aa20e9777a8e09630a94088757384329;hp=24e99e4474b61eadb67ad31e04d90bd1888b538a;hpb=a6523294e28d7e6c119a578eb65b91af8da77f8d;p=picodrive.git diff --git a/pico/cd/mcd.c b/pico/cd/mcd.c index 24e99e4..cad03e9 100644 --- a/pico/cd/mcd.c +++ b/pico/cd/mcd.c @@ -22,13 +22,10 @@ void (*PicoMCDcloseTray)(void) = NULL; PICO_INTERNAL void PicoInitMCD(void) { SekInitS68k(); - Init_CD_Driver(); - gfx_init(); } PICO_INTERNAL void PicoExitMCD(void) { - End_CD_Driver(); } PICO_INTERNAL void PicoPowerMCD(void) @@ -45,8 +42,11 @@ 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 - Reset_CD(); + cdc_init(); + cdd_reset(); + gfx_init(); // cold reset state (tested) Pico_mcd->m.state_flags = PCD_ST_S68K_RST; @@ -59,7 +59,9 @@ void pcd_soft_reset(void) { // Reset_CD(); // breaks Fahrenheit CD swap - LC89510_Reset(); + Pico_mcd->m.s68k_pend_ints = 0; + cdc_reset(); + cdd_reset(); #ifdef _ASM_CD_MEMORY_C //PicoMemResetCDdecode(1); // don't have to call this in 2M mode #endif @@ -132,7 +134,20 @@ unsigned int pcd_cycles_m68k_to_s68k(unsigned int c) static void pcd_cdc_event(unsigned int now) { // 75Hz CDC update - Check_CD_Command(); + cdd_update(); + + /* check if a new CDD command has been processed */ + if (!(Pico_mcd->s68k_regs[0x4b] & 0xf0)) + { + /* reset CDD command wait flag */ + Pico_mcd->s68k_regs[0x4b] = 0xf0; + + if (Pico_mcd->s68k_regs[0x33] & PCDS_IEN4) { + elprintf(EL_INTS|EL_CD, "s68k: cdd irq 4"); + SekInterruptS68k(4); + } + } + pcd_event_schedule(now, PCD_EVENT_CDC, 12500000/75); } @@ -150,8 +165,7 @@ static void pcd_int3_timer_event(unsigned int now) static void pcd_dma_event(unsigned int now) { - int ddx = Pico_mcd->s68k_regs[4] & 7; - Update_CDC_TRansfer(ddx); + cdc_dma_update(); } typedef void (event_cb)(unsigned int now); @@ -355,9 +369,6 @@ void pcd_state_loaded(void) if (Pico_mcd->s68k_regs[0x31]) pcd_event_schedule(SekCycleAimS68k, PCD_EVENT_TIMER3, Pico_mcd->s68k_regs[0x31] * 384); - - if (Pico_mcd->scd.Status_CDC & 0x08) - Update_CDC_TRansfer(Pico_mcd->s68k_regs[4] & 7); } diff = cycles - Pico_mcd->pcm.update_cycles;