Difference between revisions of "Talk:Controller reading code"
(→Removed last-frame compromise: new section)
m (Rainwarrior moved page Talk:Controller Reading to Talk:Controller reading code: Separating code examples to make a page just about the controller read interface that is common to all input)
Latest revision as of 16:13, 20 April 2019
Reorganization needed with Standard controller
Removed last-frame compromise
This code appeared in the DPCM Safety using Repeated Reads section. I have removed it, because I think it hurts comprehension for new readers who may not understand what they are trading away to save a few cycles they may not need. There's probably a place for this code somewhere, but I don't think it belongs in the middle of the article, and certainly not in lieu of a simpler and more standard example.
last_frame_buttons1 = $00 last_frame_buttons2 = $01 first_read_buttons1 = $02 first_read_buttons2 = $03 readjoy_safe: lda buttons2 sta last_frame_buttons2 lda buttons1 sta last_frame_buttons1 ; Read the controllers once and stash the result jsr readjoy lda buttons2 sta first_read_buttons2 lda buttons1 sta first_read_buttons1 ; Read the controllers again and compare jsr readjoy ldx #1 cleanup_loop: ; Ignore read values if a bit deletion occurred lda buttons1,x cmp first_read_buttons1,x beq not_glitched lda last_frame_buttons,x sta buttons1,x not_glitched: dex bpl cleanup_loop rts