VGA: How to set 640x480 ?

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
sevobal
Member
Member
Posts: 63
Joined: Sun Oct 22, 2006 7:11 am

VGA: How to set 640x480 ?

Post by sevobal »

Hi,
My OS (PM) is able to configurate the VGA card to mode 320x200, but I've heard VGA is compatible to mode 640x480. So which command should I send to which port to enter this mode?

Thx!
User avatar
~
Member
Member
Posts: 1228
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

Post by ~ »

You just need to send the correct register values, just like you did for entering 300x200, as far as I know.

I don't know if I have them handy; or else, try to find their correct values on the Internet, or put it in 640x480x16color mode using BIOS and read each register value, save them in a text/binary file and then integrate them in your OS.
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post by mystran »

Please remember that VGA 640x480 is 16-color only.
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

User avatar
Kevin McGuire
Member
Member
Posts: 843
Joined: Tue Nov 09, 2004 12:00 am
Location: United States
Contact:

640x480

Post by Kevin McGuire »

Code: Select all

#define CLK_25 0x00
#define CLK_28 0x04
	{
		.info = {
			.infoType = PICTURE_GFX4BPP6BPC,
			.vMemSize = (640*480/2),
			.infoWidth = 640,
			.infoHeight = 480,
			.infoRefresh = 0
		},
		.extReg = {0x03|0xC0|CLK_25},
		.crtReg = {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,0x0,0x80,0xe,0xf,0x0,0x0,0x0,0x20,0x9c,0x8e,0x8f,0x28,0x7f,0x96,0xb9,0xff,0xff},
		.seqReg = {0xff, 0x0, 0xff, 0x0, 0x0},
		.atrReg = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0x1,0x0,0xff,0x00},
		.gfxReg = {0xff,0,0,0,0,0,0x01,0x00,0xff}
	},
This should be 640x480x16. You will be using four planes with one bit per plane for each pixel sequentially. It could be less since I do not remember actually testing it throughly. If it is not let me know so I can change mine. =)
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:

Post by Combuster »

tested code here:
http://dimensionalrift.homelinux.net/co ... vga_io.bas
(compiles with freebasic)
"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 ]
User avatar
Kevin McGuire
Member
Member
Posts: 843
Joined: Tue Nov 09, 2004 12:00 am
Location: United States
Contact:

Post by Kevin McGuire »

The function for writing to the attribute registers look a little weird.

Code: Select all

' Function: Write3C0
' Writes an index/value pair to VGA register 3C0 (Attribute Control Register)
'
' in:
'     index - the AC register to access
'     value - the value to write
'
Sub Write3C0 Cdecl Alias "Write3C0" (index as byte, value as Unsigned byte)
    inportb &H3DA
	outportb &H3C0, index
	outportb &H3C0, value
End Sub
I could not find a point in the code to enable the palette registers which point into the digital to analog controller. Is this okay, or does it work on real hardware anyway?

http://www.osdever.net/FreeVGA/vga/attrreg.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:

Post by Combuster »

The code has a safe-guard: it will always reset the flip-flop (the byte inport) before writing to the attribute controller (the two byte outports).

Both the palette and RAMDAC seem to be initialized at boot so there is no direct need to change their contents, although it is a good thing if you want to be sure of the exact colors.
"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 ]
Post Reply