merge mapper code from FCEUX
[fceu.git] / mappers / 65.c
index 51983ef..1a8cb8b 100644 (file)
@@ -1,7 +1,7 @@
 /* FCE Ultra - NES/Famicom Emulator
  *
  * Copyright notice for this file:
- *  Copyright (C) 2002 Ben Parnell
+ *  Copyright (C) 2002 Xodnizel
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #include "mapinc.h"
 
 
-void FP_FASTAPASS(1) IREMIRQHook(int a)
+void IREMIRQHook(int a)
 {
   if(IRQa)
   {
    IRQCount-=a;
-   if(IRQCount<=0-4)
+   if(IRQCount<-4)
    {
-    TriggerIRQ();
+    X6502_IRQBegin(FCEU_IQEXT);
     IRQa=0;
     IRQCount=0xFFFF;
    }
   }
 }
 
-DECLFW(Mapper65_write)
+static DECLFW(Mapper65_write)
 {
-switch(A)
-{
-case 0x8000:ROM_BANK8(0x8000,V);
-            X6502_Rebase();break;
-case 0x9000:MIRROR_SET2((V>>6)&1);break;
-case 0x9003:IRQa=V&0x80;break;
-case 0x9004:IRQCount=IRQLatch;break;
-case 0x9005:          IRQLatch&=0x00FF;
-                      IRQLatch|=V<<8;
-                      break;
-case 0x9006:          IRQLatch&=0xFF00;IRQLatch|=V;
-                      break;
-case 0xB000:VROM_BANK1(0x0000,V);break;
-case 0xB001:VROM_BANK1(0x0400,V);break;
-case 0xB002:VROM_BANK1(0x0800,V);break;
-case 0xB003:VROM_BANK1(0x0C00,V);break;
-case 0xB004:VROM_BANK1(0x1000,V);break;
-case 0xB005:VROM_BANK1(0x1400,V);break;
-case 0xB006:VROM_BANK1(0x1800,V);break;
-case 0xB007:VROM_BANK1(0x1C00,V);break;
-case 0xa000:ROM_BANK8(0xA000,V);
-            X6502_Rebase();break;
-case 0xC000:ROM_BANK8(0xC000,V);
-            X6502_Rebase();break;
+ //if(A>=0x9000 && A<=0x9006)
+ // printf("$%04x:$%02x, %d\n",A,V,scanline);
+ switch(A)
+ {
+  //default: printf("$%04x:$%02x\n",A,V);
+  //        break;
+  case 0x8000:ROM_BANK8(0x8000,V);break;
+ // case 0x9000:printf("$%04x:$%02x\n",A,V);MIRROR_SET2((V>>6)&1);break;
+  case 0x9001:MIRROR_SET(V>>7);break;
+  case 0x9003:IRQa=V&0x80;X6502_IRQEnd(FCEU_IQEXT);break;
+  case 0x9004:IRQCount=IRQLatch;break;
+  case 0x9005:          IRQLatch&=0x00FF;
+                        IRQLatch|=V<<8;
+                        break;
+  case 0x9006:          IRQLatch&=0xFF00;IRQLatch|=V;
+                        break;
+  case 0xB000:VROM_BANK1(0x0000,V);break;
+  case 0xB001:VROM_BANK1(0x0400,V);break;
+  case 0xB002:VROM_BANK1(0x0800,V);break;
+  case 0xB003:VROM_BANK1(0x0C00,V);break;
+  case 0xB004:VROM_BANK1(0x1000,V);break;
+  case 0xB005:VROM_BANK1(0x1400,V);break;
+  case 0xB006:VROM_BANK1(0x1800,V);break;
+  case 0xB007:VROM_BANK1(0x1C00,V);break;
+  case 0xa000:ROM_BANK8(0xA000,V);break;
+  case 0xC000:ROM_BANK8(0xC000,V);break;
  }
+ //MIRROR_SET2(1);
 }
 
 void Mapper65_init(void)