Prev: CAB4 Up: Map Next: CB4C
CB00: Set up 'interactable' objects in current room
Used by the routine at C89F.
Deal with any objects from the room item table at 6790 that are present in the room. These are 'non-scenery' objects that Maroc or the servant can interact with.
This routine determines if an item is stationary (sitting on the floor of the room), carried by the servant, or falling/flying after being dropped by the servant.
CB00 LD HL,($EB44) Get item's data pointer for the room item table at 736F
CB03 CALL $DE7F Check room object table at 736F to see if any items are in this room. If so, copy the item data into working buffer at EB85.
CB06 LD A,($EB90) For visible room objects, this is the graphic number (offset for address table at 97C3)
CB09 CP $7C Byte value 124 = the object is not visible (yet),e.g. a key inside a chest
CB0B JR Z,$CB15
Object is visible on screen - get object's colour
CB0D LD A,($EB8B) Get the colour attribute of the object
CB10 AND $0F Keep the INK colour (0-7), and bit 3, which is set for objects that flash (change colour)
CB12 LD ($EAA8),A ...and store
Check if item is being carried by the servant
CB15 LD A,($EB4E) Item properties byte
CB18 LD C,A Temp store in C register
CB19 AND $10 Check if this item is carried by the servant - bit 4 (16) set
CB1B JR NZ,$CB25 If so, check/calculate item position based on servant's X/Y co-ordinates
Item is not being carried by the servant
CB1D LD A,C Retrieve item properties byte
CB1E AND $08 If bit 3 is set, this item is moving/falling (e.g. after being thrown/dropped by the servant)
CB20 JR NZ,$CB5B Item is moving/falling - jump out to CB5B
CB22 JP $CBA8 Item is stationary - jump out to CBA8
Item is currently held by the servant
CB25 LD A,($EAEC) Get active spell number
CB28 CP $01 Check is the servant spell still active?
CB2A JR NZ,$CB4C If not, servant spell has just been deactivated, so the item is now falling/flying
CB2C CALL $DAC8 If active, run routine calculating/checking item's vertical position on screen. Adjusted vertical boundary returned in E register ready for room boundary check at CB3F
Servant is carrying the object, so use the servant's horizontal/vertical speed to calculate that of the object (multiplied x4 as servant speed is stored on a smaller scale):
CB2F LD A,($EB01) Get servant's horizontal movement rate/offset
CB32 ADD A,A Multiply by 4
CB33 ADD A,A
CB34 LD ($EB4C),A ...and store as item's horizontal movement rate/offset
CB37 LD A,($EB02) Get servant's vertical movement rate/offset
CB3A ADD A,A Multiply by 4
CB3B ADD A,A
CB3C LD ($EB4D),A ...and store as item's vertical movement rate/offset
CB3F CALL $E039 Check room boundary and adjust item's position accordingly
CB42 LD A,($EBB1)
CB45 CP $02 This carried object status byte was set to 2 once an item has been retrieved from Maroc's backpack by the servant
CB47 JR Z,$CB96 If this is the case, do a collision check to identify if the servant has moved outside Maroc's backpack area 'hit box' (to prevent auto-cycling through inventory objects).
If so, change the byte value (EBB1) to 1
CB49 JP $CC27
Prev: CAB4 Up: Map Next: CB4C