src/state.h

Fri, 03 Dec 2010 00:12:53 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Fri, 03 Dec 2010 00:12:53 +0000
changeset 44
f928be115194
parent 37
87662afa1d98
child 46
7d14fab5e4aa
permissions
-rw-r--r--

fix state/status transposition, add GENCON.PIE handling

     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 	/// GENCON.PIE -- Parity Error Check Enable
    40 	bool		pie;
    41 } S_state;
    43 // Global emulator state. Yes, I know global variables are evil, please don't
    44 // email me and lecture me about it.  -philpem
    45 #ifndef _STATE_C
    46 extern S_state state;
    47 #else
    48 S_state state;
    49 #endif
    51 /**
    52  * @brief	Initialise system state
    53  *
    54  * @param	ramsize		RAM size in bytes -- must be a multiple of 512KiB, min 512KiB, max 4MiB.
    55  *
    56  * Initialises the emulator's internal state.
    57  */
    58 int state_init(size_t ramsize);
    60 /**
    61  * @brief Deinitialise system state
    62  *
    63  * Deinitialises the saved state, and frees all memory. Call this function
    64  * before exiting your program to avoid memory leaks.
    65  */
    66 void state_done();
    68 #endif