-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMapper_68.c
97 lines (84 loc) · 3.26 KB
/
Mapper_68.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include "Mapper_68.h"
uint8 Mapper_68_regs[4];
void Mapper_68_Init() {
ROMBANK0 = ROMPAGE( 0 );
ROMBANK1 = ROMPAGE( 1 );
ROMBANK2 = ROMLASTPAGE( 1 );
ROMBANK3 = ROMLASTPAGE( 0 );
Mapper_68_regs[0] = 0;
Mapper_68_regs[1] = 0;
Mapper_68_regs[2] = 0;
Mapper_68_regs[3] = 0;
}
void SyncMirror() {
if (Mapper_68_regs[0]) {
if (Mapper_68_regs[1] == 0) {
PPUBANK[8] = &VROM[ (Mapper_68_regs[2] + 0x80) * 0x400 ];
PPUBANK[9] = &VROM[ (Mapper_68_regs[3] + 0x80) * 0x400 ];
PPUBANK[10] = &VROM[ (Mapper_68_regs[2] + 0x80) * 0x400 ];
PPUBANK[11] = &VROM[ (Mapper_68_regs[3] + 0x80) * 0x400 ];
} else if (Mapper_68_regs[1] == 1) {
PPUBANK[8] = &VROM[ (Mapper_68_regs[2] + 0x80) * 0x400 ];
PPUBANK[9] = &VROM[ (Mapper_68_regs[2] + 0x80) * 0x400 ];
PPUBANK[10] = &VROM[ (Mapper_68_regs[3] + 0x80) * 0x400 ];
PPUBANK[11] = &VROM[ (Mapper_68_regs[3] + 0x80) * 0x400 ];
} else if (Mapper_68_regs[1] == 2) {
PPUBANK[8] = &VROM[ (Mapper_68_regs[2] + 0x80) * 0x400 ];
PPUBANK[9] = &VROM[ (Mapper_68_regs[2] + 0x80) * 0x400 ];
PPUBANK[10] = &VROM[ (Mapper_68_regs[2] + 0x80) * 0x400 ];
PPUBANK[11] = &VROM[ (Mapper_68_regs[2] + 0x80) * 0x400 ];
} else if (Mapper_68_regs[1] == 3) {
PPUBANK[8] = &VROM[ (Mapper_68_regs[3] + 0x80) * 0x400 ];
PPUBANK[9] = &VROM[ (Mapper_68_regs[3] + 0x80) * 0x400 ];
PPUBANK[10] = &VROM[ (Mapper_68_regs[3] + 0x80) * 0x400 ];
PPUBANK[11] = &VROM[ (Mapper_68_regs[3] + 0x80) * 0x400 ];
}
} else {
if (Mapper_68_regs[1] == 0) {
pNesX_Mirroring(MIRRORING_VERTICAL);
} else if (Mapper_68_regs[1] == 1) {
pNesX_Mirroring(MIRRORING_HORIZONTAL);
} else if (Mapper_68_regs[1] == 2) {
pNesX_Mirroring(MIRRORING_SINGLE_SCREEN_LOW);
} else if (Mapper_68_regs[1] == 3) {
pNesX_Mirroring(MIRRORING_SINGLE_SCREEN_HIGH);
}
}
}
void Mapper_68_Write( uint16 wAddr, unsigned char byData ) {
switch(wAddr & 0xF000) {
case 0x8000: {
PPUBANK[0] = &VROM[ (byData * 2) * 0x400 ];
PPUBANK[1] = &VROM[ ((byData * 2) + 1) * 0x400 ];
} break;
case 0x9000: {
PPUBANK[2] = &VROM[ (byData * 2) * 0x400 ];
PPUBANK[3] = &VROM[ ((byData * 2) + 1) * 0x400 ];
} break;
case 0xA000: {
PPUBANK[4] = &VROM[ (byData * 2) * 0x400 ];
PPUBANK[5] = &VROM[ ((byData * 2) + 1) * 0x400 ];
} break;
case 0xB000: {
PPUBANK[6] = &VROM[ (byData * 2) * 0x400 ];
PPUBANK[7] = &VROM[ ((byData * 2) + 1) * 0x400 ];
} break;
case 0xC000: {
Mapper_68_regs[2] = byData;
SyncMirror();
} break;
case 0xD000: {
Mapper_68_regs[3] = byData;
SyncMirror();
} break;
case 0xE000: {
Mapper_68_regs[0] = (byData & 0x10) >> 4;
Mapper_68_regs[1] = byData & 0x03;
SyncMirror();
} break;
case 0xF000: {
ROMBANK0 = ROMPAGE((byData * 2));
ROMBANK1 = ROMPAGE((byData * 2) + 1);
} break;
}
}