}
void setActivePage (int page )
{
pageBase = OxAOOO + page * 0x400;
}
void writePixel (int x, int y, int color) {
~,writeReg ( EGA_SEQUENCER, EGAJvlAPJVIASK, 1 « ( x & 3 )); pokeb ( pageBase, y*80 + ( x » 2 ), color); writeReg ( EGA_SEQUENCER, EGAJvlAPJVIASK, OxOF );
}
int readPixel (int x, int y ) {
writeReg ( EGAJ3RAPHICS, EGA_READ_MAP_SELECT, x & 3 ); return peekb ( pageBase, y*80 + ( x » 2 ));
}
void bar (int x1, int y1, int x2, int y2, int color) {
char far * videoPtr = (char far *) MK_FP ( pageBase,
y1*80 + (x1 » 2));
char far * ptr = videoPtr; int cols = ( x2 » 2 ) - (x1 » 2 ) -1;
char Imask = leftPlaneMask [ x1 & 3 ]; char rmask = rightPlaneMask [ x2 & 3 ];
if ( cols < 0 ) // both x1 & x2 are located
{ // in the same byte
writeReg ( EGA_SEQUENCER, EG AJVI AP__M AS K, Imask & rmask );
for (int y = y1; y <= y2; y++, videoPtr += 80 )
*videoPtr = color;
writeReg ( EGA_SEQUENCER, EGAJvlAPJVIASK, OxOF );
} . else
{
writeReg ( EGA_SEQUENCER, EGA_MAP„MASK, Imask );
for (int y = y1; y <- y2; y++, videoPtr += 80 )
* videoPtr = color;
writeReg ( EGA_SEQUENCER, EGAJVIAPJvlASK, OxOF );
4. Работа с основными графическими устройствам
videoPtr = ++ptr;
for ( y = y1; y <= y2; y++, videoPtr += 80 - cols ) for (int x = 0; x < cols; x++ )
* videoPtr++ = color;
writeReg ( EGA_SEQUENCER, EGA_MAP_MASK, rmask );
videoPtr = ptr + cols;
for ( y = y1; y <= y2; y++, videoPtr += 80 )
* videoPtr = color;
writeReg ( EGA_SEQUENCER, EGA_MAP_MASK, OxOF );
}
void getlmage (int x, int y, int width, int height, void * buf) {
char far * videoPtr;
char * dataPtr = (char *) buf;
for (int i = x; i < x + width; i++ ) {
videoPtr = (char far *) MK_FP (pageBase, (i » 2)+y*80): writeReg ( EGA_GRAPHICS, EGA_READ_MAP_SELECT, i & 3 );
for (int j = 0; j < height; j++, videoPtr += 80 )
* dataPtr ++ = * videoPtr;
}
}
void putlmage (int x, int y, int width, int height, void * buf) {
char far * videoPtr;
char * dataPtr = (char *) buf;