home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / EMXLIB8F.ZIP / EMX / LIB / VIDEO / VINIT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-02  |  1.5 KB  |  78 lines

  1. /* vinit.c (emx+gcc) -- Copyright (c) 1987-1993 by Eberhard Mattes */
  2.  
  3. #include <stdlib.h>
  4. #include <dos.h>
  5. #include <sys/hw.h>
  6. #define INCL_VIO
  7. #include <os2emx.h>
  8. #include <os2thunk.h>
  9. #include <sys/video.h>
  10. #include "video2.h"
  11.  
  12. int _v_width = 0;
  13. int _v_height = 0;
  14. int _v_x = 0;
  15. int _v_y = 0;
  16. int _v_attr = 0x07;
  17. char *_v_mem = NULL;
  18.  
  19. static void _v_getxy (int *x, int *y)
  20. {
  21.   if (_osmode == OS2_MODE)
  22.     {
  23.       USHORT row, col;
  24.  
  25.       VioGetCurPos (&row, &col, 0);
  26.       *x = col; *y = row;
  27.     }
  28.   else
  29.     {
  30.       union REGS r;
  31.  
  32.       r.h.ah = 0x03;
  33.       r.h.bh = 0x00;
  34.       _int86 (0x10, &r, &r);
  35.       *x = r.h.dl; *y = r.h.dh;
  36.     }
  37. }
  38.  
  39.  
  40. int v_init (void)
  41. {
  42.   int two[2];
  43.   unsigned addr, end_addr;
  44.  
  45.   _scrsize (two);
  46.   _v_width = two[0];
  47.   _v_height = two[1];
  48.   _v_getxy (&_v_x, &_v_y);
  49.   _v_mem = NULL;
  50.   if (_osmode == OS2_MODE)
  51.     {
  52.       _far16ptr addr;
  53.       USHORT len;
  54.  
  55.       len = _v_width * _v_height * 2;
  56.       if (VioGetBuf ((PULONG)&addr, &len, 0) == 0)
  57.         _v_mem = MAKEP (SELECTOROF (addr), OFFSETOF (addr));
  58.     }
  59.   else
  60.     {
  61.       union REGS r;
  62.  
  63.       r.h.ah = 0x0f;
  64.       _int86 (0x10, &r, &r);
  65.       if (r.h.al == 7 || r.h.al < 4)
  66.         {
  67.           _int86 (0x11, &r, &r);
  68.           if ((r.h.al & 0x30) == 0x30)
  69.             addr = 0xb0000;
  70.           else
  71.             addr = 0xb8000;
  72.           end_addr = (addr + _v_height * _v_width * 2 - 1) | 0xfff;
  73.           _v_mem = _memaccess (addr, end_addr, 1);
  74.         }
  75.     }
  76.   return (1);
  77. }
  78.