VGA i/o modes (not write modes)?

I'm checking the formulas used to process the VRAM address from the CPU (0x00000-0x20000 max (when using 0xA0000-0xBFFFF)) to planar addresses (plane 0-3 offset 0x0000-0xFFFF). Anyone knows if this is OK?

realoffset is the memory address relative to the start of the CPU window (0xA0000, 0xB0000 or 0xB8000).

At the end of this routine, the plane variable must contain the plane (0-3) and the offset (0x0000-0x(1)(FFFF,8000 or 0000), depending on the window) must be in realoffset.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
	byte plane; //The determined plane we use!
	if (ActiveVGA->registers->SequencerRegisters.REGISTERS.SEQUENCERMEMORYMODEREGISTER.Chain4Enable) //Chain 4 mode?
	{
		plane = realoffset&0x0003; //Lower bits!
		realoffset = realoffset&0xfffb; //Rest of the bits. Multiples of 4 wont get written!
	}
	else if (!ActiveVGA->registers->SequencerRegisters.REGISTERS.SEQUENCERMEMORYMODEREGISTER.OddEvenHostMemoryWriteAddressingDisable) //Odd/even addressing mode?
	{
		plane = (realoffset&1); //The plane to use: odd(1) or even(0)!
		plane |= (ActiveVGA->registers->ExternalRegisters.MISCOUTPUTREGISTER.OE_HighPage<<1); //Add the base plane, 0(0) or 2(1)!
		realoffset = (SETBIT0(realoffset,0)>>1); //Calculate the correct offset within the VRAM!
	}
	else //Determined by plane mask register (unchained mode)!
	{
		byte planebits = ActiveVGA->registers->SequencerRegisters.REGISTERS.MAPMASKREGISTER.MemoryPlaneWriteEnable;
		plane = 0; //Plane 0 by default!
		if (planebits&1) //Plane 0?
		{
		}
		else if (planebits&2) //Plane 1?
		{
			plane = 1;
		}
		else if (planebits&4) //Plane 2?
		{
			plane = 2;
		}
		else if (planebits&8) //Plane 3?
		{
			plane  = 3;
		}
		//The offset is used directly!
	}


Anyone knows if this is correct?
Last edited on
Topic archived. No new replies allowed.