1 /* FCE Ultra - NES/Famicom Emulator
\r
3 * Copyright notice for this file:
\r
4 * Copyright (C) 2007 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 * City Fighter IV sith Sound VRC4 hacked
\r
25 static uint8 IRQCount;
\r
26 static uint8 IRQPre;
\r
28 static uint8 prg_reg, prg_mode, mirr;
\r
29 static uint8 chr_reg[8];
\r
31 static SFORMAT StateRegs[]=
\r
33 {&IRQCount, 1, "IRQC"},
\r
34 {&IRQPre, 1, "IRQP"},
\r
36 {&prg_reg, 1, "PREG"},
\r
37 {&prg_mode, 1, "PMOD"},
\r
39 {chr_reg, 8, "CREG"},
\r
43 static void Sync(void)
\r
45 setprg32(0x8000,prg_reg>>2);
\r
47 setprg8(0xC000,prg_reg);
\r
50 setchr1(i<<10,chr_reg[i]);
\r
53 case 0: setmirror(MI_V); break;
\r
54 case 1: setmirror(MI_H); break;
\r
55 case 2: setmirror(MI_0); break;
\r
56 case 3: setmirror(MI_1); break;
\r
60 static DECLFW(UNLCITYFIGHTWrite)
\r
64 case 0x9000: prg_reg=V&0xC; mirr=V&3; break;
\r
67 case 0x900C: prg_reg=V&0xC; break;
\r
71 case 0xC00C: prg_mode=V&1; break;
\r
72 case 0xD000: chr_reg[0]=(chr_reg[0]&0xF0)|(V&0x0F); break;
\r
73 case 0xD004: chr_reg[0]=(chr_reg[0]&0x0F)|(V<<4); break;
\r
74 case 0xD008: chr_reg[1]=(chr_reg[1]&0xF0)|(V&0x0F); break;
\r
75 case 0xD00C: chr_reg[1]=(chr_reg[1]&0x0F)|(V<<4); break;
\r
76 case 0xA000: chr_reg[2]=(chr_reg[2]&0xF0)|(V&0x0F); break;
\r
77 case 0xA004: chr_reg[2]=(chr_reg[2]&0x0F)|(V<<4); break;
\r
78 case 0xA008: chr_reg[3]=(chr_reg[3]&0xF0)|(V&0x0F); break;
\r
79 case 0xA00C: chr_reg[3]=(chr_reg[3]&0x0F)|(V<<4); break;
\r
80 case 0xB000: chr_reg[4]=(chr_reg[4]&0xF0)|(V&0x0F); break;
\r
81 case 0xB004: chr_reg[4]=(chr_reg[4]&0x0F)|(V<<4); break;
\r
82 case 0xB008: chr_reg[5]=(chr_reg[5]&0xF0)|(V&0x0F); break;
\r
83 case 0xB00C: chr_reg[5]=(chr_reg[5]&0x0F)|(V<<4); break;
\r
84 case 0xE000: chr_reg[6]=(chr_reg[6]&0xF0)|(V&0x0F); break;
\r
85 case 0xE004: chr_reg[6]=(chr_reg[6]&0x0F)|(V<<4); break;
\r
86 case 0xE008: chr_reg[7]=(chr_reg[7]&0xF0)|(V&0x0F); break;
\r
87 case 0xE00C: chr_reg[7]=(chr_reg[7]&0x0F)|(V<<4); break;
\r
88 // case 0xF004: IRQCount=((IRQCount&0xF0)|(V&0xF)); break;
\r
89 // case 0xF000: IRQCount=((IRQCount&0x0F)|((V&0xF)<<4)); break;
\r
90 case 0xF008: IRQa=V&2; X6502_IRQEnd(FCEU_IQEXT); break;
\r
91 // case 0xF00C: IRQPre=16; break;
\r
93 FCEU_printf("bs %04x %02x\n",A,V);
\r
98 static DECLFW(UNLCITYFIGHTWriteLo)
\r
100 FCEU_printf("bs %04x %02x\n",A,V);
\r
103 static void UNLCITYFIGHTIRQ(void)
\r
108 // if((IRQCount>>1)==0)
\r
109 // X6502_IRQBegin(FCEU_IQEXT);
\r
110 // if(scanline==100) X6502_IRQBegin(FCEU_IQEXT);
\r
114 static void UNLCITYFIGHTPower(void)
\r
118 SetReadHandler(0x8000,0xFFFF,CartBR);
\r
119 SetWriteHandler(0x4020,0x7FFF,UNLCITYFIGHTWriteLo);
\r
120 SetWriteHandler(0x8000,0xFFFF,UNLCITYFIGHTWrite);
\r
123 static void StateRestore(int version)
\r
128 void UNLCITYFIGHT_Init(CartInfo *info)
\r
130 info->Power=UNLCITYFIGHTPower;
\r
131 GameHBIRQHook=UNLCITYFIGHTIRQ;
\r
132 GameStateRestore=StateRestore;
\r
133 AddExState(&StateRegs, ~0, 0, 0);
\r