Prev: 44126 Up: Map Next: 44258
44138: Handle Menu Keys
The routine for state 5 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 44138 LD IY,44114 Point IY at the entry for the first revolver.
44142 LD DE,4 Set the size of an entry.
44145 LD B,3 Set the number of revolvers to three.
HandleMenuKeys_Loop 44147 LD A,(IY+0) Fetch the state of the revolver.
44150 AND A Start the revolver if it has not fired yet.
44151 JR Z,HandleMenuKeys_StartMenuRevolver
44153 SUB 2 Subtract two from the state.
44155 CP 3 Return if the revolver is firing or its bullet is flying.
44157 RET C
44158 ADD IY,DE Move on to the next entry.
44160 DJNZ HandleMenuKeys_Loop Loop back until all three revolvers have been checked.
Play the title tune and read keys 1 to 5.
44162 LD DE,45267 Point DE at TitleTune.
44165 CALL PlayMusicOnce Play the tune, unless it has already been played or a key is pressed.
44168 LD DE,41500 Point DE at Options.
44171 LD A,247 Select the keys 1 to 5.
44173 CALL ReadKeyboardPort Read the keys.
44176 LD C,A Keep the keys in C.
44177 LD HL,41483 Point HL at KeyOneHeldFlag.
Check key 1.
44180 BIT 0,C Jump to HandleMenuKeys_Key1Pressed if key 1 is pressed.
44182 JR NZ,HandleMenuKeys_Key1Pressed
44184 LD (HL),0 Note that key 1 is not held down.
HandleMenuKeysKey_2 44186 INC HL Point HL at the flag for key 2 being held down.
Check key 2.
44187 BIT 1,C Jump to HandleMenuKeys_Key2Pressed if key 2 is pressed.
44189 JR NZ,HandleMenuKeys_Key2Pressed
44191 LD (HL),0 Note that key 2 is not held down.
HandleMenuKeysKey_3 44193 INC HL Move on to the next flag.
Check key 3.
44194 BIT 2,C Return if key 3 is not pressed.
44196 RET Z
44197 LD HL,41537 Point HL at StartGameFlag.
44200 INC (HL) Set the flag.
44201 LD DE,45257 Point DE at StartGameTune.
44204 CALL PlayMusic Play the tune.
44207 LD IY,44122 Point IY at MenuEntries_ThirdRevolver.
44211 JR HandleMenuKeys_StartMenuRevolver Make the revolver fire.
Key 1 is pressed, so swap between one and two players.
HandleMenuKeys_Key1Pressed 44213 LD A,(HL) Fetch the flag for key 1.
44214 AND A Test whether the key was already held down.
44215 JR NZ,HandleMenuKeysKey_2 Jump to HandleMenuKeysKey_2 if it was.
44217 LD (HL),1 Note that key 1 is held down.
44219 LD IY,44114 Point IY at MenuEntries_FirstRevolver.
44223 LD A,(DE) Fetch the options.
44224 XOR %00000001 Flip bit 0 to choose the other number of players.
44226 LD (DE),A Store the options.
44227 JR HandleMenuKeys_StartMenuRevolver Make the revolver fire.
Key 2 is pressed, so choose the next type of controls.
HandleMenuKeys_Key2Pressed 44229 LD A,(HL) Fetch the flag for key 2.
44230 AND A Test whether the key was already held down.
44231 JR NZ,HandleMenuKeysKey_3 Jump to HandleMenuKeysKey_3 if it was.
44233 LD (HL),1 Note that key 2 is held down.
44235 LD IY,44118 Point IY at MenuEntries_SecondRevolver.
44239 LD A,(DE) Fetch the options.
44240 ADD A,2 Move on to the next type of controls.
44242 AND %00000111 Keep bits 1 and 2 as the type, and bit 0 as the number of players.
44244 LD (DE),A Store the options.
Make the revolver fire.
HandleMenuKeys_StartMenuRevolver 44245 LD (IY+0),2 Set the state of the revolver to firing.
44249 LD (IY+1),72 Set the horizontal position of the bullet.
44253 LD (IY+3),0 Reset the counter.
44257 RET Return.
Prev: 44126 Up: Map Next: 44258