From 282becab483a0e14ab9d59e659e190f962947220 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 9 Dec 2007 23:17:25 +0000 Subject: [PATCH] SMB3, combo, fskip fixes git-svn-id: file:///home/notaz/opt/svn/fceu@311 be3aeb3a-fb24-0410-a615-afba39da0efa --- Makefile.gp2x | 2 +- drivers/gp2x/input.c | 46 +++++++++++++++++++++++------------------ drivers/gp2x/menu.c | 2 +- drivers/gp2x/throttle.c | 42 ++++++++++++++++++++++--------------- fce.c | 10 ++++++++- ncpu.S | 7 +++++-- ncpu_debug.c | 4 ++-- out_gp2x/readme.txt | 7 ++++++- 8 files changed, 75 insertions(+), 45 deletions(-) diff --git a/Makefile.gp2x b/Makefile.gp2x index fe002c1..1d49220 100644 --- a/Makefile.gp2x +++ b/Makefile.gp2x @@ -11,7 +11,7 @@ TFLAGS += -ggdb LDRIVER += -ggdb NOSTRIP = 1 else -TFLAGS += -ftracer -fstrength-reduce -funroll-loops -fomit-frame-pointer -fstrict-aliasing -ffast-math +TFLAGS += -ftracer -fstrength-reduce -fomit-frame-pointer -fstrict-aliasing -ffast-math # -funroll-loops TFLAGS += -O3 #-pg -fno-omit-frame-pointer LDRIVER += -O3 #-pg -fno-omit-frame-pointer endif diff --git a/drivers/gp2x/input.c b/drivers/gp2x/input.c index 34bae72..e1046bd 100644 --- a/drivers/gp2x/input.c +++ b/drivers/gp2x/input.c @@ -251,6 +251,7 @@ static void FCEUD_UpdateInput(void) if ((keys & (1 << u)) && (Settings.KeyBinds[u] & acts)) { keys &= ~(1 << u); + acts &= Settings.KeyBinds[u]; break; } } @@ -350,33 +351,38 @@ static void InitOtherInput(void) static void PrepareOtherInput(void) { - uint32 act, key, seen_acts; + uint32 act; - combo_acts = combo_keys = prev_emu_acts = seen_acts = 0; + combo_acts = combo_keys = prev_emu_acts = 0; - // find combo_acts - for (act = 1; act; act <<= 1) + for (act = 0; act < 32; act++) { - for (key = 1; key < 32; key++) + int u, keyc = 0, keyc2 = 0; + if (act == 16 || act == 17) continue; // player2 flag + if (act > 17) { - if (Settings.KeyBinds[key] & act) - { - if (seen_acts & act) combo_acts |= act; - else seen_acts |= act; - } + for (u = 0; u < 32; u++) + if (Settings.KeyBinds[u] & (1 << act)) keyc++; } - } - - combo_acts &= ~0x00030000; // don't take player_id bits - - // find combo_keys - for (act = 1; act; act <<= 1) - { - for (key = 0; key < 32; key++) + else { - if (Settings.KeyBinds[key] & combo_acts) + for (u = 0; u < 32; u++) + if ((Settings.KeyBinds[u] & 0x30000) == 0 && // pl. 1 + (Settings.KeyBinds[u] & (1 << act))) keyc++; + for (u = 0; u < 32; u++) + if ((Settings.KeyBinds[u] & 0x30000) == 1 && // pl. 2 + (Settings.KeyBinds[u] & (1 << act))) keyc2++; + if (keyc2 > keyc) keyc = keyc2; + } + if (keyc > 1) + { + // loop again and mark those keys and actions as combo + for (u = 0; u < 32; u++) { - combo_keys |= 1 << key; + if (Settings.KeyBinds[u] & (1 << act)) { + combo_keys |= 1 << u; + combo_acts |= 1 << act; + } } } } diff --git a/drivers/gp2x/menu.c b/drivers/gp2x/menu.c index ee599b4..30194d9 100644 --- a/drivers/gp2x/menu.c +++ b/drivers/gp2x/menu.c @@ -353,7 +353,7 @@ static int scandir_cmp(const void *p1, const void *p2) } static char *filter_exts[] = { - ".gpe", ".png", "ck.o", ".txt" + ".gpe", ".png", "ck.o", ".txt", ".srm" }; static int scandir_filter(const struct dirent *ent) diff --git a/drivers/gp2x/throttle.c b/drivers/gp2x/throttle.c index fdfc0eb..c572598 100644 --- a/drivers/gp2x/throttle.c +++ b/drivers/gp2x/throttle.c @@ -10,16 +10,6 @@ extern int FSkip; static int skip_count = 0; static struct timeval tv_prev; -void RefreshThrottleFPS(void) -{ - skip_count = 0; - if (Settings.perfect_vsync) - { - gp2x_video_wait_vsync(); - } - gettimeofday(&tv_prev, 0); -} - #define tvdiff(tv1, tv2) \ ((tv1.tv_sec - tv2.tv_sec) * 1000000 + tv1.tv_usec - tv2.tv_usec) @@ -39,6 +29,17 @@ void RefreshThrottleFPS(void) } \ } +void RefreshThrottleFPS(void) +{ + skip_count = 0; + if (Settings.perfect_vsync) + { + gp2x_video_wait_vsync(); + } + gettimeofday(&tv_prev, 0); + tvsub(tv_prev, PAL ? 19997 : 16639); +} + static void wait_to(struct timeval *tv_aim) { struct timeval tv_now; @@ -56,10 +57,11 @@ static void wait_to(struct timeval *tv_aim) void SpeedThrottle(void) { struct timeval tv_now, tv_aim; + int frame_time = PAL ? 19997 : 16639; // ~50.007, 19.997 ms/frame : ~60.1, 16.639 ms/frame int tdiff; tv_aim = tv_prev; - tvadd(tv_aim, PAL ? 19997 : 16639); // ~50.007, 19.997 ms/frame : ~60.1, 16.639 ms/frame + tvadd(tv_aim, frame_time); gettimeofday(&tv_now, 0); tdiff = tvdiff(tv_now, tv_aim); @@ -74,17 +76,23 @@ void SpeedThrottle(void) FSkip = 1; } } - else if (tdiff > 0) + else if (tdiff >= frame_time) { /* auto frameskip */ - tv_prev = tv_now; - if (tdiff < 1024*16) // limit frameskip - { + if (/*tdiff < 36*1024 &&*/ skip_count < 6) { // limit frameskip FSkip = 1; - tvsub(tv_prev, tdiff); - } + skip_count++; + } else + skip_count = 0; + + if (tdiff < 92*1024) + tv_prev = tv_aim; + else + tv_prev = tv_now; // something went wrong, try to recover return; } + else + skip_count = 0; #endif /* throttle */ diff --git a/fce.c b/fce.c index a21e5f5..098d3b9 100644 --- a/fce.c +++ b/fce.c @@ -112,7 +112,9 @@ static writefunc *BWriteG; static int RWWrap=0; #ifdef ASM_6502 -#ifndef DEBUG_ASM_6502 +#ifdef DEBUG_ASM_6502 +extern uint8 nes_internal_ram[0x800]; +#else static void asmcpu_update(int32 cycles) { // some code from x6502.c @@ -158,6 +160,10 @@ void asmcpu_unpack(void) nes_registers[4]|= X.P & 0x5d; nes_registers[5] = X.P << 24; // N if (!(X.P&0x02)) nes_registers[5] |= 1; // Z + +#ifdef DEBUG_ASM_6502 + memcpy(nes_internal_ram, RAM, 0x800); +#endif } void asmcpu_pack(void) @@ -184,6 +190,7 @@ DECLFW(BNull) DECLFR(ANull) { + //printf("open [%04x] %02x @ %04x (%04x)\n", A, X.DB, X.PC, X.PC&0x7ff); return(X.DB); } @@ -1541,6 +1548,7 @@ void PowerNES(void) FCEU_MemoryRand(RAM,0x800); #else memset(RAM,0x00,0x800); + memset(nes_internal_ram,0x00,0x800); #endif ResetMapping(); PowerSound(); diff --git a/ncpu.S b/ncpu.S index 962cd57..e7b07a6 100644 --- a/ncpu.S +++ b/ncpu.S @@ -161,10 +161,13 @@ ldmfd sp!,{r0-r3,r12,lr} @@@ @@@ ¥¢¥É¥ì¥¹¤òÆɤà @@@ -.macro ZP_READ_ADDR +.macro ZP_READ_ADDR update_db=0 ZP_READ ldrb REG_ADDR, [REG_ADDR, #1] orr REG_ADDR, r0, REG_ADDR, lsl #8 +.if \update_db + strb r0, [REG_OP_TABLE, #(OTOFFS_X + 0x10)] @ X.DB +.endif .endm @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ -382,7 +385,7 @@ ldmfd sp!,{r0-r3,r12,lr} @@@ ($nn), Y .macro INDY_ADDR ZERO_ADDR - ZP_READ_ADDR + ZP_READ_ADDR 1 @ SMB3 relies on open bus here add REG_ADDR, REG_ADDR, REG_Y bic REG_ADDR, REG_ADDR, #0x10000 and r0,REG_ADDR,#0xff diff --git a/ncpu_debug.c b/ncpu_debug.c index 090bcb5..8feb875 100644 --- a/ncpu_debug.c +++ b/ncpu_debug.c @@ -120,9 +120,9 @@ static void compare_state(void) if (fail) leave(); } -#if 1 static void compare_ram(void) { +#if 1 int i, fail = 0; for (i = 0; i < 0x800/4; i++) { @@ -136,8 +136,8 @@ static void compare_ram(void) } if (fail) leave(); -} #endif +} void TriggerIRQ_d(void) { diff --git a/out_gp2x/readme.txt b/out_gp2x/readme.txt index c923df8..201f7f0 100644 --- a/out_gp2x/readme.txt +++ b/out_gp2x/readme.txt @@ -109,7 +109,7 @@ You will need the FDS BIOS ROM image in /fceultra directory It's size should be 8192 bytes and it must be named "disksys.rom". gpfce will not load FDS games without this file. -You will also probably need configure keys for swapping the virtual FDS disks, +You will also probably need to configure keys for swapping the virtual FDS disks, they are configurable in Controls menu. Two types of FDS disk images are supported: disk images with the FWNES-style header, @@ -189,6 +189,11 @@ extension instead of .ips. ver 0.4 (by notaz) + ret 311 + - Improved open bus emulation, fixes missing ground in some SMB3 levels. + - Improved auto frameskip behavior in cases when emu is not fast + enough to maintain 50/60 fps. + - Fixed a bug which prevented some key combo configurations from working. rev 171 - Added optional "Accurate renderer", which is the original FCE Ultra 0.98.x renderer + PPU emulation code. It's much slower, but it can -- 2.39.5