base:both_joysticks_handling_plus_proper_keyboard_scan
Differences
This shows you the differences between two versions of the page.
base:both_joysticks_handling_plus_proper_keyboard_scan [2024-02-20 09:30] – created erhan | base:both_joysticks_handling_plus_proper_keyboard_scan [2024-02-20 09:32] (current) – erhan | ||
---|---|---|---|
Line 10: | Line 10: | ||
;all 3 operations are independent and nothing interferes. | ;all 3 operations are independent and nothing interferes. | ||
- | ;keyb lda #$f7 ;standard keyboard read example | + | ;keyb lda #$f7 ;standard keyboard read example |
; sta $dc00 | ; sta $dc00 | ||
; lda $dc01 | ; lda $dc01 | ||
- | ; and #$20 ;scan for key " | + | ; and #$20 ;scan for key " |
; bne + | ; bne + | ||
- | ; ... ;here " | + | ; ... ;here " |
- | ;+ ... ;scan for another key | + | ;+ ... ;scan for another key |
- | j2v .byte $00 ;backup value | + | j2v .byte $00 ;backup value |
- | j2f .byte $00 ;fire, $00 no - $10 yes | + | j2f .byte $00 ;fire, $00 no - $10 yes |
- | j2u .byte $00 ;up, $00 no - $01 yes | + | j2u .byte $00 ;up, $00 no - $01 yes |
- | j2d .byte $00 ;down, $00 no - $01 yes | + | j2d .byte $00 ;down, $00 no - $01 yes |
- | j2l .byte $00 ;left, $00 no - $01 yes | + | j2l .byte $00 ;left, $00 no - $01 yes |
- | j2r .byte $00 ;right, $00 no - $01 yes | + | j2r .byte $00 ;right, $00 no - $01 yes |
j2read lda #$ff | j2read lda #$ff | ||
- | sta $dc00 ;for proper keyboard scan, with joystick scan | + | sta $dc00 ;for proper keyboard scan, with joystick scan |
lda $dc00 | lda $dc00 | ||
eor #$ff | eor #$ff | ||
- | sta j2v ;inverted value and backupped | + | sta j2v ;inverted value and backupped |
and #$0f | and #$0f | ||
beq + | beq + | ||
- | lda #$00 ;clear directions | + | lda #$00 ;clear directions |
sta j2u | sta j2u | ||
sta j2d | sta j2d | ||
sta j2l | sta j2l | ||
sta j2r | sta j2r | ||
- | lda j2v ;calculate direction | + | lda j2v ;calculate direction |
lsr | lsr | ||
rol j2u | rol j2u | ||
Line 48: | Line 48: | ||
+ lda j2v | + lda j2v | ||
and #$10 | and #$10 | ||
- | sta j2f ;$10 for fire pressed | + | sta j2f ;$10 for fire pressed |
rts | rts | ||
- | j1v .byte $00 ;backup value | + | j1v .byte $00 ;backup value |
- | j1f .byte $00 ;fire, $00 no - $10 yes | + | j1f .byte $00 ;fire, $00 no - $10 yes |
- | j1u .byte $00 ;up, $00 no - $01 yes | + | j1u .byte $00 ;up, $00 no - $01 yes |
- | j1d .byte $00 ;down, $00 no - $01 yes | + | j1d .byte $00 ;down, $00 no - $01 yes |
- | j1l .byte $00 ;left, $00 no - $01 yes | + | j1l .byte $00 ;left, $00 no - $01 yes |
- | j1r .byte $00 ;right, $00 no - $01 yes | + | j1r .byte $00 ;right, $00 no - $01 yes |
j1read lda #$ff | j1read lda #$ff | ||
- | sta $dc01 ;for proper keyboard scan, with joystick scan | + | sta $dc01 ;for proper keyboard scan, with joystick scan |
lda $dc01 | lda $dc01 | ||
eor #$ff | eor #$ff | ||
- | sta j1v ;inverted value and backupped | + | sta j1v ;inverted value and backupped |
and #$0f | and #$0f | ||
beq + | beq + | ||
- | lda #$00 ;clear directions | + | lda #$00 ;clear directions |
sta j1u | sta j1u | ||
sta j1d | sta j1d | ||
sta j1l | sta j1l | ||
sta j1r | sta j1r | ||
- | lda j1v ;calculate direction | + | lda j1v ;calculate direction |
lsr | lsr | ||
rol j1u | rol j1u |
base/both_joysticks_handling_plus_proper_keyboard_scan.txt · Last modified: 2024-02-20 09:32 by erhan