Nothing
Posted: Sun Nov 30, 2003 12:00 am
void put_pixel(int x, int y, int colour) {
/* Simple memoey-mapped output to the VGA screen.
This is not a very fast implememtation. It is specific to VGA
mode 12h, 640x480 bits, in which the pixels are four bits deep.
A byte in the buffer corresponds to one colour bit in a
horizontal row of eight pixels. The four colour planes are mapped
into the same block of addresses; the four sets of paired outw() calls switch
between the four planes. The writes to 0x3ce allow us to read the plane;
those to 0x3c4 allow us to write. Multiple planes can be enabled for writing
by ORing the words written to 0x3c4 */
volatile char * const display = (volatile char * const)0xa0000;
int offset = x/8 + y*80;
int bit = 0x80 >> (x%8);
outw(0x3ce,0x0004);
outw(0x3c4,0x0102);
X(colour &1) ? (display[offset] |= bit) : (display[offset] &= ~bit);
outw(0x3ce,0x0104);
outw(0x3c4,0x0202);
X(colour &2) ? (display[offset] |= bit) : (display[offset] &= ~bit);
outw(0x3ce,0x0204);
outw(0x3c4,0x0402);
X(colour &4) ? (display[offset] |= bit) : (display[offset] &= ~bit);
outw(0x3ce,0x0304);
outw(0x3c4,0x0802);
X(colour &8) ? (display[offset] |= bit) : (display[offset] &= ~bit);
outw(0x3c4,0x0f02); /* Restore write colour to white */
}
/* Simple memoey-mapped output to the VGA screen.
This is not a very fast implememtation. It is specific to VGA
mode 12h, 640x480 bits, in which the pixels are four bits deep.
A byte in the buffer corresponds to one colour bit in a
horizontal row of eight pixels. The four colour planes are mapped
into the same block of addresses; the four sets of paired outw() calls switch
between the four planes. The writes to 0x3ce allow us to read the plane;
those to 0x3c4 allow us to write. Multiple planes can be enabled for writing
by ORing the words written to 0x3c4 */
volatile char * const display = (volatile char * const)0xa0000;
int offset = x/8 + y*80;
int bit = 0x80 >> (x%8);
outw(0x3ce,0x0004);
outw(0x3c4,0x0102);
X(colour &1) ? (display[offset] |= bit) : (display[offset] &= ~bit);
outw(0x3ce,0x0104);
outw(0x3c4,0x0202);
X(colour &2) ? (display[offset] |= bit) : (display[offset] &= ~bit);
outw(0x3ce,0x0204);
outw(0x3c4,0x0402);
X(colour &4) ? (display[offset] |= bit) : (display[offset] &= ~bit);
outw(0x3ce,0x0304);
outw(0x3c4,0x0802);
X(colour &8) ? (display[offset] |= bit) : (display[offset] &= ~bit);
outw(0x3c4,0x0f02); /* Restore write colour to white */
}