Add not-so-simple config switching from Amiga side

This commit is contained in:
beeanyew
2021-04-23 13:03:54 +02:00
parent 2803e02871
commit 8a14e4c1a1
18 changed files with 379 additions and 39 deletions

View File

@@ -208,7 +208,7 @@ void add_mapping(struct emulator_config *cfg, unsigned int type, unsigned int ad
case MAPTYPE_ROM:
in = fopen(filename, "rb");
if (!in) {
printf("[CFG] Failed to open file %s for ROM mapping.\n", filename);
printf("[CFG] Failed to open file %s for ROM mapping. Using onboard ROM instead, if available.\n", filename);
goto mapping_failed;
}
fseek(in, 0, SEEK_END);
@@ -245,6 +245,41 @@ void add_mapping(struct emulator_config *cfg, unsigned int type, unsigned int ad
fclose(in);
}
void free_config_file(struct emulator_config *cfg) {
if (!cfg) {
printf("[CFG] Tried to free NULL config, aborting.\n");
}
if (cfg->platform) {
cfg->platform->shutdown(cfg);
free(cfg->platform);
cfg->platform = NULL;
}
for (int i = 0; i < MAX_NUM_MAPPED_ITEMS; i++) {
if (cfg->map_data[i]) {
free(cfg->map_data[i]);
cfg->map_data[i] = NULL;
}
if (cfg->map_id[i]) {
free(cfg->map_id[i]);
cfg->map_id[i] = NULL;
}
}
if (cfg->mouse_file) {
free(cfg->mouse_file);
cfg->mouse_file = NULL;
}
if (cfg->keyboard_file) {
free(cfg->keyboard_file);
cfg->keyboard_file = NULL;
}
m68k_clear_ranges();
printf("[CFG] Config file freed. Maybe.\n");
}
struct emulator_config *load_config_file(char *filename) {
FILE *in = fopen(filename, "rb");
if (in == NULL) {

View File

@@ -95,6 +95,7 @@ struct platform_config {
unsigned int get_m68k_cpu_type(char *name);
struct emulator_config *load_config_file(char *filename);
void free_config_file(struct emulator_config *cfg);
int handle_mapped_read(struct emulator_config *cfg, unsigned int addr, unsigned int *val, unsigned char type);
int handle_mapped_write(struct emulator_config *cfg, unsigned int addr, unsigned int value, unsigned char type);