From: notaz Date: Mon, 10 Aug 2009 12:11:33 +0000 (+0000) Subject: move CD tray handling out of emu loop X-Git-Tag: v1.85~306 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d687ef50419fe4f286df866333a5425204e5b98e;p=picodrive.git move CD tray handling out of emu loop git-svn-id: file:///home/notaz/opt/svn/PicoDrive@743 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/pico/cd/cd_sys.c b/pico/cd/cd_sys.c index 32a94255..06cf3f83 100644 --- a/pico/cd/cd_sys.c +++ b/pico/cd/cd_sys.c @@ -208,7 +208,9 @@ int Insert_CD(const char *cdimg_name, int type) ret = Load_CD_Image(cdimg_name, type); if (ret == 0) { CD_Present = 1; - Pico_mcd->scd.Status_CDD = READY; + /* for open tray close command will handle Status_CDD */ + if (Pico_mcd->scd.Status_CDD != TRAY_OPEN) + Pico_mcd->scd.Status_CDD = READY; } } @@ -651,15 +653,12 @@ PICO_INTERNAL int Fast_Rewind_CDD_c9(void) PICO_INTERNAL int Close_Tray_CDD_cC(void) { - CD_Present = 0; - //Clear_Sound_Buffer(); - Pico_mcd->scd.Status_CDC &= ~1; // Stop CDC read elprintf(EL_STATUS, "tray close\n"); if (PicoMCDcloseTray != NULL) - CD_Present = PicoMCDcloseTray(); + PicoMCDcloseTray(); Pico_mcd->scd.Status_CDD = CD_Present ? STOPPED : NOCD; Pico_mcd->cdd.Status = 0x0000; diff --git a/pico/cd/pico.c b/pico/cd/pico.c index b0b123cb..f76a7f93 100644 --- a/pico/cd/pico.c +++ b/pico/cd/pico.c @@ -8,7 +8,7 @@ extern unsigned char formatted_bram[4*0x10]; extern unsigned int s68k_poll_adclk; void (*PicoMCDopenTray)(void) = NULL; -int (*PicoMCDcloseTray)(void) = NULL; +void (*PicoMCDcloseTray)(void) = NULL; PICO_INTERNAL void PicoInitMCD(void) diff --git a/pico/pico.h b/pico/pico.h index c3ada590..4940796d 100644 --- a/pico/pico.h +++ b/pico/pico.h @@ -78,7 +78,7 @@ void PicoGetInternal(pint_t which, pint_ret_t *ret); // cd/Pico.c extern void (*PicoMCDopenTray)(void); -extern int (*PicoMCDcloseTray)(void); +extern void (*PicoMCDcloseTray)(void); extern int PicoCDBuffers; // Pico/Pico.c diff --git a/platform/common/emu.c b/platform/common/emu.c index 167f2f09..2e813d3d 100644 --- a/platform/common/emu.c +++ b/platform/common/emu.c @@ -797,7 +797,8 @@ char *emu_get_save_fname(int load, int is_sram, int slot) if (is_sram) { - romfname_ext(saveFname, (PicoAHW&1) ? "brm"PATH_SEP : "srm"PATH_SEP, (PicoAHW&1) ? ".brm" : ".srm"); + romfname_ext(saveFname, (PicoAHW & PAHW_MCD) ? "brm"PATH_SEP : "srm"PATH_SEP, + (PicoAHW & PAHW_MCD) ? ".brm" : ".srm"); if (load) { if (try_ropen_file(saveFname)) return saveFname; // try in current dir.. @@ -989,9 +990,14 @@ void emu_set_fastforward(int set_on) } } -static void emu_msg_tray_open(void) +static void emu_tray_open(void) { - emu_status_msg("CD tray opened"); + engineState = PGS_TrayMenu; +} + +static void emu_tray_close(void) +{ + emu_status_msg("CD tray closed."); } void emu_reset_game(void) @@ -1213,8 +1219,8 @@ void emu_init(void) PicoInit(); PicoMessage = plat_status_msg_busy_next; - PicoMCDopenTray = emu_msg_tray_open; - PicoMCDcloseTray = menu_loop_tray; + PicoMCDopenTray = emu_tray_open; + PicoMCDcloseTray = emu_tray_close; } void emu_finish(void) diff --git a/platform/common/emu.h b/platform/common/emu.h index 2f5357af..f08d12ac 100644 --- a/platform/common/emu.h +++ b/platform/common/emu.h @@ -91,6 +91,7 @@ enum TPicoGameState { PGS_KeyConfig, PGS_ReloadRom, PGS_Menu, + PGS_TrayMenu, PGS_RestartRun, PGS_Suspending, /* PSP */ PGS_SuspendWake, /* PSP */ diff --git a/platform/common/main.c b/platform/common/main.c index bdcdc142..7a7c8767 100644 --- a/platform/common/main.c +++ b/platform/common/main.c @@ -104,6 +104,10 @@ int main(int argc, char *argv[]) menu_loop(); break; + case PGS_TrayMenu: + menu_loop_tray(); + break; + case PGS_ReloadRom: if (emu_reload_rom(rom_fname_reload)) engineState = PGS_Running; @@ -115,6 +119,7 @@ int main(int argc, char *argv[]) case PGS_RestartRun: engineState = PGS_Running; + /* vvv fallthrough */ case PGS_Running: emu_loop(); diff --git a/platform/common/menu.c b/platform/common/menu.c index b7f9e4d0..18c4a3fb 100644 --- a/platform/common/menu.c +++ b/platform/common/menu.c @@ -1985,8 +1985,7 @@ static int mh_tray_nothing(menu_id id, int keys) static menu_entry e_menu_tray[] = { - mee_label ("The unit is about to"), - mee_label ("close the CD tray."), + mee_label ("The CD tray has opened."), mee_label (""), mee_label (""), mee_handler("Load CD image", mh_tray_load_cd),