annotate system.h @ 1680:326d1a601fb9

Fixed crash bug that could occur in a narrow window of time when loading a ROM
author Michael Pavone <pavone@retrodev.com>
date Thu, 17 Jan 2019 10:00:24 -0800
parents 6909c5d0bbb5
children 319d90025d50 5dacaef602a7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1111
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #ifndef SYSTEM_H_
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2 #define SYSTEM_H_
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3 #include <stdint.h>
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5 typedef struct system_header system_header;
1140
4490c9c12272 Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents: 1117
diff changeset
6 typedef struct system_media system_media;
1111
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
7
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8 typedef enum {
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
9 SYSTEM_UNKNOWN,
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
10 SYSTEM_GENESIS,
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
11 SYSTEM_SMS,
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
12 SYSTEM_JAGUAR
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
13 } system_type;
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
14
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
15 typedef enum {
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
16 DEBUGGER_NATIVE,
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
17 DEBUGGER_GDB
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
18 } debugger_type;
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
19
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
20 typedef void (*system_fun)(system_header *);
1117
928a65750345 Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents: 1113
diff changeset
21 typedef uint16_t (*system_fun_r16)(system_header *);
1149
6b0da6021544 Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents: 1140
diff changeset
22 typedef void (*system_str_fun)(system_header *, char *);
6b0da6021544 Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents: 1140
diff changeset
23 typedef uint8_t (*system_str_fun_r8)(system_header *, char *);
1583
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1479
diff changeset
24 typedef void (*system_u32_fun)(system_header *, uint32_t);
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1479
diff changeset
25 typedef void (*system_u8_fun)(system_header *, uint8_t);
1433
c886c54d8cf1 Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents: 1208
diff changeset
26 typedef uint8_t (*system_u8_fun_r8)(system_header *, uint8_t);
1583
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1479
diff changeset
27 typedef void (*system_u8_u8_fun)(system_header *, uint8_t, uint8_t);
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1479
diff changeset
28 typedef void (*system_mabs_fun)(system_header *, uint8_t, uint16_t, uint16_t);
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1479
diff changeset
29 typedef void (*system_mrel_fun)(system_header *, uint8_t, int32_t, int32_t);
1111
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
30
1149
6b0da6021544 Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents: 1140
diff changeset
31 #include "arena.h"
6b0da6021544 Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents: 1140
diff changeset
32 #include "romdb.h"
6b0da6021544 Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents: 1140
diff changeset
33
1111
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
34 struct system_header {
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
35 system_header *next_context;
1149
6b0da6021544 Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents: 1140
diff changeset
36 system_str_fun start_context;
1111
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
37 system_fun resume_context;
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
38 system_fun load_save;
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
39 system_fun persist_save;
1433
c886c54d8cf1 Added save states to SMS emulation
Michael Pavone <pavone@retrodev.com>
parents: 1208
diff changeset
40 system_u8_fun_r8 load_state;
1111
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
41 system_fun request_exit;
1208
95f5253e75c7 Implement soft reset in Genesis mode
Michael Pavone <pavone@retrodev.com>
parents: 1201
diff changeset
42 system_fun soft_reset;
1111
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
43 system_fun free_context;
1117
928a65750345 Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
Michael Pavone <pavone@retrodev.com>
parents: 1113
diff changeset
44 system_fun_r16 get_open_bus_value;
1583
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1479
diff changeset
45 system_u32_fun set_speed_percent;
1111
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
46 system_fun inc_debug_mode;
1583
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1479
diff changeset
47 system_u8_u8_fun gamepad_down;
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1479
diff changeset
48 system_u8_u8_fun gamepad_up;
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1479
diff changeset
49 system_u8_u8_fun mouse_down;
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1479
diff changeset
50 system_u8_u8_fun mouse_up;
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1479
diff changeset
51 system_mabs_fun mouse_motion_absolute;
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1479
diff changeset
52 system_mrel_fun mouse_motion_relative;
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1479
diff changeset
53 system_u8_fun keyboard_down;
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1479
diff changeset
54 system_u8_fun keyboard_up;
1595
360d5bab199f Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents: 1583
diff changeset
55 system_fun config_updated;
360d5bab199f Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents: 1583
diff changeset
56 rom_info info;
1111
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
57 arena *arena;
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
58 char *next_rom;
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
59 char *save_dir;
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
60 uint8_t enter_debugger;
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
61 uint8_t should_exit;
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
62 uint8_t save_state;
1479
a568dca999b2 Fix genesis save state loading via Nuklear UI, sms probably still needs work
Michael Pavone <pavone@retrodev.com>
parents: 1438
diff changeset
63 uint8_t delayed_load_slot;
1583
430dd12e4010 Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents: 1479
diff changeset
64 uint8_t has_keyboard;
1111
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
65 debugger_type debugger_type;
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
66 system_type type;
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
67 };
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
68
1140
4490c9c12272 Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents: 1117
diff changeset
69 struct system_media {
4490c9c12272 Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents: 1117
diff changeset
70 void *buffer;
1438
e2bd03ed3190 Allow reloading current ROM with a hotkey (default F5) and allow locking on a cartridge via menu
Michael Pavone <pavone@retrodev.com>
parents: 1433
diff changeset
71 char *dir;
1201
aee2177a1630 Use filename for game title in SMS mode
Michael Pavone <pavone@retrodev.com>
parents: 1149
diff changeset
72 char *name;
1140
4490c9c12272 Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents: 1117
diff changeset
73 char *extension;
4490c9c12272 Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents: 1117
diff changeset
74 system_media *chain;
4490c9c12272 Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents: 1117
diff changeset
75 uint32_t size;
4490c9c12272 Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents: 1117
diff changeset
76 };
4490c9c12272 Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents: 1117
diff changeset
77
1113
45db303fc705 Restore 68K address logging functionality
Michael Pavone <pavone@retrodev.com>
parents: 1111
diff changeset
78 #define OPT_ADDRESS_LOG (1U << 31U)
45db303fc705 Restore 68K address logging functionality
Michael Pavone <pavone@retrodev.com>
parents: 1111
diff changeset
79
1140
4490c9c12272 Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents: 1117
diff changeset
80 system_type detect_system_type(system_media *media);
1595
360d5bab199f Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents: 1583
diff changeset
81 system_header *alloc_config_system(system_type stype, system_media *media, uint32_t opts, uint8_t force_region);
1111
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
82
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
83 #endif //SYSTEM_H_