Prev: 7302 Up: Map Next: 733f
7309: Read input from the keyboard port.
Used by the routines at 739e and 753c.
Output
A direction values $EF (L), $F7 (R) or $FF for no input detected - like joystick: 000LRDUF.
7309 ld a,($5cf3) Game options
730c bit 1,a Use Joystick?
730e jr nz,$7302 Jump if so
Read bottom-left row of keys.
7310 ld a,$fe Row: Shift,Z,X,C,V
7312 out ($fd),a Set port for reading keyboard
7314 in a,($fe) ...and read that row of keys
7316 and $1e
7318 cp $1e Check if any keys on the row are pressed
731a jr z,$7324 Jump if not - read inputs again
731c and $14 Reset all bits except X and V keys (RIGHT keys)
731e cp $14 Check if neither are pressed (reset)
7320 jr z,$7336 If so, a LEFT key was pressed: Z and C
7322 jr $7339 else RIGHT key was pressed: X and V
Read bottom-right row of keys.
7324 ld a,$7f Row: B,N,M.Sym,Sp
7326 out ($fd),a Set port for reading keyboard
7328 in a,($fe) ...and read that row of keys
732a and $1e
732c cp $1e Check if any keys on the row are pressed
732e jr z,$733c Jump if not - no input detected.
7330 and $14 Reset all bits except B and M keys (LEFT keys)
7332 cp $14 Check if neither are pressed (reset)
7334 jr z,$7339 If so, a RIGHT key was pressed: N and Sym
7336 ld a,$ef A=LEFT_KEY : 1110 1111
7338 ret
7339 ld a,$f7 A=RIGHT_KEY : 1111 0111
733b ret
733c ld a,$ff A=No input detected
733e ret
Prev: 7302 Up: Map Next: 733f