Prev: 53080 Up: Map Next: 53273
53145: Warlock or creature - materialization & disintegration events
Used by the routine at 52616.
Materialization or disintegration routine - warlocks/demons materializing, or creatures disintegrating.
This routine determines the post-materialization/disintegration actions to take. This information is held in bits 5-7 of the creature properties byte (60238).
53145 LD A,(60240) Graphic frame number/offset
53148 AND 7 Only bits 0-2 (values 0-7) needed for the number of frames
53150 CP 7 There are 6 animation frames in the materialization graphics (43079). Have we reached frame #7?
53152 JP NZ,53885 If not, jump out of routine at this point
Final materialization/disintegration frame has been reached.
53155 LD A,(60238) Creature/room item properties byte
53158 LD C,A Temp store in C register
53159 AND 7 Filter out/resets bits 4-7
53161 OR 5 Set bits 0 (indicating creature is on-screen) and 2 (indicating creature will need to be erased before drawing)
53163 LD (60238),A ...and re-store.
This routine is running because bit 5, 6 or 7 of the item (creature) properties byte (60238) is set. This bit indicates what action to take after a creature materialization or disintegration animation.
53166 LD A,C Retrieve item (creature) properties byte
53167 AND 128 Bit 7 of properties byte set = trigger WARLOCK/DEMON APPEARANCE after materialization animation is complete
53169 JR NZ,53178
53171 LD A,C
53172 AND 64 Bit 6 of properties byte set = trigger warlock DISAPPEARANCE post-materialization animation (52873) - e.g. successful object trade
53174 JR NZ,53192
53176 JR 53232 (If not either of the above) - Bit 5 of properties byte set = trigger CREATURE REMOVAL post-disintegration animation
Creature has just materialized - setup graphic for this creature:
53178 LD A,1 Set graphic frame number/offset at 1 (first frame/no frame offset)
53180 LD (60240),A
53183 LD A,(60331) Graphic number (offset for address pointers in table at 38851)
53186 CALL 57538 Set up creature graphics
53189 JP 53885
Warlock has been successfully traded with - remove warlock and initialize object trade
53192 LD A,0 Set creature type to 0 (nothing to setup/draw)
53194 LD (60227),A
53197 LD A,224 Timer indicating how long before a warlock is likely to materialize in the current room
53199 LD (60340),A The warlocks will still appear again after a successful trade, but it'll be some time
Warlock has gone - either off-screen, or disappeared after being traded an object successfully:
53202 LD A,0
53204 LD (60333),A Set warlock 'aggression' (likelihood of firing a missile at Maroc) to 0 (as it's gone)
53207 LD A,(60342) Count of creatures in current room
53210 DEC A ...reduce by 1...
53211 LD (60342),A ...and re-store.
53214 LD A,(60334) Check if the warlock is carrying an object
53217 CP 0
53219 JP Z,53885
53222 LD (60230),A ...If so, copy the item set number into the warlock's data set
53225 LD A,0
53227 LD (60334),A ...and set the held item data buffer byte to 0
53230 JR 53273 ...then skip over to the next routine
Creature has been destroyed - remove from existence:
53232 LD A,0
53234 LD (60227),A Set creature type to 0 (no creature to deal with any more)
53237 LD HL,(60228) Get address pointer to relevant creature/warlock data set at 27772
53240 INC HL
53241 INC (HL) Increment the second byte of the set. This byte holds the number of these creatures Maroc has destroyed
53242 LD A,(60342) Reduce count of creatures in current room by 1
53245 DEC A
53246 LD (60342),A Get creature type
53249 LD A,(60230)
53252 CP 8
53254 JP NC,53885 If creature >=8, it's not a warlock so jump out of the routine here
53257 LD A,0 Creature destroyed is a warlock. Set warlock 'aggression' (likelihood of firing a missile at Maroc) to 0, as the warlock is no more.
53259 LD (60333),A
If a warlock is destroyed, it will drop the object it's carrying
53262 LD A,(60328) Get object number carried by the warlock
53265 CP 0
53267 LD (60230),A ...Copy this value into the warlock's data buffer
53270 JP Z,53885 If the warlock isn't carrying anything, can jump out at this point
Prev: 53080 Up: Map Next: 53273