]> git.sesse.net Git - pistorm/blob - config_file/config_file.h
358a570027fa668d2706b02eda0a3d9e280105bf
[pistorm] / config_file / config_file.h
1 #include "../m68k.h"
2
3 #define MAX_NUM_MAPPED_ITEMS 8
4 #define SIZE_KILO 1024
5 #define SIZE_MEGA (1024 * 1024)
6 #define SIZE_GIGA (1024 * 1024 * 1024)
7
8 typedef enum {
9   MAPTYPE_NONE,
10   MAPTYPE_ROM,
11   MAPTYPE_RAM,
12   MAPTYPE_REGISTER,
13   MAPTYPE_NUM,
14 } map_types;
15
16 typedef enum {
17   MAPCMD_UNKNOWN,
18   MAPCMD_TYPE,
19   MAPCMD_ADDRESS,
20   MAPCMD_SIZE,
21   MAPCMD_RANGE,
22   MAPCMD_FILENAME,
23   MAPCMD_OVL_REMAP,
24   MAPCMD_MAP_ID,
25   MAPCMD_NUM,
26 } map_cmds;
27
28 typedef enum {
29   CONFITEM_NONE,
30   CONFITEM_CPUTYPE,
31   CONFITEM_MAP,
32   CONFITEM_LOOPCYCLES,
33   CONFITEM_MOUSE,
34   CONFITEM_KEYBOARD,
35   CONFITEM_PLATFORM,
36   CONFITEM_SETVAR,
37   CONFITEM_NUM,
38 } config_items;
39
40 typedef enum {
41   OP_TYPE_BYTE,
42   OP_TYPE_WORD,
43   OP_TYPE_LONGWORD,
44   OP_TYPE_MEM,
45   OP_TYPE_NUM,
46 } map_op_types;
47
48 struct emulator_config {
49   unsigned int cpu_type;
50
51   unsigned char map_type[MAX_NUM_MAPPED_ITEMS];
52   long map_offset[MAX_NUM_MAPPED_ITEMS];
53   long map_high[MAX_NUM_MAPPED_ITEMS];
54   unsigned int map_size[MAX_NUM_MAPPED_ITEMS];
55   unsigned int rom_size[MAX_NUM_MAPPED_ITEMS];
56   unsigned char *map_data[MAX_NUM_MAPPED_ITEMS];
57   int map_mirror[MAX_NUM_MAPPED_ITEMS];
58   char *map_id[MAX_NUM_MAPPED_ITEMS];
59
60   struct platform_config *platform;
61
62   char *mouse_file;
63
64   char mouse_toggle_key, keyboard_toggle_key;
65   unsigned char mouse_enabled, keyboard_enabled;
66
67   unsigned int loop_cycles;
68   unsigned int mapped_low, mapped_high;
69   unsigned int custom_low, custom_high;
70 };
71
72 struct platform_config {
73   char *subsys;
74   unsigned char id;
75
76   int (*custom_read)(struct emulator_config *cfg, unsigned int addr, unsigned int *val, unsigned char type);
77   int (*custom_write)(struct emulator_config *cfg, unsigned int addr, unsigned int val, unsigned char type);
78
79   int (*register_read)(unsigned int addr, unsigned char type, unsigned int *val);
80   int (*register_write)(unsigned int addr, unsigned int value, unsigned char type);
81
82   int (*platform_initial_setup)(struct emulator_config *cfg);
83   void (*handle_reset)(struct emulator_config *cfg);
84   void (*shutdown)(struct emulator_config *cfg);
85   void (*setvar)(struct emulator_config *cfg, char *var, char *val);
86 };
87
88 unsigned int get_m68k_cpu_type(char *name);
89 struct emulator_config *load_config_file(char *filename);
90
91 int handle_mapped_read(struct emulator_config *cfg, unsigned int addr, unsigned int *val, unsigned char type);
92 int handle_mapped_write(struct emulator_config *cfg, unsigned int addr, unsigned int value, unsigned char type);
93 int get_named_mapped_item(struct emulator_config *cfg, char *name);
94 unsigned int get_int(char *str);