1 /* FCE Ultra - NES/Famicom Emulator
\r
3 * Copyright notice for this file:
\r
4 * Copyright (C) 2009 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
23 static uint8 reg[7];
\r
24 static uint8 *WRAM=NULL;
\r
25 static uint32 WRAMSIZE;
\r
27 static SFORMAT StateRegs[]=
\r
33 static uint8 bs_tbl[128] = {
\r
34 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33,
\r
35 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67,
\r
36 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33, 0x03, 0x13, 0x23, 0x33,
\r
37 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67,
\r
38 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32,
\r
39 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67, 0x45, 0x67,
\r
40 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, 0x02, 0x12, 0x22, 0x32, 0x00, 0x10, 0x20, 0x30,
\r
41 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67, 0x47, 0x67,
\r
44 static uint8 br_tbl[16] = {
\r
45 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
\r
48 static void Sync(void)
\r
50 // setchr4(0x0000,(reg[0]&0x80) >> 7);
\r
51 // setchr4(0x1000,(reg[0]&0x80) >> 7);
\r
53 setprg8r(0x10,0x6000,0);
\r
54 setprg16(0x8000,bs_tbl[reg[0]&0x7f]>>4);
\r
55 setprg16(0xc000,bs_tbl[reg[0]&0x7f]&0xf);
\r
59 static DECLFW(UNLPEC586Write)
\r
61 reg[(A&0x700)>>8]=V;
\r
62 FCEU_printf("bs %04x %02x\n",A,V);
\r
66 static DECLFR(UNLPEC586Read)
\r
68 FCEU_printf("read %04x\n",A);
\r
69 return (X.DB & 0xD8) | br_tbl[reg[4]>>4];
\r
72 static void UNLPEC586Power(void)
\r
77 SetReadHandler(0x6000,0x7FFF,CartBR);
\r
78 SetWriteHandler(0x6000,0x7FFF,CartBW);
\r
79 SetReadHandler(0x8000,0xFFFF,CartBR);
\r
80 SetWriteHandler(0x5000,0x5fff,UNLPEC586Write);
\r
81 SetReadHandler(0x5000,0x5fff,UNLPEC586Read);
\r
84 static void UNLPEC586IRQ(void)
\r
99 static void UNLPEC586Close(void)
\r
106 static void StateRestore(int version)
\r
111 void UNLPEC586Init(CartInfo *info)
\r
113 info->Power=UNLPEC586Power;
\r
114 info->Close=UNLPEC586Close;
\r
115 GameHBIRQHook=UNLPEC586IRQ;
\r
116 GameStateRestore=StateRestore;
\r
119 WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
\r
120 SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
\r
121 AddExState(WRAM, WRAMSIZE, 0, "WRAM");
\r
123 AddExState(&StateRegs, ~0, 0, 0);
\r