home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BSRC_250.LZH / VFOSSIL.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  8KB  |  259 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*           This module was originally written by Bob Hartman              */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*                       BinkleyTerm VFOSSIL module                         */
  17. /*                                                                          */
  18. /*                                                                          */
  19. /*    For complete  details  of the licensing restrictions, please refer    */
  20. /*    to the License  agreement,  which  is published in its entirety in    */
  21. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.250.    */
  22. /*                                                                          */
  23. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  24. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  25. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  26. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  27. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  28. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  29. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  30. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  31. /*                                                                          */
  32. /*                                                                          */
  33. /* You can contact Bit Bucket Software Co. at any one of the following      */
  34. /* addresses:                                                               */
  35. /*                                                                          */
  36. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  37. /* P.O. Box 460398                AlterNet 7:491/0                          */
  38. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  39. /*                                Internet f491.n343.z1.fidonet.org         */
  40. /*                                                                          */
  41. /* Please feel free to contact us at any time to share your comments about  */
  42. /* our software and/or licensing policies.                                  */
  43. /*                                                                          */
  44. /*--------------------------------------------------------------------------*/
  45.  
  46. /* Include this file before any other includes or defines! */
  47.  
  48. #include "includes.h"
  49.  
  50. extern VIOMODEINFO vfos_mode;
  51.  
  52. #ifdef OS_2
  53. /*PLF Fri  05-05-1989  05:35:11 OS/2 version notes:
  54.  *
  55.  * I have basically made this two completely different versions. A lot
  56.  * of the original real mode version deals with the case when vfossil
  57.  * does not exist. Under OS/2, it is always active.
  58.  *
  59.  */
  60.  
  61. extern int vfossil_installed;
  62.  
  63. void vfossil_init (void)
  64. {
  65.    PVIOMODEINFO q;
  66.  
  67.    vfossil_installed = 1;
  68.    q = (PVIOMODEINFO) &vfos_mode;
  69.    vfos_mode.cb = sizeof (VIOMODEINFO);
  70.    VioGetMode (q, 0);
  71.    VioSetAnsi (ANSI_ON, 0);
  72. }
  73.  
  74. void vfossil_cursor (int st)
  75. {
  76.    VIOCURSORINFO   cur;
  77.  
  78.    VioGetCurType (&cur, 0);
  79.    cur.attr = st ? 0 : -1;
  80.    VioSetCurType (&cur, 0);
  81. }
  82.  
  83. void vfossil_close (void)
  84. {
  85.    vfossil_cursor (1);
  86.    vfossil_installed = 0;
  87. }
  88.  
  89. void fossil_gotoxy (int col, int row)
  90. {
  91.      VioSetCurPos ((USHORT) row, (USHORT) col, 0);
  92. }
  93.  
  94. int fossil_wherex (void)
  95. {
  96.    USHORT row, col;
  97.  
  98.    VioGetCurPos ((PUSHORT) &row, (PUSHORT) &col, 0);
  99.    return (col);
  100. }
  101.  
  102. int fossil_wherey (void)
  103. {
  104.    USHORT row, col;
  105.  
  106.    VioGetCurPos ((PUSHORT) &row, (PUSHORT) &col, 0);
  107.    return (row);
  108. }
  109.  
  110. #else   /* ifdef OS_2 */
  111.  
  112. unsigned int far pascal write_screen (PCH, unsigned int, unsigned int, unsigned int, unsigned int);
  113. unsigned int far pascal write_chars (char far *, unsigned int, unsigned int, unsigned int, unsigned int);
  114. unsigned int far pascal video_mode (PVIOMODEINFO, unsigned int);
  115.  
  116. void vfossil_init ()
  117. {
  118. #ifndef MILQ
  119.  
  120.    char far *q;
  121.    union REGS inregs, outregs;
  122.    struct SREGS s;
  123.    VFOSSIL v;
  124.  
  125.    v.vfossil_size = sizeof (VFOSSIL);
  126.    q = (char far *) &v;
  127.  
  128.    vfossil_installed = 0;
  129.  
  130.    inregs.h.ah = 0x81;
  131.    inregs.h.al = 0;
  132.  
  133.    segread (&s);
  134.    s.es = FP_SEG (q);
  135.    inregs.x.di = FP_OFF (q);
  136.    (void) int86x (0x14, &inregs, &outregs, &s);
  137.  
  138.    if (outregs.x.ax == 0x1954)
  139.       {
  140.       /* There is a VFOSSIL out there, so set it up for use */
  141.       inregs.h.al = 1;
  142.       inregs.x.cx = 80;
  143.       q = (char far *) &vfossil_funcs;
  144.       inregs.x.di = FP_OFF (q);
  145.       s.es = FP_SEG (q);
  146.       (void) int86x (0x14, &inregs, &outregs, &s);
  147.       if ((outregs.x.ax == 0x1954) && (outregs.x.bx >= 14))
  148.          {
  149.          /* It is really out there */
  150.          vfossil_installed = 1;
  151.          q = (char far *) &vfos_mode;
  152.          vfos_mode.cb = sizeof (VIOMODEINFO);
  153.          (void) VioGetMode ((PVIOMODEINFO) q, 0);
  154.          }
  155.       }
  156.  
  157.    if (!vfossil_installed)
  158.       {
  159.       (void) memset ((char *) &vfossil_funcs, 0, sizeof (vfossil_funcs));
  160.       vfossil_funcs.GetMode    = video_mode;
  161.       vfossil_funcs.WrtCellStr = write_screen;
  162.       vfossil_funcs.WrtCharStr = write_chars;
  163.       }
  164. #endif
  165.  
  166. }
  167.  
  168. void vfossil_cursor (int st)
  169. {
  170.    CURSOR cur;
  171.  
  172.    if ((long) vfossil_funcs.GetCurType)
  173.       {
  174.       /* We can make the cursor go away */
  175.       (void) VioGetCurType (&cur, 0);
  176.       cur.cur_attr = st ? 0 : -1;
  177.       (void) VioSetCurType (&cur, 0);
  178.       }
  179. }
  180.  
  181. void vfossil_close ()
  182. {
  183.    union REGS r;
  184.  
  185.    vfossil_cursor (1);
  186.  
  187.    r.h.ah = 0x81;
  188.    r.h.al = 2;
  189.  
  190.    (void) int86 (0x14, &r, &r);
  191.  
  192.    vfossil_installed = 0;
  193. }
  194.  
  195. unsigned int far pascal video_mode (PVIOMODEINFO s, unsigned int h)
  196. {
  197.    if (s->cb < 8)
  198.       {
  199.       return (382);
  200.       }
  201.  
  202.    if (h != 0)
  203.       {
  204.       return (436);
  205.       }
  206.  
  207.    s->fbType = 1;
  208.    s->color  = 1;
  209.    s->col    = 80;
  210.    s->row    = 23;
  211.    return (0);
  212. }
  213.  
  214. #ifndef MILQ
  215.  
  216. unsigned int far pascal write_screen (PCH s, unsigned int l, 
  217.                               unsigned int r, unsigned int c, unsigned int h)
  218. {
  219.    unsigned int i;
  220.    int far *p;
  221.  
  222.    p = (int far *)s;
  223.  
  224.    /* The following line is just to make -W3 happy */
  225.    i = h;
  226.  
  227.    gotoxy (c, r);
  228.  
  229.    l = l / 2;
  230.    for (i = 0; i < l; i++)
  231.       {
  232.       (void) WRITE_BIOS (*p);
  233.       ++p;
  234.       }
  235.  
  236.    return (0);
  237. }
  238.  
  239. unsigned int far pascal write_chars (char far *s, unsigned int l, 
  240.                               unsigned int r, unsigned int c, unsigned int h)
  241. {
  242.    unsigned int i;
  243.  
  244.    /* The following line is just to make -W3 happy */
  245.    i = h;
  246.  
  247.    gotoxy (c, r);
  248.  
  249.    for (i = 0; i < l; i++)
  250.       {
  251.       (void) WRITE_BIOS (*s);
  252.       ++s;
  253.       }
  254.  
  255.    return (0);
  256. }
  257. #endif          /*defined MILQ */
  258. #endif          /*defined OS_2 */
  259.