region detection, cd states wip, fixes, stuff
authornotaz <notasas@gmail.com>
Sun, 28 Jan 2007 22:51:16 +0000 (22:51 +0000)
committernotaz <notasas@gmail.com>
Sun, 28 Jan 2007 22:51:16 +0000 (22:51 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@25 be3aeb3a-fb24-0410-a615-afba39da0efa

gp2x/940ctl_ym2612.c
gp2x/Makefile
gp2x/emu.c
gp2x/emu.h
gp2x/menu.c
linux/940ctl_ym2612.c
linux/Makefile

index f1949e6..1352172 100644 (file)
@@ -27,6 +27,7 @@ static unsigned char *mp3_mem = 0;
 \r
 int crashed_940 = 0;\r
 \r
+static FILE *loaded_mp3 = 0;\r
 \r
 /***********************************************************/\r
 \r
@@ -380,6 +381,8 @@ void YM2612Init_940(int baseclock, int rate)
 \r
        internal_reset();\r
 \r
+       loaded_mp3 = 0;\r
+\r
        /* now cause 940 to init it's ym2612 stuff */\r
        shared_ctl->baseclock = baseclock;\r
        shared_ctl->rate = rate;\r
@@ -468,13 +471,12 @@ static void mix_samples(short *dest_buf, int *ym_buf, short *mp3_buf, int len, i
 \r
 // here we assume that length is different between games, but constant in one game\r
 \r
-static FILE *loaded_mp3 = 0;\r
+static int mp3_samples_ready = 0, mp3_buffer_offs = 0;\r
+static int mp3_play_bufsel = 0;\r
 \r
 void YM2612UpdateOne_940(short *buffer, int length, int stereo)\r
 {\r
        int cdda_on, *ym_buffer = shared_data->mix_buffer, mp3_job = 0;\r
-       static int mp3_samples_ready = 0, mp3_buffer_offs = 0;\r
-       static int mp3_play_bufsel = 1;\r
 \r
        //printf("YM2612UpdateOne_940()\n");\r
        if (shared_ctl->busy) wait_busy_940();\r
@@ -567,6 +569,10 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023
        printf("mp3 pos1024: %i, byte_offs %i/%i\n", pos, byte_offs, shared_ctl->mp3_len);\r
 \r
        shared_ctl->mp3_offs = byte_offs;\r
+\r
+       // reset buffer pointers..\r
+       mp3_samples_ready = mp3_buffer_offs = mp3_play_bufsel = 0;\r
+       shared_ctl->mp3_buffsel = 1; // will change to 0 on first decode\r
 }\r
 \r
 \r
index 7b41be9..d253dcc 100644 (file)
@@ -40,7 +40,8 @@ OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Utils.o ../../Pico/Memory
                ../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o\r
 # Pico - CD\r
 OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \\r
-               ../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o\r
+               ../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o \\r
+               ../../Pico/cd/Area.o ../../Pico/cd/Misc.o\r
 # asm stuff\r
 ifeq "$(asm_render)" "1"\r
 DEFINC += -D_ASM_DRAW_C\r
index dcc8f6e..17e7028 100644 (file)
@@ -456,6 +456,7 @@ int emu_ReadConfig(int game)
                currentConfig.PicoOpt = 0x0f | 0x200; // | use_940\r
                currentConfig.PsndRate = 44100;\r
                currentConfig.PicoRegion = 0; // auto\r
+               currentConfig.PicoAutoRgnOrder = 0x184; // US, EU, JP\r
                currentConfig.Frameskip = -1; // auto\r
                currentConfig.CPUclock = 200;\r
                currentConfig.volume = 50;\r
@@ -490,6 +491,7 @@ int emu_ReadConfig(int game)
        PicoOpt = currentConfig.PicoOpt;\r
        PsndRate = currentConfig.PsndRate;\r
        PicoRegionOverride = currentConfig.PicoRegion;\r
+       PicoAutoRgnOrder = currentConfig.PicoAutoRgnOrder;\r
        if (PicoOpt & 0x20) {\r
                actionNames[ 8] = "Z"; actionNames[ 9] = "Y";\r
                actionNames[10] = "X"; actionNames[11] = "MODE";\r
@@ -527,6 +529,7 @@ int emu_WriteConfig(int game)
                currentConfig.PicoOpt = PicoOpt;\r
                currentConfig.PsndRate = PsndRate;\r
                currentConfig.PicoRegion = PicoRegionOverride;\r
+               currentConfig.PicoAutoRgnOrder = PicoAutoRgnOrder;\r
                bwrite = fwrite(&currentConfig, 1, sizeof(currentConfig), f);\r
                fflush(f);\r
                fclose(f);\r
@@ -1231,6 +1234,7 @@ if (Pico.m.frame_count == 31563) {
 \r
        // save SRAM\r
        if((currentConfig.EmuOpt & 1) && SRam.changed) {\r
+               blit("", "Writing SRAM/BRAM..");\r
                emu_SaveLoadGame(0, 1);\r
                SRam.changed = 0;\r
        }\r
@@ -1321,14 +1325,16 @@ int emu_SaveLoadGame(int load, int sram)
                        if( (PmovFile = gzopen(saveFname, load ? "rb" : "wb")) ) {\r
                                areaRead  = gzRead2;\r
                                areaWrite = gzWrite2;\r
+                               areaEof   = (areaeof *) gzeof;\r
                                if(!load) gzsetparams(PmovFile, 9, Z_DEFAULT_STRATEGY);\r
                        } else\r
                                saveFname[strlen(saveFname)-3] = 0;\r
                }\r
                if(!PmovFile) { // gzip failed or was disabled\r
                        if( (PmovFile = fopen(saveFname, load ? "rb" : "wb")) ) {\r
-                               areaRead  = (STATE_SL_FUNC) fread;\r
-                               areaWrite = (STATE_SL_FUNC) fwrite;\r
+                               areaRead  = (arearw *) fread;\r
+                               areaWrite = (arearw *) fwrite;\r
+                               areaEof   = (areaeof *) feof;\r
                        }\r
                }\r
                if(PmovFile) {\r
index 3c90fdc..e5a7f30 100644 (file)
@@ -30,6 +30,7 @@ typedef struct {
        int volume;\r
        int gamma;\r
        int JoyBinds[4][32];\r
+       int PicoAutoRgnOrder;\r
 } currentConfig_t;\r
 \r
 extern char romFileName[];\r
index b771ee5..16c9ab5 100644 (file)
@@ -562,18 +562,6 @@ static void kc_sel_loop(void)
 \r
 \r
 \r
-// order must match that of currentConfig_t\r
-\r
-struct {\r
-       int EmuOpt;\r
-       int PicoOpt;\r
-       int PsndRate;\r
-       int PicoRegion;\r
-       int Frameskip;\r
-       int CPUclock;\r
-} tmp_opts;\r
-int tmp_gamma;\r
-\r
 // --------- sega/mega cd options ----------\r
 \r
 static void draw_cd_menu_options(int menu_sel, char *b_us, char *b_eu, char *b_jp)\r
@@ -585,8 +573,8 @@ static void draw_cd_menu_options(int menu_sel, char *b_us, char *b_eu, char *b_j
        gp2x_text_out8(tl_x, y,       "USA BIOS:     %s", b_us); // 0\r
        gp2x_text_out8(tl_x, (y+=10), "EUR BIOS:     %s", b_eu); // 1\r
        gp2x_text_out8(tl_x, (y+=10), "JAP BIOS:     %s", b_jp); // 2\r
-       gp2x_text_out8(tl_x, (y+=10), "CD LEDs                    %s", (tmp_opts.EmuOpt &0x400)?"ON":"OFF"); // 3\r
-       gp2x_text_out8(tl_x, (y+=10), "CDDA audio (using mp3s)    %s", (tmp_opts.EmuOpt &0x800)?"ON":"OFF"); // 4\r
+       gp2x_text_out8(tl_x, (y+=10), "CD LEDs                    %s", (currentConfig.EmuOpt &0x400)?"ON":"OFF"); // 3\r
+       gp2x_text_out8(tl_x, (y+=10), "CDDA audio (using mp3s)    %s", (currentConfig.EmuOpt &0x800)?"ON":"OFF"); // 4\r
        gp2x_text_out8(tl_x, (y+=10), "Done");\r
 \r
        // draw cursor\r
@@ -629,8 +617,8 @@ static void cd_menu_loop_options(void)
                if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
                if((inp& GP2X_B)||(inp&GP2X_LEFT)||(inp&GP2X_RIGHT)) { // toggleable options\r
                        switch (menu_sel) {\r
-                               case  3: tmp_opts.EmuOpt ^=0x400; break;\r
-                               case  4: tmp_opts.EmuOpt ^=0x800; break;\r
+                               case  3: currentConfig.EmuOpt ^=0x400; break;\r
+                               case  4: currentConfig.EmuOpt ^=0x800; break;\r
                                case  5: return;\r
                        }\r
                }\r
@@ -670,16 +658,16 @@ static void draw_amenu_options(int menu_sel)
 \r
        y = tl_y;\r
        memset(gp2x_screen, 0, 320*240);\r
-       gp2x_text_out8(tl_x, y,       "Scale 32 column mode       %s", (tmp_opts.PicoOpt&0x100)?"ON":"OFF"); // 0\r
-       gp2x_text_out8(tl_x, (y+=10), "Gamma correction           %i.%02i", tmp_gamma / 100, tmp_gamma%100); // 1\r
-       gp2x_text_out8(tl_x, (y+=10), "Emulate Z80                %s", (tmp_opts.PicoOpt&0x004)?"ON":"OFF"); // 2\r
-       gp2x_text_out8(tl_x, (y+=10), "Emulate YM2612 (FM)        %s", (tmp_opts.PicoOpt&0x001)?"ON":"OFF"); // 3\r
-       gp2x_text_out8(tl_x, (y+=10), "Emulate SN76496 (PSG)      %s", (tmp_opts.PicoOpt&0x002)?"ON":"OFF"); // 4\r
-       gp2x_text_out8(tl_x, (y+=10), "gzip savestates            %s", (tmp_opts.EmuOpt &0x008)?"ON":"OFF"); // 5\r
-       gp2x_text_out8(tl_x, (y+=10), "Don't save config on exit  %s", (tmp_opts.EmuOpt &0x020)?"ON":"OFF"); // 6\r
+       gp2x_text_out8(tl_x, y,       "Scale 32 column mode       %s", (currentConfig.PicoOpt&0x100)?"ON":"OFF"); // 0\r
+       gp2x_text_out8(tl_x, (y+=10), "Gamma correction           %i.%02i", currentConfig.gamma / 100, currentConfig.gamma%100); // 1\r
+       gp2x_text_out8(tl_x, (y+=10), "Emulate Z80                %s", (currentConfig.PicoOpt&0x004)?"ON":"OFF"); // 2\r
+       gp2x_text_out8(tl_x, (y+=10), "Emulate YM2612 (FM)        %s", (currentConfig.PicoOpt&0x001)?"ON":"OFF"); // 3\r
+       gp2x_text_out8(tl_x, (y+=10), "Emulate SN76496 (PSG)      %s", (currentConfig.PicoOpt&0x002)?"ON":"OFF"); // 4\r
+       gp2x_text_out8(tl_x, (y+=10), "gzip savestates            %s", (currentConfig.EmuOpt &0x008)?"ON":"OFF"); // 5\r
+       gp2x_text_out8(tl_x, (y+=10), "Don't save config on exit  %s", (currentConfig.EmuOpt &0x020)?"ON":"OFF"); // 6\r
        gp2x_text_out8(tl_x, (y+=10), "needs restart:");\r
-       gp2x_text_out8(tl_x, (y+=10), "craigix's RAM timings      %s", (tmp_opts.EmuOpt &0x100)?"ON":"OFF"); // 8\r
-       gp2x_text_out8(tl_x, (y+=10), "squidgehack (now %s %s",   mms, (tmp_opts.EmuOpt &0x010)?"ON":"OFF"); // 9\r
+       gp2x_text_out8(tl_x, (y+=10), "craigix's RAM timings      %s", (currentConfig.EmuOpt &0x100)?"ON":"OFF"); // 8\r
+       gp2x_text_out8(tl_x, (y+=10), "squidgehack (now %s %s",   mms, (currentConfig.EmuOpt &0x010)?"ON":"OFF"); // 9\r
        gp2x_text_out8(tl_x, (y+=10), "Done");\r
 \r
        // draw cursor\r
@@ -701,14 +689,14 @@ static void amenu_loop_options(void)
                if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
                if((inp& GP2X_B)||(inp&GP2X_LEFT)||(inp&GP2X_RIGHT)) { // toggleable options\r
                        switch (menu_sel) {\r
-                               case  0: tmp_opts.PicoOpt^=0x100; break;\r
-                               case  2: tmp_opts.PicoOpt^=0x004; break;\r
-                               case  3: tmp_opts.PicoOpt^=0x001; break;\r
-                               case  4: tmp_opts.PicoOpt^=0x002; break;\r
-                               case  5: tmp_opts.EmuOpt ^=0x008; break;\r
-                               case  6: tmp_opts.EmuOpt ^=0x020; break;\r
-                               case  8: tmp_opts.EmuOpt ^=0x100; break;\r
-                               case  9: tmp_opts.EmuOpt ^=0x010; break;\r
+                               case  0: currentConfig.PicoOpt^=0x100; break;\r
+                               case  2: currentConfig.PicoOpt^=0x004; break;\r
+                               case  3: currentConfig.PicoOpt^=0x001; break;\r
+                               case  4: currentConfig.PicoOpt^=0x002; break;\r
+                               case  5: currentConfig.EmuOpt ^=0x008; break;\r
+                               case  6: currentConfig.EmuOpt ^=0x020; break;\r
+                               case  8: currentConfig.EmuOpt ^=0x100; break;\r
+                               case  9: currentConfig.EmuOpt ^=0x010; break;\r
                                case 10: return;\r
                        }\r
                }\r
@@ -717,9 +705,9 @@ static void amenu_loop_options(void)
                        switch (menu_sel) {\r
                                case 1:\r
                                        while ((inp = gp2x_joystick_read(1)) & (GP2X_LEFT|GP2X_RIGHT)) {\r
-                                               tmp_gamma += (inp & GP2X_LEFT) ? -1 : 1;\r
-                                               if (tmp_gamma <   1) tmp_gamma =   1;\r
-                                               if (tmp_gamma > 300) tmp_gamma = 300;\r
+                                               currentConfig.gamma += (inp & GP2X_LEFT) ? -1 : 1;\r
+                                               if (currentConfig.gamma <   1) currentConfig.gamma =   1;\r
+                                               if (currentConfig.gamma > 300) currentConfig.gamma = 300;\r
                                                draw_amenu_options(menu_sel);\r
                                                usleep(18*1000);\r
                                        }\r
@@ -731,14 +719,26 @@ static void amenu_loop_options(void)
 \r
 // -------------- options --------------\r
 \r
-static char *region_name(unsigned int code)\r
+static const char *region_name(unsigned int code)\r
 {\r
-       char *names[] = { "Auto", "Japan NTSC", "Japan PAL", "USA", "Europe" };\r
-       int i = 0;\r
-       code <<= 1;\r
-       while((code >>=1)) i++;\r
-       if (i > 4) return "unknown";\r
-       return names[i];\r
+       static const char *names[] = { "Auto", "      Japan NTSC", "      Japan PAL", "      USA", "      Europe" };\r
+       static const char *names_short[] = { "", " JP", " JP", " US", " EU" };\r
+       int u, i = 0;\r
+       if (code) {\r
+               code <<= 1;\r
+               while((code >>= 1)) i++;\r
+               if (i > 4) return "unknown";\r
+               return names[i];\r
+       } else {\r
+               static char name[24];\r
+               strcpy(name, "Auto:");\r
+               for (u = 0; u < 3; u++) {\r
+                       i = 0; code = ((PicoAutoRgnOrder >> u*4) & 0xf) << 1;\r
+                       while((code >>= 1)) i++;\r
+                       strcat(name, names_short[i]);\r
+               }\r
+               return name;\r
+       }\r
 }\r
 \r
 static void draw_menu_options(int menu_sel)\r
@@ -746,13 +746,13 @@ static void draw_menu_options(int menu_sel)
        int tl_x = 25, tl_y = 40, y;\r
        char monostereo[8], strframeskip[8], *strrend;\r
 \r
-       strcpy(monostereo, (tmp_opts.PicoOpt&0x08)?"stereo":"mono");\r
-       if (tmp_opts.Frameskip < 0)\r
+       strcpy(monostereo, (currentConfig.PicoOpt&0x08)?"stereo":"mono");\r
+       if (currentConfig.Frameskip < 0)\r
                 strcpy(strframeskip, "Auto");\r
-       else sprintf(strframeskip, "%i", tmp_opts.Frameskip);\r
-       if (tmp_opts.PicoOpt&0x10) {\r
+       else sprintf(strframeskip, "%i", currentConfig.Frameskip);\r
+       if (currentConfig.PicoOpt&0x10) {\r
                strrend = " 8bit fast";\r
-       } else if (tmp_opts.EmuOpt&0x80) {\r
+       } else if (currentConfig.EmuOpt&0x80) {\r
                strrend = "16bit accurate";\r
        } else {\r
                strrend = " 8bit accurate";\r
@@ -761,19 +761,19 @@ static void draw_menu_options(int menu_sel)
        y = tl_y;\r
        memset(gp2x_screen, 0, 320*240);\r
        gp2x_text_out8(tl_x, y,       "Renderer:            %s", strrend); // 0\r
-       gp2x_text_out8(tl_x, (y+=10), "Accurate timing (slower)   %s", (tmp_opts.PicoOpt&0x040)?"ON":"OFF"); // 1\r
-       gp2x_text_out8(tl_x, (y+=10), "Accurate sprites (slower)  %s", (tmp_opts.PicoOpt&0x080)?"ON":"OFF"); // 2\r
-       gp2x_text_out8(tl_x, (y+=10), "Show FPS                   %s", (tmp_opts.EmuOpt &0x002)?"ON":"OFF"); // 3\r
+       gp2x_text_out8(tl_x, (y+=10), "Accurate timing (slower)   %s", (currentConfig.PicoOpt&0x040)?"ON":"OFF"); // 1\r
+       gp2x_text_out8(tl_x, (y+=10), "Accurate sprites (slower)  %s", (currentConfig.PicoOpt&0x080)?"ON":"OFF"); // 2\r
+       gp2x_text_out8(tl_x, (y+=10), "Show FPS                   %s", (currentConfig.EmuOpt &0x002)?"ON":"OFF"); // 3\r
        gp2x_text_out8(tl_x, (y+=10), "Frameskip                  %s", strframeskip);\r
-       gp2x_text_out8(tl_x, (y+=10), "Enable sound               %s", (tmp_opts.EmuOpt &0x004)?"ON":"OFF"); // 5\r
-       gp2x_text_out8(tl_x, (y+=10), "Sound Quality:     %5iHz %s", tmp_opts.PsndRate, monostereo);\r
-       gp2x_text_out8(tl_x, (y+=10), "Use ARM940 core for sound  %s", (tmp_opts.PicoOpt&0x200)?"ON":"OFF"); // 7\r
-       gp2x_text_out8(tl_x, (y+=10), "6 button pad               %s", (tmp_opts.PicoOpt&0x020)?"ON":"OFF"); // 8\r
-       gp2x_text_out8(tl_x, (y+=10), "Genesis Region:            %s", region_name(tmp_opts.PicoRegion));\r
-       gp2x_text_out8(tl_x, (y+=10), "Use SRAM/BRAM savestates   %s", (tmp_opts.EmuOpt &0x001)?"ON":"OFF"); // 10\r
-       gp2x_text_out8(tl_x, (y+=10), "Confirm save overwrites    %s", (tmp_opts.EmuOpt &0x200)?"ON":"OFF"); // 11\r
+       gp2x_text_out8(tl_x, (y+=10), "Enable sound               %s", (currentConfig.EmuOpt &0x004)?"ON":"OFF"); // 5\r
+       gp2x_text_out8(tl_x, (y+=10), "Sound Quality:     %5iHz %s",   currentConfig.PsndRate, monostereo);\r
+       gp2x_text_out8(tl_x, (y+=10), "Use ARM940 core for sound  %s", (currentConfig.PicoOpt&0x200)?"ON":"OFF"); // 7\r
+       gp2x_text_out8(tl_x, (y+=10), "6 button pad               %s", (currentConfig.PicoOpt&0x020)?"ON":"OFF"); // 8\r
+       gp2x_text_out8(tl_x, (y+=10), "Genesis Region:      %s",       region_name(currentConfig.PicoRegion));\r
+       gp2x_text_out8(tl_x, (y+=10), "Use SRAM/BRAM savestates   %s", (currentConfig.EmuOpt &0x001)?"ON":"OFF"); // 10\r
+       gp2x_text_out8(tl_x, (y+=10), "Confirm save overwrites    %s", (currentConfig.EmuOpt &0x200)?"ON":"OFF"); // 11\r
        gp2x_text_out8(tl_x, (y+=10), "Save slot                  %i", state_slot); // 12\r
-       gp2x_text_out8(tl_x, (y+=10), "GP2X CPU clocks            %iMhz", tmp_opts.CPUclock);\r
+       gp2x_text_out8(tl_x, (y+=10), "GP2X CPU clocks            %iMhz", currentConfig.CPUclock);\r
        gp2x_text_out8(tl_x, (y+=10), "[Sega/Mega CD options]");\r
        gp2x_text_out8(tl_x, (y+=10), "[advanced options]");            // 15\r
        gp2x_text_out8(tl_x, (y+=10), "Save cfg as default");\r
@@ -799,10 +799,32 @@ static int sndrate_prevnext(int rate, int dir)
        return rates[i];\r
 }\r
 \r
+static void region_prevnext(int right)\r
+{\r
+       // jp_ntsc=1, jp_pal=2, usa=4, eu=8\r
+       static int rgn_orders[] = { 0x148, 0x184, 0x814, 0x418, 0x841, 0x481 };\r
+       int i;\r
+       if (right) {\r
+               if (!currentConfig.PicoRegion) {\r
+                       for (i = 0; i < 6; i++)\r
+                               if (rgn_orders[i] == PicoAutoRgnOrder) break;\r
+                       if (i < 5) PicoAutoRgnOrder = rgn_orders[i+1];\r
+                       else currentConfig.PicoRegion=1;\r
+               }\r
+               else currentConfig.PicoRegion<<=1;\r
+               if (currentConfig.PicoRegion > 8) currentConfig.PicoRegion = 8;\r
+       } else {\r
+               if (!currentConfig.PicoRegion) {\r
+                       for (i = 0; i < 6; i++)\r
+                               if (rgn_orders[i] == PicoAutoRgnOrder) break;\r
+                       if (i > 0) PicoAutoRgnOrder = rgn_orders[i-1];\r
+               }\r
+               else currentConfig.PicoRegion>>=1;\r
+       }\r
+}\r
+\r
 static void menu_options_save(void)\r
 {\r
-       memcpy(&currentConfig.EmuOpt, &tmp_opts.EmuOpt, sizeof(tmp_opts));\r
-       currentConfig.gamma = tmp_gamma;\r
        PicoOpt = currentConfig.PicoOpt;\r
        PsndRate = currentConfig.PsndRate;\r
        PicoRegionOverride = currentConfig.PicoRegion;\r
@@ -820,11 +842,9 @@ static int menu_loop_options(void)
        unsigned long inp = 0;\r
 \r
        if (rom_data) menu_sel_max++;\r
-       memcpy(&tmp_opts.EmuOpt, &currentConfig.EmuOpt, sizeof(tmp_opts));\r
-       tmp_gamma = currentConfig.gamma;\r
-       tmp_opts.PicoOpt = PicoOpt;\r
-       tmp_opts.PsndRate = PsndRate;\r
-       tmp_opts.PicoRegion = PicoRegionOverride;\r
+       currentConfig.PicoOpt = PicoOpt;\r
+       currentConfig.PsndRate = PsndRate;\r
+       currentConfig.PicoRegion = PicoRegionOverride;\r
 \r
        for(;;)\r
        {\r
@@ -834,14 +854,14 @@ static int menu_loop_options(void)
                if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
                if((inp& GP2X_B)||(inp&GP2X_LEFT)||(inp&GP2X_RIGHT)) { // toggleable options\r
                        switch (menu_sel) {\r
-                               case  1: tmp_opts.PicoOpt^=0x040; break;\r
-                               case  2: tmp_opts.PicoOpt^=0x080; break;\r
-                               case  3: tmp_opts.EmuOpt ^=0x002; break;\r
-                               case  5: tmp_opts.EmuOpt ^=0x004; break;\r
-                               case  7: tmp_opts.PicoOpt^=0x200; break;\r
-                               case  8: tmp_opts.PicoOpt^=0x020; break;\r
-                               case 10: tmp_opts.EmuOpt ^=0x001; break;\r
-                               case 11: tmp_opts.EmuOpt ^=0x200; break;\r
+                               case  1: currentConfig.PicoOpt^=0x040; break;\r
+                               case  2: currentConfig.PicoOpt^=0x080; break;\r
+                               case  3: currentConfig.EmuOpt ^=0x002; break;\r
+                               case  5: currentConfig.EmuOpt ^=0x004; break;\r
+                               case  7: currentConfig.PicoOpt^=0x200; break;\r
+                               case  8: currentConfig.PicoOpt^=0x020; break;\r
+                               case 10: currentConfig.EmuOpt ^=0x001; break;\r
+                               case 11: currentConfig.EmuOpt ^=0x200; break;\r
                                case 14: cd_menu_loop_options();\r
                                        if (engineState == PGS_ReloadRom)\r
                                                return 0; // test BIOS\r
@@ -859,8 +879,7 @@ static int menu_loop_options(void)
                                        return 1;\r
                        }\r
                }\r
-               if(inp & GP2X_X) return 0;  // done (no update or write)\r
-               if(inp & GP2X_A) {\r
+               if(inp & (GP2X_X|GP2X_A)) {\r
                        menu_options_save();\r
                        return 0;  // done (update, no write)\r
                }\r
@@ -868,32 +887,29 @@ static int menu_loop_options(void)
                        switch (menu_sel) {\r
                                case  0:\r
                                        if (inp & GP2X_LEFT) {\r
-                                               if      (  tmp_opts.PicoOpt&0x10) tmp_opts.PicoOpt&= ~0x10;\r
-                                               else if (!(tmp_opts.EmuOpt &0x80))tmp_opts.EmuOpt |=  0x80;\r
-                                               else if (  tmp_opts.EmuOpt &0x80) break;\r
+                                               if      (  currentConfig.PicoOpt&0x10) currentConfig.PicoOpt&= ~0x10;\r
+                                               else if (!(currentConfig.EmuOpt &0x80))currentConfig.EmuOpt |=  0x80;\r
+                                               else if (  currentConfig.EmuOpt &0x80) break;\r
                                        } else {\r
-                                               if      (  tmp_opts.PicoOpt&0x10) break;\r
-                                               else if (!(tmp_opts.EmuOpt &0x80))tmp_opts.PicoOpt|=  0x10;\r
-                                               else if (  tmp_opts.EmuOpt &0x80) tmp_opts.EmuOpt &= ~0x80;\r
+                                               if      (  currentConfig.PicoOpt&0x10) break;\r
+                                               else if (!(currentConfig.EmuOpt &0x80))currentConfig.PicoOpt|=  0x10;\r
+                                               else if (  currentConfig.EmuOpt &0x80) currentConfig.EmuOpt &= ~0x80;\r
                                        }\r
                                        break;\r
                                case  4:\r
-                                       tmp_opts.Frameskip += (inp & GP2X_LEFT) ? -1 : 1;\r
-                                       if (tmp_opts.Frameskip < 0)  tmp_opts.Frameskip = -1;\r
-                                       if (tmp_opts.Frameskip > 32) tmp_opts.Frameskip = 32;\r
+                                       currentConfig.Frameskip += (inp & GP2X_LEFT) ? -1 : 1;\r
+                                       if (currentConfig.Frameskip < 0)  currentConfig.Frameskip = -1;\r
+                                       if (currentConfig.Frameskip > 32) currentConfig.Frameskip = 32;\r
                                        break;\r
                                case  6:\r
-                                       if ((inp & GP2X_RIGHT) && tmp_opts.PsndRate == 44100 && !(tmp_opts.PicoOpt&0x08)) {\r
-                                               tmp_opts.PsndRate = 8000;  tmp_opts.PicoOpt|= 0x08;\r
-                                       } else if ((inp & GP2X_LEFT) && tmp_opts.PsndRate == 8000 && (tmp_opts.PicoOpt&0x08)) {\r
-                                               tmp_opts.PsndRate = 44100; tmp_opts.PicoOpt&=~0x08;\r
-                                       } else tmp_opts.PsndRate = sndrate_prevnext(tmp_opts.PsndRate, inp & GP2X_RIGHT);\r
+                                       if ((inp & GP2X_RIGHT) && currentConfig.PsndRate == 44100 && !(currentConfig.PicoOpt&0x08)) {\r
+                                               currentConfig.PsndRate = 8000;  currentConfig.PicoOpt|= 0x08;\r
+                                       } else if ((inp & GP2X_LEFT) && currentConfig.PsndRate == 8000 && (currentConfig.PicoOpt&0x08)) {\r
+                                               currentConfig.PsndRate = 44100; currentConfig.PicoOpt&=~0x08;\r
+                                       } else currentConfig.PsndRate = sndrate_prevnext(currentConfig.PsndRate, inp & GP2X_RIGHT);\r
                                        break;\r
                                case  9:\r
-                                       if (inp & GP2X_RIGHT) {\r
-                                               if (tmp_opts.PicoRegion) tmp_opts.PicoRegion<<=1; else tmp_opts.PicoRegion=1;\r
-                                               if (tmp_opts.PicoRegion > 8) tmp_opts.PicoRegion = 8;\r
-                                       } else  tmp_opts.PicoRegion>>=1;\r
+                                       region_prevnext(inp & GP2X_RIGHT);\r
                                        break;\r
                                case 12:\r
                                        if (inp & GP2X_RIGHT) {\r
@@ -903,8 +919,8 @@ static int menu_loop_options(void)
                                        break;\r
                                case 13:\r
                                        while ((inp = gp2x_joystick_read(1)) & (GP2X_LEFT|GP2X_RIGHT)) {\r
-                                               tmp_opts.CPUclock += (inp & GP2X_LEFT) ? -1 : 1;\r
-                                               if (tmp_opts.CPUclock < 1) tmp_opts.CPUclock = 1;\r
+                                               currentConfig.CPUclock += (inp & GP2X_LEFT) ? -1 : 1;\r
+                                               if (currentConfig.CPUclock < 1) currentConfig.CPUclock = 1;\r
                                                draw_menu_options(menu_sel);\r
                                                usleep(50*1000);\r
                                        }\r
index b5263dc..4458a2f 100644 (file)
@@ -23,9 +23,9 @@ YM2612 *ym2612_940 = &ym2612;
 int  mix_buffer_[44100/50*2];  /* this is where the YM2612 samples will be mixed to */
 int *mix_buffer = mix_buffer_;
 
-static _940_data_t  shared_data_;
+// static _940_data_t  shared_data_;
 static _940_ctl_t   shared_ctl_;
-static _940_data_t *shared_data = &shared_data_;
+// static _940_data_t *shared_data = &shared_data_;
 static _940_ctl_t  *shared_ctl = &shared_ctl_;
 
 unsigned char *mp3_mem = 0;
index 6cce539..e8d740e 100644 (file)
@@ -30,7 +30,8 @@ OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Utils.o ../../Pico/Memory
                ../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o
 # Pico - CD
 OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \
-               ../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o
+               ../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o \
+               ../../Pico/cd/Area.o ../../Pico/cd/Misc.o
 # Pico - sound
 OBJS += ../../Pico/sound/sound.o ../../Pico/sound/sn76496.o ../../Pico/sound/ym2612.o
 # zlib