![]() |
Routines |
| Prev: F32A | Up: Map | Next: F38D |
|
Used by the routines at Berk_Interact_With_Entity and ScriptRoutine_TaskThreeClearUpstairs.
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.
|
||||||||
| Test_EntityOnRight | F32E | LD C,$01 | Load C with 01 (room−01 / right bias). | |||||
|
This entry point is used by the routine at Test_EntityOnLeft.
Walk StateData_SimpleEntities for a solid (bit 02) entity abutting IX horizontally.
|
||||||||
| Test_EntityHorizontal_Scan | F330 | PUSH HL | Stash HL and DE on the stack. | |||||
| F331 | PUSH DE | |||||||
| F332 | LD DE,$000E | Each entity record is 000E bytes, then load that into DE. | ||||||
| F335 | LD HL,$8B69 | Point HL at the simple entity table (StateData_SimpleEntities). | ||||||
|
Next simple-entity slot for the horizontal abut test (or miss on FF).
|
||||||||
| Test_EntityHorizontal_ScanSlot | F338 | LD A,(HL) | Fetch this entity's type. Is it the table terminator (FF)? If not, test the slot at Test_EntityHorizontal_CheckSlot. | |||||
| F339 | CP $FF | |||||||
| F33B | JR NZ,Test_EntityHorizontal_CheckSlot | |||||||
| F33D | POP DE | Restore DE and HL from the stack. | ||||||
| F33E | POP HL | |||||||
| F33F | SCF | Signal a miss. | ||||||
| F340 | RET | Return. | ||||||
|
Require a solid (bit 02) neighbour; skip room check for type 33.
|
||||||||
| Test_EntityHorizontal_CheckSlot | F341 | LD A,(HL) | Re-fetch the type. Is the slot empty? If so, skip to Test_EntityHorizontal_AdvanceSlot. | |||||
| F342 | OR A | |||||||
| F343 | JR Z,Test_EntityHorizontal_AdvanceSlot | |||||||
| F345 | BIT 7,A | Is the high bit set (inactive)? If so, skip to Test_EntityHorizontal_AdvanceSlot. | ||||||
| F347 | JR NZ,Test_EntityHorizontal_AdvanceSlot | |||||||
| F349 | CP (IX+$00) | Is it the same type as the subject? If so, skip to Test_EntityHorizontal_AdvanceSlot. | ||||||
| F34C | JR Z,Test_EntityHorizontal_AdvanceSlot | |||||||
| F34E | LD B,A | Keep the type in B. | ||||||
| F34F | PUSH HL | Stash HL on the stack. | ||||||
| F350 | INC HL | Advance onto flags byte 1. | ||||||
| F351 | LD A,(HL) | Fetch the flags. | ||||||
| F352 | AND %00000100 | Keep only the solid/platform bit (bit 02). | ||||||
| F354 | JR Z,Test_EntityHorizontal_Reject | If it was clear, reject at Test_EntityHorizontal_Reject. | ||||||
| F356 | BIT 5,(HL) | Is bit 05 set? If so, reject at Test_EntityHorizontal_Reject. | ||||||
| F358 | JR NZ,Test_EntityHorizontal_Reject | |||||||
| F35A | INC HL | Advance past the room/y/y-extent fields onto the room-check byte. | ||||||
| F35B | INC HL | |||||||
| F35C | INC HL | |||||||
| F35D | LD A,B | Keep the candidate type in A. Is it type 33 (skip room check)?. | ||||||
| F35E | CP $33 | |||||||
| F360 | JR Z,Test_EntityHorizontal_CheckBounds | If so, take the bounds check at Test_EntityHorizontal_CheckBounds. | ||||||
| F362 | 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. | ||||||
| F363 | SUB C | |||||||
| F364 | CP (IX+$04) | |||||||
| F367 | JR NZ,Test_EntityHorizontal_Reject | |||||||
|
Confirm vertical overlap and X-extent abutment with the subject.
|
||||||||
| Test_EntityHorizontal_CheckBounds | F369 | INC HL | Advance onto the entity's y-coordinate. | |||||
| F36A | LD A,(IX+$06) | Does the subject's y-extent (IX+06) reach this candidate y? If not, reject at Test_EntityHorizontal_Reject. | ||||||
| F36D | CP (HL) | |||||||
| F36E | JR C,Test_EntityHorizontal_Reject | |||||||
| F370 | INC HL | Advance onto the entity's y-extent. | ||||||
| F371 | LD A,(HL) | Does this candidate y-extent reach the subject's y (IX+05)? If not, reject at Test_EntityHorizontal_Reject. | ||||||
| F372 | CP (IX+$05) | |||||||
| F375 | JR C,Test_EntityHorizontal_Reject | |||||||
| F377 | INC HL | Advance HL past the x-coordinate onto the entity's x-extent. | ||||||
| F378 | INC HL | |||||||
| F379 | LD A,(IX+$07) | Fetch the subject's x (IX+07). | ||||||
| F37C | DEC A | Step it left by one. | ||||||
| F37D | CP (HL) | Does it equal this entity's x-extent (abutting on the left/right)? If not, jump to Test_EntityHorizontal_Reject. | ||||||
| F37E | JR NZ,Test_EntityHorizontal_Reject | |||||||
|
Horizontal neighbour hits: store the entity at Pointer_LastCollidedEntity and return its type.
|
||||||||
| F380 | POP HL | Restore HL from the stack. | ||||||
| F381 | LD ($72AA),HL | Store it at Pointer_LastCollidedEntity. | ||||||
| F384 | XOR A | Clear carry. | ||||||
| F385 | LD A,(HL) | Fetch the entity's type into A. | ||||||
| F386 | POP DE | Restore DE and HL from the stack. | ||||||
| F387 | POP HL | |||||||
| F388 | RET | Return. | ||||||
|
Reject this horizontal neighbour and continue the simple-entity walk.
|
||||||||
| Test_EntityHorizontal_Reject | F389 | POP HL | Restore HL from the stack. | |||||
|
Advance to the next simple-entity record in the horizontal scan.
|
||||||||
| Test_EntityHorizontal_AdvanceSlot | F38A | ADD HL,DE | Advance HL by one entity record. | |||||
| F38B | JR Test_EntityHorizontal_ScanSlot | Jump to Test_EntityHorizontal_ScanSlot to test the next horizontal neighbour. | ||||||
| Prev: F32A | Up: Map | Next: F38D |