Sun, 05 Dec 2010 16:20:00 +0000
add preliminary WD279x emulation to core
1 #ifndef _STATE_H
2 #define _STATE_H
4 #include <stddef.h>
5 #include <stdint.h>
6 #include <stdbool.h>
7 #include "wd279x.h"
9 // Maximum size of the Boot PROMs. Must be a binary power of two.
10 #define ROM_SIZE 32768
12 /**
13 * @brief Emulator state storage
14 *
15 * This structure stores the internal state of the emulator.
16 */
17 typedef struct {
18 // Boot PROM can be up to 32Kbytes total size
19 uint8_t rom[ROM_SIZE]; ///< Boot PROM data buffer
21 //// Main system RAM
22 uint8_t *ram; ///< RAM data buffer
23 size_t ram_size; ///< Size of RAM buffer in bytes
25 /// Video RAM
26 uint8_t vram[0x8000];
28 /// Map RAM
29 uint8_t map[0x800];
31 //// Registers
32 uint16_t genstat; ///< General Status Register
33 uint16_t bsr0; ///< Bus Status Register 0
34 uint16_t bsr1; ///< Bus Status Register 1
36 //// MISCELLANEOUS CONTROL REGISTER
37 bool dma_reading; ///< True if Disc DMA reads from the controller, false otherwise
38 uint8_t leds; ///< LED status, 1=on, in order red3/green2/yellow1/red0 from bit3 to bit0
40 //// GENERAL CONTROL REGISTER
41 /// GENCON.ROMLMAP -- false ORs the address with 0x800000, forcing the
42 /// 68010 to access ROM instead of RAM when booting. TRM page 2-36.
43 bool romlmap;
44 /// GENCON.PIE -- Parity Error Check Enable
45 bool pie;
47 /// DMA Address Register
48 uint32_t dma_address;
50 /// Floppy disc controller context
51 WD2797_CTX fdc_ctx;
52 } S_state;
54 // Global emulator state. Yes, I know global variables are evil, please don't
55 // email me and lecture me about it. -philpem
56 #ifndef _STATE_C
57 extern S_state state;
58 #else
59 S_state state;
60 #endif
62 /**
63 * @brief Initialise system state
64 *
65 * @param ramsize RAM size in bytes -- must be a multiple of 512KiB, min 512KiB, max 4MiB.
66 *
67 * Initialises the emulator's internal state.
68 */
69 int state_init(size_t ramsize);
71 /**
72 * @brief Deinitialise system state
73 *
74 * Deinitialises the saved state, and frees all memory. Call this function
75 * before exiting your program to avoid memory leaks.
76 */
77 void state_done();
79 #endif