-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdisk.h
55 lines (43 loc) · 1.44 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
#ifndef _DISK_H
#define _DISK_H
class disk: public Memory::Device, public PIA, public ACIA {
public:
disk(flash_file &a, flash_file &b, flash_file &c, flash_file &d):
Memory::Device(Memory::page_size),
driveA(a), driveB(b), driveC(c), driveD(d), drive(&a),
pos(0), track(0xff), ticks(0) {}
void reset();
void tick();
virtual void operator=(uint8_t);
virtual operator uint8_t();
protected:
virtual void write_portb(uint8_t);
virtual uint8_t read_porta();
virtual uint8_t read_status();
virtual uint8_t read_data();
virtual void write_control(uint8_t);
virtual void write_data(uint8_t);
virtual bool acia_more() { return drive->more(); }
virtual void acia_reset() { drive->reset(); seek_start(); }
virtual void acia_framing(uint32_t config) { drive->framing(config); }
private:
void seek_start();
void write(uint8_t);
flash_file &driveA, &driveB, &driveC, &driveD, *drive;
uint32_t pos;
uint8_t track;
volatile unsigned ticks;
};
// kludge to workaround "timing routine hang":
// 5.25 disks with OS65D v3.3 appear to hang. The reason is probably due to the timing routine, described
// here: https://osiweb.org/Peek65/Peek65_V6N10-10_1985.pdf ("OS65D V3.3 BUG!")
class disk_timer: public Memory::Device {
public:
disk_timer(): Memory::Device(Memory::page_size), _state(0) {}
virtual void operator= (uint8_t) {}
virtual operator uint8_t() { return _get(_acc); }
private:
uint8_t _get(Memory::address a);
uint8_t _state;
};
#endif