| 1 | /* FCE Ultra - NES/Famicom Emulator |
| 2 | * |
| 3 | * Copyright notice for this file: |
| 4 | * Copyright (C) 2005 CaH4e3 |
| 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 | * BMC 42-in-1 reset switch |
| 21 | */ |
| 22 | |
| 23 | #include "mapinc.h" |
| 24 | |
| 25 | static uint8 hrd_sw; |
| 26 | static uint8 latche; |
| 27 | static SFORMAT StateRegs[]= |
| 28 | { |
| 29 | {&latche, 1, "LATCHE"}, |
| 30 | {&hrd_sw, 1, "HRDSW"}, |
| 31 | {0} |
| 32 | }; |
| 33 | |
| 34 | static void Sync(void) |
| 35 | { |
| 36 | if(!(latche&0x20)) |
| 37 | setprg32r(hrd_sw,0x8000,(latche>>1)&0x0f); |
| 38 | else |
| 39 | { |
| 40 | setprg16r(hrd_sw,0x8000,latche&0x1f); |
| 41 | setprg16r(hrd_sw,0xC000,latche&0x1f); |
| 42 | } |
| 43 | switch((latche>>6)&3) |
| 44 | { |
| 45 | case 0: setmirrorw(0,0,0,1); break; |
| 46 | case 1: setmirror(MI_V); break; |
| 47 | case 2: setmirror(MI_H); break; |
| 48 | case 3: setmirror(MI_1); break; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | static DECLFW(BMC42in1rWrite) |
| 53 | { |
| 54 | latche=V; |
| 55 | Sync(); |
| 56 | } |
| 57 | |
| 58 | static void BMC42in1rReset(void) |
| 59 | { |
| 60 | hrd_sw^=1; |
| 61 | Sync(); |
| 62 | } |
| 63 | |
| 64 | static void BMC42in1rPower(void) |
| 65 | { |
| 66 | latche=0x00; |
| 67 | hrd_sw=0; |
| 68 | setchr8(0); |
| 69 | Sync(); |
| 70 | SetWriteHandler(0x8000,0xFFFF,BMC42in1rWrite); |
| 71 | SetReadHandler(0x8000,0xFFFF,CartBR); |
| 72 | } |
| 73 | |
| 74 | static void StateRestore(int version) |
| 75 | { |
| 76 | Sync(); |
| 77 | } |
| 78 | |
| 79 | void BMC42in1r_Init(CartInfo *info) |
| 80 | { |
| 81 | info->Power=BMC42in1rPower; |
| 82 | info->Reset=BMC42in1rReset; |
| 83 | AddExState(&StateRegs, ~0, 0, 0); |
| 84 | GameStateRestore=StateRestore; |
| 85 | } |
| 86 | |
| 87 | |