refresh rate: comments
[fceu.git] / mappers / 215.c
1 /*
2 #include "mapinc.h"
3
4 static uint8 cmdin;
5 static uint8 cmd;
6 static uint8 regs[8];
7 static uint8 master,chrm;
8
9 static void DoPRG215(void)
10 {
11  if(master&0x80)
12  {
13    setprg16(0x8000,master&0x1F);
14    setprg16(0xc000,master&0x1F);
15  }
16  else
17  {
18    setprg8(0x8000,regs[4]); 6
19    setprg8(0xA000,regs[6]); 7   0, 2, 5, 3, 6, 1, 7, 4
20    setprg8(0xC000,~1);
21    setprg8(0xE000,~0);
22  }
23
24 }
25
26 static void DoCHR215(void)
27 {
28  uint32 base=(cmd&0x80)<<5;
29  int orie=(chrm&0x4)<<6;
30
31  setchr2(0x0000^base,(orie|regs[0])>>1); 0
32  setchr2(0x0800^base,(orie|regs[5])>>1); 1
33
34  setchr1(0x1000,orie|regs[1]); 2
35  setchr1(0x1400,orie|regs[3]); 3
36  setchr1(0x1800,orie|regs[7]); 4
37  setchr1(0x1c00,orie|regs[2]); 5
38 }
39
40 static DECLFW(Write215_write)
41 {
42  switch(A&0xF001)
43  {
44   case 0xF001:IRQCount=V+2;break;
45   case 0xF000:X6502_IRQEnd(FCEU_IQEXT);break;
46  }
47  if(A==0x5000)
48  {
49   master=V;
50   DoPRG215();
51 //  DoCHR215();
52  }
53  else if(A==0x5001)
54  {
55   chrm=V;
56   DoCHR215();
57  }
58  else
59  switch(A&0xE001)
60  {
61   case 0xC000:setmirror(((V|(V>>7))&1)^1);break;
62   case 0xa000:cmd=V;cmdin=1;DoCHR215();break;
63   case 0x8001:if(!cmdin) break;
64               regs[cmd&7]=V;
65               DoPRG215();
66               DoCHR215();
67               cmdin=0;
68               break;
69  }
70 }
71
72 static void hooko215(void)
73 {
74  if(IRQCount)
75  {
76   IRQCount--;
77   if(!IRQCount)
78   {
79      X6502_IRQBegin(FCEU_IQEXT);
80   }
81  }
82 }
83
84 void Mapper215_init(void)
85 {
86   int x;
87   for(x=0;x<8;x++) regs[x]=0;
88   master=chrm=cmd=cmdin=IRQCount=0;
89   GameHBIRQHook=hooko215;
90   SetReadHandler(0x8000,0xFFFF,CartBR);
91   SetWriteHandler(0x5000,0xFFFF,Write215_write);
92   DoPRG215();
93   DoCHR215();
94 }
95
96 */