-
Notifications
You must be signed in to change notification settings - Fork 2
/
getdens.src
123 lines (103 loc) · 2.16 KB
/
getdens.src
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
; getdens - check density of disk
;
; Copyright (C) 1992-2004 Matthias Reichl <hias@horus.com>
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; 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 General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
; set mask for sector link (SECMASK), number of data bytes per
; sector (SECBYTE) and SIO sector length ($308/309)
; this subroutine requires a 256 bytes buffer named "SECBUF"
; and the address of the SIO routine in the label "SIOVEC"
GETDENS LDA #3
STA SECMASK
; read sector 4 with length=0
; this is needed by the XF551 to check the disk density
LDA #<SECBUF
STA DBUF
LDA #>SECBUF
STA DBUF+1
LDA #$52
STA $302
LDA #0
STA $308
STA $309
STA DSEC+1
LDA #4
STA DSEC
LDA #7
STA $306
LDA #$00
STA $303
JSR SIOVEC
; wait a bit for the sector data bytes to arrive
LDA 20
CLC
ADC #20
W20 CMP 20
BNE W20
; check the disk status
LDA #$53
STA $302
LDA #4
STA $308
; workaround for bug in older MyIDE interfaces:
; get status always put the status into $2EA..$2ED
LDA #$EA
STA DBUF
LDA #2
STA DBUF+1
LDA #$40
STA $303
JSR SIOVEC
BPL STATOK
SNGLDS LDA #0
STA $309
LDA #128
STA $308
LDA #125
STA SECBYTE
RTS
STATOK LDA $2EA
AND #$20
BNE DBLDENS
JSR SNGLDS
BNE TSTSIZE
DBLDENS LDA #1
STA $309
LDA #0
STA $308
LDA #253
STA SECBYTE
; now read the VTOC and check if the first byte is larger than 2
; if yes, the sector link is 16 bits.
TSTSIZE LDA #$52
STA $302
LDA #$68
STA DSEC
LDA #1
STA DSEC+1
LDA #$40
STA $303
LDA #<SECBUF
STA DBUF
LDA #>SECBUF
STA DBUF+1
JSR SIOVEC
BMI ENDDENS
LDA SECBUF
CMP #3
BCC ENDDENS
LDA #$FF
STA SECMASK
ENDDENS RTS