Re: [stella] debounce

Subject: Re: [stella] debounce
From: "Thomas Jentzsch" <tjentzsch@xxxxxx>
Date: Tue, 11 Sep 2001 13:08:04 +0200
> > 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'd like to share my Thrust debounce code too. The debounced states of the switches and the fire button are stored in the "Joystick" variable (the upper 4 bits are used for the joystick direction):

SWITCHESMASK    = %00000011  
BUTTONMASK      = %00001000    

; check switches:
    lda     SWCHB             
    and     #~SWITCHESMASK    
    eor     Joystick          
    and     #~SWITCHESMASK    
    eor     SWCHB             
    lda     Joystick          
    eor     #SWITCHESMASK     
    ora     SWCHB             
    stx     Joystick          
    bcc     .resetGame        
    bcc     .selectGame       

; check fire button:
    lda     Joystick               
    and     #~BUTTONMASK        ;           unmask button-bit
    bit     INPT4               ;           button pressed ?
    bmi     .noButton           ;            no, skip button
    cmp     Joystick            ;           button pressed before?
    ora     #BUTTONMASK         ;           mark as pressed
    sta     Joystick            ;           save current state
    bcc     .skipButton         ;           skip if (not pressed) or (pressed before)

Have fun!
Thomas Jentzsch         | *** Every bit is sacred ! ***
tjentzsch at web dot de |

1.000.000 DM gewinnen - kostenlos tippen -
IhrName@xxxxxx, 8MB Speicher, Verschluesselung -

Archives (includes files) at
Unsub & more at

Current Thread