|
for input, I just have it read them all at once and stick the results in an array. in NESASM:
JOY_A = $00 JOY_B = $01 JOY_SEL = $02 JOY_STA = $03 JOY_UP = $04 JOY_DOWN = $05 JOY_LEFT = $06 JOY_RIGHT = $07 DELTA_A = $08 DELTA_B = $09 DELTA_SEL = $0A DELTA_STA = $0B DELTA_UP = $0C DELTA_DOWN = $0D DELTA_LEFT = $0E DELTA_RIGHT = $0F ; or wherever you prefer to put them. ; JOY_* = whether the button is pressed or not ($01 = pressed) ; DELTA_* = whether the button's status has changed since the last read ($01 = changed)
read_joy: ldx #$01 stx $4016 dex stx $4016 readjoy_2: lda JOY_A,x sta DELTA_A,x lda $4017 sta JOY_A,x eor DELTA_A,x sta DELTA_A,x inx cpx #$08 bne readjoy_2 rts
---- This takes advantage of the fact that the status variables are arranged in the same order as $4017 returns them. The 'delta' part can be used to respond to a button press only once, for example, if you had a game menu, pressing a button would result in instantaneous, repeated selections while the button was pressed (by simply checking to see if it's pressed or not). With 'delta', you would only respond to a button if it is pressed AND its status has changed. lda JOY_A and DELTA_A bne respond_to_input do_not_respond: ...
Anyhow, just thought I'd throw that out there.
...just another vision... Studios
|