09 Jun 2020
Abfrage des Joysticks am VC-20
Wie ich leider feststellen musste, ist die Abfrage des Joysticks am VC-20 ja leider ein Ding, über das sogar Youtube-Videos gedreht werden. Ich habe hier mal eine Schnell-Lösung.
Syntax ist ACME Assembler. Kann sicher noch optimiert werden.
;; joystick bits are returned in accumulator. x reg is changed.
VICjoystick
sei ; no kbd interrupts while joystick - important!
ldx #0
stx $9113 ; DDR A complete input
ldx #%01111111
stx $9122 ; DDR B input bit 7
lda $911f ; Read PortA
lsr ; bit 1 - up, bit 2 - down, bit 3 - left, bit 4 - fire
and #%00011110
eor #%00011110 ; bits are inverted
tax
lda $9120 ; Read PortB
and #%10000000 ; bit 7 = right
eor #%10000000 ; bit is inverted
beq +
inx ; bit 0 - right
+ txa
ldx #$ff ; Restore DDR PortB
stx $9122
cli
Vielleicht trage ich nocheinmal nach, warum das so ist. Hat mit der kruden VC-20-internen Verkabelung zu tun.