User Tools

Site Tools


base:fast_joystick_handling

This is an old revision of the document!


Fast Joystick Handling

Returnes signed movement in A & Y, and CARRY gives FIRE state (SET = No Fire, CLEAR = Fire).

14 (or 16 depending on table memory location) cycles / 11 bytes code (Excl. jsr/rts) + 54 bytes tables = 65 bytes

Joystick:
    ldx CIA1.DataPortB
    cpx #%11110000      // Carry Clear = Fire, Set = No Fire.
    ldy ytab - $e5,x
    lda xtab - $e5,x
    rts
ytab:
    .byte $01, $ff, $00, $00, $01, $ff, $00, $00, $01, $ff, $00, $00, $00, $00, $00, $00
    .byte $01, $ff, $00, $00, $01, $ff, $00, $00, $01, $ff, $00
xtab:
    .byte $01, $01, $01, $00, $ff, $ff, $ff, $00, $00, $00, $00, $00, $00, $00, $00, $00
    .byte $01, $01, $01, $00, $ff, $ff, $ff, $00, $00, $00, $00

The tabled can be reduced by 32 bytes by sacrificing 3 bytes and 4 cycles in the code to mask out the Fire bit (Bit #4).

base/fast_joystick_handling.1692601544.txt.gz · Last modified: 2023-08-21 09:05 by tww