merge mappers from FCEU-mm
[fceu.git] / boards / 01-222.c
CommitLineData
386f5371 1/* FCE Ultra - NES/Famicom Emulator\r
2 *\r
3 * Copyright notice for this file:\r
4 * Copyright (C) 2006 CaH4e3\r
5 *\r
6 * This program is free software; you can redistribute it and/or modify\r
7 * it under the terms of the GNU General Public License as published by\r
8 * the Free Software Foundation; either version 2 of the License, or\r
9 * (at your option) any later version.\r
10 *\r
11 * This program is distributed in the hope that it will be useful,\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
14 * GNU General Public License for more details.\r
15 *\r
16 * You should have received a copy of the GNU General Public License\r
17 * along with this program; if not, write to the Free Software\r
43725da7 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
19 *\r
20 * TXC mappers, originally much complex banksitching\r
21 *\r
22 * 01-22111-000 (05-00002-010) (132, 22211) - MGC-001 Qi Wang\r
23 * 01-22110-000 (52S ) - MGC-002 2-in-1 Gun\r
24 * 01-22111-100 (02-00002-010) (173 ) - MGC-008 Mahjong Block\r
25 * (079 ) - MGC-012 Poke Block\r
26 * 01-22110-200 (05-00002-010) (036 ) - MGC-014 Strike Wolf\r
27 * 01-22000-400 (05-00002-010) (036 ) - MGC-015 Policeman\r
28 * 01-22017-000 (05-PT017-080) (189 ) - MGC-017 Thunder Warrior\r
29 * 01-22270-000 (05-00002-010) (132, 22211) - MGC-xxx Creatom\r
30 * 01-22200-400 (------------) (079 ) - ET.03 F-15 City War\r
31 * (172 ) - 1991 Du Ma Racing\r
32 *\r
386f5371 33 */\r
34\r
35#include "mapinc.h"\r
36\r
37static uint8 reg[4], cmd, is172, is173;\r
38static SFORMAT StateRegs[]=\r
39{\r
40 {reg, 4, "REGS"},\r
41 {&cmd, 1, "CMD"},\r
42 {0}\r
43};\r
44\r
45static void Sync(void)\r
46{\r
47 setprg32(0x8000,(reg[2]>>2)&1);\r
48 if(is172)\r
49 setchr8((((cmd^reg[2])>>3)&2)|(((cmd^reg[2])>>5)&1)); // 1991 DU MA Racing probably CHR bank sequence is WRONG, so it is possible to\r
50 // rearrange CHR banks for normal UNIF board and mapper 172 is unneccessary\r
51 else\r
52 setchr8(reg[2]&3);\r
53}\r
54\r
55static DECLFW(UNL22211WriteLo)\r
56{\r
57// FCEU_printf("bs %04x %02x\n",A,V);\r
58 reg[A&3]=V;\r
59}\r
60\r
61static DECLFW(UNL22211WriteHi)\r
62{\r
63// FCEU_printf("bs %04x %02x\n",A,V);\r
64 cmd=V;\r
65 Sync();\r
66}\r
67\r
68static DECLFR(UNL22211ReadLo)\r
69{\r
70 return (reg[1]^reg[2])|(is173?0x01:0x40);\r
71// if(reg[3])\r
72// return reg[2];\r
73// else\r
74// return X.DB;\r
75}\r
76\r
77static void UNL22211Power(void)\r
78{\r
79 Sync();\r
80 SetReadHandler(0x8000,0xFFFF,CartBR);\r
81 SetReadHandler(0x4100,0x4100,UNL22211ReadLo);\r
82 SetWriteHandler(0x4100,0x4103,UNL22211WriteLo);\r
83 SetWriteHandler(0x8000,0xFFFF,UNL22211WriteHi);\r
84}\r
85\r
86static void StateRestore(int version)\r
87{\r
88 Sync();\r
89}\r
90\r
91void UNL22211_Init(CartInfo *info)\r
92{\r
93 is172=0;\r
94 is173=0;\r
95 info->Power=UNL22211Power;\r
96 GameStateRestore=StateRestore;\r
97 AddExState(&StateRegs, ~0, 0, 0);\r
98}\r
99\r
100void Mapper172_Init(CartInfo *info)\r
101{\r
102 is172=1; \r
103 is173=0;\r
104 info->Power=UNL22211Power;\r
105 GameStateRestore=StateRestore;\r
106 AddExState(&StateRegs, ~0, 0, 0);\r
107}\r
108\r
109void Mapper173_Init(CartInfo *info)\r
110{\r
111 is172=0; \r
112 is173=1;\r
113 info->Power=UNL22211Power;\r
114 GameStateRestore=StateRestore;\r
115 AddExState(&StateRegs, ~0, 0, 0);\r
116}\r