From: notaz <notasas@gmail.com>
Date: Mon, 10 Aug 2009 12:11:33 +0000 (+0000)
Subject: move CD tray handling out of emu loop
X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f4090a90a3d5337db985325f38c7de7ca757847;p=libpicofe.git

move CD tray handling out of emu loop

git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@743 be3aeb3a-fb24-0410-a615-afba39da0efa
---

diff --git a/common/emu.c b/common/emu.c
index 167f2f0..2e813d3 100644
--- a/common/emu.c
+++ b/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/common/emu.h b/common/emu.h
index 2f5357a..f08d12a 100644
--- a/common/emu.h
+++ b/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/common/main.c b/common/main.c
index bdcdc14..7a7c876 100644
--- a/common/main.c
+++ b/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/common/menu.c b/common/menu.c
index b7f9e4d..18c4a3f 100644
--- a/common/menu.c
+++ b/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),