User Defined Palletes

Get help from the community & developers with the X16 hardware if you can't find the solution elsewhere
Post Reply
User avatar
Sarasaworks
Posts: 16
Joined: Fri Jul 05, 2024 9:47 am

User Defined Palletes

Post 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?
"I mean... You'd be pretty disappointed too if you came all this way and the princess was in another castle... All those turtles and whatnot!"
--Scout Sarasa
User avatar
ahenry3068
Posts: 1134
Joined: Tue Apr 04, 2023 9:57 pm

Re: User Defined Palletes

Post 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
Attachments
PALEDITORB.BAS
(27.57 KiB) Downloaded 66 times
PALEDITOR.PRG
(16.15 KiB) Downloaded 64 times
DPAL.BIN
(512 Bytes) Downloaded 70 times
User avatar
Sarasaworks
Posts: 16
Joined: Fri Jul 05, 2024 9:47 am

Re: User Defined Palletes

Post 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.
Last edited by Sarasaworks on Sun Jul 07, 2024 7:46 am, edited 1 time in total.
"I mean... You'd be pretty disappointed too if you came all this way and the princess was in another castle... All those turtles and whatnot!"
--Scout Sarasa
User avatar
Sarasaworks
Posts: 16
Joined: Fri Jul 05, 2024 9:47 am

File Download Re: User Defined Palletes

Post 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
Last edited by Sarasaworks on Tue Jul 09, 2024 8:40 pm, edited 4 times in total.
"I mean... You'd be pretty disappointed too if you came all this way and the princess was in another castle... All those turtles and whatnot!"
--Scout Sarasa
Ed Minchau
Posts: 503
Joined: Sat Jul 11, 2020 3:30 pm

Re: User Defined Palletes

Post by Ed Minchau »

That two byte stride should be one byte. You need to push two bytes (ggggbbbb 0000rrrr) for a single palette entry.
User avatar
Sarasaworks
Posts: 16
Joined: Fri Jul 05, 2024 9:47 am

Re: User Defined Palletes

Post 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 :)
Last edited by Sarasaworks on Tue Jul 09, 2024 8:47 pm, edited 1 time in total.
"I mean... You'd be pretty disappointed too if you came all this way and the princess was in another castle... All those turtles and whatnot!"
--Scout Sarasa
Post Reply