10
20
30
40 :
50 DIM mcode% &2000,L%-1:
60 :
70 FOR pass%=0 TO 3
80 opt%=FNsm_pass(pass%)
90 [OPT opt%
100 EQUB 0:EQUW RelocTable
110 JMP Service
120 EQUB &82:EQUB Copyright-RomStart
130 EQUB &00:EQUS "ROM Title"
140 EQUB &00:EQUS "0.00 (00 Jan 0000)"
150 .Copyright
160 EQUB &00:EQUS "(C)Author Name":EQUB &00
170 :
180 .Service
190 \ insert code here ....
200 :
210 .RelocTable
220 ]NEXT:PROCsm_table
230 PRINT"*Save <filename> ";~(mcode%+mclen%);" ";~O%;" FFFF0000 FFFBBC00"
240 END
250 :
260 DEFFNsm_pass(pass%)
270 IFpass%=0:mclen%=0
280 IFpass%=1:mclen%=O%-mcode%
290 P%=&8100-128*(pass%AND2)
300 O%=mcode%+mclen%*(pass%AND2)DIV2
310 IFpass%=1:IF O%+mclen%*2.125>L%:PRINT"Code overrun":END
320 =VALMID$("4647",pass%+1,1)
330 :
340 DEFPROCsm_table
350 base80%=mcode%+mclen%:base81%=mcode%:byte%=0:count%=0:off%=0:REPEAT
360 byte80%=base80%?off%:byte81%=base81%?off%:IF off%>=mclen%:byte80%=&80:byte81%=&80
370 IF ((byte81%-byte80%) AND &FE)<>0 THEN PRINT "ERROR: Offset by more than one page at &";~&8000+off%
380 IF (byte80% AND &C0)=&80:byte%=byte%DIV2+128*(byte81%-byte80%):count%=count%+1
390 IF count%=8:?O%=byte%:O%=O%+1:byte%=0:count%=0
400 off%=off%+1:UNTILoff%>=mclen% AND count%=0
410 ENDPROC