home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / DESQVIEW / MISC / DVAWARE.ZIP / DVAWARE.ASM
Encoding:
Assembly Source File  |  1991-03-16  |  6.2 KB  |  166 lines

  1.                                 TITLE DESQview Interfaces
  2.  
  3. ; Taken from the DESQview manual, page 196, appendix J:
  4. ;                    DESQview's application program interface
  5.  
  6. ; This listing can be assembled with the IBM or Microsoft Assembler and
  7. ; then linked with the program. It should work "as is" when linked to
  8. ; Assembler or MS Pascal programs. It isn't linkable "as is" to Turbo
  9. ; Pascal or Compiled BASIC - but can be easily adapted to these languages
  10. ; as well. For registered owners of DESQview can contact Quarterdeck if
  11. ; you need assistance.
  12.  
  13. DVINT_SEG SEGMENT 'CODE'
  14.         ASSUME CS:DVINT_SEG
  15.  
  16.         PUBLIC  DV_GET_VERSION
  17.         PUBLIC  DV_GET_VIDEO_BUFFER
  18.         PUBLIC  DV_PAUSE
  19.         PUBLIC  DV_BEGIN_CRITICAL
  20.         PUBLIC  DV_END_CRITICAL
  21.  
  22. IN_DV   DB 1
  23.  
  24. DV_GET_VERSION  PROC FAR
  25. ; Description:
  26. ; Returns a zero if the program is >not< running under DESQview.
  27. ; Otherwise, it returns the current DESQview version number. If
  28. ; the program already uses DOS or the BIOS to write to the screen,
  29. ; you should call this routine (rather than DV_GET_VIDEO_BUFFER)
  30. ; when you initialize the program.
  31.  
  32. ;Notes:
  33. ; Returns in AH/AL the DESQview major/minor version numbers,
  34. ;   and set up the IN_DV variable for later use.
  35. ; Returns 0 in AX if DESQview isn't there.
  36.         PUSH    BX
  37.         PUSH    CX
  38.         PUSH    DX
  39.         MOV     CX,'DE'         ; set CX to 4445H; DX to 5351H
  40.         MOV     DX,'SQ'         ; (AN INVALID DAT)
  41.         MOV     AX,2B01H        ; DOS' SET DATE FUNCTION
  42.         INT     21H             ; CALL DOS
  43.         CMP     AL,0FFH         ; DID DOS SEE IT AS INVALID?
  44.         JE      NO_DESQVIEW     ; IF SO, DESQVIEW ISN'T THERE
  45.         MOV     AX,BX           ; AH=MAJOR VERSION; AL=MINOR VERS
  46.         MOV     CS:IN_DV,1      ; SET INTERNAL VARIABLE USE BY
  47.         JMP     SHORT DVGV_X    ;       OTHER ROUTINES
  48. NO_DESQVIEW:
  49.         SUB     AX,AX           ; RETURN NO DESQview (version 0)
  50. DVGV_X: POP     DX
  51.         POP     CX
  52.         POP     BX
  53.         RET
  54. DV_GET_VERSION ENDP
  55.  
  56. DV_GET_VIDEO_BUFFER PROC FAR
  57. ; Descriptions:
  58. ; Takes the hardware video segment on the stack and returns that
  59. ; segment (if DESQview is not present) or returns that segment of
  60. ; DESQview's alternate video buffer. You should call this routine
  61. ; when you initialize the program if the program normally writes
  62. ; directly to the video buffer.
  63.  
  64. ; Notes:
  65. ; Takes the hardware video segment on the stack and returns that
  66. ; segment (if DESQview is not present) or DESQview's alternate
  67. ; video buffer in AX. Sets up the IN_DV variable for later use.
  68. ; Call this instead of DV_GET_VERSION if your program writes
  69. ; directly to video memory.
  70.         PUSH    BP
  71.         MOV     BP,SP
  72.         PUSH    DI
  73.         PUSH    ES
  74.         MOV     ES,[BP+6]       ; Put the hardware segment into ES
  75.         CALL    DV_GET_VERSION  ; Returns AX=0 if not in DESQview
  76.         TEST    AX,AX           ; In DV?
  77.         JZ      DVGVB_X         ; Jump if not
  78. ; Since DESQview is running, get the alternate screen buffer
  79.         MOV     AH,0FEH         ; DV's get buffer function
  80.         INT     10H             ; Returns ES:DI as alternate buffer
  81. DVGVB_X:
  82.         MOV     AX,ES           ; Return correct video buffer in ES
  83.         POP     ES
  84.         POP     DI
  85.         POP     BP
  86.         RET     2
  87. DV_GET_VIDEO_BUFFER ENDP
  88.  
  89. API_CALL PROC NEAR
  90. ; This local routine takes a program interface function in BX,
  91. ; and makes that call to DESQview after switching onto a stack
  92. ; that DESQview provides for your program.
  93.         PUSH    AX
  94.         MOV     AX,101AH        ; The function to switch to DV's stack
  95.         INT     15H             ; DV's software interrupt
  96.         MOV     AX,BX           ; Move the desired function to AX
  97.         INT     15H             ; Make that call
  98.         MOV     AX,1025H        ; Function to switch off of DV's stack
  99.         INT     15H             ; Make that call
  100.         POP     AX
  101.         RET
  102. API_CALL ENDP
  103.  
  104. DV_PAUSE PROC FAR
  105. ; Descriptions:
  106. ; If the program waits for input when it's idle, DESQview won't
  107. ; waste any processor time on it until the user types the next key.
  108. ; However, if the program sits in a loop polling the keyboard
  109. ; when it's basically idle, you'll probably want to use the
  110. ; DV_PAUSE call to relinquish the remainder of your time slice
  111. ; when you see that the event you're polling for hasn't yet occurred.
  112. ; This minimizes the amount that the program's polling loop affects
  113. ; other programs running in background.
  114.  
  115. ; Notes:
  116. ; This routine tells DESQview not to slice away from your program
  117. ; Takes no parameters and returns nothing.
  118.         CMP     CS:IN_DV,1      ; Are we in DESQview?
  119.         JNE     DVP_X           ; If not, nothing to do
  120.         PUSH    BX              ; Else make the pause function call
  121.         MOV     BX,1000H        ; This is the function code
  122.         CALL    API_CALL        ; Do it
  123.         POP     BX
  124. DVP_X:  RET
  125. DV_PAUSE ENDP
  126.  
  127. DV_BEGIN_CRITICAL PROC FAR
  128. ; Descriptions:
  129. ; This call is used in conjunction with the call DV_END_CRITICAL to
  130. ; define a section of code that DESQview won't "slice out of". Use
  131. ; this for timing critical operations.
  132.  
  133. ; Notes:
  134. ; This routine tells DESQview not to slice away your program
  135. ; until you make a DV_END_CRITICAL call.
  136. ; Takes no parameters and returns nothing.
  137.         CMP     CS:IN_DV,1      ; Are we in DESQview?
  138.         JNE     DVBC_X          ; If not, nothing to do
  139.         PUSH    BX              ; Else make the begin critical call
  140.         MOV     BX,101BH        ; This is the function code
  141.         CALL    API_CALL        ; Do it
  142.         POP     BX
  143. DVBC_X: RET
  144. DV_BEGIN_CRITICAL ENDP
  145.  
  146. DV_END_CRITICAL PROC FAR
  147. ; Descriptions:
  148. ; This call defines the end of the critical operations.
  149.  
  150. ; Notes:
  151. ; This routine tells DESQview that it is all right to slice away
  152. ; from your program again.
  153. ; Takes no parameters and returns nothing.
  154.         CMP     CS:IN_DV,1      ; Are we in DESQview?
  155.         JNE     DVEC_X          ; If not, nothing to do
  156.         PUSH    BX              ; Else make the end critical call
  157.         MOV     BX,101CH        ; This is the function code
  158.         CALL    API_CALL        ; Do it
  159.         POP     BX
  160. DVEC_X: RET
  161. DV_END_CRITICAL ENDP
  162.  
  163. DVINT_SEG ENDS
  164.         END
  165.  
  166.