/* MCGA.h Header file for graphics programming in MCGA mode */ //Prototypes void SetMCGA (); void SetText (); void PutPixel (int x, int y, unsigned char Col); void ClearBuffer (); void DisplayBuffer (); void Pal (unsigned char ColorNo, unsigned char R, unsigned char G, unsigned char B); void MakeCircle(int x, int y, int radius, unsigned char col); //Switches to VGA 320x200 256 colour void SetMCGA () { union REGS r; r.h.ah = 0; r.h.al = 0x13; int86(0x10, &r, &r); } //Switches to text 80x25 void SetText () { union REGS r; r.h.ah = 0; r.h.al = 0x3; int86(0x10, &r, &r); } //Write a pixel to the buffer void PutPixel (int x, int y, unsigned char Col) { if ((x < 320) && (y < 200)) { Buffer [(y << 8) + (y << 6) + x] = Col; } } //Clear buffer to 0 void ClearBuffer () { #ifdef __DJGPP memset (Buffer, 0, 64000); #else _fmemset (Buffer, 0, 64000); #endif } //Displays the buffer void DisplayBuffer () { #ifdef __DJGPP memcpy (Screen, Buffer, 64000); #else _fmemcpy (Screen, Buffer, 64000); #endif } //Palatte shift using ports etc. void Pal (unsigned char ColorNo, unsigned char R, unsigned char G, unsigned char B) { if (R > 63) R = 63; if (G > 63) G = 63; if (B > 63) B = 63; outp (0x03C8, ColorNo); outp (0x03C9, R); outp (0x03C9, G); outp (0x03C9, B); } //Draw a circle on the screen void MakeCircle(int x, int y, int radius, unsigned char col) { float x_result, y_result; float degrees = 0; for (degrees = 0; degrees <= 360; degrees+=.005) { x_result = x + cos(degrees) * radius; y_result = y + sin(degrees) * radius; if (x_result >=0 && y_result >=0) { PutPixel(x_result, y_result, col); } } }