10
20
30
40 :
50 fname$="NVRAM"
60 DIM mcode% &200
70 BYTEV=&20A
80 load%=&FFFF0AB4
90 NVMBASE=&900 :
100 NVMSIZE=128 :
110 NVMRAM =14 :
120 :
130 FOR P=0 TO 1
140 P%=load%:O%=mcode%
150 [OPT P*3+4
160 .go%
170 PHP:SEI
180 LDA BYTEV+0:LDX oldbyte+1
190 STX BYTEV+0:STA oldbyte+1
200 LDA BYTEV+1:LDX oldbyte+2
210 STX BYTEV+1:STA oldbyte+2
220 PLP:RTS
230 :
240 .newbyte
250 CMP #161:BEQ nvm :\ A=161, read
260 CMP #162:BEQ nvm :\ A=162, write
270 .oldbyte
280 JMP newbyte
290 .nvm
300 CPX #255:BEQ nvmsz
310 PHA:TXA:ADC #NVMRAM:CPX #NVMSIZE-NVMRAM
320 CLV:TAX:PLA:BCS nvmov
330 PHA:ROL A:BCS nvmrd
340 .nvmwr:TYA:STA NVMBASE,X
350 .nvmrd:LDY NVMBASE,X:CLC:PLA:RTS
360 .nvmsz:LDY #NVMSIZE-NVMRAM-1:CLC
370 .nvmov:RTS
380 ]NEXT
390 PRINT"*SAVE ";fname$;" ";~mcode%;" ";~O%;" ";~go%OR&FFFF0000;" ";~load%