10
20
30
40
50 :
60 OSARGS=&FFDA:OSFILE=&FFDD:OSBYTE=&FFF4
70 lptr=&A8:tmp=&A8
80 :
90 DIM mcode% &200:load%=&FFFF0900
100 FOR P=0 TO 1
110 P%=load%:O%=mcode%
120 [OPT P*3+4
130 .errBadFile
140 BRK:EQUB 225:EQUS "Bad CMOS file":BRK
150 .go%
160 LDA #1:LDY #0:LDX #lptr:JSR OSARGS
170 LDA lptr+0:STA info+0:STA load+0
180 LDA lptr+1:STA info+1:STA load+1
190 LDX #info AND 255:LDY #info DIV 256
200 LDA #5:JSR OSFILE :\ Read file info
210 LDA info+11:ORA info+12
220 ORA info+13:BNE errBadFile :\ Length>255
230 LDA info+10:BMI errBadFile :\ Length>127
240 CMP #50:BCC errBadFile:PHA :\ Length<50
250 LDX #load AND 255:LDY #load DIV 256
260 LDA #255:JSR OSFILE :\ Load file
270 PLA:TAX:DEX :\ Get file length
280 .lp
290 TXA:PHA:LDA #161:JSR OSBYTE:STY tmp :\ Read current byte
300 PLA:PHA:TAX:LDA data,X :\ Get byte from data block
310 CMP tmp:BEQ skip :\ Don't write if already same
320 TAY:LDA #162:JSR OSBYTE :\ Write to CMOS
330 .skip
340 PLA:TAX:DEX:BPL lp
350 RTS
360 :
370 .load
380 EQUW 0:EQUW data:EQUW &FFFF
390 EQUD 0:EQUD 0:EQUD 0
400 .info
410 EQUW 0
420 .data
430 EQUS "LoadCMOS 1.00":BRK
440 ]NEXT
450 A$="SAVE LoadCMOS "+STR$~mcode%+" "+STR$~O%+" "+STR$~(go%OR&FFFF0000)+" "+STR$~load%
460 PRINTA$;:OSCLIA$:PRINT