improved game vidmode change detection; some iface changes
authornotaz <notasas@gmail.com>
Mon, 5 Oct 2009 15:59:08 +0000 (15:59 +0000)
committernotaz <notasas@gmail.com>
Mon, 5 Oct 2009 15:59:08 +0000 (15:59 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@803 be3aeb3a-fb24-0410-a615-afba39da0efa

common/emu.c
common/emu.h

index a8de902..370242d 100644 (file)
@@ -41,9 +41,11 @@ int pico_pen_x = 320/2, pico_pen_y = 240/2;
 int pico_inp_mode = 0;\r
 int engineState = PGS_Menu;\r
 \r
+/* tmp buff to reduce stack usage for plats with small stack */\r
+static char static_buff[512];\r
 /* TODO: len checking */\r
-char rom_fname_reload[512] = { 0, };\r
-char rom_fname_loaded[512] = { 0, };\r
+char rom_fname_reload[512];\r
+char rom_fname_loaded[512];\r
 int rom_loaded = 0;\r
 int reset_timing = 0;\r
 static unsigned int notice_msg_time;   /* when started showing */\r
@@ -113,7 +115,6 @@ static const char * const biosfiles_jp[] = { "jp_mcd1_9112", "jp_mcd1_9111" };
 \r
 static int find_bios(int region, char **bios_file)\r
 {\r
-       static char bios_path[1024];\r
        int i, count;\r
        const char * const *files;\r
        FILE *f = NULL;\r
@@ -133,26 +134,27 @@ static int find_bios(int region, char **bios_file)
 \r
        for (i = 0; i < count; i++)\r
        {\r
-               emu_make_path(bios_path, files[i], sizeof(bios_path) - 4);\r
-               strcat(bios_path, ".bin");\r
-               f = fopen(bios_path, "rb");\r
+               emu_make_path(static_buff, files[i], sizeof(static_buff) - 4);\r
+               strcat(static_buff, ".bin");\r
+               f = fopen(static_buff, "rb");\r
                if (f) break;\r
 \r
-               bios_path[strlen(bios_path) - 4] = 0;\r
-               strcat(bios_path, ".zip");\r
-               f = fopen(bios_path, "rb");\r
+               static_buff[strlen(static_buff) - 4] = 0;\r
+               strcat(static_buff, ".zip");\r
+               f = fopen(static_buff, "rb");\r
                if (f) break;\r
        }\r
 \r
        if (f) {\r
-               lprintf("using bios: %s\n", bios_path);\r
+               lprintf("using bios: %s\n", static_buff);\r
                fclose(f);\r
-               if (bios_file) *bios_file = bios_path;\r
+               if (bios_file)\r
+                       *bios_file = static_buff;\r
                return 1;\r
        } else {\r
-               sprintf(bios_path, "no %s BIOS files found, read docs",\r
+               sprintf(static_buff, "no %s BIOS files found, read docs",\r
                        region != 4 ? (region == 8 ? "EU" : "JAP") : "USA");\r
-               me_update_msg(bios_path);\r
+               me_update_msg(static_buff);\r
                return 0;\r
        }\r
 }\r
@@ -560,6 +562,7 @@ int emu_reload_rom(char *rom_fname)
        }\r
 \r
        menu_romload_prepare(used_rom_name); // also CD load\r
+       used_rom_name = NULL; // uses static_buff\r
 \r
        ret = PicoCartLoad(rom, &rom_data, &rom_size, (PicoAHW & PAHW_SMS) ? 1 : 0);\r
        pm_close(rom);\r
@@ -594,7 +597,8 @@ int emu_reload_rom(char *rom_fname)
                if (!ret) emu_read_config(0, 0);\r
        }\r
 \r
-       if (PicoCartInsert(rom_data, rom_size)) {\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
                goto fail;\r
        }\r
@@ -700,6 +704,7 @@ static void romfname_ext(char *dst, const char *prefix, const char *ext)
        if (ext) strcat(dst, ext);\r
 }\r
 \r
+// <base dir><end>\r
 void emu_make_path(char *buff, const char *end, int size)\r
 {\r
        int pos, end_len;\r
@@ -907,7 +912,7 @@ static int try_ropen_file(const char *fname)
 \r
 char *emu_get_save_fname(int load, int is_sram, int slot)\r
 {\r
-       static char saveFname[512];\r
+       char *saveFname = static_buff;\r
        char ext[16];\r
 \r
        if (is_sram)\r
@@ -1482,7 +1487,7 @@ void emu_loop(void)
                                pframes_done++; frames_done++;\r
                                diff_lim += target_frametime;\r
 \r
-                               if (!(currentConfig.EmuOpt & EOPT_NO_FRMLIMIT)) {\r
+                               if (!(currentConfig.EmuOpt & (EOPT_NO_FRMLIMIT|EOPT_EXT_FRMLIMIT))) {\r
                                        timestamp = get_ticks();\r
                                        diff = timestamp - timestamp_base;\r
                                        if (!reset_timing && diff < diff_lim) // we are too fast\r
@@ -1508,7 +1513,7 @@ void emu_loop(void)
                PicoFrame();\r
 \r
                /* frame limiter */\r
-               if (!reset_timing && !(currentConfig.EmuOpt & EOPT_NO_FRMLIMIT))\r
+               if (!reset_timing && !(currentConfig.EmuOpt & (EOPT_NO_FRMLIMIT|EOPT_EXT_FRMLIMIT)))\r
                {\r
                        timestamp = get_ticks();\r
                        diff = timestamp - timestamp_base;\r
index 5b695ef..b498488 100644 (file)
@@ -41,6 +41,7 @@ extern int g_screen_height;
 #define EOPT_SHOW_RTC     (1<<17)
 #define EOPT_NO_FRMLIMIT  (1<<18)
 #define EOPT_WIZ_TEAR_FIX (1<<19)
+#define EOPT_EXT_FRMLIMIT (1<<20) // no internal frame limiter (limited by snd, etc)
 
 enum {
        EOPT_SCALE_NONE = 0,