10
20
30
40 :
50 DIM ctrl% 31,name% 31 :
60 X%=ctrl%:Y%=X%DIV256 :
70 INPUT "File to display: "file$ :
80 INPUT "*command to save: "save$ :
90 INPUT "Load address (RETURN for top of memory): &"load$
100 :
110 A%=FNfile(file$,5) :
120 IF A%=0:PRINT "File '"file$"' not found":END :
130 max%=X%!10 :
140 IF load$<>"":load%=EVAL("&"+load$) ELSE load%=&8000-max%-42
150 load%=load%OR&FFFF0000 :
160
170
180
190 :
200
210 DIM mcode% max%+42 :
220 addr=&A8:end=&AA:OSWRCH=&FFEE :
230 FOR P=0 TO 1:P%=load%:O%=mcode%
240 [OPT P*2+4
250 .display
260 LDA #data_start% AND 255:STA addr+0
270 LDA #data_start% DIV 256:STA addr+1 :\ addr=>start of stored VDU data
280 LDA #data_end% AND 255:STA end+0
290 LDA #data_end% DIV 256:STA end+1 :\ end=>end of stored VDU data
300 LDY #0
310 .loop
320 LDA (addr),Y:JSR OSWRCH :\ Fetch a byte and send it to VDU
330 INC addr+0:BNE P%+4:INC addr+1 :\ Increment address
340 LDA addr+0:CMP end+0:BNE loop
350 LDA addr+1:CMP end+1:BNE loop :\ Loop until addr=end
360 RTS
370 .data_start% :\ Start of data
380 ]P%=P%+max%:O%=O%+max%:[OPT P*2+4 :\ Space for VDU data
390 .data_end% :\ End of data
400 ]NEXT
410 OSCLI "Load "+file$+" "+STR$~(mcode%+data_start%-display) :
420 A$="SAVE "+save$+" "+STR$~mcode%+" "+STR$~O%+" "+STR$~load%+" "+STR$~load%
430 PRINT "Saving ";save$;:OSCLI A$:PRINT
440 END
450 DEFFNfile(A$,A%):$name%=A$:?X%=name%:X%?1=name%DIV256:=(USR&FFDD)AND&FF