| 1 | /* FCE Ultra - NES/Famicom Emulator\r |
| 2 | *\r |
| 3 | * Copyright notice for this file:\r |
| 4 | * Copyright (C) 2008 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 | \r |
| 21 | // M-022 MMC3 based 830118C T-106 4M + 4M\r |
| 22 | \r |
| 23 | #include "mapinc.h"\r |
| 24 | #include "mmc3.h"\r |
| 25 | \r |
| 26 | static void BMC830118CCW(uint32 A, uint8 V)\r |
| 27 | {\r |
| 28 | setchr1(A,(V&0x7F)|((EXPREGS[0]&0x0c)<<5));\r |
| 29 | }\r |
| 30 | \r |
| 31 | static void BMC830118CPW(uint32 A, uint8 V)\r |
| 32 | {\r |
| 33 | if((EXPREGS[0]&0x0C)==0x0C) \r |
| 34 | { \r |
| 35 | if(A==0x8000)\r |
| 36 | {\r |
| 37 | setprg8(A,(V&0x0F)|((EXPREGS[0]&0x0c)<<2));\r |
| 38 | setprg8(0xC000,(V&0x0F)|0x32);\r |
| 39 | }\r |
| 40 | else if(A==0xA000)\r |
| 41 | {\r |
| 42 | setprg8(A,(V&0x0F)|((EXPREGS[0]&0x0c)<<2));\r |
| 43 | setprg8(0xE000,(V&0x0F)|0x32);\r |
| 44 | }\r |
| 45 | }\r |
| 46 | else\r |
| 47 | {\r |
| 48 | setprg8(A,(V&0x0F)|((EXPREGS[0]&0x0c)<<2));\r |
| 49 | }\r |
| 50 | }\r |
| 51 | \r |
| 52 | static DECLFW(BMC830118CLoWrite)\r |
| 53 | {\r |
| 54 | EXPREGS[0] = V;\r |
| 55 | FixMMC3PRG(MMC3_cmd);\r |
| 56 | FixMMC3CHR(MMC3_cmd);\r |
| 57 | }\r |
| 58 | \r |
| 59 | static void BMC830118CReset(void)\r |
| 60 | {\r |
| 61 | EXPREGS[0]=0;\r |
| 62 | MMC3RegReset();\r |
| 63 | }\r |
| 64 | \r |
| 65 | static void BMC830118CPower(void)\r |
| 66 | {\r |
| 67 | EXPREGS[0] = 0;\r |
| 68 | GenMMC3Power();\r |
| 69 | SetWriteHandler(0x6800,0x68FF,BMC830118CLoWrite);\r |
| 70 | }\r |
| 71 | \r |
| 72 | void BMC830118C_Init(CartInfo *info)\r |
| 73 | {\r |
| 74 | GenMMC3_Init(info, 128, 128, 8, 0);\r |
| 75 | pwrap=BMC830118CPW;\r |
| 76 | cwrap=BMC830118CCW;\r |
| 77 | info->Power=BMC830118CPower;\r |
| 78 | info->Reset=BMC830118CReset;\r |
| 79 | AddExState(EXPREGS, 1, 0, "EXPR");\r |
| 80 | }\r |