10
20
30 :
40 OSARGS=&FFDA:OSFILE=&FFDD:OSGBPB=&FFD1:OSFIND=&FFCE
50 GSINIT=&FFC2:GSREAD=&FFC5
60 :
70 DIM mcode% &300:load%=&FFFF0900:ver$="v1.03"
80 :
90 lptr=&F2:addr=&A8
100 FOR P=0 TO 1
110 P%=load%:O%=mcode%
120 [OPT P*3+4
130 .ctrl
140 EQUW 0
150 .errSyntax
160 BRK:EQUB 220:EQUS "Syntax: SetType <fsp> <type>"
170 .errNotFound
180 BRK:EQUB 214:EQUS "File not found":BRK
190 :
200 .start%
210 LDA #1:LDX #addr:LDY #0:JSR OSARGS
220 LDA addr+0:STA lptr+0:STA ctrl+0 :\ =>filename
230 LDA addr+1:STA lptr+1:STA ctrl+1
240 CLC:JSR GSINIT:BEQ errSyntax
250 .SkipName
260 JSR GSREAD:BCC SkipName :\ Step past name
270 JSR SkipSpace:BEQ errSyntax :\ Step to parameter
280 LDX #addr:JSR GetHex:BNE errSyntax :\ Scan parameter
290 LDA #5:JSR CallFile :\ Read current info
300 TAX:BEQ errNotFound
310 LDA #&00:STA ctrl+2
320 LDA addr+0:STA ctrl+3:PHA
330 LDA addr+1:ORA #&F0:STA ctrl+4:TAY :\ Load=&FFFxxx00
340 LDX #4:LDX #&FF
350 .SetAddrLp
360 STA ctrl+5,X:DEX:BPL SetAddrLp :\ Exec=&FFFFFFFF
370 PLA:INY:BNE SetExecZero :\ <>&Fxx, set Exec=&FFFF0000
380 CMP #&FE:BCS SetInfo :\ &FFE=Command, &FFF=Text
390 CMP #&F7:BEQ SetInfo :\ &FF7=Font
400 CMP #&EB:BEQ SetInfo :\ &FEB=Obey
410 .SetExecZero
420 INC ctrl+6:INC ctrl+7 :\ Exec=&FFFF0000
430 .SetInfo
440 LDA #1 :\ Write info
450 .CallFile
460 LDX #ctrl AND 255:LDY #ctrl DIV 256
470 JMP OSFILE
480 :
490 .GetHex
500 LDA #0
510 STA 0,X:STA 1,X:STA 2,X:STA 3,X
520 .GetHexNext
530 JSR GetHexDigit:BCC SkipSpace
540 PHA:TYA:PHA:LDY #4
550 .GetHexMultiply
560 ASL 0,X:ROL 1,X:ROL 2,X:ROL 3,X
570 DEY:BNE GetHexMultiply
580 PLA:TAY:PLA:ORA 0,X:STA 0,X
590 INY:BNE GetHexNext
600 :
610 .GetHexDigit
620 LDA (lptr),Y
630 CMP #ASC"0":BCC HexDigitBad
640 CMP #ASC"9"+1:BCC HexDigitOk
650 CMP #ASC"A":BCC HexDigitBad
660 AND #&DF
670 CMP #ASC"F"+1:BCS HexDigitBad
680 SBC #7
690 .HexDigitOk
700 SBC #ASC"0"-1:RTS
710 .HexDigitBad
720 CLC:RTS
730 :
740 .SkipSpace1
750 INY
760 .SkipSpace
770 LDA (lptr),Y:CMP #ASC" ":BEQ SkipSpace1
780 CMP #13:RTS
790 :
800 \.table
810 \EQUS "TEXT" :\EQUW &FFFF
820 \EQUS "COMMAND" :\EQUW &FEFF
830 \EQUS "DATA" :\EQUW &FDFF
840 \EQUS "UTILITY" :\EQUW &FCFF
850 \EQUS "BASIC" :\EQUW &FBFF
860 \EQUS "MODULE" :\EQUW &FAFF
870 \EQUS "BBC FONT":\EQUW &F7FF
880 \EQUS "TELETEXT":\EQUW &7CFF
890 \EQUS "BBC ROM" :\EQUW &BCFB
900 \EQUB 0
910 EQUS ver$
920 :
930 ]:NEXT
940 IF P%>&B00:PRINT"Code overrun":END
950 PRINT"*SAVE SetType "+STR$~mcode%+" "+STR$~O%+" "+STR$~(start%OR&FFFF0000)+" "+STR$~(load%OR&FFFF0000)