![]() |
Routines |
| Prev: 65F1 | Up: Map | Next: 6682 |
|
Animates an explosion through three frames of a growing explosion (drawn in random colours) and then three frames to erase it again. At the end of the animation the object is restored to its old state (kept in IX+06), then:
|
||||||||
| AnimateExplosion | 65F7 | LD HL,$5E16 | HL=CurrentBug_ID. | |||||
| 65FA | INC (HL) | Increment the bug counter by one. | ||||||
| 65FB | LD C,(IX+$04) | C=the animation frame from IX+04. | ||||||
| 65FE | LD B,(IX+$05) | B=the animation speed mask from IX+05. | ||||||
| 6601 | LD A,($5E17) | A=the game timer from GameTimer. | ||||||
| 6604 | AND B | Keep only the bits set in the speed mask. | ||||||
| 6605 | JR NZ,ExplosionFetchSpriteFrame | Jump to ExplosionFetchSpriteFrame if the result is not zero. | ||||||
| 6607 | INC (IX+$04) | Increment the animation frame by one. | ||||||
| ExplosionFetchSpriteFrame | 660A | LD A,C | A=the current explosion animation frame. | |||||
| 660B | SLA C | Double the frame to make an offset into the table. | ||||||
| 660D | LD B,$00 | Clear the high byte of the offset in B. | ||||||
| 660F | LD HL,$6682 | HL=ExplosionLookupTable (the table of explosion sprites). | ||||||
| 6612 | ADD HL,BC | Add the offset to find the sprite for the frame. | ||||||
| 6613 | LD E,(HL) | DE=the sprite address for the frame from the table. | ||||||
| 6614 | INC HL | |||||||
| 6615 | LD D,(HL) | |||||||
| 6616 | LD L,(IX+$01) | L=the X position of the explosion. | ||||||
| 6619 | LD H,(IX+$02) | H=the Y position of the explosion. | ||||||
| 661C | CP $06 | If the current frame >= 06 then the animation has finished. | ||||||
| 661E | JR NC,AnimateExplosion_End | |||||||
| 6620 | CP $03 | If the current frame >= 03 then we are erasing it. | ||||||
| 6622 | JR NC,AnimateExplosion_Erase | |||||||
| 6624 | CALL DrawSprite | Call DrawSprite. | ||||||
| 6627 | LD A,($5E19) | A=RandomNumber. | ||||||
| 662A | AND %00000111 | Keep only bits 0-2. | ||||||
| 662C | OR %01000010 | Set bits 1 and 6 (BRIGHT). | ||||||
| 662E | LD (IX+$03),A | Write the random colour to IX+03 (the colour of the explosion). | ||||||
| 6631 | JP ColouriseSprite | Jump to ColouriseSprite. | ||||||
|
After an explosion, we check if it was the player that died!
|
||||||||
| AnimateExplosion_End | 6634 | LD A,(IX+$06) | Restore the old state of the object from IX+06. | |||||
| 6637 | LD (IX+$00),A | |||||||
| 663A | CALL StoreEntity | Call StoreEntity. | ||||||
| 663D | CALL RemoveEntity | Call RemoveEntity. | ||||||
| 6640 | LD (IX+$00),$00 | Write 00 to IX+00 (make the object inactive). | ||||||
| 6644 | LD A,(IX+$06) | A=the old state. | ||||||
| 6647 | AND %00111111 | Keep only bits 0-5. | ||||||
| 6649 | CP $03 | Return if it was not Robbie (A >= 03). | ||||||
| 664B | RET NC | |||||||
| 664C | CP $02 | Jump to PlayerTurnEnds if Robbie was not carrying a can (the type is not 02). | ||||||
| 664E | JP NZ,PlayerTurnEnds | |||||||
|
Robbie was carrying a can, so put it back in an empty cubby hole. A random hole is tried first, and then the following holes until an empty one is found.
|
||||||||
| 6651 | LD HL,$5E23 | HL=CubbyHoles (the first cubby hole). | ||||||
| 6654 | LD BC,$5E2D | BC=InactivePlayer_CubbyHoles (the end of the cubby holes). | ||||||
| 6657 | LD A,($5E19) | A=RandomNumber. | ||||||
| 665A | AND %00000111 | Keep only bits 0-2. | ||||||
| 665C | LD E,A | E=the random offset. | ||||||
| 665D | LD D,$00 | Clear the high byte of the offset in D. | ||||||
| 665F | ADD HL,DE | Add the random offset to HL. | ||||||
| ExplosionCubbyHole_Loop | 6660 | LD A,(HL) | A=the cubby hole. | |||||
| 6661 | AND A | Jump to ExplosionCubbyHole_Found if the hole is empty. | ||||||
| 6662 | JR Z,ExplosionCubbyHole_Found | |||||||
| 6664 | INC HL | Move on to the next hole. | ||||||
| 6665 | PUSH HL | Stash HL on the stack. | ||||||
| 6666 | AND A | Compare HL with the end of the cubby holes. | ||||||
| 6667 | SBC HL,BC | |||||||
| 6669 | POP HL | Restore HL from the stack. | ||||||
| 666A | JR NZ,ExplosionCubbyHole_Loop | Jump back to ExplosionCubbyHole_Loop if the end has not been reached. | ||||||
| 666C | LD HL,$5E23 | HL=CubbyHoles (wrap round to the first hole). | ||||||
| 666F | JR ExplosionCubbyHole_Loop | Jump to ExplosionCubbyHole_Loop. | ||||||
| ExplosionCubbyHole_Found | 6671 | LD A,($5E77) | A=the colour of the spray can from 5E77. | |||||
| 6674 | AND %00000111 | Keep only bits 0-2. | ||||||
| 6676 | OR %00001000 | Set bit 3 (the type of the item is a spray can). | ||||||
| 6678 | LD (HL),A | Write the item to the cubby hole. | ||||||
| 6679 | JP PlayerTurnEnds | Jump to PlayerTurnEnds. | ||||||
|
Erase the explosion.
|
||||||||
| AnimateExplosion_Erase | 667C | CALL SetUpPreviousSprite_Offset | Call SetUpPreviousSprite_Offset. | |||||
| 667F | JP RemoveEntity_ClearNew | Jump to RemoveEntity_ClearNew. | ||||||
| Prev: 65F1 | Up: Map | Next: 6682 |