src/state.h

Mon, 06 Dec 2010 01:43:04 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Mon, 06 Dec 2010 01:43:04 +0000
changeset 54
57c6ef81ae81
parent 53
e1693c4b8a0c
child 55
ba6b8e570062
permissions
-rw-r--r--

fix side-select bug in WDC FDC driver, was causing all reads to occur on side0... now the Loader boots!

Loader will boot, but immediately gives up on the floppy drive... Not sure why.

     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 	/// DMA count
    51 	uint32_t	dma_count;
    53 	/// DMA direction
    54 	bool		idmarw;
    55 	/// DMA enable
    56 	bool		dmaen;
    57 	bool		dmaenb;
    59 	/// Floppy disc controller context
    60 	WD2797_CTX	fdc_ctx;
    61 } S_state;
    63 // Global emulator state. Yes, I know global variables are evil, please don't
    64 // email me and lecture me about it.  -philpem
    65 #ifndef _STATE_C
    66 extern S_state state;
    67 #else
    68 S_state state;
    69 #endif
    71 /**
    72  * @brief	Initialise system state
    73  *
    74  * @param	ramsize		RAM size in bytes -- must be a multiple of 512KiB, min 512KiB, max 4MiB.
    75  *
    76  * Initialises the emulator's internal state.
    77  */
    78 int state_init(size_t ramsize);
    80 /**
    81  * @brief Deinitialise system state
    82  *
    83  * Deinitialises the saved state, and frees all memory. Call this function
    84  * before exiting your program to avoid memory leaks.
    85  */
    86 void state_done();
    88 #endif