3
/* Mapper #8 (FFE F3xxx). */
5
/* This mapper is fully supported. */
8
#include "mmc/shared.h"
11
static int ffe_f3_init (void);
13
static void ffe_f3_reset (void);
16
static void ffe_f3_save_state (PACKFILE *, int);
18
static void ffe_f3_load_state (PACKFILE *, int);
21
static const MMC mmc_ffe_f3 =
25
ffe_f3_init, ffe_f3_reset,
30
ffe_f3_save_state, ffe_f3_load_state
34
static UINT8 ffe_f3_last_write = 0;
37
#define FFE_F3_PRG_ROM_MASK 0xf8
39
#define FFE_F3_CHR_ROM_MASK 0x07
42
static void ffe_f3_write (UINT16 address, UINT8 value)
52
/* Store page #s for state saving. */
54
ffe_f3_last_write = value;
57
/* Extract ROM page # (xxxxx000). */
59
prg_page = ((value & FFE_F3_PRG_ROM_MASK) >> 3);
62
/* Select requested 16k ROM page at $8000. */
64
cpu_set_read_address_16k_rom_block (0x8000, prg_page);
67
/* Extract CHR-ROM page # (00000xxx). */
69
chr_page = (value & FFE_F3_CHR_ROM_MASK);
72
/* Convert 8k page # to 1k. */
77
/* Select requested 8k CHR-ROM page. */
79
for (index = 0; index < 8; index ++)
81
ppu_set_ram_1k_pattern_vrom_block ((index << 10), (chr_page + index));
86
static void ffe_f3_reset (void)
91
/* Note: Upper 16k ROM bank is hard-wired. */
93
/* Select first 32k ROM page. */
95
cpu_set_read_address_32k_rom_block (0x8000, MMC_FIRST_ROM_BLOCK);
98
/* Select first 8k CHR-ROM page. */
100
for (index = 0; index < 8; index ++)
102
ppu_set_ram_1k_pattern_vrom_block ((index << 10), index);
107
static int ffe_f3_init (void)
109
/* Mapper requires some CHR ROM */
110
if (mmc_pattern_vram_in_use)
116
/* Install write handler. */
118
cpu_set_write_handler_32k (0x8000, ffe_f3_write);
121
/* Set initial mappings. */
130
static void ffe_f3_save_state (PACKFILE * file, int version)
132
pack_putc (ffe_f3_last_write, file);
136
static void ffe_f3_load_state (PACKFILE * file, int version)
138
ffe_f3_write (0x8000, pack_getc (file));