![]() |
Routines |
| Prev: 66A8 | Up: Map | Next: 679C |
|
Used by the routine at Handler_Worms.
After scanning all entries, check if Percy is carrying a worm and handle the worm-in-beak sprite positioning.
|
||||||||
| Position_Worm_In_Beak | 66E1 | LD A,($5FAA) | Return if *CarryingWormFlag (worm carrying flag) is zero. | |||||
| 66E4 | OR A | |||||||
| 66E5 | RET Z | |||||||
| 66E6 | LD A,(IX+$01) | Jump to Update_Worm_In_Beak if Percy's Y position is less than 8F. | ||||||
| 66E9 | CP $8F | |||||||
| 66EB | JR C,Update_Worm_In_Beak | |||||||
| 66ED | LD A,($5FAC) | Jump to HandleRedBird_SetAnimationSeed if *WormDropFlag is set (a worm is being dropped to a chick). | ||||||
| 66F0 | OR A | |||||||
| 66F1 | JP NZ,DropWorm | |||||||
| Update_Worm_In_Beak | 66F4 | LD A,(IX+$01) | Jump to Set_Worm_Sprite_X if Percy's Y position is not less than 8D. | |||||
| 66F7 | CP $8D | |||||||
| 66F9 | JR NC,Set_Worm_Sprite_X | |||||||
| 66FB | OR %11111111 | Set *WormDropFlag to FF (enable worm drop). | ||||||
| 66FD | LD ($5FAC),A | |||||||
| Set_Worm_Sprite_X | 6700 | LD A,($5FA5) | Calculate the worm-in-beak X position: if *PercyFacingDirection (facing direction) is zero (facing right), add 0C to Percy's X, otherwise add FB (offset left). | |||||
| 6703 | OR A | |||||||
| 6704 | JR NZ,Position_Worm_In_Beak_0 | |||||||
| 6706 | ADD A,$0C | |||||||
| 6708 | JR Position_Worm_In_Beak_1 | |||||||
| Position_Worm_In_Beak_0 | 670A | LD A,$FB | A=FB. | |||||
| Position_Worm_In_Beak_1 | 670C | ADD A,(IX+$00) | Add the offset to Percy's X position. | |||||
| 670F | LD (IX+$20),A | Write the result to *IX+20 (worm sprite X position). | ||||||
| 6712 | LD A,(IX+$01) | Set the worm sprite Y position to Percy's Y plus 04. | ||||||
| 6715 | ADD A,$04 | |||||||
| 6717 | LD (IX+$21),A | |||||||
| 671A | LD C,$0D | Set the worm sprite frame: start with 0D rotate *ChickAnimationStates and if carry is not set, increment to 0E for the alternate wiggle frame. | ||||||
| 671C | LD A,($5FB4) | |||||||
| 671F | RRCA | |||||||
| 6720 | LD ($5FB4),A | |||||||
| 6723 | JR C,Set_Worm_Sprite_Frame | |||||||
| 6725 | INC C | |||||||
| Set_Worm_Sprite_Frame | 6726 | LD (IX+$23),C | Write the worm sprite frame index to *IX+23. | |||||
| 6729 | LD A,($5FAD) | Jump to Adjust_Worm_Y_Up if *LandedOnPlatformFlag (worm Y adjustment flag) is non-zero. | ||||||
| 672C | OR A | |||||||
| 672D | JR NZ,Adjust_Worm_Y_Up | |||||||
| 672F | LD A,(IX+$01) | Jump to Check_Nest_Delivery if Percy's Y position is not less than 90. | ||||||
| 6732 | CP $90 | |||||||
| 6734 | JR C,Check_Nest_Delivery | |||||||
| Adjust_Worm_Y_Up | 6736 | LD A,(IX+$21) | Subtract 04 from the worm Y position to adjust it upward. | |||||
| 6739 | SUB $04 | |||||||
| 673B | LD (IX+$21),A | |||||||
|
Check if Percy is at the nest to deliver the worm to the baby chicks (only on level 06).
|
||||||||
| Check_Nest_Delivery | 673E | LD A,($5FC5) | Return if *CurrentRoom (current level) is not equal to 06. | |||||
| 6741 | CP $06 | |||||||
| 6743 | RET NZ | |||||||
| 6744 | LD A,(IX+$01) | Return if Percy's Y position is less than 11. | ||||||
| 6747 | CP $11 | |||||||
| 6749 | RET C | |||||||
| 674A | CP $21 | Return if Percy's Y position is 21 or more. | ||||||
| 674C | RET NC | |||||||
| 674D | LD A,(IX+$00) | Return if Percy's X position is 6B or more. | ||||||
| 6750 | CP $6B | |||||||
| 6752 | RET NC | |||||||
| 6753 | LD A,($5FA5) | Return if *PercyFacingDirection (facing direction) is zero (Percy must be facing left). | ||||||
| 6756 | OR A | |||||||
| 6757 | RET Z | |||||||
|
Scan the room object data for a collected worm marker to convert into a nest delivery.
|
||||||||
| 6758 | LD BC,$0160 | Set the search counter to 0160 in BC. | ||||||
| 675B | LD HL,$DE9E | Point HL at Room_Object_Data. | ||||||
| Search_Nest_Slot_Loop | 675E | LD A,$1E | Jump to Deliver_Worm_To_Nest if *HL equals 1E (found a collected worm marker to convert). | |||||
| 6760 | CP (HL) | |||||||
| 6761 | JR Z,Deliver_Worm_To_Nest | |||||||
| 6763 | INC HL | Otherwise advance and loop back to Search_Nest_Slot_Loop, decrementing BC until zero. | ||||||
| 6764 | DEC BC | |||||||
| 6765 | LD A,C | |||||||
| 6766 | OR B | |||||||
| 6767 | JR NZ,Search_Nest_Slot_Loop | |||||||
| 6769 | RET | Return (no available slot found). | ||||||
| Deliver_Worm_To_Nest | 676A | LD (HL),$00 | Write 00 then 1F to convert the collected marker into a delivered/disabled entry. | |||||
| 676C | INC HL | |||||||
| 676D | LD (HL),$1F | |||||||
| 676F | XOR A | Deactivate the worm-in-beak sprite by writing 00 to *IX+23. | ||||||
| 6770 | LD (IX+$23),A | |||||||
| 6773 | LD A,$C8 | Call AddToScore to add C8 to the score. | ||||||
| 6775 | CALL AddToScore | |||||||
|
Play a delivery sound effect.
|
||||||||
| 6778 | LD E,$32 | Set the sound duration in E to 32. | ||||||
| 677A | LD A,$01 | Set the initial speaker state to 01. | ||||||
| Delivery_Sound_Outer | 677C | LD B,E | Copy duration to B. | |||||
| Delivery_Sound_Inner | 677D | OUT ($FE),A | Send to the speaker port. | |||||
| 677F | DJNZ Delivery_Sound_Inner | Loop the inner delay for B iterations. | ||||||
| 6781 | EX AF,AF' | Toggle the speaker bit pattern using XOR 18 mixed with duration bits for a warbling effect. | ||||||
| 6782 | LD A,E | |||||||
| 6783 | AND %00011000 | |||||||
| 6785 | LD D,A | |||||||
| 6786 | EX AF,AF' | |||||||
| 6787 | XOR %00011000 | |||||||
| 6789 | OR D | |||||||
| 678A | INC E | Advance the frequency and loop back to Delivery_Sound_Outer until E wraps to zero. | ||||||
| 678B | INC E | |||||||
| 678C | JR NZ,Delivery_Sound_Outer | |||||||
| 678E | CALL Handle_Level_Complete | Call Handle_Level_Complete. | ||||||
| Reset_Worm_State | 6791 | XOR A | Write 00 to clear;
|
|||||
| 6792 | LD ($5FAA),A | |||||||
| 6795 | LD ($5FAC),A | |||||||
| 6798 | LD (IX+$23),A | |||||||
| 679B | RET | Return. | ||||||
| Prev: 66A8 | Up: Map | Next: 679C |