Prev: 51813 Up: Map Next: 51892
51854: Trigger door opening or closing
Used by the routine at 51420.
Door opening/closing has been triggered. Jump from 51439 if bit 5 (32) of item properties byte (60238) is set, after Maroc has bumped into a door handle. Check made using collision check routine at 57293.
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)
51854 LD HL,(60241) Door graphic address pointer in table at 38851
51857 LD E,(HL)
51858 INC HL
51859 LD D,(HL) Address pointer to actual door graphics, e.g. 40248
51860 EX DE,HL Swap into HL register pair
51861 INC HL
51862 LD B,(HL) Get X co-ordinate pixel offset for graphic tile
51863 LD A,(60115) Get graphic's X co-ordinate pixel position on screen
51866 ADD A,B Add the pixel offset for the graphic tile
51867 LD D,A Store in D register
51868 LD A,(60114) Get vertical (Y) pixel co-ordinate
51871 SUB 16 The vertical co-ordinate starts at the bottom of the door, move up a bit to get to the door handle area
51873 LD E,A Store in E register
51874 LD C,1 Collision/event type to check (1 = Door being opened/closed)
51876 CALL 57293 Run a collision check (item/Maroc vs door handle)
51879 CP 0 Was there a collision?
51881 JR NZ,51958 If not, jump out of this routine
A door handle has been touched so initialize door opening/closing
51883 LD A,(60238) Door properties byte
51886 AND 15 Keep bits 0-3
51888 OR 64 Set bit 6 (indicates door is now opening or closing)
51890 JR 51955
Prev: 51813 Up: Map Next: 51892