Button queries

(See also Vectrex Internals → Joyport Devices)

BIOS

One small note in advance, in order for the joypad routines to work correctly, you must again assure that the Vec_Misc_Count ($C823) BIOS RAM location is zero, since it is used for analogous testing. As said before, if you don't change that variable somewhere, than everything is ok, since BIOS functions always return leaving that location zero.

Source see: Example Joystick Query BIOS.

The above function calls the Read_Btns ($F1BA) function.

This function does a couple of things. But the only thing we use in the above example is the information given to us in register A.

In that register a button transition information is given. That means a bit is set at a button specific position, if it's state has changed. But only half the transition is registered, the transition from unpressed to pressed. If such a transition occurred than for the next call of Read_Btns the appropriate bit will be set. Most of the time that little information is enough. Especially if you don't want continues fire or the like.

The Read Btns function has some other uses, in the second version of the button query you will find a program that makes use of the RAM locations mentioned above, these are set to the current button state by the Read_Btns function. The function does following other things:

  1. Vec_Buttons ($C811)
    Current toggle state of all buttons.
    Contains the same information as register A.

  2. Vec_Btn_State ($C80F)
    Current state of all joystick buttons.
    Contains a bitmap whether a button is pressed (1) or not (0).

  3. Vec_Prev_Btns ($C810)
    Previous state of all joystick buttons.
    Contains a bitmap whether a button was pressed (1) or not (0) before the function call.

and:

The bitmap used in all above BIOS RAM locations is as in the above program:

Source see: Example Joystick Query BIOS 2.