Page 1 of 1

640x480 16 color doesn't work

Posted: Sun Sep 12, 2010 2:11 pm
by Karlosoft
I set the mode

Code: Select all

mov al, 12h
xor ah,ah
int 10h
But when I write data from 0xa0000, no colors are shown... this [1] is the result of [2].

Re: 640x480 16 color doesn't work

Posted: Sun Sep 12, 2010 2:39 pm
by Gigasoft
This explains how VGA programming works.

http://www.osdever.net/FreeVGA/vga/vga.htm

Re: 640x480 16 color doesn't work

Posted: Sun Sep 12, 2010 2:57 pm
by Combuster
VGA Hardware also has the necessary info

Re: 640x480 16 color doesn't work

Posted: Sun Sep 12, 2010 4:23 pm
by azblue
One thing to be aware of is one byte does not represent 2 pixels; it represents 8. Every time you write to the video memory in 16 color mode each individual bit corresponds to one pixel, and it is written to one or more color planes. (By default you'll be writing to all 4 planes).

This function will set which plane you read from and which plane(s) you write to:



setcolorplane:
;ah = plane to read from (0-3)
;al = planes to write to (0-15)

push dx
push ax

mov dx, 3c4h
mov al, 2
out dx, al
mov dx, 3c5h
pop ax
push ax
out dx, al ;set plane to write to
mov dx, 3ceh
mov al, 4; read map select register
out dx, al
mov dx, 3cfh
;pop ax
;push ax
mov al, ah ;get plane to read
out dx, al
pop ax
pop dx
ret

Re: 640x480 16 color doesn't work

Posted: Mon Sep 13, 2010 2:24 am
by Candy
Plus, again, bitmaps are upside-down. Read it in line-by-line and flip it. Or, as I've done, seek to the end minus one line, read a line, seek back 2 lines, read a line etc.

Re: 640x480 16 color doesn't work

Posted: Mon Sep 13, 2010 6:15 am
by Karlosoft
@ Candy I knew it from an other post ;)
@ Everyone here: thank you ;) An other problem solved ^_^