Prev: AC5E Up: Map Next: ACE2
AC6A: Handle Menu Keys
The routine for state 05 of a menu entry, which is the only entry that reads the keys. First it starts each revolver which has not yet fired. When all three have finished it plays the title tune and checks keys 1, 2 and 3. Key 1 swaps between one and two players and key 2 chooses the next type of controls, and both make their revolver fire again so that the new text is typed. Key 3 starts the game, and fires the third revolver.
Start the next revolver which has not yet fired.
HandleMenuKeys AC6A LD IY,$AC52 Point IY at the entry for the first revolver.
AC6E LD DE,$0004 Set the size of an entry.
AC71 LD B,$03 Set the number of revolvers to three.
HandleMenuKeys_Loop AC73 LD A,(IY+$00) Fetch the state of the revolver.
AC76 AND A Start the revolver if it has not fired yet.
AC77 JR Z,HandleMenuKeys_StartMenuRevolver
AC79 SUB $02 Subtract two from the state.
AC7B CP $03 Return if the revolver is firing or its bullet is flying.
AC7D RET C
AC7E ADD IY,DE Move on to the next entry.
AC80 DJNZ HandleMenuKeys_Loop Loop back until all three revolvers have been checked.
Play the title tune and read keys 1 to 5.
AC82 LD DE,$B0D3 Point DE at TitleTune.
AC85 CALL PlayMusicOnce Play the tune, unless it has already been played or a key is pressed.
AC88 LD DE,$A21C Point DE at Options.
AC8B LD A,$F7 Select the keys 1 to 5.
AC8D CALL ReadKeyboardPort Read the keys.
AC90 LD C,A Keep the keys in C.
AC91 LD HL,$A20B Point HL at KeyOneHeldFlag.
Check key 1.
AC94 BIT 0,C Jump to HandleMenuKeys_Key1Pressed if key 1 is pressed.
AC96 JR NZ,HandleMenuKeys_Key1Pressed
AC98 LD (HL),$00 Note that key 1 is not held down.
HandleMenuKeysKey_2 AC9A INC HL Point HL at the flag for key 2 being held down.
Check key 2.
AC9B BIT 1,C Jump to HandleMenuKeys_Key2Pressed if key 2 is pressed.
AC9D JR NZ,HandleMenuKeys_Key2Pressed
AC9F LD (HL),$00 Note that key 2 is not held down.
HandleMenuKeysKey_3 ACA1 INC HL Move on to the next flag.
Check key 3.
ACA2 BIT 2,C Return if key 3 is not pressed.
ACA4 RET Z
ACA5 LD HL,$A241 Point HL at StartGameFlag.
ACA8 INC (HL) Set the flag.
ACA9 LD DE,$B0C9 Point DE at StartGameTune.
ACAC CALL PlayMusic Play the tune.
ACAF LD IY,$AC5A Point IY at MenuEntries_ThirdRevolver.
ACB3 JR HandleMenuKeys_StartMenuRevolver Make the revolver fire.
Key 1 is pressed, so swap between one and two players.
HandleMenuKeys_Key1Pressed ACB5 LD A,(HL) Fetch the flag for key 1.
ACB6 AND A Test whether the key was already held down.
ACB7 JR NZ,HandleMenuKeysKey_2 Jump to HandleMenuKeysKey_2 if it was.
ACB9 LD (HL),$01 Note that key 1 is held down.
ACBB LD IY,$AC52 Point IY at MenuEntries_FirstRevolver.
ACBF LD A,(DE) Fetch the options.
ACC0 XOR %00000001 Flip bit 0 to choose the other number of players.
ACC2 LD (DE),A Store the options.
ACC3 JR HandleMenuKeys_StartMenuRevolver Make the revolver fire.
Key 2 is pressed, so choose the next type of controls.
HandleMenuKeys_Key2Pressed ACC5 LD A,(HL) Fetch the flag for key 2.
ACC6 AND A Test whether the key was already held down.
ACC7 JR NZ,HandleMenuKeysKey_3 Jump to HandleMenuKeysKey_3 if it was.
ACC9 LD (HL),$01 Note that key 2 is held down.
ACCB LD IY,$AC56 Point IY at MenuEntries_SecondRevolver.
ACCF LD A,(DE) Fetch the options.
ACD0 ADD A,$02 Move on to the next type of controls.
ACD2 AND %00000111 Keep bits 1 and 2 as the type, and bit 0 as the number of players.
ACD4 LD (DE),A Store the options.
Make the revolver fire.
HandleMenuKeys_StartMenuRevolver ACD5 LD (IY+$00),$02 Set the state of the revolver to firing.
ACD9 LD (IY+$01),$48 Set the horizontal position of the bullet.
ACDD LD (IY+$03),$00 Reset the counter.
ACE1 RET Return.
Prev: AC5E Up: Map Next: ACE2