1 /* FCE Ultra - NES/Famicom Emulator
\r
3 * Copyright notice for this file:
\r
4 * Copyright (C) 2005 CaH4e3
\r
6 * This program is free software; you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation; either version 2 of the License, or
\r
9 * (at your option) any later version.
\r
11 * This program is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with this program; if not, write to the Free Software
\r
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
20 * CAI Shogakko no Sansu
\r
25 static uint8 *CHRRAM=NULL;
\r
26 static uint8 SWRAM[4096];
\r
28 static uint8 regs[16];
\r
29 static uint8 WRAM[4096];
\r
30 static SFORMAT StateRegs[]=
\r
32 {®s, 16, "REGS"},
\r
33 {WRAM, 4096, "WRAM"},
\r
37 static void Sync(void)
\r
41 setchr4r(0,0x1000,regs[5]&0x3F);
\r
45 setchr4r(0x10,0x0000,regs[5]);
\r
46 setchr4r(0x10,0x1000,regs[5]^1);
\r
48 setprg8r((regs[2]>>6)&1,0x8000,(regs[2]&0x3F));
\r
49 setprg8r((regs[3]>>6)&1,0xA000,(regs[3]&0x3F));
\r
50 setprg8r((regs[4]>>6)&1,0xC000,(regs[4]&0x3F));
\r
51 setprg8r(1,0xE000,~0);
\r
52 setmirror((regs[0xA]&3));
\r
55 static DECLFW(M190Write)
\r
57 // FCEU_printf("write %04x:%04x %d, %d\n",A,V,scanline,timestamp);
\r
58 regs[(A&0x0F00)>>8]=V;
\r
62 static DECLFR(M190Read)
\r
64 // FCEU_printf("read %04x:%04x %d, %d\n",A,regs[(A&0x0F00)>>8],scanline,timestamp);
\r
65 return regs[(A&0x0F00)>>8];
\r
68 static DECLFR(AWRAM)
\r
70 return(WRAM[A-0x7000]);
\r
72 static DECLFW(BWRAM)
\r
77 static DECLFR(ASWRAM)
\r
79 return(SWRAM[A-0x6000]);
\r
81 static DECLFW(BSWRAM)
\r
86 static void M190Power(void)
\r
89 SetReadHandler(0x8000,0xFFFF,CartBR);
\r
90 SetWriteHandler(0x8000,0xFFFF,M190Write);
\r
91 // SetReadHandler(0xDA00,0xDA00,M190Read);
\r
92 // SetReadHandler(0xDB00,0xDB00,M190Read);
\r
93 SetReadHandler(0xDC00,0xDC00,M190Read);
\r
94 SetReadHandler(0xDD00,0xDD00,M190Read);
\r
95 SetReadHandler(0x7000,0x7FFF,AWRAM);
\r
96 SetWriteHandler(0x7000,0x7FFF,BWRAM);
\r
97 SetReadHandler(0x6000,0x6FFF,ASWRAM);
\r
98 SetWriteHandler(0x6000,0x6FFF,BSWRAM);
\r
102 static void M190Close(void)
\r
105 FCEU_gfree(CHRRAM);
\r
109 static void StateRestore(int version)
\r
114 void Mapper190_Init(CartInfo *info)
\r
116 info->Power=M190Power;
\r
117 info->Close=M190Close;
\r
120 info->SaveGame[0]=SWRAM;
\r
121 info->SaveGameLen[0]=4096;
\r
123 GameStateRestore=StateRestore;
\r
124 CHRRAM=(uint8*)FCEU_gmalloc(8192);
\r
125 SetupCartCHRMapping(0x10,CHRRAM,8192,1);
\r
126 AddExState(CHRRAM, 8192, 0, "CHRRAM");
\r
127 AddExState(&StateRegs, ~0, 0, 0);
\r