Prev: DBD9 Up: Map Next: DCA1
DBE5: Handler: Helicopters
Used by the routine at RunHandlers.
Handler_Helicopters DBE5 LD B,$06 B=06 (maximum possible number of on-screen helicopters).
DBE7 LD IX,$D295 IX=Table_Helicopters.
DBEB XOR A Write 00 to *Flag_Orientation.
DBEC LD ($D247),A
Handler_Helicopters_Loop DBEF PUSH BC Stash current helicopter on the stack.
DBF0 LD A,(IX+$00) Jump to Handler_Helicopters_Next if this helicopter is not active.
DBF3 LD D,A
DBF4 AND A
DBF5 JP Z,Handler_Helicopters_Next
DBF8 LD C,(IX+$01) C=*IX+01.
DBFB LD B,(IX+$02) B=*IX+02.
DBFE RLCA Rotate A left one position, setting the carry flag if bit 7 was set.
DBFF JR C,Handler_Helicopters_3 Jump to Handler_Helicopters_3 if the carry flag is set.
DC01 LD A,C Jump to Handler_Helicopters_0 if C is equal to 21.
DC02 CP $21
DC04 JR Z,Handler_Helicopters_0
DC06 LD A,D A=D.
DC07 AND %01000011 Keep only bits 0-1 and 6.
DC09 INC A Increment A by one.
DC0A CP $44 Jump to Handler_Helicopters_5 until A is equal to 44.
DC0C JP NZ,Handler_Helicopters_5
DC0F LD A,$40 A=40.
DC11 INC C Increment C by one.
DC12 LD (IX+$01),C Write C to *IX+01.
DC15 JP Handler_Helicopters_5 Jump to Handler_Helicopters_5.
Handler_Helicopters_0 DC18 LD B,$04 B=04.
DC1A LD C,$20 C=20.
Handler_Helicopters_1 DC1C LD A,($D3F6) Jump to Handler_Helicopters_2 if *NumberOnScreenHelicopters is equal to 06.
DC1F CP $06
DC21 JR Z,Handler_Helicopters_2
Loop to find an empty slot.
DC23 LD HL,$D2A3 HL=D2A3 (Table_SomethingHelicopters-04).
Handler_Helicopters_FindSlot DC26 INC HL Increment HL by four.
DC27 INC HL
DC28 INC HL
DC29 INC HL
DC2A LD A,(HL) Jump to Handler_Helicopters_FindSlot if *HL is not zero.
DC2B AND A
DC2C JR NZ,Handler_Helicopters_FindSlot
DC2E LD (HL),B Write B to *HL.
DC2F INC HL Increment HL by one.
DC30 LD (HL),C Write C to *HL.
DC31 INC HL Increment HL by one.
DC32 CALL RandomNumber Get a random number between 0-31.
DC35 AND %00011111
DC37 ADD A,$08 A+=08.
DC39 AND %00011111 Keep only bits 0-4.
DC3B LD (HL),A Write A to *HL.
DC3C INC HL Increment HL by one.
DC3D LD A,(IX+$02) A=*IX+02.
DC40 DEC A Decrease A by one.
DC41 RLCA RLCA.
DC42 RLCA
DC43 ADD A,$04 A+=04.
DC45 LD (HL),A Write A to *HL.
DC46 CALL RandomNumber Get a random number between 0-3.
DC49 AND %00000011
DC4B ADD A,(HL) A+=*HL.
DC4C LD (HL),A Write A to *HL.
Handler_Helicopters_2 DC4D LD (IX+$00),$00 Write 00 to *IX+00.
DC51 LD A,($D3F5) Decrease *NumberActiveHelicopters by one.
DC54 DEC A
DC55 LD ($D3F5),A
DC58 LD A,($D3F6) Increment *NumberOnScreenHelicopters by one.
DC5B INC A
DC5C LD ($D3F6),A
DC5F JP Handler_Helicopters_Next Jump to Handler_Helicopters_Next.
Handler_Helicopters_3 DC62 LD A,C Jump to Handler_Helicopters_4 if C is equal to FC.
DC63 CP $FC
DC65 JP Z,Handler_Helicopters_4
DC68 LD A,$01 Write 01 to *Flag_Orientation.
DC6A LD ($D247),A
DC6D LD A,D A=D.
DC6E AND %10000011 Keep only bits 0-1 and 7.
DC70 INC A Increment A by one.
DC71 CP $84 Jump to Handler_Helicopters_5 if A is not equal to 84.
DC73 JP NZ,Handler_Helicopters_5
DC76 LD A,$80 A=80.
DC78 DEC C Decrease C by one.
DC79 LD (IX+$01),C Write C to *IX+01.
DC7C JP Handler_Helicopters_5 Jump to Handler_Helicopters_5.
Handler_Helicopters_4 DC7F LD B,$02 B=02.
DC81 LD C,$FC C=FC.
DC83 JP Handler_Helicopters_1 Jump to Handler_Helicopters_1.
Handler_Helicopters_5 DC86 LD (IX+$00),A Write A to *IX+00.
DC89 AND %00000011 Keep only bits 0-1.
DC8B ADD A,A A+=A.
DC8C ADD A,$DE A+=DE.
DC8E CALL PrintSprite Call PrintSprite.
DC91 XOR A Write 00 to *Flag_Orientation.
DC92 LD ($D247),A
Handler_Helicopters_Next DC95 INC IX Move onto the next helicopter table data.
DC97 INC IX
DC99 INC IX
DC9B POP BC Restore helicopter ID from the stack.
DC9C DEC B Decrease helicopter ID by one.
DC9D JP NZ,Handler_Helicopters_Loop Jump to Handler_Helicopters_Loop until all helicopters have been processed.
DCA0 RET Return.
Prev: DBD9 Up: Map Next: DCA1