Prev: 55553 Up: Map Next: 55616
55564: Check if Maroc is carrying too many objects
Used by the routine at 55553.
If Maroc collects a 4th object, either by moving over it or being given it by the servant, then he will automatically drop the next item in his inventory, as he can only carry 3.
After picking up a new object, the first byte of the next inventory slot is checked. If each (i.e. the 4th out of 4) slot contains a value of 4 (interactable object), Maroc has too many - he will drop this object being pointed at.
55564 LD HL,(60348) Get address pointer for Maroc's inventory at 32626
55567 LD A,(HL) Get first data byte of this set
55568 CP 0 This byte will be: 0 = Empty slot, or 4 = Interactable object
55570 JR Z,55616 If it's 0, it's fine - jump to the next routine
Maroc is carrying too many objects - drop the next one in the inventory slots:
First, copy the inventory item's data into the working data buffer:
55572 LD DE,60227 Pointer to start of item working data buffer
55575 LD BC,16 16 bytes
55578 LDIR Copy the item data
55580 LD HL,(60348) Get the first byte of the inventory data set for the item-about-to-be-dropped
Marked the item as dropped:
55583 LD (HL),0 Set the value as 0 as Maroc no longer has it
55585 LD A,(60238) Get the item properties byte
55588 OR %01001101 Set bit 0 (item is visible), bit 2 (item needs erasing before re-drawing), bit 3 (item is falling) and bit 6 (item can be carried)
55590 AND %11101101 Keep any other bits from the properties byte, resetting bit 1 (to indicate the item is not hidden) and 4 (to indicate the item is not being carried by the servant)
55592 LD (60238),A
55595 LD A,96 Set the vertical pixel position of the object to just below Maroc (this will always be the same screen position)
55597 LD (60234),A
55600 LD A,29 Set the horizontal (half-character/4-pixel) position of the object to Maroc's horizontal position (this will always be the same screen position)
55602 LD (60232),A
55605 CALL 56028 Fetch the item state and prepare graphics for printing
55608 CALL 57520 The item is now in the room, so copy the item details into one of the room item data sets at 31744
55611 LD (HL),255 Set an end-of-data marker at the start of the next room item data set
55613 LD (60274),HL Re-store the room item set address pointer.
Prev: 55553 Up: Map Next: 55616