-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbdos.h
More file actions
125 lines (106 loc) · 3.97 KB
/
bdos.h
File metadata and controls
125 lines (106 loc) · 3.97 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/**
bdos.cpp - CP/M 2.2 compatible Basic Disk Operating System (BDOS)
Copyright (C) 2020 Costin STROIE <costinstroie@eridu.eu.org>
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BDOS_H
#define BDOS_H
#include "Arduino.h"
#include "global.h"
#include "config.h"
#include "i8080.h"
#ifdef SPI_RAM
#include "spiram.h"
typedef SPIRAM RAM;
#else
#include "mcuram.h"
typedef MCURAM RAM;
#endif
#include "drive.h"
#include "bios.h"
struct FCB_t {
union {
struct {
uint8_t dr; // Drive: 0 for default, 1-16 for A-P.
uint8_t fn[8]; // Filename, 7-bit ASCII.
uint8_t tp[3]; // Filetype, 7-bit ASCII.
uint8_t ex; // Current extent.
uint8_t s1; // Reserved.
uint8_t s2; // Current extent, high byte.
uint8_t rc;
uint8_t al[16]; // File allocation.
uint8_t cr; // Current record within extent.
uint8_t r0; // Random access record number.
uint8_t r1; // Random access record number.
uint8_t r2; // Random access record number.
};
uint8_t buf[36];
};
};
struct DIR_t {
union {
struct {
uint8_t uu; // User number. 0-15
uint8_t fn[8]; // Filename
uint8_t tp[3]; // Filetype
uint8_t ex; // Extent counter, low byte - takes values from 0-31
uint8_t s1; // Extent counter, high byte.
uint8_t s2; // Reserved, set to 0.
uint8_t rc; // Number of records used in this extent, low byte.
uint8_t al[16]; // Allocation. Each AL is the number of a block on the disc.
};
uint8_t buf[32];
};
};
class BDOS {
public:
BDOS(I8080 *cpu, RAM *ram, DRIVE *drv, BIOS *bios);
~BDOS();
void init();
uint8_t call(uint16_t port);
bool selDrive(uint8_t drive);
bool fcb2cname(FCB_t fcb, char* fname);
private:
I8080 *cpu;
RAM *ram;
DRIVE *drv;
BIOS *bios;
void bdosError(uint8_t err);
void readFCB();
void writeFCB();
void showFCB(const char* comment = "");
void dirEntry(char *cname, uint8_t uid, uint32_t fsize);
uint8_t func; // BDOS function number
uint16_t params; // Keep DE before BDOS call
uint8_t cDrive = 0; // Current drive
uint8_t tDrive = 0; // Temporary drive
uint8_t cUser = 0; // Current user
uint16_t ramDMA = TBUFF; // DMA address
uint16_t ramFCB; // FCB address
uint16_t rwoVector = 0x0000; // Read-only / Read-write vector
uint16_t alcVector = 0x0000; // Allocation vector
uint16_t logVector = 0x0000; // Logged drives vector
FCB_t fcb; // FCB object
char fName[128]; // Filename
char cName[12]; // CP/M file name
bool fAllUsers; // Find files from all users
bool fAllExnts; // Report all extents
uint32_t fSize; // File size
uint32_t fPos; // File position (seek)
uint32_t fRec; // File record (random seek)
uint32_t fRecs; // File records in directory entry
uint16_t fExts; // File extents in directory entry
uint16_t fExtU; // File extents used in directory entry
uint16_t fAllB; // First free allocation block
uint16_t result; // Result from BDOS functions
};
#endif /* CPM_H */