On (06 Jun 97) Christopher Butler wrote to All...
[ asking about what was wrong with a class he wrote ]
#include
class GraphicsScreen {
public:
GraphicsScreen();
~GraphicsScreen();
void Box(int x1, int y1, int x2, int y2, unsigned char col);
void PutPixel(int x, int y, unsigned char col);
};
GraphicsScreen::GraphicsScreen() {
_asm {
mov ax, 0x13
int 10h
}
}
GraphicsScreen::~GraphicsScreen() {
_asm {
mov ax, 3
int 0x10
}
}
void GraphicsScreen::PutPixel(int x, int y, unsigned char col) {
char _far *spot = (char far *)MK_FP(0xa000, y*320+x);
*spot = col;
}
void GraphicsScreen::Box(int x1, int y1, int x2, int y2, unsigned char col) {
int x, y;
char _far *spot = (char far *)MK_FP(0xa000, y2*320 + x2);
int offset = 320 - (y2 - y1);
for ( y = y2 - y1; y; y--) {
for ( x = x2 - x1; x; x--)
*spot-- = col;
spot -= offset;
}
}
#include
int main(void) {
GraphicsScreen gs; // Creation sets graphics mode
gs.Box(100, 100, 200, 200, 0x13); // Box on screen.
gs.PutPixel(150, 150, 0x2f); // Pixel in middle of box
getch(); // wait for user to press a key
} // back to text mode when
// automatically destroyed.
... The Universe is a figment of its own imagination.
--- PPoint 1.90
---------------
* Origin: Point Pointedly Pointless (1:128/166.5)
|