Page 1 of 1

VGA: How to set 640x480 ?

Posted: Thu Mar 29, 2007 8:40 am
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!

Posted: Thu Mar 29, 2007 8:43 am
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.

Posted: Thu Mar 29, 2007 9:06 am
by mystran
Please remember that VGA 640x480 is 16-color only.

Posted: Thu Mar 29, 2007 9:56 am
by Dex

640x480

Posted: Thu Mar 29, 2007 12:18 pm
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. =)

Posted: Thu Mar 29, 2007 4:14 pm
by Combuster
tested code here:
http://dimensionalrift.homelinux.net/co ... vga_io.bas
(compiles with freebasic)

Posted: Thu Mar 29, 2007 5:10 pm
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

Posted: Fri Mar 30, 2007 4:36 pm
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.