From a8869ad1e809e6cacd6141fa7e9c86d349b0c0be Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 1 Oct 2007 21:05:32 +0000 Subject: [PATCH] renderers (interlace and stuff) git-svn-id: file:///home/notaz/opt/svn/PicoDrive@267 be3aeb3a-fb24-0410-a615-afba39da0efa --- platform/common/emu.h | 2 +- platform/common/menu.h | 5 +++-- platform/gizmondo/asm_utils.s | 19 ++++++++++++++++--- platform/gizmondo/emu.c | 27 ++++++++++++++++++++------- platform/gizmondo/menu.c | 32 ++++++++++++++++++-------------- 5 files changed, 58 insertions(+), 27 deletions(-) diff --git a/platform/common/emu.h b/platform/common/emu.h index 67533cbd..96cd5501 100644 --- a/platform/common/emu.h +++ b/platform/common/emu.h @@ -8,7 +8,7 @@ typedef struct { int EmuOpt; // LSb->MSb: use_sram, show_fps, enable_sound, gzip_saves, // squidgehack, no_save_cfg_on_exit, , 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 diff --git a/platform/common/menu.h b/platform/common/menu.h index b21818dd..8a9f424d 100644 --- a/platform/common/menu.h +++ b/platform/common/menu.h @@ -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, diff --git a/platform/gizmondo/asm_utils.s b/platform/gizmondo/asm_utils.s index 91e57109..1cee30e1 100644 --- a/platform/gizmondo/asm_utils.s +++ b/platform/gizmondo/asm_utils.s @@ -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: diff --git a/platform/gizmondo/emu.c b/platform/gizmondo/emu.c index d404d554..c26013b6 100644 --- a/platform/gizmondo/emu.c +++ b/platform/gizmondo/emu.c @@ -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(); diff --git a/platform/gizmondo/menu.c b/platform/gizmondo/menu.c index b062ffdc..83152942 100644 --- a/platform/gizmondo/menu.c +++ b/platform/gizmondo/menu.c @@ -991,6 +991,7 @@ menu_entry opt2_entries[] = { "Emulate Z80", MB_ONOFF, MA_OPT2_ENABLE_Z80, ¤tConfig.PicoOpt,0x0004, 0, 0, 1 }, { "Emulate YM2612 (FM)", MB_ONOFF, MA_OPT2_ENABLE_YM2612, ¤tConfig.PicoOpt,0x0001, 0, 0, 1 }, { "Emulate SN76496 (PSG)", MB_ONOFF, MA_OPT2_ENABLE_SN76496,¤tConfig.PicoOpt,0x0002, 0, 0, 1 }, + { "Wait for V-sync (slow)", MB_ONOFF, MA_OPT2_VSYNC, ¤tConfig.EmuOpt, 0x2000, 0, 0, 1 }, { "gzip savestates", MB_ONOFF, MA_OPT2_GZIP_STATES, ¤tConfig.EmuOpt, 0x0008, 0, 0, 1 }, { "Don't save last used ROM", MB_ONOFF, MA_OPT2_NO_LAST_ROM, ¤tConfig.EmuOpt, 0x0020, 0, 0, 1 }, { "done", MB_NONE, MA_OPT2_DONE, NULL, 0, 0, 0, 1 }, @@ -1056,16 +1057,17 @@ static void amenu_loop_options(void) menu_entry opt_entries[] = { { NULL, MB_NONE, MA_OPT_RENDERER, NULL, 0, 0, 0, 1 }, - { "Scale low res mode", MB_ONOFF, MA_OPT_SCALING, ¤tConfig.scaling, 0x001, 0, 3, 1 }, - { "Accurate timing (slower)", MB_ONOFF, MA_OPT_ACC_TIMING, ¤tConfig.PicoOpt, 0x040, 0, 0, 1 }, - { "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES, ¤tConfig.PicoOpt, 0x080, 0, 0, 1 }, - { "Show FPS", MB_ONOFF, MA_OPT_SHOW_FPS, ¤tConfig.EmuOpt, 0x002, 0, 0, 1 }, + { "Interlaced rend. (faster)", MB_ONOFF, MA_OPT_INTERLACED, ¤tConfig.EmuOpt, 0x4000, 0, 0, 1 }, + { "Scale low res mode", MB_ONOFF, MA_OPT_SCALING, ¤tConfig.scaling, 0x0001, 0, 3, 1 }, + { "Accurate timing (slower)", MB_ONOFF, MA_OPT_ACC_TIMING, ¤tConfig.PicoOpt, 0x0040, 0, 0, 1 }, + { "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES, ¤tConfig.PicoOpt, 0x0080, 0, 0, 1 }, + { "Show FPS", MB_ONOFF, MA_OPT_SHOW_FPS, ¤tConfig.EmuOpt, 0x0002, 0, 0, 1 }, { NULL, MB_RANGE, MA_OPT_FRAMESKIP, ¤tConfig.Frameskip, 0, -1, 16, 1 }, - { "Enable sound", MB_ONOFF, MA_OPT_ENABLE_SOUND, ¤tConfig.EmuOpt, 0x004, 0, 0, 1 }, + { "Enable sound", MB_ONOFF, MA_OPT_ENABLE_SOUND, ¤tConfig.EmuOpt, 0x0004, 0, 0, 1 }, { NULL, MB_NONE, MA_OPT_SOUND_QUALITY, NULL, 0, 0, 0, 1 }, - { "6 button pad", MB_ONOFF, MA_OPT_6BUTTON_PAD, ¤tConfig.PicoOpt, 0x020, 0, 0, 1 }, + { "6 button pad", MB_ONOFF, MA_OPT_6BUTTON_PAD, ¤tConfig.PicoOpt, 0x0020, 0, 0, 1 }, { NULL, MB_NONE, MA_OPT_REGION, NULL, 0, 0, 0, 1 }, - { "Use SRAM/BRAM savestates", MB_ONOFF, MA_OPT_SRAM_STATES, ¤tConfig.EmuOpt, 0x001, 0, 0, 1 }, + { "Use SRAM/BRAM savestates", MB_ONOFF, MA_OPT_SRAM_STATES, ¤tConfig.EmuOpt, 0x0001, 0, 0, 1 }, { NULL, MB_NONE, MA_OPT_CONFIRM_STATES,NULL, 0, 0, 0, 1 }, { "Save slot", MB_RANGE, MA_OPT_SAVE_SLOT, &state_slot, 0, 0, 9, 1 }, { "[Sega/Mega CD options]", MB_NONE, MA_OPT_SCD_OPTS, NULL, 0, 0, 0, 1 }, @@ -1243,18 +1245,20 @@ static int menu_loop_options(void) switch (selected_id) { case MA_OPT_RENDERER: if (inp & BTN_LEFT) { - if ( currentConfig.PicoOpt&0x10) currentConfig.PicoOpt&= ~0x10; - else if (!(currentConfig.EmuOpt &0x80))currentConfig.EmuOpt |= 0x80; - else if ( currentConfig.EmuOpt &0x80) break; + if ((currentConfig.PicoOpt&0x10) || !(currentConfig.EmuOpt &0x80)) { + currentConfig.PicoOpt&= ~0x10; + currentConfig.EmuOpt |= 0x80; + } } else { - if ( currentConfig.PicoOpt&0x10) break; - else if (!(currentConfig.EmuOpt &0x80))currentConfig.PicoOpt|= 0x10; - else if ( currentConfig.EmuOpt &0x80) currentConfig.EmuOpt &= ~0x80; + if (!(currentConfig.PicoOpt&0x10) || (currentConfig.EmuOpt &0x80)) { + currentConfig.PicoOpt|= 0x10; + currentConfig.EmuOpt &= ~0x80; + } } break; case MA_OPT_SOUND_QUALITY: if ((inp & BTN_RIGHT) && currentConfig.PsndRate == 44100 && !(currentConfig.PicoOpt&0x08)) { - currentConfig.PsndRate = 11025; currentConfig.PicoOpt|= 0x08; + currentConfig.PsndRate = 11025; currentConfig.PicoOpt|= 0x08; } else if ((inp & BTN_LEFT) && currentConfig.PsndRate == 11025 && (currentConfig.PicoOpt&0x08)) { currentConfig.PsndRate = 44100; currentConfig.PicoOpt&=~0x08; } else currentConfig.PsndRate = sndrate_prevnext(currentConfig.PsndRate, inp & BTN_RIGHT); -- 2.39.5