flat assembler
Message board for the users of flat assembler.

Index > Main > indexed image.

Thread Post new topic Reply to topic

Joined: 20 Feb 2006
Posts: 4240
Location: 2018

i have a problem wiht indexed palette.

i create images with gimp, it will be defined as a Cheader.

then, i modify a little this header, and use it for asm.

in the header, we have:

but, i have my palette defined.
then, i want this bitmap to be transposed in my palette.

it gives me this problem:

define a color in the palette.
if this color is still in palette then, transpose all reference to this new color code.
if color is not in palette then
if no free color entry then, seek for the nearest palette value.
else, add this color directlly in a free palette location and relocate every reference to this palette.

the palette is very interresting.
in hardware it is 3*256 6bits bytes
in Cheaders, it is 3*256 bytes.
in my fashion, it is 4*256 bytes.

then, the fourth byte can be used for axample as a counter or a alpha channel.
for the moment, it is used as alignment.

each frame refresh( vrtical retrace) i update screen and palette.

palette is then buffered too. and then, modifiable in "real time" without any I/O operation on VGA registers.

a note about palette update and vertical retrace.

if you change the palette in an other place in code (for example, 10 ms after vertical retrace, it will be horrible.

then, solution for palette update is:
        mov dx,3dah
        in al,dx
        test al,08h
        je @b
        mov bl,[esi+.c]
        mov bh,bl
        shl ebx,16
        mov bl,[esi+.c]
        mov bh,bl
        xor edi,edi
        mov eax,[fs:edi*4];+320*8]
        mov [fs:edi*4],ebx
        mov [es:edi*4],eax
        inc edi
        cmp edi,320*50;-320*4
        jl @b
        mov edi,[esi+.pal]
        mov dx,3c8h
        mov al,0
        out dx,al
        mov dx,3c9h
        mov cl,0
        mov al,[edi+.r]
        shr al,2
        out dx,al
        mov al,[edi+.g]
        shr al,2
        out dx,al
        mov al,[edi+.b]
        shr al,2
        out dx,al
        add edi,4
        dec cl
        jne @b
        push dword 0 dword[int8.ticks]
        pop dword[int8.inc] dword[int8.ticks]


put palette code before frame buffer code have various effect on your screen.
it is not the same for CRT and LCD.

and then, the bitmap to display:

Filename: kaya olga.txt
Filesize: 62.77 KB
Downloaded: 114 Time(s)

Post 18 Jan 2010, 13:06
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum

Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.