home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / POVHELP.ZIP / source / kb.asm < prev    next >
Assembly Source File  |  1994-08-09  |  6KB  |  194 lines

  1.  
  2.  
  3. ;---------------------------------------------------------------------------
  4. ;                   KB.ASM - Version 1.0
  5. ;
  6. ;  This module implements some keyboard interrupt handlers
  7. ;
  8. ;  from Persistence of Vision Raytracer
  9. ;  Copyright 1994 Persistence of Vision Team
  10. ;  Copyright 1994 Christopher J. Cason.
  11. ;---------------------------------------------------------------------------
  12. ;  NOTICE: This source code file is provided so that users may experiment
  13. ;  with enhancements to POV-Ray and to port the software to platforms other
  14. ;  than those supported by the POV-Ray Team.  There are strict rules under
  15. ;  which you are permitted to use this file.  The rules are in the file
  16. ;  named POVLEGAL.DOC which should be distributed with this file. If
  17. ;  POVLEGAL.DOC is not available or for more info please contact the POV-Ray
  18. ;  Team Coordinator by leaving a message in CompuServe's Graphics Developer's
  19. ;  Forum.  The latest version of POV-Ray may be found there as well.
  20. ;
  21. ;  POV-Ray files may also be obtained from ftp.uwa.edu.au in pub/povray.
  22. ;
  23. ;  This program was written in its entirety by Christopher J. Cason.
  24. ;  Its use is freely and permanently granted to the POV-Team and POV users
  25. ;  under the conditions specified in POVLEGAL.DOC.
  26. ;
  27. ;  Author : C. J. Cason (cjcason@yarrow.wt.uwa.edu.au, CIS 100032,1644)
  28. ;
  29. ;---------------------------------------------------------------------------
  30.  
  31. KB_TEXT segment byte public 'CODE'
  32.  
  33. DGROUP  group   _DATA, _BSS
  34.  
  35.         assume  cs:KB_TEXT, ds:DGROUP
  36.  
  37. KB_TEXT ends
  38.  
  39. _DATA   segment word public 'DATA'
  40.  
  41.         oldSS           dw        0
  42.         oldSP           dw        0
  43.         oldPSP          dw        0
  44.         oldDTA          dd        0
  45.         thestack        db        128 dup ('STACK   ')
  46.         stacksize       equ       $ - thestack
  47.  
  48.         extrn _in_0x09:word
  49.         extrn _in_0x15:word
  50.         extrn _old0x15:dword
  51.         extrn _in_0x16:word
  52.         extrn _old0x16:dword
  53.         extrn _running:word
  54.         extrn _popped_up:word
  55.         extrn _popdown:word
  56.         extrn _paste:word
  57.         extrn _home:word
  58.         extrn _scancode:word
  59.         extrn _scanflag:word
  60.         extrn __psp:word
  61.         extrn _ourDTA:word
  62.  
  63. _DATA   ends
  64.  
  65. _BSS    segment word public 'BSS'
  66. _BSS    ends
  67.  
  68. KB_TEXT segment byte public 'CODE'
  69.  
  70.         _CS_old0x16     dd        0
  71.         in16            dw        0
  72.         _CS_old0x15     dd        0
  73.         in15            dw        0
  74.  
  75. KB_TEXT ends
  76.  
  77. KB_TEXT segment byte public 'CODE'
  78.  
  79. _new0x16 proc far
  80.  
  81.          cmp     cs:in16, 00h
  82.          jnz     notOK
  83.  
  84.          cmp     ah, 00h          ; get char
  85.          jz      ok
  86.          cmp     ah, 01h          ; is char waiting ?
  87.          jz      ok
  88.          cmp     ah, 10h          ; get char, extended
  89.          jz      ok
  90.          cmp     ah, 11h          ; is char waiting ?, extended
  91.          jz      ok
  92.  
  93. notOK:
  94.          jmp     dword ptr cs:_CS_old0x16   ; re-entry ocurred, bail out
  95.  
  96. ok:
  97.          inc     cs:in16          ; so we don't re-enter
  98.          push    bx
  99.          push    cx
  100.          push    dx
  101.          push    es
  102.          push    ds
  103.          push    si
  104.          push    di
  105.          push    bp
  106.          mov     bp,DGROUP
  107.          mov     ds,bp
  108.          push    ax
  109.  
  110.          mov     ax, word ptr DGROUP:_in_0x16
  111.          inc     word ptr DGROUP:_in_0x16
  112.          or      ax, ax
  113.          jnz     skip
  114.          cmp     word ptr DGROUP:_running,0
  115.          jz      skip
  116.          cmp     word ptr DGROUP:_popped_up,0
  117.          jnz     skip
  118.          inc     word ptr DGROUP:_popped_up
  119.  
  120.          mov     ah, 62h                              ; get current PSP
  121.          int     21h
  122.          mov     oldPSP, bx                           ; store it
  123.          mov     bx, __psp                            ; our PSP
  124.          mov     ah, 50h                              ; set PSP
  125.          int     21h
  126.  
  127.          mov     ah, 2fh                              ; get DTA
  128.          int     21h
  129.          mov     word ptr oldDTA [0], bx
  130.          mov     word ptr oldDTA [2], es
  131.  
  132.          push    ds
  133.          mov     ah, 1ah                              ; set DTA
  134.          mov     dx, 128
  135.          mov     ds, __psp
  136.          int     21h
  137.          pop     ds
  138.  
  139.          mov     oldSS,ss
  140.          mov     oldSP,sp
  141.          mov     ss,bp
  142.          mov     sp,offset DGROUP:thestack + stacksize
  143.  
  144.          sti
  145.          call    far ptr _popup
  146.  
  147.          mov     ss,oldSS
  148.          mov     sp,oldSP
  149.  
  150.          push    ds
  151.          mov     ah, 1ah                              ; set DTA
  152.          lds     dx, oldDTA
  153.          int     21h
  154.          pop     ds
  155.  
  156.          mov     bx, oldPSP                           ; old PSP
  157.          mov     ah, 50h                              ; set PSP
  158.          int     21h
  159.  
  160.          mov     word ptr DGROUP:_popped_up, 0
  161.          mov     word ptr DGROUP:_running, 0
  162.          mov     word ptr DGROUP:_popdown, 0
  163.  
  164. skip:
  165.          pop     ax
  166.          pushf
  167.          call    dword ptr DGROUP:_old0x16
  168.          pushf
  169.          dec     word ptr DGROUP:_in_0x16
  170.          popf
  171.          pop     bp
  172.          pop     di
  173.          pop     si
  174.          pop     ds
  175.          pop     es
  176.          pop     dx
  177.          pop     cx
  178.          pop     bx
  179.          pushf
  180.          dec     cs:in16
  181.          popf
  182.          ret     2
  183.  
  184. _new0x16 endp
  185.  
  186. KB_TEXT ends
  187.  
  188.         public _new0x16
  189.         public _CS_old0x16
  190. ;       public _new0x15
  191. ;       public _CS_old0x15
  192.  
  193.         extrn   _popup:far
  194. end