Prev: 62250 Up: Map Next: 62349
62254: Test Entity On Right
Find a solid simple entity immediately to the right of IX (for a rightward 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_EntityOnRight 62254 LD C,1 Load C with 1 (room−1 / right bias).
This entry point is used by the routine at Test_EntityOnLeft.
Walk StateData_SimpleEntities for a solid (bit 2) entity abutting IX horizontally.
Test_EntityHorizontal_Scan 62256 PUSH HL Stash HL and DE on the stack.
62257 PUSH DE
62258 LD DE,14 Each entity record is 0014 bytes, then load that into DE.
62261 LD HL,35689 Point HL at the simple entity table (StateData_SimpleEntities).
Next simple-entity slot for the horizontal abut test (or miss on 255).
Test_EntityHorizontal_ScanSlot 62264 LD A,(HL) Fetch this entity's type. Is it the table terminator (255)? If not, test the slot at Test_EntityHorizontal_CheckSlot.
62265 CP 255
62267 JR NZ,Test_EntityHorizontal_CheckSlot
62269 POP DE Restore DE and HL from the stack.
62270 POP HL
62271 SCF Signal a miss.
62272 RET Return.
Require a solid (bit 2) neighbour; skip room check for type 51.
Test_EntityHorizontal_CheckSlot 62273 LD A,(HL) Re-fetch the type. Is the slot empty? If so, skip to Test_EntityHorizontal_AdvanceSlot.
62274 OR A
62275 JR Z,Test_EntityHorizontal_AdvanceSlot
62277 BIT 7,A Is the high bit set (inactive)? If so, skip to Test_EntityHorizontal_AdvanceSlot.
62279 JR NZ,Test_EntityHorizontal_AdvanceSlot
62281 CP (IX+0) Is it the same type as the subject? If so, skip to Test_EntityHorizontal_AdvanceSlot.
62284 JR Z,Test_EntityHorizontal_AdvanceSlot
62286 LD B,A Keep the type in B.
62287 PUSH HL Stash HL on the stack.
62288 INC HL Advance onto flags byte 1.
62289 LD A,(HL) Fetch the flags.
62290 AND %00000100 Keep only the solid/platform bit (bit 2).
62292 JR Z,Test_EntityHorizontal_Reject If it was clear, reject at Test_EntityHorizontal_Reject.
62294 BIT 5,(HL) Is bit 5 set? If so, reject at Test_EntityHorizontal_Reject.
62296 JR NZ,Test_EntityHorizontal_Reject
62298 INC HL Advance past the room/y/y-extent fields onto the room-check byte.
62299 INC HL
62300 INC HL
62301 LD A,B Keep the candidate type in A. Is it type 51 (skip room check)?.
62302 CP 51
62304 JR Z,Test_EntityHorizontal_CheckBounds If so, take the bounds check at Test_EntityHorizontal_CheckBounds.
62306 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_EntityHorizontal_Reject.
62307 SUB C
62308 CP (IX+4)
62311 JR NZ,Test_EntityHorizontal_Reject
Confirm vertical overlap and X-extent abutment with the subject.
Test_EntityHorizontal_CheckBounds 62313 INC HL Advance onto the entity's y-coordinate.
62314 LD A,(IX+6) Does the subject's y-extent (IX+6) reach this candidate y? If not, reject at Test_EntityHorizontal_Reject.
62317 CP (HL)
62318 JR C,Test_EntityHorizontal_Reject
62320 INC HL Advance onto the entity's y-extent.
62321 LD A,(HL) Does this candidate y-extent reach the subject's y (IX+5)? If not, reject at Test_EntityHorizontal_Reject.
62322 CP (IX+5)
62325 JR C,Test_EntityHorizontal_Reject
62327 INC HL Advance HL past the x-coordinate onto the entity's x-extent.
62328 INC HL
62329 LD A,(IX+7) Fetch the subject's x (IX+7).
62332 DEC A Step it left by one.
62333 CP (HL) Does it equal this entity's x-extent (abutting on the left/right)? If not, jump to Test_EntityHorizontal_Reject.
62334 JR NZ,Test_EntityHorizontal_Reject
Horizontal neighbour hits: store the entity at Pointer_LastCollidedEntity and return its type.
62336 POP HL Restore HL from the stack.
62337 LD (29354),HL Store it at Pointer_LastCollidedEntity.
62340 XOR A Clear carry.
62341 LD A,(HL) Fetch the entity's type into A.
62342 POP DE Restore DE and HL from the stack.
62343 POP HL
62344 RET Return.
Reject this horizontal neighbour and continue the simple-entity walk.
Test_EntityHorizontal_Reject 62345 POP HL Restore HL from the stack.
Advance to the next simple-entity record in the horizontal scan.
Test_EntityHorizontal_AdvanceSlot 62346 ADD HL,DE Advance HL by one entity record.
62347 JR Test_EntityHorizontal_ScanSlot Jump to Test_EntityHorizontal_ScanSlot to test the next horizontal neighbour.
Prev: 62250 Up: Map Next: 62349