Prev: E38D Up: Map Next: E414
E3E1: Human 05: Waving Arms In The Air/ Distressed Human
Human_WavingOverHead E3E1 POP HL Restore human table pointer from the stack.
WavingOverHead_DecreaseCountdown E3E2 LD A,(HL) Decrease the humans action countdown by one.
E3E3 DEC A
E3E4 LD (HL),A
E3E5 CP $C8 Jump to WavingOverHead_AboutToHide if the humans action countdown (A) is higher than C8.
E3E7 JR NC,WavingOverHead_AboutToHide
E3E9 CP $80 Jump to WavingOverHead_Action if the humans action countdown (A) is equal to 80.
E3EB JR Z,WavingOverHead_Action
E3ED JR C,WavingOverHead_EndCycle Jump to WavingOverHead_EndCycle if the humans action countdown (A) is lower than 80.
Turn the countdown into a number between 0-3 - so it's two cycles left, two cycles right.
E3EF AND %00000011 Keep only bits 0-1.
E3F1 CP $02 Jump to WavingOverHead_Left if A is lower than 02.
E3F3 JR C,WavingOverHead_Left
E3F5 JR WavingOverHead_Right Jump to WavingOverHead_Right.
Handle the waving, but also give a small chance the human should hide.
WavingOverHead_Action E3F7 CALL ShouldHumanHide Call ShouldHumanHide.
E3FA JR C,WavingOverHead_DecreaseCountdown Jump to WavingOverHead_DecreaseCountdown if the human is set to start hiding.
E3FC LD (HL),$A0 Update the countdown to A0.
Print the "normal" waving sprite.
WavingOverHead_Left E3FE LD A,$C8
ID Sprite
C8 human-200-left
E400 JP Draw_Human_Sprite Jump to Draw_Human_Sprite.
Print the "mirrored" waving sprite.
WavingOverHead_Right E403 LD A,$C8
ID Sprite
C8 human-200-right
E405 JP Draw_Human_Sprite_Mirrored Jump to Draw_Human_Sprite_Mirrored.
When the countdown reaches 0A (from 80), jump to WavingOverHead_Action to start a new cycle.
WavingOverHead_EndCycle E408 CP $0A Jump to WavingOverHead_Action if A is equal to 0A.
E40A JR Z,WavingOverHead_Action
The countdown between CE-C9 handles the delay before C8 will hide the human.
WavingOverHead_AboutToHide E40C LD A,$C0
ID Sprite
C0 human-192-left
E40E JP NZ,Draw_Human_Sprite Jump to Draw_Human_Sprite until the countdown equals C8 (from line E3E5).
E411 JP Handler_Human_Hide Jump to Handler_Human_Hide.
Prev: E38D Up: Map Next: E414