src/wd279x.h

changeset 48
d52688dad7fd
child 49
545798274dad
     1.1 diff -r c472ae8f44b2 -r d52688dad7fd src/wd279x.h
     1.2 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 +++ b/src/wd279x.h	Sun Dec 05 03:55:46 2010 +0000
     1.4 @@ -0,0 +1,42 @@
     1.5 +#ifndef _WD279X_H
     1.6 +#define _WD279X_H
     1.7 +
     1.8 +#include <stdbool.h>
     1.9 +#include <stddef.h>
    1.10 +#include <stdint.h>
    1.11 +#include <stdio.h>
    1.12 +
    1.13 +enum {
    1.14 +	WD279X_REG_STATUS = 0,
    1.15 +	WD279X_REG_COMMAND = 0,
    1.16 +	WD279X_REG_TRACK = 1,
    1.17 +	WD279X_REG_SECTOR = 2,
    1.18 +	WD279X_REG_DATA = 3
    1.19 +} WD279X_REG;
    1.20 +
    1.21 +typedef struct {
    1.22 +	// Current track, head and sector
    1.23 +	int						track, head, sector;
    1.24 +	// Geometry of current disc
    1.25 +	int						geom_secsz, geom_spt, geom_heads, geom_tracks;
    1.26 +	// IRQ status, level and edge sensitive.
    1.27 +	// Edge sensitive is cleared when host polls the IRQ status.
    1.28 +	// Level sensitive is cleared when emulated CPU polls the status reg or writes a new cmnd.
    1.29 +	// No EDGE sensitive interrupts will be issued unless the LEVEL SENSITIVE IRQ is clear.
    1.30 +	bool					irql, irqe;
    1.31 +	// Status of last command
    1.32 +	uint8_t					status;
    1.33 +	// Last command uses DRQ bit?
    1.34 +	bool					cmd_has_drq;
    1.35 +	// The last value written to the data register
    1.36 +	uint8_t					data_reg;
    1.37 +	// Last step direction. -1 for "towards zero", 1 for "away from zero"
    1.38 +	int						last_step_dir;
    1.39 +	// Data buffer, current DRQ pointer and length
    1.40 +	uint8_t					data[1024];
    1.41 +	size_t					data_pos, data_len;
    1.42 +	// Current disc image file
    1.43 +	FILE					*disc_image;
    1.44 +} WD279X_CTX;
    1.45 +
    1.46 +#endif