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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
/*
2 colors!
*/
inline byte MEMGRAPHICS_get2colors(uint_32 startaddr, int x, int y, int xres, int yres)
{
uint_32 offset;
byte bit; //The bit!
bit = 7-(x%8); //The bit number we need to adjust in the VRAM plane!
offset = ((y*getrowsize()))+((x/8)*getVRAMMemAddrSize()); //Column index in VRAM planes!
return getBitPlaneBit(startaddr,0,offset,bit); //Give the color!
}
inline void MEMGRAPHICS_put2colors(uint_32 startaddr, int x, int y, int xres, int yres, byte color)
{
uint_32 offset;
byte bit; //The bit!
bit = 7-(x%8); //The bit number we need to adjust in the VRAM plane!
offset = ((y*getrowsize()))+((x/8)*getVRAMMemAddrSize()); //Column index in VRAM planes!
setBitPlaneBit(startaddr,0,offset,bit,(color%2)); //Set the color!
}
/*
4 colors!
4 pixels per byte!
*/
inline byte MEMGRAPHICS_get4colors(uint_32 startaddr, int x, int y, int xres, int yres)
{
uint_32 offset;
byte bit; //The bit!
bit = 7-((x%4)*2); //The bit number we need to adjust in the VRAM plane! (Lower bit)
offset = ((y*getrowsize()))+((x/4)*getVRAMMemAddrSize()); //Column index in VRAM planes!
//Info: first plane has bit 0, second plane has bit 1, planes 2&3 are unused!
return getBitPlaneBit(startaddr,0,offset,bit+1)|(getBitPlaneBit(startaddr,1,offset,bit)<<1); //Give the result!
}
inline void MEMGRAPHICS_put4colors(uint_32 startaddr, int x, int y, int xres, int yres, byte color)
{
uint_32 offset;
byte bit; //The bit!
bit = 7-((x%4)*2); //The bit number we need to adjust in the VRAM plane!
offset = ((y*getrowsize()))+((x/4)*getVRAMMemAddrSize()); //Column index in VRAM planes!
//Info: first plane has bit 0, second bit 1 etc. so: PLANE|=BIT.
setBitPlaneBit(startaddr,0,offset,bit+1,color&1); //Low!
setBitPlaneBit(startaddr,1,offset,bit,(color&2)>>1); //High!
}
/*
4 colors (SHADES)!
*/
inline byte MEMGRAPHICS_get4colorsSHADE(uint_32 startaddr, int x, int y, int xres, int yres)
{
return MEMGRAPHICS_get4colors(startaddr, x,y,xres,yres); //Passtrough: same!
}
inline void MEMGRAPHICS_put4colorsSHADE(uint_32 startaddr, int x, int y, int xres, int yres, byte color)
{
MEMGRAPHICS_put4colors(startaddr, x,y,xres,yres,color); //Passtrough: same!
}
/*
16 colors!
*/
inline byte MEMGRAPHICS_get16colors(uint_32 startaddr, int x, int y, int xres, int yres)
{
uint_32 offset;
byte bit; //The bit!
bit = 7-(x%8); //The bit number we need to adjust in the VRAM plane!
offset = (y*getrowsize())+((x/8)*getVRAMMemAddrSize()); //Column index in VRAM planes!
//Info: first plane has bit 0, second bit 1 etc. so: PLANE|=BIT.
byte result; //The result!
result = 0; //Init result!
result |= getBitPlaneBit(startaddr,0,offset,bit); //Bit0!
result |= (getBitPlaneBit(startaddr,1,offset,bit)<<1); //Bit1!
result |= (getBitPlaneBit(startaddr,2,offset,bit)<<2); //Bit2!
result |= (getBitPlaneBit(startaddr,3,offset,bit)<<3); //Bit3!
return result; //Give the result!
}
inline void MEMGRAPHICS_put16colors(uint_32 startaddr, int x, int y, int xres, int yres, byte color)
{
uint_32 offset;
byte bit; //The bit!
bit = 7-(x%8); //The bit number we need to adjust in the VRAM plane!
offset = (y*getrowsize())+((x/8)*getVRAMMemAddrSize()); //Column index in VRAM planes!
//Info: first plane has bit 0, second bit 1 etc. so: PLANE|=BIT.
setBitPlaneBit(startaddr,0,offset,bit,(color&1)); //Lowest bit!
setBitPlaneBit(startaddr,1,offset,bit,((color&2)>>1)); //Bit1!
setBitPlaneBit(startaddr,2,offset,bit,((color&4)>>2)); //Bit2!
setBitPlaneBit(startaddr,3,offset,bit,((color&8)>>3)); //Bit3!
}
/*
256 COLORS
*/
inline byte MEMGRAPHICS_get256colors(uint_32 startaddr, int x, int y, int xres, int yres)
{
uint_32 pixelnumber;
pixelnumber = startaddr+(y*getrowsize())+(x*getVRAMMemAddrSize());
return VRAM_readdirect(pixelnumber); //Give the pixel from memory!
}
inline void MEMGRAPHICS_put256colors(uint_32 startaddr, int x, int y, int xres, int yres, byte color)
{
uint_32 pixelnumber;
pixelnumber = startaddr+(y*getrowsize())+(x*getVRAMMemAddrSize());
VRAM_writedirect(pixelnumber,color); //Write byte to VRAM!
}
//END OF VGA COLOR SUPPORT!
|