map229.c
1 /* 2 ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 ** 4 ** 5 ** This program is free software; you can redistribute it and/or 6 ** modify it under the terms of version 2 of the GNU Library General 7 ** Public License as published by the Free Software Foundation. 8 ** 9 ** This program is distributed in the hope that it will be useful, 10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 ** Library General Public License for more details. To obtain a 13 ** copy of the GNU Library General Public License, write to the Free 14 ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 ** 16 ** Any permitted reproduction of these routines, in whole or in part, 17 ** must bear this legend. 18 ** 19 ** 20 ** map229.c 21 ** 22 ** Mapper #229 (31 in 1) 23 ** Implementation by Firebug 24 ** Mapper information courtesy of Mark Knibbs 25 ** $Id: map229.c,v 1.2 2001/04/27 14:37:11 neil Exp $ 26 ** 27 */ 28 29 #include "noftypes.h" 30 #include "nes_mmc.h" 31 #include "nes.h" 32 #include "libsnss.h" 33 #include "log.h" 34 35 /************************/ 36 /* Mapper #229: 31 in 1 */ 37 /************************/ 38 static void map229_init (void) 39 { 40 /* On reset, PRG is set to first 32K and CHR to first 8K */ 41 mmc_bankrom (32, 0x8000, 0x00); 42 mmc_bankvrom (8, 0x0000, 0x00); 43 44 /* Done */ 45 return; 46 } 47 48 /*******************************************/ 49 /* Mapper #229 write handler ($8000-$FFFF) */ 50 /*******************************************/ 51 static void map229_write (uint32 address, uint8 value) 52 { 53 /* Value written is irrelevant */ 54 UNUSED (value); 55 56 /* A4-A0 sets 8K CHR page */ 57 mmc_bankvrom (8, 0x0000, (uint8) (address & 0x1F)); 58 59 /* If A4-A1 are all low then select the first 32K, */ 60 /* otherwise select a 16K bank at both $8000 and $C000 */ 61 if ((address & 0x1E) == 0x00) 62 { 63 mmc_bankrom (32, 0x8000, 0x00); 64 } 65 else 66 { 67 mmc_bankrom (16, 0x8000, (uint8) (address & 0x1F)); 68 mmc_bankrom (16, 0xC000, (uint8) (address & 0x1F)); 69 } 70 71 /* A5: mirroring (low = vertical, high = horizontal) */ 72 if (address & 0x20) ppu_mirror(0, 0, 1, 1); 73 else ppu_mirror(0, 1, 0, 1); 74 75 /* Done */ 76 return; 77 } 78 79 static const map_memwrite map229_memwrite [] = 80 { 81 { 0x8000, 0xFFFF, map229_write }, 82 { -1, -1, NULL } 83 }; 84 85 const mapintf_t map229_intf = 86 { 87 229, /* Mapper number */ 88 "31 in 1 (bootleg)", /* Mapper name */ 89 map229_init, /* Initialization routine */ 90 NULL, /* VBlank callback */ 91 NULL, /* HBlank callback */ 92 NULL, /* Get state (SNSS) */ 93 NULL, /* Set state (SNSS) */ 94 NULL, /* Memory read structure */ 95 map229_memwrite, /* Memory write structure */ 96 NULL /* External sound device */ 97 }; 98 99 /* 100 ** $Log: map229.c,v $ 101 ** Revision 1.2 2001/04/27 14:37:11 neil 102 ** wheeee 103 ** 104 ** Revision 1.1 2001/04/27 12:54:40 neil 105 ** blah 106 ** 107 ** Revision 1.1 2001/04/27 10:57:41 neil 108 ** wheee 109 ** 110 ** Revision 1.1 2000/12/30 06:34:31 firebug 111 ** Initial revision 112 ** 113 ** 114 */