c62d2810 |
1 | /* FCE Ultra - NES/Famicom Emulator |
2 | * |
3 | * Copyright notice for this file: |
4 | * Copyright (C) 1998 BERO |
d97315ac |
5 | * Copyright (C) 2002 Xodnizel |
c62d2810 |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2 of the License, or |
10 | * (at your option) any later version. |
11 | * |
12 | * This program is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * GNU General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU General Public License |
18 | * along with this program; if not, write to the Free Software |
386f5371 |
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
c62d2810 |
20 | */ |
d97315ac |
21 | |
c62d2810 |
22 | #include "mapinc.h" |
23 | |
24 | static uint8 latche; |
25 | |
d97315ac |
26 | static DECLFW(Mapper34_write) |
27 | { |
28 | switch(A) |
c62d2810 |
29 | { |
d97315ac |
30 | case 0x7FFD:ROM_BANK32(V);break; |
31 | case 0x7FFE:VROM_BANK4(0x0000,V);break; |
32 | case 0x7fff:VROM_BANK4(0x1000,V);break; |
c62d2810 |
33 | } |
c0bf6f9f |
34 | if(A>=0x8000) |
c0bf6f9f |
35 | ROM_BANK32(V); |
c62d2810 |
36 | } |
37 | |
38 | void Mapper34_init(void) |
39 | { |
d97315ac |
40 | ROM_BANK32(0); |
c62d2810 |
41 | SetWriteHandler(0x7ffd,0xffff,Mapper34_write); |
42 | } |
43 | |
c62d2810 |
44 | /* I might want to add some code to the mapper 96 PPU hook function |
45 | to not change CHR banks if the attribute table is being accessed, |
46 | if I make emulation a little more accurate in the future. |
47 | */ |
48 | |
49 | static uint8 M96LA; |
50 | static DECLFW(Mapper96_write) |
51 | { |
52 | latche=V; |
53 | setprg32(0x8000,V&3); |
54 | setchr4r(0x10,0x0000,(latche&4)|M96LA); |
55 | setchr4r(0x10,0x1000,(latche&4)|3); |
56 | } |
57 | |
386f5371 |
58 | static void M96Hook(uint32 A) |
c62d2810 |
59 | { |
d97315ac |
60 | if((A&0x3000)!=0x2000) return; |
61 | //if((A&0x3ff)>=0x3c0) return; |
c62d2810 |
62 | M96LA=(A>>8)&3; |
63 | setchr4r(0x10,0x0000,(latche&4)|M96LA); |
64 | } |
65 | |
d97315ac |
66 | static void M96Sync(int v) |
c62d2810 |
67 | { |
68 | setprg32(0x8000,latche&3); |
69 | setchr4r(0x10,0x0000,(latche&4)|M96LA); |
70 | setchr4r(0x10,0x1000,(latche&4)|3); |
71 | } |
72 | |
73 | void Mapper96_init(void) |
74 | { |
75 | SetWriteHandler(0x8000,0xffff,Mapper96_write); |
76 | PPU_hook=M96Hook; |
77 | AddExState(&latche, 1, 0, "LATC"); |
78 | AddExState(&M96LA, 1, 0, "LAVA"); |
79 | SetupCartCHRMapping(0x10, MapperExRAM, 32768, 1); |
80 | latche=M96LA=0; |
d97315ac |
81 | M96Sync(0); |
82 | setmirror(MI_0); |
c62d2810 |
83 | GameStateRestore=M96Sync; |
84 | } |
85 | |
386f5371 |
86 | // DIS23C01 Open Soft, Korea |
87 | // Metal Force (K) |
88 | // Buzz and Waldog (K) |