home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / misc / joystick.asm < prev    next >
Assembly Source File  |  1990-03-30  |  69KB  |  1,967 lines

  1.     Page    58,132
  2.     Title    JOYSTICK.ASM    Apple Emulator Joystick Routines
  3. ;******************************************************************************
  4. ;
  5. ;   Name:    JOYSTICK.ASM    Apple Emulator Joystick Routines
  6. ;
  7. ;   Group:    Emulator
  8. ;
  9. ;   Revision:    1.00
  10. ;
  11. ;   Date:    January 30, 1988
  12. ;
  13. ;   Author:    Randy W. Spurlock
  14. ;
  15. ;******************************************************************************
  16. ;
  17. ;  Module Functional Description:
  18. ;
  19. ;        This module contains all the code for the Apple joystick
  20. ;    routines.
  21. ;
  22. ;******************************************************************************
  23. ;
  24. ;  Changes:
  25. ;
  26. ;    DATE     REVISION                DESCRIPTION
  27. ;  --------   --------    -------------------------------------------------------
  28. ;   1/30/88    1.00    Original
  29. ;
  30. ;******************************************************************************
  31.     Page
  32. ;
  33. ;  Public Declarations
  34. ;
  35.     Public    Button_1        ; Button 1 input routine (Joystick 1)
  36.     Public    Button_2        ; Button 2 input routine (Joystick 1)
  37.     Public    Button_3        ; Button 3 input routine
  38.     Public    Joystick_1        ; Joystick 1 input routine (X-Axis)
  39.     Public    Joystick_2        ; Joystick 2 input routine (Y-Axis)
  40.     Public    Joystick_3        ; Joystick 3 input routine
  41.     Public    Joystick_4        ; Joystick 4 input routine
  42.     Public    Joystick_Strobe     ; Joystick strobe routine
  43.     Public    Joystick_Mode        ; Joystick mode routine
  44.     Public    Joystick_Type        ; Joystick type routine (Analog/Binary)
  45.     Public    Joystick_Fast        ; Joystick fast response mode routine
  46.     Public    Joystick_Center     ; Joystick self-center routine
  47.     Public    Joystick_Flight     ; Joystick flight mode routine
  48.     Public    Joystick_Reset        ; Joystick reset routine
  49.     Public    Joystick_Dummy        ; Joystick dummy routine
  50.     Public    Joy_Up_Left        ; Joystick up/left routine
  51.     Public    Joy_Up            ; Joystick up routine
  52.     Public    Joy_Up_Right        ; Joystick up/right routine
  53.     Public    Joy_Left        ; Joystick left routine
  54.     Public    Joy_Center        ; Joystick center routine
  55.     Public    Joy_Right        ; Joystick right routine
  56.     Public    Joy_Down_Left        ; Joystick down/left routine
  57.     Public    Joy_Down        ; Joystick down routine
  58.     Public    Joy_Down_Right        ; Joystick down/right routine
  59.     Public    Joy_X_Res_Inc        ; Joystick X resolution increase
  60.     Public    Joy_X_Res_Dec        ; Joystick X resolution decrease
  61.     Public    Joy_Y_Res_Inc        ; Joystick Y resolution increase
  62.     Public    Joy_Y_Res_Dec        ; Joystick Y resolution decrease
  63.     Public    Joy_X_Cen_Inc        ; Joystick X center increase
  64.     Public    Joy_X_Cen_Dec        ; Joystick X center decrease
  65.     Public    Joy_Y_Cen_Inc        ; Joystick Y center increase
  66.     Public    Joy_Y_Cen_Dec        ; Joystick Y center decrease
  67.     Public    Joy_Button_1        ; Joystick button 1 routine
  68.     Public    Joy_Button_2        ; Joystick button 2 routine
  69.     Public    Joystick_Update     ; Joystick update routine
  70. ;
  71. ;  External Declarations
  72. ;
  73.     Extrn    Key_Status:Byte     ; Keyboard status byte         (KEYBOARD)
  74.     Extrn    Last_Key:Byte        ; Last keyboard scan code    (KEYBOARD)
  75. ;
  76. ;  LOCAL Equates
  77. ;
  78. CENTER_VALUE    Equ    7F00h        ; Joystick center value (7Fh = 127)
  79. START_RES    Equ    0028h        ; Starting resolution (0028h = 0.15625)
  80. MIN_RES     Equ    0001h        ; Minimum resolution (0001h = .0039)
  81. MAX_RES     Equ    7FFFh        ; Maximum resolution (7FFFh = 127.996)
  82. MIN_CENTER    Equ    00001h        ; Minimum center (0001h = .0039)
  83. MAX_CENTER    Equ    0FFFFh        ; Maximum center (FFFFh = 255.996)
  84. JOY_MIN     Equ    00000h        ; Joystick minimum setting value
  85. JOY_MAX     Equ    0FFFFh        ; Joystick maximum setting value
  86. SMALL_RES    Equ    0001h        ; Small resolution change (01h = .004)
  87. NORMAL_RES    Equ    0010h        ; Normal resolution change (10h = .0625)
  88. SMALL_CENTER    Equ    0100h        ; Small center change value (0100 = 1)
  89. NORMAL_CENTER    Equ    0400h        ; Normal center change value (0400 = 4)
  90. RESET_MASK    Equ    0FCh        ; Forced reset mask (Direction/Buttons)
  91. BUTTON_DOWN    Equ    80h        ; Button down indication value
  92. CHARGED     Equ    80h        ; Joystick charged indication value
  93. RESET_JOY    Equ    BINARY_TYPE    ; Joystick reset value (Binary)
  94. ;
  95. ;  Define any include files needed
  96. ;
  97.     Include     Macros.inc    ; Include the macro definitions
  98.     Include     Equates.inc    ; Include the equate definitions
  99.     .286c                ; Include 80286 instructions
  100.     Page
  101. ;
  102. ;  Define the emulator code segment
  103. ;
  104. Emulate Segment Word Public 'EMULATE'   ; Emulator code segment
  105.     Assume    cs:Emulate, ds:Nothing, es:Nothing
  106.     Subttl    Button_1    Button 1 Input Routine
  107.     Page    +
  108. ;******************************************************************************
  109. ;
  110. ;    Button_1()    Joystick 1 Button
  111. ;
  112. ;        Default to button 1 NOT down
  113. ;        If button 1 is down
  114. ;            Indicate that button 1 is down
  115. ;        Endif for button check
  116. ;        Return to the caller
  117. ;
  118. ;    Registers on Entry:
  119. ;
  120. ;        None
  121. ;
  122. ;    Registers on Exit:
  123. ;
  124. ;        AL    - Joystick button 1 status (00h = Up, 80h = Down)
  125. ;
  126. ;******************************************************************************
  127.         Even            ; Force procedure to even address
  128. Button_1    Proc    Near        ; Button 1 input procedure
  129.     xor    al,al            ; Default to button NOT down
  130.     test    cs:[Joy_Flag],BUTTON_1_DOWN
  131.     jz    Button_1_Exit        ; Jump if button 1 is NOT down
  132.     mov    al,BUTTON_DOWN        ; Indicate button 1 is down
  133. Button_1_Exit:
  134.     ret                ; Return to the caller
  135. Button_1    Endp            ; End of the Button_1 procedure
  136.     Subttl    Button_2    Button 2 Input Routine
  137.     Page    +
  138. ;******************************************************************************
  139. ;
  140. ;    Button_2()    Joystick 2 Button
  141. ;
  142. ;        Default to button 2 NOT down
  143. ;        If button 2 is down
  144. ;            Indicate that button 2 is down
  145. ;        Endif for button check
  146. ;        Return to the caller
  147. ;
  148. ;    Registers on Entry:
  149. ;
  150. ;        None
  151. ;
  152. ;    Registers on Exit:
  153. ;
  154. ;        None
  155. ;
  156. ;******************************************************************************
  157.         Even            ; Force procedure to even address
  158. Button_2    Proc    Near        ; Button 2 input procedure
  159.     xor    al,al            ; Default to button NOT down
  160.     test    cs:[Joy_Flag],BUTTON_2_DOWN
  161.     jz    Button_2_Exit        ; Jump if button 2 is NOT down
  162.     mov    al,BUTTON_DOWN        ; Indicate button 2 is down
  163. Button_2_Exit:
  164.     ret                ; Return to the caller
  165. Button_2    Endp            ; End of the Button_2 procedure
  166.     Subttl    Button_3    Button 3 Input Routine
  167.     Page    +
  168. ;******************************************************************************
  169. ;
  170. ;    Button_3()    NOT SUPPORTED
  171. ;
  172. ;        Return to the caller
  173. ;
  174. ;    Registers on Entry:
  175. ;
  176. ;        None
  177. ;
  178. ;    Registers on Exit:
  179. ;
  180. ;        None
  181. ;
  182. ;******************************************************************************
  183.         Even            ; Force procedure to even address
  184. Button_3    Proc    Near        ; Button 3 input procedure
  185.     ret                ; Return to the caller
  186. Button_3    Endp            ; End of the Button_3 procedure
  187.     Subttl    Joystick_1    Joystick 1 Input Routine
  188.     Page    +
  189. ;******************************************************************************
  190. ;
  191. ;    Joystick_1()    Joystick 1 X-Axis
  192. ;
  193. ;        Save the required registers
  194. ;        Default to discharged state
  195. ;        If keyboard is in the joystick mode
  196. ;            Get the X counter value
  197. ;            If the counter value is non-zero
  198. ;                Indicate in charged state
  199. ;                Decrement the counter value
  200. ;                Update the counter value
  201. ;            Endif for non-zero counter
  202. ;        Endif for keyboard in joystick mode
  203. ;        Restore the required registers
  204. ;        Return to the caller
  205. ;
  206. ;    Registers on Entry:
  207. ;
  208. ;        None
  209. ;
  210. ;    Registers on Exit:
  211. ;
  212. ;        AL    - Joystick status (00h = Discharged, 80h = Charged)
  213. ;
  214. ;******************************************************************************
  215.         Even            ; Force procedure to even address
  216. Joystick_1    Proc    Near        ; Joystick 1 input procedure
  217.     Save    bx            ; Save the required registers
  218.     xor    al,al            ; Default to discharged state
  219.     test    cs:[Key_Status],JOY_MODE; Check for keyboard in joystick mode
  220.     jz    Joy_1_Done        ; Jump if NOT in joystick mode
  221.     mov    bl,cs:[Joy_X_Count]    ; Get the current X count value
  222.     or    bl,bl            ; CHeck for already discharged
  223.     jz    Joy_1_Done        ; Jump if already discharged
  224.     mov    al,CHARGED        ; Indicate joystick still charged
  225.     dec    bl            ; Decrement the X count value
  226.     mov    cs:[Joy_X_Count],bl    ; Update the X count value
  227. Joy_1_Done:
  228.     Restore bx            ; Restore the required registers
  229.     ret                ; Return to the caller
  230. Joystick_1    Endp            ; End of the Joystick_1 procedure
  231.     Subttl    Joystick_2    Joystick 2 Input Routine
  232.     Page    +
  233. ;******************************************************************************
  234. ;
  235. ;    Joystick_2()    Joystick 2 Y-Axis
  236. ;
  237. ;        Save the required registers
  238. ;        Default to discharged state
  239. ;        If keyboard is in the joystick mode
  240. ;            Get the Y counter value
  241. ;            If the counter value is non-zero
  242. ;                Indicate in charged state
  243. ;                Decrement the counter value
  244. ;                Update the counter value
  245. ;            Endif for non-zero counter
  246. ;        Endif for keyboard in joystick mode
  247. ;        Restore the required registers
  248. ;        Return to the caller
  249. ;
  250. ;    Registers on Entry:
  251. ;
  252. ;        None
  253. ;
  254. ;    Registers on Exit:
  255. ;
  256. ;        AL    - Joystick status (00h = Discharged, 80h = Charged)
  257. ;
  258. ;******************************************************************************
  259.         Even            ; Force procedure to even address
  260. Joystick_2    Proc    Near        ; Joystick 2 input procedure
  261.     Save    bx            ; Save the required registers
  262.     xor    al,al            ; Default to discharged state
  263.     test    cs:[Key_Status],JOY_MODE; Check for keyboard in joystick mode
  264.     jz    Joy_1_Done        ; Jump if NOT in joystick mode
  265.     mov    bl,cs:[Joy_Y_Count]    ; Get the current Y count value
  266.     or    bl,bl            ; CHeck for already discharged
  267.     jz    Joy_2_Done        ; Jump if already discharged
  268.     mov    al,CHARGED        ; Indicate joystick still charged
  269.     dec    bl            ; Decrement the Y count value
  270.     mov    cs:[Joy_Y_Count],bl    ; Update the Y count value
  271. Joy_2_Done:
  272.     Restore bx            ; Restore the required registers
  273.     ret                ; Return to the caller
  274. Joystick_2    Endp            ; End of the Joystick_2 procedure
  275.     Subttl    Joystick_3    Joystick 3 Input Routine
  276.     Page    +
  277. ;******************************************************************************
  278. ;
  279. ;    Joystick_3()    NOT SUPPORTED
  280. ;
  281. ;        Return to the caller
  282. ;
  283. ;    Registers on Entry:
  284. ;
  285. ;        None
  286. ;
  287. ;    Registers on Exit:
  288. ;
  289. ;        None
  290. ;
  291. ;******************************************************************************
  292.         Even            ; Force procedure to even address
  293. Joystick_3    Proc    Near        ; Joystick 3 input procedure
  294.     ret                ; Return to the caller
  295. Joystick_3    Endp            ; End of the Joystick_3 procedure
  296.     Subttl    Joystick_4    Joystick 4 Input Routine
  297.     Page    +
  298. ;******************************************************************************
  299. ;
  300. ;    Joystick_4()    NOT SUPPORTED
  301. ;
  302. ;        Return to the caller
  303. ;
  304. ;    Registers on Entry:
  305. ;
  306. ;        None
  307. ;
  308. ;    Registers on Exit:
  309. ;
  310. ;        None
  311. ;
  312. ;******************************************************************************
  313.         Even            ; Force procedure to even address
  314. Joystick_4    Proc    Near        ; Joystick 4 input procedure
  315.     ret                ; Return to the caller
  316. Joystick_4    Endp            ; End of the Joystick_4 procedure
  317.     Subttl    Joystick_Strobe Joystick Strobe Routine
  318.     Page    +
  319. ;******************************************************************************
  320. ;
  321. ;    Joystick_Strobe()
  322. ;
  323. ;        Save the required registers
  324. ;        If keyboard in joystick mode
  325. ;            Get the current X position
  326. ;            Get the current Y position
  327. ;            Save X position as X counter
  328. ;            Save Y position as Y counter
  329. ;        Endif
  330. ;        Restore the required registers
  331. ;        Return to the caller
  332. ;
  333. ;    Registers on Entry:
  334. ;
  335. ;        None
  336. ;
  337. ;    Registers on Exit:
  338. ;
  339. ;        None
  340. ;
  341. ;******************************************************************************
  342.         Even            ; Force procedure to even address
  343. Joystick_Strobe Proc    Near        ; Joystick strobe procedure
  344.     Save    ax,bx            ; Save the required registers
  345.     test    cs:[Key_Status],JOY_MODE; Check for keyboard in joystick mode
  346.     jz    Strobe_Done        ; Jump if NOT in joystick mode
  347.     mov    ax,cs:[Joy_X_Pos]    ; Get the current X position
  348.     mov    bx,cs:[Joy_Y_Pos]    ; Get the current Y position
  349.     mov    cs:[Joy_X_Count],ah    ; Save X position as the X count value
  350.     mov    cs:[Joy_Y_Count],bh    ; Save Y position as the Y count value
  351. Strobe_Done:
  352.     Restore ax,bx            ; Restore the required registers
  353.     ret                ; Return to the caller
  354. Joystick_Strobe Endp            ; End of the Joystick_Strobe procedure
  355.     Subttl    Joystick_Fast    Joystick Fast Response Mode Routine
  356.     Page    +
  357. ;******************************************************************************
  358. ;
  359. ;    Joystick_Fast(Scan_Code)
  360. ;
  361. ;        If the last scan code does NOT match (NOT a repeat)
  362. ;            If this is a make code
  363. ;                Toggle the joystick fast response mode bit
  364. ;            Endif
  365. ;        Endif
  366. ;        Return to the caller
  367. ;
  368. ;    Registers on Entry:
  369. ;
  370. ;        AH    - Original scan code
  371. ;
  372. ;    Registers on Exit:
  373. ;
  374. ;        None
  375. ;
  376. ;******************************************************************************
  377.         Even            ; Force procedure to even address
  378. Joystick_Fast    Proc    Near        ; Joystick fast response mode procedure
  379.     cmp    ah,cs:[Last_Key]    ; Check for a repeat scan code
  380.     je    Fast_Done        ; Jump if this key is repeating
  381.     or    ah,ah            ; Check for a make or break code
  382.     js    Fast_Done        ; Jump if this is a break code
  383.     xor    Byte Ptr cs:[Joy_Flag],FAST_MODE
  384. Fast_Done:
  385.     ret                ; Return to the caller
  386. Joystick_Fast    Endp            ; End of the Joystick_Fast procedure
  387.     Subttl    Joystick_Center Joystick Self-Center Mode Routine
  388.     Page    +
  389. ;******************************************************************************
  390. ;
  391. ;    Joystick_Center(Scan_Code)
  392. ;
  393. ;        If the last scan code does NOT match (NOT a repeat)
  394. ;            If this is a make code
  395. ;                Toggle the joystick self-center mode bit
  396. ;            Endif
  397. ;        Endif
  398. ;        Return to the caller
  399. ;
  400. ;    Registers on Entry:
  401. ;
  402. ;        AH    - Original scan code
  403. ;
  404. ;    Registers on Exit:
  405. ;
  406. ;        None
  407. ;
  408. ;******************************************************************************
  409.         Even            ; Force procedure to even address
  410. Joystick_Center Proc    Near        ; Joystick self-center mode procedure
  411.     cmp    ah,cs:[Last_Key]    ; Check for a repeat scan code
  412.     je    Self_Done        ; Jump if this key is repeating
  413.     or    ah,ah            ; Check for a make or break code
  414.     js    Self_Done        ; Jump if this is a break code
  415.     xor    Byte Ptr cs:[Joy_Flag],SELF_CENTER
  416. Self_Done:
  417.     ret                ; Return to the caller
  418. Joystick_Center Endp            ; End of the Joystick_Center procedure
  419.     Subttl    Joystick_Flight Joystick Flight Mode Routine
  420.     Page    +
  421. ;******************************************************************************
  422. ;
  423. ;    Joystick_Flight(Scan_Code)
  424. ;
  425. ;        If the last scan code does NOT match (NOT a repeat)
  426. ;            If this is a make code
  427. ;                Toggle the joystick flight mode bit
  428. ;            Endif
  429. ;        Endif
  430. ;        Return to the caller
  431. ;
  432. ;    Registers on Entry:
  433. ;
  434. ;        AH    - Original scan code
  435. ;
  436. ;    Registers on Exit:
  437. ;
  438. ;        None
  439. ;
  440. ;******************************************************************************
  441.         Even            ; Force procedure to even address
  442. Joystick_Flight Proc    Near        ; Joystick flight mode procedure
  443.     cmp    ah,cs:[Last_Key]    ; Check for a repeat scan code
  444.     je    Flight_Done        ; Jump if this key is repeating
  445.     or    ah,ah            ; Check for a make or break code
  446.     js    Flight_Done        ; Jump if this is a break code
  447.     xor    Byte Ptr cs:[Joy_Flag],FLIGHT_MODE
  448. Flight_Done:
  449.     ret                ; Return to the caller
  450. Joystick_Flight Endp            ; End of the Joystick_Flight procedure
  451.     Subttl    Joystick_Reset    Joystick Reset Routine
  452.     Page    +
  453. ;******************************************************************************
  454. ;
  455. ;    Joystick_Reset(Scan_Code)
  456. ;
  457. ;        If the last scan code does NOT match (NOT a repeat)
  458. ;            If this is a make code
  459. ;                Reset joystick position to center
  460. ;                Reset joystick center values
  461. ;                Reset joystick X/Y resolutions
  462. ;                Reset joystick type & mode values
  463. ;                Reset the joystick status
  464. ;            Endif
  465. ;        Endif
  466. ;        Return to the caller
  467. ;
  468. ;    Registers on Entry:
  469. ;
  470. ;        AH    - Original scan code
  471. ;
  472. ;    Registers on Exit:
  473. ;
  474. ;        None
  475. ;
  476. ;******************************************************************************
  477.         Even            ; Force procedure to even address
  478. Joystick_Reset    Proc    Near        ; Joystick reset procedure
  479.     cmp    ah,cs:[Last_Key]    ; Check for a repeat scan code
  480.     je    Reset_Done        ; Jump if this key is repeating
  481.     or    ah,ah            ; Check for a make or break code
  482.     js    Reset_Done        ; Jump if this is a break code
  483.     mov    cs:[Joy_X_Pos],CENTER_VALUE
  484.     mov    cs:[Joy_Y_Pos],CENTER_VALUE
  485.     mov    cs:[Joy_X_Center],CENTER_VALUE
  486.     mov    cs:[Joy_Y_Center],CENTER_VALUE
  487.     mov    cs:[Joy_X_Res],START_RES
  488.     mov    cs:[Joy_Y_Res],START_RES
  489.     mov    Byte Ptr cs:[Joy_Flag],RESET_JOY
  490. Reset_Done:
  491.     ret                ; Return to the caller
  492. Joystick_Reset    Endp            ; End of the Joystick_Reset procedure
  493.     Subttl    Joystick_Mode    Joystick Mode Routine
  494.     Page    +
  495. ;******************************************************************************
  496. ;
  497. ;    Joystick_Mode(Scan_Code)
  498. ;
  499. ;        If the last scan code does NOT match (NOT a repeat)
  500. ;            If this is a make code
  501. ;                Reset joystick status (Direction and buttons)
  502. ;            Endif
  503. ;        Endif
  504. ;        Return to the caller
  505. ;
  506. ;    Registers on Entry:
  507. ;
  508. ;        AH    - Original scan code
  509. ;
  510. ;    Registers on Exit:
  511. ;
  512. ;        None
  513. ;
  514. ;******************************************************************************
  515.         Even            ; Force procedure to even address
  516. Joystick_Mode    Proc    Near        ; Joystick mode procedure
  517.     cmp    ah,cs:[Last_Key]    ; Check for a repeat scan code
  518.     je    Mode_Done        ; Jump if this key is repeating
  519.     or    ah,ah            ; Check for a make or break code
  520.     js    Mode_Done        ; Jump if this is a break code
  521.     and    Byte Ptr cs:[Joy_Flag],RESET_MASK
  522. Mode_Done:
  523.     ret                ; Return to the caller
  524. Joystick_Mode    Endp            ; End of the Joystick_Mode procedure
  525.     Subttl    Joystick_Type    Joystick Type Routine
  526.     Page    +
  527. ;******************************************************************************
  528. ;
  529. ;    Joystick_Type(Scan_Code)
  530. ;
  531. ;        If the last scan code does NOT match (NOT a repeat)
  532. ;            If this is a make code
  533. ;                Toggle the joystick type bit
  534. ;            Endif
  535. ;        Endif
  536. ;        Return to the caller
  537. ;
  538. ;    Registers on Entry:
  539. ;
  540. ;        AH    - Original scan code
  541. ;
  542. ;    Registers on Exit:
  543. ;
  544. ;        None
  545. ;
  546. ;******************************************************************************
  547.         Even            ; Force procedure to even address
  548. Joystick_Type    Proc    Near        ; Joystick type procedure
  549.     cmp    ah,cs:[Last_Key]    ; Check for a repeat scan code
  550.     je    Type_Done        ; Jump if this key is repeating
  551.     or    ah,ah            ; Check for a make or break code
  552.     js    Type_Done        ; Jump if this is a break code
  553.     xor    Byte Ptr cs:[Joy_Flag],BINARY_TYPE
  554. Type_Done:
  555.     ret                ; Return to the caller
  556. Joystick_Type    Endp            ; End of the Joystick_Type procedure
  557.     Subttl    Joystick_Dummy    Joystick Dummy Routine
  558.     Page    +
  559. ;******************************************************************************
  560. ;
  561. ;    Joystick_Dummy()
  562. ;
  563. ;        Return to the caller
  564. ;
  565. ;    Registers on Entry:
  566. ;
  567. ;        None
  568. ;
  569. ;    Registers on Exit:
  570. ;
  571. ;        None
  572. ;
  573. ;******************************************************************************
  574.         Even            ; Force procedure to even address
  575. Joystick_Dummy    Proc    Near        ; Joystick dummy procedure
  576.     ret                ; Return to the caller
  577. Joystick_Dummy    Endp            ; End of the Joystick_Dummy procedure
  578.     Subttl    Joy_Up_Left    Joystick Up/Left Routine
  579.     Page    +
  580. ;******************************************************************************
  581. ;
  582. ;    Joy_Up_Left(Scan_Code)
  583. ;
  584. ;        Save the required registers
  585. ;        If this is a make code
  586. ;            Set the up/left flag bit
  587. ;            If joystick type is binary
  588. ;                Set joystick X position to JOY_MIN
  589. ;                Set joystick Y position to JOY_MIN
  590. ;            Else
  591. ;                If joystick mode is fast response
  592. ;                    If X position is > X center value
  593. ;                        Set X position to X center value
  594. ;                    Endif
  595. ;                    If Y position is > Y center value
  596. ;                        Set Y position to Y center value
  597. ;                    Endif
  598. ;                Endif for joystick fast response mode
  599. ;            Endif for joystick type binary
  600. ;        Else this is a break code
  601. ;            Reset the up/left flag bit
  602. ;            If this is self-center mode
  603. ;                Set joystick X position to X center value
  604. ;                Set joystick Y position to Y center value
  605. ;            Endif for self-center mode
  606. ;        Endif for scan code
  607. ;        Restore the required registers
  608. ;        Return to the caller
  609. ;
  610. ;    Registers on Entry:
  611. ;
  612. ;        AH    - Original scan code
  613. ;
  614. ;    Registers on Exit:
  615. ;
  616. ;        None
  617. ;
  618. ;******************************************************************************
  619.         Even            ; Force procedure to even address
  620. Joy_Up_Left    Proc    Near        ; Joystick up/left procedure
  621.     Save    bx,cx            ; Save the required registers
  622.     or    ah,ah            ; Check for a make or break code
  623.     js    Up_Left_Break        ; Jump if this is a break code
  624. Up_Left_Make:
  625.     or    Byte Ptr cs:[Joy_Status],UP_LEFT
  626.     mov    bx,cs:[Joy_X_Pos]    ; Get the current joystick X position
  627.     mov    cx,cs:[Joy_Y_Pos]    ; Get the current joystick Y position
  628.     test    cs:[Joy_Flag],BINARY_TYPE
  629.     jz    Up_Left_Check        ; Jump if NOT in binary mode
  630.     mov    bx,JOY_MIN        ; Set X position to joystick minimum
  631.     mov    cx,JOY_MIN        ; Set Y position to joystick minimum
  632.     jmp    Short Up_Left_Update    ; Go update the X and Y positions
  633. Up_Left_Check:
  634.     test    cs:[Joy_Flag],FAST_MODE
  635.     jz    Up_Left_Done        ; Jump if NOT in fast response mode
  636.     cmp    bx,cs:[Joy_X_Center]    ; Check the current X position value
  637.     jbe    Up_Left_Test        ; Jump if already moving left
  638.     mov    bx,cs:[Joy_X_Center]    ; Center the joystick X position
  639. Up_Left_Test:
  640.     cmp    cx,cs:[Joy_Y_Center]    ; Check the current Y position value
  641.     jbe    Up_Left_Update        ; Jump if already moving up
  642.     mov    cx,cs:[Joy_Y_Center]    ; Center the joystick Y position
  643. Up_Left_Update:
  644.     mov    cs:[Joy_X_Pos],bx    ; Update the current X position value
  645.     mov    cs:[Joy_Y_Pos],cx    ; Update the current Y position value
  646.     jmp    Short Up_Left_Done    ; Go return to the caller
  647. Up_Left_Break:
  648.     and    Byte Ptr cs:[Joy_Status],Not UP_LEFT
  649.     test    cs:[Joy_Flag],SELF_CENTER
  650.     jz    Up_Left_Done        ; Jump if NOT in self-center mode
  651.     mov    bx,cs:[Joy_X_Center]    ; Get the current X center value
  652.     mov    cs:[Joy_X_Pos],bx    ; Set X position to center value
  653.     mov    bx,cs:[Joy_Y_Center]    ; Get the current Y center value
  654.     mov    cs:[Joy_Y_Pos],bx    ; Set Y position to center value
  655. Up_Left_Done:
  656.     Restore bx,cx            ; Restore the required registers
  657.     ret                ; Return to the caller
  658. Joy_Up_Left    Endp            ; End of the Joy_Up_Left procedure
  659.     Subttl    Joy_Up        Joystick Up Routine
  660.     Page    +
  661. ;******************************************************************************
  662. ;
  663. ;    Joy_Up(Scan_Code)
  664. ;
  665. ;        Save the required registers
  666. ;        If this is a make code
  667. ;            Set the up flag bit
  668. ;            If joystick type is binary
  669. ;                If joystick mode is NOT flight mode
  670. ;                    Set joystick X pos. to X center value
  671. ;                Endif
  672. ;                Set joystick Y position to JOY_MIN
  673. ;            Else
  674. ;                If joystick mode is fast response
  675. ;                    If Y position is > Y center value
  676. ;                        Set Y position to Y center value
  677. ;                    Endif
  678. ;                Endif for joystick fast response mode
  679. ;            Endif for joystick type binary
  680. ;        Else this is a break code
  681. ;            Reset the up flag bit
  682. ;            If this is self-center mode
  683. ;                Set joystick Y position to Y center value
  684. ;            Endif for self-center mode
  685. ;        Endif for scan code
  686. ;        Restore the required registers
  687. ;        Return to the caller
  688. ;
  689. ;    Registers on Entry:
  690. ;
  691. ;        AH    - Original scan code
  692. ;
  693. ;    Registers on Exit:
  694. ;
  695. ;        None
  696. ;
  697. ;******************************************************************************
  698.         Even            ; Force procedure to even address
  699. Joy_Up        Proc    Near        ; Joystick up procedure
  700.     Save    cx            ; Save the required registers
  701.     or    ah,ah            ; Check for a make or break code
  702.     js    Up_Break        ; Jump if this is a break code
  703. Up_Make:
  704.     or    Byte Ptr cs:[Joy_Status],UP
  705.     mov    cx,cs:[Joy_Y_Pos]    ; Get the current joystick Y position
  706.     test    cs:[Joy_Flag],BINARY_TYPE
  707.     jz    Up_Check        ; Jump if NOT in binary mode
  708.     test    cs:[Joy_Flag],FLIGHT_MODE
  709.     jnz    Up_Binary        ; Jump if in flight mode
  710.     mov    cx,cs:[Joy_X_Center]    ; Get the current X center value
  711.     mov    cs:[Joy_X_Pos],cx    ; Set X position to center value
  712. Up_Binary:
  713.     mov    cx,JOY_MIN        ; Set Y position to joystick minimum
  714.     jmp    Short Up_Update     ; Go update the Y position
  715. Up_Check:
  716.     test    cs:[Joy_Flag],FAST_MODE
  717.     jz    Up_Done         ; Jump if NOT in fast response mode
  718.     cmp    cx,cs:[Joy_Y_Center]    ; Check the current Y position value
  719.     jbe    Up_Update        ; Jump if already moving up
  720.     mov    cx,cs:[Joy_Y_Center]    ; Center the joystick Y position
  721. Up_Update:
  722.     mov    cs:[Joy_Y_Pos],cx    ; Update the current Y position value
  723.     jmp    Short Up_Done        ; Go return to the caller
  724. Up_Break:
  725.     and    Byte Ptr cs:[Joy_Status],Not UP
  726.     test    cs:[Joy_Flag],SELF_CENTER
  727.     jz    Up_Done         ; Jump if NOT in self-center mode
  728.     mov    cx,cs:[Joy_Y_Center]    ; Get the current Y center value
  729.     mov    cs:[Joy_Y_Pos],cx    ; Set Y position to center value
  730. Up_Done:
  731.     Restore cx            ; Restore the required registers
  732.     ret                ; Return to the caller
  733. Joy_Up        Endp            ; End of the Joy_Up procedure
  734.     Subttl    Joy_Up_Right    Joystick Up/Right Routine
  735.     Page    +
  736. ;******************************************************************************
  737. ;
  738. ;    Joy_Up_Right(Scan_Code)
  739. ;
  740. ;        Save the required registers
  741. ;        If this is a make code
  742. ;            Set the up/right flag bit
  743. ;            If joystick type is binary
  744. ;                Set joystick X position to JOY_MAX
  745. ;                Set joystick Y position to JOY_MIN
  746. ;            Else
  747. ;                If joystick mode is fast response
  748. ;                    If X position is <= X center value
  749. ;                        Set X position to X center value
  750. ;                    Endif
  751. ;                    If Y position is > Y center value
  752. ;                        Set Y position to Y center value
  753. ;                    Endif
  754. ;                Endif for joystick fast response mode
  755. ;            Endif for joystick type binary
  756. ;        Else this is a break code
  757. ;            Reset the up/right flag bit
  758. ;            If this is self-center mode
  759. ;                Set joystick X position to X center value
  760. ;                Set joystick Y position to Y center value
  761. ;            Endif for self-center mode
  762. ;        Endif for scan code
  763. ;        Restore the required registers
  764. ;        Return to the caller
  765. ;
  766. ;    Registers on Entry:
  767. ;
  768. ;        AH    - Original scan code
  769. ;
  770. ;    Registers on Exit:
  771. ;
  772. ;        None
  773. ;
  774. ;******************************************************************************
  775.         Even            ; Force procedure to even address
  776. Joy_Up_Right    Proc    Near        ; Joystick up/right procedure
  777.     Save    bx,cx            ; Save the required registers
  778.     or    ah,ah            ; Check for a make or break code
  779.     js    Up_Right_Break        ; Jump if this is a break code
  780. Up_Right_Make:
  781.     or    Byte Ptr cs:[Joy_Status],UP_RIGHT
  782.     mov    bx,cs:[Joy_X_Pos]    ; Get the current joystick X position
  783.     mov    cx,cs:[Joy_Y_Pos]    ; Get the current joystick Y position
  784.     test    cs:[Joy_Flag],BINARY_TYPE
  785.     jz    Up_Right_Check        ; Jump if NOT in binary mode
  786.     mov    bx,JOY_MAX        ; Set X position to joystick maximum
  787.     mov    cx,JOY_MIN        ; Set Y position to joystick minimum
  788.     jmp    Short Up_Right_Update    ; Go update the X and Y positions
  789. Up_Right_Check:
  790.     test    cs:[Joy_Flag],FAST_MODE
  791.     jz    Up_Right_Done        ; Jump if NOT in fast response mode
  792.     cmp    bx,cs:[Joy_X_Center]    ; Check the current X position value
  793.     ja    Up_Right_Test        ; Jump if already moving right
  794.     mov    bx,cs:[Joy_X_Center]    ; Center the joystick X position
  795. Up_Right_Test:
  796.     cmp    cx,cs:[Joy_Y_Center]    ; Check the current Y position value
  797.     jbe    Up_Right_Update     ; Jump if already moving up
  798.     mov    cx,cs:[Joy_Y_Center]    ; Center the joystick Y position
  799. Up_Right_Update:
  800.     mov    cs:[Joy_X_Pos],bx    ; Update the current X position value
  801.     mov    cs:[Joy_Y_Pos],cx    ; Update the current Y position value
  802.     jmp    Short Up_Right_Done    ; Go return to the caller
  803. Up_Right_Break:
  804.     and    Byte Ptr cs:[Joy_Status],Not UP_RIGHT
  805.     test    cs:[Joy_Flag],SELF_CENTER
  806.     jz    Up_Right_Done        ; Jump if NOT in self-center mode
  807.     mov    bx,cs:[Joy_X_Center]    ; Get the current X center value
  808.     mov    cs:[Joy_X_Pos],bx    ; Set X position to center value
  809.     mov    bx,cs:[Joy_Y_Center]    ; Get the current Y center value
  810.     mov    cs:[Joy_Y_Pos],bx    ; Set Y position to center value
  811. Up_Right_Done:
  812.     Restore bx,cx            ; Restore the required registers
  813.     ret                ; Return to the caller
  814. Joy_Up_Right    Endp            ; End of the Joy_Up_Right procedure
  815.     Subttl    Joy_Left    Joystick Left Routine
  816.     Page    +
  817. ;******************************************************************************
  818. ;
  819. ;    Joy_Left(Scan_Code)
  820. ;
  821. ;        Save the required registers
  822. ;        If this is a make code
  823. ;            Set the left flag bit
  824. ;            If joystick type is binary
  825. ;                If joystick mode is NOT flight mode
  826. ;                    Set joystick Y pos. to Y center value
  827. ;                Endif
  828. ;                Set joystick X position to JOY_MIN
  829. ;            Else
  830. ;                If joystick mode is fast response
  831. ;                    If X position is > X center value
  832. ;                        Set X position to X center value
  833. ;                    Endif
  834. ;                Endif for joystick fast response mode
  835. ;            Endif for joystick type binary
  836. ;        Else this is a break code
  837. ;            Reset the up flag bit
  838. ;            If this is self-center mode
  839. ;                Set joystick X position to X center value
  840. ;            Endif for self-center mode
  841. ;        Endif for scan code
  842. ;        Restore the required registers
  843. ;        Return to the caller
  844. ;
  845. ;    Registers on Entry:
  846. ;
  847. ;        AH    - Original scan code
  848. ;
  849. ;    Registers on Exit:
  850. ;
  851. ;        None
  852. ;
  853. ;******************************************************************************
  854.         Even            ; Force procedure to even address
  855. Joy_Left    Proc    Near        ; Joystick left procedure
  856.     Save    bx            ; Save the required registers
  857.     or    ah,ah            ; Check for a make or break code
  858.     js    Left_Break        ; Jump if this is a break code
  859. Left_Make:
  860.     or    Byte Ptr cs:[Joy_Status],LEFT
  861.     mov    bx,cs:[Joy_X_Pos]    ; Get the current joystick X position
  862.     test    cs:[Joy_Flag],BINARY_TYPE
  863.     jz    Left_Check        ; Jump if NOT in binary mode
  864.     test    cs:[Joy_Flag],FLIGHT_MODE
  865.     jnz    Left_Binary        ; Jump if in flight mode
  866.     mov    bx,cs:[Joy_Y_Center]    ; Get the current Y center value
  867.     mov    cs:[Joy_Y_Pos],bx    ; Set Y position to center value
  868. Left_Binary:
  869.     mov    bx,JOY_MIN        ; Set X position to joystick minimum
  870.     jmp    Short Left_Update    ; Go update the X position
  871. Left_Check:
  872.     test    cs:[Joy_Flag],FAST_MODE
  873.     jz    Left_Done        ; Jump if NOT in fast response mode
  874.     cmp    bx,cs:[Joy_X_Center]    ; Check the current X position value
  875.     jbe    Left_Update        ; Jump if already moving left
  876.     mov    bx,cs:[Joy_X_Center]    ; Center the joystick X position
  877. Left_Update:
  878.     mov    cs:[Joy_X_Pos],bx    ; Update the current X position value
  879.     jmp    Short Left_Done     ; Go return to the caller
  880. Left_Break:
  881.     and    Byte Ptr cs:[Joy_Status],Not LEFT
  882.     test    cs:[Joy_Flag],SELF_CENTER
  883.     jz    Left_Done        ; Jump if NOT in self-center mode
  884.     mov    bx,cs:[Joy_X_Center]    ; Get the current X center value
  885.     mov    cs:[Joy_X_Pos],bx    ; Set X position to center value
  886. Left_Done:
  887.     Restore cx            ; Restore the required registers
  888.     ret                ; Return to the caller
  889. Joy_Left    Endp            ; End of the Joy_Left procedure
  890.     Subttl    Joy_Center    Joystick Center Routine
  891.     Page    +
  892. ;******************************************************************************
  893. ;
  894. ;    Joy_Center(Scan_Code)
  895. ;
  896. ;        Save the required registers
  897. ;        If this is a make code
  898. ;            Center the joystick X and Y positions
  899. ;        Endif
  900. ;        Restore the required registers
  901. ;        Return to the caller
  902. ;
  903. ;    Registers on Entry:
  904. ;
  905. ;        AH    - Original scan code
  906. ;
  907. ;    Registers on Exit:
  908. ;
  909. ;        None
  910. ;
  911. ;******************************************************************************
  912.         Even            ; Force procedure to even address
  913. Joy_Center    Proc    Near        ; Joystick center procedure
  914.     Save    bx            ; Save the required registers
  915.     or    ah,ah            ; Check for a make or break code
  916.     js    Center_Done        ; Jump if this is a break code
  917. Center_Make:
  918.     mov    bx,cs:[Joy_X_Center]    ; Get the current X center value
  919.     mov    cs:[Joy_X_Pos],bx    ; Set X position to center value
  920.     mov    bx,cs:[Joy_Y_Center]    ; Get the current Y center value
  921.     mov    cs:[Joy_Y_Pos],bx    ; Set Y position to center value
  922. Center_Done:
  923.     Restore bx            ; Restore the required registers
  924.     ret                ; Return to the caller
  925. Joy_Center    Endp            ; End of the Joy_Center procedure
  926.     Subttl    Joy_Right    Joystick Right Routine
  927.     Page    +
  928. ;******************************************************************************
  929. ;
  930. ;    Joy_Right(Scan_Code)
  931. ;
  932. ;        Save the required registers
  933. ;        If this is a make code
  934. ;            Set the right flag bit
  935. ;            If joystick type is binary
  936. ;                If joystick mode is NOT flight mode
  937. ;                    Set joystick Y pos. to Y center value
  938. ;                Endif
  939. ;                Set joystick X position to JOY_MAX
  940. ;            Else
  941. ;                If joystick mode is fast response
  942. ;                    If X position is <= X center value
  943. ;                        Set X position to X center value
  944. ;                    Endif
  945. ;                Endif for joystick fast response mode
  946. ;            Endif for joystick type binary
  947. ;        Else this is a break code
  948. ;            Reset the up flag bit
  949. ;            If this is self-center mode
  950. ;                Set joystick X position to X center value
  951. ;            Endif for self-center mode
  952. ;        Endif for scan code
  953. ;        Restore the required registers
  954. ;        Return to the caller
  955. ;
  956. ;    Registers on Entry:
  957. ;
  958. ;        AH    - Original scan code
  959. ;
  960. ;    Registers on Exit:
  961. ;
  962. ;        None
  963. ;
  964. ;******************************************************************************
  965.         Even            ; Force procedure to even address
  966. Joy_Right    Proc    Near        ; Joystick right procedure
  967.     Save    bx            ; Save the required registers
  968.     or    ah,ah            ; Check for a make or break code
  969.     js    Right_Break        ; Jump if this is a break code
  970. Right_Make:
  971.     or    Byte Ptr cs:[Joy_Status],RIGHT
  972.     mov    bx,cs:[Joy_X_Pos]    ; Get the current joystick X position
  973.     test    cs:[Joy_Flag],BINARY_TYPE
  974.     jz    Right_Check        ; Jump if NOT in binary mode
  975.     test    cs:[Joy_Flag],FLIGHT_MODE
  976.     jnz    Right_Binary        ; Jump if in flight mode
  977.     mov    bx,cs:[Joy_Y_Center]    ; Get the current Y center value
  978.     mov    cs:[Joy_Y_Pos],bx    ; Set Y position to center value
  979. Right_Binary:
  980.     mov    bx,JOY_MAx        ; Set X position to joystick maximum
  981.     jmp    Short Right_Update    ; Go update the X position
  982. Right_Check:
  983.     test    cs:[Joy_Flag],FAST_MODE
  984.     jz    Right_Done        ; Jump if NOT in fast response mode
  985.     cmp    bx,cs:[Joy_X_Center]    ; Check the current X position value
  986.     ja    Right_Update        ; Jump if already moving right
  987.     mov    bx,cs:[Joy_X_Center]    ; Center the joystick X position
  988. Right_Update:
  989.     mov    cs:[Joy_X_Pos],bx    ; Update the current X position value
  990.     jmp    Short Right_Done    ; Go return to the caller
  991. Right_Break:
  992.     and    Byte Ptr cs:[Joy_Status],Not RIGHT
  993.     test    cs:[Joy_Flag],SELF_CENTER
  994.     jz    Right_Done        ; Jump if NOT in self-center mode
  995.     mov    bx,cs:[Joy_X_Center]    ; Get the current X center value
  996.     mov    cs:[Joy_X_Pos],bx    ; Set X position to center value
  997. Right_Done:
  998.     Restore cx            ; Restore the required registers
  999.     ret                ; Return to the caller
  1000. Joy_Right    Endp            ; End of the Joy_Right procedure
  1001.     Subttl    Joy_Down_Left    Joystick Down/Left Routine
  1002.     Page    +
  1003. ;******************************************************************************
  1004. ;
  1005. ;    Joy_Down_Left(Scan_Code)
  1006. ;
  1007. ;        Save the required registers
  1008. ;        If this is a make code
  1009. ;            Set the down/left flag bit
  1010. ;            If joystick type is binary
  1011. ;                Set joystick X position to JOY_MIN
  1012. ;                Set joystick Y position to JOY_MAX
  1013. ;            Else
  1014. ;                If joystick mode is fast response
  1015. ;                    If X position is > X center value
  1016. ;                        Set X position to X center value
  1017. ;                    Endif
  1018. ;                    If Y position is <= Y center value
  1019. ;                        Set Y position to Y center value
  1020. ;                    Endif
  1021. ;                Endif for joystick fast response mode
  1022. ;            Endif for joystick type binary
  1023. ;        Else this is a break code
  1024. ;            Reset the down/left flag bit
  1025. ;            If this is self-center mode
  1026. ;                Set joystick X position to X center value
  1027. ;                Set joystick Y position to Y center value
  1028. ;            Endif for self-center mode
  1029. ;        Endif for scan code
  1030. ;        Restore the required registers
  1031. ;        Return to the caller
  1032. ;
  1033. ;    Registers on Entry:
  1034. ;
  1035. ;        AH    - Original scan code
  1036. ;
  1037. ;    Registers on Exit:
  1038. ;
  1039. ;        None
  1040. ;
  1041. ;******************************************************************************
  1042.         Even            ; Force procedure to even address
  1043. Joy_Down_Left    Proc    Near        ; Joystick down/left procedure
  1044.     Save    bx,cx            ; Save the required registers
  1045.     or    ah,ah            ; Check for a make or break code
  1046.     js    Down_Left_Break     ; Jump if this is a break code
  1047. Down_Left_Make:
  1048.     or    Byte Ptr cs:[Joy_Status],DOWN_LEFT
  1049.     mov    bx,cs:[Joy_X_Pos]    ; Get the current joystick X position
  1050.     mov    cx,cs:[Joy_Y_Pos]    ; Get the current joystick Y position
  1051.     test    cs:[Joy_Flag],BINARY_TYPE
  1052.     jz    Down_Left_Check     ; Jump if NOT in binary mode
  1053.     mov    bx,JOY_MIN        ; Set X position to joystick minimum
  1054.     mov    cx,JOY_MAX        ; Set Y position to joystick maximum
  1055.     jmp    Short Down_Left_Update    ; Go update the X and Y positions
  1056. Down_Left_Check:
  1057.     test    cs:[Joy_Flag],FAST_MODE
  1058.     jz    Down_Left_Done        ; Jump if NOT in fast response mode
  1059.     cmp    bx,cs:[Joy_X_Center]    ; Check the current X position value
  1060.     jbe    Down_Left_Test        ; Jump if already moving left
  1061.     mov    bx,cs:[Joy_X_Center]    ; Center the joystick X position
  1062. Down_Left_Test:
  1063.     cmp    cx,cs:[Joy_Y_Center]    ; Check the current Y position value
  1064.     ja    Down_Left_Update    ; Jump if already moving down
  1065.     mov    cx,cs:[Joy_Y_Center]    ; Center the joystick Y position
  1066. Down_Left_Update:
  1067.     mov    cs:[Joy_X_Pos],bx    ; Update the current X position value
  1068.     mov    cs:[Joy_Y_Pos],cx    ; Update the current Y position value
  1069.     jmp    Short Down_Left_Done    ; Go return to the caller
  1070. Down_Left_Break:
  1071.     and    Byte Ptr cs:[Joy_Status],Not DOWN_LEFT
  1072.     test    cs:[Joy_Flag],SELF_CENTER
  1073.     jz    Down_Left_Done        ; Jump if NOT in self-center mode
  1074.     mov    bx,cs:[Joy_X_Center]    ; Get the current X center value
  1075.     mov    cs:[Joy_X_Pos],bx    ; Set X position to center value
  1076.     mov    bx,cs:[Joy_Y_Center]    ; Get the current Y center value
  1077.     mov    cs:[Joy_Y_Pos],bx    ; Set Y position to center value
  1078. Down_Left_Done:
  1079.     Restore bx,cx            ; Restore the required registers
  1080.     ret                ; Return to the caller
  1081. Joy_Down_Left    Endp            ; End of the Joy_Down_Left procedure
  1082.     Subttl    Joy_Down    Joystick Down Routine
  1083.     Page    +
  1084. ;******************************************************************************
  1085. ;
  1086. ;    Joy_Down(Scan_Code)
  1087. ;
  1088. ;        Save the required registers
  1089. ;        If this is a make code
  1090. ;            Set the down flag bit
  1091. ;            If joystick type is binary
  1092. ;                If joystick mode is NOT flight mode
  1093. ;                    Set joystick X pos. to X center value
  1094. ;                Endif
  1095. ;                Set joystick Y position to JOY_MAX
  1096. ;            Else
  1097. ;                If joystick mode is fast response
  1098. ;                    If Y position is <= X center value
  1099. ;                        Set Y position to Y center value
  1100. ;                    Endif
  1101. ;                Endif for joystick fast response mode
  1102. ;            Endif for joystick type binary
  1103. ;        Else this is a break code
  1104. ;            Reset the down flag bit
  1105. ;            If this is self-center mode
  1106. ;                Set joystick Y position to Y center value
  1107. ;            Endif for self-center mode
  1108. ;        Endif for scan code
  1109. ;        Restore the required registers
  1110. ;        Return to the caller
  1111. ;
  1112. ;    Registers on Entry:
  1113. ;
  1114. ;        AH    - Original scan code
  1115. ;
  1116. ;    Registers on Exit:
  1117. ;
  1118. ;        None
  1119. ;
  1120. ;******************************************************************************
  1121.         Even            ; Force procedure to even address
  1122. Joy_Down    Proc    Near        ; Joystick down procedure
  1123.     Save    cx            ; Save the required registers
  1124.     or    ah,ah            ; Check for a make or break code
  1125.     js    Down_Break        ; Jump if this is a break code
  1126. Down_Make:
  1127.     or    Byte Ptr cs:[Joy_Status],DOWN
  1128.     mov    cx,cs:[Joy_Y_Pos]    ; Get the current joystick Y position
  1129.     test    cs:[Joy_Flag],BINARY_TYPE
  1130.     jz    Down_Check        ; Jump if NOT in binary mode
  1131.     test    cs:[Joy_Flag],FLIGHT_MODE
  1132.     jnz    Down_Binary        ; Jump if in flight mode
  1133.     mov    cx,cs:[Joy_X_Center]    ; Get the current X center value
  1134.     mov    cs:[Joy_X_Pos],cx    ; Set X position to center value
  1135. Down_Binary:
  1136.     mov    cx,JOY_MAX        ; Set Y position to joystick maximum
  1137.     jmp    Short Down_Update    ; Go update the Y position
  1138. Down_Check:
  1139.     test    cs:[Joy_Flag],FAST_MODE
  1140.     jz    Down_Done        ; Jump if NOT in fast response mode
  1141.     cmp    cx,cs:[Joy_Y_Center]    ; Check the current Y position value
  1142.     ja    Down_Update        ; Jump if already moving down
  1143.     mov    cx,cs:[Joy_Y_Center]    ; Center the joystick Y position
  1144. Down_Update:
  1145.     mov    cs:[Joy_Y_Pos],cx    ; Update the current Y position value
  1146.     jmp    Short Down_Done     ; Go return to the caller
  1147. Down_Break:
  1148.     and    Byte Ptr cs:[Joy_Status],Not DOWN
  1149.     test    cs:[Joy_Flag],SELF_CENTER
  1150.     jz    Down_Done        ; Jump if NOT in self-center mode
  1151.     mov    cx,cs:[Joy_Y_Center]    ; Get the current Y center value
  1152.     mov    cs:[Joy_Y_Pos],cx    ; Set Y position to center value
  1153. Down_Done:
  1154.     Restore cx            ; Restore the required registers
  1155.     ret                ; Return to the caller
  1156. Joy_Down    Endp            ; End of the Joy_Down procedure
  1157.     Subttl    Joy_Down_Right    Joystick Down/Right Routine
  1158.     Page    +
  1159. ;******************************************************************************
  1160. ;
  1161. ;    Joy_Down_Right(Scan_Code)
  1162. ;
  1163. ;        Save the required registers
  1164. ;        If this is a make code
  1165. ;            Set the down/right flag bit
  1166. ;            If joystick type is binary
  1167. ;                Set joystick X position to JOY_MAX
  1168. ;                Set joystick Y position to JOY_MAX
  1169. ;            Else
  1170. ;                If joystick mode is fast response
  1171. ;                    If X position is <= X center value
  1172. ;                        Set X position to X center value
  1173. ;                    Endif
  1174. ;                    If Y position is <= Y center value
  1175. ;                        Set Y position to Y center value
  1176. ;                    Endif
  1177. ;                Endif for joystick fast response mode
  1178. ;            Endif for joystick type binary
  1179. ;        Else this is a break code
  1180. ;            Reset the down/right flag bit
  1181. ;            If this is self-center mode
  1182. ;                Set joystick X position to X center value
  1183. ;                Set joystick Y position to Y center value
  1184. ;            Endif for self-center mode
  1185. ;        Endif for scan code
  1186. ;        Restore the required registers
  1187. ;        Return to the caller
  1188. ;
  1189. ;    Registers on Entry:
  1190. ;
  1191. ;        AH    - Original scan code
  1192. ;
  1193. ;    Registers on Exit:
  1194. ;
  1195. ;        None
  1196. ;
  1197. ;******************************************************************************
  1198.         Even            ; Force procedure to even address
  1199. Joy_Down_Right    Proc    Near        ; Joystick down/right procedure
  1200.     Save    bx,cx            ; Save the required registers
  1201.     or    ah,ah            ; Check for a make or break code
  1202.     js    Down_Right_Break    ; Jump if this is a break code
  1203. Down_Right_Make:
  1204.     or    Byte Ptr cs:[Joy_Status],DOWN_RIGHT
  1205.     mov    bx,cs:[Joy_X_Pos]    ; Get the current joystick X position
  1206.     mov    cx,cs:[Joy_Y_Pos]    ; Get the current joystick Y position
  1207.     test    cs:[Joy_Flag],BINARY_TYPE
  1208.     jz    Down_Right_Check    ; Jump if NOT in binary mode
  1209.     mov    bx,JOY_MAX        ; Set X position to joystick maximum
  1210.     mov    cx,JOY_MAX        ; Set Y position to joystick maximum
  1211.     jmp    Short Down_Right_Update ; Go update the X and Y positions
  1212. Down_Right_Check:
  1213.     test    cs:[Joy_Flag],FAST_MODE
  1214.     jz    Down_Right_Done     ; Jump if NOT in fast response mode
  1215.     cmp    bx,cs:[Joy_X_Center]    ; Check the current X position value
  1216.     ja    Down_Right_Test     ; Jump if already moving right
  1217.     mov    bx,cs:[Joy_X_Center]    ; Center the joystick X position
  1218. Down_Right_Test:
  1219.     cmp    cx,cs:[Joy_Y_Center]    ; Check the current Y position value
  1220.     ja    Down_Right_Update    ; Jump if already moving down
  1221.     mov    cx,cs:[Joy_Y_Center]    ; Center the joystick Y position
  1222. Down_Right_Update:
  1223.     mov    cs:[Joy_X_Pos],bx    ; Update the current X position value
  1224.     mov    cs:[Joy_Y_Pos],cx    ; Update the current Y position value
  1225.     jmp    Short Down_Right_Done    ; Go return to the caller
  1226. Down_Right_Break:
  1227.     and    Byte Ptr cs:[Joy_Status],Not DOWN_RIGHT
  1228.     test    cs:[Joy_Flag],SELF_CENTER
  1229.     jz    Down_Right_Done     ; Jump if NOT in self-center mode
  1230.     mov    bx,cs:[Joy_X_Center]    ; Get the current X center value
  1231.     mov    cs:[Joy_X_Pos],bx    ; Set X position to center value
  1232.     mov    bx,cs:[Joy_Y_Center]    ; Get the current Y center value
  1233.     mov    cs:[Joy_Y_Pos],bx    ; Set Y position to center value
  1234. Down_Right_Done:
  1235.     Restore bx,cx            ; Restore the required registers
  1236.     ret                ; Return to the caller
  1237. Joy_Down_Right    Endp            ; End of the Joy_Down_Right procedure
  1238.     Subttl    Joy_X_Res_Inc    Joystick X Resolution Increase Routine
  1239.     Page    +
  1240. ;******************************************************************************
  1241. ;
  1242. ;    Joy_X_Res_Inc(Scan_Code)
  1243. ;
  1244. ;        Save the required registers
  1245. ;        If this is joystick mode
  1246. ;            If this is a make code
  1247. ;                If the shift key is down
  1248. ;                    Do a small X resolution increment
  1249. ;                Else
  1250. ;                    Do a normal X resolution increment
  1251. ;                Endif
  1252. ;                Make sure X resolution is in range
  1253. ;            Endif this is a break code
  1254. ;        Endif for joystick mode
  1255. ;        Restore the required registers
  1256. ;        Return to the caller
  1257. ;
  1258. ;    Registers on Entry:
  1259. ;
  1260. ;        AH    - Original scan code
  1261. ;
  1262. ;    Registers on Exit:
  1263. ;
  1264. ;        None
  1265. ;
  1266. ;******************************************************************************
  1267.         Even            ; Force procedure to even address
  1268. Joy_X_Res_Inc    Proc    Near        ; Joystick X resolution inc. procedure
  1269.     Save    bx            ; Save the required registers
  1270.     test    cs:[Key_Status],JOY_MODE; Check for keyboard in joystick mode
  1271.     jz    X_Res_Inc_Done        ; Jump if NOT in joystick mode
  1272.     or    ah,ah            ; Check for a make or break code
  1273.     js    X_Res_Inc_Done        ; Jump if this is a break code
  1274.     mov    bx,cs:[Joy_X_Res]    ; Get the current X resolution value
  1275.     test    cs:[Key_Status],SHIFTED ; Check for shift key down
  1276.     jz    Do_X_Res_Inc        ; Jump if shift key is NOT held down
  1277.     add    bx,SMALL_RES        ; Add small change value to resolution
  1278.     jmp    Short X_Res_Inc_Check    ; Go check the X resolution value
  1279. Do_X_Res_Inc:
  1280.     add    bx,NORMAL_RES        ; Add normal change value to resolution
  1281. X_Res_Inc_Check:
  1282.     jc    X_Res_Inc_Bad        ; Jump if X increment is bad
  1283.     cmp    bx,MAX_RES        ; Check against maximum resolution
  1284.     jbe    X_Res_Inc_Update    ; Go update X resolution if in range
  1285. X_Res_Inc_Bad:
  1286.     mov    bx,MAX_RES        ; Set X resolution to maximum value
  1287. X_Res_Inc_Update:
  1288.     mov    cs:[Joy_X_Res],bx    ; Update the X resolution value
  1289. X_Res_Inc_Done:
  1290.     Restore bx            ; Restore the required registers
  1291.     ret                ; Return to the caller
  1292. Joy_X_Res_Inc    Endp            ; End of the Joy_X_Res_Inc procedure
  1293.     Subttl    Joy_X_Res_Dec    Joystick X Resolution Decrease Routine
  1294.     Page    +
  1295. ;******************************************************************************
  1296. ;
  1297. ;    Joy_X_Res_Dec(Scan_Code)
  1298. ;
  1299. ;        Save the required registers
  1300. ;        If this is joystick mode
  1301. ;            If this is a make code
  1302. ;                If the shift key is down
  1303. ;                    Do a small X resolution decrement
  1304. ;                Else
  1305. ;                    Do a normal X resolution decrement
  1306. ;                Endif
  1307. ;                Make sure X resolution is in range
  1308. ;            Endif this is a break code
  1309. ;        Endif for joystick mode
  1310. ;        Restore the required registers
  1311. ;        Return to the caller
  1312. ;
  1313. ;    Registers on Entry:
  1314. ;
  1315. ;        AH    - Original scan code
  1316. ;
  1317. ;    Registers on Exit:
  1318. ;
  1319. ;        None
  1320. ;
  1321. ;******************************************************************************
  1322.         Even            ; Force procedure to even address
  1323. Joy_X_Res_Dec    Proc    Near        ; Joystick X resolution dec. procedure
  1324.     Save    bx            ; Save the required registers
  1325.     test    cs:[Key_Status],JOY_MODE; Check for keyboard in joystick mode
  1326.     jz    X_Res_Dec_Done        ; Jump if NOT in joystick mode
  1327.     or    ah,ah            ; Check for a make or break code
  1328.     js    X_Res_Dec_Done        ; Jump if this is a break code
  1329.     mov    bx,cs:[Joy_X_Res]    ; Get the current X resolution value
  1330.     test    cs:[Key_Status],SHIFTED ; Check for Shift key down
  1331.     jz    Do_X_Res_Dec        ; Jump if shift key is NOT held down
  1332.     sub    bx,SMALL_RES        ; Subtract small change value
  1333.     jmp    Short X_Res_Dec_Check    ; Go check the X resolution value
  1334. Do_X_Res_Dec:
  1335.     sub    bx,NORMAL_RES        ; Subtract normal change value
  1336. X_Res_Dec_Check:
  1337.     jc    X_Res_Dec_Bad        ; Jump if X decrement is bad
  1338.     cmp    bx,MIN_RES        ; Check against minimum resolution
  1339.     jae    X_Res_Dec_Update    ; Go update X resolution if in range
  1340. X_Res_Dec_Bad:
  1341.     mov    bx,MIN_RES        ; Set X resolution to minimum value
  1342. X_Res_Dec_Update:
  1343.     mov    cs:[Joy_X_Res],bx    ; Update the X resolution value
  1344. X_Res_Dec_Done:
  1345.     Restore bx            ; Restore the required registers
  1346.     ret                ; Return to the caller
  1347. Joy_X_Res_Dec    Endp            ; End of the Joy_X_Res_Dec procedure
  1348.     Subttl    Joy_Y_Res_Inc    Joystick Y Resolution Increase Routine
  1349.     Page    +
  1350. ;******************************************************************************
  1351. ;
  1352. ;    Joy_Y_Res_Inc(Scan_Code)
  1353. ;
  1354. ;        Save the required registers
  1355. ;        If this is joystick mode
  1356. ;            If this is a make code
  1357. ;                If the shift key is down
  1358. ;                    Do a small Y resolution increment
  1359. ;                Else
  1360. ;                    Do a normal Y resolution increment
  1361. ;                Endif
  1362. ;                Make sure Y resolution is in range
  1363. ;            Endif this is a break code
  1364. ;        Endif for joystick mode
  1365. ;        Restore the required registers
  1366. ;        Return to the caller
  1367. ;
  1368. ;    Registers on Entry:
  1369. ;
  1370. ;        AH    - Original scan code
  1371. ;
  1372. ;    Registers on Exit:
  1373. ;
  1374. ;        None
  1375. ;
  1376. ;******************************************************************************
  1377.         Even            ; Force procedure to even address
  1378. Joy_Y_Res_Inc    Proc    Near        ; Joystick Y resolution inc. procedure
  1379.     Save    bx            ; Save the required registers
  1380.     test    cs:[Key_Status],JOY_MODE; Check for keyboard in joystick mode
  1381.     jz    Y_Res_Inc_Done        ; Jump if NOT in joystick mode
  1382.     or    ah,ah            ; Check for a make or break code
  1383.     js    Y_Res_Inc_Done        ; Jump if this is a break code
  1384.     mov    bx,cs:[Joy_Y_Res]    ; Get the current Y resolution value
  1385.     test    cs:[Key_Status],SHIFTED ; Check for shift key down
  1386.     jz    Do_Y_Res_Inc        ; Jump if shift key is NOT held down
  1387.     add    bx,SMALL_RES        ; Add small change value to resolution
  1388.     jmp    Short Y_Res_Inc_Check    ; Go check the Y resolution value
  1389. Do_Y_Res_Inc:
  1390.     add    bx,NORMAL_RES        ; Add normal change value to resolution
  1391. Y_Res_Inc_Check:
  1392.     jc    Y_Res_Inc_Bad        ; Jump if Y increment is bad
  1393.     cmp    bx,MAX_RES        ; Check against maximum resolution
  1394.     jbe    Y_Res_Inc_Update    ; Go update Y resolution if in range
  1395. Y_Res_Inc_Bad:
  1396.     mov    bx,MAX_RES        ; Set Y resolution to maximum value
  1397. Y_Res_Inc_Update:
  1398.     mov    cs:[Joy_Y_Res],bx    ; Update the Y resolution value
  1399. Y_Res_Inc_Done:
  1400.     Restore bx            ; Restore the required registers
  1401.     ret                ; Return to the caller
  1402. Joy_Y_Res_Inc    Endp            ; End of the Joy_Y_Res_Inc procedure
  1403.     Subttl    Joy_Y_Res_Dec    Joystick Y Resolution Decrease Routine
  1404.     Page    +
  1405. ;******************************************************************************
  1406. ;
  1407. ;    Joy_Y_Res_Dec(Scan_Code)
  1408. ;
  1409. ;        Save the required registers
  1410. ;        If this is joystick mode
  1411. ;            If this is a make code
  1412. ;                If the shift key is down
  1413. ;                    Do a small Y resolution decrement
  1414. ;                Else
  1415. ;                    Do a normal Y resolution decrement
  1416. ;                Endif
  1417. ;                Make sure Y resolution is in range
  1418. ;            Endif this is a break code
  1419. ;        Endif for joystick mode
  1420. ;        Restore the required registers
  1421. ;        Return to the caller
  1422. ;
  1423. ;    Registers on Entry:
  1424. ;
  1425. ;        AH    - Original scan code
  1426. ;
  1427. ;    Registers on Exit:
  1428. ;
  1429. ;        None
  1430. ;
  1431. ;******************************************************************************
  1432.         Even            ; Force procedure to even address
  1433. Joy_Y_Res_Dec    Proc    Near        ; Joystick Y resolution dec. procedure
  1434.     Save    bx            ; Save the required registers
  1435.     test    cs:[Key_Status],JOY_MODE; Check for keyboard in joystick mode
  1436.     jz    Y_Res_Dec_Done        ; Jump if NOT joystick mode
  1437.     or    ah,ah            ; Check for a make or break code
  1438.     js    Y_Res_Dec_Done        ; Jump if this is a break code
  1439.     mov    bx,cs:[Joy_Y_Res]    ; Get the current Y resolution value
  1440.     test    cs:[Key_Status],SHIFTED ; Check for shift key down
  1441.     jz    Do_Y_Res_Dec        ; Jump if shift key is NOT held down
  1442.     sub    bx,SMALL_RES        ; Subtract small change value
  1443.     jmp    Short Y_Res_Dec_Check    ; Go check the Y resolution value
  1444. Do_Y_Res_Dec:
  1445.     sub    bx,NORMAL_RES        ; Subtract normal change value
  1446. Y_Res_Dec_Check:
  1447.     jc    Y_Res_Dec_Bad        ; Jump if Y decrement is bad
  1448.     cmp    bx,MIN_RES        ; Check against minimum resolution
  1449.     jae    Y_Res_Dec_Update    ; Go update Y resolution if in range
  1450. Y_Res_Dec_Bad:
  1451.     mov    bx,MIN_RES        ; Set Y resolution to minimum value
  1452. Y_Res_Dec_Update:
  1453.     mov    cs:[Joy_Y_Res],bx    ; Update the Y resolution value
  1454. Y_Res_Dec_Done:
  1455.     Restore bx            ; Restore the required registers
  1456.     ret                ; Return to the caller
  1457. Joy_Y_Res_Dec    Endp            ; End of the Joy_Y_Res_Dec procedure
  1458.     Subttl    Joy_X_Cen_Inc    Joystick X Center Increase Routine
  1459.     Page    +
  1460. ;******************************************************************************
  1461. ;
  1462. ;    Joy_X_Cen_Inc(Scan_Code)
  1463. ;
  1464. ;        Save the required registers
  1465. ;        If this is joystick mode
  1466. ;            If this is a make code
  1467. ;                If the shift key is down
  1468. ;                    Do a small X center increment
  1469. ;                    Do a small X position increment
  1470. ;                Else
  1471. ;                    Do a normal X center increment
  1472. ;                    Do a normal X position increment
  1473. ;                Endif
  1474. ;                Make sure X center is in range
  1475. ;                make sure X position is in range
  1476. ;            Endif this is a break code
  1477. ;        Endif for joystick mode
  1478. ;        Restore the required registers
  1479. ;        Return to the caller
  1480. ;
  1481. ;    Registers on Entry:
  1482. ;
  1483. ;        AH    - Original scan code
  1484. ;
  1485. ;    Registers on Exit:
  1486. ;
  1487. ;        None
  1488. ;
  1489. ;******************************************************************************
  1490.         Even            ; Force procedure to even address
  1491. Joy_X_Cen_Inc    Proc    Near        ; Joystick X center increment procedure
  1492.     Save    bx,cx            ; Save the required registers
  1493.     test    cs:[Key_Status],JOY_MODE; Check for keyboard in joystick mode
  1494.     jz    X_Cen_Inc_Done        ; Jump if NOT in joystick mode
  1495.     or    ah,ah            ; Check for a make or break code
  1496.     js    X_Cen_Inc_Done        ; Jump if this is a break code
  1497.     test    cs:[Key_Status],SHIFTED ; Check for shift key down
  1498.     jz    Do_X_Cen_Inc        ; Jump if shift key is NOT held down
  1499.     mov    bx,SMALL_CENTER     ; Setup small change value for center
  1500.     mov    cx,SMALL_CENTER     ; Setup small change value for position
  1501.     jmp    Short X_Cen_Inc_Check    ; Go check the X center value
  1502. Do_X_Cen_Inc:
  1503.     mov    bx,NORMAL_CENTER    ; Setup normal change value for center
  1504.     mov    cx,NORMAL_CENTER    ; Setup normal change value for position
  1505. X_Cen_Inc_Check:
  1506.     add    bx,cs:[Joy_X_Center]    ; Compute the new X center value
  1507.     jc    X_Cen_Inc_Bad        ; Jump if X increment is bad
  1508.     cmp    bx,MAX_CENTER        ; Check against maximum center
  1509.     jbe    X_Cen_Inc_Update    ; Go update X center if in range
  1510. X_Cen_Inc_Bad:
  1511.     mov    bx,MAX_CENTER        ; Set X center to maximum value
  1512. X_Cen_Inc_Update:
  1513.     mov    cs:[Joy_X_Center],bx    ; Update the X center value
  1514. X_Pos_Inc_Check:
  1515.     add    cx,cs:[Joy_X_Pos]    ; Compute the new X position value
  1516.     jnc    X_Pos_Inc_Update    ; Jump if X position is ok
  1517.     mov    cx,JOY_MAX        ; Setup X position to maximum
  1518. X_Pos_Inc_Update:
  1519.     mov    cs:[Joy_X_Pos],cx    ; Update the X position value
  1520. X_Cen_Inc_Done:
  1521.     Restore bx,cx            ; Restore the required registers
  1522.     ret                ; Return to the caller
  1523. Joy_X_Cen_Inc    Endp            ; End of the Joy_X_Cen_Inc procedure
  1524.     Subttl    Joy_X_Cen_Dec    Joystick X Center Decrease Routine
  1525.     Page    +
  1526. ;******************************************************************************
  1527. ;
  1528. ;    Joy_X_Cen_Dec(Scan_Code)
  1529. ;
  1530. ;        Save the required registers
  1531. ;        If this is joystick mode
  1532. ;            If this is a make code
  1533. ;                If the shift key is down
  1534. ;                    Do a small X center decrement
  1535. ;                    Do a small X position decrement
  1536. ;                Else
  1537. ;                    Do a normal X center decrement
  1538. ;                    Do a normal X position decrement
  1539. ;                Endif
  1540. ;                Make sure X center is in range
  1541. ;                Make sure X position is in range
  1542. ;            Endif this is a break code
  1543. ;        Endif for joystick mode
  1544. ;        Restore the required registers
  1545. ;        Return to the caller
  1546. ;
  1547. ;    Registers on Entry:
  1548. ;
  1549. ;        AH    - Original scan code
  1550. ;
  1551. ;    Registers on Exit:
  1552. ;
  1553. ;        None
  1554. ;
  1555. ;******************************************************************************
  1556.         Even            ; Force procedure to even address
  1557. Joy_X_Cen_Dec    Proc    Near        ; Joystick X center decrement procedure
  1558.     Save    ax,bx,cx        ; Save the required registers
  1559.     test    cs:[Key_Status],JOY_MODE; Check for keyboard in joystick mode
  1560.     jz    X_Cen_Dec_Done        ; Jump if NOT in joystick mode
  1561.     or    ah,ah            ; Check for a make or break code
  1562.     js    X_Cen_Dec_Done        ; Jump if this is a break code
  1563.     test    cs:[Key_Status],SHIFTED ; Check for Shift key down
  1564.     jz    Do_X_Cen_Dec        ; Jump if shift key is NOT held down
  1565.     mov    bx,SMALL_CENTER     ; Setup small change value for center
  1566.     mov    cx,SMALL_CENTER     ; Setup small change value for position
  1567.     jmp    Short X_Cen_Dec_Check    ; Go check the X center value
  1568. Do_X_Cen_Dec:
  1569.     mov    bx,NORMAL_CENTER    ; Setup normal change value for center
  1570.     mov    cx,NORMAL_CENTER    ; Setup normal change value for position
  1571. X_Cen_Dec_Check:
  1572.     mov    ax,cs:[Joy_X_Center]    ; Get the current X center value
  1573.     sub    ax,bx            ; Compute the new X center value
  1574.     jc    X_Cen_Dec_Bad        ; Jump if X decrement is bad
  1575.     cmp    ax,MIN_CENTER        ; Check against minimum center
  1576.     jae    X_Cen_Dec_Update    ; Go update X center if in range
  1577. X_Cen_Dec_Bad:
  1578.     mov    ax,MIN_CENTER        ; Set X center to minimum value
  1579. X_Cen_Dec_Update:
  1580.     mov    cs:[Joy_X_Center],ax    ; Update the X center value
  1581. X_Pos_Dec_Check:
  1582.     mov    ax,cs:[Joy_X_Pos]    ; Get the current X position value
  1583.     sub    ax,cx            ; Compute the new X position value
  1584.     jnc    X_Pos_Dec_Update    ; Jump if X position is ok
  1585.     mov    ax,JOY_MIN        ; Setup X position to minimum
  1586. X_Pos_Dec_Update:
  1587.     mov    cs:[Joy_X_Pos],ax    ; Update the X position value
  1588. X_Cen_Dec_Done:
  1589.     Restore ax,bx,cx        ; Restore the required registers
  1590.     ret                ; Return to the caller
  1591. Joy_X_Cen_Dec    Endp            ; End of the Joy_X_Cen_Dec procedure
  1592.     Subttl    Joy_Y_Cen_Inc    Joystick Y Center Increase Routine
  1593.     Page    +
  1594. ;******************************************************************************
  1595. ;
  1596. ;    Joy_Y_Cen_Inc(Scan_Code)
  1597. ;
  1598. ;        Save the required registers
  1599. ;        If this is joystick mode
  1600. ;            If this is a make code
  1601. ;                If the shift key is down
  1602. ;                    Do a small Y center increment
  1603. ;                    Do a small Y position increment
  1604. ;                Else
  1605. ;                    Do a normal Y center increment
  1606. ;                    Do a normal Y position increment
  1607. ;                Endif
  1608. ;                Make sure Y center is in range
  1609. ;                Make sure Y position is in range
  1610. ;            Endif this is a break code
  1611. ;        Endif for joystick mode
  1612. ;        Restore the required registers
  1613. ;        Return to the caller
  1614. ;
  1615. ;    Registers on Entry:
  1616. ;
  1617. ;        AH    - Original scan code
  1618. ;
  1619. ;    Registers on Exit:
  1620. ;
  1621. ;        None
  1622. ;
  1623. ;******************************************************************************
  1624.         Even            ; Force procedure to even address
  1625. Joy_Y_Cen_Inc    Proc    Near        ; Joystick Y center increment procedure
  1626.     Save    bx,cx            ; Save the required registers
  1627.     test    cs:[Key_Status],JOY_MODE; Check for keyboard in joystick mode
  1628.     jz    Y_Cen_Inc_Done        ; Jump if NOT in joystick mode
  1629.     or    ah,ah            ; Check for a make or break code
  1630.     js    Y_Cen_Inc_Done        ; Jump if this is a break code
  1631.     test    cs:[Key_Status],SHIFTED ; Check for shift key down
  1632.     jz    Do_Y_Cen_Inc        ; Jump if shift key is NOT held down
  1633.     mov    bx,SMALL_CENTER     ; Setup small change value for center
  1634.     mov    cx,SMALL_CENTER     ; Setup small change value for position
  1635.     jmp    Short Y_Cen_Inc_Check    ; Go check the Y center value
  1636. Do_Y_Cen_Inc:
  1637.     mov    bx,NORMAL_CENTER    ; Setup normal change value for center
  1638.     mov    cx,NORMAL_CENTER    ; Setup normal change value for position
  1639. Y_Cen_Inc_Check:
  1640.     add    bx,cs:[Joy_Y_Center]    ; Compute the new Y center value
  1641.     jc    Y_Cen_Inc_Bad        ; Jump if Y increment is bad
  1642.     cmp    bx,MAX_CENTER        ; Check against maximum center
  1643.     jbe    Y_Cen_Inc_Update    ; Go update Y center if in range
  1644. Y_Cen_Inc_Bad:
  1645.     mov    bx,MAX_CENTER        ; Set Y center to maximum value
  1646. Y_Cen_Inc_Update:
  1647.     mov    cs:[Joy_Y_Center],bx    ; Update the Y center value
  1648. Y_Pos_Inc_Check:
  1649.     add    cx,cs:[Joy_Y_Pos]    ; Compute the new Y position value
  1650.     jnc    Y_Pos_Inc_Update    ; Jump if Y position is ok
  1651.     mov    cx,JOY_MAX        ; Setup Y position to maximum
  1652. Y_Pos_Inc_Update:
  1653.     mov    cs:[Joy_Y_Pos],cx    ; Update the Y position value
  1654. Y_Cen_Inc_Done:
  1655.     Restore bx,cx            ; Restore the required registers
  1656.     ret                ; Return to the caller
  1657. Joy_Y_Cen_Inc    Endp            ; End of the Joy_Y_Cen_Inc procedure
  1658.     Subttl    Joy_Y_Cen_Dec    Joystick Y Center Decrease Routine
  1659.     Page    +
  1660. ;******************************************************************************
  1661. ;
  1662. ;    Joy_Y_Cen_Dec(Scan_Code)
  1663. ;
  1664. ;        Save the required registers
  1665. ;        If this is joystick mode
  1666. ;            If this is a make code
  1667. ;                If the shift key is down
  1668. ;                    Do a small Y center decrement
  1669. ;                    Do a small Y position decrement
  1670. ;                Else
  1671. ;                    Do a normal Y center decrement
  1672. ;                    Do a normal Y position decrement
  1673. ;                Endif
  1674. ;                Make sure Y center is in range
  1675. ;                Make sure Y position is in range
  1676. ;            Endif this is a break code
  1677. ;        Endif for joystick mode
  1678. ;        Restore the required registers
  1679. ;        Return to the caller
  1680. ;
  1681. ;    Registers on Entry:
  1682. ;
  1683. ;        AH    - Original scan code
  1684. ;
  1685. ;    Registers on Exit:
  1686. ;
  1687. ;        None
  1688. ;
  1689. ;******************************************************************************
  1690.         Even            ; Force procedure to even address
  1691. Joy_Y_Cen_Dec    Proc    Near        ; Joystick Y center decrement procedure
  1692.     Save    ax,bx,cx        ; Save the required registers
  1693.     test    cs:[Key_Status],JOY_MODE; Check for keyboard in joystick mode
  1694.     jz    Y_Cen_Dec_Done        ; Jump if NOT joystick mode
  1695.     or    ah,ah            ; Check for a make or break code
  1696.     js    Y_Cen_Dec_Done        ; Jump if this is a break code
  1697.     test    cs:[Key_Status],SHIFTED ; Check for shift key down
  1698.     jz    Do_Y_Cen_Dec        ; Jump if shift key is NOT held down
  1699.     mov    bx,SMALL_CENTER     ; Setup small change value for center
  1700.     mov    cx,SMALL_CENTER     ; Setup small change value for position
  1701.     jmp    Short Y_Cen_Dec_Check    ; Go check the Y center value
  1702. Do_Y_Cen_Dec:
  1703.     mov    bx,NORMAL_CENTER    ; Setup normal change value for center
  1704.     mov    cx,NORMAL_CENTER    ; Setup normal change value for position
  1705. Y_Cen_Dec_Check:
  1706.     mov    ax,cs:[Joy_Y_Center]    ; Get the current Y center value
  1707.     sub    ax,bx            ; Compute the new Y center value
  1708.     jc    Y_Cen_Dec_Bad        ; Jump if Y decrement is bad
  1709.     cmp    ax,MIN_CENTER        ; Check against minimum center
  1710.     jae    Y_Cen_Dec_Update    ; Go update Y center if in range
  1711. Y_Cen_Dec_Bad:
  1712.     mov    ax,MIN_CENTER        ; Set Y center to minimum value
  1713. Y_Cen_Dec_Update:
  1714.     mov    cs:[Joy_Y_Center],ax    ; Update the Y center value
  1715. Y_Pos_Dec_Check:
  1716.     mov    ax,cs:[Joy_Y_Pos]    ; Get the current Y position value
  1717.     sub    ax,cx            ; Compute the new Y position value
  1718.     jnc    Y_Pos_Dec_Update    ; Jump if Y position is ok
  1719.     mov    ax,JOY_MIN        ; Setup Y position to minimum
  1720. Y_Pos_Dec_Update:
  1721.     mov    cs:[Joy_Y_Pos],ax    ; Update the Y position value
  1722. Y_Cen_Dec_Done:
  1723.     Restore ax,bx,cx        ; Restore the required registers
  1724.     ret                ; Return to the caller
  1725. Joy_Y_Cen_Dec    Endp            ; End of the Joy_Y_Cen_Dec procedure
  1726.     Subttl    Joy_Button_1    Joystick Button 1 Routine
  1727.     Page    +
  1728. ;******************************************************************************
  1729. ;
  1730. ;    Joy_Button_1(Scan_Code)
  1731. ;
  1732. ;        If this is a make code
  1733. ;            Set the button 1 pressed flag
  1734. ;        Else this is a break code
  1735. ;            Reset the button 1 pressed flag
  1736. ;        Endif
  1737. ;        Return to the caller
  1738. ;
  1739. ;    Registers on Entry:
  1740. ;
  1741. ;        AH    - Original scan code
  1742. ;
  1743. ;    Registers on Exit:
  1744. ;
  1745. ;        None
  1746. ;
  1747. ;******************************************************************************
  1748.         Even            ; Force procedure to even address
  1749. Joy_Button_1    Proc    Near        ; Joystick button 1 procedure
  1750.     or    ah,ah            ; Check for a make or break code
  1751.     js    Button_1_Break        ; Jump if this is a break code
  1752. Button_1_Make:
  1753.     or    Byte Ptr cs:[Joy_Flag],BUTTON_1_DOWN
  1754.     jmp    Short Button_1_Done    ; Go return to the caller
  1755. Button_1_Break:
  1756.     and    Byte Ptr cs:[Joy_Flag],Not BUTTON_1_DOWN
  1757. Button_1_Done:
  1758.     ret                ; Return to the caller
  1759. Joy_Button_1    Endp            ; End of the Joy_Button_1 procedure
  1760.     Subttl    Joy_Button_2    Joystick Button 2 Routine
  1761.     Page    +
  1762. ;******************************************************************************
  1763. ;
  1764. ;    Joy_Button_2(Scan_Code)
  1765. ;
  1766. ;        If this is a make code
  1767. ;            Set the button 2 pressed flag
  1768. ;        Else this is a break code
  1769. ;            Reset the button 2 pressed flag
  1770. ;        Endif
  1771. ;        Return to the caller
  1772. ;
  1773. ;    Registers on Entry:
  1774. ;
  1775. ;        AH    - Original scan code
  1776. ;
  1777. ;    Registers on Exit:
  1778. ;
  1779. ;        None
  1780. ;
  1781. ;******************************************************************************
  1782.         Even            ; Force procedure to even address
  1783. Joy_Button_2    Proc    Near        ; Joystick button 2 procedure
  1784.     or    ah,ah            ; Check for a make or break code
  1785.     js    Button_2_Break        ; Jump if this is a break code
  1786. Button_2_Make:
  1787.     or    Byte Ptr cs:[Joy_Flag],BUTTON_2_DOWN
  1788.     jmp    Short Button_2_Done    ; Go return to the caller
  1789. Button_2_Break:
  1790.     and    Byte Ptr cs:[Joy_Flag],Not BUTTON_2_DOWN
  1791. Button_2_Done:
  1792.     ret                ; Return to the caller
  1793. Joy_Button_2    Endp            ; End of the Joy_Button_2 procedure
  1794.     Subttl    Joystick_Update Joystick Update Routine
  1795.     Page    +
  1796. ;******************************************************************************
  1797. ;
  1798. ;    Joystick_Update()
  1799. ;
  1800. ;        Save the required registers
  1801. ;        If in joystick mode
  1802. ;            If NOT a binary type joystick
  1803. ;                Zero the X position delta value
  1804. ;                Zero the Y position delta value
  1805. ;                If the joystick up is set
  1806. ;                    Subtract Y resolution from Y delta value
  1807. ;                Endif
  1808. ;                If the joystick down is set
  1809. ;                    Add Y resolution to Y delta value
  1810. ;                Endif
  1811. ;                If the joystick left is set
  1812. ;                    Subtract X resolution from X delta value
  1813. ;                Endif
  1814. ;                If the joystick right is set
  1815. ;                    Add X resolution to X delta value
  1816. ;                Endif
  1817. ;                Add X delta value to current X position
  1818. ;                Make sure X position is in range
  1819. ;                Add Y delta value to current Y position
  1820. ;                Make sure Y position is in range
  1821. ;            Endif for binary type
  1822. ;        Endif for joystick mode
  1823. ;        Return to the caller
  1824. ;
  1825. ;    Registers on Entry:
  1826. ;
  1827. ;        None
  1828. ;
  1829. ;    Registers on Exit:
  1830. ;
  1831. ;        None
  1832. ;
  1833. ;******************************************************************************
  1834.         Even            ; Force procedure to even address
  1835. Joystick_Update Proc    Near        ; Joystick update procedure
  1836.     Save    ax,bx,cx        ; Save the required registers
  1837.     mov    al,cs:[Joy_Status]    ; Get the joystick status byte
  1838.     xor    bx,bx            ; Zero the X position delta value
  1839.     xor    cx,cx            ; Zero the Y position delta value
  1840.     test    cs:[Key_Status],JOY_MODE; Check for keyboard in joystick mode
  1841.     jz    Update_Done        ; Jump if NOT in joystick mode
  1842.     test    cs:[Joy_Flag],BINARY_TYPE
  1843.     jnz    Update_Done        ; Jump if in binary mode
  1844. Up_Test:
  1845.     test    al,UP + UP_LEFT + UP_RIGHT
  1846.     jz    Down_Test        ; Jump if NOT moving in up direction
  1847.     sub    cx,cs:[Joy_Y_Res]    ; Subtract from Y position delta value
  1848. Down_Test:
  1849.     test    al,DOWN + DOWN_LEFT + DOWN_RIGHT
  1850.     jz    Left_Test        ; Jump if NOT moving in down direction
  1851.     add    cx,cs:[Joy_Y_Res]    ; Add to the Y position delta value
  1852. Left_Test:
  1853.     test    al,LEFT + UP_LEFT + DOWN_LEFT
  1854.     jz    Right_Test        ; Jump if NOT moving in left direction
  1855.     sub    bx,cs:[Joy_X_Res]    ; Subtract from X position delta value
  1856. Right_Test:
  1857.     test    al,RIGHT + UP_RIGHT + DOWN_RIGHT
  1858.     jz    Update_X        ; Jump if NOT moving in right direction
  1859.     add    bx,cs:[Joy_X_Res]    ; Add to the X position delta value
  1860. Update_X:
  1861.     or    bx,bx            ; Check for a positive/negative value
  1862.     js    Subtract_X        ; Jump if X delta value is negative
  1863. Add_X:
  1864.     add    bx,cs:[Joy_X_Pos]    ; Compute the new X position value
  1865.     jnc    Update_Y        ; Jump if X update is ok
  1866. X_Update_Bad:
  1867.     mov    bx,JOY_MAX        ; Set X position to joystick maximum
  1868.     jmp    Short Update_Y        ; Go update the Y position value
  1869. Subtract_X:
  1870.     add    bx,cs:[Joy_X_Pos]    ; Compute the new X position value
  1871.     jc    Update_Y        ; Jump if X update is ok
  1872. Bad_X_Update:
  1873.     mov    bx,JOY_MIN        ; Set X position to joystick minimum
  1874. Update_Y:
  1875.     or    cx,cx            ; Check for a positive/negative value
  1876.     js    Subtract_Y        ; Jump if Y delta value is negative
  1877. Add_Y:
  1878.     add    cx,cs:[Joy_Y_Pos]    ; Compute the new Y position value
  1879.     jnc    Update_Position     ; Jump if Y update is ok
  1880. Y_Update_Bad:
  1881.     mov    cx,JOY_MAX        ; Set Y position to joystick maximum
  1882.     jmp    Short Update_Position    ; Go update the joystick position
  1883. Subtract_Y:
  1884.     add    cx,cs:[Joy_Y_Pos]    ; Compute the new Y position value
  1885.     jc    Update_Position     ; Jump if Y update is ok
  1886. Bad_Y_Update:
  1887.     mov    cx,JOY_MIN        ; Set Y position to joystick minimum
  1888. Update_Position:
  1889.     mov    cs:[Joy_X_Pos],bx    ; Update the joystick X position
  1890.     mov    cs:[Joy_Y_Pos],cx    ; Update the joystick Y position
  1891. Update_Done:
  1892.     Restore ax,bx,cx        ; Restore the required registers
  1893.     ret                ; Return to the caller
  1894. Joystick_Update Endp            ; End of the Joystick_Update procedure
  1895. ;******************************************************************************
  1896. ;
  1897. ;    Define the joystick status
  1898. ;
  1899. ;    -----------------
  1900. ;    |7|6|5|4|3|2|1|0|
  1901. ;    -----------------
  1902. ;     | | | | | | | |
  1903. ;     | | | | | | | -------> Joystick up held down
  1904. ;     | | | | | | ---------> Joystick down held down
  1905. ;     | | | | | -----------> Joystick left held down
  1906. ;     | | | | -------------> Joystick right held down
  1907. ;     | | | ---------------> Joystick up/left held down
  1908. ;     | | -----------------> Joystick up/right held down
  1909. ;     | -------------------> Joystick down/left held down
  1910. ;     ---------------------> Joystick down/right held down
  1911. ;
  1912. ;******************************************************************************
  1913. Joy_Status    Db    0        ; Joystick status byte
  1914. UP        Equ    01h        ; Joystick up position flag
  1915. DOWN        Equ    02h        ; Joystick down position flag
  1916. LEFT        Equ    04h        ; Joystick left position flag
  1917. RIGHT        Equ    08h        ; Joystick right position flag
  1918. UP_LEFT     Equ    10h        ; Joystick up/left position flag
  1919. UP_RIGHT    Equ    20h        ; Joystick up/right position flag
  1920. DOWN_LEFT    Equ    40h        ; Joystick down/left position flag
  1921. DOWN_RIGHT    Equ    80h        ; Joystick down/right position flag
  1922. ;******************************************************************************
  1923. ;
  1924. ;    Define the joystick flags
  1925. ;
  1926. ;    -----------------
  1927. ;    |7|6|5|4|3|2|1|0|
  1928. ;    -----------------
  1929. ;     | | | | | | | |
  1930. ;     | | | | | | | -------> Button 1 held down
  1931. ;     | | | | | | ---------> Button 2 held down
  1932. ;     | | | | | -----------> Joystick type (0 = Analog, 1 = Binary)
  1933. ;     | | | | -------------> Joystick center mode (0 = Normal, 1 = Self)
  1934. ;     | | | ---------------> Joystick flight mode (0 = Normal, 1 = Flight)
  1935. ;     | | -----------------> Joystick response mode (0 = Slow, 1 = Fast)
  1936. ;     | -------------------> ***** Reserved *****
  1937. ;     ---------------------> ***** Reserved *****
  1938. ;
  1939. ;******************************************************************************
  1940. Joy_Flag    Db    BINARY_TYPE    ; Joystick flag byte
  1941. BUTTON_1_DOWN    Equ    01h        ; Joystick button 1 held down flag
  1942. BUTTON_2_DOWN    Equ    02h        ; Joystick button 2 held down flag
  1943. BINARY_TYPE    Equ    04h        ; Joystick binary type flag
  1944. SELF_CENTER    Equ    08h        ; Joystick self center flag
  1945. FLIGHT_MODE    Equ    10h        ; Joystick flight mode flag
  1946. FAST_MODE    Equ    20h        ; Joystick fast mode flag
  1947. ;******************************************************************************
  1948. ;
  1949. ;    Define any other joystick variables
  1950. ;
  1951. ;******************************************************************************
  1952. Joy_X_Pos    Dw    CENTER_VALUE    ; Joystick X axis position value
  1953. Joy_Y_Pos    Dw    CENTER_VALUE    ; Joystick Y axis position value
  1954. Joy_X_Center    Dw    CENTER_VALUE    ; Joystick X axis center value
  1955. Joy_Y_Center    Dw    CENTER_VALUE    ; Joystick Y axis center value
  1956. Joy_X_Res    Dw    START_RES    ; Joystick X resolution value
  1957. Joy_Y_Res    Dw    START_RES    ; Joystick Y resolution value
  1958. Joy_X_Count    Db    ?        ; Joystick X counter value
  1959. Joy_Y_Count    Db    ?        ; Joystick Y counter value
  1960. ;******************************************************************************
  1961. ;
  1962. ;    Define the end of the Emulator Code Segment
  1963. ;
  1964. ;******************************************************************************
  1965. Emulate Ends
  1966.     End                ; End of the Joystick module
  1967.