blob: 398795610cd87b23a709f8538514ef1e41bae434 (
plain)
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
|
static uint8_t mapper_007_2_prg_rom_read(struct nes_state *state, uint32_t addr) {
struct mapper_007_2 *mapper = &state->mapper_data.m007_2;
if(addr >= 0x8000) {
return mapper->prg_rom[addr & 0x7fff];
}
return 0;
}
static void mapper_007_2_prg_rom_write(struct nes_state *state, uint32_t addr, uint8_t value) {
struct mapper_007_2 *mapper = &state->mapper_data.m007_2;
if(addr >= 0x8000) {
uint32_t prg_off = (value & 0x0f) << 15;
uint32_t ciram_off = (value & 0x10) << 11;
mapper->prg_rom = state->prg_rom + prg_off;
mapper->ciram = state->ciram + ciram_off;
// mapper->prg_rom = state->prg_rom + ((value & 0x0f) * 0x8000);
// mapper->ciram = state->ciram + ((value & 0x10) ? 0x400 : 0x000);
}
}
static uint8_t mapper_007_2_chr_read(struct nes_state *state, uint32_t addr) {
return state->chr_ram[addr];
}
static void mapper_007_2_chr_write(struct nes_state *state, uint32_t addr, uint8_t value) {
state->chr_ram[addr] = value;
}
static uint8_t mapper_007_2_ciram_read(struct nes_state *state, uint32_t addr) {
struct mapper_007_2 *mapper = &state->mapper_data.m007_2;
return mapper->ciram[addr & 0x3ff];
}
static void mapper_007_2_ciram_write(struct nes_state *state, uint32_t addr, uint8_t value) {
struct mapper_007_2 *mapper = &state->mapper_data.m007_2;
mapper->ciram[addr & 0x3ff] = value;
}
static void mapper_007_2_init(struct nes_state *state) {
struct mapper_007_2 *mapper = &state->mapper_data.m007_2;
mapper->prg_rom = state->prg_rom;
mapper->ciram = state->ciram; // << THIS WAS THE BUG, set ciram = 0, zero understanding to how this worked for 6+ months.
state->mapper_function.prg_rom_read = mapper_007_2_prg_rom_read;
state->mapper_function.prg_rom_write = mapper_007_2_prg_rom_write;
state->mapper_function.chr_read = mapper_007_2_chr_read;
state->mapper_function.chr_write = mapper_007_2_chr_write;
state->mapper_function.ciram_read = mapper_007_2_ciram_read;
state->mapper_function.ciram_write = mapper_007_2_ciram_write;
}
|