Repository navigation
Expand file tree
/
Copy pathdiskbytes.asm
More file actions
75 lines (72 loc) · 2.23 KB
/
Copy pathdiskbytes.asm
File metadata and controls
75 lines (72 loc) · 2.23 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
; OpenDiskSysROM
; Copyright (c) 2026 Daniel Oranguthang
;
; This program is free software: you can redistribute it and/or modify it under
; the terms of the GNU Lesser General Public License version 3 as published by
; the Free Software Foundation.
;
; 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 Lesser General Public License for more
; details.
;
; You should have received a copy of the GNU Lesser General Public License
; along with this program. If not, see <https://www.gnu.org/licenses/>.
; Reads the next byte of the block being transferred. Like XferByte, but it
; does not touch $4024, and the end of the disk ends the disk call with
; EOF_READ instead of waiting for a byte that will not come: $4030 bit 6 says so
; on some drives, $4032 bit 1 (not ready) once the drive has stopped at the end
; on others. Reading $4030 clears the byte transfer flag, so each byte is taken
; once.
; Returns: A = byte read
; Affects: A
ReadByte:
@wait:
LDA DISKSTATUS
AND #%01000010 ; bit 1: a byte is there, bit 6: end of the disk
BNE @status
LDA DRIVESTATUS
AND #%00000010 ; bit 1: the drive stopped
BEQ @wait
BNE @end
@status:
AND #%00000010
BEQ @end
LDA READDATA
RTS
@end:
LDA #EOF_READ
JMP DiskExit
; Writes the next byte of the block being written: waits until the RAM adapter
; has taken the previous one, then hands it A. The end of the disk ($4030 bit
; 6, or $4032 bit 1 once the drive has stopped) ends the disk call with
; EOF_WRITE.
; Parameters: A = byte to write
; Affects: nothing else
WriteByte:
PHA
JSR WaitWriteReady
PLA
STA WRITEDATA
RTS
; Waits for the next byte time of a write: until the RAM adapter is ready for
; a byte. The end of the disk ($4030 bit 6, or $4032 bit 1 once the drive has
; stopped) ends the disk call with EOF_WRITE, so a write that runs off the
; disk never waits for good.
; Affects: A
WaitWriteReady:
@wait:
LDA DISKSTATUS
AND #%01000010 ; bit 1: ready for a byte, bit 6: end of the disk
BNE @status
LDA DRIVESTATUS
AND #%00000010 ; bit 1: the drive stopped
BEQ @wait
BNE @end
@status:
AND #%00000010
BEQ @end
RTS
@end:
LDA #EOF_WRITE
JMP DiskExit