46 lines
1.3 KiB
Text
46 lines
1.3 KiB
Text
define ArrayPointerLo $00 ;define some helpful labels.
|
|
define ArrayPointerHi $01
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
setArray: ;Easy6502 doesn't let us define arbitrary bytes so the best option is to fill the range at runtime.
|
|
lda #$10
|
|
ldx #0
|
|
loop_setArray:
|
|
sta $1200,x
|
|
clc
|
|
adc #$10
|
|
inx
|
|
cpx #$08
|
|
bcc loop_setArray
|
|
; stores this sequence of hex values starting at $1200: $10 $20 $30 $40 $50 $60 $70 $80
|
|
|
|
ClearMem: ;clear $D000-$D0FF
|
|
lda #0
|
|
ldx #0
|
|
loop_clearMem:
|
|
sta $D000,x
|
|
inx
|
|
bne loop_clearMem
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
; end of prep work, the real code begins here.
|
|
|
|
lda #$12 ;high byte of array address
|
|
sta ArrayPointerHi
|
|
lda #$00 ;low byte of array address
|
|
sta ArrayPointerLo ;these are used to look up the array rather than hard-code it in.
|
|
|
|
|
|
|
|
ldx #$0E ;the loop counter, gets decremented twice per iteration to skip the odd addresses.
|
|
ldy #7 ;the index into the source array.
|
|
|
|
;on the 6502 looping backwards is almost always faster.
|
|
|
|
loop_fill:
|
|
lda (ArrayPointerLo),y ;loads from the array's base address, plus Y
|
|
sta $D000,x ;store at $D000+X
|
|
dey ;decrement array index
|
|
dex
|
|
dex ;decrement destination index twice
|
|
bpl loop_fill ;if destination index equals #$FF, we are done.
|
|
|
|
brk ;end of program
|