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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
byte VGA_getpixel(VGA_Type *VGA, int x, int y)
{
word vramstart = ((VGA->registers->CRTControllerRegisters.REGISTERS.STARTADDRESSHIGHREGISTER<<8)|VGA->registers->CRTControllerRegisters.REGISTERS.STARTADDRESSLOWREGISTER); //Start address of VRAM display!
uint_32 offset; //The offset!
byte bit; //The bit we need!
if (VGA->registers->GraphicsRegisters.REGISTERS.GRAPHICSMODEREGISTER.Color256ShiftMode) //256-color mode?
{
//TODO!
offset = getVRAMScanlineStart(VGA,y)+x; //The full offset (in pixels)!
byte plane = offset%4; //The plane we use!
offset /= 4; //The offset within the plane!
uint_32 fulloffset = vramstart+(plane*0x10000)+offset; //Full offset within the correct plane!
if (VGA->precalcs.VRAMmemaddrsize==2) //Word mode?
{
if (!VGA->registers->CRTControllerRegisters.REGISTERS.CRTCMODECONTROLREGISTER.AW) //Appear as if only 64k memory is present?
{
fulloffset &= 0xFFFF; //Force plane #0 (65k mem)
}
}
return readVRAMdirect(VGA,0,patch_map1314(VGA,addresswrap(VGA,fulloffset),y,offset)); //The full offset of the plane!
}
else if (VGA->registers->GraphicsRegisters.REGISTERS.GRAPHICSMODEREGISTER.ShiftRegisterInterleaveMode) //Shift Register Interleave mode?
{
//TODO!
uint_32 planeindex = getVRAMScanlineStart(VGA,y)+(x/8); //The full offset (in pixels)!
byte planebase = (x/4)%2; //Base plane (0/1)! OK!
uint_32 scanlinestart = 0; //Default: no scanline start!
byte planelow = readVRAMdirect(VGA,0,patch_map1314(VGA,addresswrap(VGA,vramstart+scanlinestart+(planebase*0x10000)+planeindex),y,planeindex)); //Lower plane: OK!
byte planehigh = readVRAMdirect(VGA,0,patch_map1314(VGA,addresswrap(VGA,vramstart+scanlinestart+((planebase+2)*0x10000)+planeindex),y,planeindex)); //Higher plane: OK!
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!
}
else
{
//Should be OK?
byte result;
offset = (getVRAMScanlineStart(VGA,y)+((x/8)*getVRAMMemAddrSize(VGA))); //Offset!
bit = 7-(x%8); //The bit in the byte!
//16-color mode!
result = (getBitPlaneBit(VGA,vramstart,0,offset,bit)| //Bit0
(getBitPlaneBit(VGA,vramstart,1,offset,bit)<<1)| //Bit1
(getBitPlaneBit(VGA,vramstart,2,offset,bit)<<2)| //Bit2
(getBitPlaneBit(VGA,vramstart,3,offset,bit)<<3)); //Bit3
if (!VGA->registers->ExternalRegisters.MISCOUTPUTREGISTER.IO_AS) //Monochrome mode uses only plane 0?
{
result &= 0x1; //Only bit0!
}
return result; //Give the result!
}
}
|