some movies fixed
[fceu.git] / boards / simple.c
1 /* FCE Ultra - NES/Famicom Emulator
2  *
3  * Copyright notice for this file:
4  *  Copyright (C) 2002 Ben Parnell
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 #define CHRRAM (GameMemBlock)
24 static uint8 latche;
25
26 DECLFW(CPROMWrite)
27 {
28  latche=V&3;
29  setvram4(0x1000,CHRRAM+((V&3)<<12));
30 }
31
32 static void CPROMReset(void)
33 {
34  setprg32(0x8000,0);
35  setvram8(0);
36  SetReadHandler(0x8000,0xFFFF,CartBR);
37  SetWriteHandler(0x8000,0xffff,CPROMWrite);
38 }
39
40 static void CPROMRestore(int version)
41 {
42  setvram4(0x1000,CHRRAM+((latche)<<12));
43 }
44
45 void CPROM_Init(void)
46 {
47  BoardPower=CPROMReset;
48  GameStateRestore=CPROMRestore;
49  AddExState(&latche, 1, 0, "LATC");
50 }
51
52 DECLFW(CNROMWrite)
53 {
54  latche=V&3;
55  setchr8(V&3);
56 }
57
58 static void CNROMReset(void)
59 {
60   setprg16(0x8000,0);
61   setprg16(0xC000,1);
62   SetReadHandler(0x8000,0xFFFF,CartBR);
63   SetWriteHandler(0x8000,0xffff,CNROMWrite);
64 }
65
66 static void CNROMRestore(int version)
67 {
68  setchr8(latche);
69 }
70
71 void CNROM_Init(void)
72 {
73  BoardPower=CNROMReset;
74  GameStateRestore=CNROMRestore;
75  AddExState(&latche, 1, 0, "LATC");
76 }
77
78 static void NROM128Reset(void)
79 {
80   setprg16(0x8000,0);
81   setprg16(0xC000,0);
82   setchr8(0);
83   SetReadHandler(0x8000,0xFFFF,CartBR);
84 }
85
86 static void NROM256Reset(void)
87 {
88   setprg16(0x8000,0);
89   setprg16(0xC000,1);
90   setchr8(0);
91   SetReadHandler(0x8000,0xFFFF,CartBR);
92 }
93 void NROM128_Init(void)
94 {
95   BoardPower=NROM128Reset;
96 }
97
98 void NROM256_Init(void)
99 {
100   BoardPower=NROM256Reset;
101 }
102
103 static DECLFW(MHROMWrite)
104 {
105  setprg32(0x8000,V>>4);
106  setchr8(V);
107  latche=V;
108  X6502_Rebase();
109 }
110
111 static void MHROMReset(void)
112 {
113  setprg32(0x8000,0);
114  setchr8(0);
115  latche=0;
116  SetReadHandler(0x8000,0xFFFF,CartBR);
117 }
118
119 static void MHROMRestore(int version)
120 {
121  setprg32(0x8000,latche);
122  setchr8(latche);
123  SetWriteHandler(0x8000,0xffff,MHROMWrite);
124 }
125
126 void MHROM_Init(void)
127 {
128  BoardPower=MHROMReset;
129  AddExState(&latche, 1, 0,"LATC");
130  PRGmask32[0]&=1;
131  CHRmask8[0]&=1;
132  GameStateRestore=MHROMRestore;
133 }
134
135 static void UNROMRestore(int version)
136 {
137  setprg16(0x8000,latche);
138 }
139
140 static DECLFW(UNROMWrite)
141 {
142  setprg16(0x8000,V);
143  latche=V;
144  X6502_Rebase();
145 }
146
147 static void UNROMReset(void)
148 {
149  setprg16(0x8000,0);
150  setprg16(0xc000,~0);
151  setvram8(CHRRAM);
152  SetWriteHandler(0x8000,0xffff,UNROMWrite);
153  SetReadHandler(0x8000,0xFFFF,CartBR);
154  latche=0;
155 }
156
157 void UNROM_Init(void)
158 {
159  BoardPower=UNROMReset;
160  PRGmask16[0]&=7;
161  AddExState(&latche, 1, 0, "LATC");
162  AddExState(CHRRAM, 8192, 0, "CHRR");
163  GameStateRestore=UNROMRestore;
164 }