| 1 | /* FCE Ultra - NES/Famicom Emulator\r |
| 2 | *\r |
| 3 | * Copyright notice for this file:\r |
| 4 | * Copyright (C) 2011 CaH4e3\r |
| 5 | *\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 |
| 10 | *\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 |
| 15 | *\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 |
| 19 | * \r |
| 20 | * PCB-018 board, discrete multigame cart 110-in-1\r |
| 21 | *\r |
| 22 | */\r |
| 23 | \r |
| 24 | #include "mapinc.h"\r |
| 25 | \r |
| 26 | static uint8 prot[4], prg, mode, chr, mirr;\r |
| 27 | \r |
| 28 | static SFORMAT StateRegs[]=\r |
| 29 | {\r |
| 30 | {prot, 4, "PROT"},\r |
| 31 | {&prg, 1, "PRG"},\r |
| 32 | {&chr, 1, "CHR"},\r |
| 33 | {&mode, 1, "MODE"},\r |
| 34 | {&mirr, 1, "MIRR"},\r |
| 35 | {0}\r |
| 36 | };\r |
| 37 | \r |
| 38 | static void Sync(void)\r |
| 39 | {\r |
| 40 | if(mode)\r |
| 41 | {\r |
| 42 | setprg16(0x8000,prg);\r |
| 43 | setprg16(0xC000,prg);\r |
| 44 | }\r |
| 45 | else\r |
| 46 | setprg32(0x8000,prg>>1);\r |
| 47 | setchr8(chr);\r |
| 48 | setmirror(mirr);\r |
| 49 | }\r |
| 50 | \r |
| 51 | static DECLFW(M225Write)\r |
| 52 | {\r |
| 53 | uint32 bank = (A >> 14) & 1;\r |
| 54 | mirr = (A >> 13) & 1;\r |
| 55 | mode = (A >> 12) & 1;\r |
| 56 | chr = (A & 0x3f) | (bank << 6);\r |
| 57 | prg = ((A >> 6) & 0x3f) | (bank << 6);\r |
| 58 | Sync();\r |
| 59 | }\r |
| 60 | \r |
| 61 | static DECLFW(M225LoWrite)\r |
| 62 | {\r |
| 63 | }\r |
| 64 | \r |
| 65 | static DECLFR(M225LoRead)\r |
| 66 | {\r |
| 67 | return 0;\r |
| 68 | }\r |
| 69 | \r |
| 70 | static void M225Power(void)\r |
| 71 | { \r |
| 72 | prg = 0;\r |
| 73 | mode = 0;\r |
| 74 | Sync();\r |
| 75 | SetReadHandler(0x5000,0x5fff,M225LoRead);\r |
| 76 | SetWriteHandler(0x5000,0x5fff,M225LoWrite);\r |
| 77 | SetReadHandler(0x8000,0xFFFF,CartBR);\r |
| 78 | SetWriteHandler(0x8000,0xFFFF,M225Write);\r |
| 79 | }\r |
| 80 | \r |
| 81 | static void M225Reset(void)\r |
| 82 | {\r |
| 83 | prg = 0;\r |
| 84 | mode = 0;\r |
| 85 | Sync();\r |
| 86 | }\r |
| 87 | \r |
| 88 | static void StateRestore(int version)\r |
| 89 | {\r |
| 90 | Sync();\r |
| 91 | }\r |
| 92 | \r |
| 93 | void Mapper225_Init(CartInfo *info)\r |
| 94 | {\r |
| 95 | info->Reset=M225Reset;\r |
| 96 | info->Power=M225Power;\r |
| 97 | GameStateRestore=StateRestore;\r |
| 98 | AddExState(&StateRegs, ~0, 0, 0);\r |
| 99 | }\r |