VGA port-index

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
smbogan
Member
Member
Posts: 29
Joined: Tue Nov 21, 2006 3:17 pm

VGA port-index

Post by smbogan »

I'm looking at http://www.osdever.net/documents/vga_po ... ?the_id=26, and I've also looked at Ralph Brown's List, but neither give me much clarity on the subject. I'm sure it is rather simple, once you know it.

My question is this: in the link above, what's the difference between a port and a port-index. And when I'm looking to, for example, change the chain4 plane modes, how do I know the actual port to write to.

Thanks for any help,
smbogan
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Post by Pype.Clicker »

iirc, the VGA hardware has several internal registers behind a single IO ports. To use them, you need to send first the register number to the IO port, and then the data.

That's all a bit rusty in my mind, though ... so you're better to cross-check my sayings.
smbogan
Member
Member
Posts: 29
Joined: Tue Nov 21, 2006 3:17 pm

Post by smbogan »

I will give that a try. It would seem to make sense with the things that I'm reading.

Thank You.
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 »

This is a more elaborate reference of the vga registers, including how to write to them - you may want to try this instead:
http://www.osdever.net/FreeVGA/vga/vga.htm

Beware that several sets of vga registers are programmed differently. only one such set is written through one port.

You can also have a look at some of my own code snippets
"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
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Post by Pype.Clicker »

so i wasn't remembering that bad. The BASIC code makes it even more obvious, indeed.

One thing that has never been clear to me with that approach is how one can be sure he's sending out the index, and not the data. In odd situation after the boot, i can remind of some S3 video cards that were messing up the two for some of their IO ports (which was annoying as hell)
User avatar
Ryu
Posts: 13
Joined: Sun Dec 03, 2006 8:58 am

Post by Ryu »

Well unless your talking about a specific VGA port that I don't know of that is "flipped flopped", they have a index port with a differnt data port number pair.

If it helps, heres an assembly sample making use of the VGA registers but was only tested under my VGA card.

Code: Select all

;// Initialize Video
;// ------------------------------------------------
	mov		ax, 0003h
	int		10h

	mov		dx, 3CCh
	in		al, dx		;//Miscellaneous Output Register (Read at 3CCh, Write at 3C2h)
	or		al, 2h		;//we want to enable cpu access to video memory also
						;//select I/OAS -- Input/Output Address Select to 3Dx
	mov		dx, 3C2h
	out		dx, al		;//write to register

;-------------------
	mov		dx, 3D4h	;//CRT registers
	mov		al, 0Ah		;//Cursor Start Register (Index 0Ah)
	out		dx, al

	mov		dx, 3D5h
	in		al, dx		;//
	or		al, 10h		;//disable cursor
	out		dx, al

	mov		dx, 3D4h
	mov		al, 0Ah
	out		dx, al
;---------------------
	mov		dx, 3CEh	;// address port to VGA Graphic Registers
	mov		al, 06h		;// index to 06h = misc register
	out		dx, al		;// write to address register

	mov		dx, 3CFh	;// data port to VGA Graphic Register
	in		al, dx		;// read register
	and		al, 0F3h	;// bits 3:2 = 00b == A0000h-BFFFFh (128K region)  

	out		dx, al		;// save to register

	mov		dx, 3CEh	;// address port to VGA Graphic Registers
	mov		al, 06h		;// index to 06h = misc register
	out		dx, al		;// close the port
;---------------------
Post Reply