-
Notifications
You must be signed in to change notification settings - Fork 0
/
vdi.h
59 lines (50 loc) · 3.39 KB
/
vdi.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
@file vdi.h
PUNY-80
TRS-80 disk image tool for Linux and other *nix operating systems
Copyright (c) 2024 Stefan Vogt and Shawn Sijnstra
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
See file LICENSE for details.
Based on TRS-80 Virtual Disk Kit by Miguel Dutra and Mike Gore.
*/
//---------------------------------------------------------------------------------
// Virtual Disk Interface
//---------------------------------------------------------------------------------
enum VDI_DENSITY
{
VDI_DENSITY_SINGLE = 0, // Single density disk
VDI_DENSITY_DOUBLE = 1, // Double density disk
VDI_DENSITY_MIXED = 2 // First track in opposity density to that of the other tracks
};
struct VDI_TRACK // Track Descriptor
{
BYTE nTrack; // Track number
BYTE nFirstSide; // First side number (0 or 1)
BYTE nLastSide; // Last side number (1 or 2)
BYTE nFirstSector; // First sector number (0 or 1)
BYTE nLastSector; // Last sector number
WORD wSectorSize; // Sector size (128, 256, 512, 1024)
VDI_DENSITY nDensity; // Sector density
};
struct VDI_GEOMETRY // Disk Descriptor
{
VDI_TRACK FT; // First track parameters
VDI_TRACK LT; // Last track (rest of the disk) parameters
};
class CVDI
{
protected:
FILE *m_hFile; // Handle for operations on the associated disk file
DWORD m_dwFlags; // User flags (future usage)
VDI_GEOMETRY m_DG; // Disk descriptor
public:
CVDI(); // Initialize member variables
virtual ~CVDI(); // Release allocated memory
virtual DWORD Load(HANDLE hFile, DWORD dwFlags = 0)=0; // Validate disk format and detect disk geometry
virtual DWORD Read(BYTE nTrack, BYTE nSide, BYTE nSector, BYTE* pBuffer, WORD wSize)=0; // Read one sector from the disk
virtual DWORD Write(BYTE nTrack, BYTE nSide, BYTE nSector, BYTE* pBuffer, WORD wSize)=0; // Write one sector to the disk
virtual void GetDG(VDI_GEOMETRY& DG); // Copy the disk geometry to the caller's struct
};