GameGenie fixed
authornotaz <notasas@gmail.com>
Sun, 6 May 2007 13:11:32 +0000 (13:11 +0000)
committernotaz <notasas@gmail.com>
Sun, 6 May 2007 13:11:32 +0000 (13:11 +0000)
git-svn-id: file:///home/notaz/opt/svn/fceu@125 be3aeb3a-fb24-0410-a615-afba39da0efa

bench.txt
cart.c
cart.h
fce.c
ncpu.S

index 4305a99..1121918 100644 (file)
--- a/bench.txt
+++ b/bench.txt
@@ -14,3 +14,7 @@ cvn3 ~88
 
 --
 v03+merge
+smb 95-96
+bm 86-87
+kage 82-83
+
diff --git a/cart.c b/cart.c
index 1113f35..e1cd5da 100644 (file)
--- a/cart.c
+++ b/cart.c
@@ -642,6 +642,24 @@ void GeniePower(void)
   geniestage=2;
 }
 
+static uint8 *real_pages[16];
+
+void GenieSetPages(int restore)
+{
+ int page;
+ if (restore)
+ {
+  for (page=16; page<32; page++)
+   Page[page] = real_pages[page-16];
+ }
+ else
+ {
+  for (page=16; page<32; page++) {
+   real_pages[page-16] = Page[page];
+   Page[page]=GENIEROM - (page<<11) + ((page&1)<<11);
+  }
+ }
+}
 
 void FCEU_SaveGameSave(CartInfo *LocalHWInfo)
 {
diff --git a/cart.h b/cart.h
index 140c54e..9c60b34 100644 (file)
--- a/cart.h
+++ b/cart.h
@@ -101,6 +101,7 @@ void GeniePower(void);
 void OpenGenie(void);
 void CloseGenie(void);
 void FCEU_KillGenie(void);
+void GenieSetPages(int restore);
 
 #endif // ndef _CART_H
 
diff --git a/fce.c b/fce.c
index a5cc4b0..35d7209 100644 (file)
--- a/fce.c
+++ b/fce.c
@@ -203,6 +203,9 @@ void FlushGenieRW(void)
    ARead[x+0x8000]=AReadG[x];
    BWrite[x+0x8000]=BWriteG[x];
   }
+#ifdef ASM_6502
+  GenieSetPages(1);
+#endif
   free(AReadG);
   free(BWriteG);
   AReadG=0;
@@ -1425,6 +1428,18 @@ void ResetNES(void)
         X6502_Reset();
 }
 
+static void FCEU_MemoryRand(uint8 *ptr, uint32 size)
+{
+ int x=0;
+ while(size)
+ {
+  *ptr=(x&4)?0xFF:0x00;
+  x++;
+  size--;
+  ptr++;
+ }
+}
+
 void PowerNES(void)
 {
         if(!GameLoaded) return;
@@ -1434,12 +1449,20 @@ void PowerNES(void)
 
         GeniePower();
 
+#ifndef DEBUG_ASM_6502
+        FCEU_MemoryRand(RAM,0x800);
+#else
         memset(RAM,0x00,0x800);
+#endif
         ResetMapping();
        GameInterface(GI_POWER);
         PowerSound();
        PowerPPU();
        timestampbase=0;
+#ifdef ASM_6502
+       if (geniestage)
+        GenieSetPages(0);
+#endif
        X6502_Power();
 }
 
diff --git a/ncpu.S b/ncpu.S
index 0b000ec..d26a9ca 100644 (file)
--- a/ncpu.S
+++ b/ncpu.S
@@ -205,20 +205,13 @@ ldmfd sp!,{r0-r3,r12,lr}
 @@@ Read byte
 @@@
 
-.macro READ rom_optimize=1
-       adr     lr, 1f
-.if \rom_optimize
-       tst     REG_ADDR, #0x8000
-       bne     read_rom_byte
-.endif
+.macro READ unused_param
        tst     REG_ADDR, #0xe000
-       bne     read_byte
        @ RAM
-       bic     r0, REG_ADDR, #0x1800
-       add     r0, r0, #OTOFFS_NES_RAM
-       ldrb    r0, [r0, REG_OP_TABLE]
-       @@ ¤È¤¤¤¦¤ï¤±¤Ç¥¸¥ã¥ó¥×¤¹¤ëɬÍפϤʤ¤
-1:
+       biceq   r0, REG_ADDR, #0x1800
+       addeq   r0, r0, #OTOFFS_NES_RAM
+       ldreqb  r0, [r0, REG_OP_TABLE]
+       blne    read_byte
 .endm
 
 @@@
@@ -235,10 +228,8 @@ ldmfd sp!,{r0-r3,r12,lr}
 @@@ OP¤Ç¤Ïr3¤òÊݸ¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤
 
 .macro READ_WRITE_1
-       adr     lr, 9999f
-       tst     REG_ADDR, #0x8000
-       bne     read_rom_byte
        tst     REG_ADDR, #0xe000
+       adrne   lr, 9999f
        bne     read_byte
        @ RAM
        bic     REG_ADDR, REG_ADDR, #0x1800
@@ -282,7 +273,6 @@ ldmfd sp!,{r0-r3,r12,lr}
 @@@ REG_ADDR¤òÊѹ¹¤¹¤ë¤¬µ¤¤Ë¤¹¤ë¤Ê
 @@@
 .macro READ_WORD
-       @ don't do ROM check, because we might be fetching important stuff like vectors
        READ    0
        mov     REG_PC, r0
        add     REG_ADDR, REG_ADDR, #1
@@ -2723,10 +2713,11 @@ reset_cpu:
 @@@ low-level memhandlers
 @@@
 
+/*
+@ disabled because no improvements noticed, only causes trouble (with gg for example)
 read_rom_byte:
 @ try to avoid lookup of every address at least for ROM and RAM areas
 @ I've verified that if ARead[0xfff0] points to CartBR, it is always normal ROM read.
-#ifndef DEBUG_ASM_6502
        ldr     r0, =CartBR
        ldr     r2, =ARead
        mov     r1, #0xff00
@@ -2739,7 +2730,7 @@ read_rom_byte:
        ldr     r2, [r2, r1, lsl #2]
        ldrb    r0, [r2, REG_ADDR]
        bx      lr
-#endif
+*/
 
 
 read_byte: