Routines
| Prev: DEC1 | Up: Map | Next: DF02 |
DED9: Pre-check for PUT IN: will the thing fit in the container?
|
Sets IX to the thing being moved ($A013), IY to the container ($A015) and A to the container's id, then falls into the fit check at DEE4 - which the SIT IN / GET INTO pre-check (E3F5) also jumps into with different registers (IX = the actor, IY = the chair): a shared tail.
DEE4 refuses if none of bits 0-2 of the container's field +4 are set (it cannot hold things). Otherwise it fits if capacity - size - what's already inside is at least 1, where capacity and size are both field +2 and D2ED totals what is already inside.
Holmes (size 96) gets into Watson's armchair (capacity 255) even with Watson in it (D2ED returns 96): 255-96-96 = 63.
|
||||||||||||||||||||
| DED9 | LD IX,($A013) | IX = the thing being put somewhere | ||||||||||||||||||
| DEDD | LD IY,($A015) | IY = the container | ||||||||||||||||||
| DEE1 | LD A,($A035) | A = the container's id | ||||||||||||||||||
|
This entry point is used by the routine at E3F5.
|
||||||||||||||||||||
| DEE4 | LD B,A | B = the container's id. Can the container hold things? | ||||||||||||||||||
| DEE5 | LD A,(IY+$04) | Read the type byte (+4) of the thing record at IY into A | ||||||||||||||||||
| DEE8 | AND $07 | Keep only bits 0, 1, 2 of A (mask $07) | ||||||||||||||||||
| DEEA | JP Z,$DC15 | No: refuse | ||||||||||||||||||
| DEED | LD A,(IY+$02) | Capacity minus the size of the thing... | ||||||||||||||||||
| DEF0 | SUB (IX+$02) | Subtract the size byte (+2) of the thing record at IX from A | ||||||||||||||||||
| DEF3 | JR C,$DF00 | ...too big even for an empty container? Refuse | ||||||||||||||||||
| DEF5 | PUSH AF | Save AF on the stack | ||||||||||||||||||
| DEF6 | LD A,B | How much is already inside the container? | ||||||||||||||||||
| DEF7 | CALL $D2ED | Call the routine "Total size (+2) of the things directly in thing A" (D2ED) | ||||||||||||||||||
| DEFA | LD B,A | Copy A into B | ||||||||||||||||||
| DEFB | POP AF | Restore AF from the stack | ||||||||||||||||||
| DEFC | SUB B | Take that off too | ||||||||||||||||||
| DEFD | JR C,$DF00 | Not enough room: refuse | ||||||||||||||||||
| DEFF | RET NZ | At least 1 to spare: it fits (NZ) | ||||||||||||||||||
| DF00 | XOR A | Exactly full also refuses (Z) | ||||||||||||||||||
| DF01 | RET | Return to the caller | ||||||||||||||||||
| Prev: DEC1 | Up: Map | Next: DF02 |