1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 2002 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
26 static uint8 sim0reg, sim0bit, sim0byte, sim0parity, sim0bcnt;
27 static uint16 sim0data;
28 static uint8 sim0array[128] =
30 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
31 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
32 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
33 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
34 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
35 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
36 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
37 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xAA,
40 static SFORMAT StateRegs[]=
42 {&prg_reg, 1, "PREG"},
43 {&chr_reg, 1, "CREG"},
47 static void Sync(void)
49 setprg32(0x8000, prg_reg);
53 static void StateRestore(int version)
58 static DECLFW(M216WriteHi)
60 // FCEU_printf("%04x:%04x\n",A,V);
66 static DECLFW(M216Write5000)
68 // FCEU_printf("WRITE: %04x:%04x\n",A,V);
72 sim0bit=sim0byte=sim0parity=0;
73 sim0data=sim0array[0];
82 static DECLFR(M216Read5000)
86 sim0reg=(sim0reg^(sim0reg<<1))&0x40;
94 // sim0data=((sim0array[sim0byte]<<(sim0bit))&0x80)>>1;
95 sim0out=(sim0data&1)<<6;
103 sim0out=sim0parity&1;
107 if(sim0byte==sim0bcnt)
113 sim0data=sim0array[sim0byte];
117 // FCEU_printf("READ: %04x (%04x-%02x,%04x)\n",A,X.PC,sim0out,sim0byte);
122 static void Power(void)
127 SetReadHandler(0x8000,0xFFFF,CartBR);
128 SetWriteHandler(0x8000,0xFFFF,M216WriteHi);
129 SetWriteHandler(0x5000,0x5000,M216Write5000);
130 SetReadHandler(0x5000,0x5000,M216Read5000);
134 void Mapper216_Init(CartInfo *info)
137 GameStateRestore=StateRestore;
138 AddExState(&StateRegs, ~0, 0, 0);