mapper fixes for ncpu, debug is broken atm
[fceu.git] / mappers / 68.c
CommitLineData
c62d2810 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
23static void Fixerit(void)
24{
25 switch(mapbyte2[0]&3)
26 {
27 case 0:vnapage[0]=vnapage[2]=VROM+(((mapbyte1[0]|128)&CHRmask1[0])<<10);
28 vnapage[1]=vnapage[3]=VROM+(((mapbyte1[1]|128)&CHRmask1[0])<<10);
29 break;
30 case 1:vnapage[0]=vnapage[1]=VROM+(((mapbyte1[0]|128)&CHRmask1[0])<<10);
31 vnapage[2]=vnapage[3]=VROM+(((mapbyte1[1]|128)&CHRmask1[0])<<10);
32 break;
33 case 2:vnapage[0]=vnapage[1]=vnapage[2]=vnapage[3]=VROM+(((mapbyte1[0]|128)&CHRmask1[0])<<10);
34 break;
35 case 3:vnapage[0]=vnapage[1]=vnapage[2]=vnapage[3]=VROM+(((mapbyte1[1]|128)&CHRmask1[0])<<10);
36 break;
37 }
38}
39
40DECLFW(Mapper68_write)
41{
42 A&=0xF000;
43
44 if(A>=0x8000 && A<=0xB000)
45 {
46 VROM_BANK2((A-0x8000)>>1,V);
47 }
48 else switch(A)
49 {
50 case 0xc000:mapbyte1[0]=V;
51 if(VROM_size && mapbyte2[0]&0x10)
52 Fixerit();
53 break;
54
55 case 0xd000:mapbyte1[1]=V;
56 if(VROM_size && mapbyte2[0]&0x10)
57 Fixerit();
58 break;
59
60 case 0xe000: mapbyte2[0]=V;
61 if(!(V&0x10))
62 {
63 switch(V&3)
64 {
65 case 0:MIRROR_SET2(1);break;
66 case 1:MIRROR_SET2(0);break;
67 case 2:onemir(0);break;
68 case 3:onemir(1);break;
69 }
70 }
71 else if(VROM_size)
72 {
73 Fixerit();
74 PPUNTARAM=0;
75 }
76 break;
c0bf6f9f 77 case 0xf000: ROM_BANK16(0x8000,V);
78 X6502_Rebase();break;
c62d2810 79 }
80}
81
82static void Mapper68_StateRestore(int version)
83{
84 if(!(mapbyte2[0]&0x10))
85 {
86 switch(mapbyte2[0]&3)
87 {
88 case 0:MIRROR_SET(0);break;
89 case 1:MIRROR_SET(1);break;
90 case 2:onemir(0);break;
91 case 3:onemir(1);break;
92 }
93 }
94 else if(VROM_size)
95 {
96 Fixerit();
97 PPUNTARAM=0;
98 }
99}
100
101void Mapper68_init(void)
102{
103 SetWriteHandler(0x8000,0xffff,Mapper68_write);
104 MapStateRestore=Mapper68_StateRestore;
105}