Entities_Actions: CALL =Reset_Entities_Collision_Map LD HL, $mem_entities_list CALL =Entity_Action CALL =Entity_Action CALL =Entity_Action CALL =Entity_Action CALL =Entity_Action CALL =Entity_Action CALL =Entity_Action CALL =Entity_Action CALL =Entity_Action CALL =Entity_Action CALL =Entity_Action CALL =Entity_Action CALL =Entity_Action CALL =Entity_Action CALL =Entity_Action CALL =Entity_Action RET Entity_Action: LD A, (HL+) CP $00 JR Z, =Entity_Action.skip INC HL INC HL INC HL LD A, (HL+) LD D, A LD A, (HL+) LD E, A PUSH HL LD A, L AND $f8 LD L, A ; This is confusing but this thing is actually CALL DE LD BC, =Entity_Action.interaction_end PUSH BC PUSH DE RET Entity_Action.interaction_end: POP HL Entity_Action.skip: LD A, L AND $f8 ADD $08 LD L, A RET Update_Animation_Steps: LD A, $mem_map_loading_flags BIT 3, A JR Z, =Update_Animation_Steps.end LD A, $mem_moving_animation_step INC A AND $0f LD $mem_moving_animation_step, A CP $00 JR NZ, =Update_Animation_Steps.end LD A, $mem_map_loading_flags RES 3, A SET 1, A LD $mem_map_loading_flags, A Update_Animation_Steps.end: RET Fox_AI: PUSH HL PUSH BC PUSH DE INC HL LD A, (HL+) LD B, A LD A, (HL+) LD C, A LD A, (HL+) LD D, A Fox_AI.Start_action_or_movement: LD A, $mem_map_loading_flags BIT 3, A JR Z, =Fox_AI.Start_action_or_movement.end LD A, $mem_moving_animation_step CP $00 JR NZ, =Fox_AI.Start_action_or_movement.end ; Choose direction LD A, B ADD $80 LD E, A LD A, $mem_bunny_x ADD $80 CP E JR Z =Fox_AI.Vertical JR NC =Fox_AI.Go_Left Fox_AI.Go_Right: LD A, $enum_direction_left JR =Fox_AI.Direction_check_end Fox_AI.Go_Left: LD A, $enum_direction_right JR Z =Fox_AI.Direction_check_end Fox_AI.Vertical: LD A, C ADD $80 LD E, A LD A, $mem_bunny_y ADD $80 CP E PUSH AF PUSH HL LD HL, $9800 LD A, $00 RL A CALL =Print_8bit POP HL POP AF JR Z =Fox_AI.Start_action_or_movement.end JR C =Fox_AI.Go_Up Fox_AI.Go_Down: LD A, $enum_direction_down JR =Fox_AI.Direction_check_end Fox_AI.Go_Up: LD A, $enum_direction_up Fox_AI.Direction_check_end: OR $08 LD D, A ; Check collision Check_Collision: PUSH BC CALL =Get_Position_After_Move LD A, C CALL =Is_Collisionable CALL =Carve_Entity_Collision_Map POP BC CP $00 JR Z, =Fox_AI.Start_action_or_movement.not_collision RES 3, D Fox_AI.Start_action_or_movement.not_collision: Fox_AI.Start_action_or_movement.end: Fox_AI.End_movement: LD A, $mem_map_loading_flags BIT 3, A JP Z, =Fox_AI.End_movement.end LD A, $mem_moving_animation_step CP $0f JP NZ, =Fox_AI.End_movement.end BIT 3, D JR Z, =Fox_AI.End_movement.end LD A, $01 .ADD_A_TO_DIRECTION_BC Fox_AI.End_movement.end: LD A, L AND $f8 LD L, A INC HL LD A, B LD (HL+), A LD A, C LD (HL+), A LD A, D LD (HL+), A POP DE POP BC POP HL RET