-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfloppy.cs
89 lines (68 loc) · 1.71 KB
/
floppy.cs
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
class FloppyDisk : Device
{
private i8237 _dma_controller = null;
private PendingInterrupt _pi = new();
public FloppyDisk()
{
}
public void SetDma(i8237 dma_instance)
{
_dma_controller = dma_instance;
}
public override void SetPic(pic8259 pic_instance)
{
_pic = pic_instance;
_pi.int_vec = _pic.GetInterruptOffset() + 6;
}
public override String GetName()
{
return "FloppyDisk";
}
public override void RegisterDevice(Dictionary <ushort, Device> mappings)
{
for(ushort port=0x03f0; port<0x03f8; port++)
mappings[port] = this;
}
public override bool HasAddress(uint addr)
{
return false;
}
public override void WriteByte(uint offset, byte value)
{
}
public override byte ReadByte(uint offset)
{
return 0xee;
}
public override void SyncClock(int clock)
{
}
public override bool Tick(int cycles)
{
return false;
}
public override List<PendingInterrupt> GetPendingInterrupts()
{
if (_pi.pending)
{
List<PendingInterrupt> rc = new();
rc.Add(_pi);
return rc;
}
return null;
}
public override (byte, bool) IO_Read(ushort port)
{
Log.DoLog($"Floppy-IN {port:X4}", true);
if (port == 0x3f4)
return (128, _pi.pending);
return (0x00, _pi.pending);
}
public override bool IO_Write(ushort port, byte value)
{
Log.DoLog($"Floppy-OUT {port:X4} {value:X2}", true);
if (port == 0x3f2)
_pi.pending = true; // FDC enable (controller reset) (IRQ 6)
return _pi.pending;
}
}