![]() |
Routines |
| Prev: 26808 | Up: Map | Next: 26986 |
|
Used by the routine at Handler_PlayerDeathGameOver.
Handles the ship explosion animation, including the flashing attribute effect and cycling through the explosion sprite frames.
|
||||||||
|
||||||||
| Handler_ShipExplosion | 26918 | PUSH BC | Stash BC on the stack. | |||||
|
Calculate a flashing attribute for the explosion. The PAPER colour from the flash counter is used as the INK colour to create a visual effect. The bits are manipulated to move PAPER bits 3-5 to INK positions 0-2, and bit 6 (BRIGHT) is set.
|
||||||||
| 26919 | LD A,(26277) | A=*Explosion_Counter. | ||||||
| 26922 | DEC A | Decrease A by one. | ||||||
| 26923 | XOR %11111111 | Flip bits 0-7. | ||||||
| 26925 | AND %00111000 | Keep only bits 3-5. | ||||||
| 26927 | SRA A | Shift the PAPER bits to the INK bits. | ||||||
| 26929 | SRA A | |||||||
| 26931 | SRA A | |||||||
| 26933 | ADD A,64 | Set bit 6 (e.g. add 01000000) to set this attribute as BRIGHT. | ||||||
| 26935 | LD B,A | Store the result in B. | ||||||
|
Check if this is the second frame of the explosion animation to decide whether to use the calculated flashing attribute or a plain one.
|
||||||||
| 26936 | LD A,IXl | A=the low byte of IX. | ||||||
| 26938 | CP 2 | Jump to Handler_ShipExplosion_SetAttribute if A is equal to 2. | ||||||
| 26940 | JR Z,Handler_ShipExplosion_SetAttribute | |||||||
| 26942 | LD A,64 | Set the attribute byte to: INK:BLACK, PAPER:BLACK (BRIGHT). | ||||||
| 26944 | JR Handler_ShipExplosion_Draw | Jump to Handler_ShipExplosion_Draw. | ||||||
| Handler_ShipExplosion_SetAttribute | 26946 | LD A,B | Load A with the attribute byte from B. | |||||
| Handler_ShipExplosion_Draw | 26947 | LD (HL),A | Write the attribute byte to *HL. | |||||
| 26948 | CALL ConvertAttributeToScreenBufferAddress | Call ConvertAttributeToScreenBufferAddress. | ||||||
| 26951 | PUSH HL | Stash the screen buffer address on the stack. | ||||||
|
Calculate the sprite data address for the current explosion frame. Each frame is 8 bytes long, so multiply the frame number by 8 and add it to the base address.
|
||||||||
| 26952 | LD A,(26275) | HL=*Explosion_Frame. | ||||||
| 26955 | LD H,0 | |||||||
| 26957 | LD L,A | |||||||
| 26958 | ADD HL,HL | Multiply HL by 8. | ||||||
| 26959 | ADD HL,HL | |||||||
| 26960 | ADD HL,HL | |||||||
| 26961 | LD DE,24995 | HL+=Graphics_ExplosionBits. | ||||||
| 26964 | ADD HL,DE | |||||||
| 26965 | EX DE,HL | Switch the result into DE (HL is discarded). | ||||||
| 26966 | POP HL | Restore the screen buffer address into HL from the stack. | ||||||
|
Advance to the next explosion frame. If the frame counter reaches 3 reset it to 0 to loop the animation.
|
||||||||
| 26967 | INC A | Increment the frame counter. | ||||||
| 26968 | CP 3 | Jump to Handler_ShipExplosion_SetFrame until the frame counter is 3. | ||||||
| 26970 | JR NZ,Handler_ShipExplosion_SetFrame | |||||||
|
There is no frame 3 so reset the frame counter back to 0.
|
||||||||
| 26972 | XOR A | Point to frame 0. | ||||||
| Handler_ShipExplosion_SetFrame | 26973 | LD (26275),A | Write the frame number to *Explosion_Frame. | |||||
| 26976 | LD B,8 | Set a line counter in B (8 lines in a UDG). | ||||||
| Handler_ShipExplosion_LineLoop | 26978 | LD A,(DE) | Copy the UDG data to the screen buffer. | |||||
| 26979 | LD (HL),A | |||||||
| 26980 | INC H | Move down one pixel line in the screen buffer. | ||||||
| 26981 | INC DE | Move to the next UDG graphic data byte. | ||||||
| 26982 | DJNZ Handler_ShipExplosion_LineLoop | Decrease the line counter by one and loop back to Handler_ShipExplosion_LineLoop until all 8 lines of the UDG character have been drawn. | ||||||
| 26984 | POP BC | Restore BC from the stack. | ||||||
| 26985 | RET | Return. | ||||||
| Prev: 26808 | Up: Map | Next: 26986 |