[WIP] Add platforms, Z2 config file-based autoconf Fast

This commit is contained in:
beeanyew
2020-12-05 19:56:32 +01:00
parent e650e632ea
commit 97ab27cbb3
15 changed files with 484 additions and 23 deletions

View File

@@ -1,4 +1,4 @@
#include "config_file.h"
#include "../platforms/platforms.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -32,6 +32,7 @@ const char *config_item_names[CONFITEM_NUM] = {
"loopcycles",
"mouse",
"keyboard",
"platform",
};
const char *mapcmd_names[MAPCMD_NUM] = {
@@ -227,7 +228,7 @@ void add_mapping(struct emulator_config *cfg, unsigned int type, unsigned int ad
break;
}
printf("[MAP %d] Added %s mapping for range %.8lX-%.8lX (%lX)\n", index, map_type_names[type], cfg->map_offset[index], cfg->map_offset[index] + cfg->map_size[index] - 1, (uint64_t)cfg->map_data[index]);
printf("[MAP %d] Added %s mapping for range %.8lX-%.8lX ID: %s\n", index, map_type_names[type], cfg->map_offset[index], cfg->map_offset[index] + cfg->map_size[index] - 1, cfg->map_id[index] ? cfg->map_id[index] : "None");
return;
@@ -352,6 +353,19 @@ struct emulator_config *load_config_file(char *filename) {
cfg->keyboard_toggle_key = cur_cmd[0];
printf("Enabled keyboard event forwarding, toggle key %c.\n", cfg->keyboard_toggle_key);
break;
case CONFITEM_PLATFORM: {
char platform_name[128], platform_sub[128];
memset(platform_name, 0x00, 128);
memset(platform_sub, 0x00, 128);
get_next_string(parse_line, platform_name, &str_pos, ' ');
printf("Setting platform to %s", platform_name);
get_next_string(parse_line, platform_sub, &str_pos, ' ');
if (strlen(platform_sub))
printf(" (sub: %s)", platform_sub);
printf("\n");
cfg->platform = make_platform_config(platform_name, platform_sub);
break;
}
case CONFITEM_NONE:
default:
printf("Unknown config item %s on line %d.\n", cur_cmd, cur_line);
@@ -379,3 +393,17 @@ struct emulator_config *load_config_file(char *filename) {
return cfg;
}
int get_named_mapped_item(struct emulator_config *cfg, char *name) {
if (strlen(name) == 0)
return -1;
for (int i = 0; i < MAX_NUM_MAPPED_ITEMS; i++) {
if (cfg->map_type[i] == MAPTYPE_NONE || !cfg->map_id[i])
continue;
if (strcmp(name, cfg->map_id[i]) == 0)
return i;
}
return -1;
}

View File

@@ -32,6 +32,7 @@ typedef enum {
CONFITEM_LOOPCYCLES,
CONFITEM_MOUSE,
CONFITEM_KEYBOARD,
CONFITEM_PLATFORM,
CONFITEM_NUM,
} config_items;
@@ -54,6 +55,8 @@ struct emulator_config {
int map_mirror[MAX_NUM_MAPPED_ITEMS];
char *map_id[MAX_NUM_MAPPED_ITEMS];
struct platform_config *platform;
char *mouse_file;
char mouse_toggle_key, keyboard_toggle_key;
@@ -62,10 +65,22 @@ struct emulator_config {
unsigned int loop_cycles;
};
struct platform_config {
char *subsys;
int (*custom_read)(struct emulator_config *cfg, unsigned int addr, unsigned int *val, unsigned char type);
int (*custom_write)(struct emulator_config *cfg, unsigned int addr, unsigned int val, unsigned char type);
int (*register_read)(unsigned int addr, unsigned char type, unsigned int *val);
int (*register_write)(unsigned int addr, unsigned int value, unsigned char type);
int (*platform_initial_setup)(struct emulator_config *cfg);
void (*setvar)(char *var, char *val);
};
unsigned int get_m68k_cpu_type(char *name);
struct emulator_config *load_config_file(char *filename);
int handle_mapped_read(struct emulator_config *cfg, unsigned int addr, unsigned int *val, unsigned char type, unsigned char mirror);
int handle_mapped_write(struct emulator_config *cfg, unsigned int addr, unsigned int value, unsigned char type, unsigned char mirror);
int handle_register_read(unsigned int addr, unsigned char type, unsigned int *val);
int handle_register_write(unsigned int addr, unsigned int value, unsigned char type);
int get_named_mapped_item(struct emulator_config *cfg, char *name);