VGA 4-color mode?

I'm trying to get the VGA's Shift Register Interleave mode down, which is used in 4-color modes.

Anyone knows what might be wrong?

1
2
3
4
5
6
7
8
9
10
11
12
		uint_32 scanlineoffset = getVRAMScanlineStart(VGA,y); //Scanline offset!
		uint_32 planeindex = (x/8)*getVRAMMemAddrSize(VGA); //The full offset, within the plane with our pixel!
		byte planebase = (x/4)%2; //Base plane (0/1)! OK!
		byte planelow = readVRAMdirect(VGA,0,addresswrap(VGA,patch_map1314(VGA,((vramstart+scanlineoffset)*4)+planebase+(planeindex*4),y,scanlineoffset))); //Lower plane: OK!
		//byte planehigh = readVRAMdirect(VGA,0,addresswrap(VGA,patch_map1314(VGA,addresswrap(VGA,((vramstart+scanlineoffset)*4)+planebase+2+(planeindex*4)),y,scanlineoffset))); //Higher plane: OK!
		byte planehigh = 0; //Disable high plane for now, just test the low plane!
		byte shift = 6-((x%4)*2); //OK!
		byte bitmask = 3<<shift; //The bitmask for the lower&higher planes: OK!
		return ( //This should be OK!
			((planelow&bitmask)>>shift)|
			(((planehigh&bitmask)>>shift)<<2)
			); //Give the VRAM value of the specified pixel! 


addresswrap(VGA,fullvramoffset) applies address wrapping arround 64k when defined in the VGA registers (and when in word addressing mode).

getVRAMScanlineStart(VGA,y) gives the start offset of a graphics or text row, based upon the memory address size (byte, word or doubleword mode) and the Offset register. (As far as i know =2*Memory size(1,2 or 4)*Offset register).

patchMap1314(VGA,vram_addr,rowscancounter,rowscanaddress) patches a full VRAM address, according to the CRTC Mode Control register, bits 0&1 (MAP13&MAP14 bits).

readVRAMdirect(VGA,fullstartaddress,fulloffset) reads from VRAM. The address in VRAM is calculated like this: fullstartaddress+fulloffset (byte offsets).

The VRAM is structured like this:
Index 0 = Plane 0 byte 0
Index 1 = Plane 1 byte 0
Index 2 = Plane 2 byte 0
Index 3 = Plane 3 byte 0
Index 4 = Plane 0 byte 1
Index 5 = Plane 1 byte 1
Index 6 = Plane 2 byte 1
Index 7 = Plane 3 byte 1
Index 8 = Plane 0 byte 2
etc. till plane 3 byte 65535.

Anyone knows what I'm doing wrong? (I'm basing it upon the FreeVGA documentation ( http://www.osdever.net/FreeVGA/vga/vga.htm ))
Last edited on
Topic archived. No new replies allowed.