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