src/wd279x.h

Sun, 05 Dec 2010 03:55:46 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Sun, 05 Dec 2010 03:55:46 +0000
changeset 48
d52688dad7fd
child 49
545798274dad
permissions
-rw-r--r--

add preliminary WD2797 FDC emulator

     1 #ifndef _WD279X_H
     2 #define _WD279X_H
     4 #include <stdbool.h>
     5 #include <stddef.h>
     6 #include <stdint.h>
     7 #include <stdio.h>
     9 enum {
    10 	WD279X_REG_STATUS = 0,
    11 	WD279X_REG_COMMAND = 0,
    12 	WD279X_REG_TRACK = 1,
    13 	WD279X_REG_SECTOR = 2,
    14 	WD279X_REG_DATA = 3
    15 } WD279X_REG;
    17 typedef struct {
    18 	// Current track, head and sector
    19 	int						track, head, sector;
    20 	// Geometry of current disc
    21 	int						geom_secsz, geom_spt, geom_heads, geom_tracks;
    22 	// IRQ status, level and edge sensitive.
    23 	// Edge sensitive is cleared when host polls the IRQ status.
    24 	// Level sensitive is cleared when emulated CPU polls the status reg or writes a new cmnd.
    25 	// No EDGE sensitive interrupts will be issued unless the LEVEL SENSITIVE IRQ is clear.
    26 	bool					irql, irqe;
    27 	// Status of last command
    28 	uint8_t					status;
    29 	// Last command uses DRQ bit?
    30 	bool					cmd_has_drq;
    31 	// The last value written to the data register
    32 	uint8_t					data_reg;
    33 	// Last step direction. -1 for "towards zero", 1 for "away from zero"
    34 	int						last_step_dir;
    35 	// Data buffer, current DRQ pointer and length
    36 	uint8_t					data[1024];
    37 	size_t					data_pos, data_len;
    38 	// Current disc image file
    39 	FILE					*disc_image;
    40 } WD279X_CTX;
    42 #endif