src/state.h

Wed, 01 Dec 2010 22:34:15 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Wed, 01 Dec 2010 22:34:15 +0000
changeset 26
fef12817c5e8
parent 24
724d2f6deb37
child 32
a44afcf2354c
permissions
-rw-r--r--

move repeated R/W bit-shifting stuff into macros and fix RAM addressing issue

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