68df5b5d75e0a802f8f4392e29238acd9021978b
[fceu.git] / mappers / 189.c
1 /* Is this an MMC3 workalike piece of hardware, with the addition of
2    a register at $4120 or does it have only partial MMC3 functionality?
3    A good test would be to see if commands 6 and 7 can change PRG banks
4    and of course test the regs >=$c000, on the real cart.
5 */
6 #include "mapinc.h"
7
8 #define cmd mapbyte1[0]
9 static DECLFW(Mapper189_write)
10 {
11  //if(A>=0xc000) printf("$%04x:$%02x\n",A,V);
12  if((A&0xF100)==0x4100) ROM_BANK32(V>>4);
13  else if((A&0xF100)==0x6100) ROM_BANK32(V&3);
14  else switch(A&0xE001)
15  {
16   case 0xa000:MIRROR_SET(V&1);break;
17   case 0x8000:cmd=V;break;
18   case 0x8001:switch(cmd&7)
19               {
20                case 0:VROM_BANK2(0x0000,V>>1);break;
21                case 1:VROM_BANK2(0x0800,V>>1);break;
22                case 2:VROM_BANK1(0x1000,V);break;
23                case 3:VROM_BANK1(0x1400,V);break;
24                case 4:VROM_BANK1(0x1800,V);break;
25                case 5:VROM_BANK1(0x1C00,V);break;
26               }
27    case 0xc000:IRQLatch=V;break;
28    case 0xc001:IRQCount=IRQLatch;break;
29    case 0xe000:IRQa=0;X6502_IRQEnd(FCEU_IQEXT);break;
30    case 0xe001:IRQa=1;break;
31               break;
32
33  }
34 }
35 void m189irq(void)
36 {
37  if(IRQa)
38  {
39   if(IRQCount)
40   {
41    IRQCount--;
42    if(!IRQCount) X6502_IRQBegin(FCEU_IQEXT);
43   }
44  }
45
46 }
47 void Mapper189_init(void)
48 {
49   GameHBIRQHook=m189irq;
50   SetWriteHandler(0x4120,0xFFFF,Mapper189_write);
51   SetReadHandler(0x6000,0x7FFF,0);
52   ROM_BANK32(0);
53 }
54
55