Prev: E2CC Up: Map Next: E3E1
E38D: Human 04: Full Wave
Human_FullWave E38D POP HL Restore human table pointer from the stack.
FullWave_DecreaseCountdown E38E LD A,(HL) Decrease the humans action countdown by one.
E38F DEC A
E390 LD (HL),A
E391 CP $C8 Jump to FullWave_AboutToHide if the humans action countdown (A) is higher than C8.
E393 JR NC,FullWave_AboutToHide
E395 CP $80 Jump to FullWave_Action if the humans action countdown (A) is equal to 80.
E397 JR Z,FullWave_Action
E399 JR C,FullWave_EndCycle Jump to FullWave_EndCycle if the humans action countdown (A) is lower than 80.
Ensure the number is between 0-63.
E39B AND %00111111 Keep only bits 0-5.
E39D CP $20 Jump to FullWave_Mirrored if A is higher than 20.
E39F JR NC,FullWave_Mirrored
Ensure the number is between 0-3.
E3A1 AND %00000011 Keep only bits 0-1.
E3A3 CP $02 Jump to FullWave_LeftFrame1 if A is lower than 02.
E3A5 JR C,FullWave_LeftFrame1
E3A7 JR FullWave_LeftFrame2 Jump to FullWave_LeftFrame2.
Ensure the number is between 0-3.
FullWave_Mirrored E3A9 AND %00000011 Keep only bits 0-1.
E3AB CP $02 Jump to FullWave_RightFrame1 if A is lower than 02.
E3AD JR C,FullWave_RightFrame1
E3AF JR FullWave_RightFrame2 Jump to FullWave_RightFrame2.
Handle the waving, but also give a small chance the human should hide.
FullWave_Action E3B1 CALL ShouldHumanHide Call ShouldHumanHide.
E3B4 JR C,FullWave_DecreaseCountdown Jump to FullWave_DecreaseCountdown if the human is set to start hiding.
E3B6 CALL RandomNumber Call RandomNumber.
E3B9 LD (HL),$C0 Update the countdown to C0.
E3BB AND %00000001 50/50 chance of jumping to FullWave_RightFrame1.
E3BD JR Z,FullWave_RightFrame1
E3BF LD (HL),$A0 Write A0 to *HL.
Print the "normal" waving sprite frame 1.
FullWave_LeftFrame1 E3C1 LD A,$C4
ID Sprite
C4 human-196-left
E3C3 JP Draw_Human_Sprite Jump to Draw_Human_Sprite.
Print the "normal" waving sprite frame 2.
FullWave_LeftFrame2 E3C6 LD A,$C8
ID Sprite
C8 human-200-left
E3C8 JP Draw_Human_Sprite Jump to Draw_Human_Sprite.
Print the "mirrored" waving sprite frame 1.
FullWave_RightFrame1 E3CB LD A,$C4
ID Sprite
C4 human-196-right
E3CD JP Draw_Human_Sprite_Mirrored Jump to Draw_Human_Sprite_Mirrored.
Print the "mirrored" waving sprite frame 2.
FullWave_RightFrame2 E3D0 LD A,$C8
ID Sprite
C8 human-200-right
E3D2 JP Draw_Human_Sprite_Mirrored Jump to Draw_Human_Sprite_Mirrored.
When the countdown reaches 0A (from 80), jump to FullWave_Action to start a new cycle.
FullWave_EndCycle E3D5 CP $0A Jump to FullWave_Action if A is equal to 0A.
E3D7 JR Z,FullWave_Action
The countdown between CE-C9 handles the delay before C8 will hide the human.
FullWave_AboutToHide E3D9 LD A,$C0
ID Sprite
C0 human-192-left
E3DB JP NZ,Draw_Human_Sprite Jump to Draw_Human_Sprite until the countdown equals C8 (from line E391).
E3DE JP Handler_Human_Hide Jump to Handler_Human_Hide.
Prev: E2CC Up: Map Next: E3E1