map046.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 ** map046.c 21 ** 22 ** Mapper #46 (Pelican Game Station) 23 ** Implementation by Firebug 24 ** Mapper information courtesy of Kevin Horton 25 ** $Id: map046.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 static uint8 prg_low_bank; 36 static uint8 chr_low_bank; 37 static uint8 prg_high_bank; 38 static uint8 chr_high_bank; 39 40 /*************************************************/ 41 /* Set banks from the combined register values */ 42 /*************************************************/ 43 static void map46_set_banks (void) 44 { 45 /* Set the PRG and CHR pages */ 46 mmc_bankrom (32, 0x8000, (prg_high_bank << 1) | (prg_low_bank)); 47 mmc_bankvrom (8, 0x0000, (chr_high_bank << 3) | (chr_low_bank)); 48 49 /* Done */ 50 return; 51 } 52 53 /*********************************************************/ 54 /* Mapper #46: Pelican Game Station (aka Rumble Station) */ 55 /*********************************************************/ 56 static void map46_init (void) 57 { 58 /* High bank switch register is set to zero on reset */ 59 prg_high_bank = 0x00; 60 chr_high_bank = 0x00; 61 map46_set_banks (); 62 63 /* Done */ 64 return; 65 } 66 67 /******************************************/ 68 /* Mapper #46 write handler ($6000-$FFFF) */ 69 /******************************************/ 70 static void map46_write (uint32 address, uint8 value) 71 { 72 /* $8000-$FFFF: D6-D4 = lower three bits of CHR bank */ 73 /* D0 = low bit of PRG bank */ 74 /* $6000-$7FFF: D7-D4 = high four bits of CHR bank */ 75 /* D3-D0 = high four bits of PRG bank */ 76 if (address & 0x8000) 77 { 78 prg_low_bank = value & 0x01; 79 chr_low_bank = (value >> 4) & 0x07; 80 map46_set_banks (); 81 } 82 else 83 { 84 prg_high_bank = value & 0x0F; 85 chr_high_bank = (value >> 4) & 0x0F; 86 map46_set_banks (); 87 } 88 89 /* Done */ 90 return; 91 } 92 93 /****************************************************/ 94 /* Shove extra mapper information into a SNSS block */ 95 /****************************************************/ 96 static void map46_setstate (SnssMapperBlock *state) 97 { 98 /* TODO: Store SNSS information */ 99 UNUSED (state); 100 101 /* Done */ 102 return; 103 } 104 105 /*****************************************************/ 106 /* Pull extra mapper information out of a SNSS block */ 107 /*****************************************************/ 108 static void map46_getstate (SnssMapperBlock *state) 109 { 110 /* TODO: Retrieve SNSS information */ 111 UNUSED (state); 112 113 /* Done */ 114 return; 115 } 116 117 static const map_memwrite map46_memwrite [] = 118 { 119 { 0x6000, 0xFFFF, map46_write }, 120 { -1, -1, NULL } 121 }; 122 123 const mapintf_t map46_intf = 124 { 125 46, /* Mapper number */ 126 "Pelican Game Station", /* Mapper name */ 127 map46_init, /* Initialization routine */ 128 NULL, /* VBlank callback */ 129 NULL, /* HBlank callback */ 130 map46_getstate, /* Get state (SNSS) */ 131 map46_setstate, /* Set state (SNSS) */ 132 NULL, /* Memory read structure */ 133 map46_memwrite, /* Memory write structure */ 134 NULL /* External sound device */ 135 }; 136 137 /* 138 ** $Log: map046.c,v $ 139 ** Revision 1.2 2001/04/27 14:37:11 neil 140 ** wheeee 141 ** 142 ** Revision 1.1 2001/04/27 12:54:40 neil 143 ** blah 144 ** 145 ** Revision 1.1 2001/04/27 10:57:41 neil 146 ** wheee 147 ** 148 ** Revision 1.1 2000/12/27 19:23:05 firebug 149 ** initial revision 150 ** 151 ** 152 */