-
Notifications
You must be signed in to change notification settings - Fork 3
/
device.h
95 lines (88 loc) · 1.95 KB
/
device.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
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
#pragma once
#include <SDL.h>
#include <stdio.h>
#include <Windows.h>
#define MAXDEVS 16
#define DEVBLOCK 0x8000 //32 KiB
class Device
{
public:
Device(void);
virtual ~Device(void) = 0;
virtual unsigned int Read(unsigned int address);
virtual void Write(unsigned int address, unsigned int value);
virtual int GetID();
virtual void HBlank();
virtual void VBlank();
};
class DiskDrive : public Device
{
private:
FILE* file;
unsigned char* data;
unsigned short sector;
unsigned long capacity;
unsigned int tracks, heads, sectors;
int error;
int type;
public:
DiskDrive(int newType);
~DiskDrive(void);
int Mount(const WCHAR* filename);
int Unmount();
unsigned int Read(unsigned int address);
void Write(unsigned int address, unsigned int value);
int GetID();
void HBlank();
void VBlank();
int GetType();
bool IsMounted();
};
//0x0144: 1.44 MB, even if it's a hard disk drive
#define DEVID_DISKDRIVE 0x0144
enum diskDriveTypes
{
ddDiskette,
ddHardDisk,
};
class LinePrinter : public Device
{
private:
char line[120];
int lineLength, visibleLength, padLength;
int pageLength;
public:
LinePrinter(void);
~LinePrinter(void);
unsigned int Read(unsigned int address);
void Write(unsigned int address, unsigned int value);
int GetID();
void HBlank();
void VBlank();
};
//0x4C50: LP for Line Printer
#define DEVID_LINEPRINTER 0x4C50
class InputOutputDevice : public Device
{
private:
unsigned int buffer[32];
unsigned int bufferCursor;
int lastMouseX, lastMouseY;
unsigned int mouseLatch;
public:
InputOutputDevice(void);
~InputOutputDevice(void);
unsigned int Read(unsigned int address);
void Write(unsigned int address, unsigned int value);
int GetID();
void HBlank();
void VBlank();
void Enqueue(SDL_Keysym sym);
};
//0x494F: IO for Input Output
#define DEVID_INPUT 0x494F
#define READ_DEVID(x) \
if (address == 0) return (x >> 8); \
else if (address == 1) return (x & 0xFF);
extern Device* devices[MAXDEVS];
extern InputOutputDevice* inputDev;