map075.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  ** map75.c
 21  **
 22  ** mapper 75 interface
 23  ** $Id: map075.c,v 1.2 2001/04/27 14:37:11 neil Exp $
 24  */
 25  
 26  #include "noftypes.h"
 27  #include "nes_mmc.h"
 28  #include "nes_ppu.h"
 29  
 30  
 31  static uint8 latch[2];
 32  static uint8 hibits;
 33  
 34  /* mapper 75: Konami VRC1 */
 35  static void map75_write(uint32 address, uint8 value)
 36  {
 37     switch ((address & 0xF000) >> 12)
 38     {
 39     case 0x8:
 40        mmc_bankrom(8, 0x8000, value);
 41        break;
 42  
 43     case 0x9:
 44        hibits = (value & 0x06);
 45        
 46        mmc_bankvrom(4, 0x0000, ((hibits & 0x02) << 3) | latch[0]);
 47        mmc_bankvrom(4, 0x1000, ((hibits & 0x04) << 2) | latch[1]);
 48  
 49        if (value & 1)
 50           ppu_mirror(0, 1, 0, 1); /* vert */
 51        else
 52           ppu_mirror(0, 0, 1, 1); /* horiz */
 53  
 54        break;
 55  
 56     case 0xA:
 57        mmc_bankrom(8, 0xA000, value);
 58        break;
 59  
 60     case 0xC:
 61        mmc_bankrom(8, 0xC000, value);
 62        break;
 63  
 64     case 0xE:
 65        latch[0] = (value & 0x0F);
 66        mmc_bankvrom(4, 0x0000, ((hibits & 0x02) << 3) | latch[0]);
 67        break;
 68  
 69     case 0xF:
 70        latch[1] = (value & 0x0F);
 71        mmc_bankvrom(4, 0x1000, ((hibits & 0x04) << 2) | latch[1]);
 72        break;
 73  
 74     default:
 75        break;
 76     }
 77  }
 78  
 79  static const map_memwrite map75_memwrite[] =
 80  {
 81     { 0x8000, 0xFFFF, map75_write },
 82     {     -1,     -1, NULL }
 83  };
 84  
 85  const mapintf_t map75_intf =
 86  {
 87     75, /* mapper number */
 88     "Konami VRC1", /* mapper name */
 89     NULL, /* init 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     map75_memwrite, /* memory write structure */
 96     NULL /* external sound device */
 97  };
 98  
 99  /*
100  ** $Log: map075.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.1.1  2001/04/27 07:03:54  neil
108  ** initial
109  **
110  ** Revision 1.1  2000/10/24 12:19:33  matt
111  ** changed directory structure
112  **
113  ** Revision 1.6  2000/10/22 19:17:46  matt
114  ** mapper cleanups galore
115  **
116  ** Revision 1.5  2000/10/22 15:03:14  matt
117  ** simplified mirroring
118  **
119  ** Revision 1.4  2000/10/21 19:33:38  matt
120  ** many more cleanups
121  **
122  ** Revision 1.3  2000/07/10 05:29:03  matt
123  ** cleaned up some mirroring issues
124  **
125  ** Revision 1.2  2000/07/06 02:48:43  matt
126  ** clearly labelled structure members
127  **
128  ** Revision 1.1  2000/07/06 01:01:56  matt
129  ** initial revision
130  **
131  */