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