This repository has been archived by the owner on Jun 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
disk.h
83 lines (68 loc) · 2.3 KB
/
disk.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
#ifndef DISK_H
#define DISK_H
#include "sio.h"
extern int command_frame_counter;
// Specify sectors 0-UNCACHED_REGION to not be cached
// Normally, this is set to 3 to not cache the first three sectors, which
// may be only 128 bytes compared to 256 bytes for double density images.
// If you set this to 65535, then the cache is completely disabled.
// Please do not change this value yet, the cache has been ripped out
// due to be rewritten.
#define UNCACHED_REGION 65535
#define ATARISIO_ATARI_FREQUENCY_PAL 1773447
#define COMMAND_FRAME_SPEED_CHANGE_THRESHOLD 2
#define HISPEED_INDEX 0x06
// 0x06
// 10
// 0x00
#define HISPEED_BAUDRATE (ATARISIO_ATARI_FREQUENCY_PAL * 10) / (10 * (2 * (HISPEED_INDEX + 7)) + 3)
// 68837
// 52640
//125984
#define STANDARD_BAUDRATE 19200
#define SERIAL_TIMEOUT 300
unsigned short para_to_num_sectors(unsigned short para, unsigned char para_hi, unsigned short ss);
unsigned long num_sectors_to_para(unsigned short num_sectors, unsigned short sector_size);
class sioDisk : public sioDevice
{
private:
FILE *_file;
unsigned short sectorSize = 128;
byte sector[256];
byte sectorCache[4][256];
unsigned short lastSectorNum = 65535;
struct
{
unsigned char num_tracks;
unsigned char step_rate;
unsigned char sectors_per_trackM;
unsigned char sectors_per_trackL;
unsigned char num_sides;
unsigned char density;
unsigned char sector_sizeM;
unsigned char sector_sizeL;
unsigned char drive_present;
unsigned char reserved1;
unsigned char reserved2;
unsigned char reserved3;
} percomBlock;
void sio_read();
void sio_write(bool verify);
void sio_format();
void sio_status() override;
void sio_process() override;
void derive_percom_block(unsigned short numSectors);
void sio_read_percom_block();
void sio_write_percom_block();
void dump_percom_block();
void sio_high_speed();
public:
void mount(FILE *f);
void umount();
void invalidate_cache();
bool write_blank_atr(FILE *f, unsigned short sectorSize, unsigned short numSectors);
FILE *file();
};
long sector_offset(unsigned short sectorNum, unsigned short sectorSize);
unsigned short sector_size(unsigned short sectorNum, unsigned short sectorSize);
#endif // guard