Wed, 01 Dec 2010 22:11:06 +0000
add VRAM emulation
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 // GENERAL CONTROL REGISTER
28 /// GENCON.ROMLMAP -- false ORs the address with 0x800000, forcing the
29 /// 68010 to access ROM instead of RAM when booting. TRM page 2-36.
30 bool romlmap;
31 } S_state;
33 // Global emulator state. Yes, I know global variables are evil, please don't
34 // email me and lecture me about it. -philpem
35 #ifndef _STATE_C
36 extern S_state state;
37 #else
38 S_state state;
39 #endif
41 /**
42 * @brief Initialise system state
43 *
44 * @param ramsize RAM size in bytes -- must be a multiple of 512KiB, min 512KiB, max 4MiB.
45 *
46 * Initialises the emulator's internal state.
47 */
48 int state_init(size_t ramsize);
50 /**
51 * @brief Deinitialise system state
52 *
53 * Deinitialises the saved state, and frees all memory. Call this function
54 * before exiting your program to avoid memory leaks.
55 */
56 void state_done();
58 #endif