--- os2sdk/demos/apps/life/life.c 2018/08/09 12:25:13 1.1.1.1 +++ os2sdk/demos/apps/life/life.c 2018/08/09 12:25:56 1.1.1.2 @@ -3,13 +3,7 @@ * * LIFE - An OS/2 Game of Life * - * - * Author: - * - * Brian J. Smith - * (c) Microsoft Corporation - * 1987 - * + * Created by Microsoft Corp. 1987 * * Description: * @@ -31,9 +25,11 @@ * */ +#define INCL_DOS /* includes all OS/2 calls in */ +#define INCL_SUB /* bsedos.h and bsesub.h */ -#include /* definitions for DOS calls and */ -#include /* associated data structures */ +#include /* definitions for OS/2 calls and */ +#include /* associated data structures */ /* defines */ #define SCR_WID 80 /* screen buffer row width in bytes */ @@ -87,14 +83,14 @@ int ScrRow = 45; /* rows & column on s int ScrCol = 79; int SizeScrRow = 4; /* pixel rows per screen grid row */ int SizeScrCol = 8; /* pixels cols per screen grid column*/ -char far *InGrid; /* pointer to internal grid, a simple +PSZ InGrid; /* pointer to internal grid, a simple * bit map of the space and cells */ -char far *InGrid2; /* pointer for secondary map used +PSZ InGrid2; /* pointer for secondary map used * to calculate next generation */ /* screen related global data */ -static struct ModeData Highres = {12, 3, 1, 80, 25, 640, 200}; /* 640x200 b/w*/ -struct ModeData Savemode = {12}; /* place to save old screen mode */ +static VIOMODEINFO Highres = {12, 3, 1, 80, 25, 640, 200}; /* 640x200 b/w*/ +VIOMODEINFO Savemode = {12}; /* place to save old screen mode */ unsigned ScrSeg; /* screen buffer segment address */ char Cell[]={32,7}; /* blank for clear screen */ unsigned OddPage=0x2000; /* offset on Cga of odd row bit plane*/ @@ -104,7 +100,7 @@ unsigned Cga=2; /* if using a Cga, sc * the odd and even row bit planes * if using non-Cga mode, should be 1*/ /* mouse related global data */ -unsigned Mouse = 0; /* handle if mouse is present, else */ +HMOU Mouse = 0; /* handle if mouse is present, else */ int MouBoundRow = COM_ROW*FONT_ROW+6; /* last row mouse is allowed on */ int MouBoundCol = 631; /* last column mouse is allowed on */ @@ -121,7 +117,7 @@ int Slow=0; /* number of slow-down lo * and the function that does the command. */ struct Commands { int Col; - char *Name; + NPSZ Name; char GoAble; void (*Fun)(); } ComLine[] = { 0, "Command:", 0, beep, @@ -148,67 +144,68 @@ struct Commands { * mouse with the ComLine structure into a command to execute. */ main () { - struct KeyData kbd; /* return for KBD call */ - struct PhysBufData get_phys; /* return for GetPhysBufData */ - unsigned long throwaway; /* for returns I don't use */ + KBDKEYINFO kbd; /* return for KBD call */ + VIOPHYSBUF get_phys; /* return for GetPhysBufData */ + USHORT throwaway; /* for returns I don't use */ int i; /* just a counter */ unsigned far *ptr; /*used to clear internal grid*/ /* data for the mouse (or keyboard emulator) */ int ptrrow = 86; /* current pointer position */ int ptrcol = 316; - unsigned status = 0x100; /* for MouSetDevStatus */ - int type=0; /* for no waits on mouse read */ - struct EventInfo event; /* return for mouse reads */ - struct PtrLoc loc; /* data for MouSetPtrPos */ + USHORT status = 0x100; /* for MouSetDevStatus */ + USHORT type=0; /* for no waits on mouse read */ + MOUEVENTINFO event; /* return for mouse reads */ + PTRLOC loc; /* data for MouSetPtrPos */ /* try to open and initialize mouse. If none installed, Mouse will * stay 0 to show keyboard emulation must be used */ - if (!MOUOPEN (0L, (unsigned far *) &Mouse)) /* get handle */ + if (!MouOpen (0L, &Mouse)) /* get handle */ /* mouse is here and well, so initialize it */ - MOUSETDEVSTATUS ((unsigned far *) &status, Mouse); + MouSetDevStatus (&status, Mouse); /* get current screen mode and save it for restoring on exit */ - if (VIOGETMODE ((struct ModeData far *) &Savemode, 0)) { + if (VioGetMode (&Savemode, 0)) { printf ("Error setting screen mode, exitting\n"); - DOSEXIT (1, 0); /* exit if error */ + DosExit (EXIT_PROCESS, 0); /* exit if error */ } /* set screen mode to 640x200 b/w (Cga high resolution */ - if (VIOSETMODE ((struct ModeData far *) &Highres, 0)) { + if (VioSetMode (&Highres, 0)) { printf ("Error setting screen mode, exitting\n"); - DOSEXIT (1, 0); /* exit if error */ + DosExit (EXIT_PROCESS, 0); /* exit if error */ } /* set mouse pointer to middle of screen */ if (Mouse) { - loc.RowPos=ptrrow; - loc.ColPos=ptrcol; - MOUSETPTRPOS ((struct PtrLoc far *) &loc, Mouse); + loc.row=ptrrow; + loc.col=ptrcol; + MouSetPtrPos (&loc, Mouse); } /* get screen buffer segment */ - get_phys.buf_start=0xb8000L; - get_phys.buf_length=16*1024L; - if (VIOGETPHYSBUF ((struct PhysBufData far *) &get_phys, 0)) { + get_phys.pBuf=(PBYTE)0xb8000L; + get_phys.cb=16*1024L; + if (VioGetPhysBuf (&get_phys, 0)) { /* if error here, restore screen and exit */ - VIOSETMODE ((struct ModeData far *) &Savemode, 0); + VioSetMode (&Savemode, 0); printf ("Error accessing screen memory, exitting\n"); - DOSEXIT (1, 0); + DosExit (EXIT_PROCESS, 0); } - ScrSeg = get_phys.selectors[0]; /* store in global */ + ScrSeg = get_phys.asel[0]; /* store in global */ /* set ctrl-C to quit() to reset screen at even a break */ - DOSSETSIGHANDLER (exitlife, &throwaway, (unsigned far *)&throwaway, 2, 1); + DosSetSigHandler (exitlife, (PFNSIGHANDLER FAR *)&throwaway, + &throwaway, 2, 1); /* allocate a segment to hold internal grid representation */ - if (DOSALLOCSEG (InRow*InCol/BYTEINCOLS, (unsigned far *) &InGrid, 0)) + if (DosAllocSeg (InRow*InCol/BYTEINCOLS, (PSEL) &InGrid, 0)) /* from here on use anerror() to report errors */ anerror ("Error allocating memory", 1); (long) InGrid *= 0x10000L; /* move selector to high word*/ /* allocate a segment to hold second buffer used in stepping */ - if (DOSALLOCSEG(InRow*InCol/BYTEINCOLS, (unsigned far *) &InGrid2, 0)) + if (DosAllocSeg(InRow*InCol/BYTEINCOLS, (PSEL) &InGrid2, 0)) anerror ("Error allocating memory", 1); (long) InGrid2 *= 0x10000L; /* move selector to high word*/ @@ -222,32 +219,31 @@ main () { /* main input loop, polling mouse and keyboard */ while (1) { /* try to get mouse event from keyboard or mouse */ - kbd.char_code=0; /* clear key buffer residue */ + kbd.chChar=0; /* clear key buffer residue */ kbdreadeventque (&event, ptrrow, ptrcol); if (Mouse) - MOUREADEVENTQUE ((struct EventInfo far *) &event, - (unsigned far *) &type, Mouse); + MouReadEventQue (&event, &type, Mouse); /* if any mouse-like events, do this */ - if (event.Mask) { + if (event.fs) { xorptr (ptrrow, ptrcol); /* hide cursor */ - if (event.Mask & 1+2+8) { /* if any motion */ + if (event.fs & 1+2+8) { /* if any motion */ /* update position, if off screen grid,ptr=max or min*/ - ptrrow = event.Row; - ptrcol = event.Col; + ptrrow = event.row; + ptrcol = event.col; if (ptrrow > MouBoundRow) ptrrow = MouBoundRow; if (ptrcol > MouBoundCol) ptrcol = MouBoundCol; } /* if a button was hit */ - if (event.Mask & (2|4|8|16)) { + if (event.fs & (2|4|8|16)) { if (ptrrow < COM_ROW*FONT_ROW-SizeScrRow) { /* if on grid */ Generation=0; /* reset Gen if */ putgen(); /* grid modified*/ - if (event.Mask & (2 | 4)) /* if left down*/ + if (event.fs & (2 | 4)) /* if left down*/ fill (ptrcol/SizeScrCol, ptrrow/SizeScrRow); - else if (event.Mask & (8 | 16)) /* if right */ + else if (event.fs & (8 | 16)) /* if right */ remove (ptrcol/SizeScrCol, ptrrow/SizeScrRow); } else { /* on command line*/ @@ -267,13 +263,13 @@ main () { } /* check keys, no wait */ - KBDPEEK ((struct KeyData far *) &kbd, 0); - if (kbd.char_code) { /* get key only if not regular char */ - KBDCHARIN ((struct KeyData far *) &kbd, 1, 0); /*get command*/ + KbdPeek (&kbd, 0); + if (kbd.chChar) { /* get key only if not regular char */ + KbdCharIn (&kbd, 1, 0); /*get command*/ xorptr (ptrrow, ptrcol); /* avoid overwrites */ /* walk command structure and execute function, highlighting */ for(i=0; ComLine[i].Fun != 0; i++) - if ((kbd.char_code & 0xdf) == *(ComLine[i].Name)) { + if ((kbd.chChar & 0xdf) == *(ComLine[i].Name)) { gputs(ComLine[i].Name,COM_ROW,ComLine[i].Col,0xff); (*(ComLine[i].Fun))(); if (ComLine[i].Fun) /*restore name if not removed*/ @@ -338,17 +334,17 @@ blank (){ */ void go () { - struct KeyData kbd; /* return from KBD call */ - int background=0; /* 0 if forground, 1 backgrd */ - struct EventInfo event; /* return from mouse read */ - int type=0; /* for no waits on mouse read*/ - struct QueInfo num; /* return for GetNumQueEl */ - unsigned x,y; /* for slowing down loops */ + KBDKEYINFO kbd; /* return from KBD call */ + int background=0; /* 0 if forground, 1 backgrd */ + MOUEVENTINFO event; /* return from mouse read */ + USHORT type=0; /* for no waits on mouse read*/ + MOUQUEINFO num; /* return for GetNumQueEl */ + unsigned x,y; /* for slowing down loops */ /* step until key or button is hit, executing GoAble commands */ - kbd.scan_code=0; - event.Mask=0; - while (!kbd.scan_code) { + kbd.chScan=0; + event.fs=0; + while (!kbd.chScan) { if (step ()) background=1; else if (background==1) { @@ -357,11 +353,10 @@ go () { } if (Mouse) { /* read all events on que */ - MOUGETNUMQUEEL ((struct QueInfo far *) &num, Mouse); - while (num.Events--) { - MOUREADEVENTQUE ((struct EventInfo far *) &event, - (unsigned far *) &type, Mouse); - if (event.Mask & (2|4|8|16)) { /* leave if mouse hit*/ + MouGetNumQueEl (&num, Mouse); + while (num.cEvents--) { + MouReadEventQue (&event, &type, Mouse); + if (event.fs & (2|4|8|16)) { /* leave if mouse hit*/ wait4release(); return; } @@ -369,15 +364,15 @@ go () { } /* check keys, no wait. Execute if GoAble command */ - KBDPEEK ((struct KeyData far *) &kbd, 0); - if (kbd.scan_code) { + KbdPeek (&kbd, 0); + if (kbd.chScan) { /* walk command structure and execute function, highlighting */ for(x=0; ComLine[x].Fun != 0; x++) - if ((kbd.char_code & 0xdf) == *(ComLine[x].Name) + if ((kbd.chChar & 0xdf) == *(ComLine[x].Name) && ComLine[x].GoAble) { gputs(ComLine[x].Name,COM_ROW,ComLine[x].Col,0xff); - KBDCHARIN ((struct KeyData far *) &kbd, 1, 0); - kbd.scan_code=0; + KbdCharIn (&kbd, 1, 0); + kbd.chScan=0; (*(ComLine[x].Fun))(); if (ComLine[x].Fun) /*restore name if not removed*/ gputs(ComLine[x].Name,COM_ROW,ComLine[x].Col,0); @@ -442,8 +437,8 @@ quit () { */ void diskread () { - unsigned handle; /* file handle */ - unsigned action; /* return for file calls */ + HFILE handle; /* file handle */ + USHORT action; /* return for file calls */ unsigned signature; /* life file signature word */ /* get file name into Filespec */ @@ -451,51 +446,51 @@ diskread () { return; /* return if user hit ESC */ /* open file, fail if it doesn't exist */ - if (DOSOPEN ((char far *) Filespec, (unsigned far *) &handle, - (unsigned far *) &action, 0L, 0, 0x01, 0x42, 0L)) { + if (DosOpen ((PSZ) Filespec, &handle, + &action, 0L, 0, 0x01, 0x42, 0L)) { anerror ("Can't open file", 0); Filespec[0]=0; /* clear bad file name */ return; } /* read appropriate from file */ - if (DOSREAD (handle, (char far *) &signature, sizeof (signature), - (unsigned far *) &action) || action != sizeof (signature)) + if (DosRead (handle, (PSZ) &signature, sizeof (signature), + &action) || action != sizeof (signature)) anerror ("Error writing to file", 0); else if (signature != SIGNATURE) { anerror ("Not a life file", 0); - if (DOSCLOSE (handle)) + if (DosClose (handle)) anerror ("Error closing file", 0); return; } - else if (DOSREAD (handle, (char far *) &InRow, sizeof (InRow), - (unsigned far *) &action) || action != sizeof (InRow)) + else if (DosRead (handle, (PSZ) &InRow, sizeof (InRow), + &action) || action != sizeof (InRow)) anerror ("Error reading from file", 0); - else if (DOSREAD (handle, (char far *) &InCol, sizeof (InCol), - (unsigned far *) &action) || action != sizeof (InCol)) + else if (DosRead (handle, (PSZ) &InCol, sizeof (InCol), + &action) || action != sizeof (InCol)) anerror ("Error reading from file", 0); - else if (DOSREAD (handle, (char far *) &Generation, - sizeof (Generation), (unsigned far *) &action) || + else if (DosRead (handle, (PSZ) &Generation, + sizeof (Generation), &action) || action != sizeof (Generation)) anerror ("Error reading from file", 0); /* change size of *InGrid to match saved pattern */ - else if (DOSREALLOCSEG (InRow*InCol/BYTEINCOLS, (unsigned) + else if (DosReallocSeg (InRow*InCol/BYTEINCOLS, (unsigned) ((long) InGrid/0x10000L))) anerror ("Error allocating memory", 0); - else if (DOSREAD (handle, InGrid, InRow*InCol/BYTEINCOLS, - (unsigned far *) &action) || action != InRow*InCol/BYTEINCOLS) + else if (DosRead (handle, InGrid, InRow*InCol/BYTEINCOLS, + &action) || action != InRow*InCol/BYTEINCOLS) anerror ("Error reading from file", 0); /* show the newly loaded pattern on the screen */ showingrid (); /* close file */ - if (DOSCLOSE (handle)) + if (DosClose (handle)) anerror ("Error closing file", 0); } @@ -549,8 +544,8 @@ step() { */ void diskwrite () { - unsigned handle; /* file handle */ - unsigned action; /* return for file calls */ + HFILE handle; /* file handle */ + USHORT action; /* return for file calls */ unsigned signature=SIGNATURE; /* life file signature word */ /* get file name into Filespec */ @@ -558,37 +553,37 @@ diskwrite () { return; /* return if user hit ESC */ /* open file and truncate or create it if it doesn't exist */ - if (DOSOPEN ((char far *) Filespec, (unsigned far *) &handle, - (unsigned far *) &action, 0L, 0, 0x12, 0x42, 0L)) { + if (DosOpen ((PSZ) Filespec, &handle, + &action, 0L, 0, 0x12, 0x42, 0L)) { anerror ("Can't open file", 0); Filespec[0]=0; /* clear bad file name */ return; } /* write appropriate info to file */ - if (DOSWRITE (handle, (char far *) &signature, sizeof (signature), - (unsigned far *) &action) || action != sizeof (signature)) + if (DosWrite (handle, (PSZ) &signature, sizeof (signature), + &action) || action != sizeof (signature)) anerror ("Error writing to file", 0); - else if (DOSWRITE (handle, (char far *) &InRow, sizeof (InRow), - (unsigned far *) &action) || action != sizeof (InRow)) + else if (DosWrite (handle, (PSZ) &InRow, sizeof (InRow), + &action) || action != sizeof (InRow)) anerror ("Error writing to file", 0); - else if (DOSWRITE (handle, (char far *) &InCol, sizeof (InCol), - (unsigned far *) &action) || action != sizeof (InCol)) + else if (DosWrite (handle, (PSZ) &InCol, sizeof (InCol), + &action) || action != sizeof (InCol)) anerror ("Error writing to file", 0); - else if (DOSWRITE (handle, (char far *) &Generation, - sizeof (Generation), (unsigned far *) &action) || + else if (DosWrite (handle, (PSZ) &Generation, + sizeof (Generation), &action) || action != sizeof (Generation)) anerror ("Error writing to file", 0); - else if (DOSWRITE (handle, InGrid, InRow*InCol/BYTEINCOLS, - (unsigned far *) &action) || action != InRow*InCol/BYTEINCOLS) + else if (DosWrite (handle, InGrid, InRow*InCol/BYTEINCOLS, + &action) || action != InRow*InCol/BYTEINCOLS) anerror ("Error writing to file", 0); /* close file */ - if (DOSCLOSE (handle)) + if (DosClose (handle)) anerror ("Error closing file", 0); } @@ -632,7 +627,7 @@ down() { */ void beep () { - DOSBEEP (500, 50); + DosBeep (500, 50); } @@ -654,7 +649,7 @@ beep () { void showingrid () { int x, y; /* cell coordinates for loop */ - char retcode; /* for VIOSCRLOCK */ + BYTE retcode; /* for VIOSCRLOCK */ /* prepare blank screen so we only have to fill in cells that are on */ draw_grid (); /* draw blank grid on screen */ @@ -665,13 +660,13 @@ showingrid () { putgen (); /* loop through the screen sized area of the grid */ - VIOSCRLOCK (1, (char far *) &retcode, 0); /* get screen access */ + VioScrLock (1, &retcode, 0); /* get screen access */ for (y=ScrRow; y--;) for (x=ScrCol; x--;) /* if the internal cell is on, turn on the screen one*/ if (*(InGrid + (x + y*InCol)/BYTEINCOLS) & (0x80 >> (x&7))) fill (x, y); - VIOSCRUNLOCK (0); + VioScrUnLock (0); } @@ -694,38 +689,37 @@ showingrid () { */ int getfilespec () { - int c=0; /* index for Filespec[] */ - struct KeyData kbd; /* return for KBD call */ - unsigned space=0x0020; /* space character for print */ - struct EventInfo event; /* return for mouse */ - int type=0; /* mouse reads w/no wait */ + int c=0; /* index for Filespec[] */ + KBDKEYINFO kbd; /* return for KBD call */ + unsigned space=0x0020; /* space character for print */ + MOUEVENTINFO event; /* return for mouse */ + USHORT type=0; /* mouse reads w/no wait */ - kbd.scan_code=0; - event.Mask=0; + kbd.chScan=0; + event.fs=0; /* put up default file name if one exists */ if (Filespec[0]) { gputs ("Type file name or enter for default: ", PROMPT_ROW, PROMPT_COL,0); gputs (Filespec, PROMPT_ROW, FILE_COL, 0); /* wait for first key or button to see if they accept default */ - while (!kbd.scan_code && !(event.Mask & (2|4|8|16))) { + while (!kbd.chScan && !(event.fs & (2|4|8|16))) { if (Mouse) - MOUREADEVENTQUE ((struct EventInfo far *) &event, - (unsigned far *) &type, Mouse); - KBDPEEK ((struct KeyData far *) &kbd, 0); + MouReadEventQue (&event, &type, Mouse); + KbdPeek (&kbd, 0); } } - if (event.Mask & (8 | 16)) { /* if right button hit, same as ESC */ - kbd.char_code = 0x1b; + if (event.fs & (8 | 16)) { /* if right button hit, same as ESC */ + kbd.chChar = 0x1b; wait4release(); } - if (event.Mask & (2 | 4)) { /* if left button hit, same as \r */ + if (event.fs & (2 | 4)) { /* if left button hit, same as \r */ wait4release(); gputs (Logo, PROMPT_ROW, PROMPT_COL, 0); putgen(); return (0); } - if (kbd.char_code == 0x1b) { /* if ESC, return */ + if (kbd.chChar == 0x1b) { /* if ESC, return */ gputs (Logo, PROMPT_ROW, PROMPT_COL, 0); putgen(); return (0x1b); /* return escape */ @@ -735,9 +729,9 @@ getfilespec () { gputs("Type file name, followed by enter: ",PROMPT_ROW,PROMPT_COL,0); /* read chars and print them until \r */ - while (!(KBDCHARIN ((struct KeyData far *) &kbd, 0, 0)) && - kbd.char_code != '\r') { - if (kbd.char_code == '\b') { /* if backspace, backspace */ + while (!(KbdCharIn (&kbd, 0, 0)) && + kbd.chChar != '\r') { + if (kbd.chChar == '\b') { /* if backspace, backspace */ if (c > 0) { /* prevent underflow*/ Filespec[--c]=0; /* erase backed-out character*/ @@ -746,17 +740,17 @@ getfilespec () { else /* if overflow, yell */ beep(); } - else if (kbd.char_code == 0x1b) { /* if escape was hit */ + else if (kbd.chChar == 0x1b) { /* if escape was hit */ Filespec[0]=0; /* blank name */ gputs (Logo, PROMPT_ROW, PROMPT_COL, 0); putgen(); return (0x1b); /* return escape */ } - else if (kbd.char_code <46 || kbd.char_code > 122) + else if (kbd.chChar <46 || kbd.chChar > 122) beep(); /* if not char, beep */ else if (c < sizeof (Filespec)) { /* prevent overflow */ - Filespec[c]=kbd.char_code; /* add to string */ + Filespec[c]=kbd.chChar; /* add to string */ Filespec[++c]=0; /* null terminal */ } else /* if overflow, yell */ @@ -880,7 +874,7 @@ int x,y; * F9 key is responded to as left button, F10 key as right. * Pointer location is advanced by SizeScrCol or SizeScrRow according * to direction of direction key hits. - * Does not wait for input, instead returns 0 event mask. + * Does not wait for input, instead returns 0 event fs. * Does not check MouDevStatus, instead always returns pixel coordinates * Event buffer is filled according to MouReadEventQue * @@ -893,57 +887,57 @@ int x,y; */ int kbdreadeventque (event, ptrrow, ptrcol) -struct EventInfo *event; +MOUEVENTINFO *event; int ptrrow, ptrcol; { - struct KeyData kbd; /* return for KBD call */ + KBDKEYINFO kbd; /* return for KBD call */ - kbd.char_code=0; /* clear data struct residue*/ - kbd.scan_code=0; + kbd.chChar=0; /* clear data struct residue*/ + kbd.chScan=0; /* peek at key buffer */ - KBDPEEK ((struct KeyData far *) &kbd, 0); + KbdPeek (&kbd, 0); /* if it is an extended key code, process it */ - if (kbd.char_code == 0 && kbd.scan_code) { - KBDCHARIN ((struct KeyData far *) &kbd, 1, 0); /* take char */ - event->Row=ptrrow; /* initial position */ - event->Col=ptrcol; - switch (kbd.scan_code) { /* check second byte of code */ + if (kbd.chChar == 0 && kbd.chScan) { + KbdCharIn (&kbd, 1, 0); /* take char */ + event->row=ptrrow; /* initial position */ + event->col=ptrcol; + switch (kbd.chScan) { /* check second byte of code */ case 0x48: /* cursor up */ - event->Row -= SizeScrRow; - event->Mask=1; + event->row -= SizeScrRow; + event->fs=1; break; case 0x50: /* cursor down */ - event->Row += SizeScrRow; - event->Mask=1; + event->row += SizeScrRow; + event->fs=1; break; case 0x4b: /* cursor left */ - event->Col -= SizeScrCol; - event->Mask=1; + event->col -= SizeScrCol; + event->fs=1; break; case 0x4d: /* cursor right */ - event->Col += SizeScrCol; - event->Mask=1; + event->col += SizeScrCol; + event->fs=1; break; case 0x43: /* left button (F9) */ - event->Mask=4; + event->fs=4; break; case 0x52: /* left button (INS) */ - event->Mask=4; + event->fs=4; break; case 0x44: /* right button (F10) */ - event->Mask=16; + event->fs=16; break; case 0x53: /* right button (DEL) */ - event->Mask=16; + event->fs=16; break; default: /* anything else is no good */ - event->Mask=0; + event->fs=0; break; } } else - event->Mask=0; /* if no extended key */ + event->fs=0; /* if no extended key */ } @@ -962,9 +956,9 @@ xorptr (ptrrow, ptrcol) unsigned ptrrow, ptrcol; { char far *gridptr; - unsigned mask=0; /* bit mask for pointer shape*/ - int x=8; /* count for rows of pointer */ - char retcode; /* return from VioScrLock */ + unsigned mask=0; /* bit mask for pointer shape*/ + int x=8; /* count for rows of pointer */ + BYTE retcode; /* return from VioScrLock */ /* set gridptr to & in screen buff to xor */ ptrrow++; /* 1st move ptr to next row*/ @@ -972,7 +966,7 @@ unsigned ptrrow, ptrcol; (unsigned) gridptr = ptrcol/x+(ptrrow/Cga*SCR_WID);/* fill offset*/ /* fill in screen pointer */ - VIOSCRLOCK (1, (char far *) &retcode, 0); /* get screen */ + VioScrLock (1, &retcode, 0); /* get screen */ while (x--) { mask = mask >> 1; /* make mask thicker */ mask |= 0x8000; /* at bottom */ @@ -987,7 +981,7 @@ unsigned ptrrow, ptrcol; if (!(ptrrow & 1) && Cga == 2) /*only advance on odd*/ gridptr += SCR_WID; /* row w/o CGA */ } - VIOSCRUNLOCK (0); /* give back screen */ + VioScrUnLock (0); /* give back screen */ } @@ -1018,26 +1012,27 @@ char *string; unsigned col, row; char mask; { - static struct VIOFONT fontdata = {14,1,FONT_ROW,8,0L,0};/*for GetFont*/ + static VIOFONTINFO fontdata = {14,1,FONT_ROW,8,0L,0};/*for GetFont*/ char c; - char retcode; /* for VIOSCRLOCK */ + BYTE retcode; /* for VioScrLock */ char far *scr_addr; /* address in screen buffer to print at */ /* try lock without waiting for availability */ - VIOSCRLOCK (0, (char far *) &retcode, 0); /* get screen access */ + VioScrLock (0, &retcode, 0); /* get screen access */ /* do display only if screen available now */ if (retcode == 0) { /* get address of font table if haven't yet */ - if (!fontdata.font_data) - VIOGETFONT ((struct VIOFONT far *) &fontdata, 0); + if (!fontdata.pbData) + VioGetFont (&fontdata, 0); (long) scr_addr = ScrSeg*0x10000; /* fill in segment address*/ (unsigned)scr_addr = col+(row*SCR_WID*(FONT_ROW/Cga));/*offset*/ while ((c=*(string++)) != 0) /* print each char */ - gputchar(scr_addr++, fontdata.font_data+c*FONT_ROW,mask); - VIOSCRUNLOCK (0); /* give up screen */ + gputchar(scr_addr++, + (ULONG)fontdata.pbData+c*FONT_ROW,mask); + VioScrUnLock (0); /* give up screen */ } } @@ -1050,7 +1045,7 @@ char mask; * must be on even Cga bit plane * font_addr - far address in font table bit pattern * mask - xor'ed with each byte put on screen - * VIOSCRLOCK is active + * VioScrLock is active * * Exit: None */ @@ -1096,7 +1091,7 @@ anerror (message, fatal) char message[]; int fatal; { - struct KeyData kbd; /* return for KBD call */ + KBDKEYINFO kbd; /* return for KBD call */ gputs (Logo, PROMPT_ROW, PROMPT_COL,0); gputs (message, PROMPT_ROW, PROMPT_COL, 0);/* print passed message */ @@ -1125,27 +1120,26 @@ int fatal; */ char gethit () { - struct KeyData kbd; /* for keyboard */ - struct EventInfo event; /* for mouse */ - int type=0; - char rc; /* return code */ + KBDKEYINFO kbd; /* for keyboard */ + MOUEVENTINFO event; /* for mouse */ + USHORT type=0; + char rc; /* return code */ /* loop till a hit */ - kbd.scan_code=0; - event.Mask=0; - while (!kbd.scan_code && !(event.Mask & (2|4|8|16))) { + kbd.chScan=0; + event.fs=0; + while (!kbd.chScan && !(event.fs & (2|4|8|16))) { if (Mouse) - MOUREADEVENTQUE ((struct EventInfo far *) &event, - (unsigned far *) &type, Mouse); - KBDCHARIN ((struct KeyData far *) &kbd, 1, 0); - } - if (kbd.scan_code) /* if key, return char */ - rc=kbd.char_code & 0xdf; - else if (event.Mask & (8 | 16)) { /* if right */ + MouReadEventQue (&event, &type, Mouse); + KbdCharIn (&kbd, 1, 0); + } + if (kbd.chScan) /* if key, return char */ + rc=kbd.chChar & 0xdf; + else if (event.fs & (8 | 16)) { /* if right */ rc='N'; wait4release (); } - else if (event.Mask & (2 | 4)) { /* if left down*/ + else if (event.fs & (2 | 4)) { /* if left down*/ rc='Y'; wait4release (); } @@ -1159,14 +1153,14 @@ gethit () { */ void wait4release () { - struct EventInfo event; - unsigned type = 0; /* if OS/2, wait for events */ + MOUEVENTINFO event; + USHORT type = 0; /* if OS/2, wait for events */ - event.Mask=2; /* force 1st read */ + event.fs=2; /* force 1st read */ if (Mouse) /* loop till no button events */ - while ((event.Mask & (2|4|8|16)) || event.Time==0) - MOUREADEVENTQUE ((struct EventInfo far *) &event, - (unsigned far *) &type, Mouse); + while ((event.fs & (2|4|8|16)) || event.Time==0) + MouReadEventQue (&event, &type, Mouse); + } @@ -1180,8 +1174,8 @@ wait4release () { */ void far pascal exitlife() { - VIOSETMODE ((struct ModeData far *) &Savemode, 0); /* restore*/ - VIOSCROLLUP (0,0,-1,-1,-1, (char far *) Cell,0); /* cls */ - DOSEXIT (1, 0); /* exit all threads */ + VioSetMode (&Savemode, 0); /* restore*/ + VioScrollUp (0,0,-1,-1,-1, (char far *) Cell,0); /* cls */ + DosExit (EXIT_PROCESS, 0); /* exit all threads */ }