Prev: D901 Up: Map Next: D940
D90C: Check if Maroc is carrying too many objects
Used by the routine at D901.
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.
D90C LD HL,($EBBC) Get address pointer for Maroc's inventory at 7F72
D90F LD A,(HL) Get first data byte of this set
D910 CP $00 This byte will be: 0 = Empty slot, or 4 = Interactable object
D912 JR Z,$D940 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:
D914 LD DE,$EB43 Pointer to start of item working data buffer
D917 LD BC,$0010 16 bytes
D91A LDIR Copy the item data
D91C LD HL,($EBBC) Get the first byte of the inventory data set for the item-about-to-be-dropped
Marked the item as dropped:
D91F LD (HL),$00 Set the value as 0 as Maroc no longer has it
D921 LD A,($EB4E) Get the item properties byte
D924 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)
D926 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)
D928 LD ($EB4E),A
D92B LD A,$60 Set the vertical pixel position of the object to just below Maroc (this will always be the same screen position)
D92D LD ($EB4A),A
D930 LD A,$1D Set the horizontal (half-character/4-pixel) position of the object to Maroc's horizontal position (this will always be the same screen position)
D932 LD ($EB48),A
D935 CALL $DADC Fetch the item state and prepare graphics for printing
D938 CALL $E0B0 The item is now in the room, so copy the item details into one of the room item data sets at 7C00
D93B LD (HL),$FF Set an end-of-data marker at the start of the next room item data set
D93D LD ($EB72),HL Re-store the room item set address pointer.
Prev: D901 Up: Map Next: D940