10
20
30
40
50
60
70 :
80 INPUT"(L)oad, (E)xec, (A)ddr? "A$:A$=LEFT$(A$,1)
90 IFA$="L":A$="Load":A%=2 ELSE IFA$="E":A$="Exec":A%=3 ELSE A$="Addr":A%=3
100 OSARGS=&FFDA:OSFILE=&FFDD
110 lptr=&A8:addr=&AA:tempY=&AE
120 DIM mcode%:load%=&FFFF0900
130 FOR P=0 TO 1
140 O%=mcode%:P%=load%
150 [OPT P*3+4
160 .ctrl
170 EQUW 0
180 .syntax
190 BRK:EQUB 220
200 EQUS "Syntax: Set"+A$+" <fsp> <addr>"+LEFT$(" <addr>",A$="Addr"):BRK
210 .start%
220 LDA #1:LDY #0:LDX #lptr
230 JSR OSARGS:STY addr:STY addr+1
240 LDA (lptr),Y:CMP #13:BEQ syntax
250 LDA lptr:STA ctrl:LDA lptr+1:STA ctrl+1
260 .skip_name
270 LDA (lptr),Y:INY:CMP #33:BCS skip_name
280 CMP #13:BEQ syntax
290 DEY:JSR space2:BEQ syntax
300 LDX #addr:JSR get_hex_addr
310 JSR space2
320 ]
330 IF A$="Addr":[OPT P*3:BEQ syntax:LDA addr+3:PHA:LDA addr+2:PHA:LDA addr+1:PHA:LDA addr+0:PHA:JSR get_hex_addr:JSR space2:]
340 [OPT P*3
350 BNE syntax
360 .got_addr
370 LDA addr+0:STA ctrl+A%*4-6
380 LDA addr+1:STA ctrl+A%*4-5
390 LDA addr+2:STA ctrl+A%*4-4
400 LDA addr+3:STA ctrl+A%*4-3
410 .do_file
420 LDX #ctrl AND 255:LDY #ctrl DIV 256:LDA #A%
430 ]
440 IF A$="Addr":[OPT P*3:JSR OSFILE:PLA:STA ctrl+2:PLA:STA ctrl+3:PLA:STA ctrl+4:PLA:STA ctrl+5:LDX #ctrl AND 255:LDY #ctrl DIV 256:LDA #2:]
450 [OPT P*3
460 JMP OSFILE
470 :
480 .get_hex_addr
490 LDA #0
500 STA 0,X:STA 1,X:STA 2,X:STA 3,X
510 .nextchar
520 LDA (lptr),Y:JSR asc_to_bin
530 BCS gh_exit
540 ASL A:ASL A:ASL A:ASL A
550 STY tempY:LDY #4
560 .gh_again
570 ASL A:ROL 0,X:ROL 1,X:ROL 2,X:ROL 3,X
580 DEY:BNE gh_again
590 LDY tempY
600 INY:BNE nextchar
610 .gh_exit
620 RTS
630 .asc_to_bin
640 CMP #48:BCC illegal
650 CMP #58:BCC zero_nine
660 AND #&DF:CMP #71:BCS illegal
670 SBC #6
680 .zero_nine
690 AND #&0F:CLC:RTS
700 .skpspc INY
710 .space2 LDA (lptr),Y:CMP #32
720 BEQ skpspc:CMP #13
730 .illegal
740 SEC:RTS
750 EQUS "v1.01"
760 ]:NEXT
770 PRINT"*SAVE Set"+A$+" ";~mcode%;" ";~O%;" ";~start%OR&FFFF0000;" ";~load%