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

philpem@18 1 #ifndef _STATE_H
philpem@18 2 #define _STATE_H
philpem@18 3
philpem@18 4 #include <stddef.h>
philpem@18 5 #include <stdint.h>
philpem@18 6 #include <stdbool.h>
philpem@18 7
philpem@18 8 // Maximum size of the Boot PROMs. Must be a binary power of two.
philpem@18 9 #define ROM_SIZE 32768
philpem@18 10
philpem@18 11 /**
philpem@18 12 * @brief Emulator state storage
philpem@18 13 *
philpem@18 14 * This structure stores the internal state of the emulator.
philpem@18 15 */
philpem@18 16 typedef struct {
philpem@18 17 // Boot PROM can be up to 32Kbytes total size
philpem@18 18 uint8_t rom[ROM_SIZE]; ///< Boot PROM data buffer
philpem@18 19
philpem@18 20 // Main system RAM
philpem@18 21 uint8_t *ram; ///< RAM data buffer
philpem@18 22 size_t ram_size; ///< Size of RAM buffer in bytes
philpem@18 23
philpem@24 24 // Video RAM
philpem@24 25 uint8_t vram[0x8000]; ///< Video RAM
philpem@24 26
philpem@26 27 // Map RAM
philpem@26 28 uint8_t map[0x800]; ///< Map RAM
philpem@26 29
philpem@37 30 // Registers
philpem@37 31 uint16_t genstat; ///< General Status Register
philpem@37 32 uint16_t bsr0; ///< Bus Status Register 0
philpem@37 33 uint16_t bsr1; ///< Bus Status Register 1
philpem@32 34
philpem@18 35 // GENERAL CONTROL REGISTER
philpem@18 36 /// GENCON.ROMLMAP -- false ORs the address with 0x800000, forcing the
philpem@18 37 /// 68010 to access ROM instead of RAM when booting. TRM page 2-36.
philpem@24 38 bool romlmap;
philpem@44 39 /// GENCON.PIE -- Parity Error Check Enable
philpem@44 40 bool pie;
philpem@18 41 } S_state;
philpem@18 42
philpem@18 43 // Global emulator state. Yes, I know global variables are evil, please don't
philpem@18 44 // email me and lecture me about it. -philpem
philpem@18 45 #ifndef _STATE_C
philpem@18 46 extern S_state state;
philpem@18 47 #else
philpem@18 48 S_state state;
philpem@18 49 #endif
philpem@18 50
philpem@18 51 /**
philpem@18 52 * @brief Initialise system state
philpem@18 53 *
philpem@18 54 * @param ramsize RAM size in bytes -- must be a multiple of 512KiB, min 512KiB, max 4MiB.
philpem@18 55 *
philpem@18 56 * Initialises the emulator's internal state.
philpem@18 57 */
philpem@18 58 int state_init(size_t ramsize);
philpem@18 59
philpem@18 60 /**
philpem@18 61 * @brief Deinitialise system state
philpem@18 62 *
philpem@18 63 * Deinitialises the saved state, and frees all memory. Call this function
philpem@18 64 * before exiting your program to avoid memory leaks.
philpem@18 65 */
philpem@18 66 void state_done();
philpem@18 67
philpem@18 68 #endif