Prev: AC24 Up: Map Next: AC6B
AC28: Pause Game
Used by the routines at UpdateCounters, GameComplete and HandlerPoems.
Pauses the game if SPACE (or CAPS SHIFT) is being pressed on its own. While the game is paused the border flashes. Pressing SPACE (or CAPS SHIFT) again carries on with the game, and the border is set back to black.
PauseGame AC28 EI Enable interrupts.
AC29 LD A,$7E Read from the keyboard (7E is also written to port FD);
Port Number Bit
0 1 2 3 4
7E SPACE FULL-STOP M N B
Shift Z X C V
AC2B OUT ($FD),A
AC2D IN A,($FE)
AC2F BIT 0,A Return if neither SPACE nor CAPS SHIFT is being pressed.
AC31 RET NZ
AC32 CPL Flip the bits so that the keys being pressed are set.
AC33 AND %00011110 Keep only the other keys on this row (bits 1-4).
AC35 RET NZ Return if any other key is being pressed.
Wait for the key to be released.
PauseGame_Release AC36 LD A,$7E Read from the keyboard (7E is also written to port FD);
Port Number Bit
0 1 2 3 4
7E SPACE FULL-STOP M N B
Shift Z X C V
AC38 OUT ($FD),A
AC3A IN A,($FE)
AC3C BIT 0,A Jump back to PauseGame_Release until SPACE and CAPS SHIFT have been released.
AC3E JR Z,PauseGame_Release
Flash the border every frame until the key is pressed again.
PauseGame_Loop AC40 LD HL,$5C78 Point HL at FRAMES.
AC43 LD A,(HL) Fetch the frame counter.
PauseGame_Frame AC44 CP (HL) Jump back to PauseGame_Frame until the frame counter changes.
AC45 JR Z,PauseGame_Frame
AC47 LD A,D Fetch the border flash counter from D.
AC48 ADD A,$04 Add 04 to the border flash counter.
AC4A LD D,A Store the border flash counter in D.
AC4B RLCA Rotate left twice, so bit 7 is now in bit 1.
AC4C RLCA
AC4D AND %00000010 Keep only bit 1.
AC4F OR %00000001 Set bit 0, so the border alternates between blue and magenta.
AC51 OUT ($FE),A Set the border colour.
AC53 LD A,$7E Read from the keyboard (7E is also written to port FD);
Port Number Bit
0 1 2 3 4
7E SPACE FULL-STOP M N B
Shift Z X C V
AC55 OUT ($FD),A
AC57 IN A,($FE)
AC59 BIT 0,A Jump back to PauseGame_Loop until SPACE or CAPS SHIFT is pressed to unpause.
AC5B JR NZ,PauseGame_Loop
Wait for the key to be released again.
PauseGame_Release_Again AC5D LD A,$7E Read from the keyboard (7E is also written to port FD);
Port Number Bit
0 1 2 3 4
7E SPACE FULL-STOP M N B
Shift Z X C V
AC5F OUT ($FD),A
AC61 IN A,($FE)
AC63 BIT 0,A Jump back to PauseGame_Release_Again until SPACE and CAPS SHIFT have been released.
AC65 JR Z,PauseGame_Release_Again
AC67 XOR A Select black for the border.
AC68 OUT ($FE),A Set the border colour.
AC6A RET Return.
Prev: AC24 Up: Map Next: AC6B