Page 1 of 1
VGA port-index
Posted: Tue Nov 21, 2006 3:24 pm
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
Posted: Wed Nov 22, 2006 5:05 am
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.
Posted: Wed Nov 22, 2006 11:04 am
by smbogan
I will give that a try. It would seem to make sense with the things that I'm reading.
Thank You.
Posted: Wed Nov 22, 2006 11:25 am
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
Posted: Fri Nov 24, 2006 5:30 am
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)
Posted: Sun Dec 03, 2006 9:24 am
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
;---------------------