Prev: 58337 Up: Map Next: 58439
58388: Human 6: Waving Side-To-Side/ Distressed Human
Human_WavingSideToSide 58388 POP HL Restore human table pointer from the stack.
WavingSideToSide_DecreaseCountdown 58389 LD A,(HL) Decrease the humans action countdown by one.
58390 DEC A
58391 LD (HL),A
58392 CP 200 Jump to WavingSideToSide_AboutToHide if the humans action countdown (A) is higher than 200.
58394 JR NC,WavingSideToSide_AboutToHide
58396 CP 128 Jump to WavingSideToSide_Action if the humans action countdown (A) is equal to 128.
58398 JR Z,WavingSideToSide_Action
58400 JR C,WavingSideToSide_EndCycle Jump to WavingSideToSide_EndCycle if the humans action countdown (A) is lower than 128.
Turn the countdown into a number between 0-7 - so it's four cycles left, four cycles right.
58402 AND %00000111 Keep only bits 0-2.
58404 CP 4 Jump to WavingSideToSide_Left if A is lower than 4.
58406 JR C,WavingSideToSide_Left
58408 JR WavingSideToSide_Right Jump to WavingSideToSide_Right.
Handle the waving, but also give a small chance the human should hide.
WavingSideToSide_Action 58410 CALL ShouldHumanHide Call ShouldHumanHide.
58413 JR C,WavingSideToSide_DecreaseCountdown Jump to WavingSideToSide_DecreaseCountdown if the human is set to start hiding.
58415 LD (HL),192 Update the countdown to 192.
Print the "normal" waving sprite.
WavingSideToSide_Left 58417 LD A,196
ID Sprite
196 human-196-left
58419 JP Draw_Human_Sprite Jump to Draw_Human_Sprite.
Print the "mirrored" waving sprite.
WavingSideToSide_Right 58422 LD A,196
ID Sprite
196 human-196-right
58424 JP Draw_Human_Sprite_Mirrored Jump to Draw_Human_Sprite_Mirrored.
When the countdown reaches 10 (from 128), jump to WavingSideToSide_Action to start a new cycle.
WavingSideToSide_EndCycle 58427 CP 10 Jump to WavingSideToSide_Action if A is equal to 10.
58429 JR Z,WavingSideToSide_Action
The countdown between 206-201 handles the delay before 200 will hide the human.
WavingSideToSide_AboutToHide 58431 LD A,192
ID Sprite
192 human-192-left
58433 JP NZ,Draw_Human_Sprite Jump to Draw_Human_Sprite until the countdown equals 200 (from line 58392).
58436 JP Handler_Human_Hide Jump to Handler_Human_Hide.
Prev: 58337 Up: Map Next: 58439