-/* FCE Ultra - NES/Famicom Emulator\r
- *\r
- * Copyright notice for this file:\r
- * Copyright (C) 2005 CaH4e3\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
-#include "mmc3.h"\r
-\r
-static uint8 *CHRRAM = NULL;\r
-static uint8 resetmode;\r
-static int masko8[8]={63,31,15,1,3,0,0,0};\r
-\r
-static void Super24PW(uint32 A, uint8 V)\r
-{\r
- uint32 NV=V&masko8[EXPREGS[0]&7];\r
- NV|=(EXPREGS[1]<<1);\r
- setprg8r((NV>>6)&0xF,A,NV);\r
-}\r
-\r
-static void Super24CW(uint32 A, uint8 V)\r
-{\r
- if(EXPREGS[0]&0x20)\r
- setchr1r(0x10,A,V);\r
- else\r
- {\r
- uint32 NV=V|(EXPREGS[2]<<3);\r
- setchr1r((NV>>9)&0xF,A,NV);\r
- }\r
-}\r
-\r
-static DECLFW(Super24Write)\r
-{\r
- switch(A)\r
- {\r
- case 0x5FF0: EXPREGS[0]=V;\r
- FixMMC3PRG(MMC3_cmd);\r
- FixMMC3CHR(MMC3_cmd);\r
- break;\r
- case 0x5FF1: EXPREGS[1]=V;\r
- FixMMC3PRG(MMC3_cmd);\r
- break;\r
- case 0x5FF2: EXPREGS[2]=V;\r
- FixMMC3CHR(MMC3_cmd);\r
- break;\r
- }\r
-}\r
-\r
-static DECLFW(Super24IRQ)\r
-{\r
- switch(A&0xE001)\r
- {\r
- case 0xc000: IRQLatch=V;\r
- if(resetmode==1)\r
- IRQCount=IRQLatch;\r
- break;\r
- case 0xc001: resetmode=1;\r
- IRQCount=IRQLatch;\r
- break;\r
- case 0xE000: IRQa=0;\r
- X6502_IRQEnd(FCEU_IQEXT);\r
- if(resetmode==1)\r
- IRQCount=IRQLatch;\r
- break;\r
- case 0xE001: IRQa=1;\r
- if(resetmode==1)\r
- IRQCount=IRQLatch;\r
- break;\r
- }\r
-}\r
-\r
-static void Super24HB(void)\r
-{\r
- resetmode=0;\r
- if(IRQCount!=0)\r
- {\r
- IRQCount--;\r
- if(IRQCount==0)\r
- {\r
- if(IRQa)\r
- {\r
- resetmode=1;\r
- X6502_IRQBegin(FCEU_IQEXT);\r
- }\r
- }\r
- }\r
-}\r
-\r
-static void Super24Power(void)\r
-{\r
- EXPREGS[0]=0x24;\r
- EXPREGS[1]=159;\r
- EXPREGS[2]=0;\r
- GenMMC3Power();\r
- SetWriteHandler(0x5000,0x7FFF,Super24Write);\r
- SetWriteHandler(0xC000,0xFFFF,Super24IRQ);\r
- SetReadHandler(0x8000,0xFFFF,CartBR);\r
-}\r
-\r
-static void Super24Reset(void)\r
-{\r
- EXPREGS[0]=0x24;\r
- EXPREGS[1]=159;\r
- EXPREGS[2]=0;\r
- MMC3RegReset();\r
-}\r
-\r
-static void Super24Close(void)\r
-{\r
- if(CHRRAM)\r
- FCEU_gfree(CHRRAM);\r
- CHRRAM = NULL;\r
-}\r
-\r
-void Super24_Init(CartInfo *info)\r
-{\r
- info->Power=Super24Power;\r
- info->Reset=Super24Reset;\r
- info->Close=Super24Close;\r
- cwrap=Super24CW;\r
- pwrap=Super24PW;\r
- CHRRAM=(uint8*)FCEU_gmalloc(8192);\r
- SetupCartCHRMapping(0x10, CHRRAM, 8192, 1);\r
- GameHBIRQHook=Super24HB;\r
- AddExState(CHRRAM, 8192, 0, "CHRR");\r
- AddExState(EXPREGS, 3, 0, "BIG2");\r
-}\r
+/* FCE Ultra - NES/Famicom Emulator
+ *
+ * Copyright notice for this file:
+ * Copyright (C) 2005 CaH4e3
+ *
+ * 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"
+#include "mmc3.h"
+
+//static uint8 *CHRRAM = NULL;
+static int masko8[8]={63,31,15,1,3,0,0,0};
+
+static void Super24PW(uint32 A, uint8 V)
+{
+ uint32 NV=V&masko8[EXPREGS[0]&7];
+ NV|=(EXPREGS[1]<<1);
+ setprg8r((NV>>6)&0xF,A,NV);
+}
+
+static void Super24CW(uint32 A, uint8 V)
+{
+ if(EXPREGS[0]&0x20)
+ setchr1r(0x10,A,V);
+ else
+ {
+ uint32 NV=V|(EXPREGS[2]<<3);
+ setchr1r((NV>>9)&0xF,A,NV);
+ }
+}
+
+static DECLFW(Super24Write)
+{
+ switch(A)
+ {
+ case 0x5FF0: EXPREGS[0]=V;
+ FixMMC3PRG(MMC3_cmd);
+ FixMMC3CHR(MMC3_cmd);
+ break;
+ case 0x5FF1: EXPREGS[1]=V;
+ FixMMC3PRG(MMC3_cmd);
+ break;
+ case 0x5FF2: EXPREGS[2]=V;
+ FixMMC3CHR(MMC3_cmd);
+ break;
+ }
+}
+
+static void Super24Power(void)
+{
+ EXPREGS[0]=0x24;
+ EXPREGS[1]=159;
+ EXPREGS[2]=0;
+ GenMMC3Power();
+ SetWriteHandler(0x5000,0x7FFF,Super24Write);
+ SetReadHandler(0x8000,0xFFFF,CartBR);
+}
+
+static void Super24Reset(void)
+{
+ EXPREGS[0]=0x24;
+ EXPREGS[1]=159;
+ EXPREGS[2]=0;
+ MMC3RegReset();
+}
+
+static void Super24Close(void)
+{
+ if(CHRRAM)
+ FCEU_gfree(CHRRAM);
+ CHRRAM = NULL;
+}
+
+void Super24_Init(CartInfo *info)
+{
+ GenMMC3_Init(info, 128, 256, 0, 0);
+ info->Power=Super24Power;
+ info->Reset=Super24Reset;
+ info->Close=Super24Close;
+ cwrap=Super24CW;
+ pwrap=Super24PW;
+ CHRRAM=(uint8*)FCEU_gmalloc(8192);
+ SetupCartCHRMapping(0x10, CHRRAM, 8192, 1);
+ AddExState(CHRRAM, 8192, 0, "CHRR");
+ AddExState(EXPREGS, 3, 0, "BIG2");
+}