10
20
30 :
40 DIM ctrl% 31,data% 255:X%=ctrl%:Y%=X%DIV256
50 :
60 REPEAT
70 *ROMS
80 INPUT "Filename: "fn$
90 INPUT "SRAM Bank: "bank%
100 result%=FNsr_load(fn$, bank%)
110 PRINT"Result: ";result%
120 PRINT
130 UNTIL FALSE
140 :
150 :
160 :
170
180
190
200
210
220
230
240
250
260 :
270 DEFFNsr_load(fn$,bank%):=FNsr_file(TRUE)
280 :
290
300
310
320
330
340
350
360
370 :
380 DEFFNsr_save(fn$,bank%):=FNsr_file(FALSE)
390 :
400 DEFFNsr_file(LD%)
410 IF HIMEM<&FFFF:IF ?&FFF7=&6C:IF ?&FFFB<128 ELSE =144:
420 LOCAL addr%,chn%:sr_wr=sr_wr:IFsr_wr=0:PROCsr_asm
430 IFLD%:chn%=OPENIN(fn$):IFchn%=0:=214:
440 IFNOTLD%:chn%=OPENOUT(fn$):IFchn%=0:=192:
450 IFLD%:ROMTABLE?bank%=0
460 REPEAT:!&70=addr%+&8000
470 IFLD%:PROCgbpb(3,chn%,data%,256,0):A%=bank%:CALLsr_wr
480 IFNOTLD%:A%=bank%:CALLsr_rd:PROCgbpb(1,chn%,data%,256,0)
490 addr%=addr%+256:IFLD%:IFEOF#chn%:addr%=&4000
500 UNTILaddr%>&3FFF:IFLD%:PTR#chn%=6:ROMTABLE?bank%=BGET#chn%
510 CLOSE#chn%:chn%=0:=0:
520 :
530 DEFPROCsr_asm
540 ROMTABLE=&2A1:IF?&FFB2=&40:ROMTABLE=&2A0
550 DIM mc% 39:FOR P=0 TO 1:P%=mc%:[OPT P*2
560 .sr_rd:CLC:EQUB &24
570 .sr_wr:SEC:TAX:LDA &F4:PHA:PHP:JSR SelectROM:LDY #0:PLP
580 .loop:BCC read:LDA data%,Y:STA (&70),Y
590 .read:LDA (&70),Y:STA data%,Y:INY:BNE loop:PLA:TAX
600 .SelectROM:STX &F6:STX &F4:JMP &FFB9
610 ]:NEXT:ENDPROC
620 :
630 DEFPROCgbpb(A%,chn%,addr%,num%,ptr%):?X%=chn%:X%!1=addr%:X%!5=num%:X%!9=ptr%:CALL&FFD1:ENDPROC
640 :