home *** CD-ROM | disk | FTP | other *** search
/ Crazy Collection 12 / CC-12_1.iso / update / doompack / data.a00 / DMS015.ZIP / DMS015.ASM next >
Encoding:
Assembly Source File  |  1995-06-19  |  10.4 KB  |  406 lines

  1. ;---------------------------------------------------------------------------
  2. ;
  3. ; DMS   v0.12ß          Instant 180-degree turns in Doom!
  4. ;   Copyright (c) Tom Klok and Dave 'Zoid' Kirsch         August, 1994
  5. ;
  6. ; DMS   v0.13      Support for keyboard added.
  7. ; DMS   v0.15ß     Toggle key to disable/enable mouse Y movement added.
  8. ;       Modifications by Lincoln Yeoh. 
  9. ;
  10. ;   Freely distributable as long as copyright and attributions
  11. ;   are maintained.
  12. ;
  13. ;   a344@mindlink.bc.ca, tom@auggy.mlnet.com
  14. ;   zoid@mindlink.bc.ca, zoid@grog.mlnet.com
  15. ;
  16. ;---------------------------------------------------------------------------
  17.  
  18.         .286
  19.  
  20. bk              equ     8
  21. ht              equ     9
  22. lf              equ     10
  23. ff              equ     12
  24. cr              equ     13
  25. eof             equ     26
  26. eos             equ     '$'
  27.  
  28. mouse_vector    equ     033h
  29. _buttons        equ     00003h
  30. _mickeys        equ     0000Bh
  31. _query          equ     0DEADh
  32. chk_response    equ     0D00Dh
  33. chk_version     equ     0012Ah
  34.  
  35. dos_vector      equ     021h
  36. _outstr         equ     00900h
  37. _getvec         equ     03500h + mouse_vector
  38. _setvec         equ     02500h + mouse_vector
  39. _tsr            equ     03100h
  40. _free           equ     04900h
  41. _exit           equ     04C00h
  42. _exit1          equ     _exit + 1
  43.  
  44. env_offset      equ     0002ch
  45. tail_buff       equ     00081h
  46.  
  47. turn_90         equ     1463
  48. turn_180        equ     turn_90 * 2
  49. turn_270        equ     -turn_90
  50. button_left     equ     1
  51. button_right    equ     2
  52. button_mid      equ     4
  53. button_none     equ     8               ; Any four button mice for PCs? 
  54.  
  55. msdos           macro   name, val
  56.         ifdef   &name
  57.         mov     ax, &name
  58.         ifdef   &val
  59.         mov     dx, offset &val
  60.         endif
  61.         endif
  62.         int     dos_vector
  63.         endm
  64.  
  65. ;---------------------------------------------------------------------------
  66.  
  67. code_seg        segment public
  68.         assume  cs:code_seg, ds:nothing, es:nothing
  69.         org     00100h
  70.  
  71. dms:            jmp     install
  72.  
  73. ;---------------------------------------------------------------------------
  74.  
  75.         align   4
  76. old_vector:     db      'oldv'
  77.         ; +x is right, +y is backwards
  78. newmickeysx     dw      0               ; if non-zero, we're going to pass
  79. newmickeysy     dw      0               ; if non-zero, we're going to pass
  80. mickeyset       db      0
  81.  
  82. ;DON'T CHANGE ORDER OF FOLLOWING LINES OR INSERT ANYTHING IN BETWEEN
  83.  
  84. button          db      0               ; 1 = left, 2 = right, 4 = middle
  85. flipkeydwn      db      52              ;Default set to .
  86. flipkeyup       db      52+128
  87. mvtogkeydwn     db      45              ;Toggle key to disable mouse f/b.
  88. mvtogkeyup      db      45+128          ;Key set to X
  89. ; that's it.                                         
  90.  
  91. keypressed      db      0
  92. mvlock          db      0               ;Disable mouse forward/backward?
  93. togpressed      db      0
  94. oldal           db      0
  95. ;---------------------------------------------------------------------------
  96.  
  97. dms_proc:       cmp     ax, _buttons            ; get button info?
  98.         je      getbutton
  99.  
  100.         cmp     ax, _mickeys            ; get mickeys?
  101.         jne     nopemick
  102.         jmp      getmickeys
  103. nopemick:
  104.         cmp     ax, _query              ; installation check?
  105.         jne     old_handler
  106.  
  107.         mov     ax, chk_response        ; yes, we're here!
  108.         mov     bx, chk_version
  109.         mov     di, offset button
  110.         iret
  111.  
  112. old_handler:
  113.         jmp     dword ptr cs:[old_vector]
  114.  
  115. getbutton:      ; call the mouse handler (we're going to change it)
  116.         ; But first check the keyboard!
  117.         pushf
  118.         mov     cs:[oldal], al
  119.         in      al,060h
  120.         cmp     al,flipkeydwn
  121.         jne     notit
  122.         cmp     cs:[keypressed], 0
  123.         jnz     getnkey                  ; If key hasn't been lifted since 
  124.                     ; the last flip, don't keep flipping!
  125.         mov     cs:[newmickeysx], turn_180
  126.         inc     cs:[keypressed]          ; Okay it's  down now
  127.         jmp     getnkey
  128.         
  129. notit:
  130.         cmp     al,flipkeyup
  131.         jne     getnkey
  132.  
  133. ; flipkey has been released
  134.  
  135.         mov     cs:[keypressed], 0       ; So flip on next flipkeydwn
  136. getnkey:         
  137.         cmp     al,mvtogkeydwn
  138.         jne     notit2
  139.         cmp     cs:[togpressed],0
  140.         jnz     chkbkey
  141.         xor     cs:[mvlock],1
  142.         inc     cs:[togpressed]
  143.         jmp     chkbkey
  144. notit2:
  145.         cmp     al,mvtogkeyup
  146.         jne     chkbkey
  147.         mov     cs:[togpressed],0
  148. chkbkey:
  149.         nop
  150. getbut:
  151.         mov     al, cs:[oldal]
  152.         call    dword ptr cs:[old_vector]
  153.  
  154.         mov     al, cs:[button]
  155.         xor     bl, al
  156.         test    bl, al                  ; test for button set
  157.         jnz     nomickey
  158.  
  159.         ; button(s) were pressed... are we debouncing?
  160.  
  161.         cmp     cs:[mickeyset], 0
  162.         jnz     doiret                  ; debouncing, so ignore it
  163.  
  164.         ; set up our fake mickeys
  165.  
  166.         mov     cs:[newmickeysx], turn_180
  167.         inc     cs:[mickeyset]          ; debouce next time
  168.         iret
  169.  
  170. nomickey:
  171.         xor     bl, al
  172.         mov     cs:[mickeyset], 0       ; not debouncing next time
  173.         iret
  174.  
  175. getmickeys:     ; call the mouse handler (we're going to change it)
  176.  
  177.         pushf
  178.         call    dword ptr cs:[old_vector]
  179.  
  180.         add     cx, cs:[newmickeysx]    ; zoot!  do the turn
  181.         mov     cs:[newmickeysx], 0
  182.         cmp     cs:[mvlock],0
  183.         jz      doiret                 ; No lock- mouse ymove enabled
  184.         mov     dx,0
  185.                 
  186. doiret:         iret
  187.  
  188. end_of_tsr:
  189.  
  190. ;---------------------------------------------------------------------------
  191.  
  192. ttl:            db      "DMS v0.12ß (c) "
  193.         db      " Tom Klok/Dave 'Zoid' Kirsch",cr,lf
  194.         db      "DMS v0.13 "
  195.         db      ??date
  196.         db      " keyboard support added by Lincoln Yeoh.",cr,eos
  197. keypls:         db      cr,lf,"Please press your 180-flip key or press Esc for the default '.' "
  198.         db      cr,lf,eos
  199. keypls2:        db      cr,lf,"Please press your y-toggle key or press Esc for the default 'X' "
  200.         db      cr,lf,eos
  201. keynotok:       db      "Sorry, extended keys not supported!",cr,lf,eos
  202. keyset:         db      "Alright! Let's get going!",cr,lf,eos
  203. welcome:        db      ': installed!',cr,lf,eos
  204. update_str:     db      ': buttons updated.',cr,lf,eos
  205. usage_str:      db      cr,lf,lf,"Usage: DMS -[l][m][r][n] where LMR represent "
  206.         db      "Left, Mid, Right mouse buttons.",cr,lf
  207.         db      "And N for none of the above...",cr,lf
  208.         db      "The default button selection is '-r' for Right."
  209.         db      cr,lf,lf,"Freely distributable.  "
  210.         db      "Queries or comments to a344@mindlink.bc.ca."
  211. crlfeos         db      cr,lf,eos
  212. buttons_str     db      "Mouse buttons to activate: ",eos
  213. left_str        db      "left+",eos
  214. middle_str      db      "middle+",eos
  215. right_str       db      "right+",eos
  216. none_str        db      "NONE ",eos
  217. backup_str      db      bk,"."
  218.         db      cr,lf,eos
  219.  
  220. ;---------------------------------------------------------------------------
  221.  
  222. install:
  223.         msdos   _outstr, ttl
  224.  
  225.         ; chk command line for mouse button preferences
  226.  
  227.         mov     si, tail_buff+1
  228. chk_cmd:
  229.         lodsb
  230.  
  231.         cmp     al, cr          ; is it the terminator?
  232.         je      cmd_done
  233.         cmp     al, 0
  234.         je      cmd_done
  235.  
  236.         cmp     al, ' '
  237.         je      chk_cmd
  238.         cmp     al, '-'
  239.         je      chk_cmd
  240.         cmp     al, '/'
  241.         je      chk_cmd
  242.  
  243.         and     al, 0dfh        ; to uppercase
  244.  
  245.         cmp     al, 'L'
  246.         jne     next2
  247.         or      cs:[button], button_left
  248.         jmp     chk_cmd
  249. next2:
  250.         cmp     al, 'R'
  251.         jne     next3
  252.         or      cs:[button], button_right
  253.         jmp     chk_cmd
  254. next3:
  255.         cmp     al, 'M'
  256.         jne     next4
  257.         or      cs:[button], button_mid
  258.         jmp     chk_cmd
  259. next4:                                  ; For those who don't want to use mouse
  260.         cmp     al, 'N'
  261.         jne     show_usage
  262.         or      cs:[button], button_none
  263.         jmp     chk_cmd
  264. show_usage:
  265.         msdos   _outstr, usage_str
  266.         msdos   _exit1
  267. cmd_done:
  268.         cmp     cs:[button], 0
  269.         jne     moreinstall
  270.         or      cs:[button], button_right
  271. moreinstall:
  272.         msdos   _outstr, keypls
  273. waitup:
  274.         in      al,060h
  275.         cmp     al,128
  276.         jb     waitup
  277.         cmp     al,224
  278.         je      waitk
  279. waitdwn:
  280.         in      al,060h
  281.         cmp     al,224
  282.         je      waitk
  283.         cmp     al,128
  284.         jnb     waitdwn
  285.         jmp     keyok
  286. waitk:
  287.         in      al,060h
  288.         cmp     al,224
  289.         je     waitk
  290.         msdos   _outstr, keynotok
  291.         jmp     moreinstall
  292. keyok:
  293.         cmp     al,1
  294.         je      waitup2
  295.         mov     cs:[flipkeydwn],al
  296.         add     al,128
  297.         mov     cs:[flipkeyup],al
  298. waitup2:
  299.         in      al,060h
  300.         cmp     al,128
  301.         jb     waitup2
  302.         msdos   _outstr, keyset
  303. moreinstallB:
  304.         msdos   _outstr, keypls2
  305. waitupB:
  306.         in      al,060h
  307.         cmp     al,128
  308.         jb     waitupB
  309.         cmp     al,224
  310.         je      waitkB
  311. waitdwnB:
  312.         in      al,060h
  313.         cmp     al,224
  314.         je      waitkB
  315.         cmp     al,128
  316.         jnb     waitdwnB
  317.         jmp     keyokB
  318. waitkB:
  319.         in      al,060h
  320.         cmp     al,224
  321.         je     waitkB
  322.         msdos   _outstr, keynotok
  323.         jmp     moreinstallB
  324. keyokB:
  325.         cmp     al,1
  326.         je      waitup2B
  327.         mov     cs:[mvtogkeydwn],al
  328.         add     al,128
  329.         mov     cs:[mvtogkeyup],al
  330. waitup2B:
  331.         in      al,060h
  332.         cmp     al,128
  333.         jb     waitup2B
  334.         msdos   _outstr, keyset
  335.  
  336.         mov     ax, _query
  337.         int     mouse_vector
  338.         cmp     ax, chk_response
  339.         je      change_button
  340.  
  341.         msdos   _outstr, welcome
  342.  
  343.         msdos   _getvec                 ; es:bx <- int 33h pointer
  344.         mov     word ptr [old_vector], bx
  345.         mov     word ptr [old_vector + 2], es
  346.         msdos   _setvec, dms_proc       ; int 33h pointer <- ds:dx
  347.  
  348.         call    display_buttons
  349.  
  350.         mov     ax, ds:[env_offset]     ; get envt segment
  351.         mov     es, ax
  352.         msdos   _free
  353.  
  354.         mov     dx, offset end_of_tsr
  355.         add     dx, 15
  356.         shr     dx, 4
  357.         msdos   _tsr
  358.  
  359. change_button:
  360.         push    di
  361.         msdos   _getvec                 ; es:bx <- int 33h pointer
  362.         mov     al, cs:[button]
  363.         pop     di
  364.         mov     es:[di], al
  365.         mov     al, cs:[flipkeydwn]
  366.         mov     es:[di+1], al
  367.         mov     al, cs:[flipkeyup]
  368.         mov     es:[di+2], al
  369.         mov     al, cs:[mvtogkeydwn]
  370.         mov     es:[di+3], al
  371.         mov     al, cs:[mvtogkeyup]
  372.         mov     es:[di+4], al
  373.         msdos   _outstr, update_str
  374.         call    display_buttons
  375.         msdos   _exit1
  376.  
  377. display_buttons:
  378.         msdos   _outstr, buttons_str
  379.         test    cs:[button], button_none
  380.         je      gotbuttons
  381.         msdos   _outstr, none_str       
  382.         jmp     db3
  383. gotbuttons:
  384.         test    cs:[button], button_left
  385.         je      db1
  386.         msdos   _outstr, left_str
  387. db1:
  388.         test    cs:[button], button_mid
  389.         je      db2
  390.         msdos   _outstr, middle_str
  391. db2:
  392.         test    cs:[button], button_right
  393.         je      db3
  394.         msdos   _outstr, right_str
  395. db3:
  396.         msdos   _outstr, backup_str
  397.         ret
  398.  
  399.  
  400. ;---------------------------------------------------------------------------
  401.  
  402. code_seg        ends
  403.         end     dms
  404.  
  405.