![]() |
Routines |
| Prev: 7082 | Up: Map | Next: 7190 |
|
Used by the routine at Handler_Frogs.
Updates a single frog's animation and sound state. Frogs sit idle on their platform, then randomly jump upward through a series of animation frames. A croaking sound effect plays during the jump, rising in pitch on the way up and falling on the way down.
|
||||||||||||||||
|
Check the jump timer to determine if the frog is mid-jump or idle.
|
||||||||||||||||
| Update_Frog | 70DB | LD A,(HL) | Fetch the jump timer value from *HL. | |||||||||||||
| 70DC | OR A | |||||||||||||||
| 70DD | JR Z,Set_Frog_Idle | Jump to Set_Frog_Idle if the timer is zero (frog is idle). | ||||||||||||||
| 70DF | DEC (HL) | Decrement the jump timer by one. | ||||||||||||||
| 70E0 | JR Z,Set_Frog_Idle | Jump to Set_Frog_Idle if the timer has now reached zero (jump complete). | ||||||||||||||
|
Frog is mid-jump; cycle through animation frames 00-03.
|
||||||||||||||||
| 70E2 | LD A,(IX+$02) | Increment the animation frame at *IX+02 wrapping at 03. | ||||||||||||||
| 70E5 | INC A | |||||||||||||||
| 70E6 | AND %00000011 | |||||||||||||||
| 70E8 | LD (IX+$02),A | |||||||||||||||
| 70EB | JR Handle_Frog_Sound | Jump to Handle_Frog_Sound. | ||||||||||||||
|
Frog is idle; set the idle frame.
|
||||||||||||||||
| Set_Frog_Idle | 70ED | LD (IX+$02),$06 | Write 06 to *IX+02 (idle animation frame). | |||||||||||||
|
Handle the frog's croak sound effect. The sound has two phases: ascending pitch (counter rises from 01 to 18), then descending pitch (counter falls back to 00).
|
||||||||||||||||
| Handle_Frog_Sound | 70F1 | INC HL | Advance to the ascending sound counter. | |||||||||||||
| 70F2 | LD A,(HL) | |||||||||||||||
| 70F3 | OR A | Jump to Check_Random_Croak if the sound counter is zero (no sound playing). | ||||||||||||||
| 70F4 | JR Z,Check_Random_Croak | |||||||||||||||
| 70F6 | INC HL | Advance to the descending flag. | ||||||||||||||
| 70F7 | LD A,(HL) | Jump to Frog_Sound_Descending if the descending flag is non-zero (sound is descending). | ||||||||||||||
| 70F8 | OR A | |||||||||||||||
| 70F9 | JR NZ,Frog_Sound_Descending | |||||||||||||||
|
Ascending phase: increment the pitch and output to the speaker.
|
||||||||||||||||
| 70FB | DEC HL | Move back to the ascending counter. | ||||||||||||||
| 70FC | LD A,(HL) | Calculate the speaker output from the counter: add 03 rotate left, mask and set bit 0 for the border. | ||||||||||||||
| 70FD | ADD A,$03 | |||||||||||||||
| 70FF | RLCA | |||||||||||||||
| 7100 | AND %00011000 | |||||||||||||||
| 7102 | OR %00000001 | |||||||||||||||
| 7104 | OUT ($FE),A | Output to the speaker port. | ||||||||||||||
| 7106 | LD A,(HL) | Fetch the ascending counter and increment it. | ||||||||||||||
| 7107 | INC A | |||||||||||||||
| 7108 | CP $19 | Jump to Store_Ascending_Counter if the ascending counter has not reached 19. | ||||||||||||||
| 710A | JR NZ,Store_Ascending_Counter | |||||||||||||||
|
Ascending phase complete; switch to descending.
|
||||||||||||||||
| 710C | XOR A | Write 00 to clear the ascending counter. | ||||||||||||||
| 710D | LD (HL),A | |||||||||||||||
| 710E | INC HL | Set the descending flag to FF. | ||||||||||||||
| 710F | DEC A | |||||||||||||||
| 7110 | LD (HL),A | |||||||||||||||
| 7111 | DEC HL | Move the pointer back to the ascending counter. | ||||||||||||||
| 7112 | JR Position_Frog_Sprite | Jump to Position_Frog_Sprite. | ||||||||||||||
| Store_Ascending_Counter | 7114 | LD (HL),A | Write the updated ascending counter back. | |||||||||||||
| 7115 | JR Position_Frog_Sprite | Jump to Position_Frog_Sprite. | ||||||||||||||
|
Descending phase: decrement the pitch and output to the speaker.
|
||||||||||||||||
| Frog_Sound_Descending | 7117 | DEC HL | Move back to the ascending counter (used as pitch value). | |||||||||||||
| 7118 | LD A,(HL) | Calculate the speaker output from the counter: rotate left, mask and set bit 0 for the border. | ||||||||||||||
| 7119 | RLCA | |||||||||||||||
| 711A | AND %00011000 | |||||||||||||||
| 711C | OR %00000001 | |||||||||||||||
| 711E | OUT ($FE),A | Output to the speaker port. | ||||||||||||||
| 7120 | DEC (HL) | Decrement the counter; jump to Position_Frog_Sprite if it is non-zero. | ||||||||||||||
| 7121 | JR NZ,Position_Frog_Sprite | |||||||||||||||
| 7123 | INC HL | Counter has reached zero; clear the descending flag and move back. | ||||||||||||||
| 7124 | LD (HL),$00 | |||||||||||||||
| 7126 | DEC HL | |||||||||||||||
| 7127 | JR Position_Frog_Sprite | Jump to Position_Frog_Sprite. | ||||||||||||||
|
No sound playing; randomly trigger a new croak if the frog is idle.
|
||||||||||||||||
| Check_Random_Croak | 7129 | LD A,R | Read the R register and mask; jump to Position_Frog_Sprite if it does not equal 0F (random chance to croak). | |||||||||||||
| 712B | AND %00111111 | |||||||||||||||
| 712D | CP $0F | |||||||||||||||
| 712F | JR NZ,Position_Frog_Sprite | |||||||||||||||
| 7131 | LD A,(IX+$02) | Jump to Position_Frog_Sprite if the animation frame at *IX+02 is not 06 (frog must be idle to start a croak). | ||||||||||||||
| 7134 | CP $06 | |||||||||||||||
| 7136 | JR NZ,Position_Frog_Sprite | |||||||||||||||
| 7138 | INC HL | Advance to the descending flag; check if it is non-zero and move back. | ||||||||||||||
| 7139 | LD A,(HL) | |||||||||||||||
| 713A | OR A | |||||||||||||||
| 713B | DEC HL | |||||||||||||||
| 713C | JR NZ,Start_Descending_Croak | Jump to Start_Descending_Croak if the descending flag is non-zero. | ||||||||||||||
| 713E | LD (HL),$01 | Write 01 to start the ascending sound counter. | ||||||||||||||
| 7140 | JR Position_Frog_Sprite | Jump to Position_Frog_Sprite. | ||||||||||||||
| Start_Descending_Croak | 7142 | LD (HL),$19 | Write 19 to the ascending counter (start from maximum pitch). | |||||||||||||
|
Calculate the frog's screen position based on its jump state and facing direction.
|
||||||||||||||||
| Position_Frog_Sprite | 7144 | LD E,(HL) | Load the ascending counter into E and descending flag into D. | |||||||||||||
| 7145 | INC HL | |||||||||||||||
| 7146 | LD D,(HL) | |||||||||||||||
| 7147 | LD A,E | Jump to Frog_On_Platform if the ascending counter is zero (frog is on the platform). | ||||||||||||||
| 7148 | OR A | |||||||||||||||
| 7149 | JR Z,Frog_On_Platform | |||||||||||||||
|
Frog is mid-jump; calculate the Y position from the jump height table.
|
||||||||||||||||
| 714B | DEC A | Decrement the counter to form a zero-based table index. | ||||||||||||||
| 714C | PUSH DE | Stash DE on the stack. | ||||||||||||||
| 714D | LD DE,$71EF | Look up the jump height from the table at Table_FrogJumpHeight. | ||||||||||||||
| 7150 | LD L,A | |||||||||||||||
| 7151 | LD H,$00 | |||||||||||||||
| 7153 | ADD HL,DE | |||||||||||||||
| 7154 | POP DE | Restore DE from the stack. | ||||||||||||||
| 7155 | LD A,B | Subtract from the platform Y position in B. | ||||||||||||||
| 7156 | SUB (HL) | |||||||||||||||
| 7157 | LD (IX+$01),A | Write it to *IX+01. | ||||||||||||||
| 715A | LD A,E | Calculate the X position: ascending counter * 04 + platform X. | ||||||||||||||
| 715B | ADD A,A | |||||||||||||||
| 715C | ADD A,A | |||||||||||||||
| 715D | ADD A,C | |||||||||||||||
| 715E | LD (IX+$00),A | Write it to *IX+00. | ||||||||||||||
|
||||||||||||||||
| 7161 | LD (IX+$03),$28 | Set the sprite frame to 28 (frog jumping right). | ||||||||||||||
| 7165 | BIT 7,D | Return if bit 7 of D is not set (facing right). | ||||||||||||||
| 7167 | RET Z | |||||||||||||||
|
||||||||||||||||
| 7168 | INC (IX+$03) | Increment the sprite frame to 29 (frog jumping left). | ||||||||||||||
| 716B | RET | Return. | ||||||||||||||
|
Frog is on the platform; set its resting position.
|
||||||||||||||||
| Frog_On_Platform | 716C | LD (IX+$01),B | Set the Y position to the platform Y from B. | |||||||||||||
| 716F | BIT 7,D | Jump to Frog_Facing_Left if bit 7 of D is set (frog faces left). | ||||||||||||||
| 7171 | JR NZ,Frog_Facing_Left | |||||||||||||||
| 7173 | LD (IX+$00),C | Set the X position to the platform X from C. | ||||||||||||||
|
||||||||||||||||
| 7176 | LD (IX+$03),$2A | Set the sprite frame to 2A (frog sitting right). | ||||||||||||||
| Random_Tongue_Flick | 717A | LD A,R | Read the R register and mask. | |||||||||||||
| 717C | AND %00011111 | |||||||||||||||
| 717E | OR A | Return if the result is non-zero (random chance to flick tongue). | ||||||||||||||
| 717F | RET NZ | |||||||||||||||
|
||||||||||||||||
| 7180 | INC (IX+$03) | Increment the sprite frame by one (tongue-out variant). | ||||||||||||||
| 7183 | RET | Return. | ||||||||||||||
|
Left-facing frog on platform.
|
||||||||||||||||
| Frog_Facing_Left | 7184 | LD A,C | Set the X position to platform X plus 68. | |||||||||||||
| 7185 | ADD A,$68 | |||||||||||||||
| 7187 | LD (IX+$00),A | |||||||||||||||
|
||||||||||||||||
| 718A | LD (IX+$03),$2C | Set the sprite frame to 2C (frog sitting left). | ||||||||||||||
| 718E | JR Random_Tongue_Flick | Jump to Random_Tongue_Flick. | ||||||||||||||
| Prev: 7082 | Up: Map | Next: 7190 |