clarify PicoDrive's license
[picodrive.git] / platform / common / emu.c
index 1e60925..8066796 100644 (file)
@@ -1,7 +1,10 @@
-// (c) Copyright 2006-2009 notaz, All rights reserved.\r
-// Free for non-commercial use.\r
-\r
-// For commercial use, separate licencing terms must be obtained.\r
+/*\r
+ * PicoDrive\r
+ * (C) notaz, 2007-2010\r
+ *\r
+ * This work is licensed under the terms of MAME license.\r
+ * See COPYING file in the top-level directory.\r
+ */\r
 \r
 #include <stdio.h>\r
 #include <stdlib.h>\r
 #include <unistd.h>\r
 #endif\r
 \r
+#include "../libpicofe/posix.h"\r
+#include "../libpicofe/input.h"\r
+#include "../libpicofe/fonts.h"\r
+#include "../libpicofe/lprintf.h"\r
+#include "../libpicofe/plat.h"\r
 #include "emu.h"\r
-#include "menu.h"\r
-#include "fonts.h"\r
-#include "lprintf.h"\r
+#include "input_pico.h"\r
+#include "menu_pico.h"\r
 #include "config.h"\r
-#include "plat.h"\r
-#include "input.h"\r
-#include "posix.h"\r
 \r
 #include <pico/pico_int.h>\r
 #include <pico/patch.h>\r
@@ -184,7 +188,7 @@ static int find_bios(int region, char **bios_file)
        } else {\r
                sprintf(static_buff, "no %s BIOS files found, read docs",\r
                        region != 4 ? (region == 8 ? "EU" : "JAP") : "USA");\r
-               me_update_msg(static_buff);\r
+               menu_update_msg(static_buff);\r
                return 0;\r
        }\r
 }\r
@@ -510,32 +514,32 @@ int emu_reload_rom(char *rom_fname)
                int dummy;\r
                FILE *movie_file = fopen(rom_fname, "rb");\r
                if (!movie_file) {\r
-                       me_update_msg("Failed to open movie.");\r
+                       menu_update_msg("Failed to open movie.");\r
                        return 0;\r
                }\r
                fseek(movie_file, 0, SEEK_END);\r
                movie_size = ftell(movie_file);\r
                fseek(movie_file, 0, SEEK_SET);\r
                if (movie_size < 64+3) {\r
-                       me_update_msg("Invalid GMV file.");\r
+                       menu_update_msg("Invalid GMV file.");\r
                        fclose(movie_file);\r
                        return 0;\r
                }\r
                movie_data = malloc(movie_size);\r
                if (movie_data == NULL) {\r
-                       me_update_msg("low memory.");\r
+                       menu_update_msg("low memory.");\r
                        fclose(movie_file);\r
                        return 0;\r
                }\r
                dummy = fread(movie_data, 1, movie_size, movie_file);\r
                fclose(movie_file);\r
                if (strncmp((char *)movie_data, "Gens Movie TEST", 15) != 0) {\r
-                       me_update_msg("Invalid GMV file.");\r
+                       menu_update_msg("Invalid GMV file.");\r
                        return 0;\r
                }\r
                dummy = try_rfn_cut(rom_fname) || try_rfn_cut(rom_fname);\r
                if (!dummy) {\r
-                       me_update_msg("Could't find a ROM for movie.");\r
+                       menu_update_msg("Could't find a ROM for movie.");\r
                        return 0;\r
                }\r
                get_ext(rom_fname, ext);\r
@@ -547,7 +551,7 @@ int emu_reload_rom(char *rom_fname)
                PicoPatchLoad(rom_fname);\r
                dummy = try_rfn_cut(rom_fname) || try_rfn_cut(rom_fname);\r
                if (!dummy) {\r
-                       me_update_msg("Could't find a ROM to patch.");\r
+                       menu_update_msg("Could't find a ROM to patch.");\r
                        return 0;\r
                }\r
                get_ext(rom_fname, ext);\r
@@ -555,7 +559,7 @@ int emu_reload_rom(char *rom_fname)
 \r
        media_type = detect_media(rom_fname);\r
        if (media_type == PM_BAD) {\r
-               me_update_msg("Not a ROM/CD img selected.");\r
+               menu_update_msg("Not a ROM/CD img selected.");\r
                return 0;\r
        }\r
 \r
@@ -590,7 +594,7 @@ int emu_reload_rom(char *rom_fname)
                        PicoAHW |= PAHW_MCD;\r
                }\r
                else {\r
-                       me_update_msg("Invalid CD image");\r
+                       menu_update_msg("Invalid CD image");\r
                        return 0;\r
                }\r
        }\r
@@ -601,7 +605,7 @@ int emu_reload_rom(char *rom_fname)
 \r
        rom = pm_open(used_rom_name);\r
        if (rom == NULL) {\r
-               me_update_msg("Failed to open ROM");\r
+               menu_update_msg("Failed to open ROM");\r
                return 0;\r
        }\r
 \r
@@ -611,9 +615,9 @@ int emu_reload_rom(char *rom_fname)
        ret = PicoCartLoad(rom, &rom_data, &rom_size, (PicoAHW & PAHW_SMS) ? 1 : 0);\r
        pm_close(rom);\r
        if (ret != 0) {\r
-               if      (ret == 2) me_update_msg("Out of memory");\r
-               else if (ret == 3) me_update_msg("Read failed");\r
-               else               me_update_msg("PicoCartLoad() failed.");\r
+               if      (ret == 2) menu_update_msg("Out of memory");\r
+               else if (ret == 3) menu_update_msg("Read failed");\r
+               else               menu_update_msg("PicoCartLoad() failed.");\r
                goto fail;\r
        }\r
 \r
@@ -629,7 +633,7 @@ int emu_reload_rom(char *rom_fname)
        }\r
 \r
        if (bad_rom) {\r
-               me_update_msg("Bad ROM detected.");\r
+               menu_update_msg("Bad ROM detected.");\r
                goto fail;\r
        }\r
 \r
@@ -643,7 +647,7 @@ int emu_reload_rom(char *rom_fname)
 \r
        emu_make_path(static_buff, "carthw.cfg", sizeof(static_buff));\r
        if (PicoCartInsert(rom_data, rom_size, static_buff)) {\r
-               me_update_msg("Failed to load ROM.");\r
+               menu_update_msg("Failed to load ROM.");\r
                goto fail;\r
        }\r
 \r
@@ -653,7 +657,7 @@ int emu_reload_rom(char *rom_fname)
                if (ret != 0) {\r
                        PicoCartUnload();\r
                        rom_data = NULL; // freed by unload\r
-                       me_update_msg("Insert_CD() failed, invalid CD image?");\r
+                       menu_update_msg("Insert_CD() failed, invalid CD image?");\r
                        goto fail;\r
                }\r
        }\r
@@ -716,7 +720,7 @@ int emu_swap_cd(const char *fname)
        if (cd_type != CIT_NOT_CD)\r
                ret = Insert_CD(fname, cd_type);\r
        if (ret != 0) {\r
-               me_update_msg("Load failed, invalid CD image?");\r
+               menu_update_msg("Load failed, invalid CD image?");\r
                return 0;\r
        }\r
 \r
@@ -1012,7 +1016,7 @@ char *emu_get_save_fname(int load, int is_sram, int slot)
        return NULL;\r
 }\r
 \r
-int emu_check_save_file(int slot)\r
+int emu_check_save_file(int slot, int *time)\r
 {\r
        return emu_get_save_fname(1, 0, slot) ? 1 : 0;\r
 }\r
@@ -1239,7 +1243,7 @@ static void run_events_ui(unsigned int which)
        if (which & (PEV_STATE_LOAD|PEV_STATE_SAVE))\r
        {\r
                int do_it = 1;\r
-               if ( emu_check_save_file(state_slot) &&\r
+               if ( emu_check_save_file(state_slot, NULL) &&\r
                        (((which & PEV_STATE_LOAD) && (currentConfig.confirm_save & EOPT_CONFIRM_LOAD)) ||\r
                         ((which & PEV_STATE_SAVE) && (currentConfig.confirm_save & EOPT_CONFIRM_SAVE))) )\r
                {\r
@@ -1258,13 +1262,13 @@ static void run_events_ui(unsigned int which)
                        plat_status_msg_busy_first(tmp);\r
 \r
                        in_set_config_int(0, IN_CFG_BLOCKING, 1);\r
-                       while (in_menu_wait_any(50) & (PBTN_MA3|PBTN_MBACK))\r
+                       while (in_menu_wait_any(NULL, 50) & (PBTN_MA3|PBTN_MBACK))\r
                                ;\r
-                       while ( !((keys = in_menu_wait_any(50)) & (PBTN_MA3|PBTN_MBACK)) )\r
+                       while ( !((keys = in_menu_wait_any(NULL, 50)) & (PBTN_MA3|PBTN_MBACK)) )\r
                                ;\r
                        if (keys & PBTN_MBACK)\r
                                do_it = 0;\r
-                       while (in_menu_wait_any(50) & (PBTN_MA3|PBTN_MBACK))\r
+                       while (in_menu_wait_any(NULL, 50) & (PBTN_MA3|PBTN_MBACK))\r
                                ;\r
                        in_set_config_int(0, IN_CFG_BLOCKING, 0);\r
                }\r
@@ -1292,7 +1296,7 @@ static void run_events_ui(unsigned int which)
                }\r
 \r
                emu_status_msg("SAVE SLOT %i [%s]", state_slot,\r
-                       emu_check_save_file(state_slot) ? "USED" : "FREE");\r
+                       emu_check_save_file(state_slot, NULL) ? "USED" : "FREE");\r
        }\r
        if (which & PEV_MENU)\r
                engineState = PGS_Menu;\r
@@ -1357,6 +1361,7 @@ void emu_cmn_forced_frame(int no_scale, int do_emu)
 \r
        memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4);\r
 \r
+       PicoOpt &= ~POPT_ALT_RENDERER;\r
        PicoOpt |= POPT_ACC_SPRITES;\r
        if (!no_scale)\r
                PicoOpt |= POPT_EN_SOFTSCALE;\r