Prev: 58060 Up: Map Next: 58337
58253: Human 4: Full Wave
Human_FullWave 58253 POP HL Restore human table pointer from the stack.
FullWave_DecreaseCountdown 58254 LD A,(HL) Decrease the humans action countdown by one.
58255 DEC A
58256 LD (HL),A
58257 CP 200 Jump to FullWave_AboutToHide if the humans action countdown (A) is higher than 200.
58259 JR NC,FullWave_AboutToHide
58261 CP 128 Jump to FullWave_Action if the humans action countdown (A) is equal to 128.
58263 JR Z,FullWave_Action
58265 JR C,FullWave_EndCycle Jump to FullWave_EndCycle if the humans action countdown (A) is lower than 128.
Ensure the number is between 0-63.
58267 AND %00111111 Keep only bits 0-5.
58269 CP 32 Jump to FullWave_Mirrored if A is higher than 32.
58271 JR NC,FullWave_Mirrored
Ensure the number is between 0-3.
58273 AND %00000011 Keep only bits 0-1.
58275 CP 2 Jump to FullWave_LeftFrame1 if A is lower than 2.
58277 JR C,FullWave_LeftFrame1
58279 JR FullWave_LeftFrame2 Jump to FullWave_LeftFrame2.
Ensure the number is between 0-3.
FullWave_Mirrored 58281 AND %00000011 Keep only bits 0-1.
58283 CP 2 Jump to FullWave_RightFrame1 if A is lower than 2.
58285 JR C,FullWave_RightFrame1
58287 JR FullWave_RightFrame2 Jump to FullWave_RightFrame2.
Handle the waving, but also give a small chance the human should hide.
FullWave_Action 58289 CALL ShouldHumanHide Call ShouldHumanHide.
58292 JR C,FullWave_DecreaseCountdown Jump to FullWave_DecreaseCountdown if the human is set to start hiding.
58294 CALL RandomNumber Call RandomNumber.
58297 LD (HL),192 Update the countdown to 192.
58299 AND %00000001 50/50 chance of jumping to FullWave_RightFrame1.
58301 JR Z,FullWave_RightFrame1
58303 LD (HL),160 Write 160 to *HL.
Print the "normal" waving sprite frame 1.
FullWave_LeftFrame1 58305 LD A,196
ID Sprite
196 human-196-left
58307 JP Draw_Human_Sprite Jump to Draw_Human_Sprite.
Print the "normal" waving sprite frame 2.
FullWave_LeftFrame2 58310 LD A,200
ID Sprite
200 human-200-left
58312 JP Draw_Human_Sprite Jump to Draw_Human_Sprite.
Print the "mirrored" waving sprite frame 1.
FullWave_RightFrame1 58315 LD A,196
ID Sprite
196 human-196-right
58317 JP Draw_Human_Sprite_Mirrored Jump to Draw_Human_Sprite_Mirrored.
Print the "mirrored" waving sprite frame 2.
FullWave_RightFrame2 58320 LD A,200
ID Sprite
200 human-200-right
58322 JP Draw_Human_Sprite_Mirrored Jump to Draw_Human_Sprite_Mirrored.
When the countdown reaches 10 (from 128), jump to FullWave_Action to start a new cycle.
FullWave_EndCycle 58325 CP 10 Jump to FullWave_Action if A is equal to 10.
58327 JR Z,FullWave_Action
The countdown between 206-201 handles the delay before 200 will hide the human.
FullWave_AboutToHide 58329 LD A,192
ID Sprite
192 human-192-left
58331 JP NZ,Draw_Human_Sprite Jump to Draw_Human_Sprite until the countdown equals 200 (from line 58257).
58334 JP Handler_Human_Hide Jump to Handler_Human_Hide.
Prev: 58060 Up: Map Next: 58337