home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / t / tvgluetc.zip / INT15.C next >
C/C++ Source or Header  |  1988-03-02  |  5KB  |  124 lines

  1. /*
  2. **    INT15.C - C interface functions.
  3. **    IBM Personal Computer - TopView C Interface Header File.
  4. **    Written for Borland Turbo C v1.5.
  5. **    (Microsoft MASM v5 is required to recompile the interface functions.)
  6. */
  7.  
  8. #pragma inline
  9.  
  10. #include <dos.h>
  11.  
  12. #include "int15def.h"    /* definitions */
  13. #include "int15c.h"        /* types and function prototypes */
  14.  
  15. WORD pascal TopVer(void)    /* GET TOPVIEW VERSION (0 = NOT TOPVIEW) */
  16. {
  17.     _BX = 0;                    /* use to test for TopView not loaded */
  18.     _AX = 0x1000+GETVER;        /* get version number */
  19.     geninterrupt(0x15);            /* issue the interrupt */
  20.     return _BX;                    /* return value */
  21. }
  22.  
  23. void pascal SetBit(            /* SETBIT POST FROM A 1ST-LEVEL INT HANDLER */
  24.     WORD bit                    /* bit to set */
  25. )
  26. {
  27.     _BX = bit;
  28.     _AX = 0x1000+SETBIT;
  29.     geninterrupt(0x15);            /* issue the interrupt */
  30. }
  31.  
  32. void pascal SubCall(        /* TOPVIEW SUBROUTINE CALL */
  33.     WORD func_code,                /* function code */
  34.     REGLIST *call_args            /* registers to/from */
  35. )
  36. {
  37. asm    mov    di,func_code    ; /* save the caller's AL function code */
  38. #if defined(__TINY__) || defined(__SMALL__) || defined(__COMPACT__)
  39. asm    mov    si,call_args    ; /* get address of call_args record parameter */
  40. asm    mov    ax,ds            ;
  41. asm    mov    es,ax            ;
  42. #else
  43. asm    les    si,call_args    ; /* get address of call_args record parameter */
  44. #endif
  45. asm    mov    ax,1000h+OSTACK    ; /* set system stack seg & stack ptr */
  46. asm    int    15h                ; /* issue the interrupt */
  47. asm    push si                ; /* save es:si */
  48. asm    push es                ;
  49. asm    mov    ax,di            ; /* get the caller's AL function code */
  50. asm    mov    ah,10h            ; /* and add the subcall function code */
  51. asm    mov    bx,es:[si].bxreg; /* get the value of bx from call_args for subcall */
  52. asm    mov    cx,es:[si].cxreg; /* do the same for cx, */
  53. asm    mov    dx,es:[si].dxreg; /* dx, */
  54. asm    les    di,es:[si].direg; /* es, and di. */
  55. asm    int    15h                ; /* issue the interrupt */
  56. asm    mov    ax,es            ; /* save es */
  57. asm    pop    es                ; /* restore es:si */
  58. asm    pop    si                ;
  59. asm    mov    es:[si].bxreg,bx; /* move the values from the registers returned by */
  60. asm    mov    es:[si].cxreg,cx; /*  subcall back into call_args record parameter */
  61. asm    mov    es:[si].dxreg,dx; /* . */
  62. asm    mov    es:[si].direg,di; /* . */
  63. asm    mov    es:[si].esreg,ax; /* . */
  64. asm    mov    ax,1000h+USTACK    ; /* restore user stack seg & stack ptr */
  65. asm    int    15h                ; /* issue the interrupt */
  66. }
  67.  
  68. void pascal SendMsg(        /* SEND MESSAGE TO TOPVIEW OBJECT */
  69.     WORD msg_num,                /* message number */
  70.     WORD mod_num,                /* object modifier */
  71.     OBJECT object_hdl,            /* object handle (0 = none) */
  72.     PARMLIST *msg_args            /* parameter list & return value(s) */
  73. )
  74. {
  75. asm    mov    bh,msg_num        ; /* get the caller's message number */
  76. asm    mov    bl,mod_num        ; /*  and the modifier */
  77. asm    les    di,object_hdl    ; /* get the caller's object handle */
  78. asm    mov    dx,es            ; /* . */
  79. #if defined(__TINY__) || defined(__SMALL__) || defined(__COMPACT__)
  80. asm    mov    si,msg_args        ; /* get address of msg_args record parameter */
  81. asm    mov    ax,ds            ;
  82. asm    mov    es,ax            ;
  83. #else
  84. asm    les    si,msg_args        ; /* get address of msg_args record parameter */
  85. #endif
  86. asm    mov    ax,1000h+OSTACK    ; /* set system stack seg & stack ptr */
  87. asm    int    15h                ; /* issue the interrupt */
  88. asm    mov    ax,sp            ; /* save stack pointer */
  89. asm    mov cx,es:[si]        ; /* number of arguments */
  90. asm    jcxz send40            ; /* none */
  91. send30:
  92. asm    push es:[si+4]        ; /* push argument h on stack */
  93. asm    push es:[si+2]        ; /* push argument l on stack */
  94. asm    add    si,4            ; /* point to next */
  95. asm    loop send30            ; /* until done */
  96. asm    sub    si,ax            ; /* restore argument pointer */
  97. asm    add    si,sp
  98. send40:
  99. asm    mov    cx,dx            ; /* test object pointer */
  100. asm    or    cx,di
  101. asm    jz    send50            ; /* none */
  102. asm    push dx                ; /* push the object pointer */
  103. asm    push di                ;
  104. send50:
  105. asm    mov    cx,ax            ; /* save stack pointer */
  106. asm    mov    ah,12h            ; /* get the send message function code */
  107. asm    int    15h                ; /* issue the interrupt request */
  108. asm    sub    cx,sp            ; /* calculate the number of bytes returned */
  109. asm    mov    ax,cx            ; /* save the number of bytes */
  110. asm    shr    cx,1            ; /* shift right twice to divide by 4 giving the */
  111. asm    shr    cx,1            ; /*  number of msg_args arguments returned */
  112. asm    mov    es:[si],cx         ; /*  and put in # of args to be returned */
  113. asm    jcxz send70            ; /* if no arguments returned then continue */
  114. asm    add    si,ax            ; /* advance pointer to last slot in result area */
  115. send60:
  116. asm    pop    es:[si-2]        ; /* pop "l" part of argument into result list */
  117. asm    pop    es:[si]            ; /* pop "h" part of argument into result list */
  118. asm    sub    si,4            ; /* skip back 4 bytes to next argument */
  119. asm    loop send60            ; /* loop if there are more arguments to move */
  120. send70:
  121. asm    mov    ax,1000h+USTACK    ; /* restore user stack seg & stack ptr */
  122. asm    int    15h                ; /* issue the interrupt */
  123. }
  124.