I have a code like below, and it works fine. It clears the screen, puts some color in color memory of first 12 characters on screen, and prints a text on the screen.
jsr $e544
ldx #$00
lda #3
loopclr: sta $d800,x
inx
cpx #$0c
bne loopclr
ldx #$00
lda #0
loop: lda message,x
sta $0400,x
inx
cpx #$0c
bne loop
rts
message: .byte "Hello "
.byte "World!"
What I wonder is, if there's an easier way to change the text color in C64 Assembly, like POKE 646,color
in BASIC?
Edit: I thought I need to be more clear, I can use
lda #color
sta 646
But it doesn't affect the text put on screen by assembly code in 1024+.
Is there an address that affects all characters put on screen?
Edit: I think I know the answer, no.
Now there's a question I never thought I'd be asked! sta $0286 (646 decimal) sets the background color to be used when using the system print routine ($FFD2) which I recommend over direct access to the video ram since it takes into account the cursor position. So:
lda #$00 ; Black letters
sta $0286 ; Set color
ldx #$00
msgloop:
lda message,x
beq msgdone ; Zero byte sets z flag - end of string - shorter than checking x value
jsr $ffd2 ; print a to current device at current position (default: screen)
inx
bne msgloop ; pretty much always unless you have a string > 255
msgdone:
rts
message: .byte "Hello "
.byte "World!"
.byte 0
Well, there goes my credibility as a modern assembler guy! ;-)