home *** CD-ROM | disk | FTP | other *** search
- #include "window.h"
- #include <dos.h>
- #include <stdlib.h>
-
- int Window::Getch()
- {
- union REGS reg;
-
- reg.h.ah = 0x07;
- int86(0x21, ®, ®);
- return (int)(reg.h.al);
- }
-
-
- void Window::SetVideoMem()
- {
- if ((vc == TYPE_MDA) || (vc == TYPE_HGC))
- Video = (short far *)MK_FP(0xb000, 0);
- else
- Video = (short far *)MK_FP(0xb800, 0);
- }
-
-
- void Error(char *msg)
- {
- fprintf(stderr, msg);
- fprintf(stderr, "\n");
- exit(1);
- }
-
-
- VideoCardType Window::IdentifyVideoCard()
- {
- union REGS reg;
- uchar isvga, disptype;
-
- // call VGA "Identify Adapter Service" first
- reg.x.ax = 0x1a00;
- int86(0x10, ®, ®);
- isvga = reg.h.al;
- disptype = reg.h.bl;
-
- if (isvga == 0x1a)
- switch (disptype) {
- case 1:
- return(TYPE_MDA);
- case 2:
- return(TYPE_CGA);
- case 4:
- case 5:
- return(TYPE_EGA);
- case 7:
- case 8:
- return(TYPE_VGA);
- case 10:
- case 11:
- case 12:
- return(TYPE_MCGA);
- default:
- return(TYPE_UNKNOWN);
- }
- else {
- // VGA services not available -- maybe it's EGA
- uchar isega;
-
- reg.h.ah = 0x1a;
- reg.h.bl = 0x10;
- int86(0x10, ®, ®);
- isega = reg.h.bl;
-
- // if BL is not 0x10, we have an EGA
- if (isega != 0x10)
- return(TYPE_EGA);
- else {
- // check 2-bit monitor type setting in eqip word
- unsigned short equip, i, status_changed;
- uchar orig_status;
-
- int86(0x11, ®, ®);
- equip = reg.x.ax;
- switch ((equip & 0x30) >> 4) {
- case 0:
- return(TYPE_UNKNOWN);
- case 1:
- case 2:
- return(TYPE_CGA);
- case 3:
- status_changed = 0;
- orig_status = (uchar)(inp(0x03ba) &
- 0x80);
- for (i=0; i<30000u; i++) {
- if (orig_status != (uchar)
- (inp(0x03ba) & 0x80)) {
- status_changed = 1;
- break;
- }
- }
- if (status_changed)
- return(TYPE_HGC);
- else
- return(TYPE_MDA);
- }
- }
- }
- }
-
-
- void Window::HideCursor()
- {
- union REGS reg;
-
- if (CursorHidden)
- return;
- else {
- reg.h.ah = 0x03;
- reg.h.bh = 0;
- int86(0x10, ®, ®);
- CursorShape = reg.x.cx;
- reg.h.ah = 0x01;
- reg.x.cx = 0x2000;
- int86(0x10, ®, ®);
- CursorHidden = TRUE;
- }
- }
-
-
- void Window::ShowCursor()
- {
- union REGS reg;
-
- if (!CursorHidden)
- return;
- else {
- reg.h.ah = 0x01;
- reg.x.cx = CursorShape;
- int86(0x10, ®, ®);
- CursorHidden = FALSE;
- }
- }
-