From Intellivision Wiki
m (Protected "Hand Controller" ([edit=autoconfirmed] (indefinite) [move=autoconfirmed] (indefinite)))
Latest revision as of 08:34, 4 December 2010
In the image above, the hexadecimal numbers indicate which bits get set to zero when the user presses the corresponding input. Reading the hand controller returns all 1's in the lower 8 bits when no key is pressed. The numbers are shown in this form because many programs typically read the controller inputs and then invert the values, in order to quickly determine if any key is pressed. Because of this inversion, most programs use values similar to the ones shown above to interpret the controller's input.
For instance, pressing the '1' key clears bits 0 and 7. This gives the value $7E when reading the controller port. ($7E, when inverted, yields $81.) Pressing more than one input causes all of the corresponding bits to clear. For instance, pressing 1 and 9 together clears bits 0, 2, 5 and 7, giving $5A.
Careful inspection shows that programs can easily decode single keypad presses from the 12-key keypad, or any side-action button combined with a disc input. It is not possible to uniquely decode a keypad input combined with either a side-action button or disc input, nor is it possible to uniquely decode two side-action buttons pressed simultaneously.
Here's a minimalist code snippet showing how to read the Master Component controllers:
MVI $01FE, R0 ; read right controller AND $01FF, R0 ; read left controller XORI #$FF, R0 ; invert bits BEQ no_input ; if result is null --> no input ... ; something to process
NB: Since significant input bits are set to zero rather than one, a AND is used to mix values from both controllers.