src/state.h

Fri, 03 Dec 2010 01:43:57 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Fri, 03 Dec 2010 01:43:57 +0000
changeset 46
7d14fab5e4aa
parent 44
f928be115194
child 52
a350dfa92895
permissions
-rw-r--r--

add comments for some write-only regs, fix LOG_NOT_HANDLED_R(32) in read16, basic LED reg decoding

     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 	// MISCELLANEOUS CONTROL REGISTER
    36 	uint8_t		leds;				///< LED status, 1=on, in order red3/green2/yellow1/red0 from bit3 to bit0
    38 	// GENERAL CONTROL REGISTER
    39 	/// GENCON.ROMLMAP -- false ORs the address with 0x800000, forcing the
    40 	/// 68010 to access ROM instead of RAM when booting. TRM page 2-36.
    41 	bool		romlmap;
    42 	/// GENCON.PIE -- Parity Error Check Enable
    43 	bool		pie;
    44 } S_state;
    46 // Global emulator state. Yes, I know global variables are evil, please don't
    47 // email me and lecture me about it.  -philpem
    48 #ifndef _STATE_C
    49 extern S_state state;
    50 #else
    51 S_state state;
    52 #endif
    54 /**
    55  * @brief	Initialise system state
    56  *
    57  * @param	ramsize		RAM size in bytes -- must be a multiple of 512KiB, min 512KiB, max 4MiB.
    58  *
    59  * Initialises the emulator's internal state.
    60  */
    61 int state_init(size_t ramsize);
    63 /**
    64  * @brief Deinitialise system state
    65  *
    66  * Deinitialises the saved state, and frees all memory. Call this function
    67  * before exiting your program to avoid memory leaks.
    68  */
    69 void state_done();
    71 #endif