1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/state.h Mon Nov 29 00:20:40 2010 +0000 1.3 @@ -0,0 +1,55 @@ 1.4 +#ifndef _STATE_H 1.5 +#define _STATE_H 1.6 + 1.7 +#include <stddef.h> 1.8 +#include <stdint.h> 1.9 +#include <stdbool.h> 1.10 + 1.11 +// Maximum size of the Boot PROMs. Must be a binary power of two. 1.12 +#define ROM_SIZE 32768 1.13 + 1.14 +/** 1.15 + * @brief Emulator state storage 1.16 + * 1.17 + * This structure stores the internal state of the emulator. 1.18 + */ 1.19 +typedef struct { 1.20 + // Boot PROM can be up to 32Kbytes total size 1.21 + uint8_t rom[ROM_SIZE]; ///< Boot PROM data buffer 1.22 + 1.23 + // Main system RAM 1.24 + uint8_t *ram; ///< RAM data buffer 1.25 + size_t ram_size; ///< Size of RAM buffer in bytes 1.26 + 1.27 + // GENERAL CONTROL REGISTER 1.28 + /// GENCON.ROMLMAP -- false ORs the address with 0x800000, forcing the 1.29 + /// 68010 to access ROM instead of RAM when booting. TRM page 2-36. 1.30 + bool romlmap; 1.31 +} S_state; 1.32 + 1.33 +// Global emulator state. Yes, I know global variables are evil, please don't 1.34 +// email me and lecture me about it. -philpem 1.35 +#ifndef _STATE_C 1.36 +extern S_state state; 1.37 +#else 1.38 +S_state state; 1.39 +#endif 1.40 + 1.41 +/** 1.42 + * @brief Initialise system state 1.43 + * 1.44 + * @param ramsize RAM size in bytes -- must be a multiple of 512KiB, min 512KiB, max 4MiB. 1.45 + * 1.46 + * Initialises the emulator's internal state. 1.47 + */ 1.48 +int state_init(size_t ramsize); 1.49 + 1.50 +/** 1.51 + * @brief Deinitialise system state 1.52 + * 1.53 + * Deinitialises the saved state, and frees all memory. Call this function 1.54 + * before exiting your program to avoid memory leaks. 1.55 + */ 1.56 +void state_done(); 1.57 + 1.58 +#endif