.zero outside .byt 0 oldbuttons .byt 0 Buttons .byt 0 indir .word 0 count .byt 0 .bss *=$700 values .dsb 16 .text *=$F800 #include "constants.inc" nmi: lda PPU_STATUS ; clear bit, we'll finish too fast ldx #JOY_1_LATCH ; 2 \\ begin stx JOY_1 ; 4 ; strobe controller lda JOY_1 ; 4 ; read other bits; won't clock register dex ; 2 stx JOY_1 ; 4 and #$FC ; 2 tax ; 2 ; now X = other bits cpx JOY_1 ; 4 ror ; 2 cpx JOY_1 ; 4 ror ; 2 cpx JOY_1 ; 4 ror ; 2 cpx JOY_1 ; 4 ror ; 2 cpx JOY_1 ; 4 ror ; 2 cpx JOY_1 ; 4 ror ; 2 cpx JOY_1 ; 4 ror ; 2 cpx JOY_1 ; 4 ror ; 2 // end : 68 cycles sta Buttons ; 3 lda Buttons cmp oldbuttons bne ContinueProcessing jmp donemode ContinueProcessing sta oldbuttons lda #JOY_UP bit Buttons bnz NotUp lda #1 bit count bnz LowNybbleUp HighNybbleUp lda count lsr tax clc lda #16 adc values,x sta values,x jmp NotUp LowNybbleUp lda count lsr tax clc lda #1 adc values,x sta values,x NotUp lda #JOY_DN bit Buttons bnz NotDown lda #1 bit count bnz LowNybbleDown HighNybbleDown lda count lsr tax clc lda #240 adc values,x sta values,x jmp NotDown LowNybbleDown lda count lsr tax clc lda #255 adc values,x sta values,x NotDown lda #JOY_LT bit Buttons bnz NotLt dec count bpl NotLt lda #31 sta count NotLt lda #JOY_RT bit Buttons bnz NotRt inc count lda count cmp #32 blt NotRt lda #0 sta count NotRt lda values bpl nocliplo lda #0 sta values nocliplo cmp #15 blt nocliphi lda #14 sta values nocliphi sta outside inc outside ldy #0 lda #>NameTable(0,15) sta PPU_ADDR lda #NameTable(0,16) sta PPU_ADDR lda #chr sta indir+1 lda #