10
20
30
40 :
50 PROCassem(0):CLEAR:PROCassem(2):PROCsm_table
60 A$="*SAVE "+fname$+" "+STR$~(mcode%+M%)+" "+STR$~O%+" FFFF0000 FFFBBC00"
70 PRINTA$;:OSCLIA$:PRINT
80 END
90 :
100 DEFPROCassem(pass%)
110 OSASCI=&FFE3:OSWRCH=&FFEE:OSNEWL=&FFE7:OSWORD=&FFF1
120 ver$="0.00":date$="01 Jan 2000":fname$="SoftConfig"
130 ws=&A8:tmp=ws+7:osw14=14:osw15=osw14+1:save=&D94
140 DIM mcode% &1000, L%-1
150 :
160 FOR pass%=pass% TO pass%+1
170 opt%=FNsm_pass(pass%)+8+16
180 [OPT opt%
190 .ROMBase
200 EQUB &00:EQUW RelocTable
210 JMP Service
220 EQUB &82:EQUB copyright-ROMBase
230 .ROMTitle
240 EQUB VALver$*10:EQUS "SoftConfig"
250 EQUB &00:EQUS ver$+" ("+date$+")"
260 .copyright
270 EQUB &00:EQUS "(C)J.G.Harston"
280 EQUB &00
290 :
300 \ SERVICE 9 - *Help
310 \ -----------------
320 .Serv09
330 LDA (&F2),Y
340 CMP #13:BNE Serv9Exit :\ Not *Help<cr>
350 JSR OSNEWL
360 .Serv9a
370 LDX #0
380 .Serv9Lp
390 LDA &8009,X:BNE Serv9Chk :\ Display ROM title
400 LDA #ASC" ":BNE Serv9Char
410 .Serv9Chk
420 CMP #ASC" ":BEQ Serv9Done
430 .Serv9Char
440 JSR OSWRCH:INX:BNE Serv9Lp
450 .Serv9Done
460 JSR OSNEWL
470 .Serv9Exit
480 LDA #9:RTS
490 :
500 .Service
510 \CMP $&04:\BEQ Serv04 :\ *Command
520 CMP #&07:BEQ Serv07 :\ OSBYTE
530 CMP #&09:BEQ Serv09 :\ *Help
540 RTS
550 :
560 \ SERVICE 7 - OSBYTE
570 \ -----------------
580 .Serv07
590 LDY &F1:LDX &F0:LDA &EF :\ A=num, X=byte, Y=value
600 CMP #161:BEQ Osbyte161 :\ OSBYTE 161 - Read CMOS
610 CMP #162:BEQ Osbyte162 :\ OSWORD 162 - Write CMOS
620 .Serv07Quit
630 LDA #7:RTS
640 :
650 .Osbyte162
660 INX:BEQ OsbyteClaim :\ Don't write size byte
670 DEX:BEQ OsbyteClaim :\ Don't write station number
680 TYA:STA CMOS,X
690 .Osbyte161
700 LDY CMOS,X
710 .OsbyteClaim
720 LDA #0:RTS
730 .CMOS
740 EQUS STRING$(128,CHR$0)
750 EQUS STRING$(127,CHR$0)
760 EQUB &FF :\ Size=256-1
770 :
780 ]:RelocTable=P%:NEXT:ENDPROC
790 :
800 DEFFNsm_pass(pass%)
810 IFpass%=0:M%=0
820 IFpass%=1:M%=O%-mcode%
830 P%=&8100-128*(pass%AND2)
840 O%=mcode%+M%*(pass%AND2)DIV2
850 IFpass%=1:IF O%+M%*2.125>L%:PRINT"Code overrun":END
860 =VALMID$("4646",pass%+1,1)
870 :
880 DEFPROCsm_table
890 base80%=mcode%+M%:base81%=mcode%:byte%=0:count%=0:off%=0:REPEAT
900 byte80%=base80%?off%:byte81%=base81%?off%:IF off%>=M%:byte80%=&80:byte81%=&80
910 IF ((byte81%-byte80%) AND &FE)<>0 THEN PRINT "ERROR: Offset by more than one page at &";~&8000+off%
920 IF (byte80% AND &C0)=&80:byte%=byte%DIV2+128*(byte81%-byte80%):count%=count%+1
930 IF count%=8:?O%=byte%:O%=O%+1:byte%=0:count%=0
940 off%=off%+1:UNTILoff%>=M% AND count%=0
950 ENDPROC