mapper fixes for ncpu, debug is broken atm
[fceu.git] / mappers / simple.c
index 8f1ad74..de6c42f 100644 (file)
@@ -18,7 +18,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-
+#include <string.h>
 #include "mapinc.h"
 
 static uint8 latche;
@@ -27,6 +27,7 @@ static DECLFW(Mapper2_write)
 {
        latche=V;
         ROM_BANK16(0x8000,V);
+        X6502_Rebase();
 }
 
 void Mapper2_init(void)
@@ -52,11 +53,13 @@ DECLFW(Mapper7_write)
       ROM_BANK32(V&0xF);
       onemir((V>>4)&1);
       latche=V;
+      X6502_Rebase();
 }
 
 void Mapper7_init(void)
 {
         onemir(0);
+        ROM_BANK32(0);
         SetWriteHandler(0x8000,0xFFFF,Mapper7_write);
        AddExState(&latche, 1, 0, "LATC");
 }
@@ -66,6 +69,7 @@ DECLFW(Mapper11_write)
         ROM_BANK32(V);
         VROM_BANK8(V>>4);
        latche=V;
+        X6502_Rebase();
 }
 
 void Mapper11_init(void)
@@ -80,6 +84,7 @@ static DECLFW(Mapper13_write)
        setchr4r(0x10,0x1000,V&3);
        setprg32(0x8000,(V>>4)&3);
        latche=V;
+       X6502_Rebase();
 }
 
 static void Mapper13_StateRestore(int version)
@@ -87,6 +92,7 @@ static void Mapper13_StateRestore(int version)
        setchr4r(0x10,0x0000,0);
         setchr4r(0x10,0x1000,latche&3);
         setprg32(0x8000,(latche>>4)&3);
+       X6502_Rebase();
 }
 
 void Mapper13_init(void)
@@ -105,12 +111,16 @@ DECLFW(Mapper34_write)
 {
 switch(A)
  {
- case 0x7FFD:ROM_BANK32(V);break;
+ case 0x7FFD:ROM_BANK32(V);
+             X6502_Rebase();break;
  case 0x7FFE:VROM_BANK4(0x0000,V);break;
  case 0x7fff:VROM_BANK4(0x1000,V);break;
  }
-if(A>=0x8000)
- ROM_BANK32(V);
+ if(A>=0x8000)
+ {
+  ROM_BANK32(V);
+  X6502_Rebase();
+ }
 }
 
 void Mapper34_init(void)
@@ -123,6 +133,7 @@ DECLFW(Mapper66_write)
  VROM_BANK8(V&0xF);
  ROM_BANK32((V>>4));
  latche=V;
+ X6502_Rebase();
 }
 
 void Mapper66_init(void)
@@ -138,6 +149,7 @@ DECLFW(Mapper152_write)
  VROM_BANK8(V&0xF);
  onemir((V>>7)&1);     /* Saint Seiya...hmm. */
  latche=V;
+ X6502_Rebase();
 }
 
 void Mapper152_init(void)
@@ -152,6 +164,7 @@ static DECLFW(Mapper70_write)
  ROM_BANK16(0x8000,V>>4);
  VROM_BANK8(V&0xF);
  latche=V;
+ X6502_Rebase();
 }
 
 void Mapper70_init(void)
@@ -167,6 +180,7 @@ static DECLFW(Mapper78_write)
  VROM_BANK8(V>>4);
  onemir((V>>3)&1);
  latche=V;
+ X6502_Rebase();
 }
 
 void Mapper78_init(void)
@@ -192,6 +206,7 @@ DECLFW(Mapper93_write)
   ROM_BANK16(0x8000,V>>4);
   MIRROR_SET(V&1);
   latche=V;
+  X6502_Rebase();
 }
 
 void Mapper93_init(void)
@@ -205,6 +220,7 @@ DECLFW(Mapper94_write)
 {
  ROM_BANK16(0x8000,V>>2);
  latche=V;
+ X6502_Rebase();
 }
 
 void Mapper94_init(void)
@@ -225,11 +241,12 @@ static DECLFW(Mapper96_write)
  setprg32(0x8000,V&3);
  setchr4r(0x10,0x0000,(latche&4)|M96LA);
  setchr4r(0x10,0x1000,(latche&4)|3);
+ X6502_Rebase();
 }
 
 static void FP_FASTAPASS(1) M96Hook(uint32 A)
 {
- if(A<0x2000)
+ if((A&0x3000)!=0x2000)
   return;
  M96LA=(A>>8)&3;
  setchr4r(0x10,0x0000,(latche&4)|M96LA);
@@ -240,6 +257,7 @@ static void M96Sync()
  setprg32(0x8000,latche&3);
  setchr4r(0x10,0x0000,(latche&4)|M96LA);
  setchr4r(0x10,0x1000,(latche&4)|3);
+ X6502_Rebase();
 }
 
 void Mapper96_init(void)
@@ -258,6 +276,7 @@ static DECLFW(Mapper140_write)
 {
  VROM_BANK8(V&0xF);
  ROM_BANK32((V>>4)&0xF);
+ X6502_Rebase();
 }
 
 void Mapper140_init(void)