home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / teseract / source / tsint28.asm < prev    next >
Encoding:
Assembly Source File  |  1988-10-02  |  7.3 KB  |  262 lines

  1. IFNDEF TP4
  2.         PAGE 60,132
  3. ;----------------------------------------------------------------------------
  4. SUBTTL  TesSeRact Revision Level 1
  5. ;-----------------------------------------------------------------------------
  6. ;   TesSeRact(tm) -- A Library of Routines for Creating Ram-Resident (TSR)
  7. ;                    programs for the IBM PC and compatible Personal
  8. ;                    Computers.
  9. ;
  10. ;The software, documentation and source code are: 
  11. ;       Copyright (C) 1986, 1987, 1988 Tesseract Development Team
  12. ;       All Rights Reserved 
  13. ;       c/o Chip Rabinowitz
  14. ;       Innovative Data Concepts
  15. ;       2084 Woodlawn Avenue
  16. ;       Glenside, PA 19038
  17. ;       1-215-884-3373
  18. ;
  19. ;-----------------------------------------------------------------------------
  20. ;   This product supports the TesSeRact Standard for Ram-Resident Program 
  21. ;   Communication.  For information about TesSeRact, contact the TesSeRact 
  22. ;   Development Team at:
  23. ;       Compuserve:    70731,20
  24. ;       MCIMAIL:       315-5415
  25. ;   This MCIMAIL Account has been provided to the TesSeRact Development
  26. ;   Team by Borland International, Inc.  The TesSeRact Development Team
  27. ;   is in no way associated with Borland International, Inc.
  28. ;-----------------------------------------------------------------------------
  29.  
  30. INCLUDE TESS.INC
  31. IFDEF   ALLPUBLIC
  32. INCLUDE tsint28.pub     ;public definitions (uses Periscope PUBLIC.COM /E)
  33. ENDIF
  34.  
  35. .MODEL small
  36.  
  37. EXTRN TSRBACKCHECK:FAR
  38.  
  39. .CODE
  40.  
  41. EXTRN _TESSDOPOPUP:near
  42.  
  43. EXTRN _TESSDOBACK:near
  44. EXTRN TESSBEEP:FAR
  45.  
  46. EXTRN TESS_GLOBALS:byte
  47. EXTRN TESS_USERPARMS:byte
  48.  
  49. PUBLIC newint28, _TESSBACKGROUND
  50.  
  51. ENDIF
  52.  
  53. wait28  db      8
  54.  
  55. ; --------------------------------------------------------------------;
  56. ;       Interrupt 28  DOS idle interrupt                              ;
  57. ; --------------------------------------------------------------------;
  58.  
  59. _TESSBACKGROUND proc near
  60.  
  61.         ASSUMEDS
  62.  
  63.         mov     ax,WPTR [STATUS]        ;get TSR status flags
  64.         test    ax,BACKSET              ;do we have a routine?
  65.         jz      done_background         ;nope -- do next one
  66.  
  67.         test    ax,INT28ACTIVE          ;are we already running?
  68.         jz      chkdos_28_1
  69.         jmp     done_background
  70. chkdos_28_1:
  71.  
  72.         cld
  73.         push    ds                      ;check if dos critical error in effect
  74.         push    si
  75.         lds     si,DPTR [DOSCRITERR]    ;zero says dos is interruptable
  76.         ASSUMENODS
  77.         lodsb                           ;$ff  says dos is in a critical state
  78.         or      al,BPTR [INTFLAGS]      ;any flags says we're busy
  79.                                         ;NOTE:  Indos flag is always set here!
  80.                                         ; just check to make sure it is *only*
  81.                                         ; set to '1'
  82.         mov     ah,al                   ;save it away
  83.         lds     si,DPTR [INDOSFLAG]
  84.         lodsb
  85.  
  86.         mov     BPTR [SAVEDINDOSFLG],al
  87.         and     al,0FEh                 ;mask off first bit
  88.         or      al,ah
  89.  
  90.         pop     si
  91.         pop     ds
  92.         ASSUMEDS
  93.         jnz     done_background         ;we're busy-EXIT & try again next time
  94.  
  95.         or      WPTR [STATUS],INT28ACTIVE       ;set active bit
  96.  
  97.         push    ds
  98.         push    es
  99.  
  100.         mov     ax,WPTR [OURDSEG]
  101.         push    ax
  102.         push    ax
  103.         pop     es
  104.         pop     ds
  105.  
  106.         ASSUMENODS
  107.  
  108. IFDEF   TP4
  109. IFNDEF ASMCOM
  110.         call    DPTR PBACKCHECK         ; call users INT28 routine (TP4 ver)
  111. ELSE
  112.         call    TSRBACKCHECK            ; call users INT28 routine
  113. ENDIF
  114. ELSE
  115.         call    TSRBACKCHECK            ; call users INT28 routine
  116. ENDIF
  117.         pop     es
  118.         pop     ds
  119.  
  120.         ASSUMEDS
  121.  
  122.         or      ax,ax
  123.         jz      again_28
  124.  
  125.         call    _TESSDOBACK
  126.  
  127. again_28:
  128.         and     WPTR [STATUS],NOT INT28ACTIVE   ;set active bit
  129.         mov     BPTR [SAVEDINDOSFLG],0
  130.     xor    ax,ax
  131.     jmp    done_b2
  132.  
  133. done_background:
  134.     mov    ax,-1
  135. done_b2:
  136.     ret
  137. _TESSBACKGROUND endp
  138.  
  139.  
  140. newint28 proc far
  141.  
  142.         push    ds
  143.         push    cs
  144.         pop     ds
  145.  
  146.         ASSUMEDS
  147.  
  148.         pushf
  149.         test    WPTR [STATUS],TSRRELEASED
  150.         jnz     tfl_28
  151.  
  152.         test    WPTR [STATUS],TSRENABLED
  153.         jz      do_old28
  154.  
  155. tfl_28:
  156.         test    BPTR [SOFTINTFLAGS],ININT28     ;See if recursion has taken place
  157.         jz      start_new_int28         ;If not continue with new int 28
  158.  
  159. do_old28:
  160.         POPFF
  161.         pop     ds
  162.         ASSUMENODS
  163.         jmp     DPTR [OLDINT28]
  164.  
  165. start_new_int28:
  166.  
  167.         ASSUMEDS
  168.         POPFF
  169.  
  170.         pushf                           ;simulate interrupt ...
  171.         cli
  172.         call DPTR [OLDINT28]            ;do the original
  173.         sti
  174.  
  175.         or      BPTR [SOFTINTFLAGS],ININT28 ;Say INT 28 is active
  176.  
  177.         push    dx
  178.         push    cx                      ;save regs
  179.         push    bx
  180.         push    ax
  181.  
  182.  
  183.     call    _TESSBACKGROUND
  184.  
  185. test_28:
  186.         mov     ax,WPTR [STATUS]        ;get TSR status flags
  187.  
  188.         test    ax,INT28ACTIVE          ;are we already running?
  189.         jnz     again_28_2
  190.         test    ax,POPUPSET             ;ax holds status flags
  191.         jz      again_28_2
  192.         test    ax,HOTKEYON             ;is hot-key flag set?
  193.         jz      again_28_2
  194.         test    ax,TSRACTIVE            ;are we already running?
  195.         jnz     again_28_2              ;yep -- next one
  196.  
  197. chkdos_28:
  198.         cld
  199.         push    ds                      ;check if dos critical error in effect
  200.         push    si
  201.         lds     si,DPTR [DOSCRITERR]    ;zero says dos is interruptable
  202.         ASSUMENODS
  203.         lodsb                           ;$ff  says dos is in a critical state
  204.         or      al,BPTR [INTFLAGS]      ;any flags says we're busy
  205.                                         ;NOTE:  Indos flag is always set here!
  206.                                         ; just check to make sure it is *only*
  207.                                         ; set to '1'
  208.         mov     ah,al                   ;save it away
  209.         lds     si,DPTR [INDOSFLAG]
  210.         lodsb
  211.  
  212.         mov     BPTR [SAVEDINDOSFLG],al
  213.         and     al,0FEh                 ;mask off first bit
  214.         or      al,ah
  215.  
  216.         pop     si
  217.         pop     ds
  218.         ASSUMEDS
  219.         jnz     end_28                  ;we're busy-EXIT & try again next time
  220.  
  221.         and     BPTR [SOFTINTFLAGS],NOT ININT28 ;pretend we're out of INT28
  222.         call    _TESSDOPOPUP            ;... call the popup stuff
  223.         mov     BPTR [SAVEDINDOSFLG],0
  224. reset_28:
  225.         mov     wait28,8
  226.         jmp     short again_28_2
  227. end_28:
  228.         dec     wait28
  229.         jnz     again_28_2
  230.  
  231.         test    WPTR [STATUS],TSRRELEASED
  232.         jnz     reset_28
  233.         and     WPTR [STATUS],NOT HOTKEYON
  234. IFDEF TP4
  235. IFNDEF ASMCOM
  236.         call    FAR PTR TESSBEEP
  237. ELSE
  238.         call    TESSBEEP
  239. ENDIF
  240. ELSE
  241.         call    TESSBEEP
  242. ENDIF
  243.         jmp     short reset_28
  244.  
  245. again_28_2:
  246.         and     BPTR [SOFTINTFLAGS],NOT ININT28 ;tell we're out of INT28
  247.         mov     BPTR [WAITCOUNT],0              ;clear waiting count and ...
  248.  
  249.         pop     ax                      ;get back registers
  250.         pop     bx
  251.         pop     cx
  252.         pop     dx
  253. exit_28:
  254.         pop     ds
  255.         iret
  256.  
  257. newint28 endp
  258.  
  259. ENDIT
  260.