1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 2005 CaH4e3
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.
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.
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
20 * CAI Shogakko no Sansu
25 static uint8 *CHRRAM=NULL;
26 static uint8 SWRAM[4096];
28 static uint8 regs[16];
29 static uint8 WRAM[4096];
30 static SFORMAT StateRegs[]=
37 static void Sync(void)
41 setchr4r(0,0x1000,regs[5]&0x3F);
45 setchr4r(0x10,0x0000,regs[5]);
46 setchr4r(0x10,0x1000,regs[5]^1);
48 setprg8r((regs[2]>>6)&1,0x8000,(regs[2]&0x3F));
49 setprg8r((regs[3]>>6)&1,0xA000,(regs[3]&0x3F));
50 setprg8r((regs[4]>>6)&1,0xC000,(regs[4]&0x3F));
51 setprg8r(1,0xE000,~0);
52 setmirror((regs[0xA]&3));
55 static DECLFW(M190Write)
57 // FCEU_printf("write %04x:%04x %d, %d\n",A,V,scanline,timestamp);
58 regs[(A&0x0F00)>>8]=V;
62 static DECLFR(M190Read)
64 // FCEU_printf("read %04x:%04x %d, %d\n",A,regs[(A&0x0F00)>>8],scanline,timestamp);
65 return regs[(A&0x0F00)>>8];
70 return(WRAM[A-0x7000]);
79 return(SWRAM[A-0x6000]);
86 static void M190Power(void)
89 SetReadHandler(0x8000,0xFFFF,CartBR);
90 SetWriteHandler(0x8000,0xFFFF,M190Write);
91 // SetReadHandler(0xDA00,0xDA00,M190Read);
92 // SetReadHandler(0xDB00,0xDB00,M190Read);
93 SetReadHandler(0xDC00,0xDC00,M190Read);
94 SetReadHandler(0xDD00,0xDD00,M190Read);
95 SetReadHandler(0x7000,0x7FFF,AWRAM);
96 SetWriteHandler(0x7000,0x7FFF,BWRAM);
97 SetReadHandler(0x6000,0x6FFF,ASWRAM);
98 SetWriteHandler(0x6000,0x6FFF,BSWRAM);
100 Page[14]=Page[15]=WRAM-0x7000;
101 Page[12]=Page[13]=SWRAM-0x6000;
106 static void M190Close(void)
113 static void StateRestore(int version)
118 void Mapper190_Init(CartInfo *info)
120 info->Power=M190Power;
121 info->Close=M190Close;
124 info->SaveGame[0]=SWRAM;
125 info->SaveGameLen[0]=4096;
127 GameStateRestore=StateRestore;
128 CHRRAM=(uint8*)FCEU_gmalloc(8192);
129 SetupCartCHRMapping(0x10,CHRRAM,8192,1);
130 AddExState(CHRRAM, 8192, 0, "CHRRAM");
131 AddExState(&StateRegs, ~0, 0, 0);