ReadPaddle:
-:  in     a,($dc)         ; Wait for TR input to be 0
    bit    5,a
    jr     nz,-
    and    $0f             ; Save RLDU bits in e
    ld     e,a
-:  in     a,($dc)         ; Wait for TR input to be 1
    bit    5,a
    jr     z,-
    rrca                   ; Get low 4 bits into 4 high bits
    rrca
    rrca
    rrca
    and    $f0
    or     e               ; Merge with e
    ret                    ; result in a (position 0..255)

Some games use a "weighted history" to smooth out any noise or abrupt changes; this is achieved by adding the latest "raw" position to the last smoothed position and dividing by two. This will however introduce a small control lag.




Return to top
0.069s