2023-11-26 12:11:49 -05:00
|
|
|
#include "../include/mapper.h"
|
2024-01-06 14:27:09 -05:00
|
|
|
#include "../include/rom.h"
|
|
|
|
#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
|
|
|
|
|
|
|
|
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);
|
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;
|
|
|
|
}
|