Prev: 62978 Up: Map Next: 63040
62979: Read Player Controls
Used by the routine at GameStart.
Sample Kempston (31) or the keyboard table at Table_ControlKeyCodes into the control input bitmap. Pause (H / bit 6) waits for the key to be released and pressed again before returning.
Clear the bitmap, then try Kempston if enabled.
Read_PlayerControls 62979 XOR A Clear A, then clear the control input bitmap.
62980 LD (62968),A
62983 LD A,(62978) Fetch the Kempston-enabled flag. Is Kempston selected? If not, read the keyboard at Read_PlayerControls_Keyboard.
62986 OR A
62987 JR Z,Read_PlayerControls_Keyboard
62989 IN A,(31) Read Kempston port 31.
62991 AND %00011111 Keep bits 0–4.
62993 JR NZ,Read_PlayerControls_WriteBitmap If any direction/fire is pressed, store it at Read_PlayerControls_WriteBitmap.
Match the pressed key against Table_ControlKeyCodes and set the corresponding bit.
Read_PlayerControls_Keyboard 62995 CALL Read_KeyboardControls Call Read_KeyboardControls to read a key code.
62998 OR A Was a key pressed? If not, return with the bitmap clear.
62999 RET Z
63000 LD E,1 Start the bit mask at 1 (bit 0 = Right).
63002 LD B,7 Load B with 7 table entries.
63004 LD HL,62971 Point HL at Table_ControlKeyCodes.
Scan Table_ControlKeyCodes for the pressed key and build the matching bit of ControlInputBitmap.
Read_PlayerControls_ScanTable 63007 CP (HL) Does this table slot match the pressed key? If so, handle it at Read_PlayerControls_Matched.
63008 JR Z,Read_PlayerControls_Matched
63010 INC HL Advance to the next slot.
63011 SLA E Shift the bit mask left by one.
63013 DJNZ Read_PlayerControls_ScanTable Loop until the table is exhausted.
63015 XOR A Clear A (unrecognised key), then store a clear bitmap at Read_PlayerControls_WriteBitmap.
63016 JR Read_PlayerControls_WriteBitmap
Matched a control key: handle pause specially, otherwise write the bitmap.
Read_PlayerControls_Matched 63018 LD A,E Keep the matched bit mask in A.
63019 BIT 6,A Is it the pause key (bit 6)? If so, debounce pause at Read_PlayerControls_PauseRelease.
63021 JR NZ,Read_PlayerControls_PauseRelease
Store the assembled control bits into ControlInputBitmap.
Read_PlayerControls_WriteBitmap 63023 LD (62968),A Write the control input bitmap to ControlInputBitmap.
63026 RET Return.
Wait for pause to be released, then for any key to resume.
Read_PlayerControls_PauseRelease 63027 CALL Read_KeyboardControls Call Read_KeyboardControls. Is a key still held? If so, keep waiting at Read_PlayerControls_PauseRelease.
63030 OR A
63031 JR NZ,Read_PlayerControls_PauseRelease
After pause release, wait for any key before resuming play.
Read_PlayerControls_PauseResume 63033 CALL Read_KeyboardControls Call Read_KeyboardControls. Has a key been pressed to resume? If not, keep waiting at Read_PlayerControls_PauseResume.
63036 OR A
63037 JR Z,Read_PlayerControls_PauseResume
63039 RET Return.
Prev: 62978 Up: Map Next: 63040