1 ' Disk file editor for FIFTH
2 ' Svjatoslav Agejenko: n0@hot.ee
6 DECLARE SUB ask (a$, b$)
8 DECLARE SUB llen (a%, l%)
16 DIM SHARED buf(0 TO 31, 0 TO 31)
17 DIM SHARED obuf(0 TO 31, 0 TO 31)
18 DIM SHARED byte AS STRING * 1
19 DIM SHARED font(0 TO 20, 0 TO 255)
21 DIM SHARED keys(0 TO 10000)
24 DIM SHARED fil$(0 TO 1000)
25 DIM SHARED fline, froll
30 OPEN "..\..\disk.raw" FOR BINARY AS #1
40 IF keyl > 10000 THEN keyl = 0
50 LOCATE 16, 34 + LEN(a$)
62 IF c <> obuf(x, y) THEN
63 PUT (x * 8, y * 8), font(0, c), PSET
74 IF c = 15 THEN c = 0 ELSE c = 10
99 PRINT "page:"; eb; " "
106 IF keyl = keyc THEN GOTO 2
107 a$ = CHR$(keys(keyc))
109 IF keyc > 10000 THEN keyc = 0
113 IF a$ = CHR$(0) + CHR$(73) THEN eb = eb - 1
114 IF a$ = CHR$(0) + CHR$(81) THEN eb = eb + 1
115 IF a$ = CHR$(27) THEN GOTO 4
116 IF a$ = CHR$(0) + "M" THEN curx = curx + 1
117 IF a$ = CHR$(0) + "K" THEN curx = curx - 1
118 IF a$ = CHR$(0) + "P" THEN cury = cury + 1
119 IF a$ = CHR$(0) + "H" THEN cury = cury - 1
120 IF a$ = CHR$(0) + "=" THEN ask "page: ", b$: eb = VAL(b$)
121 IF a$ = CHR$(0) + "?" THEN ask "file: ", b$: fopen b$
122 IF a$ = CHR$(0) + CHR$(132) THEN fline = fline - 1: fdisp
123 IF a$ = CHR$(0) + CHR$(118) THEN fline = fline + 1: fdisp
124 IF a$ = CHR$(0) + CHR$(64) THEN ' F6
126 FOR b = 1 TO LEN(fil$(fline))
127 c$ = RIGHT$(LEFT$(fil$(fline), b), 1)
128 IF c$ = CHR$(9) THEN c$ = " "
129 IF c$ = " " OR c$ = CHR$(255) THEN d = d + 1 ELSE d = 0
130 IF d < 2 THEN addk c$
134 IF a$ = CHR$(0) + ";" THEN
143 IF a$ = CHR$(0) + CHR$(83) THEN
145 buf(b, cury) = buf(b + 1, cury)
151 IF (a$ = CHR$(13)) AND (bk = 0) THEN
154 FOR a = 31 TO cury + 2 STEP -1
156 buf(b, a) = buf(b, a - 1)
160 buf(a, cury + 1) = 255
163 SWAP buf(a, cury), buf(a - curx, cury + 1)
172 IF ASC(a$) = 32 THEN a$ = CHR$(255)
173 IF (a$ = CHR$(8)) AND (bk = 0) THEN
176 FOR b = curx - 1 TO 30
177 buf(b, cury) = buf(b + 1, cury)
187 buf(b, cury - 1) = buf(b - a, cury)
191 buf(b, a) = buf(b, a + 1)
204 IF a$ = CHR$(0) + "<" THEN
205 ask "decimal number:", b$
208 c = ASC(RIGHT$(LEFT$(b$, a), 1))
209 IF (c <= 57) AND (c >= 48) THEN d$ = CHR$(c - 48): addk d$
210 IF (c <= 70) AND (c >= 65) THEN d$ = CHR$(c - 55): addk d$
214 IF a$ = CHR$(0) + CHR$(65) THEN
215 FOR a = 999 TO fline STEP -1
216 fil$(a + 1) = fil$(a)
220 fil$(fline) = fil$(fline) + CHR$(buf(a, cury))
225 IF a$ = CHR$(0) + ">" THEN
226 ask "ascii code:", b$
231 FOR b = 31 TO curx + 1 STEP -1
232 buf(b, cury) = buf(b - 1, cury)
234 buf(curx, cury) = ASC(a$)
239 IF eb < 0 THEN eb = 0
240 IF curx < 0 THEN curx = 0
241 IF cury < 0 THEN cury = 0
242 IF curx > 31 THEN curx = 31
243 IF cury > 31 THEN cury = 31
250 IF fline < 0 THEN fline = 0
251 IF fline > 1000 THEN fline = 1000
252 IF fline - froll > 10 THEN froll = fline - 10
253 IF fline - froll < 0 THEN froll = fline
254 IF froll < 0 THEN froll = 0
259 PRINT "file: " + filename$
266 IF a + froll = fline THEN
268 IF fil$(a + froll) = SPACE$(LEN(fil$(a + froll))) THEN
277 PRINT fil$(a + froll) + SPACE$(80 - LEN(fil$(a + froll)));
291 OPEN filename$ FOR INPUT AS #2
293 IF EOF(2) <> 0 THEN GOTO 6
297 IF b > 1000 THEN GOTO 6
308 FOR b = 31 TO 0 STEP -1
309 IF buf(b, a) <> 255 THEN l = b + 1: GOTO 3
324 buf(x, y) = ASC(byte)
337 byte = CHR$(buf(x, y))
349 filename$ = "<noname>"
355 OPEN "font.dat" FOR BINARY AS #1
362 IF n >= b THEN n = n - b: c = 15 ELSE c = 0
367 GET (0, 0)-(7, 7), font(0, f)
378 PRINT "F1 - clear page"
380 PRINT "F2 - enter decimal number"
382 PRINT "F3 - goto page"
384 PRINT "F4 - enter character code"
386 PRINT "F5 - load source file"
388 PRINT "F6 - insert line from source file"
390 PRINT "F7 - copy line to source file"