move CD tray handling out of emu loop

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@743 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2009-08-10 12:11:33 +00:00
parent c5c73e2fe4
commit d687ef5041
7 changed files with 24 additions and 14 deletions

View file

@ -208,6 +208,8 @@ int Insert_CD(const char *cdimg_name, int type)
ret = Load_CD_Image(cdimg_name, type);
if (ret == 0) {
CD_Present = 1;
/* 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;

View file

@ -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)

View file

@ -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

View file

@ -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)

View file

@ -91,6 +91,7 @@ enum TPicoGameState {
PGS_KeyConfig,
PGS_ReloadRom,
PGS_Menu,
PGS_TrayMenu,
PGS_RestartRun,
PGS_Suspending, /* PSP */
PGS_SuspendWake, /* PSP */

View file

@ -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();

View file

@ -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),