-
Notifications
You must be signed in to change notification settings - Fork 3
/
write71.asm
executable file
·141 lines (101 loc) · 3.63 KB
/
write71.asm
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// using standard kernal calls
// main entry
// carry bit is set on return if an error occurs
WRITE_D71:
jsr SET_1571_MODE // set drive in 1571 mode
// check for fast serial
bit SERIAL // check bit 6
bvs !+ // if set, then fast serial is available
lda #3
sta $d020
sec
rts
!:
// open buffer channel for data
jsr BUFFER_CHANNEL_OPEN
bcc write_d71_loop
lda #1
sta $d020
sec
rts
// actual write loop
write_d71_loop:
jsr DISPLAY_PROGRESS // print progress string
jsr DISPLAY_PROGRESS_HOME // move cursor to column 0
// get sector data from reu to memory buffer
// 256 bytes
jsr REU_TRANSFER_SECTOR
jsr CHECK_BUFFER_EMPTY // all 0's means empty sector
bcc !+ // carry bit clear means buffer is empty
jsr WRITE_SECTOR // write to disk
!:
jsr NEXT_SECTOR // update command string
inc current_sector // update sector counter
ldx current_track // get index to table
lda sectors_1571,x // get # sectors in this track
cmp current_sector // all track sectors done?
beq next_track_d71 // go to next track
jmp write_d71_loop // do next sector in this track
next_track_d71:
// start at sector 0 in next track
lda #0
sta current_sector
jsr RESET_SECTOR
// go to next track
jsr NEXT_TRACK // update command string
inc current_track // update track counter
lda current_track
cmp #71 // all tracks done?
bne write_d71_loop // do next track
clc // no error
rts
// --------------------------------------------------------------------------
// resets block pointer to position 0
// assumes channel 15 is open, and channel 2 is used for block operations
RESET_BLOCK_POINTER:
ldx #15
jsr CHKOUT // use file 15 (command) as output.
ldy #0
!loop:
lda bp_command,y // read byte from command string
jsr BSOUT // send to command channel
iny
cpy #bp_command_end - bp_command
bne !loop-
jsr CLRCH // execute sent command
rts
bp_command:
.text "B-P 2 0"
bp_command_end:
// Sets 1571 drive in double sided mode
SET_1571_MODE:
ldx #15
jsr CHKOUT // use file 15 (command) as output.
ldy #0
!:
lda ds_command,y // read byte from command string
jsr BSOUT // send to command channel
iny
cpy #ds_command_end - ds_command
bne !-
jsr CLRCH // execute sent command
rts
ds_command:
.text "U0>M1"
ds_command_end:
// see track.asm for the rest of the common routines
// -------------------------------------------------
// 1571 # of sectors per track
// sectors start at 0, tracks start at 1
sectors_1571:
.byte 0
// side 1, track 1
.byte 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21 // 17
.byte 19,19,19,19,19,19,19 // 7
.byte 18,18,18,18,18,18 // 6
.byte 17,17,17,17,17 // 5
// side 2, track 36
.byte 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21
.byte 19,19,19,19,19,19,19
.byte 18,18,18,18,18,18
.byte 17,17,17,17,17