Prev: 29385 Up: Map Next: 29703
29453: Handler: Display Mothership Bonus
Used by the routine at Handler_LevelReset.
Displays the bonus screen after completing the mothership level (phase 4).
Only continue if;
Handler_DisplayMothershipBonus 29453 LD A,(26276) Return if *Flag_Collision is equal to 1.
29456 CP 1
29458 RET Z
29459 LD A,(26353) Jump to Check_InitialiseLevel if *Phase is not equal to 4.
29462 CP 4
29464 JP NZ,Check_InitialiseLevel
29467 LD A,(26323) Return if *MothershipAlienState is zero.
29470 OR A
29471 RET Z
Display a bonus screen with star background.
First fill the screen with the star UDG character (note they're written in INK:BLACK, PAPER:BLACK so they're not yet visible - this is just an example in INK:CYAN, PAPER:BLACK (BRIGHT) to show what is happening at this point).
Frame Output
1 fill-3
29472 CALL ClearScreen Call ClearScreen.
29475 LD DE,25051 DE=Graphics_StarLarge.
29478 CALL FillScreenWithUDG Call FillScreenWithUDG.
Print the bonus score text.
Frame Output
2 bonus-1
29481 LD DE,18542 DE=18542 (screen buffer location).
29484 LD BC,1093 Printing 4 characters in INK:CYAN, PAPER:BLACK (BRIGHT).
29487 LD HL,25899 HL=BonusScoreBuffer.
Calculate the bonus digit.
29490 LD A,(26239) Load *AlienCount (the number of aliens in the current level) into A.
29493 SRA A Divide by 2 and add 52 (ASCII "4").
29495 ADD A,52
29497 LD (HL),A Write the result to the score buffer.
29498 CALL Configurable_PrintString Call Configurable_PrintString.
Print it again...
Frame Output
3 bonus-2
29501 LD HL,25899 HL=BonusScoreBuffer.
29504 LD E,142 Update the printing location to 18574.
29506 LD B,4 Printing 4 characters.
29508 CALL Configurable_PrintString Call Configurable_PrintString.
Smoosh the top score down:
Frame Output Frame Output
4 bonus-3 5 bonus-4
6 bonus-5 7 bonus-6
29511 LD C,4 Set a row counter in C to 4.
BonusScrollTop_RowLoop 29513 LD HL,20075 HL=20075 (screen buffer location).
29516 LD DE,20331 DE=20331 (screen buffer location).
29519 LD B,8 Set a line counter in B (8 lines in a UDG).
BonusScrollTop_LineLoop 29521 PUSH BC Stash BC and HL on the stack.
29522 PUSH HL
29523 LD BC,10 BC=0010.
29526 LDIR LDIR.
29528 POP DE Restore DE from the stack.
29529 PUSH DE Stash DE on the stack.
29530 POP HL Restore HL from the stack.
29531 DEC H Decrease H by one.
29532 POP BC Restore BC from the stack.
29533 DJNZ BonusScrollTop_LineLoop Decrease counter by one and loop back to BonusScrollTop_LineLoop until counter is zero.
29535 DEC C Decrease C by one.
29536 JR NZ,BonusScrollTop_RowLoop Jump to BonusScrollTop_RowLoop until C is zero.
Smoosh the bottom score up:
Frame Output Frame Output
8 bonus-7 9 bonus-8
10 bonus-9 11 bonus-10
29538 LD C,4 C=4.
BonusScrollBottom_RowLoop 29540 LD HL,18827 HL=18827 (screen buffer location).
29543 LD DE,18571 DE=18571 (screen buffer location).
29546 LD B,7 B=7.
BonusScrollBottom_LineLoop 29548 PUSH BC Stash BC and HL on the stack.
29549 PUSH HL
29550 LD BC,10 BC=0010.
29553 LDIR LDIR.
29555 POP DE Restore DE from the stack.
29556 PUSH DE Stash DE on the stack.
29557 POP HL Restore HL from the stack.
29558 INC H Increment H by one.
29559 POP BC Restore BC from the stack.
29560 DJNZ BonusScrollBottom_LineLoop Decrease counter by one and loop back to BonusScrollBottom_LineLoop until counter is zero.
29562 DEC C Decrease C by one.
29563 JR NZ,BonusScrollBottom_RowLoop Jump back to BonusScrollBottom_RowLoop until C is zero.
29565 CALL Handler_Score Call Handler_Score.
Animate the bonus frame shimmering effect.
29568 LD IX,0 IX=0000.
29572 LD B,16 Set an outer counter to 16.
BonusAnimation_OuterLoop 29574 PUSH BC Stash the outer counter on the stack.
29575 LD B,11 Set an inner counter to 11.
BonusAnimation_InnerLoop 29577 PUSH BC Stash the inner counter on the stack.
29578 PUSH IX Stash IX on the stack.
29580 LD HL,22858 HL=22858 (attribute buffer location).
29583 LD DE,779 Set DE to initial frame dimensions (width=11, height=3).
29586 LD A,12 B=12-B.
29588 SUB B
29589 LD B,A
BonusAnimation_FrameLoop 29590 PUSH BC Stash BC on the stack.
29591 LD A,IXl A=the low byte of IX.
29593 AND %00111111 Keep only bits 0-5.
29595 LD B,E Set the horizontal counter from E (frame width).
Draw the top edge of the frame (left to right).
BonusAnimation_TopEdge 29596 LD (HL),A Write the attribute byte to the attribute buffer.
29597 INC HL Move the attribute address pointer right one block.
29598 DJNZ BonusAnimation_TopEdge Decrease the horizontal counter by one and loop back to BonusAnimation_TopEdge until the top edge of the frame has been drawn.
29600 LD B,D Set the vertical counter from D (frame height).
Draw the right edge of the frame (top to bottom).
BonusAnimation_RightEdge 29601 PUSH BC Stash the vertical counter on the stack.
29602 LD (HL),A Write the attribute byte to the attribute buffer.
29603 LD BC,32 Move down one row (add 0032 to the attribute address).
29606 ADD HL,BC
29607 POP BC Restore the vertical counter from the stack.
29608 DJNZ BonusAnimation_RightEdge Decrease the vertical counter by one and loop back to BonusAnimation_RightEdge until the right edge of the frame has been drawn.
29610 LD B,E Set the horizontal counter from E (frame width).
Draw the bottom edge of the frame (right to left).
BonusAnimation_BottomEdge 29611 LD (HL),A Write the attribute byte to the attribute buffer.
29612 DEC HL Move the attribute address pointer left one block.
29613 DJNZ BonusAnimation_BottomEdge Decrease the horizontal counter by one and loop back to BonusAnimation_BottomEdge until the bottom edge of the frame has been drawn.
29615 LD B,D Set the vertical counter from D (frame height).
Draw the left edge of the frame (bottom to top).
BonusAnimation_LeftEdge 29616 PUSH BC Stash the vertical counter on the stack.
29617 LD (HL),A Write the attribute byte to the attribute buffer.
29618 LD BC,32 Move up one row (subtract 0032 from the attribute address).
29621 SBC HL,BC
29623 POP BC Restore the vertical counter from the stack.
29624 DJNZ BonusAnimation_LeftEdge Decrease the vertical counter by one and loop back to BonusAnimation_LeftEdge until the left edge of the frame has been drawn.
Move outward to the next frame.
29626 LD C,33 Move up one row and left one block (subtract 0033 from the attribute address).
29628 SBC HL,BC
Increase the frame dimensions.
29630 INC E Increment frame width by two.
29631 INC E
29632 INC D Increment the frame height by two.
29633 INC D
29634 INC IX Increment IX by one.
29636 POP BC Restore BC from the stack.
29637 DJNZ BonusAnimation_FrameLoop Decrease counter by one and loop back to BonusAnimation_FrameLoop until counter is zero.
Play a sound effect for the animation.
Note this sample is the whole thing, obviously it loops round.
29639 POP HL Restore HL from the stack.
29640 PUSH HL Stash HL on the stack.
29641 LD A,L A=L.
29642 AND %00001111 Keep only bits 0-3.
29644 LD L,A L=A.
29645 LD H,B H=B.
29646 ADD HL,HL Multiply HL by 100.
29647 ADD HL,HL
29648 ADD HL,HL
29649 ADD HL,HL
29650 ADD HL,HL
29651 ADD HL,HL
29652 LD B,7 Set a sound iteration counter to 7 loops.
BonusAnimation_SoundLoop 29654 PUSH BC Stash the sound iteration counter and pitch on the stack.
29655 PUSH HL
29656 LD DE,2 Set sound duration to 0002.
29659 CALL 949 Call BEEPER.
29662 DI Disable interrupts.
29663 POP HL Restore the pitch value from the stack.
29664 LD BC,20 Increase the pitch value by 0020.
29667 ADD HL,BC
29668 POP BC Restore the sound iteration counter from the stack.
29669 DJNZ BonusAnimation_SoundLoop Decrease the sound iteration counter by one and loop back to BonusAnimation_SoundLoop until the sound has played out.
29671 POP IX Restore IX from the stack.
29673 DEC IX Decrease IX by one.
29675 POP BC Restore the inner counter from the stack.
29676 DJNZ BonusAnimation_InnerLoop Decrease the inner counter by one and loop back to BonusAnimation_InnerLoop until the counter is zero.
29678 POP BC Restore the outer counter from the stack.
29679 DJNZ BonusAnimation_OuterLoop Decrease the outer counter by one and loop back to BonusAnimation_OuterLoop until the counter is zero.
29681 CALL ClearScreen Call ClearScreen.
29684 LD BC,200 BC=0200.
BonusDelay_Loop 29687 DJNZ BonusDelay_Loop Decrease counter by one and loop back to BonusDelay_Loop until counter is zero.
29689 DEC C Decrease C by one.
29690 JR NZ,BonusDelay_Loop Jump to BonusDelay_Loop until C is zero.
Self-modifying code; decrease the difficulty delay so the levels play faster.
29692 LD HL,26776 HL=26776.
29695 LD A,(HL) Jump to InitialiseLevel if the current difficulty delay is less than 4.
29696 CP 4
29698 JR C,InitialiseLevel
29700 DEC (HL) Decrease the difficulty delay by one.
29701 JR InitialiseLevel Jump to InitialiseLevel.
Prev: 29385 Up: Map Next: 29703