nesemu/mappers/simple_mapper.c

26 lines
758 B
C
Raw Normal View History

2023-11-26 12:11:49 -05:00
#include "../include/mapper.h"
2024-01-06 14:27:09 -05:00
#include "../include/rom.h"
2024-05-06 20:23:44 -04:00
#include "../cpu/memory.h"
2024-01-06 14:27:09 -05:00
#include <string.h>
2023-11-26 12:11:49 -05:00
2024-01-06 14:27:09 -05:00
#define SIMPLE_MAPPER_PRG_START_ADDR 0x8000
#define PRG_PART_SIZE 0x4000 // 16Kb
2024-05-06 20:23:44 -04:00
void post_prg_load(unsigned int prg_size) {
2024-01-06 14:27:09 -05:00
if (prg_size == 2) {
// The whole space is occupied, nothing to do
return;
}
// We need to mirror the data in the upper ram
2024-05-06 20:23:44 -04:00
byte *source = mem_get_ptr(SIMPLE_MAPPER_PRG_START_ADDR);
byte *destination = mem_get_ptr(SIMPLE_MAPPER_PRG_START_ADDR + PRG_PART_SIZE);
2024-01-06 14:27:09 -05:00
memcpy(destination, source, PRG_PART_SIZE);
2023-11-26 12:11:49 -05:00
}
Mapper get_simple_mapper() {
Mapper mapper;
2024-01-06 14:27:09 -05:00
mapper.prg_rom_start_addr = SIMPLE_MAPPER_PRG_START_ADDR;
mapper.post_prg_load = &post_prg_load;
2023-11-26 12:11:49 -05:00
return mapper;
}