Thu, 02 Dec 2010 20:58:12 +0000
rework address-check logic
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 // Video RAM
25 uint8_t vram[0x8000]; ///< Video RAM
27 // Map RAM
28 uint8_t map[0x800]; ///< Map RAM
30 // Registers
31 uint16_t genstat; ///< General Status Register
32 uint16_t bsr0; ///< Bus Status Register 0
33 uint16_t bsr1; ///< Bus Status Register 1
35 // GENERAL CONTROL REGISTER
36 /// GENCON.ROMLMAP -- false ORs the address with 0x800000, forcing the
37 /// 68010 to access ROM instead of RAM when booting. TRM page 2-36.
38 bool romlmap;
39 } S_state;
41 // Global emulator state. Yes, I know global variables are evil, please don't
42 // email me and lecture me about it. -philpem
43 #ifndef _STATE_C
44 extern S_state state;
45 #else
46 S_state state;
47 #endif
49 /**
50 * @brief Initialise system state
51 *
52 * @param ramsize RAM size in bytes -- must be a multiple of 512KiB, min 512KiB, max 4MiB.
53 *
54 * Initialises the emulator's internal state.
55 */
56 int state_init(size_t ramsize);
58 /**
59 * @brief Deinitialise system state
60 *
61 * Deinitialises the saved state, and frees all memory. Call this function
62 * before exiting your program to avoid memory leaks.
63 */
64 void state_done();
66 #endif