Prev: 46044 Up: Map Next: 46176
46056: Handler: Jetman Death
Flash the dying actor from the frame timer, then convert the slot to type 133.
Input
IX Actor slot
Flash the dying actor from the frame timer.
Handler_JetmanDeath 46056 LD A,(24130) Fetch GameTimer.
46059 CPL Invert the bits.
46060 AND %00000001 Keep only bit 0.
46062 JR Z,Handler_JetmanDeath_TripleTimer Jump to Handler_JetmanDeath_TripleTimer if this is an odd frame.
46064 DEC (IX+8) Jump to Handler_JetmanDeath_NoLives if the death timer is now zero.
46067 JR Z,Handler_JetmanDeath_NoLives
Pick a death-frame triplet and apply its X/Y offsets.
Handler_JetmanDeath_TripleTimer 46069 LD A,(IX+8) Fetch the death timer.
46072 LD C,A Stash it in C.
46073 ADD A,A Double it.
46074 ADD A,C Add the original.
46075 LD L,A Create an offset in HL.
46076 LD H,0
46078 LD BC,46161 Point HL at that triplet, offset from Handler_JetmanDeath_Offsets.
46081 ADD HL,BC
Fetch the frame byte and write it as the actor type.
46082 EX DE,HL Switch the table pointer into DE.
46083 LD A,(DE) Copy the next table byte.
46084 INC DE
Sprite IDs begin at 224 ("Explosion: Frame 1").
46085 ADD A,224 Add 224 for the dying frames.
46087 LD (IX+0),A Write it to the actor type.
Offset the actor world X by the table value.
46090 LD L,(IX+2) Fetch the actor world X.
46093 LD H,(IX+3) Fetch the high byte.
46096 PUSH HL Stash the world X on the stack.
Fetch the X offset and sign-extend it.
46097 LD A,(DE) Copy the next table byte.
46098 INC DE
46099 LD C,A Copy the X offset into C.
46100 LD B,0 Clear B.
46102 AND A Jump to Handler_JetmanDeath_WriteX if the offset is positive.
46103 JP P,Handler_JetmanDeath_WriteX
46106 DEC B Sign-extend into B.
Handler_JetmanDeath_WriteX 46107 CALL MaskWorldX Call MaskWorldX.
46110 LD (IX+2),L Write the low byte as the actor world X.
46113 LD (IX+3),H Write the high byte.
Offset the actor Y by the table value.
46116 LD A,(IX+4) Fetch the actor Y.
46119 PUSH AF Stash it on the stack.
46120 LD A,(DE) Fetch the Y offset.
46121 ADD A,(IX+4) Add the actor Y.
46124 LD (IX+4),A Write it back.
Draw the dying frame, then restore the stored position.
46127 CALL DrawActorSprite Call DrawActorSprite.
46130 CALL ColouriseSprite Call ColouriseSprite.
46133 POP AF Restore the actor Y from the stack.
46134 LD (IX+4),A Write it back.
46137 POP HL Restore the world X from the stack.
46138 LD (IX+2),L Write the low byte back.
46141 LD (IX+3),H Write the high byte back.
46144 RET Return.
Clear the lives count and become type 133.
Handler_JetmanDeath_NoLives 46145 CALL ClearSpriteScratch Call ClearSpriteScratch.
46148 XOR A Write 0 to ActivePlayer_Lives.
46149 LD (24225),A
46152 LD (IX+0),133 Write 133 to the actor type.
46156 LD (IX+5),64 Write 64 to the actor speed.
46160 RET Return.
Handler_JetmanDeath_Offsets 46161 DEFB 0,0,0,0,24,252,1,16 Death-frame offsets.
46169 DEFB 250,2,8,254,3,0,0
Prev: 46044 Up: Map Next: 46176