Wnk.asm

From Intellivision Wiki

(Difference between revisions)
Jump to: navigation, search
(Functions Provided)
(Notes)
Line 15: Line 15:
= Notes =
= Notes =
 +
The code reads both controllers by [[XOR]]ing the inputs of the two together.  Thus, it is possible to fool this code into thinking nothing is pressed if the exact same thing is pressed on both controllers.  This isn't seen as a big deal.
 +
 +
Despite "key" appearing in their name, WAITKEY and WAITNOKEY really look for <I>any</I> input.  Disc, action buttons and keypad all have the same effect to this code.
= Source Code =
= Source Code =

Revision as of 03:44, 12 September 2008


Contents

Functions Provided

Entry pointFunction providedNotes
WAITKEYWaits for a tap on either controllerSpecifically, waits for there to be no input on either controller, followed by an input from either controller, and then no input again. Debounces the input to avoid glitches.
WAITNOKEYWaits for there to be no input on either controller.Debounced to avoid glitches.



See source code below for calling convention.

Examples

(todo... please contribute!)

Notes

The code reads both controllers by XORing the inputs of the two together. Thus, it is possible to fool this code into thinking nothing is pressed if the exact same thing is pressed on both controllers. This isn't seen as a big deal.

Despite "key" appearing in their name, WAITKEY and WAITNOKEY really look for any input. Disc, action buttons and keypad all have the same effect to this code.

Source Code

;* ======================================================================== *;
;*  These routines are placed into the public domain by their author.  All  *;
;*  copyright rights are hereby relinquished on the routines and data in    *;
;*  this file.  -- Joseph Zbiciak, 2008                                     *;
;* ======================================================================== *;

;; ======================================================================== ;;
;;  WAITKEY     Wait for release/press/release                              ;;
;;  WAITNOKEY   Wait for key release                                        ;;
;; ======================================================================== ;;
WAITKEY     PROC
            PSHR    R5
@@1:        CALL    WAITNOKEY   ; Wait for release-press-release
@@wk        MVI     $1FE,   R0
            XOR     $1FF,   R0
            BEQ     @@wk
            INCR    PC          ; skip PSHR R5 
WAITNOKEY   PSHR    R5

@@waitnokey MVII    #200,   R1  ; Debounce counter

@@stillnk   MVI     $1FE,   R0
            XOR     $1FF,   R0
            BNEQ    @@waitnokey

            DECR    R1          ; Avoid glitches:  Make sure it's good and gone
            BPL     @@stillnk

            PULR    PC
            ENDP
        
;; ======================================================================== ;;
;;  End of File:  wnk.asm                                                   ;;
;; ======================================================================== ;;
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox