static OPTINLINE uint_32 addresswrap(VGA_Type *VGA, uint_32 memoryaddress) //Wraps memory arround 64k!
{
if (getVRAMMemAddrSize(VGA)==2) //Word address mode?
{
register uint_32 address = memoryaddress; //Init address to memory address!
register uint_32 address2;
address2 = address; //Load the initial value for calculating!
if (VGA->registers->CRTControllerRegisters.REGISTERS.CRTCMODECONTROLREGISTER.AW) //MA15 has to be on MA0
{
address2 >>= 15;
address2 &= 1;
address &= ~(1|(1<<15)); //Clear bit MA15&0!
address |= address2; //Add bit MA15 at position 0!
}
else //MA13 has to be on MA0?
{
address2 >>= 13;
address2 &= 1;
address &= ~(1|(1<<13)); //Clear bit MA13&0!
address |= address2; //Add bit MA13 at position 0!
}
return address; //Adjusted address!
}
return memoryaddress; //Normal operating mode!
}
AW -- Address Wrap Select
"This bit selects the memory-address bit, bit MA 13 or MA 15, that appears on the output pin MA 0, in the word address mode. If the VGA is not in the word address mode, bit 0 from the address counter appears on the output pin, MA 0. When set to 1, this bit selects MA 15. In odd/even mode, this bit should be set to 1 because 256KB of video memory is installed on the system board. (Bit MA 13 is selected in applications where only 64KB is present. This function maintains compatibility with the IBM Color/Graphics Monitor Adapter.)"