Below is my self modifying routine for memory copy on Commodore 64.
I wrote char codes
and number of repeats
in a table and filled the screen_ram the with this routine.
I'm looking for suggestions for optimization. My priority is memory in this case.
memCopy:
sourceAddress=*+1 ; mark self modifying addrres
fetchNewData:
lda data_table ; read char value into A
ldx data_table+1 ; read repeat value into x
inc sourceAddress
inc sourceAddress
cpx #00 ; if X=0
beq end ; finish copying
destination=*+1
- sta SCREEN_RAM
inc destination
dex
bne -
jmp fetchNewData
end:
rts
; data format: <char>,<number of repeats>,[<char>,<number of repeats>,...],00,00
data_table:
!by 01,03,02,02,......,00,00
SCREEN_RAM
and only in case it was 256-byte aligned at the start. – Thundercloud