Annotation of src/jstick.asm, revision 1.1

1.1     ! root        1: ; JSTICK.ASM
        !             2: ;
        !             3: ; by Les Bird for Witchaven
        !             4: ;
        !             5: ; Copyright (c) 1995 IntraCorp, Inc.
        !             6: ;
        !             7: ; ***********************************************************************
        !             8: ; *     void jstick()   - this 'C' callable routine reads the position  *
        !             9: ; *                       of joystick #1 attached to a game-port (0x201)*
        !            10: ; *                       and returns the X position in variable _joyx  *
        !            11: ; *                       and the Y position in variable _joyy and the  *
        !            12: ; *                       button status in variable _joyb               *
        !            13: ; *                                                                     *
        !            14: ; *     _joyb   - xxxx.0000                                             *
        !            15: ; *                 ||                                                  *
        !            16: ; *                 |`-- 0 if joystick #1, button #1 pressed            *
        !            17: ; *                 `--- 0 if joystick #1, button #2 pressed            *
        !            18: ; *                                                                     *
        !            19: ; *     'C' example:                                                    *
        !            20: ; *                                                                     *
        !            21: ; *     extern                                                          *
        !            22: ; *     int joyb,joyx,joyy;                                             *
        !            23: ; *                                                                     *
        !            24: ; *     void                                                            *
        !            25: ; *     main(void)                                                      *
        !            26: ; *     {                                                               *
        !            27: ; *          jstick();                                                  *
        !            28: ; *          printf("Joystick X position = %d",joyx);                   *
        !            29: ; *          printf("Joystick Y position = %d",joyy);                   *
        !            30: ; *          printf("Joystick button stat= %d",joyb);                   *
        !            31: ; *     }                                                               *
        !            32: ; *                                                                     *
        !            33: ; ***********************************************************************
        !            34: ;
        !            35: .386p
        !            36: ;
        !            37: JOYPORT equ     201H            ; game-port I/O address
        !            38: ;
        !            39: _DATA   SEGMENT DWORD PUBLIC 'DATA'
        !            40: ;
        !            41: EXTRN   _joyb:BYTE      ;   db      0               ; joystick button status
        !            42: EXTRN   _joyx:WORD      ;   dw      0               ; joystick X position
        !            43: EXTRN   _joyy:WORD      ;   dw      0               ; joystick Y position
        !            44: joydn   db      ?               ; internal compare value
        !            45: joycr   dw      ?               ; internal counter
        !            46: ;
        !            47: _DATA   ENDS
        !            48: ;
        !            49: _TEXT   SEGMENT BYTE PUBLIC 'CODE'
        !            50:         ASSUME  cs:_TEXT, ds:_DATA
        !            51: ;
        !            52: PUBLIC  jstick_
        !            53: jstick_ PROC    near
        !            54: ;
        !            55:         pushf
        !            56:         push    ebp
        !            57:         cli
        !            58:         mov     bx,0
        !            59:         mov     cx,800h
        !            60:         mov     joycr,cx
        !            61:         xor     cx,cx
        !            62:         mov     dx,JOYPORT
        !            63:         in      al,dx
        !            64:         mov     _joyb,al
        !            65:         and     al,0fh
        !            66:         mov     joydn,al
        !            67:         out     dx,al
        !            68: jloop:  in      al,dx
        !            69:         push    ax
        !            70:         and     al,0fh
        !            71:         cmp     al,joydn
        !            72:         pop     ax
        !            73:         jz      jretrn
        !            74:         dec     joycr
        !            75:         jz      jretrn
        !            76:         push    ax
        !            77:         and     al,1
        !            78:         pop     ax
        !            79:         jz      jupdy
        !            80:         inc     bx
        !            81: jupdy:  and     al,2
        !            82:         jz      jloop
        !            83:         inc     cx
        !            84:         jmp     jloop
        !            85: jretrn: mov     _joyx,bx
        !            86:         mov     _joyy,cx
        !            87:         pop     ebp
        !            88:         popf
        !            89:         ret
        !            90: ;
        !            91: jstick_ ENDP
        !            92: ;
        !            93: _TEXT   ENDS
        !            94: ;
        !            95:         END

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.