Save palette screen 5 apart from image

By Mafcase

Champion (258)

Mafcase さんの画像

25-09-2021, 01:58

After loading a .sc5 file in memory i can restore the palette with color=restore.
I would like to know if there is a way to save this memory part (colors) apart from the picture.

Is there anyone who can tell me the memory adress I need to save this?

ログイン/登録して投稿

By RvS

Expert (95)

RvS さんの画像

25-09-2021, 08:14

Hi,

The actual pallette is stored in registers.
More information can be found here:
https://www.msx.org/wiki/VDP_Color_Palette_Registers

By Mafcase

Champion (258)

Mafcase さんの画像

25-09-2021, 12:04

Thank you for your reply.

I forgot to say I meant i'm using MSX basic...
Maybe there is a simple way to load an .pl5 from Graphsaurus and use it in basic?

By Sandy Brand

Champion (309)

Sandy Brand さんの画像

25-09-2021, 12:28

Yes, that should definitely be possible Smile

The way MSX-Basic stores palettes in binary files is nothing more than a simple convention whereby the palette data is stored in a VRAM area that is not used for anything else. This is the area starting at &H7680 and ending at &H769F (= 16 * 2 = 32 bytes).
The COLOR=RESTORE command does nothing more than read the palette data from that VRAM area and writing it into the appropriate VDP registers so that the palette is actually used to draw the screen.

So, you can easily extract the palette from the image with a little BASIC program. If you first load up the entire image with a BLOAD "",S command, you can then save the palette part with this: BSAVE "abcdef.pal",&H7680,&H769F,S

From then on you can set that palette at any time you want with just BLOAD "abcdef.pal",S;COLOR=RESTORE

By Mafcase

Champion (258)

Mafcase さんの画像

25-09-2021, 13:15

@ Sandy Brand: Thank you very much! That's exactly what i need. Smile

- This works like a charm!