Mon, 29 Nov 2010 00:20:40 +0000
split state handling into state.[ch]
1 #ifndef _STATE_H
2 #define _STATE_H
4 #include <stddef.h>
5 #include <stdint.h>
6 #include <stdbool.h>
8 // Maximum size of the Boot PROMs. Must be a binary power of two.
9 #define ROM_SIZE 32768
11 /**
12 * @brief Emulator state storage
13 *
14 * This structure stores the internal state of the emulator.
15 */
16 typedef struct {
17 // Boot PROM can be up to 32Kbytes total size
18 uint8_t rom[ROM_SIZE]; ///< Boot PROM data buffer
20 // Main system RAM
21 uint8_t *ram; ///< RAM data buffer
22 size_t ram_size; ///< Size of RAM buffer in bytes
24 // GENERAL CONTROL REGISTER
25 /// GENCON.ROMLMAP -- false ORs the address with 0x800000, forcing the
26 /// 68010 to access ROM instead of RAM when booting. TRM page 2-36.
27 bool romlmap;
28 } S_state;
30 // Global emulator state. Yes, I know global variables are evil, please don't
31 // email me and lecture me about it. -philpem
32 #ifndef _STATE_C
33 extern S_state state;
34 #else
35 S_state state;
36 #endif
38 /**
39 * @brief Initialise system state
40 *
41 * @param ramsize RAM size in bytes -- must be a multiple of 512KiB, min 512KiB, max 4MiB.
42 *
43 * Initialises the emulator's internal state.
44 */
45 int state_init(size_t ramsize);
47 /**
48 * @brief Deinitialise system state
49 *
50 * Deinitialises the saved state, and frees all memory. Call this function
51 * before exiting your program to avoid memory leaks.
52 */
53 void state_done();
55 #endif