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.

Comments

  • You need to take the button they check for on that part of the engine and change it. Start by working back from controller readying with $4016 and $4017, and see where they store the variables. Then find the one they use in the engine, and just fiddle with them and see which action each check handles. Then, change the button they check for from the L/R buttons to A/B. Anything more than that needed with help, might as well be asking us to do it for you honestly. Not that there is anything wrong, just don't expect results/
  • Please ask all programming questions in this thread:



    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.
  • There is a much easier routine that makes this super easy.



    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
Sign In or Register to comment.