Prev: CA65 Up: Map Next: CAB4
CA8E: Trigger door opening or closing
Used by the routine at C8DC.
Door opening/closing has been triggered. Jump from C8EF if bit 5 (32) of item properties byte (EB4E) is set, after Maroc has bumped into a door handle. Check made using collision check routine at DFCD.
Can be triggered by:
  • Maroc bumping into a door to open or close it
  • Servant closing a door
  • Creature closing a door
  • Missile fired by a creature closing an open door (e.g. rebounding off Maroc's shield)
CA8E LD HL,($EB51) Door graphic address pointer in table at 97C3
CA91 LD E,(HL)
CA92 INC HL
CA93 LD D,(HL) Address pointer to actual door graphics, e.g. 9D38
CA94 EX DE,HL Swap into HL register pair
CA95 INC HL
CA96 LD B,(HL) Get X co-ordinate pixel offset for graphic tile
CA97 LD A,($EAD3) Get graphic's X co-ordinate pixel position on screen
CA9A ADD A,B Add the pixel offset for the graphic tile
CA9B LD D,A Store in D register
CA9C LD A,($EAD2) Get vertical (Y) pixel co-ordinate
CA9F SUB $10 The vertical co-ordinate starts at the bottom of the door, move up a bit to get to the door handle area
CAA1 LD E,A Store in E register
CAA2 LD C,$01 Collision/event type to check (1 = Door being opened/closed)
CAA4 CALL $DFCD Run a collision check (item/Maroc vs door handle)
CAA7 CP $00 Was there a collision?
CAA9 JR NZ,$CAF6 If not, jump out of this routine
A door handle has been touched so initialize door opening/closing
CAAB LD A,($EB4E) Door properties byte
CAAE AND $0F Keep bits 0-3
CAB0 OR $40 Set bit 6 (indicates door is now opening or closing)
CAB2 JR $CAF3
Prev: CA65 Up: Map Next: CAB4