Prev: 52136 Up: Map Next: 52338
52263: Check and change object state after positive events match/collision
Used by the routines at 51968, 52059, 52118 and 52136.
'Interactions' in Avalon are based on matching event values. For example:
  • using a (particular) key on a (particular) chest
  • using a spell on a room object, e.g. OPEN/UNLOCK
  • using an object on another object (e.g. flashing star on the floor marking in room 2)
Items that can be affected by other actions/items have extra data in the room item table (29551). This additional data indicates the next 'state' of the item (e.g. closed chest > open chest)
Some items are hidden until another item is used (in the aforementioned case of chests holding objects).
A successful value match between the acting item, and the item acted upon, advances the state of the object to the next one.
52263 LD A,(60303) Event number ID to check for this item (acting on another item, e.g. a key opening its corresponding chest)
52266 CP 0
52268 JR Z,52278 If zero, there's nothing to check
52270 CP 137
52272 JP Z,55944 Special check for event/collision #137 - Maroc using CALIBURN on AVELACH. This ends the game.
52275 CALL 58032 Copy room item event data into working buffer
Event/collision checking:
52278 LD A,(60302) Event number for items acting on this item (e.g. for a chest, which is opened by a key)
52281 LD C,A
52282 CP 15 Event 15 means an item is collectible (Maroc can pick it up)
52284 JP Z,52338 If so, check if Maroc has picked up the item, either by moving over it or given it by the servant
52287 CALL 57293 For all other events, run an event check for this item
52290 CP 1 Has a collision/event occurred?
52292 JP NZ,52338 If not, skip to the next routine
EVENT/COLLISION HAS TAKEN PLACE
For the object acted upon, advance its 'state' by one, to the next state:
52295 LD A,(60300) Grab the byte containing the number of 'states' for the object
52298 LD C,A
52299 LD A,(60297) Current object state number (starts at 1 for default object state)
52302 INC A Increment object state by one
52303 CP C
52304 JR C,52310
52306 JR Z,52310 Object state <= max states for this item, skip the next instruction
52308 LD A,1 Object state > max states for this item, so reset the object state to 1
52310 LD HL,(60228) Address pointer to start of item's data set at 29551
52313 INC HL
52314 INC HL
52315 INC HL
52316 INC HL Move to the 5th byte of set, containing the item's state number
52317 LD (HL),A ...and store the new state number.
52318 CALL 56028 Fetch object state and prepare graphics for printing
Set properties for the new object state
52321 LD A,(60301) Get first byte of object state data
52324 AND 248 Filter out bits 0-2 (values 0-7)
52326 LD C,A
52327 LD A,(60238) Get the current item properties byte
52330 AND 31 Keep bits 0-4...
52332 OR 5 Set bits 0 (item is visible) and 2 (item is moving/will need erasing)
52334 OR C ...append the rest of the bits from the new-state-object...
52335 LD (60238),A ...and re-store.
Prev: 52136 Up: Map Next: 52338