Posted By
JamesD on 2017-11-28 20:36:48
| Re: Patch for BASIC to make it faster?
I was running some benchmarks and the horribly slow times indicated it was doing just what it's doing. Way too much to read a byte.
FWIW, the CHARGET and CHARGOT can be patched without doing anything to the ROM. Just replace the code with the patched version that removes the interrupt disable, switch in RAM, and then switches in ROM, and enables interrupts after reading 1 byte. But you can't do it from BASIC. You also need to patch the pointers to the top of memory and things like that, but it's not difficult code.
This is the section of ROM. The disassembly is pretty incomplete so I don't know if you can patch get under ROM or not. I'm not sure what uses it. The functions are at the following addresses in RAM. CHRGET equ $0473 ; get byte from basic ( incs LastBasicLineNo first ) CHRGOT equ $0479 ; gets current byte from basic (doesn't inc LastBasicLineNo )
---------------------------------------------------------------------------------------------------------- ; ; CHRGET/CHRGOT - This chunk of code is copied to RAM ; and run from there. It is used to get data UNDER the ; system ROM's for basic. ; ; CHRGET ($0473) L8123 INC LastBasicLineNo ; $3b (goes to $0473 ) CHRGET BNE L8129 INC LastBasicLineNo+1 ; $3c ; ; CHRGOT ($0479) ; L8129 SEI <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< STA RAM_ON <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< LDY #$00 LDA (LastBasicLineNo),y ; $3b STA ROM_ON <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< CLI <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< CMP #$3A ; ":" (colon) BCS L8143 ; if colon, exit CMP #$20 ; " " (space) BEQ L8123 ; if space, get NEXT byte from basic SEC SBC #$30 SEC SBC #$D0 L8143 RTS
L0494 STA $049C ; set location to get byte from.
; ; This section gets copied to $04A5 ; GetUnderROM SEI ; IRQ's off <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< STA RAM_ON ; DISABLE ROM <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< LDA ($00),y ; get byte ($00 is at location $49C) STA ROM_ON ; enable ROM <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< CLI ; IRQ's on again.. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< RTS ; and return... db $00,$00,$00 -------------------------------------------------------------------------------------------------------------
Rough code for the patch. Unfinished.
SEI ;Set up new pointers here ;copy new CHARGOT routine over old one LDX #21 ; Copy down NEWCHRGOT L804C LDA NEWCHARGOT,x ; routines. These are used for STA $0479,x ; fetching data under the system DEX ; ROM BNE L804C CLI ;return to BASIC here. ORG $0479 ;assemble for target address, then db the resulting bytes as part of above program ; ; CHRGOT ($0479) ; NEWCHARGOT LDY #$00 LDA (LastBasicLineNo),y ; $3b CMP #$3A ; ":" (colon) BCS EXIT ; if colon, exit CMP #$20 ; " " (space) BEQ $0473 ; if space, get NEXT byte from basic SEC SBC #$30 SEC SBC #$D0 EXIT RTS
|