Prev: 57990 Up: Map Next: 58064
58032: Copy room item event data into working buffer
Used by the routines at 52263, 52616 and 53403.
Input
A Event number involving this object (stored at 60303)
Also used for energy-affecting objects, e.g. orbs and mushrooms, 254 = energy drain, 253 = energy replenish
Uses room item event data sets at 32691 that will need checking for certain items/objects in the current room.
58032 LD C,A Copy event number ID into C register
58033 LD A,(60116) Horizontal position of object (high byte). This is 0 if object is on-screen. 1 means off-screen to the right, 255 means off-screen to the left.
58036 CP 0 If it's 0, it's on the current screen (viewport)
58038 JR NZ,58063 If not, this item is off-screen so no collisions/interactions with this object will need checking - jump straight to RET
58040 LD HL,(60077) Pointer to the event data sets at 32691
58043 LD (HL),2 Set the first byte of the set to 2, which means the event will be checked for 2 game cycles, mainly in case items are moving around.
58045 INC HL Move along one byte
58046 LD (HL),C Byte 2 of set - the event/interaction identifier/value to check for this item
58047 INC HL
58048 LD A,(60115) Byte 3 of set - item's horizontal screen position (in pixels)
58051 LD (HL),A
58052 INC HL
58053 LD A,(60114) Byte 4 of set - item's vertical position (in pixels)
58056 LD (HL),A
58057 INC HL The event table is dynamic - it can shrink/expand and is recaculated each frame, so put a 255 at the start of the next set to mark the end of item sets
58058 LD (HL),255
58060 LD (60077),HL Restore the address pointer at the start of this next set
58063 RET
Prev: 57990 Up: Map Next: 58064