Routines |
Prev: 56281 | Up: Map | Next: 56481 |
Used by the routine at RunHandlers.
|
||||
Handler_Helicopters | 56293 | LD B,6 | B=6 (maximum possible number of on-screen helicopters). | |
56295 | LD IX,53909 | IX=Table_Helicopters. | ||
56299 | XOR A | Write 0 to *Flag_Orientation. | ||
56300 | LD (53831),A | |||
Handler_Helicopters_Loop | 56303 | PUSH BC | Stash current helicopter on the stack. | |
56304 | LD A,(IX+0) | Jump to Handler_Helicopters_Next if this helicopter is not active. | ||
56307 | LD D,A | |||
56308 | AND A | |||
56309 | JP Z,Handler_Helicopters_Next | |||
56312 | LD C,(IX+1) | C=*IX+1. | ||
56315 | LD B,(IX+2) | B=*IX+2. | ||
56318 | RLCA | Rotate A left one position, setting the carry flag if bit 7 was set. | ||
56319 | JR C,Handler_Helicopters_3 | Jump to Handler_Helicopters_3 if the carry flag is set. | ||
56321 | LD A,C | Jump to Handler_Helicopters_0 if C is equal to 33. | ||
56322 | CP 33 | |||
56324 | JR Z,Handler_Helicopters_0 | |||
56326 | LD A,D | A=D. | ||
56327 | AND %01000011 | Keep only bits 0-1 and 6. | ||
56329 | INC A | Increment A by one. | ||
56330 | CP 68 | Jump to Handler_Helicopters_5 until A is equal to 68. | ||
56332 | JP NZ,Handler_Helicopters_5 | |||
56335 | LD A,64 | A=64. | ||
56337 | INC C | Increment C by one. | ||
56338 | LD (IX+1),C | Write C to *IX+1. | ||
56341 | JP Handler_Helicopters_5 | Jump to Handler_Helicopters_5. | ||
Handler_Helicopters_0 | 56344 | LD B,4 | B=4. | |
56346 | LD C,32 | C=32. | ||
Handler_Helicopters_1 | 56348 | LD A,(54262) | Jump to Handler_Helicopters_2 if *NumberOnScreenHelicopters is equal to 6. | |
56351 | CP 6 | |||
56353 | JR Z,Handler_Helicopters_2 | |||
Loop to find an empty slot.
|
||||
56355 | LD HL,53923 | HL=53923 (Table_SomethingHelicopters-4). | ||
Handler_Helicopters_FindSlot | 56358 | INC HL | Increment HL by four. | |
56359 | INC HL | |||
56360 | INC HL | |||
56361 | INC HL | |||
56362 | LD A,(HL) | Jump to Handler_Helicopters_FindSlot if *HL is not zero. | ||
56363 | AND A | |||
56364 | JR NZ,Handler_Helicopters_FindSlot | |||
56366 | LD (HL),B | Write B to *HL. | ||
56367 | INC HL | Increment HL by one. | ||
56368 | LD (HL),C | Write C to *HL. | ||
56369 | INC HL | Increment HL by one. | ||
56370 | CALL RandomNumber | Get a random number between 0-31. | ||
56373 | AND %00011111 | |||
56375 | ADD A,8 | A+=8. | ||
56377 | AND %00011111 | Keep only bits 0-4. | ||
56379 | LD (HL),A | Write A to *HL. | ||
56380 | INC HL | Increment HL by one. | ||
56381 | LD A,(IX+2) | A=*IX+2. | ||
56384 | DEC A | Decrease A by one. | ||
56385 | RLCA | RLCA. | ||
56386 | RLCA | |||
56387 | ADD A,4 | A+=4. | ||
56389 | LD (HL),A | Write A to *HL. | ||
56390 | CALL RandomNumber | Get a random number between 0-3. | ||
56393 | AND %00000011 | |||
56395 | ADD A,(HL) | A+=*HL. | ||
56396 | LD (HL),A | Write A to *HL. | ||
Handler_Helicopters_2 | 56397 | LD (IX+0),0 | Write 0 to *IX+0. | |
56401 | LD A,(54261) | Decrease *NumberActiveHelicopters by one. | ||
56404 | DEC A | |||
56405 | LD (54261),A | |||
56408 | LD A,(54262) | Increment *NumberOnScreenHelicopters by one. | ||
56411 | INC A | |||
56412 | LD (54262),A | |||
56415 | JP Handler_Helicopters_Next | Jump to Handler_Helicopters_Next. | ||
Handler_Helicopters_3 | 56418 | LD A,C | Jump to Handler_Helicopters_4 if C is equal to 252. | |
56419 | CP 252 | |||
56421 | JP Z,Handler_Helicopters_4 | |||
56424 | LD A,1 | Write 1 to *Flag_Orientation. | ||
56426 | LD (53831),A | |||
56429 | LD A,D | A=D. | ||
56430 | AND %10000011 | Keep only bits 0-1 and 7. | ||
56432 | INC A | Increment A by one. | ||
56433 | CP 132 | Jump to Handler_Helicopters_5 if A is not equal to 132. | ||
56435 | JP NZ,Handler_Helicopters_5 | |||
56438 | LD A,128 | A=128. | ||
56440 | DEC C | Decrease C by one. | ||
56441 | LD (IX+1),C | Write C to *IX+1. | ||
56444 | JP Handler_Helicopters_5 | Jump to Handler_Helicopters_5. | ||
Handler_Helicopters_4 | 56447 | LD B,2 | B=2. | |
56449 | LD C,252 | C=252. | ||
56451 | JP Handler_Helicopters_1 | Jump to Handler_Helicopters_1. | ||
Handler_Helicopters_5 | 56454 | LD (IX+0),A | Write A to *IX+0. | |
56457 | AND %00000011 | Keep only bits 0-1. | ||
56459 | ADD A,A | A+=A. | ||
56460 | ADD A,222 | A+=222. | ||
56462 | CALL PrintSprite | Call PrintSprite. | ||
56465 | XOR A | Write 0 to *Flag_Orientation. | ||
56466 | LD (53831),A | |||
Handler_Helicopters_Next | 56469 | INC IX | Move onto the next helicopter table data. | |
56471 | INC IX | |||
56473 | INC IX | |||
56475 | POP BC | Restore helicopter ID from the stack. | ||
56476 | DEC B | Decrease helicopter ID by one. | ||
56477 | JP NZ,Handler_Helicopters_Loop | Jump to Handler_Helicopters_Loop until all helicopters have been processed. | ||
56480 | RET | Return. |
Prev: 56281 | Up: Map | Next: 56481 |