Prev: E22A Up: Map Next: E290
E262: Find Colliding Wave Enemy
Walks the wave entity list between the snapshot pointer at C50B and the write pointer at C50D. For each entity with a type nibble below 04 tests bounds overlap via HitTestBounds8AtHL; returns without carry set if an overlapping entity is found with its position left in alternate HL. Returns with carry set if the list is exhausted without a match. Entities with a type nibble of 04 or higher are skipped as non-collidable. Called from Handle_Horizontal_Enemy_Entity and Process_Wall_Bouncing_Enemy.
Find_Colliding_Wave_Enemy E262 EXX Switch to alternate registers and load the entity list snapshot pointer from C50B.
E263 LD HL,($C50B)
Find_Colliding_Wave_Enemy_Next E266 EX DE,HL Compare the snapshot against the write pointer; return with carry set (no match) if the list is exhausted.
E267 LD HL,($C50D)
E26A AND A
E26B SBC HL,DE
E26D SCF
E26E EX DE,HL
E26F RET Z Advance three bytes past the handler word, read the entity type nibble, and mask to the low 4 bits.
E270 INC HL
E271 INC HL
E272 INC HL
E273 LD A,(HL)
E274 AND %00001111 Mask the type to the low nibble.
E276 CP $04 Jump to Find_Colliding_Wave_Enemy_1 to skip this entity if the type is 04 or higher (non-collidable).
E278 INC HL
E279 JP NC,Find_Colliding_Wave_Enemy_1 Test whether this entity's bounds overlap the current position via HitTestBounds8AtHL; advance and loop if they do not.
E27C CALL HitTestBounds8AtHL
E27F RET NC No overlap: step the alternate HL back three bytes and loop.
E280 EXX
E281 DEC HL
E282 DEC HL
E283 DEC HL
E284 EXX
Find_Colliding_Wave_Enemy_0 E285 INC HL Advance two bytes to the next entity record and loop.
E286 INC HL
E287 JP Find_Colliding_Wave_Enemy_Next
Find_Colliding_Wave_Enemy_1 E28A INC HL Wide entity: advance three more bytes and loop.
E28B INC HL
E28C INC HL
E28D JP Find_Colliding_Wave_Enemy_0
Prev: E22A Up: Map Next: E290