![]() |
Routines |
| Prev: 68B8 | Up: Map | Next: 696A |
|
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 | 6926 | 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.
|
||||||||
| 6927 | LD A,($66A5) | A=*Explosion_Counter. | ||||||
| 692A | DEC A | Decrease A by one. | ||||||
| 692B | XOR %11111111 | Flip bits 0-7. | ||||||
| 692D | AND %00111000 | Keep only bits 3-5. | ||||||
| 692F | SRA A | Shift the PAPER bits to the INK bits. | ||||||
| 6931 | SRA A | |||||||
| 6933 | SRA A | |||||||
| 6935 | ADD A,$40 | Set bit 6 (e.g. add 01000000) to set this attribute as BRIGHT. | ||||||
| 6937 | 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.
|
||||||||
| 6938 | LD A,IXl | A=the low byte of IX. | ||||||
| 693A | CP $02 | Jump to Handler_ShipExplosion_SetAttribute if A is equal to 02. | ||||||
| 693C | JR Z,Handler_ShipExplosion_SetAttribute | |||||||
| 693E | LD A,$40 | Set the attribute byte to: INK:BLACK, PAPER:BLACK (BRIGHT). | ||||||
| 6940 | JR Handler_ShipExplosion_Draw | Jump to Handler_ShipExplosion_Draw. | ||||||
| Handler_ShipExplosion_SetAttribute | 6942 | LD A,B | Load A with the attribute byte from B. | |||||
| Handler_ShipExplosion_Draw | 6943 | LD (HL),A | Write the attribute byte to *HL. | |||||
| 6944 | CALL ConvertAttributeToScreenBufferAddress | Call ConvertAttributeToScreenBufferAddress. | ||||||
| 6947 | PUSH HL | Stash the screen buffer address on the stack. | ||||||
|
Calculate the sprite data address for the current explosion frame. Each frame is 08 bytes long, so multiply the frame number by 08 and add it to the base address.
|
||||||||
| 6948 | LD A,($66A3) | HL=*Explosion_Frame. | ||||||
| 694B | LD H,$00 | |||||||
| 694D | LD L,A | |||||||
| 694E | ADD HL,HL | Multiply HL by 08. | ||||||
| 694F | ADD HL,HL | |||||||
| 6950 | ADD HL,HL | |||||||
| 6951 | LD DE,$61A3 | HL+=Graphics_ExplosionBits. | ||||||
| 6954 | ADD HL,DE | |||||||
| 6955 | EX DE,HL | Switch the result into DE (HL is discarded). | ||||||
| 6956 | POP HL | Restore the screen buffer address into HL from the stack. | ||||||
|
Advance to the next explosion frame. If the frame counter reaches 03 reset it to 00 to loop the animation.
|
||||||||
| 6957 | INC A | Increment the frame counter. | ||||||
| 6958 | CP $03 | Jump to Handler_ShipExplosion_SetFrame until the frame counter is 03. | ||||||
| 695A | JR NZ,Handler_ShipExplosion_SetFrame | |||||||
|
There is no frame 03 so reset the frame counter back to 00.
|
||||||||
| 695C | XOR A | Point to frame 00. | ||||||
| Handler_ShipExplosion_SetFrame | 695D | LD ($66A3),A | Write the frame number to *Explosion_Frame. | |||||
| 6960 | LD B,$08 | Set a line counter in B (08 lines in a UDG). | ||||||
| Handler_ShipExplosion_LineLoop | 6962 | LD A,(DE) | Copy the UDG data to the screen buffer. | |||||
| 6963 | LD (HL),A | |||||||
| 6964 | INC H | Move down one pixel line in the screen buffer. | ||||||
| 6965 | INC DE | Move to the next UDG graphic data byte. | ||||||
| 6966 | DJNZ Handler_ShipExplosion_LineLoop | Decrease the line counter by one and loop back to Handler_ShipExplosion_LineLoop until all 08 lines of the UDG character have been drawn. | ||||||
| 6968 | POP BC | Restore BC from the stack. | ||||||
| 6969 | RET | Return. | ||||||
| Prev: 68B8 | Up: Map | Next: 696A |