Prev: F788 Up: Map Next: F8BE
F795: Handler: Collision Monsters?
Used by the routine at F788.
Input
HL Either D243 or D240
B is used as the "currently processed monster ID"; we work backwards from Ralph, to Lizzy and last George.
Handler_CollisionMonsters F795 LD B,$03 B=03 (total number of monsters/ players).
Handler_CollisionMonsters_Loop F797 LD A,(HL) A=*HL.
F798 AND A Jump to Handler_CollisionMonsters_Next if A is zero.
F799 JR Z,Handler_CollisionMonsters_Next
F79B CP $C1 Jump to Handler_CollisionMonsters_0 if A is higher than C1.
F79D JR NC,Handler_CollisionMonsters_0
F79F AND %00111111 Keep only bits 0-5.
F7A1 CP $32 Jump to Handler_CollisionMonsters_0 if A is higher than 32.
F7A3 JR NC,Handler_CollisionMonsters_0
F7A5 LD A,B A=currently processed monster ID.
F7A6 CALL SetIYMonsterData Call SetIYMonsterData.
IX now contains a pointer to the currently processed monster state data.
F7A9 PUSH IY IX=IY using the stack.
F7AB POP IX
F7AD LD A,(HL) A=*HL.
F7AE CALL Convert_To_MonsterData Call Convert_To_MonsterData, on return - A will contain the action monster ID and IY the monster state.
Is the action targeting the currently processed monster?
F7B1 CP B Jump to Handler_CollisionMonsters_Next if the action is for the monster currently being processed.
F7B2 JR Z,Handler_CollisionMonsters_Next
F7B4 LD A,(IY+$02) Jump to Handler_CollisionMonsters_Punched if *IY+02 is not zero.
F7B7 AND A
F7B8 JR NZ,Handler_CollisionMonsters_Punched
F7BA LD A,(IY+$03) A=*IY+03.
F7BD XOR (IX+$03)
F7C0 JR Z,Handler_CollisionMonsters_Punched Jump to Handler_CollisionMonsters_Punched if the result is zero.
F7C2 LD A,(IX+$03) A=*IX+03.
F7C5 LD (IY+$03),A Write A to *IY+03.
Handler_CollisionMonsters_Punched F7C8 LD (IY+$00),$0A Write 0A to *IY+00.
F7CC LD (IY+$04),$01 Write 01 to *IY+04.
Take off two hit points from the monsters energy.
F7D0 LD A,$02 A=02.
F7D2 CALL Handler_DecreaseEnergy Call Handler_DecreaseEnergy.
F7D5 LD A,$06 Write melody ID 06 to *MelodyID.
F7D7 LD ($FF8D),A
Handler_CollisionMonsters_Next F7DA DEC HL Decrease HL by one.
F7DB DJNZ Handler_CollisionMonsters_Loop Decrease counter by one and loop back to Handler_CollisionMonsters_Loop until counter is zero.
F7DD RET Return.
Handler_CollisionMonsters_0 F7DE LD A,(HL) A=*HL.
F7DF PUSH HL Stash HL and BC on the stack.
F7E0 PUSH BC
F7E1 CP $05 Jump to Housekeeping_CollisionMonsters_Next if A is equal to 05.
F7E3 JR Z,Housekeeping_CollisionMonsters_Next
F7E5 CP $40 Jump to Handler_Vehicle_Punched if A is lower than 40.
F7E7 JR C,Handler_Vehicle_Punched
F7E9 CP $79 Jump to Handler_CollisionMonsters_1 if A is equal to 79.
F7EB JR Z,Handler_CollisionMonsters_1
F7ED CP $7B Jump to Housekeeping_CollisionMonsters_Next if A is equal to 7B.
F7EF JR Z,Housekeeping_CollisionMonsters_Next
F7F1 CP $7F Jump to Housekeeping_CollisionMonsters_Next if A is equal to 7F.
F7F3 JR Z,Housekeeping_CollisionMonsters_Next
F7F5 CP $75 Jump to Housekeeping_CollisionMonsters_Next if A is equal to 75.
F7F7 JR Z,Housekeeping_CollisionMonsters_Next
F7F9 CP $77 Jump to Housekeeping_CollisionMonsters_Next if A is equal to 77.
F7FB JR Z,Housekeeping_CollisionMonsters_Next
F7FD CP $DD Jump to Handler_CollisionMonsters_3 if A is lower than DD.
F7FF JR C,Handler_CollisionMonsters_3
F801 JP Handler_Helicopter_Punched Jump to Handler_Helicopter_Punched.
Tidies the stack before moving onto the next monster.
Housekeeping_CollisionMonsters_Next F804 POP BC Restore BC and HL from the stack.
F805 POP HL
F806 JR Handler_CollisionMonsters_Next Jump to Handler_CollisionMonsters_Next.
Handles when a vehicle has been punched.
Handler_Vehicle_Punched F808 LD A,$18 Reset *VehicleCounter back to 18.
F80A LD ($D401),A
F80D LD A,B A=currently processed monster ID.
F80E LD DE,$0503 DE=0503.
F811 CALL Handler_AddPoints Call Handler_AddPoints.
F814 LD A,($D404) A=*VehicleYPosition.
F817 AND %00111111 Keep only bits 0-5.
F819 INC A Increment A by one.
F81A LD B,A B=A.
F81B LD A,($D403) C=*VehicleXPosition.
F81E LD C,A
F81F LD A,$77 A=explosion sprite (77).
ID Sprite
77 sprite-119-left
F821 CALL PrintSprite Call PrintSprite.
F824 LD A,$06 Write melody ID 06 to *MelodyID.
F826 LD ($FF8D),A
F829 JR Housekeeping_CollisionMonsters_Next Jump to Housekeeping_CollisionMonsters_Next.
Handler_CollisionMonsters_1 F82B LD A,B A=B.
F82C CALL SetIYMonsterData Call SetIYMonsterData.
F82F LD A,($D406) A=*TrainXPosition.
F832 SUB $04 A-=04.
F834 CP (IY+$09) Compare A with *IY+09.
F837 LD A,($D407) A=*TrainYPosition.
F83A JR NC,Handler_CollisionMonsters_2 Jump to Handler_CollisionMonsters_2 if {} is higher.
F83C XOR %10000000 Flip bit 7.
Handler_CollisionMonsters_2 F83E OR %01000000 Set bit 6.
F840 LD ($D407),A Write A to *TrainYPosition.
F843 LD A,B A=B.
F844 LD DE,$0203 DE=0203.
F847 CALL Handler_AddPoints Call Handler_AddPoints.
F84A LD A,$06 Write melody ID 06 to *MelodyID.
F84C LD ($FF8D),A
F84F JR Housekeeping_CollisionMonsters_Next Jump to Housekeeping_CollisionMonsters_Next.
Handler_CollisionMonsters_3 F851 LD A,B A=B.
F852 CALL SetIYMonsterData Call SetIYMonsterData.
F855 LD A,(IY+$04) Jump to Housekeeping_CollisionMonsters_Next if *IY+04 is not zero.
F858 AND A
F859 JR NZ,Housekeeping_CollisionMonsters_Next
F85B LD A,(IY+$02) Jump to Housekeeping_CollisionMonsters_Next if *IY+02 is zero.
F85E AND A
F85F JR Z,Housekeeping_CollisionMonsters_Next
F861 LD (IY+$00),$1A Write 1A to *IY+00.
F865 LD (IY+$07),$04 Write 04 to *IY+07.
F869 LD A,B A=B.
F86A LD D,$01 D=01.
F86C LD E,$03 E=03.
F86E CALL Handler_AddPoints Call Handler_AddPoints.
F871 LD A,$06 Write melody ID 06 to *MelodyID.
F873 LD ($FF8D),A
F876 JR Housekeeping_CollisionMonsters_Next Jump to Housekeeping_CollisionMonsters_Next.
Handles when a helicopter has been punched.
Handler_Helicopter_Punched F878 PUSH AF Stash AF on the stack.
F879 LD A,B A=B.
F87A LD D,$05 D=05.
F87C LD E,$03 E=03.
F87E CALL Handler_AddPoints Call Handler_AddPoints.
F881 POP AF Restore AF from the stack.
F882 SUB $E6 A-=E6.
F884 ADD A,A A*=04.
F885 ADD A,A
F886 LD H,$00 H=00.
F888 LD L,A L=A.
F889 LD DE,$D2A7 HL+=Table_SomethingHelicopters.
F88C ADD HL,DE
F88D LD A,(HL) Jump to Housekeeping_CollisionMonsters_Next if *HL is zero.
F88E AND A
F88F JP Z,Housekeeping_CollisionMonsters_Next
F892 LD A,($D3F6) Decrease *NumberOnScreenHelicopters by one.
F895 DEC A
F896 LD ($D3F6),A
F899 LD A,(HL) A=*HL.
F89A LD (HL),$00 Write 00 to *HL.
F89C INC HL Increment HL by one.
F89D RRCA RRCA.
F89E AND %00000111 Keep only bits 0-2.
F8A0 CP $03 Jump to SetExplosionCoordinates if A is lower than 03.
F8A2 JR C,SetExplosionCoordinates
F8A4 CP $06 Jump to SetExplosionCoordinates if A is higher than 06.
F8A6 JR NC,SetExplosionCoordinates
Set BC to the screen co-ordinates for the explosion.
F8A8 LD B,(HL) B=*HL.
F8A9 INC HL Increment HL by one.
F8AA LD C,(HL) C=*HL.
Displays an explosion sprite.
Handler_Helicopter_Explosion F8AB LD A,$77 A=explosion sprite (77).
ID Sprite
77 sprite-119-left
F8AD CALL PrintSprite Call PrintSprite.
F8B0 LD A,$06 Write melody ID 06 to *MelodyID.
F8B2 LD ($FF8D),A
F8B5 JP Housekeeping_CollisionMonsters_Next Jump to Housekeeping_CollisionMonsters_Next.
Set BC to the screen co-ordinates for the explosion.
SetExplosionCoordinates F8B8 LD C,(HL) C=*HL.
F8B9 INC HL Increment HL by two.
F8BA INC HL
F8BB LD B,(HL) B=*HL.
F8BC JR Handler_Helicopter_Explosion Jump to Handler_Helicopter_Explosion.
Prev: F788 Up: Map Next: F8BE