move CD tray handling out of emu loop
authornotaz <notasas@gmail.com>
Mon, 10 Aug 2009 12:11:33 +0000 (12:11 +0000)
committernotaz <notasas@gmail.com>
Mon, 10 Aug 2009 12:11:33 +0000 (12:11 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@743 be3aeb3a-fb24-0410-a615-afba39da0efa

pico/cd/cd_sys.c
pico/cd/pico.c
pico/pico.h
platform/common/emu.c
platform/common/emu.h
platform/common/main.c
platform/common/menu.c

index 32a9425..06cf3f8 100644 (file)
@@ -208,7 +208,9 @@ int Insert_CD(const char *cdimg_name, int type)
                ret = Load_CD_Image(cdimg_name, type);\r
                if (ret == 0) {\r
                        CD_Present = 1;\r
-                       Pico_mcd->scd.Status_CDD = READY;\r
+                       /* for open tray close command will handle Status_CDD */\r
+                       if (Pico_mcd->scd.Status_CDD != TRAY_OPEN)\r
+                               Pico_mcd->scd.Status_CDD = READY;\r
                }\r
        }\r
 \r
@@ -651,15 +653,12 @@ PICO_INTERNAL int Fast_Rewind_CDD_c9(void)
 \r
 PICO_INTERNAL int Close_Tray_CDD_cC(void)\r
 {\r
-       CD_Present = 0;\r
-       //Clear_Sound_Buffer();\r
-\r
        Pico_mcd->scd.Status_CDC &= ~1;                 // Stop CDC read\r
 \r
        elprintf(EL_STATUS, "tray close\n");\r
 \r
        if (PicoMCDcloseTray != NULL)\r
-               CD_Present = PicoMCDcloseTray();\r
+               PicoMCDcloseTray();\r
 \r
        Pico_mcd->scd.Status_CDD = CD_Present ? STOPPED : NOCD;\r
        Pico_mcd->cdd.Status = 0x0000;\r
index b0b123c..f76a7f9 100644 (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)
index c3ada59..4940796 100644 (file)
@@ -78,7 +78,7 @@ void PicoGetInternal(pint_t which, pint_ret_t *ret);
 \r
 // cd/Pico.c\r
 extern void (*PicoMCDopenTray)(void);\r
-extern int  (*PicoMCDcloseTray)(void);\r
+extern void (*PicoMCDcloseTray)(void);\r
 extern int PicoCDBuffers;\r
 \r
 // Pico/Pico.c\r
index 167f2f0..2e813d3 100644 (file)
@@ -797,7 +797,8 @@ char *emu_get_save_fname(int load, int is_sram, int slot)
 \r
        if (is_sram)\r
        {\r
-               romfname_ext(saveFname, (PicoAHW&1) ? "brm"PATH_SEP : "srm"PATH_SEP, (PicoAHW&1) ? ".brm" : ".srm");\r
+               romfname_ext(saveFname, (PicoAHW & PAHW_MCD) ? "brm"PATH_SEP : "srm"PATH_SEP,\r
+                               (PicoAHW & PAHW_MCD) ? ".brm" : ".srm");\r
                if (load) {\r
                        if (try_ropen_file(saveFname)) return saveFname;\r
                        // try in current dir..\r
@@ -989,9 +990,14 @@ void emu_set_fastforward(int set_on)
        }\r
 }\r
 \r
-static void emu_msg_tray_open(void)\r
+static void emu_tray_open(void)\r
 {\r
-       emu_status_msg("CD tray opened");\r
+       engineState = PGS_TrayMenu;\r
+}\r
+\r
+static void emu_tray_close(void)\r
+{\r
+       emu_status_msg("CD tray closed.");\r
 }\r
 \r
 void emu_reset_game(void)\r
@@ -1213,8 +1219,8 @@ void emu_init(void)
 \r
        PicoInit();\r
        PicoMessage = plat_status_msg_busy_next;\r
-       PicoMCDopenTray = emu_msg_tray_open;\r
-       PicoMCDcloseTray = menu_loop_tray;\r
+       PicoMCDopenTray = emu_tray_open;\r
+       PicoMCDcloseTray = emu_tray_close;\r
 }\r
 \r
 void emu_finish(void)\r
index 2f5357a..f08d12a 100644 (file)
@@ -91,6 +91,7 @@ enum TPicoGameState {
        PGS_KeyConfig,
        PGS_ReloadRom,
        PGS_Menu,
+       PGS_TrayMenu,
        PGS_RestartRun,
        PGS_Suspending,         /* PSP */
        PGS_SuspendWake,        /* PSP */
index bdcdc14..7a7c876 100644 (file)
@@ -104,6 +104,10 @@ int main(int argc, char *argv[])
                                menu_loop();\r
                                break;\r
 \r
+                       case PGS_TrayMenu:\r
+                               menu_loop_tray();\r
+                               break;\r
+\r
                        case PGS_ReloadRom:\r
                                if (emu_reload_rom(rom_fname_reload))\r
                                        engineState = PGS_Running;\r
@@ -115,6 +119,7 @@ int main(int argc, char *argv[])
 \r
                        case PGS_RestartRun:\r
                                engineState = PGS_Running;\r
+                               /* vvv fallthrough */\r
 \r
                        case PGS_Running:\r
                                emu_loop();\r
index b7f9e4d..18c4a3f 100644 (file)
@@ -1985,8 +1985,7 @@ static int mh_tray_nothing(menu_id id, int keys)
 \r
 static menu_entry e_menu_tray[] =\r
 {\r
-       mee_label  ("The unit is about to"),\r
-       mee_label  ("close the CD tray."),\r
+       mee_label  ("The CD tray has opened."),\r
        mee_label  (""),\r
        mee_label  (""),\r
        mee_handler("Load CD image",  mh_tray_load_cd),\r