Prev: 62349 Up: Map Next: 62447
62353: Test Entity Below
Find a solid simple entity immediately below IX (for a downward step). On a hit, store it at Pointer_LastCollidedEntity and clear carry; on a miss, set carry.
Input
IX Address of complex state data for the subject entity
Test_EntityBelow 62353 LD C,1 Load C with 1 (room−1 / down bias).
This entry point is used by the routine at Test_EntityAbove.
Walk StateData_SimpleEntities for a solid entity abutting IX vertically.
Test_EntityVertical_Scan 62355 PUSH HL Stash HL and DE on the stack.
62356 PUSH DE
62357 LD DE,14 Each entity record is 0014 bytes, then load that into DE.
62360 LD HL,35689 Point HL at the simple entity table (StateData_SimpleEntities).
Next simple-entity slot for the vertical abut test (or miss on 255).
Test_EntityVertical_ScanSlot 62363 LD A,(HL) Fetch this entity's type. Is it the table terminator (255)? If not, test the slot at Test_EntityVertical_CheckSlot.
62364 CP 255
62366 JR NZ,Test_EntityVertical_CheckSlot
62368 POP DE Restore DE and HL from the stack.
62369 POP HL
62370 SCF Signal a miss.
62371 RET Return.
Require a solid (bit 2) neighbour; skip room check for type 51.
Test_EntityVertical_CheckSlot 62372 LD A,(HL) Re-fetch the type. Is the slot empty? If so, skip to Test_EntityVertical_AdvanceSlot.
62373 OR A
62374 JR Z,Test_EntityVertical_AdvanceSlot
62376 BIT 7,A Is the high bit set (inactive)? If so, skip to Test_EntityVertical_AdvanceSlot.
62378 JR NZ,Test_EntityVertical_AdvanceSlot
62380 CP (IX+0) Is it the same type as the subject? If so, skip to Test_EntityVertical_AdvanceSlot.
62383 JR Z,Test_EntityVertical_AdvanceSlot
62385 LD B,A Keep the type in B.
62386 PUSH HL Stash HL on the stack.
62387 INC HL Advance onto flags byte 1.
62388 LD A,(HL) Fetch the flags.
62389 AND %00000100 Keep only the solid/platform bit (bit 2).
62391 JR Z,Test_EntityVertical_Reject If it was clear, reject at Test_EntityVertical_Reject.
62393 BIT 5,(HL) Is bit 5 set? If so, reject at Test_EntityVertical_Reject.
62395 JR NZ,Test_EntityVertical_Reject
62397 INC HL Advance past the room/y/y-extent fields onto the room-check byte.
62398 INC HL
62399 INC HL
62400 LD A,B Keep the candidate type in A. Is it type 51 (skip room check)?.
62401 CP 51
62403 JR Z,Test_EntityVertical_CheckBounds If so, take the bounds check at Test_EntityVertical_CheckBounds.
62405 LD A,(HL) Fetch the entity's room. Subtract the caller's room bias in C. Does it match the subject's room? If not, reject at Test_EntityVertical_Reject.
62406 SUB C
62407 CP (IX+4)
62410 JR NZ,Test_EntityVertical_Reject
Confirm horizontal overlap and Y abutment with the subject.
Test_EntityVertical_CheckBounds 62412 INC HL Advance onto the entity's y-coordinate.
62413 LD A,(IX+6) Does the subject's y-extent (IX+6) reach this candidate y? If not, reject at Test_EntityVertical_Reject.
62416 CP (HL)
62417 JR C,Test_EntityVertical_Reject
62419 INC HL Advance onto the entity's y-extent.
62420 LD A,(HL) Does this candidate y-extent reach the subject's y (IX+5)? If not, reject at Test_EntityVertical_Reject.
62421 CP (IX+5)
62424 JR C,Test_EntityVertical_Reject
62426 INC HL Advance onto the entity's x-coordinate.
62427 LD A,(IX+8) Fetch the subject's x-extent (IX+8). Step it right by one. Does it equal this entity's x (abutting above/below)? If not, reject at Test_EntityVertical_Reject.
62430 INC A
62431 CP (HL)
62432 JR NZ,Test_EntityVertical_Reject
Vertical neighbour hits: store the entity at Pointer_LastCollidedEntity and return its type.
62434 POP HL Restore HL from the stack.
62435 LD (29354),HL Store it at Pointer_LastCollidedEntity.
62438 XOR A Clear carry.
62439 LD A,(HL) Fetch the entity's type into A.
62440 POP DE Restore DE and HL from the stack.
62441 POP HL
62442 RET Return.
Reject this vertical neighbour and continue the simple-entity walk.
Test_EntityVertical_Reject 62443 POP HL Restore HL from the stack.
Advance to the next simple-entity record in the vertical scan.
Test_EntityVertical_AdvanceSlot 62444 ADD HL,DE Advance HL by one entity record.
62445 JR Test_EntityVertical_ScanSlot Jump to Test_EntityVertical_ScanSlot to test the next vertical neighbour.
Prev: 62349 Up: Map Next: 62447