![]() |
Routines |
| Prev: F2C2 | Up: Map | Next: F32A |
|
Used by the routines at Update_Berk_ReadControls, ScriptRoutine_TaskThreeSeekBerk, ScriptRoutine_VatRoomTransition and ScriptRoutine_CollectibleLeaveRoomUp.
As Test_EntityOverlap, but match entities whose room is one deeper than IX (room−01). Used when Berk moves forward into the next depth band.
|
||||||||
| Test_EntityOverlap_AtDepth | F2C7 | LD BC,$0001 | Load BC with 0001 (reject bit 05, then room−01). | |||||
|
This entry point is used by the routines at Test_EntityOverlap_AllowSpecial and Test_EntityOverlap.
Walk the simple-entity table for a collidable overlap with IX.
|
||||||||
| Test_EntityOverlap_Scan | F2CA | PUSH HL | Stash HL and DE on the stack. | |||||
| F2CB | PUSH DE | |||||||
| F2CC | LD DE,$000E | Each entity record is 000E bytes, then load that into DE. | ||||||
| F2CF | LD HL,$8B69 | Point HL at the simple entity table (StateData_SimpleEntities). | ||||||
|
Next simple-entity slot for the overlap test (or miss on FF).
|
||||||||
| Test_EntityOverlap_ScanSlot | F2D2 | LD A,(HL) | Fetch this entity's type. Is it the table terminator (FF)? If not, test the slot at Test_EntityOverlap_CheckSlot. | |||||
| F2D3 | CP $FF | |||||||
| F2D5 | JR NZ,Test_EntityOverlap_CheckSlot | |||||||
|
Simple-entity scan miss: restore registers and return carry set.
|
||||||||
| F2D7 | POP DE | Restore DE and HL from the stack. | ||||||
| F2D8 | POP HL | |||||||
| F2D9 | SCF | Signal a miss. | ||||||
| F2DA | RET | Return. | ||||||
|
Reject empty/inactive/same-type slots; require collidable bit 00 (and optional bit 05).
|
||||||||
| Test_EntityOverlap_CheckSlot | F2DB | LD A,(HL) | Re-fetch the type. Is the slot empty (type 00)? If so, skip to Test_EntityOverlap_AdvanceSlot. | |||||
| F2DC | OR A | |||||||
| F2DD | JR Z,Test_EntityOverlap_AdvanceSlot | |||||||
| F2DF | BIT 7,A | Is the high bit set (inactive)? If so, skip to Test_EntityOverlap_AdvanceSlot. | ||||||
| F2E1 | JR NZ,Test_EntityOverlap_AdvanceSlot | |||||||
| F2E3 | CP (IX+$00) | Is it the same type as the subject? If so, skip to Test_EntityOverlap_AdvanceSlot. | ||||||
| F2E6 | JR Z,Test_EntityOverlap_AdvanceSlot | |||||||
| F2E8 | PUSH HL | Stash HL on the stack. | ||||||
| F2E9 | INC HL | Advance onto flags byte 1. | ||||||
| F2EA | LD A,(HL) | Fetch flags byte 1. | ||||||
| F2EB | AND %00000001 | Keep only the collidable bit (bit 00). | ||||||
| F2ED | JR Z,Test_EntityOverlap_Reject | If it was clear, reject at Test_EntityOverlap_Reject. | ||||||
| F2EF | BIT 0,B | Has the caller allowed bit-05 entities (B bit 00)? If so, skip the bit-05 reject at Test_EntityOverlap_CheckBounds. | ||||||
| F2F1 | JR NZ,Test_EntityOverlap_CheckBounds | |||||||
| F2F3 | BIT 5,(HL) | Is bit 05 set on this entity? If so, reject at Test_EntityOverlap_Reject. | ||||||
| F2F5 | JR NZ,Test_EntityOverlap_Reject | |||||||
|
Require matching room (minus C) and overlapping y/x extents with IX.
|
||||||||
| Test_EntityOverlap_CheckBounds | F2F7 | INC HL | Advance HL past the unused entity fields onto the room byte. | |||||
| F2F8 | INC HL | |||||||
| F2F9 | INC HL | |||||||
| F2FA | LD A,(HL) | Fetch the entity's room. | ||||||
| F2FB | SUB C | Subtract the caller's room bias in C. | ||||||
| F2FC | CP (IX+$04) | Does it match the subject's room (IX+04)? If not, jump to Test_EntityOverlap_Reject. | ||||||
| F2FF | JR NZ,Test_EntityOverlap_Reject | |||||||
| F301 | INC HL | Advance onto the entity's y-coordinate. | ||||||
| F302 | LD A,(IX+$06) | Does the subject's y-extent (IX+06) reach this candidate y? If not, reject at Test_EntityOverlap_Reject. | ||||||
| F305 | CP (HL) | |||||||
| F306 | JR C,Test_EntityOverlap_Reject | |||||||
| F308 | INC HL | Advance onto the entity's y-extent. | ||||||
| F309 | LD A,(HL) | Does this candidate y-extent reach the subject's y (IX+05)? If not, reject at Test_EntityOverlap_Reject. | ||||||
| F30A | CP (IX+$05) | |||||||
| F30D | JR C,Test_EntityOverlap_Reject | |||||||
| F30F | INC HL | Advance onto the entity's x-coordinate. | ||||||
| F310 | LD A,(IX+$08) | Does the subject's x-extent (IX+08) reach this candidate x? If not, reject at Test_EntityOverlap_Reject. | ||||||
| F313 | CP (HL) | |||||||
| F314 | JR C,Test_EntityOverlap_Reject | |||||||
| F316 | INC HL | Advance onto the entity's x-extent. | ||||||
| F317 | LD A,(HL) | Does this candidate x-extent reach the subject's x (IX+07)? If not, reject at Test_EntityOverlap_Reject. | ||||||
| F318 | CP (IX+$07) | |||||||
| F31B | JR C,Test_EntityOverlap_Reject | |||||||
|
Hit: remember the entity and return its type with carry clear.
|
||||||||
| F31D | POP HL | Restore HL from the stack. | ||||||
| F31E | XOR A | Clear A / carry. | ||||||
| F31F | LD ($72AA),HL | Store the entity pointer at Pointer_LastCollidedEntity. | ||||||
| F322 | LD A,(HL) | Fetch the entity's type into A. | ||||||
| F323 | POP DE | Restore DE and HL from the stack. | ||||||
| F324 | POP HL | |||||||
| F325 | RET | Return. | ||||||
|
Reject this overlap candidate and continue the simple-entity walk.
|
||||||||
| Test_EntityOverlap_Reject | F326 | POP HL | Restore HL from the stack. | |||||
|
Advance to the next simple-entity record in the overlap scan.
|
||||||||
| Test_EntityOverlap_AdvanceSlot | F327 | ADD HL,DE | Advance HL by one entity record. | |||||
| F328 | JR Test_EntityOverlap_ScanSlot | Jump to Test_EntityOverlap_ScanSlot to test the next simple entity. | ||||||
| Prev: F2C2 | Up: Map | Next: F32A |