[stella] debounce

Subject: [stella] debounce
From: "TwoHeaded Software" <adavie@xxxxxxxxxxxxx>
Date: Tue, 11 Sep 2001 20:18:44 +1000
> This does exactly what I want it to, except one thing: the fire button
still
> acts wonky on the Atari. What's the normal way to debounce the fire
button? I

I was pretty pleased with my debounce code for the console switches in Qb.
With minor modification this can work for joystick buttons, too...

GetState

        sta temp

        and SWCHB
        cmp #1
        ror
        eor #D7
        and temp+1                ; D1 SWCHB -> D7
        asl

        rol temp+1                ; sneaky!  keep C on D0

        lda SWCHB
        eor #3
        and #3
        beq SW2                         ; both NOT pressed -> enable both

        and temp
        beq SW3                         ; THIS one NOT pressed?

        clc
        bcc SW3

SW2     sec
SW3     ror temp+1                ; if button pressed, -> 0        (and
D0->C)
        rts


Buggered if I can figure out how it works, now ;)
The above code will debounce any console switch, passed in A.

Usage is...

    lda #D1                         ; SELECT
    jsr GetState
    bcc CheckReset



Cheers
A

-
Andrew Davie, TwoHeaded Software
adavie@xxxxxxxxxxxxx



-
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/

Current Thread