+// SPDX-License-Identifier: MIT
+
#include "platforms/platforms.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "rominfo.h"
+
#define M68K_CPU_TYPES M68K_CPU_TYPE_SCC68070
const char *cpu_types[M68K_CPU_TYPES] = {
"rom",
"ram",
"register",
+ "ram (no alloc)",
};
const char *config_item_names[CONFITEM_NUM] = {
}
switch(type) {
+ case MAPTYPE_RAM_NOALLOC:
+ printf("[CFG] Adding %d byte (%d MB) RAM mapping %s...\n", size, size / 1024 / 1024, map_id);
+ cfg->map_data[index] = (unsigned char *)filename;
+ break;
case MAPTYPE_RAM:
printf("[CFG] Allocating %d bytes for RAM mapping (%d MB)...\n", size, size / 1024 / 1024);
cfg->map_data[index] = (unsigned char *)malloc(size);
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);
memset(cfg->map_data[index], 0x00, cfg->map_size[index]);
fread(cfg->map_data[index], cfg->rom_size[index], 1, in);
fclose(in);
+ displayRomInfo(cfg->map_data[index]);
+ if (cfg->map_size[index] == cfg->rom_size[index])
+ m68k_add_rom_range(cfg->map_offset[index], cfg->map_high[index], cfg->map_data[index]);
break;
case MAPTYPE_REGISTER:
default:
}
printf("[CFG] [MAP %d] Added %s mapping for range %.8lX-%.8lX ID: %s\n", index, map_type_names[type], cfg->map_offset[index], cfg->map_high[index] - 1, cfg->map_id[index] ? cfg->map_id[index] : "None");
- if (cfg->map_size[index] == cfg->rom_size[index])
- m68k_add_rom_range(cfg->map_offset[index], cfg->map_high[index], cfg->map_data[index]);
return;
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) {