![]() |
Routines |
| Prev: 26986 | Up: Map | Next: 27441 |
|
Used by the routine at Handler_AliensMovement_Spawning.
Renders and animates the mothership plasma thing, the rotating strip, the mothership alien and handles the bullets.
|
|||||||||||||||||||||||||||||||||||||||
|
Prints the top part of the alien mothership:
Which looks like this when animated:
|
|||||||||||||||||||||||||||||||||||||||
| Handler_Mothership | 27171 | LD DE,16591 | DE=16591 (left-hand UDG screen buffer target). | ||||||||||||||||||||||||||||||||||||
| 27174 | PUSH DE | Stash this destination address on the stack. | |||||||||||||||||||||||||||||||||||||
| 27175 | LD HL,25921 | HL=Table_Mothership_Animation (UDG graphics). | |||||||||||||||||||||||||||||||||||||
| 27178 | LD BC,562 | Configure the text routine to print the two UDG characters in INK:RED, PAPER:YELLOW. | |||||||||||||||||||||||||||||||||||||
| 27181 | CALL CustomFont_PrintString | Call CustomFont_PrintString. | |||||||||||||||||||||||||||||||||||||
| 27184 | POP HL | Restore the original screen pointer from the stack. | |||||||||||||||||||||||||||||||||||||
|
Apply a rippling graphic effect between the UDG tiles to imply charging plasma energy (timed from MothershipAnimationCounter).
|
|||||||||||||||||||||||||||||||||||||||
| 27185 | LD A,(26324) | A=*MothershipAnimationCounter (current ripple phase). | |||||||||||||||||||||||||||||||||||||
| 27188 | PUSH AF | Stash the animation counter on the stack. | |||||||||||||||||||||||||||||||||||||
| 27189 | SRA A | Shift A right (with carry). | |||||||||||||||||||||||||||||||||||||
| 27191 | AND %00000111 | Keep only bits 0-2. | |||||||||||||||||||||||||||||||||||||
| 27193 | XOR %00000111 | Flip bits 0-2. | |||||||||||||||||||||||||||||||||||||
| 27195 | ADD A,H | Add the result to H. | |||||||||||||||||||||||||||||||||||||
| 27196 | LD H,A | ||||||||||||||||||||||||||||||||||||||
|
Draw the "line" between the two ... masts (?) obviously it's hard to tell exactly what this is supposed to represent - but I've always thought it's a tesla coil type thing.
|
|||||||||||||||||||||||||||||||||||||||
| 27197 | LD (HL),%00000011 | Write 3 to draw two pixels on the left-hand UDG. | |||||||||||||||||||||||||||||||||||||
| 27199 | INC HL | Move to the next position. | |||||||||||||||||||||||||||||||||||||
| 27200 | LD (HL),%11000000 | Write 192 to draw two pixels on the right-hand UDG to complete the line. | |||||||||||||||||||||||||||||||||||||
| 27202 | POP AF | Restore the animation counter from the stack. | |||||||||||||||||||||||||||||||||||||
|
Decide whether to scroll the middle (blue) strip. This only happens when the lowest two counter bits are zero so the conveyor effect moves slowly.
|
|||||||||||||||||||||||||||||||||||||||
| 27203 | AND %00000011 | Keep only bits 0-1. | |||||||||||||||||||||||||||||||||||||
| 27205 | JR NZ,Handler_Mothership_UpdateCounter | Jump to Handler_Mothership_UpdateCounter if the bits aren’t both zero (skip scrolling). | |||||||||||||||||||||||||||||||||||||
|
Scroll the middle (blue) strip right by one character line to keep the mothership interior "machinery" moving.
Which looks like this when animated:
|
|||||||||||||||||||||||||||||||||||||||
| 27207 | LD HL,18487 | HL=18487 (upper source row). | |||||||||||||||||||||||||||||||||||||
| 27210 | LD DE,18488 | DE=18488 (destination one line below). | |||||||||||||||||||||||||||||||||||||
| 27213 | LD B,8 | Set a line counter in B (8 lines in a UDG). | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_ScrollLoop | 27215 | PUSH BC | Stash the line counter on the stack. | ||||||||||||||||||||||||||||||||||||
| 27216 | LD A,(DE) | A=*DE. | |||||||||||||||||||||||||||||||||||||
| 27217 | PUSH HL | Stash HL and DE on the stack. | |||||||||||||||||||||||||||||||||||||
| 27218 | PUSH DE | ||||||||||||||||||||||||||||||||||||||
| 27219 | LD BC,17 | Copy 0017 bytes right-to-left (scroll left by one character). | |||||||||||||||||||||||||||||||||||||
| 27222 | LDDR | ||||||||||||||||||||||||||||||||||||||
| 27224 | LD (DE),A | Write A to *DE. | |||||||||||||||||||||||||||||||||||||
| 27225 | POP DE | Restore DE and HL from the stack. | |||||||||||||||||||||||||||||||||||||
| 27226 | POP HL | ||||||||||||||||||||||||||||||||||||||
| 27227 | INC H | Increment H by one. | |||||||||||||||||||||||||||||||||||||
| 27228 | INC D | Increment D by one. | |||||||||||||||||||||||||||||||||||||
| 27229 | POP BC | Restore the line counter from the stack. | |||||||||||||||||||||||||||||||||||||
| 27230 | DJNZ Handler_Mothership_ScrollLoop | Decrease the line counter by one and loop back to Handler_Mothership_ScrollLoop until the counter is zero. | |||||||||||||||||||||||||||||||||||||
|
Finish the scroll by copying the bottom line back to the top so the conveyor appears continuous.
|
|||||||||||||||||||||||||||||||||||||||
| 27232 | LD D,89 | D=89. | |||||||||||||||||||||||||||||||||||||
| 27234 | LD H,D | H=D. | |||||||||||||||||||||||||||||||||||||
| 27235 | LD C,17 | C=17. | |||||||||||||||||||||||||||||||||||||
| 27237 | LD A,(DE) | A=*DE. | |||||||||||||||||||||||||||||||||||||
| 27238 | LDDR | LDDR. | |||||||||||||||||||||||||||||||||||||
| 27240 | LD (DE),A | Write A to *DE. | |||||||||||||||||||||||||||||||||||||
|
Update mothership animation state.
|
|||||||||||||||||||||||||||||||||||||||
| Handler_Mothership_UpdateCounter | 27241 | LD HL,26324 | HL=MothershipAnimationCounter. | ||||||||||||||||||||||||||||||||||||
| 27244 | LD A,(HL) | Fetch the animation counter. | |||||||||||||||||||||||||||||||||||||
| 27245 | INC (HL) | Increment *MothershipAnimationCounter by one. | |||||||||||||||||||||||||||||||||||||
|
Display the mothership alien.
|
|||||||||||||||||||||||||||||||||||||||
| 27246 | AND %00001111 | Only animate the mothership alien every 16th frame (when bits 0-3 are all zero); otherwise skip to bullet processing (Handler_Mothership_ProcessBullets). | |||||||||||||||||||||||||||||||||||||
| 27248 | JR NZ,Handler_Mothership_ProcessBullets | ||||||||||||||||||||||||||||||||||||||
|
Select one of the two alien frames (2×2 sprite) based on bit 4 of the counter and draw it to the screen.
|
|||||||||||||||||||||||||||||||||||||||
| 27250 | BIT 4,(HL) | Test bit 4 of the animation counter to choose the frame. | |||||||||||||||||||||||||||||||||||||
|
Default to:
|
|||||||||||||||||||||||||||||||||||||||
| 27252 | LD HL,24532 | HL=Graphics_MothershipAlien_01. | |||||||||||||||||||||||||||||||||||||
| 27255 | JR Z,Handler_Mothership_DrawAlien | Jump to Handler_Mothership_DrawAlien if bit 4 is clear. | |||||||||||||||||||||||||||||||||||||
|
Else use:
|
|||||||||||||||||||||||||||||||||||||||
| 27257 | LD HL,24564 | HL=Graphics_MothershipAlien_02. | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_DrawAlien | 27260 | LD DE,16623 | DE=16623 (top-left screen cell for the alien). | ||||||||||||||||||||||||||||||||||||
| 27263 | LD B,2 | Set a counter in B for 2 rows. | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_RowLoop | 27265 | PUSH BC | Stash the row counter on the stack. | ||||||||||||||||||||||||||||||||||||
| 27266 | LD B,2 | Set a counter in B for 2 columns. | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_ColumnLoop | 27268 | PUSH BC | Stash the column counter and screen buffer pointer on the stack. | ||||||||||||||||||||||||||||||||||||
| 27269 | PUSH DE | ||||||||||||||||||||||||||||||||||||||
| 27270 | LD B,8 | Set a line counter in B (8 lines in a UDG). | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_LineLoop | 27272 | LD A,(HL) | Copy the UDG data to the screen buffer. | ||||||||||||||||||||||||||||||||||||
| 27273 | LD (DE),A | ||||||||||||||||||||||||||||||||||||||
| 27274 | INC D | Move down one pixel line in the screen buffer. | |||||||||||||||||||||||||||||||||||||
| 27275 | INC HL | Move to the next UDG graphic data byte. | |||||||||||||||||||||||||||||||||||||
| 27276 | DJNZ Handler_Mothership_LineLoop | Decrease the line counter by one and loop back to Handler_Mothership_LineLoop until all 8 lines of the UDG character have been drawn. | |||||||||||||||||||||||||||||||||||||
| 27278 | POP DE | Restore the original screen buffer pointer from the stack. | |||||||||||||||||||||||||||||||||||||
| 27279 | INC DE | Move right one character block. | |||||||||||||||||||||||||||||||||||||
| 27280 | POP BC | Restore the column counter from the stack. | |||||||||||||||||||||||||||||||||||||
| 27281 | DJNZ Handler_Mothership_ColumnLoop | Decrease the column counter by one and loop back to Handler_Mothership_ColumnLoop until both UDGs have been drawn in this row. | |||||||||||||||||||||||||||||||||||||
| 27283 | LD DE,18447 | DE=18447 (screen buffer location). | |||||||||||||||||||||||||||||||||||||
| 27286 | POP BC | Restore the row counter from the stack. | |||||||||||||||||||||||||||||||||||||
| 27287 | DJNZ Handler_Mothership_RowLoop | Decrease the row counter by one and loop back to Handler_Mothership_RowLoop until both rows have finished being drawn and the alien is complete. | |||||||||||||||||||||||||||||||||||||
|
Handle the two mothership bullets (fire only when the player bullet limiter Bullet_RateLimiter is zero).
|
|||||||||||||||||||||||||||||||||||||||
| Handler_Mothership_ProcessBullets | 27289 | LD A,(26261) | Return if *Bullet_RateLimiter is not zero. | ||||||||||||||||||||||||||||||||||||
| 27292 | OR A | ||||||||||||||||||||||||||||||||||||||
| 27293 | RET NZ | ||||||||||||||||||||||||||||||||||||||
| 27294 | LD HL,3 | HL=0003. | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_BulletLoop | 27297 | PUSH HL | Stash HL on the stack. | ||||||||||||||||||||||||||||||||||||
| 27298 | PUSH HL | IX=HL (using the stack). | |||||||||||||||||||||||||||||||||||||
| 27299 | POP IX | ||||||||||||||||||||||||||||||||||||||
| 27301 | LD BC,26298 | Multiply HL by 2 and add 26298. | |||||||||||||||||||||||||||||||||||||
| 27304 | ADD HL,HL | ||||||||||||||||||||||||||||||||||||||
| 27305 | ADD HL,BC | ||||||||||||||||||||||||||||||||||||||
| 27306 | PUSH HL | Stash HL on the stack. | |||||||||||||||||||||||||||||||||||||
| 27307 | LD E,(HL) | E=*HL. | |||||||||||||||||||||||||||||||||||||
| 27308 | INC HL | Increment HL by one. | |||||||||||||||||||||||||||||||||||||
| 27309 | LD D,(HL) | D=*HL. | |||||||||||||||||||||||||||||||||||||
| 27310 | LD A,D | A=D. | |||||||||||||||||||||||||||||||||||||
| 27311 | EX DE,HL | Exchange the DE and HL registers. | |||||||||||||||||||||||||||||||||||||
| 27312 | OR A | Jump to Handler_Mothership_BulletActive if the bullet slot is active. | |||||||||||||||||||||||||||||||||||||
| 27313 | JR NZ,Handler_Mothership_BulletActive | ||||||||||||||||||||||||||||||||||||||
| 27315 | CALL GenerateRandomNumber | Call GenerateRandomNumber. | |||||||||||||||||||||||||||||||||||||
| 27318 | AND %00001111 | Keep only bits 0-3. | |||||||||||||||||||||||||||||||||||||
| 27320 | OR A | Jump to Handler_Mothership_0 if A is not zero. | |||||||||||||||||||||||||||||||||||||
| 27321 | JR NZ,Handler_Mothership_0 | ||||||||||||||||||||||||||||||||||||||
| 27323 | LD HL,22863 | HL=22863 (attribute buffer location). | |||||||||||||||||||||||||||||||||||||
| 27326 | JR Mothership_Bullet_Collision | Jump to Mothership_Bullet_Collision. | |||||||||||||||||||||||||||||||||||||
|
Only fire if the random nibble equals 3 otherwise skip the slot.
|
|||||||||||||||||||||||||||||||||||||||
| Handler_Mothership_0 | 27328 | CP 3 | Jump to Handler_Mothership_SaveBulletPosition if A is not equal to 3. | ||||||||||||||||||||||||||||||||||||
| 27330 | JR NZ,Handler_Mothership_SaveBulletPosition | ||||||||||||||||||||||||||||||||||||||
| 27332 | LD HL,22864 | HL=22864 (attribute buffer location). | |||||||||||||||||||||||||||||||||||||
| 27335 | JR Mothership_Bullet_Collision | Jump to Mothership_Bullet_Collision. | |||||||||||||||||||||||||||||||||||||
|
Update an active bullet by erasing its old sprite and moving it down.
|
|||||||||||||||||||||||||||||||||||||||
| Handler_Mothership_BulletActive | 27337 | LD A,(HL) | A=*HL. | ||||||||||||||||||||||||||||||||||||
| 27338 | AND %01000111 | Keep only bits 0-2, 6. | |||||||||||||||||||||||||||||||||||||
| 27340 | CP 6 | Jump to Handler_Mothership_2 if A is not equal to 6. | |||||||||||||||||||||||||||||||||||||
| 27342 | JR NZ,Handler_Mothership_2 | ||||||||||||||||||||||||||||||||||||||
| 27344 | LD A,(HL) | A=*HL. | |||||||||||||||||||||||||||||||||||||
| 27345 | AND %11111000 | Keep only bits 3-7. | |||||||||||||||||||||||||||||||||||||
| 27347 | LD (HL),A | Write A to *HL. | |||||||||||||||||||||||||||||||||||||
| 27348 | PUSH HL | Stash HL on the stack. | |||||||||||||||||||||||||||||||||||||
| 27349 | CALL ConvertAttributeToScreenBufferAddress | Call ConvertAttributeToScreenBufferAddress. | |||||||||||||||||||||||||||||||||||||
| 27352 | LD B,8 | B=8. | |||||||||||||||||||||||||||||||||||||
| 27354 | XOR A | Write 0 to *HL. | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_1 | 27355 | LD (HL),A | |||||||||||||||||||||||||||||||||||||
| 27356 | INC H | Increment H by one. | |||||||||||||||||||||||||||||||||||||
| 27357 | DJNZ Handler_Mothership_1 | Decrease counter by one and loop back to Handler_Mothership_1 until counter is zero. | |||||||||||||||||||||||||||||||||||||
| 27359 | POP HL | Restore HL from the stack. | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_2 | 27360 | LD BC,32 | HL+=0032. | ||||||||||||||||||||||||||||||||||||
| 27363 | ADD HL,BC | ||||||||||||||||||||||||||||||||||||||
| 27364 | PUSH HL | Stash HL on the stack. | |||||||||||||||||||||||||||||||||||||
| 27365 | LD BC,23295 | BC=23295 (attribute buffer location). | |||||||||||||||||||||||||||||||||||||
| 27368 | AND A | HL-=BC. | |||||||||||||||||||||||||||||||||||||
| 27369 | SBC HL,BC | ||||||||||||||||||||||||||||||||||||||
| 27371 | POP HL | Restore HL from the stack. | |||||||||||||||||||||||||||||||||||||
| 27372 | JR C,Mothership_Bullet_Collision | Jump to Mothership_Bullet_Collision if H is less than A. | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_DeactivateBullet | 27374 | LD H,0 | H=0. | ||||||||||||||||||||||||||||||||||||
| 27376 | JR Handler_Mothership_SaveBulletPosition | Jump to Handler_Mothership_SaveBulletPosition. | |||||||||||||||||||||||||||||||||||||
| Mothership_Bullet_Collision | 27378 | LD A,(HL) | Jump to Handler_Mothership_SaveBulletPosition if *HL is equal to RED. | ||||||||||||||||||||||||||||||||||||
| 27379 | CP 2 | ||||||||||||||||||||||||||||||||||||||
| 27381 | JR Z,Handler_Mothership_SaveBulletPosition | ||||||||||||||||||||||||||||||||||||||
| 27383 | CP 70 | Jump to Handler_Mothership_CheckGround if *HL is not equal to INK:YELLOW, PAPER:BLACK (BRIGHT). | |||||||||||||||||||||||||||||||||||||
| 27385 | JR NZ,Handler_Mothership_CheckGround | ||||||||||||||||||||||||||||||||||||||
| 27387 | LD A,(26259) | Jump to Handler_Mothership_DeactivateBullet if *Flag_Shield is active. | |||||||||||||||||||||||||||||||||||||
| 27390 | OR A | ||||||||||||||||||||||||||||||||||||||
| 27391 | JR NZ,Handler_Mothership_DeactivateBullet | ||||||||||||||||||||||||||||||||||||||
| 27393 | LD (HL),6 | Write YELLOW to *HL. | |||||||||||||||||||||||||||||||||||||
| 27395 | JR Handler_Mothership_DrawBullet | Jump to Handler_Mothership_DrawBullet. | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_CheckGround | 27397 | AND %00000111 | Keep only bits 0-2. | ||||||||||||||||||||||||||||||||||||
| 27399 | JR NZ,Handler_Mothership_DeactivateBullet | Jump to Handler_Mothership_DeactivateBullet if A is not equal to A. | |||||||||||||||||||||||||||||||||||||
| 27401 | LD A,(HL) | A=*HL. | |||||||||||||||||||||||||||||||||||||
| 27402 | ADD A,6 | A+=6. | |||||||||||||||||||||||||||||||||||||
| 27404 | LD (HL),A | Write A to *HL. | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_DrawBullet | 27405 | PUSH HL | Stash HL on the stack. | ||||||||||||||||||||||||||||||||||||
| 27406 | CALL ConvertAttributeToScreenBufferAddress | Call ConvertAttributeToScreenBufferAddress. | |||||||||||||||||||||||||||||||||||||
| 27409 | EX DE,HL | Exchange the DE and HL registers. | |||||||||||||||||||||||||||||||||||||
| 27410 | LD BC,24614 | BC=Graphics_LivesIcon. | |||||||||||||||||||||||||||||||||||||
| 27413 | PUSH IX | HL=IX (using the stack). | |||||||||||||||||||||||||||||||||||||
| 27415 | POP HL | ||||||||||||||||||||||||||||||||||||||
| 27416 | ADD HL,HL | Multiply HL by 8. | |||||||||||||||||||||||||||||||||||||
| 27417 | ADD HL,HL | ||||||||||||||||||||||||||||||||||||||
| 27418 | ADD HL,HL | ||||||||||||||||||||||||||||||||||||||
| 27419 | ADD HL,BC | HL+=BC. | |||||||||||||||||||||||||||||||||||||
| 27420 | LD B,8 | Set a line counter in B (8 lines in a UDG). | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_BulletDrawLoop | 27422 | LD A,(HL) | Copy the UDG data to the screen buffer. | ||||||||||||||||||||||||||||||||||||
| 27423 | LD (DE),A | ||||||||||||||||||||||||||||||||||||||
| 27424 | INC D | Move down one pixel line in the screen buffer. | |||||||||||||||||||||||||||||||||||||
| 27425 | INC HL | Move to the next UDG graphic data byte. | |||||||||||||||||||||||||||||||||||||
| 27426 | DJNZ Handler_Mothership_BulletDrawLoop | Decrease the line counter by one and loop back to Handler_Mothership_BulletDrawLoop until all 8 lines of the UDG character have been drawn. | |||||||||||||||||||||||||||||||||||||
| 27428 | POP HL | Restore the attribute position from the stack. | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_SaveBulletPosition | 27429 | EX DE,HL | Exchange the DE and HL registers. | ||||||||||||||||||||||||||||||||||||
| 27430 | POP HL | Restore the bullet position table from the stack. | |||||||||||||||||||||||||||||||||||||
| 27431 | LD (HL),E | Save the current bullet position to the table. | |||||||||||||||||||||||||||||||||||||
| 27432 | INC HL | ||||||||||||||||||||||||||||||||||||||
| 27433 | LD (HL),D | ||||||||||||||||||||||||||||||||||||||
| 27434 | INC HL | ||||||||||||||||||||||||||||||||||||||
| 27435 | POP HL | Restore the bullet index from the stack. | |||||||||||||||||||||||||||||||||||||
| 27436 | DEC L | Decrease the bullet index by one. | |||||||||||||||||||||||||||||||||||||
| 27437 | JP NZ,Handler_Mothership_BulletLoop | Jump back to Handler_Mothership_BulletLoop until there are no more bullets left to process. | |||||||||||||||||||||||||||||||||||||
| 27440 | RET | Return. | |||||||||||||||||||||||||||||||||||||
| Prev: 26986 | Up: Map | Next: 27441 |