bugfixes, new scaling, double ym upd at 940
authornotaz <notasas@gmail.com>
Sat, 31 Mar 2007 13:57:45 +0000 (13:57 +0000)
committernotaz <notasas@gmail.com>
Sat, 31 Mar 2007 13:57:45 +0000 (13:57 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@83 be3aeb3a-fb24-0410-a615-afba39da0efa

gp2x/940ctl.c
gp2x/Makefile
gp2x/emu.c
gp2x/emu.h
gp2x/gp2x.c
gp2x/gp2x.h
gp2x/menu.c
gp2x/version.h
linux/Makefile
linux/gp2x.c
linux/port_config.h

index bcbb09b..f2e98a9 100644 (file)
@@ -66,8 +66,10 @@ static int   writebuff_ptr = 0;
 \r
 \r
 /* OPN Mode Register Write */\r
-static void set_timers( int v )\r
+static int set_timers( int v )\r
 {\r
+       int change;\r
+\r
        /* b7 = CSM MODE */\r
        /* b6 = 3 slot mode */\r
        /* b5 = reset b */\r
@@ -76,6 +78,7 @@ static void set_timers( int v )
        /* b2 = timer enable a */\r
        /* b1 = load b */\r
        /* b0 = load a */\r
+       change = (ST_mode ^ v) & 0xc0;\r
        ST_mode = v;\r
 \r
        /* reset Timer b flag */\r
@@ -85,6 +88,8 @@ static void set_timers( int v )
        /* reset Timer a flag */\r
        if( v & 0x10 )\r
                ST_status &= ~1;\r
+\r
+       return change;\r
 }\r
 \r
 /* YM2612 write */\r
@@ -93,11 +98,14 @@ static void set_timers( int v )
 /* returns 1 if sample affecting state changed */\r
 int YM2612Write_940(unsigned int a, unsigned int v)\r
 {\r
-       int addr; //, ret=1;\r
+       int addr;\r
+       int upd = 1;    /* the write affects sample generation */\r
 \r
        v &= 0xff;      /* adjust to 8 bit bus */\r
        a &= 3;\r
 \r
+       //printf("%05i:%03i: ym w ([%i] %02x)\n", Pico.m.frame_count, Pico.m.scanline, a, v);\r
+\r
        switch( a ) {\r
        case 0: /* address port 0 */\r
                if (!addr_A1 && ST_address == v)\r
@@ -108,7 +116,7 @@ int YM2612Write_940(unsigned int a, unsigned int v)
                        (v == 0x24 || v == 0x25 || v == 0x26 || v == 0x2a))\r
                                return 0;\r
                addr_A1 = 0;\r
-               //ret=0;\r
+               upd = 0;\r
                break;\r
 \r
        case 1: /* data port 0    */\r
@@ -152,14 +160,16 @@ int YM2612Write_940(unsigned int a, unsigned int v)
                                }\r
                                return 0;\r
                        case 0x27:      /* mode, timer control */\r
-                               set_timers( v );\r
-                               break; // other side needs ST.mode for 3slot mode\r
+                               if (set_timers( v ))\r
+                                       break; // other side needs ST.mode for 3slot mode\r
+                               return 0;\r
                        case 0x2a:      /* DAC data (YM2612) */\r
                                dacout = ((int)v - 0x80) << 6;  /* level unknown (notaz: 8 seems to be too much) */\r
                                return 0;\r
                        case 0x2b:      /* DAC Sel  (YM2612) */\r
                                /* b7 = dac enable */\r
                                dacen = v & 0x80;\r
+                               upd = 0;\r
                                break; // other side has to know this\r
                        default:\r
                                break;\r
@@ -173,7 +183,7 @@ int YM2612Write_940(unsigned int a, unsigned int v)
                        return 0;\r
                ST_address = v;\r
                addr_A1 = 1;\r
-               //ret=0;\r
+               upd = 0;\r
                break;\r
 \r
        case 3: /* data port 1    */\r
@@ -186,14 +196,25 @@ int YM2612Write_940(unsigned int a, unsigned int v)
                break;\r
        }\r
 \r
+       //printf("ym pass\n");\r
+\r
        if(currentConfig.EmuOpt & 4) {\r
-               /* queue this write for 940 */\r
-               if (writebuff_ptr < 2047) {\r
-                       if (shared_ctl->writebuffsel == 1) {\r
-                               shared_ctl->writebuff0[writebuff_ptr++] = (a<<8)|v;\r
-                       } else {\r
-                               shared_ctl->writebuff1[writebuff_ptr++] = (a<<8)|v;\r
+               UINT16 *writebuff = shared_ctl->writebuffsel ? shared_ctl->writebuff0 : shared_ctl->writebuff1;\r
+\r
+               /* detect rapid ym updates */\r
+               if (upd && !(writebuff_ptr & 0x80000000) && Pico.m.scanline < 224) {\r
+                       int mid = Pico.m.pal ? 68 : 93;\r
+                       if (Pico.m.scanline > mid) {\r
+                               //printf("%05i:%03i: rapid ym\n", Pico.m.frame_count, Pico.m.scanline);\r
+                               writebuff[writebuff_ptr++ & 0xffff] = 0xfffe;\r
+                               writebuff_ptr |= 0x80000000;\r
+                               //printf("%05i:%03i: ym w ([%02x] %02x, upd=%i)\n", Pico.m.frame_count, Pico.m.scanline, addr, v, upd);\r
                        }\r
+               }\r
+\r
+               /* queue this write for 940 */\r
+               if ((writebuff_ptr&0xffff) < 2047) {\r
+                       writebuff[writebuff_ptr++ & 0xffff] = (a<<8)|v;\r
                } else {\r
                        printf("warning: writebuff_ptr > 2047 ([%i] %02x)\n", a, v);\r
                }\r
@@ -301,7 +322,7 @@ void YM2612PicoStateLoad_940(void)
 \r
        addr_A1 = old_A1;\r
 \r
-       add_job_940(JOB940_PICOSTATELOAD);\r
+//     add_job_940(JOB940_PICOSTATELOAD);\r
 }\r
 \r
 \r
@@ -465,9 +486,9 @@ int YM2612UpdateOne_940(int *buffer, int length, int stereo, int is_buf_empty)
        else memset32(buffer, 0, length<<stereo);\r
 \r
        if (shared_ctl->writebuffsel == 1) {\r
-               shared_ctl->writebuff0[writebuff_ptr] = 0xffff;\r
+               shared_ctl->writebuff0[writebuff_ptr & 0xffff] = 0xffff;\r
        } else {\r
-               shared_ctl->writebuff1[writebuff_ptr] = 0xffff;\r
+               shared_ctl->writebuff1[writebuff_ptr & 0xffff] = 0xffff;\r
        }\r
        writebuff_ptr = 0;\r
 \r
index b045c2d..07f9992 100644 (file)
@@ -84,7 +84,8 @@ OBJS += mp3.o
 # CPU cores\r
 ifeq "$(use_musashi)" "1"\r
 DEFINC += -DEMU_M68K\r
-OBJS += _build\m68kcpu.o _build\m68kopac.o _build\m68kopdm.o _build\m68kopnz.o _build\m68kops.o\r
+OBJS += ../../cpu/musashi/m68kcpu.o ../../cpu/musashi/m68kopac.o ../../cpu/musashi/m68kopdm.o\r
+OBJS += ../../cpu/musashi/m68kopnz.o ../../cpu/musashi/m68kops.o\r
 else\r
 DEFINC += -DEMU_C68K\r
 OBJS += ../../cpu/Cyclone/proj/Cyclone.o\r
index f43f9b7..99357b2 100644 (file)
@@ -63,21 +63,7 @@ unsigned char *framebuff = 0;  // temporary buffer for alt renderer
 int state_slot = 0;\r
 int reset_timing = 0;\r
 \r
-/*\r
-// tmp\r
-static FILE *logf = NULL;\r
 \r
-void pprintf(char *texto, ...)\r
-{\r
-       va_list args;\r
-\r
-       va_start(args,texto);\r
-       vfprintf(logf,texto,args);\r
-       va_end(args);\r
-       fflush(logf);\r
-       sync();\r
-}\r
-*/\r
 // utilities\r
 static void strlwr(char* string)\r
 {\r
@@ -467,6 +453,18 @@ static void find_combos(void)
 }\r
 \r
 \r
+void scaling_update(void)\r
+{\r
+       PicoOpt &= ~0x4100;\r
+       switch (currentConfig.scaling) {\r
+               default: break; // off\r
+               case 1:  // hw hor\r
+               case 2:  PicoOpt |=  0x0100; break; // hw hor+vert\r
+               case 3:  PicoOpt |=  0x4000; break; // sw hor\r
+       }\r
+}\r
+\r
+\r
 int emu_ReadConfig(int game)\r
 {\r
        FILE *f;\r
@@ -501,6 +499,7 @@ int emu_ReadConfig(int game)
                currentConfig.KeyBinds[22] = 1<<30; // vol down\r
                currentConfig.gamma = 100;\r
                currentConfig.PicoCDBuffers = 64;\r
+               currentConfig.scaling = 0;\r
                strncpy(cfg, PicoConfigFile, 511);\r
                cfg[511] = 0;\r
        } else {\r
@@ -516,7 +515,7 @@ int emu_ReadConfig(int game)
                bread = fread(&currentConfig, 1, sizeof(currentConfig), f);\r
                fclose(f);\r
        }\r
-       printf((bread == sizeof(currentConfig)) ? "(ok)\n" : "(failed)\n");\r
+       printf(bread > 0 ? "(ok)\n" : "(failed)\n");\r
 \r
        PicoOpt = currentConfig.PicoOpt;\r
        PsndRate = currentConfig.PsndRate;\r
@@ -527,6 +526,7 @@ int emu_ReadConfig(int game)
                actionNames[ 8] = "Z"; actionNames[ 9] = "Y";\r
                actionNames[10] = "X"; actionNames[11] = "MODE";\r
        }\r
+       scaling_update();\r
        // some sanity checks\r
        if (currentConfig.CPUclock < 1 || currentConfig.CPUclock > 4096) currentConfig.CPUclock = 200;\r
        if (currentConfig.gamma < 10 || currentConfig.gamma > 300) currentConfig.gamma = 100;\r
@@ -536,7 +536,7 @@ int emu_ReadConfig(int game)
                currentConfig.KeyBinds[22] = 1<<30; // vol down\r
        }\r
 \r
-       return (bread == sizeof(currentConfig));\r
+       return (bread > 0); // == sizeof(currentConfig));\r
 }\r
 \r
 \r
@@ -565,7 +565,9 @@ int emu_WriteConfig(int game)
                bwrite = fwrite(&currentConfig, 1, sizeof(currentConfig), f);\r
                fflush(f);\r
                fclose(f);\r
+#ifndef NO_SYNC\r
                sync();\r
+#endif\r
        }\r
        printf((bwrite == sizeof(currentConfig)) ? "(ok)\n" : "(failed)\n");\r
 \r
@@ -581,8 +583,23 @@ void emu_Deinit(void)
                SRam.changed = 0;\r
        }\r
 \r
-       if (!(currentConfig.EmuOpt & 0x20))\r
-               emu_WriteConfig(0);\r
+       if (!(currentConfig.EmuOpt & 0x20)) {\r
+               FILE *f = fopen(PicoConfigFile, "r+b");\r
+               if (!f) emu_WriteConfig(0);\r
+               else {\r
+                       // if we already have config, reload it, except last ROM\r
+                       fseek(f, sizeof(currentConfig.lastRomFile), SEEK_SET);\r
+                       fread(&currentConfig.EmuOpt, 1, sizeof(currentConfig) - sizeof(currentConfig.lastRomFile), f);\r
+                       fseek(f, 0, SEEK_SET);\r
+                       fwrite(&currentConfig, 1, sizeof(currentConfig), f);\r
+                       fflush(f);\r
+                       fclose(f);\r
+#ifndef NO_SYNC\r
+                       sync();\r
+#endif\r
+               }\r
+       }\r
+\r
        free(framebuff);\r
 \r
        PicoExit();\r
@@ -706,9 +723,13 @@ static void blit(const char *fps, const char *notice)
                }\r
        }\r
 \r
-       if (notice) osd_text(4, 232, notice);\r
-       if (emu_opt & 2)\r
-               osd_text(osd_fps_x, 232, fps);\r
+       if (notice || (emu_opt & 2)) {\r
+               int h = 232;\r
+               if (currentConfig.scaling == 2 && !(Pico.video.reg[1]&8)) h -= 8;\r
+               if (notice) osd_text(4, h, notice);\r
+               if (emu_opt & 2)\r
+                       osd_text(osd_fps_x, h, fps);\r
+       }\r
        if ((emu_opt & 0x400) && (PicoMCD & 1))\r
                cd_leds();\r
 \r
@@ -771,7 +792,9 @@ static void vidResetMode(void)
        }\r
        Pico.m.dirtyPal = 1;\r
        // reset scaling\r
-       gp2x_video_RGB_setscaling((PicoOpt&0x100)&&!(Pico.video.reg[12]&1) ? 256 : 320, 240);\r
+       if (currentConfig.scaling == 2 && !(Pico.video.reg[1]&8))\r
+            gp2x_video_RGB_setscaling(8, (PicoOpt&0x100)&&!(Pico.video.reg[12]&1) ? 256 : 320, 224);\r
+       else gp2x_video_RGB_setscaling(0, (PicoOpt&0x100)&&!(Pico.video.reg[12]&1) ? 256 : 320, 240);\r
 }\r
 \r
 \r
@@ -1133,7 +1156,9 @@ void emu_Loop(void)
                                        vidCpyM2 = vidCpyM2_32col;\r
                                }\r
                        }\r
-                       gp2x_video_RGB_setscaling(scalex, 240);\r
+                       if (currentConfig.scaling == 2 && !(modes&8)) // want vertical scaling and game is not in 240 line mode\r
+                            gp2x_video_RGB_setscaling(8, scalex, 224);\r
+                       else gp2x_video_RGB_setscaling(0, scalex, 240);\r
                        oldmodes = modes;\r
                        clearArea(1);\r
                }\r
@@ -1171,7 +1196,7 @@ void emu_Loop(void)
                                if (frames_shown > frames_done) frames_shown = frames_done;\r
                        }\r
                }\r
-#if 0\r
+#if 1\r
                sprintf(fpsbuff, "%05i", Pico.m.frame_count);\r
 #endif\r
                lim_time = (frames_done+1) * target_frametime;\r
@@ -1446,7 +1471,9 @@ int emu_SaveLoadGame(int load, int sram)
                                ret = fwrite(sram_data, 1, sram_size, sramFile);\r
                                ret = (ret != sram_size) ? -1 : 0;\r
                                fclose(sramFile);\r
+#ifndef NO_SYNC\r
                                sync();\r
+#endif\r
                        }\r
                }\r
                return ret;\r
@@ -1470,8 +1497,10 @@ int emu_SaveLoadGame(int load, int sram)
                        ret = PmovState(load ? 6 : 5, PmovFile);\r
                        areaClose(PmovFile);\r
                        PmovFile = 0;\r
-                       if (!load) sync();\r
-                       else Pico.m.dirtyPal=1;\r
+                       if (load) Pico.m.dirtyPal=1;\r
+#ifndef NO_SYNC\r
+                       else sync();\r
+#endif\r
                }\r
                else    ret = -1;\r
                if (!ret)\r
index f5dcee3..b487c51 100644 (file)
@@ -18,7 +18,7 @@ enum TPicoGameState {
 typedef struct {\r
        char lastRomFile[512];\r
        int EmuOpt;             // LSb->MSb: use_sram, show_fps, enable_sound, gzip_saves,\r
-                                       // squidgehack, save_cfg_on_exit, <unused>, 16_bit_mode\r
+                                       // squidgehack, no_save_cfg_on_exit, <unused>, 16_bit_mode\r
                                        // craigix_ram, confirm_save, show_cd_leds\r
                                        //\r
        int PicoOpt;  // used for config saving only, see Pico.h\r
@@ -32,6 +32,7 @@ typedef struct {
        int JoyBinds[4][32];\r
        int PicoAutoRgnOrder;\r
        int PicoCDBuffers;\r
+       int scaling; // 0=center, 1=hscale, 2=hvscale, 3=hsoftscale\r
 } currentConfig_t;\r
 \r
 extern char romFileName[];\r
@@ -52,4 +53,5 @@ int  emu_check_save_file(int slot);
 void emu_set_save_cbs(int gz);\r
 void emu_forced_frame(void);\r
 int  find_bios(int region, char **bios_file);\r
+void scaling_update(void);\r
 \r
index 28c0a93..f138be6 100644 (file)
@@ -52,19 +52,21 @@ void *gp2x_screen;
 #define FRAMEBUFF_ADDR2 (FRAMEBUFF_ADDR1+0x30000)\r
 #define FRAMEBUFF_ADDR3 (FRAMEBUFF_ADDR2+0x30000)\r
 \r
-static const int gp2x_screenaddrs[] = { FRAMEBUFF_ADDR0, FRAMEBUFF_ADDR1, FRAMEBUFF_ADDR2, FRAMEBUFF_ADDR3 };\r
+static const int gp2x_screenaddrs[4] = { FRAMEBUFF_ADDR0, FRAMEBUFF_ADDR1, FRAMEBUFF_ADDR2, FRAMEBUFF_ADDR3 };\r
+static int gp2x_screenaddrs_use[4];\r
 static unsigned short gp2x_screenaddr_old[4];\r
 \r
 \r
 /* video stuff */\r
 void gp2x_video_flip(void)\r
 {\r
-       unsigned short msw = (unsigned short)(gp2x_screenaddrs[screensel&3] >> 16);\r
+       unsigned short lsw = (unsigned short) gp2x_screenaddrs_use[screensel&3];\r
+       unsigned short msw = (unsigned short)(gp2x_screenaddrs_use[screensel&3] >> 16);\r
 \r
        gp2x_memregs[0x2910>>1] = msw;\r
        gp2x_memregs[0x2914>>1] = msw;\r
-       gp2x_memregs[0x290E>>1] = 0;\r
-       gp2x_memregs[0x2912>>1] = 0;\r
+       gp2x_memregs[0x290E>>1] = lsw;\r
+       gp2x_memregs[0x2912>>1] = lsw;\r
 \r
        // jump to other buffer:\r
        gp2x_screen = gp2x_screens[++screensel&3];\r
@@ -73,7 +75,7 @@ void gp2x_video_flip(void)
 /* doulblebuffered flip */\r
 void gp2x_video_flip2(void)\r
 {\r
-       unsigned short msw = (unsigned short)(gp2x_screenaddrs[screensel&1] >> 16);\r
+       unsigned short msw = (unsigned short)(gp2x_screenaddrs_use[screensel&1] >> 16);\r
 \r
        gp2x_memregs[0x2910>>1] = msw;\r
        gp2x_memregs[0x2914>>1] = msw;\r
@@ -113,10 +115,17 @@ void gp2x_video_setpalette(int *pal, int len)
 \r
 \r
 // TV Compatible function //\r
-void gp2x_video_RGB_setscaling(int W, int H)\r
+void gp2x_video_RGB_setscaling(int ln_offs, int W, int H)\r
 {\r
        float escalaw, escalah;\r
        int bpp = (gp2x_memregs[0x28DA>>1]>>9)&0x3;\r
+       unsigned short scalw;\r
+\r
+       // set offset\r
+       gp2x_screenaddrs_use[0] = gp2x_screenaddrs[0] + ln_offs * 320 * bpp;\r
+       gp2x_screenaddrs_use[1] = gp2x_screenaddrs[1] + ln_offs * 320 * bpp;\r
+       gp2x_screenaddrs_use[2] = gp2x_screenaddrs[2] + ln_offs * 320 * bpp;\r
+       gp2x_screenaddrs_use[3] = gp2x_screenaddrs[3] + ln_offs * 320 * bpp;\r
 \r
        escalaw = 1024.0; // RGB Horiz LCD\r
        escalah = 320.0; // RGB Vert LCD\r
@@ -131,7 +140,10 @@ void gp2x_video_RGB_setscaling(int W, int H)
        }\r
 \r
        // scale horizontal\r
-       gp2x_memregs[0x2906>>1]=(unsigned short)((float)escalaw *(W/320.0));\r
+       scalw = (unsigned short)((float)escalaw *(W/320.0));\r
+       /* if there is no horizontal scaling, vertical doesn't work. Here is a nasty wrokaround... */\r
+       if (H != 240 && W == 320) scalw--;\r
+       gp2x_memregs[0x2906>>1]=scalw;\r
        // scale vertical\r
        gp2x_memregl[0x2908>>2]=(unsigned long)((float)escalah *bpp *(H/240.0));\r
 }\r
@@ -304,6 +316,7 @@ void gp2x_init(void)
        gp2x_screenaddr_old[2] = gp2x_memregs[0x2912>>1];\r
        gp2x_screenaddr_old[3] = gp2x_memregs[0x2914>>1];\r
 \r
+       memcpy(gp2x_screenaddrs_use, gp2x_screenaddrs, sizeof(gp2x_screenaddrs));\r
        gp2x_memset_all_buffers(0, 0, 320*240*2);\r
 \r
        // snd\r
index 9883b22..349b898 100644 (file)
@@ -12,7 +12,7 @@ void gp2x_video_flip2(void);
 void gp2x_video_changemode(int bpp);\r
 void gp2x_video_changemode2(int bpp);\r
 void gp2x_video_setpalette(int *pal, int len);\r
-void gp2x_video_RGB_setscaling(int W, int H);\r
+void gp2x_video_RGB_setscaling(int ln_offs, int W, int H);\r
 void gp2x_video_wait_vsync(void);\r
 void gp2x_memcpy_buffers(int buffers, void *data, int offset, int len);\r
 void gp2x_memcpy_all_buffers(void *data, int offset, int len);\r
index d29d6d0..f9c8065 100644 (file)
@@ -286,7 +286,10 @@ static int scandir_cmp(const void *p1, const void *p2)
        return alphasort(d1, d2);\r
 }\r
 \r
-static char *filter_exts[] = { ".mp3", ".MP3", ".srm", ".brm", "s.gz", ".mds", "bcfg", ".txt", ".htm", "html", ".jpg", ".gpe" };\r
+static char *filter_exts[] = {\r
+       ".mp3", ".MP3", ".srm", ".brm", "s.gz", ".mds", "bcfg", ".txt", ".htm", "html",\r
+       ".jpg", ".gpe", ".cue"\r
+};\r
 \r
 static int scandir_filter(const struct dirent *ent)\r
 {\r
@@ -864,16 +867,15 @@ static void draw_amenu_options(int menu_sel)
        //memset(gp2x_screen, 0, 320*240);\r
        gp2x_pd_clone_buffer2();\r
 \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,       "Gamma correction           %i.%02i", currentConfig.gamma / 100, currentConfig.gamma%100); // 0\r
+       gp2x_text_out8(tl_x, (y+=10), "Emulate Z80                %s", (currentConfig.PicoOpt&0x004)?"ON":"OFF"); // 1\r
+       gp2x_text_out8(tl_x, (y+=10), "Emulate YM2612 (FM)        %s", (currentConfig.PicoOpt&0x001)?"ON":"OFF"); // 2\r
+       gp2x_text_out8(tl_x, (y+=10), "Emulate SN76496 (PSG)      %s", (currentConfig.PicoOpt&0x002)?"ON":"OFF"); // 3\r
+       gp2x_text_out8(tl_x, (y+=10), "gzip savestates            %s", (currentConfig.EmuOpt &0x008)?"ON":"OFF"); // 4\r
+       gp2x_text_out8(tl_x, (y+=10), "Don't save config on exit  %s", (currentConfig.EmuOpt &0x020)?"ON":"OFF"); // 5\r
        gp2x_text_out8(tl_x, (y+=10), "needs restart:");\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), "craigix's RAM timings      %s", (currentConfig.EmuOpt &0x100)?"ON":"OFF"); // 7\r
+       gp2x_text_out8(tl_x, (y+=10), "squidgehack (now %s %s",   mms, (currentConfig.EmuOpt &0x010)?"ON":"OFF"); // 8\r
        gp2x_text_out8(tl_x, (y+=10), "Done");\r
 \r
        // draw cursor\r
@@ -884,7 +886,7 @@ static void draw_amenu_options(int menu_sel)
 \r
 static void amenu_loop_options(void)\r
 {\r
-       int menu_sel = 0, menu_sel_max = 10;\r
+       int menu_sel = 0, menu_sel_max = 9;\r
        unsigned long inp = 0;\r
 \r
        for(;;)\r
@@ -895,21 +897,20 @@ 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: 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
+                               case  1: currentConfig.PicoOpt^=0x004; break;\r
+                               case  2: currentConfig.PicoOpt^=0x001; break;\r
+                               case  3: currentConfig.PicoOpt^=0x002; break;\r
+                               case  4: currentConfig.EmuOpt ^=0x008; break;\r
+                               case  5: currentConfig.EmuOpt ^=0x020; break;\r
+                               case  7: currentConfig.EmuOpt ^=0x100; break;\r
+                               case  8: currentConfig.EmuOpt ^=0x010; break;\r
+                               case  9: return;\r
                        }\r
                }\r
                if(inp & (GP2X_X|GP2X_A)) return;\r
                if(inp & (GP2X_LEFT|GP2X_RIGHT)) { // multi choise\r
                        switch (menu_sel) {\r
-                               case 1:\r
+                               case 0:\r
                                        while ((inp = gp2x_joystick_read(1)) & (GP2X_LEFT|GP2X_RIGHT)) {\r
                                                currentConfig.gamma += (inp & GP2X_LEFT) ? -1 : 1;\r
                                                if (currentConfig.gamma <   1) currentConfig.gamma =   1;\r
@@ -949,8 +950,8 @@ static const char *region_name(unsigned int code)
 \r
 static void draw_menu_options(int menu_sel)\r
 {\r
-       int tl_x = 25, tl_y = 40, y;\r
-       char monostereo[8], strframeskip[8], *strrend;\r
+       int tl_x = 25, tl_y = 32, y;\r
+       char monostereo[8], strframeskip[8], *strrend, *strscaling;\r
 \r
        strcpy(monostereo, (currentConfig.PicoOpt&0x08)?"stereo":"mono");\r
        if (currentConfig.Frameskip < 0)\r
@@ -963,27 +964,34 @@ static void draw_menu_options(int menu_sel)
        } else {\r
                strrend = " 8bit accurate";\r
        }\r
+       switch (currentConfig.scaling) {\r
+               default: strscaling = "            OFF";   break;\r
+               case 1:  strscaling = "hw horizontal";     break;\r
+               case 2:  strscaling = "hw horiz. + vert."; break;\r
+               case 3:  strscaling = "sw horizontal";     break;\r
+       }\r
 \r
        y = tl_y;\r
        //memset(gp2x_screen, 0, 320*240);\r
        gp2x_pd_clone_buffer2();\r
 \r
        gp2x_text_out8(tl_x, y,       "Renderer:            %s", strrend); // 0\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), "Scaling:       %s", strscaling);    // 1\r
+       gp2x_text_out8(tl_x, (y+=10), "Accurate timing (slower)   %s", (currentConfig.PicoOpt&0x040)?"ON":"OFF"); // 2\r
+       gp2x_text_out8(tl_x, (y+=10), "Accurate sprites (slower)  %s", (currentConfig.PicoOpt&0x080)?"ON":"OFF"); // 3\r
+       gp2x_text_out8(tl_x, (y+=10), "Show FPS                   %s", (currentConfig.EmuOpt &0x002)?"ON":"OFF"); // 4\r
        gp2x_text_out8(tl_x, (y+=10), "Frameskip                  %s", strframeskip);\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), "Enable sound               %s", (currentConfig.EmuOpt &0x004)?"ON":"OFF"); // 6\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), "Use ARM940 core for sound  %s", (currentConfig.PicoOpt&0x200)?"ON":"OFF"); // 8\r
+       gp2x_text_out8(tl_x, (y+=10), "6 button pad               %s", (currentConfig.PicoOpt&0x020)?"ON":"OFF"); // 9\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), "Use SRAM/BRAM savestates   %s", (currentConfig.EmuOpt &0x001)?"ON":"OFF"); // 11\r
+       gp2x_text_out8(tl_x, (y+=10), "Confirm save overwrites    %s", (currentConfig.EmuOpt &0x200)?"ON":"OFF"); // 12\r
+       gp2x_text_out8(tl_x, (y+=10), "Save slot                  %i", state_slot); // 13\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), "[advanced options]");            // 16\r
        gp2x_text_out8(tl_x, (y+=10), "Save cfg as default");\r
        if (rom_data)\r
                gp2x_text_out8(tl_x, (y+=10), "Save cfg for current game only");\r
@@ -1042,11 +1050,12 @@ static void menu_options_save(void)
        } else {\r
                actionNames[8] = actionNames[9] = actionNames[10] = actionNames[11] = 0;\r
        }\r
+       scaling_update();\r
 }\r
 \r
 static int menu_loop_options(void)\r
 {\r
-       int menu_sel = 0, menu_sel_max = 16;\r
+       int menu_sel = 0, menu_sel_max = 17;\r
        unsigned long inp = 0;\r
 \r
        if (rom_data) menu_sel_max++;\r
@@ -1062,25 +1071,25 @@ 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: 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
+                               case  2: currentConfig.PicoOpt^=0x040; break;\r
+                               case  3: currentConfig.PicoOpt^=0x080; break;\r
+                               case  4: currentConfig.EmuOpt ^=0x002; break;\r
+                               case  6: currentConfig.EmuOpt ^=0x004; break;\r
+                               case  8: currentConfig.PicoOpt^=0x200; break;\r
+                               case  9: currentConfig.PicoOpt^=0x020; break;\r
+                               case 11: currentConfig.EmuOpt ^=0x001; break;\r
+                               case 12: currentConfig.EmuOpt ^=0x200; break;\r
+                               case 15: cd_menu_loop_options();\r
                                        if (engineState == PGS_ReloadRom)\r
                                                return 0; // test BIOS\r
                                        break;\r
-                               case 15: amenu_loop_options();    break;\r
-                               case 16: // done (update and write)\r
+                               case 16: amenu_loop_options();    break;\r
+                               case 17: // done (update and write)\r
                                        menu_options_save();\r
                                        if (emu_WriteConfig(0)) strcpy(menuErrorMsg, "config saved");\r
                                        else strcpy(menuErrorMsg, "failed to write config");\r
                                        return 1;\r
-                               case 17: // done (update and write for current game)\r
+                               case 18: // done (update and write for current game)\r
                                        menu_options_save();\r
                                        if (emu_WriteConfig(1)) strcpy(menuErrorMsg, "config saved");\r
                                        else strcpy(menuErrorMsg, "failed to write config");\r
@@ -1104,28 +1113,33 @@ static int menu_loop_options(void)
                                                else if (  currentConfig.EmuOpt &0x80) currentConfig.EmuOpt &= ~0x80;\r
                                        }\r
                                        break;\r
-                               case  4:\r
+                               case  1:\r
+                                       currentConfig.scaling += (inp & GP2X_LEFT) ? -1 : 1;\r
+                                       if (currentConfig.scaling < 0) currentConfig.scaling = 0;\r
+                                       if (currentConfig.scaling > 3) currentConfig.scaling = 3;\r
+                                       break;\r
+                               case  5:\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
+                               case  7:\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
+                               case 10:\r
                                        region_prevnext(inp & GP2X_RIGHT);\r
                                        break;\r
-                               case 12:\r
+                               case 13:\r
                                        if (inp & GP2X_RIGHT) {\r
                                                state_slot++; if (state_slot > 9) state_slot = 0;\r
                                        } else {state_slot--; if (state_slot < 0) state_slot = 9;\r
                                        }\r
                                        break;\r
-                               case 13:\r
+                               case 14:\r
                                        while ((inp = gp2x_joystick_read(1)) & (GP2X_LEFT|GP2X_RIGHT)) {\r
                                                currentConfig.CPUclock += (inp & GP2X_LEFT) ? -1 : 1;\r
                                                if (currentConfig.CPUclock < 1) currentConfig.CPUclock = 1;\r
@@ -1222,7 +1236,11 @@ static void menu_loop_root(void)
        if (rom_data) menu_sel = menu_sel_min = 0;\r
        if (PicoPatches) menu_sel_max = 9;\r
 \r
-       for(;;)\r
+       /* make sure action buttons are not pressed on entering menu */\r
+       draw_menu_root(menu_sel);\r
+       while (gp2x_joystick_read(1) & (GP2X_B|GP2X_X|GP2X_SELECT)) usleep(50*1000);\r
+\r
+       for (;;)\r
        {\r
                draw_menu_root(menu_sel);\r
                inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_B|GP2X_X|GP2X_SELECT);\r
@@ -1324,7 +1342,7 @@ static void menu_gfx_prepare(void)
 \r
        // switch to 8bpp\r
        gp2x_video_changemode2(8);\r
-       gp2x_video_RGB_setscaling(320, 240);\r
+       gp2x_video_RGB_setscaling(0, 320, 240);\r
        gp2x_video_flip2();\r
 }\r
 \r
index 1725e8d..cc93f89 100644 (file)
@@ -1,2 +1,2 @@
-#define VERSION "1.31"\r
+#define VERSION "1.32"\r
 \r
index 9a8f3df..a01a529 100644 (file)
@@ -90,7 +90,7 @@ PicoDrive : $(OBJS) ../gp2x/helix/helix_mp3_x86.a
 
 ../../Pico/sound/ym2612.o : ../../Pico/sound/ym2612.c
        @echo $@
-       @$(GCC) $(COPT_COMMON) $(DEFINC) -DEXTERNAL_YM2612 -c $< -o $@ # -mtune=arm940t
+       @$(GCC) $(COPT_COMMON) $(DEFINC) -c $< -o $@ # -mtune=arm940t -DEXTERNAL_YM2612
 
 # faked asm
 ../../Pico/Draw.o : ../../Pico/Draw.c
index cc4db98..40cd7bc 100644 (file)
@@ -257,7 +257,7 @@ void gp2x_video_setpalette(int *pal, int len)
        memcpy(current_pal, pal, len*4);
 }
 
-void gp2x_video_RGB_setscaling(int W, int H)
+void gp2x_video_RGB_setscaling(int v_offs, int W, int H)
 {
 }
 
index 42be264..765c0cd 100644 (file)
@@ -4,7 +4,7 @@
 #define PORT_CONFIG_H
 
 #define CPU_CALL
-#define NO_IONBF
+#define NO_SYNC
 
 // draw2.c
 #define START_ROW  0 // which row of tiles to start rendering at?