8-Bit Software Online Conversion
Universal Packager - Listing
10REM Generate a universal header for
a
20REM data file
30:
40MODE7
50PRINT"Universal file generator"'
60osas=&FFE3:osfi=&FFDD
70header=109:REM Size of BASIC header
80DIMprint% 128
90:
100INPUT"File to append: "F$
110INPUT"Chosen value of PAGE: "page$
120page%=(EVAL(page$) DIV256)*256
130IFpage%<&E00 THENPRINT'"Bad PAGE":E
ND
140PRINT"Line 1:";:line1$=FNgetline
150PRINT"Line 2:";:line2$=FNgetline
160PRINT"Line 3:";:line3$=FNgetline
170:
180PRINT'"Opening ";F$;" to save at &"
;÷page%
190PRINT"Final version is 'OUTPUT'"
200F=OPENIN F$:IFF=0 THENCLOSE#F:PRINT
'"Not found":END
210lof%=EXT#F
220:
230REM Assemble as though ABOVE the da
ta file
240FORX=4 TO7 STEP3
250P%=page%+lof%+header:O%=print%
260[OPTX
270.entry
280LDY#0
290.printhelp
300LDApage%,Y:BMIdone:JSRosas:INY:BPLp
rinthelp
310.done
320RTS
330]
340NEXT
350REM Splice the 2 files together
360PTR#F=0:O=OPENOUT"OUTPUT"
370PROCputline(CHR$13+CHR$10+CHR$10+CH
R$32+"*| "+line1$)
380PROCputline(CHR$13+CHR$10+CHR$10+CH
R$32+"*| "+line2$)
390PROCputline(CHR$13+CHR$10+CHR$10+CH
R$32+"*| "+line3$)
400PROCputline(CHR$13+CHR$10+CHR$10+CH
R$10+"*FX119")
410PROCputline(CHR$13+CHR$255+CHR$21):
REM End the BASIC file and turn off the
VDU
420REPEAT
430byte%=BGET#F:BPUT#O,byte%
440UNTILEOF#F
450:
460FORoffset%=print% TO(O%-1)
470BPUT#O,?offset%
480NEXT
490:
500CLOSE#F:CLOSE#O
510:
520REM Now set the attributes
530FORX=0TO2STEP2
540P%=print%
550[OPTX
560.block
570EQUW fname:½Pointer to fname
580EQUW page%
590EQUW &FFFF:½Load addr (4b)
600EQUW page%+lof%+header
610EQUW &FFFF:½Exec addr (4b)
620EQUD 0
630EQUD 0
640.fname
650EQUS"OUTPUT"+CHR$13
660]
670NEXT
680X%=print% MOD256:Y%=print% DIV256
690A%=1:CALL osfi
700PRINT'"Done."
710END
720:
730DEFPROCputline(string$)
740FORoffset%=1TOLENstring$:BPUT#O,ASC
MID$(string$,offset%,1):NEXT
750ENDPROC
760:
770DEFFNgetline
780work$="":Y%=VPOS
790REPEAT
800key%=GET
810IFkey%=127 THENwork$=LEFT$(work$,LE
Nwork$-1)
820IFkey%=21 THENwork$=""
830IFkey%<>13 ANDkey%<>127 ANDkey%<>21
THENwork$=work$+CHR$key%
840PRINTTAB(7,Y%);work$;STRING$(25-LEN
work$," ");
850UNTILkey%=13 ORLENwork$=25
860work$=work$+STRING$(25-LENwork$," "
):PRINT
870=work$
880