nesemu/mappers/simple_mapper.c

25 lines
744 B
C

#include "../include/mapper.h"
#include "../include/rom.h"
#include <string.h>
#define SIMPLE_MAPPER_PRG_START_ADDR 0x8000
#define PRG_PART_SIZE 0x4000 // 16Kb
void post_prg_load(ram ram, unsigned int prg_size) {
if (prg_size == 2) {
// The whole space is occupied, nothing to do
return;
}
// We need to mirror the data in the upper ram
byte *source = (byte *) &ram[SIMPLE_MAPPER_PRG_START_ADDR];
byte *destination = (byte *) &ram[SIMPLE_MAPPER_PRG_START_ADDR + PRG_PART_SIZE];
memcpy(destination, source, PRG_PART_SIZE);
}
Mapper get_simple_mapper() {
Mapper mapper;
mapper.prg_rom_start_addr = SIMPLE_MAPPER_PRG_START_ADDR;
mapper.post_prg_load = &post_prg_load;
return mapper;
}