Prev: 9454 Up: Map Next: 9563
9459: Finish Object Pass
The return address of every object handler.
It moves IX on to the next object record. If the frame counter has changed since the last time (that is, an interrupt has happened) the priority records are handled first: the two projectile records and, while Sabreman's type is from 09 to 1B Sabreman himself.
When all of the object records have been handled it adds one to the tick counter, counts down the gem timer, checks for the pause key and for a new press of an action key, runs the handlers of the small object records and then starts the main loop again.
Move on to the next object record and see if the frame counter has changed.
Finish_Object_Pass 9459 LD DE,$0010 Set the size of an object record to 10.
945C ADD IX,DE Move IX on to the next object record.
945E PUSH IX Stash the pointer to the next record on the stack.
9460 LD HL,($5C78) Fetch the frame counter (the low word of FRAMES) from 5C78.
9463 LD DE,($8EDF) Fetch the last frame counter from LastFrame.
9467 LD ($8EDF),HL Store the new frame counter in LastFrame.
946A AND A Subtract the last frame counter from the new one.
946B SBC HL,DE
946D JP NZ,Finish_Object_Pass_Priority_Records Jump to Finish_Object_Pass_Priority_Records if the frame counter has changed.
If there are more object records, run the handler of the next one.
Finish_Object_Pass_Next_Record 9470 POP HL Restore the pointer to the next record into HL.
9471 LD DE,$902A Point at the end of the object records (Small_Object_Records).
9474 AND A Subtract the end of the records from the pointer.
9475 SBC HL,DE
9477 JP C,Run_Object_Handler Jump to Run_Object_Handler if there are more records to handle.
All of the records have been handled, so count a tick.
947A LD HL,($8ED6) Fetch the tick counter from GameTimer.
947D INC HL Add one to the tick counter.
947E LD ($8ED6),HL Store the tick counter.
9481 LD A,($8EF1) Fetch the byte at Type_5C_Active_Flag.
9484 LD ($8EF2),A Store it in Previous_Type_5C_Active_Flag.
9487 XOR A Write 00 to Type_5C_Active_Flag.
9488 LD ($8EF1),A
948B LD A,($8ED6) Fetch the low byte of the tick counter.
948E AND %00000011 Keep only bits 0 and 1.
9490 JR NZ,Finish_Object_Pass_Check_Pause Jump to Finish_Object_Pass_Check_Pause if the tick counter is not a multiple of four.
Every fourth tick the gem timer counts down.
9492 LD A,($8EEE) Fetch the gem timer from Gem_Timer.
9495 AND A Jump to Finish_Object_Pass_Check_Pause if the gem timer is zero.
9496 JR Z,Finish_Object_Pass_Check_Pause
9498 DEC A Count down the gem timer, keeping it as a BCD value.
9499 DAA
949A LD ($8EEE),A Store the gem timer.
949D PUSH AF Stash the timer flags on the stack.
949E CALL Print_Status_Panel_Gem_Timer Print the gem timer.
94A1 POP AF Restore the timer flags.
94A2 JR NZ,Finish_Object_Pass_Check_Pause Jump to Finish_Object_Pass_Check_Pause if the gem timer has not run out.
94A4 LD A,$47 Make Sabreman bright white again.
94A6 LD ($8F1F),A
Check for the ENTER key which pauses the game.
Finish_Object_Pass_Check_Pause 94A9 LD A,$BF Read from the keyboard;
Port Number Bit
0 1 2 3 4
BF ENTER L K J H
94AB OUT ($FD),A
94AD IN A,($FE)
94AF AND %00000001 Keep only the bit for ENTER.
94B1 JR NZ,Finish_Object_Pass_Check_Action_Keys Jump to Finish_Object_Pass_Check_Action_Keys if ENTER is not pressed.
94B3 DI Disable interrupts.
Wait for ENTER to be released.
Finish_Object_Pass_Wait_For_Release 94B4 LD A,$BF Read from the keyboard;
Port Number Bit
0 1 2 3 4
BF ENTER L K J H
94B6 OUT ($FD),A
94B8 CALL Pause_Briefly
94BB IN A,($FE) Read from port FE.
94BD AND %00000001 Keep only the bit for ENTER.
94BF JR Z,Finish_Object_Pass_Wait_For_Release Jump to Finish_Object_Pass_Wait_For_Release if ENTER is still pressed.
The game is paused. Wait for ENTER to be pressed again.
Finish_Object_Pass_Wait_For_Resume 94C1 LD A,$BF Read from the keyboard;
Port Number Bit
0 1 2 3 4
BF ENTER L K J H
94C3 OUT ($FD),A
94C5 CALL Pause_Briefly
94C8 IN A,($FE) Read from port FE.
94CA AND %00000001 Keep only the bit for ENTER.
94CC JR NZ,Finish_Object_Pass_Wait_For_Resume Jump to Finish_Object_Pass_Wait_For_Resume if ENTER is not pressed.
Wait for ENTER to be released and carry on with the game.
Finish_Object_Pass_Wait_For_Final_Release 94CE LD A,$BF Read from the keyboard;
Port Number Bit
0 1 2 3 4
BF ENTER L K J H
94D0 OUT ($FD),A
94D2 CALL Pause_Briefly
94D5 IN A,($FE) Read from port FE.
94D7 AND %00000001 Keep only the bit for ENTER.
94D9 JR Z,Finish_Object_Pass_Wait_For_Final_Release Jump to Finish_Object_Pass_Wait_For_Final_Release if ENTER is still pressed.
94DB EI Enable interrupts.
Check for the keys that pick up, drop or throw weapons (SPACE, SYMBOL SHIFT, M, N and B). A new press is recorded in New_Action_Key_Press_Flag and a held key in Action_Key_Held_Flag.
Finish_Object_Pass_Check_Action_Keys 94DC LD A,($8EF0) Fetch the room redrawn flag from Room_Redrawn_Flag.
94DF AND A Jump to Handle_Small_Objects if the room has just been redrawn.
94E0 JR NZ,Handle_Small_Objects
94E2 LD A,$7F Read from the keyboard;
Port Number Bit
0 1 2 3 4
7F SPACE SYMBOL SHIFT M N B
94E4 OUT ($FD),A
94E6 IN A,($FE)
94E8 CPL Flip the bits so that a pressed key gives a set bit.
94E9 AND %00011111 Keep only the bits of the five keys.
94EB JR NZ,Finish_Object_Pass_Key_Is_Pressed Jump to Finish_Object_Pass_Key_Is_Pressed if one of the keys is pressed.
Finish_Object_Pass_Store_Key_Flags 94ED LD ($8EE9),A Store the key held flag in Action_Key_Held_Flag.
94F0 LD ($8EEA),A Store the new key press flag in New_Action_Key_Press_Flag.
94F3 JR Handle_Small_Objects Jump to Handle_Small_Objects.
Finish_Object_Pass_Key_Is_Pressed 94F5 LD A,($8EE9) Fetch the key held flag from Action_Key_Held_Flag.
94F8 AND A Jump to Finish_Object_Pass_Key_Is_Held if the key was already pressed.
94F9 JR NZ,Finish_Object_Pass_Key_Is_Held
This is a new press, so empty the table of the weapons that Sabreman holds; the handlers of the weapons fill it in again.
94FB XOR A Empty the three slots of the weapons table at Weapon_Slots.
94FC LD H,A
94FD LD L,A
94FE LD ($8EEB),A
9501 LD ($8EEC),HL
9504 LD A,$FF Jump to Finish_Object_Pass_Store_Key_Flags with FF to set the key held and new key press flags.
9506 JR Finish_Object_Pass_Store_Key_Flags
Finish_Object_Pass_Key_Is_Held 9508 XOR A The key is only being held, so clear the new key press flag in New_Action_Key_Press_Flag.
9509 LD ($8EEA),A
Run the handlers of the small object records.
Handle_Small_Objects 950C LD IX,$902A Point at the first small object record (Small_Object_Records).
Finish_Object_Pass_Small_Object_Loop 9510 LD HL,$954C Point at the return address of the handler (Finish_Object_Pass_Small_Object_Return).
9513 PUSH HL Stash it on the stack.
9514 LD L,(IX+$00) Fetch the type of the object.
9517 LD BC,$921A Point at the handler table (Object_Handler_Table).
951A JP Run_Object_Handler_Look_Up Jump to Run_Object_Handler_Look_Up to run the handler.
The frame counter has changed, so handle the priority records: the first two object records (the projectiles) and, when Sabreman's type is from 09 to 1B Sabreman's record too.
Finish_Object_Pass_Priority_Records 951D LD IX,$8EFA Point at the first object record (Object_Records).
Finish_Object_Pass_Priority_Loop 9521 LD HL,$9527 Point at the return address of the handler (Finish_Object_Pass_Priority_Return).
9524 JP Run_Object_Handler_Stash_Return Jump to Run_Object_Handler_Stash_Return to run the handler.
Finish_Object_Pass_Priority_Return 9527 LD DE,$0010 Set the size of an object record to 10.
952A ADD IX,DE Move IX on to the next object record.
952C LD DE,$8F1A Point at the record of Sabreman (Sabreman_Record).
952F LD A,($8F1A) Fetch the type of Sabreman.
9532 CP $1C Jump to Finish_Object_Pass_Priority_Limit if the type is greater than or equal to 1C.
9534 JR NC,Finish_Object_Pass_Priority_Limit
9536 CP $09 Jump to Finish_Object_Pass_Priority_Limit if the type is less than 09.
9538 JR C,Finish_Object_Pass_Priority_Limit
953A LD DE,$8F2A Point at the record after Sabreman's (Rope_Record).
Finish_Object_Pass_Priority_Limit 953D PUSH IX Copy IX to HL (using the stack).
953F POP HL
9540 AND A Subtract the limit from the pointer.
9541 SBC HL,DE
9543 JR C,Finish_Object_Pass_Priority_Loop Jump to Finish_Object_Pass_Priority_Loop if there are more priority records to handle.
9545 POP IX Restore IX to the pointer to the next record.
9547 PUSH IX Stash it on the stack again.
9549 JP Finish_Object_Pass_Next_Record Jump to Finish_Object_Pass_Next_Record to carry on with the normal pass.
Return address of the handlers of the small object records.
Finish_Object_Pass_Small_Object_Return 954C LD DE,$0008 Set the size of a small object record to 08.
954F ADD IX,DE Move IX on to the next small object record.
9551 PUSH IX Copy IX to HL (using the stack).
9553 POP HL
9554 LD DE,$9052 Point at the end of the small object records (Select_Game_Options).
9557 AND A Subtract the end of the records from the pointer.
9558 SBC HL,DE
955A JR C,Finish_Object_Pass_Small_Object_Loop Jump to Finish_Object_Pass_Small_Object_Loop if there are more small object records to handle.
955C XOR A Write 00 to Room_Redrawn_Flag to clear the room redrawn flag.
955D LD ($8EF0),A
9560 JP Main_Loop Jump back to the main loop.
Prev: 9454 Up: Map Next: 9563