e2d0dd92 |
1 | /* FCE Ultra - NES/Famicom Emulator |
2 | * |
3 | * Copyright notice for this file: |
4 | * Copyright (C) 2005 CaH4e3 |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. |
10 | * |
11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU General Public License |
17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | */ |
20 | |
21 | #include "mapinc.h" |
22 | |
23 | static uint8 reg[8]; |
24 | static uint8 mirror, cmd, is154; |
25 | |
26 | static SFORMAT StateRegs[]= |
27 | { |
28 | {&cmd, 1, "CMD"}, |
29 | {&mirror, 1, "MIRR"}, |
30 | {reg, 8, "REGS"}, |
31 | {0} |
32 | }; |
33 | |
34 | static void Sync(void) |
35 | { |
36 | setchr2(0x0000,reg[0]>>1); |
37 | setchr2(0x0800,reg[1]>>1); |
38 | setchr1(0x1000,reg[2]|0x40); |
39 | setchr1(0x1400,reg[3]|0x40); |
40 | setchr1(0x1800,reg[4]|0x40); |
41 | setchr1(0x1C00,reg[5]|0x40); |
42 | setprg8(0x8000,reg[6]); |
43 | setprg8(0xA000,reg[7]); |
44 | } |
45 | |
46 | static void MSync(void) |
47 | { |
48 | if(is154)setmirror(MI_0+(mirror&1)); |
49 | } |
50 | |
51 | static DECLFW(M88Write) |
52 | { |
53 | switch(A&0x8001) |
54 | { |
55 | case 0x8000: cmd=V&7; mirror=V>>6; MSync(); break; |
56 | case 0x8001: reg[cmd]=V; Sync(); break; |
57 | } |
58 | } |
59 | |
60 | static void M88Power(void) |
61 | { |
62 | setprg16(0xC000,~0); |
63 | SetReadHandler(0x8000,0xFFFF,CartBR); |
64 | SetWriteHandler(0x8000,0xFFFF,M88Write); |
65 | } |
66 | |
67 | static void StateRestore(int version) |
68 | { |
69 | Sync(); |
70 | MSync(); |
71 | } |
72 | |
73 | void Mapper88_Init(CartInfo *info) |
74 | { |
75 | is154=0; |
76 | info->Power=M88Power; |
77 | GameStateRestore=StateRestore; |
78 | AddExState(&StateRegs, ~0, 0, 0); |
79 | } |
80 | |
81 | void Mapper154_Init(CartInfo *info) |
82 | { |
83 | is154=1; |
84 | info->Power=M88Power; |
85 | GameStateRestore=StateRestore; |
86 | AddExState(&StateRegs, ~0, 0, 0); |
87 | } |