renderers (interlace and stuff)
authornotaz <notasas@gmail.com>
Mon, 1 Oct 2007 21:05:32 +0000 (21:05 +0000)
committernotaz <notasas@gmail.com>
Mon, 1 Oct 2007 21:05:32 +0000 (21:05 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@267 be3aeb3a-fb24-0410-a615-afba39da0efa

platform/common/emu.h
platform/common/menu.h
platform/gizmondo/asm_utils.s
platform/gizmondo/emu.c
platform/gizmondo/menu.c

index 67533cb..96cd550 100644 (file)
@@ -8,7 +8,7 @@ typedef struct {
        int EmuOpt;             // LSb->MSb: use_sram, show_fps, enable_sound, gzip_saves,
                                        // squidgehack, no_save_cfg_on_exit, <unused>, 16_bit_mode
                                        // craigix_ram, confirm_save, show_cd_leds, confirm_load
-                                       // A_SNs_gamma, perfect_vsync
+                                       // A_SNs_gamma, perfect_vsync, interlace
        int PicoOpt;  // used for config saving only, see Pico.h
        int PsndRate; // ditto
        int PicoRegion; // ditto
index b21818d..8a9f424 100644 (file)
@@ -50,6 +50,7 @@ typedef enum
        MA_OPT_SAVECFG,
        MA_OPT_SAVECFG_GAME,
        MA_OPT_LOADCFG,
+       MA_OPT_INTERLACED,      /* giz */
        MA_OPT2_GAMMA,
        MA_OPT2_A_SN_GAMMA,
        MA_OPT2_VSYNC,
@@ -58,8 +59,8 @@ typedef enum
        MA_OPT2_ENABLE_SN76496,
        MA_OPT2_GZIP_STATES,
        MA_OPT2_NO_LAST_ROM,
-       MA_OPT2_RAMTIMINGS,
-       MA_OPT2_SQUIDGEHACK,
+       MA_OPT2_RAMTIMINGS,     /* gp2x */
+       MA_OPT2_SQUIDGEHACK,    /* gp2x */
        MA_OPT2_DONE,
        MA_CDOPT_TESTBIOS_USA,
        MA_CDOPT_TESTBIOS_EUR,
index 91e5710..1cee30e 100644 (file)
@@ -1,23 +1,31 @@
 @ vim:filetype=armasm
 
 
-.global vidCpy8to16 @ void *dest, void *src, short *pal, int lines|(is32col<<8)
+.global vidCpy8to16 @ void *dest, void *src, short *pal, int lines|(flags<<16),
+                    @ flags=is32col[0], no_even_lines[1], no_odd_lines[2]
 
 vidCpy8to16:
     stmfd   sp!, {r4-r8,lr}
 
-    tst     r3, #0x100
+    and     r4, r3, #0xff0000
     and     r3, r3, #0xff
+    tst     r4, #0x10000
     mov     r3, r3, lsr #1
     orr     r3, r3, r3, lsl #8
     orreq   r3, r3, #(320/8-1)<<24 @ 40 col mode
     orrne   r3, r3, #(256/8-1)<<24 @ 32 col mode
-    orrne   r3, r3, #0x10000
     addne   r0, r0, #32*2
+    orr     r3, r3, r4
     add     r1, r1, #8
     mov     lr, #0xff
     mov     lr, lr, lsl #1
 
+    @ no even lines?
+    tst     r3, #0x20000
+    addne   r0, r0, #320*2
+    addne   r1, r1, #328
+    bne     vcloop_odd
+
     @ even lines first
 vcloop_aligned:
     ldr     r12, [r1], #4
@@ -62,6 +70,10 @@ vcloop_aligned:
     tst     r3, #0xff
     bne     vcloop_aligned
 
+    @ no odd lines?
+    tst     r3, #0x40000
+    ldmnefd sp!, {r4-r8,pc}
+
     and     r4, r3, #0xff00
     orr     r3, r3, r4, lsr #8
     mov     r4, r4, lsr #7
@@ -75,6 +87,7 @@ vcloop_aligned:
     sub     r1, r1, r4
 
     sub     r0, r0, #2
+vcloop_odd:
     mov     r8, #0
 
 vcloop_unaligned:
index d404d55..c26013b 100644 (file)
@@ -140,6 +140,7 @@ void emu_setDefaultConfig(void)
        currentConfig.KeyBinds[ 6] = 1<<5;
        currentConfig.KeyBinds[ 7] = 1<<6;
        currentConfig.KeyBinds[ 4] = 1<<7;
+       currentConfig.KeyBinds[13] = 1<<26; // switch rend
        currentConfig.KeyBinds[ 8] = 1<<27; // save state
        currentConfig.KeyBinds[ 9] = 1<<28; // load state
        currentConfig.KeyBinds[12] = 1<<29; // vol up
@@ -154,6 +155,9 @@ static int EmuScan16(unsigned int num, void *sdata)
        if (!(Pico.video.reg[1]&8)) num += 8;
        DrawLineDest = (unsigned short *) giz_screen + 321*(num+1);
 
+       if ((currentConfig.EmuOpt&0x4000) && (num&1) == (Pico.m.frame_count&1))
+               return 1; // skip next line
+
        return 0;
 }
 
@@ -216,7 +220,9 @@ static void blit(const char *fps, const char *notice)
                        Pico.m.dirtyPal = 0;
                        vidConvCpyRGB565(localPal, Pico.cram, 0x40);
                }
-               if (!(Pico.video.reg[12]&1)) lines_flags|=0x100;
+               if (!(Pico.video.reg[12]&1)) lines_flags|=0x10000;
+               if (currentConfig.EmuOpt&0x4000)
+                       lines_flags|=(Pico.m.frame_count&1)?0x20000:0x40000;
                vidCpy8to16((unsigned short *)giz_screen+321*8, PicoDraw2FB+328*8, localPal, lines_flags);
        }
        else if (!(emu_opt&0x80))
@@ -242,7 +248,9 @@ static void blit(const char *fps, const char *notice)
                        } */
                }
                lines_flags = (Pico.video.reg[1]&8) ? 240 : 224;
-               if (!(Pico.video.reg[12]&1)) lines_flags|=0x100;
+               if (!(Pico.video.reg[12]&1)) lines_flags|=0x10000;
+               if (currentConfig.EmuOpt&0x4000)
+                       lines_flags|=(Pico.m.frame_count&1)?0x20000:0x40000;
                vidCpy8to16((unsigned short *)giz_screen+321*8, PicoDraw2FB+328*8, localPal, lines_flags);
        }
 
@@ -360,9 +368,12 @@ static void RunEvents(unsigned int which)
        if (which & 0x1800) { // save or load (but not both)
                int do_it = 1;
                if ( emu_checkSaveFile(state_slot) &&
-                               (( (which & 0x1000) && (currentConfig.EmuOpt & 0x800)) ||   // load
-                                (!(which & 0x1000) && (currentConfig.EmuOpt & 0x200))) ) { // save
+                               (( (which & 0x1000) && (currentConfig.EmuOpt & 0x800)) || // load
+                                (!(which & 0x1000) && (currentConfig.EmuOpt & 0x200))) ) // save
+               {
                        int keys;
+                       if (giz_screen == NULL)
+                               giz_screen = Framework2D_LockBuffer();
                        blit("", (which & 0x1000) ? "LOAD STATE? (PLAY=yes, STOP=no)" : "OVERWRITE SAVE? (PLAY=yes, STOP=no)");
                        while( !((keys = Framework_PollGetButtons()) & (BTN_PLAY|BTN_STOP)) )
                                Sleep(50);
@@ -379,9 +390,8 @@ static void RunEvents(unsigned int which)
                reset_timing = 1;
        }
        if (which & 0x0400) { // switch renderer
-               if      (  PicoOpt&0x10)             { PicoOpt&=~0x10; currentConfig.EmuOpt |= 0x80; }
-               else if (!(currentConfig.EmuOpt&0x80)) PicoOpt|= 0x10;
-               else   currentConfig.EmuOpt &= ~0x80;
+               if (PicoOpt&0x10) { PicoOpt&=~0x10; currentConfig.EmuOpt |=  0x80; }
+               else              { PicoOpt|= 0x10; currentConfig.EmuOpt &= ~0x80; }
 
                vidResetMode();
 
@@ -716,6 +726,9 @@ void emu_Loop(void)
 
                PicoFrame();
 
+               if (currentConfig.EmuOpt&0x2000)
+                       Framework2D_WaitVSync();
+
                if (giz_screen == NULL)
                        giz_screen = Framework2D_LockBuffer();
 
index b062ffd..8315294 100644 (file)
@@ -991,6 +991,7 @@ menu_entry opt2_entries[] =
        { "Emulate Z80",               MB_ONOFF, MA_OPT2_ENABLE_Z80,    &currentConfig.PicoOpt,0x0004, 0, 0, 1 },\r
        { "Emulate YM2612 (FM)",       MB_ONOFF, MA_OPT2_ENABLE_YM2612, &currentConfig.PicoOpt,0x0001, 0, 0, 1 },\r
        { "Emulate SN76496 (PSG)",     MB_ONOFF, MA_OPT2_ENABLE_SN76496,&currentConfig.PicoOpt,0x0002, 0, 0, 1 },\r
+       { "Wait for V-sync (slow)",    MB_ONOFF, MA_OPT2_VSYNC,         &currentConfig.EmuOpt, 0x2000, 0, 0, 1 },\r
        { "gzip savestates",           MB_ONOFF, MA_OPT2_GZIP_STATES,   &currentConfig.EmuOpt, 0x0008, 0, 0, 1 },\r
        { "Don't save last used ROM",  MB_ONOFF, MA_OPT2_NO_LAST_ROM,   &currentConfig.EmuOpt, 0x0020, 0, 0, 1 },\r
        { "done",                      MB_NONE,  MA_OPT2_DONE,          NULL, 0, 0, 0, 1 },\r
@@ -1056,16 +1057,17 @@ static void amenu_loop_options(void)
 menu_entry opt_entries[] =\r
 {\r
        { NULL,                        MB_NONE,  MA_OPT_RENDERER,      NULL, 0, 0, 0, 1 },\r
-       { "Scale low res mode",        MB_ONOFF, MA_OPT_SCALING,       &currentConfig.scaling, 0x001, 0, 3, 1 },\r
-       { "Accurate timing (slower)",  MB_ONOFF, MA_OPT_ACC_TIMING,    &currentConfig.PicoOpt, 0x040, 0, 0, 1 },\r
-       { "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES,   &currentConfig.PicoOpt, 0x080, 0, 0, 1 },\r
-       { "Show FPS",                  MB_ONOFF, MA_OPT_SHOW_FPS,      &currentConfig.EmuOpt,  0x002, 0, 0, 1 },\r
+       { "Interlaced rend. (faster)", MB_ONOFF, MA_OPT_INTERLACED,    &currentConfig.EmuOpt,  0x4000, 0, 0, 1 },\r
+       { "Scale low res mode",        MB_ONOFF, MA_OPT_SCALING,       &currentConfig.scaling, 0x0001, 0, 3, 1 },\r
+       { "Accurate timing (slower)",  MB_ONOFF, MA_OPT_ACC_TIMING,    &currentConfig.PicoOpt, 0x0040, 0, 0, 1 },\r
+       { "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES,   &currentConfig.PicoOpt, 0x0080, 0, 0, 1 },\r
+       { "Show FPS",                  MB_ONOFF, MA_OPT_SHOW_FPS,      &currentConfig.EmuOpt,  0x0002, 0, 0, 1 },\r
        { NULL,                        MB_RANGE, MA_OPT_FRAMESKIP,     &currentConfig.Frameskip, 0, -1, 16, 1 },\r
-       { "Enable sound",              MB_ONOFF, MA_OPT_ENABLE_SOUND,  &currentConfig.EmuOpt,  0x004, 0, 0, 1 },\r
+       { "Enable sound",              MB_ONOFF, MA_OPT_ENABLE_SOUND,  &currentConfig.EmuOpt,  0x0004, 0, 0, 1 },\r
        { NULL,                        MB_NONE,  MA_OPT_SOUND_QUALITY, NULL, 0, 0, 0, 1 },\r
-       { "6 button pad",              MB_ONOFF, MA_OPT_6BUTTON_PAD,   &currentConfig.PicoOpt, 0x020, 0, 0, 1 },\r
+       { "6 button pad",              MB_ONOFF, MA_OPT_6BUTTON_PAD,   &currentConfig.PicoOpt, 0x0020, 0, 0, 1 },\r
        { NULL,                        MB_NONE,  MA_OPT_REGION,        NULL, 0, 0, 0, 1 },\r
-       { "Use SRAM/BRAM savestates",  MB_ONOFF, MA_OPT_SRAM_STATES,   &currentConfig.EmuOpt,  0x001, 0, 0, 1 },\r
+       { "Use SRAM/BRAM savestates",  MB_ONOFF, MA_OPT_SRAM_STATES,   &currentConfig.EmuOpt,  0x0001, 0, 0, 1 },\r
        { NULL,                        MB_NONE,  MA_OPT_CONFIRM_STATES,NULL, 0, 0, 0, 1 },\r
        { "Save slot",                 MB_RANGE, MA_OPT_SAVE_SLOT,     &state_slot, 0, 0, 9, 1 },\r
        { "[Sega/Mega CD options]",    MB_NONE,  MA_OPT_SCD_OPTS,      NULL, 0, 0, 0, 1 },\r
@@ -1243,18 +1245,20 @@ static int menu_loop_options(void)
                                switch (selected_id) {\r
                                        case MA_OPT_RENDERER:\r
                                                if (inp & BTN_LEFT) {\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
+                                                       if ((currentConfig.PicoOpt&0x10) || !(currentConfig.EmuOpt &0x80)) {\r
+                                                               currentConfig.PicoOpt&= ~0x10;\r
+                                                               currentConfig.EmuOpt |=  0x80;\r
+                                                       }\r
                                                } else {\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
+                                                       if (!(currentConfig.PicoOpt&0x10) || (currentConfig.EmuOpt &0x80)) {\r
+                                                               currentConfig.PicoOpt|=  0x10;\r
+                                                               currentConfig.EmuOpt &= ~0x80;\r
+                                                       }\r
                                                }\r
                                                break;\r
                                        case MA_OPT_SOUND_QUALITY:\r
                                                if ((inp & BTN_RIGHT) && currentConfig.PsndRate == 44100 && !(currentConfig.PicoOpt&0x08)) {\r
-                                                       currentConfig.PsndRate = 11025;  currentConfig.PicoOpt|= 0x08;\r
+                                                       currentConfig.PsndRate = 11025; currentConfig.PicoOpt|= 0x08;\r
                                                } else if ((inp & BTN_LEFT) && currentConfig.PsndRate == 11025 && (currentConfig.PicoOpt&0x08)) {\r
                                                        currentConfig.PsndRate = 44100; currentConfig.PicoOpt&=~0x08;\r
                                                } else currentConfig.PsndRate = sndrate_prevnext(currentConfig.PsndRate, inp & BTN_RIGHT);\r