Forgive me for asking about something so simple, but I am paranoid about program efficiency. This is the best way I could come up with to read all the joypad data into one byte...is it decent? Anything you would do differently?
It's really short and simple, but I want to make sure I'm doing this stuff right and not, for example, doing an adc when a cmp would suffice. I want to start off with good programming practices so I don't end up with a huge mess later.
Just before I posted it I already noticed one thing to fix, I was able to eliminate one extra load/store to pad1.
Code:
lda #$01 ;strobe joypad
sta $4016
lda #$00
sta $4016
clc
lda #0 ;clear pad 1 data
stx #8 ;loop 8 times, once for every button
- sta pad1
lda $4016 ;get next button state
adc pad1 ;add the 0 or 1 into pad data
ror ;rotate pad data right
dex
bne -
sta pad1
sta $4016
lda #$00
sta $4016
clc
lda #0 ;clear pad 1 data
stx #8 ;loop 8 times, once for every button
- sta pad1
lda $4016 ;get next button state
adc pad1 ;add the 0 or 1 into pad data
ror ;rotate pad data right
dex
bne -
sta pad1
It's really short and simple, but I want to make sure I'm doing this stuff right and not, for example, doing an adc when a cmp would suffice. I want to start off with good programming practices so I don't end up with a huge mess later.
Just before I posted it I already noticed one thing to fix, I was able to eliminate one extra load/store to pad1.