how does it work based on the palette offset at 16 colors

All aspects of programming on the Commander X16.
Post Reply
funkheld
Posts: 322
Joined: Mon Feb 26, 2024 11:11 am

how does it work based on the palette offset at 16 colors

Post by funkheld »

Hi good afternoon.

what is the offset?
how/where does the palette offset have to be written in basic for sprites 16 color?
I don't really understand that.

where are the palettes for 16 color written?
I also have to use my palette from the system.

--------------------------
BVLOAD "SPRITE.BIN",8,1,$3000 >>>>> 64x64
BVLOAD "FUNKPAL.PAL",8,1,$fa00) ; 256 color for the system
BVLOAD "SPR.PAL",8,1,($fa00.....) >>>>>>>>> 16 color for the sprite ???

SPRMEM 1,1,$3000,0
SPRITE 1,3,0,0,3,3 >>>>> ?
MOVSPR 1,320,200
------------------------

Thanks.
greeting

------------------------
palette offset is the palette offset for the sprite. Range is 0-15 inclusive. This value is multiplied by 16 to determine the starting palette index.
-----------------------
User avatar
ahenry3068
Posts: 1146
Joined: Tue Apr 04, 2023 9:57 pm

Re: how does it work based on the palette offset at 16 colors

Post by ahenry3068 »

There is only 1 palette. The Palette for a 16 color sprite is an Offset into the 256 color hardware palette.
funkheld
Posts: 322
Joined: Mon Feb 26, 2024 11:11 am

Re: how does it work based on the palette offset at 16 colors

Post by funkheld »

hello, thanks for info.

greeting.
funkheld
Posts: 322
Joined: Mon Feb 26, 2024 11:11 am

Re: how does it work based on the palette offset at 16 colors

Post by funkheld »

Hi good afternoon.

With the red background, the funkpal.pal from the demo program where my code was taken is not correct. So are there other system colors?

The sprites are fine in terms of color.

If I then want to have the system pal, then
Do I have to save it first?

BSAVE "SYSTEM.PAL",8,1,$FA00,$FA00 + 255 ?
why don't all colors appear?

Thanks.
greeting


this no funkpal.pal :
----------------------------------------
BVLOAD "pebispr641.bin",8,1,$3000
BVLOAD "spr641.pal",8,1,($fa00 + (16*2))

SPRMEM 1,1,$3000,0
SPRITE 1,3,1,0,3,3,0
MOVSPR 1,320,200
-----------------------------------------


this with funkpal.pal :
-----------------------------------------
BVLOAD "pebispr641.bin",8,1,$3000
BVLOAD "funkpal.pal",8,1,$fa00)
BVLOAD "spr641.pal",8,1,($fa00 + (16*2))

SPRMEM 1,1,$3000,0
SPRITE 1,3,1,0,3,3,0
MOVSPR 1,320,200
-----------------------------------------
Attachments
system-farben.jpg
system-farben.jpg (99.49 KiB) Viewed 572 times
with-funkpal.jpg
with-funkpal.jpg (42.62 KiB) Viewed 582 times
no-funkpal.jpg
no-funkpal.jpg (42.28 KiB) Viewed 582 times
User avatar
ahenry3068
Posts: 1146
Joined: Tue Apr 04, 2023 9:57 pm

Re: how does it work based on the palette offset at 16 colors

Post by ahenry3068 »

funkheld wrote: Fri Mar 22, 2024 11:39 am Hi good afternoon.

With the red background, the funkpal.pal from the demo program where my code was taken is not correct. So are there other system colors?

The sprites are fine in terms of color.

If I then want to have the system pal, then
Do I have to save it first?

BSAVE "SYSTEM.PAL",8,1,$FA00,$FA00 + 255 ?

Thanks.
greeting


this no funkpal.pal :
----------------------------------------
BVLOAD "pebispr641.bin",8,1,$3000
BVLOAD "spr641.pal",8,1,($fa00 + (16*2))

SPRMEM 1,1,$3000,0
SPRITE 1,3,1,0,3,3,0
MOVSPR 1,320,200
-----------------------------------------


this with funkpal.pal :
-----------------------------------------
BVLOAD "pebispr641.bin",8,1,$3000
BVLOAD "funkpal.pal",8,1,$fa00)
BVLOAD "spr641.pal",8,1,($fa00 + (16*2))

SPRMEM 1,1,$3000,0
SPRITE 1,3,1,0,3,3,0
MOVSPR 1,320,200
-----------------------------------------
Saving the system Palette that way won't work. BSAVE doesn't work on Video Ram. After you change the Palette you do need to restore it to use it. THERE IS ONLY 1 HARDWARE PALETTE. Whatever is loaded in the HARDWARE PALETTE is used by whatever image is on the screen. For 8 bit images the entire palette is used. For 16 color (4 bit) sprites an OFFSET into the HARDWARE PALETTE tells it where the 16 Colors START. I'm attaching a DPAL.PAL here. It is a binary image of the default VERA palette.

HERE'S THE DEFAULT PALETTE IMAGE (zipped)
DPAL.PAL.zip
(609 Bytes) Downloaded 57 times
funkheld
Posts: 322
Joined: Mon Feb 26, 2024 11:11 am

Re: how does it work based on the palette offset at 16 colors

Post by funkheld »

hello, thanks for the pal.
is an interesting story.

I have to understand the whole x16 system first.
takes longer for me. :roll:

Thanks.
greeting
hstubbs3
Posts: 72
Joined: Thu Oct 26, 2023 12:14 pm

Re: how does it work based on the palette offset at 16 colors

Post by hstubbs3 »

Guess I'll put this here, seems should be topical here.

https://github.com/hstubbs3/CommanderX1 ... png_to_bin

I had just made changes to the Python code so it takes in the RGBA PNG file and then attempts to find best colors in _each_ of the 16 palette offsets ...

will have to update the GIT with some documentation later.. but for now .. as example -

first on the host - prepped my BIN file for the graphics data ( is 32 64x64 sprites at 16 colors = 64KB !)

Code: Select all

python3 png_to_bin_perceptual_4bit.py spider_128x64.png spider_128x64_4bit_perc.inc
python3 inc_to_bin.py spider_128x64_4bit_perc.inc SPIDERS.BIN
then wrote a bas file so could do exec

so in the x16 -
BVLOAD "SPIDERS.BIN",8,0,$0000
BLOAD "SPIDERS.BAS",8,1,$8000
EXEC $8000

have no clue what the errors are but hey mostly works..

Image
Post Reply