Page 1 of 1

User Defined Palletes

Posted: Sun Jul 07, 2024 3:51 am
by Sarasaworks
I am playing with tiles and sprites at the moment, but where I am struggling is defining a set of palettes. I saw a small section on palettes in the VERA docs. It shows how the colors are defined, but not how to compile those colors into usable/swappable 16 color palettes that can be sent to VRAM. Is this even possible or am confined to a collection of defaults?

Re: User Defined Palletes

Posted: Sun Jul 07, 2024 7:26 am
by ahenry3068
Sarasaworks wrote: Sun Jul 07, 2024 3:51 am I am playing with tiles and sprites at the moment, but where I am struggling is defining a set of palettes. I saw a small section on palettes in the VERA docs. It shows how the colors are defined, but not how to compile those colors into usable/swappable 16 color palettes that can be sent to VRAM. Is this even possible or am confined to a collection of defaults?
This probably isn't everything you want. But it should give you some ideas
viewtopic.php?t=6793

Re: User Defined Palletes

Posted: Sun Jul 07, 2024 7:39 am
by Sarasaworks
I just know that defining palettes on the NES is as simple as:
P0: 
.byte $00, $03, $42, $D3

P1: 
.byte $00, $01, $02, $03
And then sending them to the proper PPU address... Was looking for something similar.

I'll look at the BASIC file in a bit. Don't have a reader on my phone.

Re: User Defined Palletes

Posted: Tue Jul 09, 2024 6:50 am
by Sarasaworks
So, after a few videos and deciphering how to manipulate VERA and VRAM, this was my conclusion:
    stz $9f25   ; Select VRAM Data Bus Zero
    lda #$00    ; Low Byte, 17bit VRAM address ($1FA00)
    sta $9f20
    lda #$fa    ; Mid Byte, 17bit VRAM address
    sta $9f21   
    lda #$11    ; High Bit, 17bit VRAM address + 1 byte stride
    sta $9f22
    ldx #$00
loop:
    cpx #$20
    beq exit
    lda pal0,x 
    sta $9f23   ; Send palette Data to VRAM Data Bus Zero
    inx
    jmp loop

exit:
    rts

pal0: 
    .byte $00,$00   ; Transparent
    .byte $ff,$0f   ; White
    .byte $fd,$0a   ; Flesh Tones
    .byte $fc,$08
    .byte $ea,$08
    .byte $d8,$06
    .byte $41,$00   ; Brown
    .byte $6b,$0f   ; Blues
    .byte $53,$0f
    .byte $13,$0f
    .byte $dc,$05   ; Yellows
    .byte $a8,$04
    .byte $dd,$0d   ; Grayscale
    .byte $bb,$0b
    .byte $66,$06
    .byte $00,$00   ; Black

Re: User Defined Palletes

Posted: Tue Jul 09, 2024 6:19 pm
by Ed Minchau
That two byte stride should be one byte. You need to push two bytes (ggggbbbb 0000rrrr) for a single palette entry.

Re: User Defined Palletes

Posted: Tue Jul 09, 2024 8:39 pm
by Sarasaworks
Ed Minchau wrote: Tue Jul 09, 2024 6:19 pm That two byte stride should be one byte. You need to push two bytes (ggggbbbb 0000rrrr) for a single palette entry.
Good call! Thanks! I edited my code accordingly :D :)