640x480 16 color doesn't work

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Karlosoft
Member
Member
Posts: 277
Joined: Thu Feb 14, 2008 10:46 am
Location: Italy
Contact:

640x480 16 color doesn't work

Post 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].
Attachments
credits.PNG
credits.PNG (11.47 KiB) Viewed 1518 times
bootloader2.PNG
bootloader2.PNG (11.09 KiB) Viewed 1518 times
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: 640x480 16 color doesn't work

Post by Gigasoft »

This explains how VGA programming works.

http://www.osdever.net/FreeVGA/vga/vga.htm
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: 640x480 16 color doesn't work

Post by Combuster »

VGA Hardware also has the necessary info
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
azblue
Member
Member
Posts: 147
Joined: Sat Feb 27, 2010 8:55 pm

Re: 640x480 16 color doesn't work

Post 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
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re: 640x480 16 color doesn't work

Post 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.
User avatar
Karlosoft
Member
Member
Posts: 277
Joined: Thu Feb 14, 2008 10:46 am
Location: Italy
Contact:

Re: 640x480 16 color doesn't work

Post by Karlosoft »

@ Candy I knew it from an other post ;)
@ Everyone here: thank you ;) An other problem solved ^_^
Post Reply