SMB3, combo, fskip fixes
authornotaz <notasas@gmail.com>
Sun, 9 Dec 2007 23:17:25 +0000 (23:17 +0000)
committernotaz <notasas@gmail.com>
Sun, 9 Dec 2007 23:17:25 +0000 (23:17 +0000)
git-svn-id: file:///home/notaz/opt/svn/fceu@311 be3aeb3a-fb24-0410-a615-afba39da0efa

Makefile.gp2x
drivers/gp2x/input.c
drivers/gp2x/menu.c
drivers/gp2x/throttle.c
fce.c
ncpu.S
ncpu_debug.c
out_gp2x/readme.txt

index fe002c1..1d49220 100644 (file)
@@ -11,7 +11,7 @@ TFLAGS        += -ggdb
 LDRIVER        += -ggdb
 NOSTRIP = 1
 else
 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
 TFLAGS += -O3 #-pg -fno-omit-frame-pointer
 LDRIVER        += -O3 #-pg -fno-omit-frame-pointer
 endif
index 34bae72..e1046bd 100644 (file)
@@ -251,6 +251,7 @@ static void FCEUD_UpdateInput(void)
                                        if ((keys & (1 << u)) && (Settings.KeyBinds[u] & acts))
                                        {
                                                keys &= ~(1 << u);
                                        if ((keys & (1 << u)) && (Settings.KeyBinds[u] & acts))
                                        {
                                                keys &= ~(1 << u);
+                                               acts &= Settings.KeyBinds[u];
                                                break;
                                        }
                                }
                                                break;
                                        }
                                }
@@ -350,33 +351,38 @@ static void InitOtherInput(void)
 
 static void PrepareOtherInput(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;
+                               }
                        }
                }
        }
                        }
                }
        }
index ee599b4..30194d9 100644 (file)
@@ -353,7 +353,7 @@ static int scandir_cmp(const void *p1, const void *p2)
 }\r
 \r
 static char *filter_exts[] = {\r
 }\r
 \r
 static char *filter_exts[] = {\r
-       ".gpe", ".png", "ck.o", ".txt"\r
+       ".gpe", ".png", "ck.o", ".txt", ".srm"\r
 };\r
 \r
 static int scandir_filter(const struct dirent *ent)\r
 };\r
 \r
 static int scandir_filter(const struct dirent *ent)\r
index fdfc0eb..c572598 100644 (file)
@@ -10,16 +10,6 @@ extern int FSkip;
 static int skip_count = 0;
 static struct timeval tv_prev;
 
 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)
 
 #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;
 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;
 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;
        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);
 
        gettimeofday(&tv_now, 0);
        tdiff = tvdiff(tv_now, tv_aim);
@@ -74,17 +76,23 @@ void SpeedThrottle(void)
                        FSkip = 1;
                }
        }
                        FSkip = 1;
                }
        }
-       else if (tdiff > 0)
+       else if (tdiff >= frame_time)
        {
                /* auto frameskip */
        {
                /* auto frameskip */
-               tv_prev = tv_now;
-               if (tdiff < 1024*16)    // limit frameskip
-               {
+               if (/*tdiff < 36*1024 &&*/ skip_count < 6) {    // limit frameskip
                        FSkip = 1;
                        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;
        }
                return;
        }
+       else
+               skip_count = 0;
 #endif
 
        /* throttle */
 #endif
 
        /* throttle */
diff --git a/fce.c b/fce.c
index a21e5f5..098d3b9 100644 (file)
--- a/fce.c
+++ b/fce.c
@@ -112,7 +112,9 @@ static writefunc *BWriteG;
 static int RWWrap=0;
 
 #ifdef ASM_6502
 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
 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
        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)
 }
 
 void asmcpu_pack(void)
@@ -184,6 +190,7 @@ DECLFW(BNull)
 
 DECLFR(ANull)
 {
 
 DECLFR(ANull)
 {
+ //printf("open [%04x] %02x @ %04x (%04x)\n", A, X.DB, X.PC, X.PC&0x7ff);
  return(X.DB);
 }
 
  return(X.DB);
 }
 
@@ -1541,6 +1548,7 @@ void PowerNES(void)
         FCEU_MemoryRand(RAM,0x800);
 #else
         memset(RAM,0x00,0x800);
         FCEU_MemoryRand(RAM,0x800);
 #else
         memset(RAM,0x00,0x800);
+       memset(nes_internal_ram,0x00,0x800);
 #endif
         ResetMapping();
         PowerSound();
 #endif
         ResetMapping();
         PowerSound();
diff --git a/ncpu.S b/ncpu.S
index 962cd57..e7b07a6 100644 (file)
--- 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
        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
 
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 .endm
 
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@ -382,7 +385,7 @@ ldmfd sp!,{r0-r3,r12,lr}
 @@@ ($nn), Y
 .macro INDY_ADDR
        ZERO_ADDR
 @@@ ($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
        add     REG_ADDR, REG_ADDR, REG_Y
        bic     REG_ADDR, REG_ADDR, #0x10000
        and     r0,REG_ADDR,#0xff
index 090bcb5..8feb875 100644 (file)
@@ -120,9 +120,9 @@ static void compare_state(void)
        if (fail) leave();
 }
 
        if (fail) leave();
 }
 
-#if 1
 static void compare_ram(void)
 {
 static void compare_ram(void)
 {
+#if 1
        int i, fail = 0;
        for (i = 0; i < 0x800/4; i++)
        {
        int i, fail = 0;
        for (i = 0; i < 0x800/4; i++)
        {
@@ -136,8 +136,8 @@ static void compare_ram(void)
        }
 
        if (fail) leave();
        }
 
        if (fail) leave();
-}
 #endif
 #endif
+}
 
 void TriggerIRQ_d(void)
 {
 
 void TriggerIRQ_d(void)
 {
index c923df8..201f7f0 100644 (file)
@@ -109,7 +109,7 @@ You will need the FDS BIOS ROM image in <where_you_put_gpfce>/fceultra directory
 It's size should be 8192 bytes and it must be named "disksys.rom".\r
 gpfce will not load FDS games without this file.\r
 \r
 It's size should be 8192 bytes and it must be named "disksys.rom".\r
 gpfce will not load FDS games without this file.\r
 \r
-You will also probably need configure keys for swapping the virtual FDS disks,\r
+You will also probably need to configure keys for swapping the virtual FDS disks,\r
 they are configurable in Controls menu.\r
 \r
 Two types of FDS disk images are supported: disk images with the FWNES-style header,\r
 they are configurable in Controls menu.\r
 \r
 Two types of FDS disk images are supported: disk images with the FWNES-style header,\r
@@ -189,6 +189,11 @@ extension instead of .ips.
 \r
 \r
 ver 0.4 (by notaz)\r
 \r
 \r
 ver 0.4 (by notaz)\r
+  ret 311\r
+          - Improved open bus emulation, fixes missing ground in some SMB3 levels.\r
+          - Improved auto frameskip behavior in cases when emu is not fast\r
+            enough to maintain 50/60 fps.\r
+          - Fixed a bug which prevented some key combo configurations from working.\r
   rev 171\r
           - Added optional "Accurate renderer", which is the original FCE Ultra\r
             0.98.x renderer + PPU emulation code. It's much slower, but it can\r
   rev 171\r
           - Added optional "Accurate renderer", which is the original FCE Ultra\r
             0.98.x renderer + PPU emulation code. It's much slower, but it can\r