forked from Konamiman/Nextor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCONCLUS.MAC
174 lines (137 loc) · 2.9 KB
/
CONCLUS.MAC
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
.z80
jp START
INFO:
db 13
db "CONCLUS - Check if a file is stored across consecutive clusters",13,10
db 13,10
db "Usage: CONCLUS <file path>",13,10
db 1Ah
db "$"
START:
call CHECK_NEXTOR_21
;--- Get file info, terminate on any error
ld hl,PARAMETERS_S
ld de,BUF
ld b,255
ld c,_GENV##
call 5
ld de,BUF
call REMOVE_SPACES
ex de,hl
ld a,(hl)
or a
ld de,INFO
jp z,PRINT_ERR_TERM ;No filename provided?
ld c,_FFIRST##
ex de,hl
push de
ld ix,FIB
ld b,0
call 5
pop de
ld b,a
ld c,_TERM##
jp nz,5 ;Error searching the file?
ld a,(FIB+25)
ld (DRIVE),a
ld hl,(FIB+19) ;First cluster of the file
;--- Loop to check all the clusters of the file.
; Input: HL = Last cluster checked
GETCLUS_LOOP:
ex de,hl
ld c,_GETCLUS##
ld hl,BUF
ld a,(DRIVE)
push de
call 5
ld b,a
ld c,_TERM##
jp nz,5 ;Error getting cluster info?
ld e,"."
ld c,_CONOUT##
call 5
ld a,(BUF+11)
and 1000b ;Last cluster of the file?
ld de,YESCON_S
jp nz,PRINT_TERM
ld de,(BUF+8) ;Value of FAT entry (next cluster number)
pop hl ;Previous cluster number
inc hl
push hl
or a
sbc hl,de
ld a,h
or l
pop hl
jr z,GETCLUS_LOOP
ld e,'*'
ld c,_CONOUT##
call 5
ld de,NOCON_S
jp PRINT_TERM
;>>> Subroutines
;--- Remove leading spaces from string pointed by DE
; (returns DE pointing to first non-space)
REMOVE_SPACES:
ld a,(de)
cp ' '
ret nz
inc de
jr REMOVE_SPACES
;--- Check Nextor kernel and NEXTOR.SYS versions
CHECK_NEXTOR_21:
ld b,05Ah
ld hl,01234h
ld de,0ABCDh
ld c,_DOSVER##
ld ix,0
call 5
push de
pop hl
ld de,BADKER_MSG
ld a,b
cp 2
jr c,PRINT_ERR_TERM ;Error if MSX-DOS 1
push ix
pop bc
ld a,b
cp 1 ;NEXTOR_ID
jr nz,PRINT_ERR_TERM ;Not Nextor
ld a,c
cp 3
ret nc ;Nextor >= 3.0
cp 2
jr c,PRINT_ERR_TERM ;Nextor < 2.0
push iy
pop bc
ld a,b
or a
jr z,PRINT_ERR_TERM ;Nextor 2.0
ld de,BADSYS_MSG
ld a,h
cp 2
jr c,PRINT_ERR_TERM ;NEXTOR.SYS < 2.0
ld a,l
cp 011h
ret nc ;NEXTOR>SYS > 2.11: ok
PRINT_ERR_TERM:
ld b,1
PRINT_TERM:
ld c,_STROUT##
call 5
ld c,_TERM##
jp 5
BADKER_MSG:
db "*** This program requires Nextor 2.1 or later",13,10,"$"
BADSYS_MSG:
db "*** Bad version of NEXTOR.SYS, version 2.11 or later is required",13,10,"$"
;>>> Strings and data
PARAMETERS_S: db "PARAMETERS",0
YESCON_S:
db 13,10,"The file is stored across consecutive clusters :-)",13,10,"$"
NOCON_S:
db 13,10,"The file is NOT stored across consecutive clusters! :-(",13,10,"$"
DRIVE: db 0
FIB: ds 64
BUF:
end