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