updated bords/mappers/stuff to 0.98.15, lots of them got broken, asmcore support...
[fceu.git] / boards / konami-qtai.c
diff --git a/boards/konami-qtai.c b/boards/konami-qtai.c
new file mode 100644 (file)
index 0000000..ff552e1
--- /dev/null
@@ -0,0 +1,128 @@
+/* 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
+ * CAI Shogakko no Sansu\r
+ */\r
+\r
+#include "mapinc.h"\r
+\r
+static uint8 *CHRRAM=NULL;\r
+static uint8 SWRAM[4096];\r
+\r
+static uint8 regs[16];\r
+static uint8 WRAM[4096];\r
+static SFORMAT StateRegs[]=\r
+{\r
+  {&regs, 16, "REGS"},\r
+  {WRAM, 4096, "WRAM"},\r
+  {0}\r
+};\r
+\r
+static void Sync(void)\r
+{\r
+  if(regs[5]&0x40)\r
+  {\r
+    setchr4r(0,0x1000,regs[5]&0x3F);\r
+  }\r
+  else\r
+  {\r
+    setchr4r(0x10,0x0000,regs[5]);\r
+    setchr4r(0x10,0x1000,regs[5]^1);\r
+  }\r
+  setprg8r((regs[2]>>6)&1,0x8000,(regs[2]&0x3F));\r
+  setprg8r((regs[3]>>6)&1,0xA000,(regs[3]&0x3F));\r
+  setprg8r((regs[4]>>6)&1,0xC000,(regs[4]&0x3F));\r
+  setprg8r(1,0xE000,~0);\r
+  setmirror((regs[0xA]&3));\r
+}\r
+\r
+static DECLFW(M190Write)\r
+{\r
+// FCEU_printf("write %04x:%04x %d, %d\n",A,V,scanline,timestamp);\r
+  regs[(A&0x0F00)>>8]=V;\r
+  Sync();\r
+}\r
+\r
+static DECLFR(M190Read)\r
+{\r
+// FCEU_printf("read %04x:%04x %d, %d\n",A,regs[(A&0x0F00)>>8],scanline,timestamp);\r
+  return regs[(A&0x0F00)>>8];\r
+}\r
+\r
+static DECLFR(AWRAM)\r
+{\r
+  return(WRAM[A-0x7000]);\r
+}\r
+static DECLFW(BWRAM)\r
+{\r
+  WRAM[A-0x7000]=V;\r
+}\r
+\r
+static DECLFR(ASWRAM)\r
+{\r
+  return(SWRAM[A-0x6000]);\r
+}\r
+static DECLFW(BSWRAM)\r
+{\r
+  SWRAM[A-0x6000]=V;\r
+}\r
+\r
+static void M190Power(void)\r
+{\r
+  setvram8(CHRRAM);\r
+  SetReadHandler(0x8000,0xFFFF,CartBR);\r
+  SetWriteHandler(0x8000,0xFFFF,M190Write);\r
+// SetReadHandler(0xDA00,0xDA00,M190Read);\r
+// SetReadHandler(0xDB00,0xDB00,M190Read);\r
+  SetReadHandler(0xDC00,0xDC00,M190Read);\r
+  SetReadHandler(0xDD00,0xDD00,M190Read);\r
+  SetReadHandler(0x7000,0x7FFF,AWRAM);\r
+  SetWriteHandler(0x7000,0x7FFF,BWRAM);\r
+  SetReadHandler(0x6000,0x6FFF,ASWRAM);\r
+  SetWriteHandler(0x6000,0x6FFF,BSWRAM);\r
+  Sync();\r
+}\r
+\r
+static void M190Close(void)\r
+{\r
+  if(CHRRAM)\r
+    FCEU_gfree(CHRRAM);\r
+  CHRRAM=NULL;\r
+}\r
+\r
+static void StateRestore(int version)\r
+{\r
+  Sync();\r
+}\r
+\r
+void Mapper190_Init(CartInfo *info)\r
+{\r
+  info->Power=M190Power;\r
+  info->Close=M190Close;\r
+  if(info->battery)\r
+  {\r
+    info->SaveGame[0]=SWRAM;\r
+    info->SaveGameLen[0]=4096;\r
+  }\r
+  GameStateRestore=StateRestore;\r
+  CHRRAM=(uint8*)FCEU_gmalloc(8192);\r
+  SetupCartCHRMapping(0x10,CHRRAM,8192,1);\r
+  AddExState(CHRRAM, 8192, 0, "CHRRAM");\r
+  AddExState(&StateRegs, ~0, 0, 0);\r
+}\r