NES Assembly: Making a sprite move left and right with the D-Pad
This is probably a Obscure Question and pretty sure it's been answered in Nerdy Nights but,
I wan't to change the controls from A and B to the Left and Right D-Pad. But i have completly no clue how and Nerdy Nights currently didn't help. I was wondering how to do it but (obviously) it's difficult to make it possible.
I wan't to change the controls from A and B to the Left and Right D-Pad. But i have completly no clue how and Nerdy Nights currently didn't help. I was wondering how to do it but (obviously) it's difficult to make it possible.
Comments
http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=103138
While your question is important, we don't want to clutter the forum with individual questions about this sort of thing.
ReadController:
LDA #$01
STA $4016
LDA #$00
STA $4016
LDX #$08
ReadControllerLoop:
LDA $4016
LSR A ; bit0 -> Carry
ROL buttons ; bit0 <- Carry
DEX
BNE ReadControllerLoop
RTS
Call this subroutine once per frame in your loop. What it does is that it makes the "buttons" variable have each byte controlling a button (00001000 - respectively A, B, Start, Select, Up, Down, Left and Right - the 1 is on Up)
Then, in your loop, use this routine to make a button (in this case, the left button) do the work.
CheckLeft:
LDA buttons
AND %00000010
BEQ LeftDone
;Put your code that's triggered by pressing the button here
LeftDone:
However, you should post this in the programming questions thread next time