updated bords/mappers/stuff to 0.98.15, lots of them got broken, asmcore support...
[fceu.git] / mappers / 6.c
index 29caa6a..45a8f0d 100644 (file)
@@ -1,77 +1,80 @@
-/* FCE Ultra - NES/Famicom Emulator
- *
- * Copyright notice for this file:
- *  Copyright (C) 2002 Ben Parnell
- *
- * 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
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * 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
- */
-
-#include "mapinc.h"
-
-
-#define FVRAM_BANK8(A,V) {VPage[0]=VPage[1]=VPage[2]=VPage[3]=VPage[4]=VPage[5]=VPage[6]=VPage[7]=V?&MapperExRAM[(V)<<13]-(A):&CHRRAM[(V)<<13]-(A);CHRBankList[0]=((V)<<3);CHRBankList[1]=((V)<<3)+1;CHRBankList[2]=((V)<<3)+2;CHRBankList[3]=((V)<<3)+3;CHRBankList[4]=((V)<<3)+4;CHRBankList[5]=((V)<<3)+5;CHRBankList[6]=((V)<<3)+6;CHRBankList[7]=((V)<<3)+7;PPUCHRRAM=0xFF;}
-
-static void FP_FASTAPASS(1) FFEIRQHook(int a)
-{
-  if(IRQa)
-  {
-   IRQCount+=a;
-   if(IRQCount>=0x10000)
-   {
-    TriggerIRQ();
-    IRQa=0;
-    IRQCount=0;
-   }
-  }
-}
-
-DECLFW(Mapper6_write)
-{
-        if(A<0x8000)
-        {
-                switch(A){
-                case 0x42FF:MIRROR_SET((V>>4)&1);break;
-                case 0x42FE:onemir((V>>3)&2);break;
-                case 0x4501:IRQa=0;break;
-                case 0x4502:IRQCount&=0xFF00;IRQCount|=V;break;
-                case 0x4503:IRQCount&=0xFF;IRQCount|=V<<8;IRQa=1;break;
-                }
-        } else {
-        ROM_BANK16(0x8000,V>>2);
-        FVRAM_BANK8(0x0000,V&3);
-        X6502_Rebase();
-        }
-}
-void Mapper6_StateRestore(int version)
-{
- int x;
- for(x=0;x<8;x++)
-  if(PPUCHRRAM&(1<<x))
-  {
-   if(CHRBankList[x]>7)
-    VPage[x]=&MapperExRAM[(CHRBankList[x]&31)*0x400]-(x*0x400);
-   else VPage[x]=&CHRRAM[(CHRBankList[x]&7)*0x400]-(x*0x400);
-  }
-}
-void Mapper6_init(void)
-{
-MapIRQHook=FFEIRQHook;
-ROM_BANK16(0xc000,7);
-
-SetWriteHandler(0x4020,0x5fff,Mapper6_write);
-SetWriteHandler(0x8000,0xffff,Mapper6_write);
-MapStateRestore=Mapper6_StateRestore;
-}
-
+/* FCE Ultra - NES/Famicom Emulator\r
+ *\r
+ * Copyright notice for this file:\r
+ *  Copyright (C) 2002 Xodnizel\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 FFEmode;\r
+\r
+#define FVRAM_BANK8(A,V) {VPage[0]=VPage[1]=VPage[2]=VPage[3]=VPage[4]=VPage[5]=VPage[6]=VPage[7]=V?&MapperExRAM[(V)<<13]-(A):&CHRRAM[(V)<<13]-(A);CHRBankList[0]=((V)<<3);CHRBankList[1]=((V)<<3)+1;CHRBankList[2]=((V)<<3)+2;CHRBankList[3]=((V)<<3)+3;CHRBankList[4]=((V)<<3)+4;CHRBankList[5]=((V)<<3)+5;CHRBankList[6]=((V)<<3)+6;CHRBankList[7]=((V)<<3)+7;PPUCHRRAM=0xFF;}\r
+\r
+static void FP_FASTAPASS(1) FFEIRQHook(int a)\r
+{\r
+  if(IRQa)\r
+  {\r
+   IRQCount+=a;\r
+   if(IRQCount>=0x10000)\r
+   {\r
+    X6502_IRQBegin(FCEU_IQEXT);\r
+    IRQa=0;\r
+    IRQCount=0;\r
+   }\r
+  }\r
+}\r
+\r
+DECLFW(Mapper6_write)\r
+{\r
+        if(A<0x8000)\r
+        {\r
+                switch(A){\r
+                case 0x42FF:MIRROR_SET((V>>4)&1);break;\r
+                case 0x42FE:onemir((V>>3)&2); FFEmode=V&0x80;break;\r
+                case 0x4501:IRQa=0;X6502_IRQEnd(FCEU_IQEXT);break;\r
+                case 0x4502:IRQCount&=0xFF00;IRQCount|=V;break;\r
+                case 0x4503:IRQCount&=0xFF;IRQCount|=V<<8;IRQa=1;break;\r
+                }\r
+        } else {\r
+         switch (FFEmode)\r
+         {\r
+           case 0x80:  setchr8(V); break;\r
+           default: ROM_BANK16(0x8000,V>>2);\r
+                    FVRAM_BANK8(0x0000,V&3);\r
+         }\r
+        }\r
+}\r
+void Mapper6_StateRestore(int version)\r
+{\r
+ int x;\r
+ for(x=0;x<8;x++)\r
+  if(PPUCHRRAM&(1<<x))\r
+  {\r
+   if(CHRBankList[x]>7)\r
+    VPage[x]=&MapperExRAM[(CHRBankList[x]&31)*0x400]-(x*0x400);\r
+   else VPage[x]=&CHRRAM[(CHRBankList[x]&7)*0x400]-(x*0x400);\r
+  }\r
+}\r
+void Mapper6_init(void)\r
+{\r
+MapIRQHook=FFEIRQHook;\r
+ROM_BANK16(0xc000,7);\r
+\r
+SetWriteHandler(0x4020,0x5fff,Mapper6_write);\r
+SetWriteHandler(0x8000,0xffff,Mapper6_write);\r
+MapStateRestore=Mapper6_StateRestore;\r
+}\r