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