home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BTMTSRC3.ZIP / VFOSSIL.C < prev    next >
Text File  |  1990-07-11  |  8KB  |  293 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-90, 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.240.    */
  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:132/491, 1:141/491  */
  37. /* P.O. Box 460398                AlterNet 7:491/0                          */
  38. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  39. /*                                Internet f491.n132.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 <stdio.h>
  47. #include <dos.h>
  48. #ifdef __TURBOC__
  49. #include <mem.h>
  50. #else
  51. #include <memory.h>
  52. #endif
  53.  
  54. #include "vfossil.h"
  55. #include "com.h"
  56. #include "xfer.h"
  57. #include "zmodem.h"
  58. #include "keybd.h"
  59. #include "sbuf.h"
  60. #include "sched.h"
  61. #include "externs.h"
  62. #include "prototyp.h"
  63.  
  64.  
  65. extern VIOMODEINFO vfos_mode;
  66.  
  67. #ifdef OS_2
  68. /*PLF Fri  05-05-1989  05:35:11 OS/2 version notes:
  69.  *
  70.  * I have basically made this two completely different versions. A lot
  71.  * of the original real mode version deals with the case when vfossil
  72.  * does not exist. Under OS/2, it is always active.
  73.  *
  74.  */
  75.  
  76. extern int vfossil_installed;
  77.  
  78. void vfossil_init (void)
  79. {
  80.    PVIOMODEINFO q;
  81.  
  82.    vfossil_installed = 1;
  83.    q = (PVIOMODEINFO) &vfos_mode;
  84.    vfos_mode.cb = sizeof (VIOMODEINFO);
  85.    VioGetMode (q, 0L);
  86.    VioSetAnsi (ANSI_ON, 0L);
  87. }
  88.  
  89. void vfossil_cursor (int st)
  90. {
  91.    VIOCURSORINFO   cur;
  92.  
  93.    VioGetCurType (&cur, 0);
  94.    cur.attr = st ? 0 : -1;
  95.    VioSetCurType (&cur, 0);
  96. }
  97.  
  98. void vfossil_close (void)
  99. {
  100.    vfossil_cursor (1);
  101.    vfossil_installed = 0;
  102. }
  103.  
  104. void fossil_gotoxy (int col, int row)
  105. {
  106.      VioSetCurPos ((USHORT) row, (USHORT) col, 0);
  107. }
  108.  
  109. int fossil_wherex (void)
  110. {
  111.    USHORT row, col;
  112.  
  113.    VioGetCurPos ((PUSHORT) &row, (PUSHORT) &col, 0L);
  114.    return (col);
  115. }
  116.  
  117. int fossil_wherey (void)
  118. {
  119.    USHORT row, col;
  120.  
  121.    VioGetCurPos ((PUSHORT) &row, (PUSHORT) &col, 0L);
  122.    return (row);
  123. }
  124.  
  125. #else   /* ifdef OS_2 */
  126.  
  127. static int far pascal write_screen (unsigned int far *, unsigned int, unsigned int, unsigned int, unsigned int);
  128. static int far pascal write_chars (char far *, unsigned int, unsigned int, unsigned int, unsigned int);
  129. static int far pascal video_mode (PVIOMODEINFO, unsigned int);
  130.  
  131. static void vfossil_open (void);
  132.  
  133. static VFOSSIL v;
  134.  
  135. void vfossil_init ()
  136. {
  137.    char far *q;
  138.    union REGS r;
  139.    struct SREGS s;
  140.  
  141.    v.vfossil_size = sizeof (VFOSSIL);
  142.    q = (char far *) &v;
  143.  
  144.    r.h.ah = 0x81;
  145.    r.h.al = 0;
  146.  
  147.    segread (&s);
  148.    s.es = FP_SEG (q);
  149.    r.x.di = FP_OFF (q);
  150.    (void) int86x (0x14, &r, &r, &s);
  151.  
  152.    vfossil_installed = 0;
  153.  
  154.    if (r.x.ax == 0x1954)
  155.       {
  156.       /* There is a VFOSSIL out there, so set it up for use */
  157.       vfossil_open ();
  158.       }
  159.  
  160.    if (!vfossil_installed)
  161.       {
  162.       (void) memset ((char *) &vfossil_funcs, 0, sizeof (vfossil_funcs));
  163.       vfossil_funcs.GetMode    = video_mode;
  164.       vfossil_funcs.WrtCellStr = write_screen;
  165.       vfossil_funcs.WrtCharStr = write_chars;
  166.       }
  167.  
  168. }
  169.  
  170. static CURSOR _cursor;
  171.  
  172. void vfossil_cursor (st)
  173. int st;
  174. {
  175.    CURSOR far *q;
  176.  
  177.    if ((long) vfossil_funcs.GetCurType)
  178.       {
  179.       q = (CURSOR far *) &_cursor;
  180.       /* We can make the cursor go away */
  181.       (void) VioGetCurType (q, 0);
  182.       _cursor.cur_attr = st ? 0 : -1;
  183.       (void) VioSetCurType (q, 0);
  184.       }
  185. }
  186.  
  187. static void vfossil_open ()
  188. {
  189.    char far *q;
  190.    union REGS r;
  191.    struct SREGS s;
  192.  
  193.    segread (&s);
  194.    r.h.ah = 0x81;
  195.    r.h.al = 1;
  196.    r.x.cx = 80;
  197.    q = (char far *) &vfossil_funcs;
  198.    r.x.di = FP_OFF (q);
  199.    s.es = FP_SEG (q);
  200.    (void) int86x (0x14, &r, &r, &s);
  201.    if ((r.x.ax == 0x1954) && (r.x.bx >= 14))
  202.       {
  203.       /* It is really out there */
  204.       vfossil_installed = 1;
  205.       q = (char far *) &vfos_mode;
  206.       vfos_mode.cb = sizeof (VIOMODEINFO);
  207.       (void) VioGetMode ((PVIOMODEINFO) q, 0);
  208.       }
  209. }
  210.  
  211. void vfossil_close ()
  212. {
  213.    union REGS r;
  214.  
  215.    vfossil_cursor (1);
  216.  
  217.    r.h.ah = 0x81;
  218.    r.h.al = 2;
  219.  
  220.    (void) int86 (0x14, &r, &r);
  221.  
  222.    vfossil_installed = 0;
  223. }
  224.  
  225. static int far pascal video_mode (s, h)
  226. PVIOMODEINFO s;
  227. unsigned int h;
  228. {
  229.    if (s->cb < 8)
  230.       {
  231.       return (382);
  232.       }
  233.    if (h != 0)
  234.       {
  235.       return (436);
  236.       }
  237.  
  238.    s->fbType = 1;
  239.    s->color  = 1;
  240.    s->col    = 80;
  241.    s->row    = 23;
  242.    return (0);
  243. }
  244.  
  245. static int far pascal write_screen (s, l, r, c, h)
  246. unsigned int far *s;
  247. unsigned int l;
  248. unsigned int r;
  249. unsigned int c;
  250. unsigned int h;
  251. {
  252.    int i;
  253.  
  254.    /* The following line is just to make -W3 happy */
  255.    i = h;
  256.  
  257.    gotoxy (c, r);
  258.  
  259.    l = l / 2;
  260.    for (i = 0; i < l; i++)
  261.       {
  262.       (void) WRITE_BIOS (*s);
  263.       ++s;
  264.       }
  265.  
  266.    return (0);
  267. }
  268.  
  269. static int far pascal write_chars (s, l, r, c, h)
  270. char far *s;
  271. unsigned int l;
  272. unsigned int r;
  273. unsigned int c;
  274. unsigned int h;
  275. {
  276.    int i;
  277.  
  278.    /* The following line is just to make -W3 happy */
  279.    i = h;
  280.  
  281.    gotoxy (c, r);
  282.  
  283.    for (i = 0; i < l; i++)
  284.       {
  285.       (void) WRITE_BIOS (*s);
  286.       ++s;
  287.       }
  288.  
  289.    return (0);
  290. }
  291.  
  292. #endif          /*ifdef OS_2 */
  293.