c62d2810 |
1 | /* FCE Ultra - NES/Famicom Emulator |
2 | * |
3 | * Copyright notice for this file: |
4 | * Copyright (C) 2002 Ben Parnell |
5 | * |
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. |
10 | * |
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. |
15 | * |
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 |
19 | */ |
20 | |
21 | /* Not finished. Darn evil game... *Mumble*... */ |
22 | |
23 | #include "mapinc.h" |
24 | |
25 | static uint8 cmd; |
26 | static uint8 regs[8]; |
27 | |
28 | static void DoPRG(void) |
29 | { |
30 | if(cmd&0x40) |
31 | { |
32 | setprg8(0xC000,regs[4]); |
33 | setprg8(0xA000,regs[5]); |
34 | setprg8(0x8000,~1); |
35 | setprg8(0xE000,~0); |
36 | } |
37 | else |
38 | { |
39 | setprg8(0x8000,regs[4]); |
40 | setprg8(0xA000,regs[5]); |
41 | setprg8(0xC000,~1); |
42 | setprg8(0xE000,~0); |
43 | } |
44 | } |
45 | |
46 | static void DoCHR(void) |
47 | { |
48 | uint32 base=(cmd&0x80)<<5; |
49 | |
50 | setchr2(0x0000^base,regs[0]); |
51 | setchr2(0x0800^base,regs[2]); |
52 | |
53 | setchr1(0x1000^base,regs[6]); |
54 | setchr1(0x1400^base,regs[1]); |
55 | setchr1(0x1800^base,regs[7]); |
56 | setchr1(0x1c00^base,regs[3]); |
57 | } |
58 | |
59 | static DECLFW(H2288Write) |
60 | { |
61 | //printf("$%04x:$%02x, $%04x\n",A,V,X.PC.W); |
62 | //RAM[0x7FB]=0x60; |
63 | switch(A&0xE001) |
64 | { |
65 | case 0xa000:setmirror((V&1)^1);break; |
66 | case 0x8000:// DumpMem("out",0x0000,0xFFFF); |
67 | cmd=V;DoPRG();DoCHR();break; |
68 | case 0x8001:regs[cmd&7]=V; |
69 | if((cmd&7)==4 || (cmd&7)==5) |
70 | DoPRG(); |
71 | else |
72 | DoCHR(); |
73 | break; |
74 | } |
75 | } |
76 | |
77 | static DECLFR(H2288Read) |
78 | { |
79 | //printf("Rd: $%04x, $%04x\n",A,X.PC.W); |
80 | return((X.DB&0xFE)|(A&(A>>8))); |
81 | } |
82 | |
83 | static void H2288Reset(void) |
84 | { |
85 | int x; |
86 | |
87 | SetReadHandler(0x5800,0x5FFF,H2288Read); |
88 | SetReadHandler(0x8000,0xFFFF,CartBR); |
89 | SetWriteHandler(0x8000,0xFFFF,H2288Write); |
90 | for(x=0;x<8;x++) regs[x]=0; |
91 | cmd=0; |
92 | DoPRG(); |
93 | DoCHR(); |
94 | } |
95 | |
96 | void H2288_Init(void) |
97 | { |
98 | BoardPower=H2288Reset; |
99 | } |