NESDev and Strangulation Records messageboards
Forum Index | FAQ | New User | Login | Search

Previous ThreadView All ThreadsNext ThreadShow in Flat Mode*


SubjectRe: Shift Ops and Input (?)  
Posted byzero soul
Posted on1/21/03 01:09 AM



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

-
Entire Thread
Subject  Posted byPosted On
*Shift Ops and Input (?)   deschenes201/18/03 05:21 AM
.*Re: Shift Ops and Input (?)   mcmartin1/18/03 05:36 AM
..*Re: Shift Ops and Input (?)   deschenes201/18/03 05:47 AM
...*Re: Shift Ops and Input (?)   mcmartin1/19/03 06:18 AM
.....Re: Shift Ops and Input (?)   zero soul1/21/03 01:09 AM
.....*Re: Shift Ops and Input (?)   quietust1/21/03 04:47 AM
......*Re: Shift Ops and Input (?)   zero soul1/21/03 8:36 PM
.......*(and an addendum)  zero soul1/21/03 8:39 PM
........*Re: (and an addendum)  gesis_l1/21/03 10:36 PM
.........*Re: (and an addendum)  zero soul1/22/03 00:14 AM
.......*(correction)  zero soul1/21/03 8:37 PM
Jump to

Memblers' homepage             Contact Me

Forums powered by WWWThreads Demo