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 |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\r |
19 | * Mortal Kombat 2 YOKO */\r |
20 | \r |
21 | #include "mapinc.h"\r |
22 | #include "mmc3.h"\r |
23 | \r |
24 | static uint8 reg[8];\r |
25 | \r |
26 | static SFORMAT StateRegs[]=\r |
27 | {\r |
28 | {reg, 8, "REGS"},\r |
29 | {0}\r |
30 | };\r |
31 | \r |
32 | static void Sync(void)\r |
33 | {\r |
34 | // FCEU_printf("(%02x, %02x)\n",reg[3],reg[4]);\r |
35 | setprg8(0x8000,reg[0]);\r |
36 | setprg8(0xA000,reg[1]);\r |
37 | setprg8(0xC000,reg[2]);\r |
38 | setprg8(0xE000,~0);\r |
39 | // setchr2(0x0000,reg[3]);\r |
40 | // setchr2(0x0800,reg[4]);\r |
41 | // setchr2(0x1000,reg[5]);\r |
42 | // setchr2(0x1800,reg[6]);\r |
43 | setchr2(0x0000,reg[3]);\r |
44 | setchr2(0x0800,reg[4]);\r |
45 | setchr2(0x1000,reg[5]);\r |
46 | setchr2(0x1800,reg[6]);\r |
47 | }\r |
48 | \r |
49 | static DECLFW(MCN22MWrite)\r |
50 | {\r |
51 | //FCEU_printf("bs %04x %02x\n",A,V);\r |
52 | switch(A)\r |
53 | {\r |
54 | case 0x8c00:\r |
55 | case 0x8c01:\r |
56 | case 0x8c02: reg[A&3]=V; break;\r |
57 | case 0x8d10: reg[3]=V; break;\r |
58 | case 0x8d11: reg[4]=V; break;\r |
59 | case 0x8d16: reg[5]=V; break;\r |
60 | case 0x8d17: reg[6]=V; break;\r |
61 | }\r |
62 | Sync();\r |
63 | }\r |
64 | \r |
65 | static void MCN22MPower(void)\r |
66 | {\r |
67 | reg[0]=reg[1]=reg[2]=0;\r |
68 | Sync(); \r |
69 | SetReadHandler(0x8000,0xFFFF,CartBR);\r |
70 | SetWriteHandler(0x8000,0xFFFF,MCN22MWrite);\r |
71 | }\r |
72 | /*\r |
73 | static void MCN22MIRQHook(void)\r |
74 | {\r |
75 | int count = IRQCount;\r |
76 | if(!count || IRQReload)\r |
77 | {\r |
78 | IRQCount = IRQLatch;\r |
79 | IRQReload = 0;\r |
80 | }\r |
81 | else\r |
82 | IRQCount--;\r |
83 | if(!IRQCount)\r |
84 | {\r |
85 | if(IRQa)\r |
86 | {\r |
87 | X6502_IRQBegin(FCEU_IQEXT);\r |
88 | }\r |
89 | }\r |
90 | }\r |
91 | */\r |
92 | static void StateRestore(int version)\r |
93 | {\r |
94 | Sync();\r |
95 | }\r |
96 | \r |
97 | void UNLCN22M_Init(CartInfo *info)\r |
98 | {\r |
99 | info->Power=MCN22MPower;\r |
100 | // GameHBIRQHook=MCN22MIRQHook;\r |
101 | GameStateRestore=StateRestore;\r |
102 | AddExState(&StateRegs, ~0, 0, 0);\r |
103 | }\r |