![]() |
Routines |
| Prev: 696A | Up: Map | Next: 6B31 |
|
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 | 6A23 | LD DE,$40CF | DE=40CF (left-hand UDG screen buffer target). | ||||||||||||||||||||||||||||||||||||
| 6A26 | PUSH DE | Stash this destination address on the stack. | |||||||||||||||||||||||||||||||||||||
| 6A27 | LD HL,$6541 | HL=Table_Mothership_Animation (UDG graphics). | |||||||||||||||||||||||||||||||||||||
| 6A2A | LD BC,$0232 | Configure the text routine to print the two UDG characters in INK:RED, PAPER:YELLOW. | |||||||||||||||||||||||||||||||||||||
| 6A2D | CALL CustomFont_PrintString | Call CustomFont_PrintString. | |||||||||||||||||||||||||||||||||||||
| 6A30 | 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).
|
|||||||||||||||||||||||||||||||||||||||
| 6A31 | LD A,($66D4) | A=*MothershipAnimationCounter (current ripple phase). | |||||||||||||||||||||||||||||||||||||
| 6A34 | PUSH AF | Stash the animation counter on the stack. | |||||||||||||||||||||||||||||||||||||
| 6A35 | SRA A | Shift A right (with carry). | |||||||||||||||||||||||||||||||||||||
| 6A37 | AND %00000111 | Keep only bits 0-2. | |||||||||||||||||||||||||||||||||||||
| 6A39 | XOR %00000111 | Flip bits 0-2. | |||||||||||||||||||||||||||||||||||||
| 6A3B | ADD A,H | Add the result to H. | |||||||||||||||||||||||||||||||||||||
| 6A3C | 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.
|
|||||||||||||||||||||||||||||||||||||||
| 6A3D | LD (HL),%00000011 | Write 03 to draw two pixels on the left-hand UDG. | |||||||||||||||||||||||||||||||||||||
| 6A3F | INC HL | Move to the next position. | |||||||||||||||||||||||||||||||||||||
| 6A40 | LD (HL),%11000000 | Write C0 to draw two pixels on the right-hand UDG to complete the line. | |||||||||||||||||||||||||||||||||||||
| 6A42 | 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.
|
|||||||||||||||||||||||||||||||||||||||
| 6A43 | AND %00000011 | Keep only bits 0-1. | |||||||||||||||||||||||||||||||||||||
| 6A45 | 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:
|
|||||||||||||||||||||||||||||||||||||||
| 6A47 | LD HL,$4837 | HL=4837 (upper source row). | |||||||||||||||||||||||||||||||||||||
| 6A4A | LD DE,$4838 | DE=4838 (destination one line below). | |||||||||||||||||||||||||||||||||||||
| 6A4D | LD B,$08 | Set a line counter in B (08 lines in a UDG). | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_ScrollLoop | 6A4F | PUSH BC | Stash the line counter on the stack. | ||||||||||||||||||||||||||||||||||||
| 6A50 | LD A,(DE) | A=*DE. | |||||||||||||||||||||||||||||||||||||
| 6A51 | PUSH HL | Stash HL and DE on the stack. | |||||||||||||||||||||||||||||||||||||
| 6A52 | PUSH DE | ||||||||||||||||||||||||||||||||||||||
| 6A53 | LD BC,$0011 | Copy 0011 bytes right-to-left (scroll left by one character). | |||||||||||||||||||||||||||||||||||||
| 6A56 | LDDR | ||||||||||||||||||||||||||||||||||||||
| 6A58 | LD (DE),A | Write A to *DE. | |||||||||||||||||||||||||||||||||||||
| 6A59 | POP DE | Restore DE and HL from the stack. | |||||||||||||||||||||||||||||||||||||
| 6A5A | POP HL | ||||||||||||||||||||||||||||||||||||||
| 6A5B | INC H | Increment H by one. | |||||||||||||||||||||||||||||||||||||
| 6A5C | INC D | Increment D by one. | |||||||||||||||||||||||||||||||||||||
| 6A5D | POP BC | Restore the line counter from the stack. | |||||||||||||||||||||||||||||||||||||
| 6A5E | 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.
|
|||||||||||||||||||||||||||||||||||||||
| 6A60 | LD D,$59 | D=59. | |||||||||||||||||||||||||||||||||||||
| 6A62 | LD H,D | H=D. | |||||||||||||||||||||||||||||||||||||
| 6A63 | LD C,$11 | C=11. | |||||||||||||||||||||||||||||||||||||
| 6A65 | LD A,(DE) | A=*DE. | |||||||||||||||||||||||||||||||||||||
| 6A66 | LDDR | LDDR. | |||||||||||||||||||||||||||||||||||||
| 6A68 | LD (DE),A | Write A to *DE. | |||||||||||||||||||||||||||||||||||||
|
Update mothership animation state.
|
|||||||||||||||||||||||||||||||||||||||
| Handler_Mothership_UpdateCounter | 6A69 | LD HL,$66D4 | HL=MothershipAnimationCounter. | ||||||||||||||||||||||||||||||||||||
| 6A6C | LD A,(HL) | Fetch the animation counter. | |||||||||||||||||||||||||||||||||||||
| 6A6D | INC (HL) | Increment *MothershipAnimationCounter by one. | |||||||||||||||||||||||||||||||||||||
|
Display the mothership alien.
|
|||||||||||||||||||||||||||||||||||||||
| 6A6E | 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). | |||||||||||||||||||||||||||||||||||||
| 6A70 | 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.
|
|||||||||||||||||||||||||||||||||||||||
| 6A72 | BIT 4,(HL) | Test bit 4 of the animation counter to choose the frame. | |||||||||||||||||||||||||||||||||||||
|
Default to:
|
|||||||||||||||||||||||||||||||||||||||
| 6A74 | LD HL,$5FD4 | HL=Graphics_MothershipAlien_01. | |||||||||||||||||||||||||||||||||||||
| 6A77 | JR Z,Handler_Mothership_DrawAlien | Jump to Handler_Mothership_DrawAlien if bit 4 is clear. | |||||||||||||||||||||||||||||||||||||
|
Else use:
|
|||||||||||||||||||||||||||||||||||||||
| 6A79 | LD HL,$5FF4 | HL=Graphics_MothershipAlien_02. | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_DrawAlien | 6A7C | LD DE,$40EF | DE=40EF (top-left screen cell for the alien). | ||||||||||||||||||||||||||||||||||||
| 6A7F | LD B,$02 | Set a counter in B for 02 rows. | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_RowLoop | 6A81 | PUSH BC | Stash the row counter on the stack. | ||||||||||||||||||||||||||||||||||||
| 6A82 | LD B,$02 | Set a counter in B for 02 columns. | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_ColumnLoop | 6A84 | PUSH BC | Stash the column counter and screen buffer pointer on the stack. | ||||||||||||||||||||||||||||||||||||
| 6A85 | PUSH DE | ||||||||||||||||||||||||||||||||||||||
| 6A86 | LD B,$08 | Set a line counter in B (08 lines in a UDG). | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_LineLoop | 6A88 | LD A,(HL) | Copy the UDG data to the screen buffer. | ||||||||||||||||||||||||||||||||||||
| 6A89 | LD (DE),A | ||||||||||||||||||||||||||||||||||||||
| 6A8A | INC D | Move down one pixel line in the screen buffer. | |||||||||||||||||||||||||||||||||||||
| 6A8B | INC HL | Move to the next UDG graphic data byte. | |||||||||||||||||||||||||||||||||||||
| 6A8C | DJNZ Handler_Mothership_LineLoop | Decrease the line counter by one and loop back to Handler_Mothership_LineLoop until all 08 lines of the UDG character have been drawn. | |||||||||||||||||||||||||||||||||||||
| 6A8E | POP DE | Restore the original screen buffer pointer from the stack. | |||||||||||||||||||||||||||||||||||||
| 6A8F | INC DE | Move right one character block. | |||||||||||||||||||||||||||||||||||||
| 6A90 | POP BC | Restore the column counter from the stack. | |||||||||||||||||||||||||||||||||||||
| 6A91 | 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. | |||||||||||||||||||||||||||||||||||||
| 6A93 | LD DE,$480F | DE=480F (screen buffer location). | |||||||||||||||||||||||||||||||||||||
| 6A96 | POP BC | Restore the row counter from the stack. | |||||||||||||||||||||||||||||||||||||
| 6A97 | 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 | 6A99 | LD A,($6695) | Return if *Bullet_RateLimiter is not zero. | ||||||||||||||||||||||||||||||||||||
| 6A9C | OR A | ||||||||||||||||||||||||||||||||||||||
| 6A9D | RET NZ | ||||||||||||||||||||||||||||||||||||||
| 6A9E | LD HL,$0003 | HL=0003. | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_BulletLoop | 6AA1 | PUSH HL | Stash HL on the stack. | ||||||||||||||||||||||||||||||||||||
| 6AA2 | PUSH HL | IX=HL (using the stack). | |||||||||||||||||||||||||||||||||||||
| 6AA3 | POP IX | ||||||||||||||||||||||||||||||||||||||
| 6AA5 | LD BC,$66BA | Multiply HL by 02 and add 66BA. | |||||||||||||||||||||||||||||||||||||
| 6AA8 | ADD HL,HL | ||||||||||||||||||||||||||||||||||||||
| 6AA9 | ADD HL,BC | ||||||||||||||||||||||||||||||||||||||
| 6AAA | PUSH HL | Stash HL on the stack. | |||||||||||||||||||||||||||||||||||||
| 6AAB | LD E,(HL) | E=*HL. | |||||||||||||||||||||||||||||||||||||
| 6AAC | INC HL | Increment HL by one. | |||||||||||||||||||||||||||||||||||||
| 6AAD | LD D,(HL) | D=*HL. | |||||||||||||||||||||||||||||||||||||
| 6AAE | LD A,D | A=D. | |||||||||||||||||||||||||||||||||||||
| 6AAF | EX DE,HL | Exchange the DE and HL registers. | |||||||||||||||||||||||||||||||||||||
| 6AB0 | OR A | Jump to Handler_Mothership_BulletActive if the bullet slot is active. | |||||||||||||||||||||||||||||||||||||
| 6AB1 | JR NZ,Handler_Mothership_BulletActive | ||||||||||||||||||||||||||||||||||||||
| 6AB3 | CALL GenerateRandomNumber | Call GenerateRandomNumber. | |||||||||||||||||||||||||||||||||||||
| 6AB6 | AND %00001111 | Keep only bits 0-3. | |||||||||||||||||||||||||||||||||||||
| 6AB8 | OR A | Jump to Handler_Mothership_0 if A is not zero. | |||||||||||||||||||||||||||||||||||||
| 6AB9 | JR NZ,Handler_Mothership_0 | ||||||||||||||||||||||||||||||||||||||
| 6ABB | LD HL,$594F | HL=594F (attribute buffer location). | |||||||||||||||||||||||||||||||||||||
| 6ABE | JR Mothership_Bullet_Collision | Jump to Mothership_Bullet_Collision. | |||||||||||||||||||||||||||||||||||||
|
Only fire if the random nibble equals 03 otherwise skip the slot.
|
|||||||||||||||||||||||||||||||||||||||
| Handler_Mothership_0 | 6AC0 | CP $03 | Jump to Handler_Mothership_SaveBulletPosition if A is not equal to 03. | ||||||||||||||||||||||||||||||||||||
| 6AC2 | JR NZ,Handler_Mothership_SaveBulletPosition | ||||||||||||||||||||||||||||||||||||||
| 6AC4 | LD HL,$5950 | HL=5950 (attribute buffer location). | |||||||||||||||||||||||||||||||||||||
| 6AC7 | 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 | 6AC9 | LD A,(HL) | A=*HL. | ||||||||||||||||||||||||||||||||||||
| 6ACA | AND %01000111 | Keep only bits 0-2, 6. | |||||||||||||||||||||||||||||||||||||
| 6ACC | CP $06 | Jump to Handler_Mothership_2 if A is not equal to 06. | |||||||||||||||||||||||||||||||||||||
| 6ACE | JR NZ,Handler_Mothership_2 | ||||||||||||||||||||||||||||||||||||||
| 6AD0 | LD A,(HL) | A=*HL. | |||||||||||||||||||||||||||||||||||||
| 6AD1 | AND %11111000 | Keep only bits 3-7. | |||||||||||||||||||||||||||||||||||||
| 6AD3 | LD (HL),A | Write A to *HL. | |||||||||||||||||||||||||||||||||||||
| 6AD4 | PUSH HL | Stash HL on the stack. | |||||||||||||||||||||||||||||||||||||
| 6AD5 | CALL ConvertAttributeToScreenBufferAddress | Call ConvertAttributeToScreenBufferAddress. | |||||||||||||||||||||||||||||||||||||
| 6AD8 | LD B,$08 | B=08. | |||||||||||||||||||||||||||||||||||||
| 6ADA | XOR A | Write 00 to *HL. | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_1 | 6ADB | LD (HL),A | |||||||||||||||||||||||||||||||||||||
| 6ADC | INC H | Increment H by one. | |||||||||||||||||||||||||||||||||||||
| 6ADD | DJNZ Handler_Mothership_1 | Decrease counter by one and loop back to Handler_Mothership_1 until counter is zero. | |||||||||||||||||||||||||||||||||||||
| 6ADF | POP HL | Restore HL from the stack. | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_2 | 6AE0 | LD BC,$0020 | HL+=0020. | ||||||||||||||||||||||||||||||||||||
| 6AE3 | ADD HL,BC | ||||||||||||||||||||||||||||||||||||||
| 6AE4 | PUSH HL | Stash HL on the stack. | |||||||||||||||||||||||||||||||||||||
| 6AE5 | LD BC,$5AFF | BC=5AFF (attribute buffer location). | |||||||||||||||||||||||||||||||||||||
| 6AE8 | AND A | HL-=BC. | |||||||||||||||||||||||||||||||||||||
| 6AE9 | SBC HL,BC | ||||||||||||||||||||||||||||||||||||||
| 6AEB | POP HL | Restore HL from the stack. | |||||||||||||||||||||||||||||||||||||
| 6AEC | JR C,Mothership_Bullet_Collision | Jump to Mothership_Bullet_Collision if H is less than A. | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_DeactivateBullet | 6AEE | LD H,$00 | H=00. | ||||||||||||||||||||||||||||||||||||
| 6AF0 | JR Handler_Mothership_SaveBulletPosition | Jump to Handler_Mothership_SaveBulletPosition. | |||||||||||||||||||||||||||||||||||||
| Mothership_Bullet_Collision | 6AF2 | LD A,(HL) | Jump to Handler_Mothership_SaveBulletPosition if *HL is equal to RED. | ||||||||||||||||||||||||||||||||||||
| 6AF3 | CP $02 | ||||||||||||||||||||||||||||||||||||||
| 6AF5 | JR Z,Handler_Mothership_SaveBulletPosition | ||||||||||||||||||||||||||||||||||||||
| 6AF7 | CP $46 | Jump to Handler_Mothership_CheckGround if *HL is not equal to INK:YELLOW, PAPER:BLACK (BRIGHT). | |||||||||||||||||||||||||||||||||||||
| 6AF9 | JR NZ,Handler_Mothership_CheckGround | ||||||||||||||||||||||||||||||||||||||
| 6AFB | LD A,($6693) | Jump to Handler_Mothership_DeactivateBullet if *Flag_Shield is active. | |||||||||||||||||||||||||||||||||||||
| 6AFE | OR A | ||||||||||||||||||||||||||||||||||||||
| 6AFF | JR NZ,Handler_Mothership_DeactivateBullet | ||||||||||||||||||||||||||||||||||||||
| 6B01 | LD (HL),$06 | Write YELLOW to *HL. | |||||||||||||||||||||||||||||||||||||
| 6B03 | JR Handler_Mothership_DrawBullet | Jump to Handler_Mothership_DrawBullet. | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_CheckGround | 6B05 | AND %00000111 | Keep only bits 0-2. | ||||||||||||||||||||||||||||||||||||
| 6B07 | JR NZ,Handler_Mothership_DeactivateBullet | Jump to Handler_Mothership_DeactivateBullet if A is not equal to A. | |||||||||||||||||||||||||||||||||||||
| 6B09 | LD A,(HL) | A=*HL. | |||||||||||||||||||||||||||||||||||||
| 6B0A | ADD A,$06 | A+=06. | |||||||||||||||||||||||||||||||||||||
| 6B0C | LD (HL),A | Write A to *HL. | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_DrawBullet | 6B0D | PUSH HL | Stash HL on the stack. | ||||||||||||||||||||||||||||||||||||
| 6B0E | CALL ConvertAttributeToScreenBufferAddress | Call ConvertAttributeToScreenBufferAddress. | |||||||||||||||||||||||||||||||||||||
| 6B11 | EX DE,HL | Exchange the DE and HL registers. | |||||||||||||||||||||||||||||||||||||
| 6B12 | LD BC,$6026 | BC=Graphics_LivesIcon. | |||||||||||||||||||||||||||||||||||||
| 6B15 | PUSH IX | HL=IX (using the stack). | |||||||||||||||||||||||||||||||||||||
| 6B17 | POP HL | ||||||||||||||||||||||||||||||||||||||
| 6B18 | ADD HL,HL | Multiply HL by 08. | |||||||||||||||||||||||||||||||||||||
| 6B19 | ADD HL,HL | ||||||||||||||||||||||||||||||||||||||
| 6B1A | ADD HL,HL | ||||||||||||||||||||||||||||||||||||||
| 6B1B | ADD HL,BC | HL+=BC. | |||||||||||||||||||||||||||||||||||||
| 6B1C | LD B,$08 | Set a line counter in B (08 lines in a UDG). | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_BulletDrawLoop | 6B1E | LD A,(HL) | Copy the UDG data to the screen buffer. | ||||||||||||||||||||||||||||||||||||
| 6B1F | LD (DE),A | ||||||||||||||||||||||||||||||||||||||
| 6B20 | INC D | Move down one pixel line in the screen buffer. | |||||||||||||||||||||||||||||||||||||
| 6B21 | INC HL | Move to the next UDG graphic data byte. | |||||||||||||||||||||||||||||||||||||
| 6B22 | DJNZ Handler_Mothership_BulletDrawLoop | Decrease the line counter by one and loop back to Handler_Mothership_BulletDrawLoop until all 08 lines of the UDG character have been drawn. | |||||||||||||||||||||||||||||||||||||
| 6B24 | POP HL | Restore the attribute position from the stack. | |||||||||||||||||||||||||||||||||||||
| Handler_Mothership_SaveBulletPosition | 6B25 | EX DE,HL | Exchange the DE and HL registers. | ||||||||||||||||||||||||||||||||||||
| 6B26 | POP HL | Restore the bullet position table from the stack. | |||||||||||||||||||||||||||||||||||||
| 6B27 | LD (HL),E | Save the current bullet position to the table. | |||||||||||||||||||||||||||||||||||||
| 6B28 | INC HL | ||||||||||||||||||||||||||||||||||||||
| 6B29 | LD (HL),D | ||||||||||||||||||||||||||||||||||||||
| 6B2A | INC HL | ||||||||||||||||||||||||||||||||||||||
| 6B2B | POP HL | Restore the bullet index from the stack. | |||||||||||||||||||||||||||||||||||||
| 6B2C | DEC L | Decrease the bullet index by one. | |||||||||||||||||||||||||||||||||||||
| 6B2D | JP NZ,Handler_Mothership_BulletLoop | Jump back to Handler_Mothership_BulletLoop until there are no more bullets left to process. | |||||||||||||||||||||||||||||||||||||
| 6B30 | RET | Return. | |||||||||||||||||||||||||||||||||||||
| Prev: 696A | Up: Map | Next: 6B31 |