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             
    tax                       
    lda     Joystick          
    eor     #SWITCHESMASK     
    ora     SWCHB             
    stx     Joystick          
    lsr                       
    bcc     .resetGame        
    lsr                       
    bcc     .selectGame       


; check fire button:
    clc                            
    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
.noButton:
    sta     Joystick            ;           save current state
    bcc     .skipButton         ;           skip if (not pressed) or (pressed before)

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


_______________________________________________________________________
1.000.000 DM gewinnen - kostenlos tippen - http://millionenklick.web.de
IhrName@xxxxxx, 8MB Speicher, Verschluesselung - http://freemail.web.de



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

Current Thread