Quick Question (I Think) Background color in ASM

All aspects of programming on the Commander X16.
Post Reply
User avatar
schristis
Posts: 68
Joined: Sat Apr 08, 2023 6:28 am

Quick Question (I Think) Background color in ASM

Post by schristis »

Hi Just a quick Question...

In Assembly I can set the character color like...---> lda #153 then jsr $FFD2
so... in text mode like screen 0 how do I set the background color ?
As jsr $FF29 does nothing for me in screen 0 ...

just so I can change the background color lol... ? even though it might be a simple answer for someone.... :|

(I'm trying not to use basic~)
User avatar
ahenry3068
Posts: 1144
Joined: Tue Apr 04, 2023 9:57 pm

Re: Quick Question (I Think) Background color in ASM

Post by ahenry3068 »

schristis wrote: Sat Nov 30, 2024 11:20 am Hi Just a quick Question...

In Assembly I can set the character color like...---> lda #153 then jsr $FFD2
so... in text mode like screen 0 how do I set the background color ?
As jsr $FF29 does nothing for me in screen 0 ...

just so I can change the background color lol... ? even though it might be a simple answer for someone.... :|

(I'm trying not to use basic~)
On the C64 & C128 this was not possible as there was not a "per character" background color. On the x16 a new control code now exists CHR$(1). This Swaps Foreground for Background. So to set background. LDA (desBGcolorcode), jsr $FFD2, LDA #1 jsr $FFD2, LDA, DesiredForeGroundCode jsr $FFD2

A little extra work but you get there.
User avatar
schristis
Posts: 68
Joined: Sat Apr 08, 2023 6:28 am

Re: Quick Question (I Think) Background color in ASM

Post by schristis »

Ummm.. The entire background color sorry, not just the background of the text....
on the C64 it was actually a memory location to change the border and background... With the X16 we have the VERA... soooo...What register in the Vera (If any) to change the entire background ?
or is the trick to fill the screen with chr($1) ? in reverse ???..

this was easy on the C64... if that was a location?
c64.JPG
c64.JPG (28.98 KiB) Viewed 280 times
What would be the assembly equivalent of ' COLOR 1,0 '
User avatar
ahenry3068
Posts: 1144
Joined: Tue Apr 04, 2023 9:57 pm

Re: Quick Question (I Think) Background color in ASM

Post by ahenry3068 »

schristis wrote: Sat Nov 30, 2024 1:17 pm Ummm.. The entire background color sorry, not just the background of the text....
on the C64 it was actually a memory location to change the border and background... With the X16 we have the VERA... soooo...What register in the Vera (If any) to change the entire background ?
or is the trick to fill the screen with chr($1) ? in reverse ???..

this was easy on the C64... if that was a location?
c64.JPG

What would be the assembly equivalent of ' COLOR 1,0 '
Exactly what I said. If you do a CLS the current background color is used. But background color in the video memory is on a "per character basis). There is a COLOR.BYTE that is used for the printed attribute but there currently isn't a documented API for it other than the CHROUT color codes. To Clear do what you want


lda colorcodeforblack
jsr CHROUT
lda #1
jsr CHROUT
lda colorcodeforWhite
jsr CHROUT
; to clrscrn
lda HOMECODE
jsr CHROUT
User avatar
schristis
Posts: 68
Joined: Sat Apr 08, 2023 6:28 am

Re: Quick Question (I Think) Background color in ASM

Post by schristis »

You were right !

; This will change the color of the BACKGROUND

lda #$1 ;SWAP COLORS
jsr $FFD2
lda #147 ;CLEAR SCREEN
jsr $FFD2
rts


Just tried this code and worked ... really simple...
Thankyou again and sorry to be a bother~

Best regards
Shaun
User avatar
ahenry3068
Posts: 1144
Joined: Tue Apr 04, 2023 9:57 pm

Re: Quick Question (I Think) Background color in ASM

Post by ahenry3068 »

schristis wrote: Sat Nov 30, 2024 1:42 pm ; This will change the color of the BACKGROUND

lda #$1 ;SWAP COLORS
jsr $FFD2
lda #147 ;CLEAR SCREEN
jsr $FFD2
rts


Just tried this code and worked ... really simple...
Thankyou again and sorry to be a bother~

Best regards
Shaun

No problem. I probably confused the issue by bring VRAM memory layout into the picture. There actually is a seperate color code in VRAM for each character. But Clear screen does fill the entire VRAM with the current background & foreground color code.
Post Reply