First Commit of my working state
[simh.git] / AltairZ80 / sim_imd.h
CommitLineData
196ba1fc
PH
1/*************************************************************************\r
2 * *\r
3 * $Id: sim_imd.h 1904 2008-05-21 06:57:57Z hharte $ *\r
4 * *\r
5 * Copyright (c) 2007-2008 Howard M. Harte. *\r
6 * http://www.hartetec.com *\r
7 * *\r
8 * Permission is hereby granted, free of charge, to any person obtaining *\r
9 * a copy of this software and associated documentation files (the *\r
10 * "Software"), to deal in the Software without restriction, including *\r
11 * without limitation the rights to use, copy, modify, merge, publish, *\r
12 * distribute, sublicense, and/or sell copies of the Software, and to *\r
13 * permit persons to whom the Software is furnished to do so, subject to *\r
14 * the following conditions: *\r
15 * *\r
16 * The above copyright notice and this permission notice shall be *\r
17 * included in all copies or substantial portions of the Software. *\r
18 * *\r
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *\r
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *\r
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *\r
22 * NONINFRINGEMENT. IN NO EVENT SHALL HOWARD M. HARTE BE LIABLE FOR ANY *\r
23 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, *\r
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE *\r
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *\r
26 * *\r
27 * Except as contained in this notice, the name of Howard M. Harte shall *\r
28 * not be used in advertising or otherwise to promote the sale, use or *\r
29 * other dealings in this Software without prior written authorization *\r
30 * Howard M. Harte. *\r
31 * *\r
32 * SIMH Interface based on altairz80_hdsk.c, by Peter Schorn. *\r
33 * *\r
34 * Module Description: *\r
35 * ImageDisk Disk Image File access module for SIMH, definitions. *\r
36 * see : *\r
37 * for details on the ImageDisk format and other utilities. *\r
38 * *\r
39 * Environment: *\r
40 * User mode only *\r
41 * *\r
42 *************************************************************************/\r
43\r
44typedef struct {\r
45 unsigned char mode;\r
46 unsigned char cyl;\r
47 unsigned char head;\r
48 unsigned char nsects;\r
49 unsigned char sectsize;\r
50} IMD_HEADER;\r
51\r
52\r
53#define IMD_FLAG_SECT_HEAD_MAP (1 << 6)\r
54#define IMD_FLAG_SECT_CYL_MAP (1 << 7)\r
55\r
56#define SECT_RECORD_UNAVAILABLE 0 /* Data could not be read from the original media */\r
57#define SECT_RECORD_NORM 1 /* Normal Data */\r
58#define SECT_RECORD_NORM_COMP 2 /* Compressed Normal Data */\r
59#define SECT_RECORD_NORM_DAM 3 /* Normal Data with deleted address mark */\r
60#define SECT_RECORD_NORM_DAM_COMP 4 /* Compressed Normal Data with deleted address mark */\r
61#define SECT_RECORD_NORM_ERR 5 /* Normal Data */\r
62#define SECT_RECORD_NORM_COMP_ERR 6 /* Compressed Normal Data */\r
63#define SECT_RECORD_NORM_DAM_ERR 7 /* Normal Data with deleted address mark */\r
64#define SECT_RECORD_NORM_DAM_COMP_ERR 8 /* Compressed Normal Data with deleted address mark */\r
65\r
66#define MAX_CYL 80\r
67#define MAX_HEAD 2\r
68#define MAX_SPT 26\r
69\r
70#define FD_FLAG_WRITELOCK 1\r
71\r
72#define IMD_DISK_IO_ERROR_GENERAL (1 << 0) /* General data error. */\r
73#define IMD_DISK_IO_ERROR_CRC (1 << 1) /* Data read/written, but got a CRC error. */\r
74#define IMD_DISK_IO_DELETED_ADDR_MARK (1 << 2) /* Sector had a deleted address mark */\r
75#define IMD_DISK_IO_COMPRESSED (1 << 3) /* Sector is compressed in the IMD file (Read Only) */\r
76\r
77#define IMD_MODE_500K_FM 0\r
78#define IMD_MODE_300K_FM 1\r
79#define IMD_MODE_250K_FM 2\r
80#define IMD_MODE_500K_MFM 3\r
81#define IMD_MODE_300K_MFM 4\r
82#define IMD_MODE_250K_MFM 5\r
83\r
84#define IMD_MODE_FM(x) (x <= IMD_MODE_250K_FM)\r
85#define IMD_MODE_MFM(x) (x >= IMD_MODE_500K_MFM)\r
86\r
87typedef struct {\r
88 unsigned char mode;\r
89 unsigned char nsects;\r
90 unsigned int sectsize;\r
91 unsigned int sectorOffsetMap[MAX_SPT];\r
92 unsigned char start_sector;\r
93} TRACK_INFO;\r
94\r
95typedef struct {\r
96 FILE *file;\r
97 unsigned int ntracks;\r
98 unsigned char nsides;\r
99 unsigned char flags;\r
100 TRACK_INFO track[MAX_CYL][MAX_HEAD];\r
101} DISK_INFO;\r
102\r
103extern DISK_INFO *diskOpen(FILE *fileref, int isVerbose); /*char *filename); */\r
104extern unsigned int diskClose(DISK_INFO *myDisk);\r
105extern unsigned int imdGetSides(DISK_INFO *myDisk);\r
106extern unsigned int imdIsWriteLocked(DISK_INFO *myDisk);\r
107\r
108extern int sectSeek(DISK_INFO *myDisk, unsigned int Cyl, unsigned int Head);\r
109extern int sectRead(DISK_INFO *myDisk, unsigned int Cyl, unsigned int Head, unsigned int Sector, unsigned char *buf, unsigned int buflen, unsigned int *flags, unsigned int *readlen);\r
110extern int sectWrite(DISK_INFO *myDisk, unsigned int Cyl, unsigned int Head, unsigned int Sector, unsigned char *buf, unsigned int buflen, unsigned int *flags, unsigned int *writelen);\r