Prev: CCA8 Up: Map Next: CD21
CCDD: Maroc has picked up an item
Used by the routine at CC72.
There are 4 inventory slots in Maroc's backpack (7F72). However, he can only carry 3 objects.
The 4th consecutive slot is used as an 'overflow' slot. This is checked later at D90C. If there's an object in it, Maroc will immediately drop it. So Maroc can actually - but (very) temporarily - carry 4 objects.
Add the collected object to Maroc's inventory:
CCDD LD HL,($EBBC) Address pointer to current slot of Maroc's inventory at 7F72
CCE0 LD A,(HL)
CCE1 CP $00 Empty inventory slot?
CCE3 JP NZ,$CD85 If the slot isn't empty, it may be that the servant has moved the object over Maroc's backpack (rather than Maroc picking it up himself).
If so, and the servant moves slowly enough, it can swap the carried object with the next one in the inventory - so go and check if this is the case.
Empty inventory slot has been found:
CCE6 LD A,($EB4E) Get the item properties byte
CCE9 LD C,A
CCEA AND $10 Is the item being carried by the servant (if bit 4 is set)?
CCEC JR Z,$CCF9 If not, skip next few instructions
The servant has just put the item in Maroc's backpack. Set item status to 'not carried by servant'
CCEE LD A,C Retrieve item properties byte
CCEF AND $EF Object is now in Maroc's backpack, so reset bit 4 of its properties byte, as it's no longer carried by the servant.
CCF1 LD ($EB4E),A ...and re-store the item properties byte
CCF4 LD A,$00
CCF6 LD ($EBB1),A Set the 'servant-carrying-item' flag to zero
Copy 16 bytes of the item's data from the working buffer at EB43 into the inventory slot (at 7F72).
Then move the inventory address pointer to the next available slot.
Next time the servant moves over Maroc's backpack, it will retrieve the next consecutive object.
CCF9 EX DE,HL Swap inventory address pointer into DE register pair
CCFA LD HL,$EB43 Start of item working data buffer
CCFD LD BC,$0010
CD00 LDIR Copy 16 bytes of item data into inventory slot
CD02 EX DE,HL HL register pair is now pointing to the start of the next inventory slot
CD03 LD A,(HL)
CD04 CP $FF Are we at the end of the 4 inventory slots?
CD06 JR NZ,$CD0B
CD08 LD HL,($EBBA) If so, switch the inventory pointer back to inventory slot 1
CD0B LD ($EBBC),HL Store inventory slot pointer
The next few instructions check if the spell number is >=224. If so a value (240) is subtracted, which sets the amount to increase/decrease Maroc's energy by (from -16 to +15).
No object/spell number is close to this value. It's likely that it was added for the collection of energy giving/reducing items (e.g. food), but not used in favour of the other better energy routines.
CD0E LD A,($EB8A) Get the spell number (normally will be 0 for objects)
CD11 CP $E0
CD13 JR C,$CD1A
CD15 SUB $F0 If >=224, subtract 240 (would give a value of -16 to +15)...
CD17 CALL $E3CC ...and increase/decrease Maroc's energy accordingly
This object has now been collected:
CD1A LD A,$00
CD1C LD ($EB43),A Set it's object type to 0, as it's in Maroc's inventory and no longer in the room
CD1F JR $CD85
Prev: CCA8 Up: Map Next: CD21