#ifndef DRAWING_H
#define DRAWING_H
#include <dos.h>
#include <conio.h>
#include <stdio.h>
struct REGPACK regs;
unsigned CURSOR_BRUSH[17] = {0x001C, 0x003F, 0x0073, 0x00B3, 0x01BF, 0x03DE, 0x07E4, 0x0BF8, 0x0BF0, 0x1DE0, 0x1E40, 0x3F80, 0x2E00, 0x5800, 0x6000, 0x6000, 0x0F01};
unsigned CURSOR_ERASER[17] = {0x0FC0, 0x1BE0, 0x3DF0, 0x7EF8, 0xFF70, 0x7FBE, 0x3FD1, 0x1FE1, 0x0FDE, 0x07BC, 0x0378, 0x01F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0004};
unsigned CURSOR_DEFAULT[17] = {0x0000, 0x0780, 0x0FC0, 0x18E0, 0x3060, 0x2060, 0x0060, 0x0060, 0x00E0, 0x01C0, 0x0300, 0x0300, 0x0300, 0x0000, 0x0300, 0x0300, 0x0707};
void intrMouse(int param) {
regs.r_ax = param;
intr(0x33, ®s);
}
int initMouse() {
intrMouse(0);
if (regs.r_ax == 0) {
printf ("ERROR. MOUSE NOT FOUND. PRESS ANY KEY TO EXIT...");
return 1;
}
else {
printf ("MOUSE IS PRESENT, AND HAS %d BUTTON", regs.r_bx);
return 0;
}
}
void showMouse(void) {
intrMouse(1);
}
void hideMouse(void) {
intrMouse(2);
}
void mouseState(int &mX, int &mY, int &mB) {
intrMouse(3);
mX = regs.r_cx;
mY = regs.r_dx;
mB = regs.r_bx;
}
void mousePosition(int mX, int mY) {
regs.r_cx = mX;
regs.r_dx = mY;
intrMouse(4);
}
void brushActive (int &mX, int &mY, int &prevX, int &prevY, int sizeCursor, int &colorBrush) {
hideMouse();
setcolor(colorBrush);
line(prevX, prevY, mX, mY);
showMouse();
}
void eraserActive (int &mX, int &mY, int sizeCursor) {
int bkcolor = getbkcolor();
hideMouse();
for (int i = mX - sizeCursor; i <= mX + sizeCursor; i++)
for (int j = mY - sizeCursor; j <= mY + sizeCursor; j++) {
putpixel (i,j,bkcolor);
}
showMouse();
}
void setMouseCursor(unsigned styleCursor[17]) {
unsigned newStyleCursor[32];
for(int i=0; i<16; i++) {
newStyleCursor[i] = (~styleCursor[i]);
newStyleCursor[i+16] = styleCursor[i];
}
regs.r_bx = styleCursor[16]/0x100;
regs.r_cx = styleCursor[16]%0x100;
regs.r_es = FP_SEG(&newStyleCursor);
regs.r_dx = FP_OFF(&newStyleCursor);
intrMouse(9);
}
#endif