mirror of
https://github.com/captain-amygdala/pistorm.git
synced 2026-04-15 16:09:58 +00:00
Add support for ROM mirroring
Confirmed to be working this way on a real Amiga, removes the need for separate ROM image maps in the config file for 256/512KB ROM images.
This commit is contained in:
@@ -212,12 +212,13 @@ void add_mapping(struct emulator_config *cfg, unsigned int type, unsigned int ad
|
||||
}
|
||||
fseek(in, 0, SEEK_SET);
|
||||
cfg->map_data[index] = (unsigned char *)calloc(1, cfg->map_size[index]);
|
||||
cfg->rom_size[index] = (cfg->map_size[index] <= file_size) ? cfg->map_size[index] : file_size;
|
||||
if (!cfg->map_data[index]) {
|
||||
printf("ERROR: Unable to allocate memory for mapped ROM!\n");
|
||||
goto mapping_failed;
|
||||
}
|
||||
memset(cfg->map_data[index], 0x00, cfg->map_size[index]);
|
||||
fread(cfg->map_data[index], (cfg->map_size[index] <= file_size) ? cfg->map_size[index] : file_size, 1, in);
|
||||
fread(cfg->map_data[index], cfg->rom_size[index], 1, in);
|
||||
fclose(in);
|
||||
break;
|
||||
case MAPTYPE_REGISTER:
|
||||
|
||||
@@ -49,6 +49,7 @@ struct emulator_config {
|
||||
unsigned char map_type[MAX_NUM_MAPPED_ITEMS];
|
||||
long map_offset[MAX_NUM_MAPPED_ITEMS];
|
||||
unsigned int map_size[MAX_NUM_MAPPED_ITEMS];
|
||||
unsigned int rom_size[MAX_NUM_MAPPED_ITEMS];
|
||||
unsigned char *map_data[MAX_NUM_MAPPED_ITEMS];
|
||||
int map_mirror[MAX_NUM_MAPPED_ITEMS];
|
||||
char *map_id[MAX_NUM_MAPPED_ITEMS];
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
# Sets CPU type. Valid types are (probably) 68000, 68010, 68020, 68EC020, 68030, 68EC030, 68040, 68EC040, 68LC040 and some STTTT thing.
|
||||
cpu 68020
|
||||
# Map 512KB kickstart ROM to default offset.
|
||||
map type=rom address=0xF80000 size=0x80000 file=kick512.rom ovl=0
|
||||
# This is for mapping a 256KB kickstart ROM. I can probably add some additional thing about kicking this file into low/high area.
|
||||
#map type=rom address=0xFC0000 size=0x40000 file=kick256.rom ovl=0
|
||||
map type=rom address=0xF80000 size=0x80000 file=kick.rom ovl=0
|
||||
# Want to map an extended ROM, such as CDTV or CD32?
|
||||
#map type=rom address=0xF00000 size=0x90000 file=cdtv.rom
|
||||
#map type=rom address=0xF00000 size=0x80000 file=cdtv.rom
|
||||
# Map 256MB of Fast RAM at 0x8000000.
|
||||
map type=ram address=0x08000000 size=128M
|
||||
# Map Gayle as a register range.
|
||||
|
||||
@@ -27,9 +27,9 @@ int handle_mapped_read(struct emulator_config *cfg, unsigned int addr, unsigned
|
||||
switch(cfg->map_type[i]) {
|
||||
case MAPTYPE_ROM:
|
||||
if (CHKRANGE(addr, cfg->map_offset[i], cfg->map_size[i]))
|
||||
read_addr = cfg->map_data[i] + (addr - cfg->map_offset[i]);
|
||||
read_addr = cfg->map_data[i] + ((addr - cfg->map_offset[i]) % cfg->rom_size[i]);
|
||||
else if (cfg->map_mirror[i] != -1 && mirror && CHKRANGE(addr, cfg->map_mirror[i], cfg->map_size[i]))
|
||||
read_addr = cfg->map_data[i] + (addr - cfg->map_mirror[i]);
|
||||
read_addr = cfg->map_data[i] + ((addr - cfg->map_mirror[i]) % cfg->rom_size[i]);
|
||||
break;
|
||||
case MAPTYPE_RAM:
|
||||
if (CHKRANGE(addr, cfg->map_offset[i], cfg->map_size[i]))
|
||||
|
||||
Reference in New Issue
Block a user