I'm building an emulator which implements a VGA card. As far as I know each address is incremented by a byte, word or doubleword, depending on the Byte/Word and DoubleWord bits in the VGA registers.
What I'm finding strange, is that during text mode, it's set to word mode. So this would mean that the first letter is at plane 0, address 0, the second at plane 0, address 2, the third at plane 0, address 4. So this would mean that every even letter is skipped?
Example (using 16-bit segmented PC addressing):
0xA000:0000 A = plane 0 offset 0
0xA000:0000 0xF = plane 1 offset 0
0xA000:0002 B = plane 0 offset 1
0xA000:0000 0xF = plane 1 offset 1
0xA000:0004 C = plane 0 offset 2
0xA000:0000 0xF = plane 1 offset 2
0xA000:0006 D = plane 0 offset 3
0xA000:0000 0xF = plane 1 offset 3
0xA000:0008 E = plane 0 offset 4
0xA000:0000 0xF = plane 1 offset 4
0xA000:000A F = plane 0 offset 5
0xA000:0000 0xF = plane 1 offset 5
Display should be, according to word mode (bit 0 is essentially cleared for the first row):
ACE
But all documentation says it's supposed to be:
ABCDEF
Is this correct? Or does the text mode operation ignore the Byte/Word/Doubleword mode setting for some reason? Am I implementing the word mode wrong?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
OPTINLINE uint_32 addresswrap(VGA_Type *VGA, uint_32 memoryaddress) //Wraps memory arround 64k!
{
register uint_32 address2; //Load the initial value for calculating!
register uint_32 result;
result = memoryaddress; //Default: don't change!
if (getVRAMMemAddrSize(VGA)==2) //Word mode?
{
address2 = memoryaddress; //Load the address for calculating!
if (VGA->registers->CRTControllerRegisters.REGISTERS.CRTCMODECONTROLREGISTER.AW) //MA15 has to be on MA0
{
address2 >>= 15;
}
else //MA13 has to be on MA0?
{
address2 >>= 13;
}
address2 &= 1; //Only load 1 bit!
result &= ~1; //Clear bit 0!
result |= address2; //Add bit MA15 at position 0!
}
return result; //Adjusted address!
}
|