Prev: 64FA Up: Map Next: 6682
65F7: Animate Explosion
Input
IX Explosion animation object
AnimateExplosion 65F7 LD HL,$5E16 HL=CurrentBug_ID.
65FA INC (HL) Increment CurrentBug_ID by one.
65FB LD C,(IX+$04) C=explosion animation frame.
65FE LD B,(IX+$05) B=explosion animation state.
6601 LD A,($5E17) A=GameTimer.
6604 AND B Increment frame if timer & state are both zero.
6605 JR NZ,ExplosionFetchSpriteFrame
6607 INC (IX+$04)
ExplosionFetchSpriteFrame 660A LD A,C A=current explosion animation frame.
660B SLA C Create an offset using the animation frame ID.
660D LD B,$00
660F LD HL,$6682 HL=ExplosionLookupTable.
6612 ADD HL,BC HL=HL + offset.
6613 LD E,(HL) DE=fetch sprite frame address from HL.
6614 INC HL
6615 LD D,(HL)
6616 LD L,(IX+$01) HL=X/Y co-ordinates of the exploding actor.
6619 LD H,(IX+$02)
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're halfway done.
6622 JR NC,AnimateExplosion_2
6624 CALL $751C Call 751C.
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 Update with a random colour
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) Update anim object so "animating" = "direction".
6637 LD (IX+$00),A
663A CALL StoreEntity Call StoreEntity.
663D CALL $7526 Call 7526.
6640 LD (IX+$00),$00
6644 LD A,(IX+$06)
6647 AND %00111111 Keep only bits 0-5.
6649 CP $03
664B RET NC
664C CP $02
664E JP NZ,PlayerTurnEnds
6651 LD HL,$5E23 HL=5E23.
6654 LD BC,$5E2D BC=5E2D.
6657 LD A,($5E19) A=RandomNumber.
665A AND %00000111 Keep only bits 0-2.
665C LD E,A
665D LD D,$00
665F ADD HL,DE
AnimateExplosion_0 6660 LD A,(HL)
6661 AND A
6662 JR Z,AnimateExplosion_1
6664 INC HL
6665 PUSH HL
6666 AND A
6667 SBC HL,BC
6669 POP HL
666A JR NZ,AnimateExplosion_0
666C LD HL,$5E23 HL=5E23.
666F JR AnimateExplosion_0 Jump to AnimateExplosion_0.
AnimateExplosion_1 6671 LD A,($5E77) A=5E77.
6674 AND %00000111 Keep only bits 0-2.
6676 OR %00001000 Set bit 3.
6678 LD (HL),A Stash the result at the address held by HL.
6679 JP PlayerTurnEnds Jump to PlayerTurnEnds.
AnimateExplosion_2 667C CALL $74AB Call 74AB.
667F JP $7529 Jump to 7529.
Prev: 64FA Up: Map Next: 6682