home *** CD-ROM | disk | FTP | other *** search
/ Doom 2 Explosion / Doom2Explosion.bin / doom2exp / programs / dms012 / dms.asm next >
Assembly Source File  |  1994-08-12  |  7KB  |  263 lines

  1. ;---------------------------------------------------------------------------
  2. ;
  3. ; DMS   v0.12ß          Instant 180-degree turns in Doom!
  4. ;
  5. ;   Copyright (c) Tom Klok and Dave 'Zoid' Kirsch         August, 1994
  6. ;
  7. ;   Freely distributable as long as copyright and attributions
  8. ;   are maintained.
  9. ;
  10. ;   a344@mindlink.bc.ca, tom@auggy.mlnet.com
  11. ;   zoid@mindlink.bc.ca, zoid@grog.mlnet.com
  12. ;
  13. ;---------------------------------------------------------------------------
  14.  
  15.         .286
  16.  
  17. bk              equ     8
  18. ht              equ     9
  19. lf        equ    10
  20. ff        equ    12
  21. cr        equ    13
  22. eof        equ    26
  23. eos        equ    '$'
  24.  
  25. mouse_vector    equ    033h
  26. _buttons    equ    00003h
  27. _mickeys    equ    0000Bh
  28. _query        equ    0DEADh
  29. chk_response    equ    0D00Dh
  30. chk_version     equ     0012Ah
  31.  
  32. dos_vector    equ    021h
  33. _outstr     equ    00900h
  34. _getvec     equ    03500h + mouse_vector
  35. _setvec     equ    02500h + mouse_vector
  36. _tsr        equ    03100h
  37. _free        equ    04900h
  38. _exit        equ    04C00h
  39. _exit1        equ    _exit + 1
  40.  
  41. env_offset    equ    0002ch
  42. tail_buff    equ    00081h
  43.  
  44. turn_90         equ     1463
  45. turn_180    equ    turn_90 * 2
  46. turn_270    equ    -turn_90
  47.  
  48. button_left     equ     1
  49. button_right    equ     2
  50. button_mid      equ     4
  51.  
  52. msdos        macro    name, val
  53.         ifdef    &name
  54.         mov    ax, &name
  55.         ifdef    &val
  56.         mov    dx, offset &val
  57.         endif
  58.         endif
  59.         int    dos_vector
  60.         endm
  61.  
  62. ;---------------------------------------------------------------------------
  63.  
  64. code_seg    segment public
  65.                 assume  cs:code_seg, ds:nothing, es:nothing
  66.         org    00100h
  67.  
  68. dms:        jmp    install
  69.  
  70. ;---------------------------------------------------------------------------
  71.  
  72.         align    4
  73. old_vector:    db    'oldv'
  74.         ; +x is right, +y is backwards
  75. newmickeysx    dw    0        ; if non-zero, we're going to pass
  76. ;newmickeysy    dw      0               ; if non-zero, we're going to pass
  77. mickeyset    db    0
  78. button        db    0        ; 1 = left, 2 = right, 4 = middle
  79.  
  80. ;---------------------------------------------------------------------------
  81.  
  82. dms_proc:    cmp    ax, _buttons        ; get button info?
  83.         je    getbutton
  84.  
  85.         cmp    ax, _mickeys        ; get mickeys?
  86.         je    getmickeys
  87.  
  88.         cmp    ax, _query        ; installation check?
  89.         jne    old_handler
  90.  
  91.         mov    ax, chk_response    ; yes, we're here!
  92.                 mov     bx, chk_version
  93.                 mov     di, offset button
  94.         iret
  95.  
  96. old_handler:
  97.         jmp    dword ptr cs:[old_vector]
  98.  
  99. getbutton:    ; call the mouse handler (we're going to change it)
  100.  
  101.                 pushf
  102.                 call    dword ptr cs:[old_vector]
  103.  
  104.                 mov     al, cs:[button]
  105.                 xor     bl, al
  106.                 test    bl, al                  ; test for button set
  107.         jnz    nomickey
  108.  
  109.                 ; button(s) were pressed... are we debouncing?
  110.  
  111.                 cmp     cs:[mickeyset], 0
  112.                 jnz     doiret                  ; debouncing, so ignore it
  113.  
  114.         ; set up our fake mickeys
  115.  
  116.         mov    cs:[newmickeysx], turn_180
  117.                 inc     cs:[mickeyset]          ; debouce next time
  118.                 iret
  119.  
  120. nomickey:
  121.                 xor     bl, al
  122.                 mov     cs:[mickeyset], 0       ; not debouncing next time
  123.         iret
  124.  
  125. getmickeys:    ; call the mouse handler (we're going to change it)
  126.  
  127.                 pushf
  128.                 call    dword ptr cs:[old_vector]
  129.  
  130.                 add     cx, cs:[newmickeysx]    ; zoot!  do the turn
  131.                 mov     cs:[newmickeysx], 0
  132.  
  133. ;               add     dx, cs:[newmickeysy]
  134. ;               mov     cs:[newmickeysy], 0
  135.  
  136. doiret:     iret
  137.  
  138. end_of_tsr:
  139.  
  140. ;---------------------------------------------------------------------------
  141.  
  142. ttl:            db      "DMS v0.12ß (c) "
  143.                 db      ??date
  144.                 db      " Tom Klok/Dave 'Zoid' Kirsch",eos
  145. welcome:        db      ': installed!',cr,lf,eos
  146. update_str:     db      ': buttons updated.',cr,lf,eos
  147. usage_str:      db      cr,lf,lf,"Usage: DMS -[l][m][r] where LMR represent "
  148.                 db      "Left, Mid, Right mouse buttons.",cr,lf
  149.                 db      "The default button selection is '-r' for Right."
  150.                 db      cr,lf,lf,"Freely distributable.  "
  151.                 db      "Queries or comments to a344@mindlink.bc.ca."
  152. crlfeos     db    cr,lf,eos
  153. buttons_str     db      "Mouse buttons to activate: ",eos
  154. left_str        db      "left+",eos
  155. middle_str      db      "middle+",eos
  156. right_str       db      "right+",eos
  157. backup_str      db      bk,"."
  158.                 db      cr,lf,eos
  159.  
  160. ;---------------------------------------------------------------------------
  161.  
  162. install:
  163.         msdos    _outstr, ttl
  164.  
  165.         ; chk command line for mouse button preferences
  166.  
  167.         mov    si, tail_buff+1
  168. chk_cmd:
  169.         lodsb
  170.  
  171.         cmp    al, cr        ; is it the terminator?
  172.         je    cmd_done
  173.                 cmp     al, 0
  174.         je    cmd_done
  175.  
  176.         cmp    al, ' '
  177.         je    chk_cmd
  178.                 cmp     al, '-'
  179.         je    chk_cmd
  180.                 cmp     al, '/'
  181.         je    chk_cmd
  182.  
  183.         and    al, 0dfh    ; to uppercase
  184.  
  185.                 cmp     al, 'L'
  186.         jne    next2
  187.                 or      cs:[button], button_left
  188.         jmp    chk_cmd
  189. next2:
  190.         cmp    al, 'R'
  191.         jne    next3
  192.                 or      cs:[button], button_right
  193.         jmp    chk_cmd
  194. next3:
  195.         cmp    al, 'M'
  196.                 jne     show_usage
  197.                 or      cs:[button], button_mid
  198.         jmp    chk_cmd
  199. show_usage:
  200.         msdos    _outstr, usage_str
  201.         msdos    _exit1
  202. cmd_done:
  203.         cmp    cs:[button], 0
  204.                 jne     moreinstall
  205.                 or      cs:[button], button_right
  206. moreinstall:
  207.         mov    ax, _query
  208.         int    mouse_vector
  209.         cmp    ax, chk_response
  210.         je    change_button
  211.  
  212.         msdos    _outstr, welcome
  213.  
  214.         msdos    _getvec         ; es:bx <- int 33h pointer
  215.         mov    word ptr [old_vector], bx
  216.         mov    word ptr [old_vector + 2], es
  217.                 msdos   _setvec, dms_proc       ; int 33h pointer <- ds:dx
  218.  
  219.         call    display_buttons
  220.  
  221.         mov    ax, ds:[env_offset]    ; get envt segment
  222.         mov    es, ax
  223.         msdos    _free
  224.  
  225.         mov    dx, offset end_of_tsr
  226.         add    dx, 15
  227.         shr    dx, 4
  228.         msdos    _tsr
  229.  
  230. change_button:
  231.                 push    di
  232.         msdos    _getvec         ; es:bx <- int 33h pointer
  233.                 mov     al, cs:[button]
  234.                 pop     di
  235.                 mov     es:[di], al
  236.  
  237.                 msdos   _outstr, update_str
  238.         call    display_buttons
  239.         msdos    _exit1
  240.  
  241. display_buttons:
  242.         msdos    _outstr, buttons_str
  243.                 test    cs:[button], button_left
  244.         je    db1
  245.         msdos    _outstr, left_str
  246. db1:
  247.                 test    cs:[button], button_mid
  248.         je    db2
  249.         msdos    _outstr, middle_str
  250. db2:
  251.                 test    cs:[button], button_right
  252.         je    db3
  253.         msdos    _outstr, right_str
  254. db3:
  255.                 msdos   _outstr, backup_str
  256.         ret
  257.  
  258. ;---------------------------------------------------------------------------
  259.  
  260. code_seg    ends
  261.         end    dms
  262.  
  263.