flame Posted May 10, 2020 Share Posted May 10, 2020 Hey everyone, Is there a way to check if the direction input was the same as the last ? I have a value that needs to reset if it is not. MoveRT: lda direction cmp #$20 beq .Reset jmp .Done MoveLT: lda direction cmp #0 beq .Reset jmp .Done .Reset lda #0 sta value .Done: rts I have a direction facing that switches thanks to advice from @SpiceWare This is what I am trying to do, but I am missing something. Quote Link to comment Share on other sites More sharing options...
flame Posted May 11, 2020 Author Share Posted May 11, 2020 MoveRT subroutine lda direction cmp #0 beq .repeat lda #0 sta steps .repeat inc steps lda #0 sta direction rts MoveLT subroutine lda direction cmp #$20 beq .repeat lda #0 sta steps .repeat inc steps lda #$20 sta direction rts I friend chimed in with some advice, this seems to be working ! Quote Link to comment Share on other sites More sharing options...
+Pat Brady Posted May 11, 2020 Share Posted May 11, 2020 MoveRT subroutine lda #0 beq .move ; always branch MoveLT lda #$20 .move cmp direction sta direction beq .repeat lda #1 sta steps rts .repeat inc steps rts I haven’t tested it but believe this will do the same thing, in fewer bytes and worst-case cycles. (You could also change the #1 to #0 and remove the first rts, trading a few cycles for a byte.) 1 Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted May 11, 2020 Share Posted May 11, 2020 I don't recall what direction is holding, but if you save the value of SCHWA from one frame you can easily compare it using EOR. lda SWCHA eor SAVED_SWCHA beq no_change ; handle change here, any bit in the accumulator that's a 1 is a joystick direction that's not the same as the prior frame no_change: lda SWCHA sta SAVED_SWCHA 2 Quote Link to comment Share on other sites More sharing options...
flame Posted May 11, 2020 Author Share Posted May 11, 2020 (edited) whoa okei it never occurred to me to poll SCHWA—I'll see what happens ! EDIT That's amazing—thank you ! Edited May 11, 2020 by pvmpkin Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.