// clear screen
writeReg ( EGA_SEQUENCER, EGA_MAP_MASK, OxOF ); Jmemset ( MK_FP ( pageBase, 0 ), ,\0', OxFFFF );
}
void setVisualPage (int page ) {
unsigned addr = page * 0x4B00;
// wait for vertical retrace while ((inportb ( 0x3DA ) & 0x08 ) == 0 )
>
writeReg ( EGA__CRTC, OxOC, addr » 8 ); writeReg ( EGACRTC, OxDC, addr & OxOF );
}
void setActivePage (int page )

4. Работа с основными графическими устройствам

^ pageBase = OxAOOO + page * 0x4B0; }
void writePixei (int x, int y, int color)
* writeReg ( EGA_SEQUENCER, EGA_MAP_MASK. 1 « ( x & 3 )); pokeb ( pageBase, y * bytesPerLine + ( x » 2 ), color); writeReg ( EGA_SEQUENCER, EGA_MAP_MASK, OxOF );
}
int readPixel (int x, int y )
* writeReg ( EGA_GRAPHICS, EGA_READ_MAP__SELECT, x & 3 ); return peekb ( pageBase, y * bytesPerLine + ( x » 2 ));
}
void bar (int x1, int y1, int x2, int y2, int color) {
char far * vptr = (char far *) MK_FP ( pageBase,
y1 * bytesPerLine + (x1 » 2));
char far * ptr = vptr;
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_SEQLfENCER,EGA_MAP_MASK,lmask & rmask);
for (int y = y1; y <= y2; y++, vptr += bytesPerLine) *vptr = color;
writeReg ( EGA_SEQUENCER, EGA_MAP_MASK, OxOF );
}
else
{
writeReg ( EGA_SEQUENCER, EGA_MAP_MASK, Imask );
for (int y = y1; y <= y2; y++, vptr += bytesPerLine) *vptr = color;
writeReg ( EGA_SEQUENCER, EGA_MAP_MASK, OxOF ); vptr = ++ptr;
for (y=y1; y<=y2; y++, vptr += bytesPerLine-cols ) for (int x = 0; x < cols; x++ ) *vptr++ = color;
writeReg ( EGA_SEQUENCER, EGA_MAP_MASK, rmask );
vptr = ptr + cols;
for ( y = y1; y <= y2; y++, vptr += bytesPerLine ) *vptr - color;
}

Компьютерная графика. Полигональные модели

writeReg ( EGA_SEQUENCER, EGA_MAP__MASK, OxOF );
}
void drawString (int x, int y, char * str, int color)
* for (; *str != '\0'; str++, x+= 8 )

⇐ Предыдущая| |Следующая ⇒