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