Prev: 55233 Up: Map Next: 55404
55349: Move the lift to a random floor if Magic Knight is not nearby
Used by the routine at 54996.
55349 LD A,(65529) Load Magic Knight's current room into A
55352 OR A Return if Magic Knight is in the lift (room 0)...
55353 RET Z ...
55354 DEC A Return if Magic Knight is in a room that connects with the lift...
55355 AND 7 ...
55357 RET Z ...
55358 LD B,6 Load A with a random number less than or equal to 6...
55360 CALL 38505 ...
55363 LD B,A Copy random number into B
55364 LD A,(23411) Load A with game progress flags, part 1
55367 AND 1 If the lift is fixed...
55369 JR NZ,55378 ...then jump to 55378
55371 LD A,B Else copy random number back to A
55372 CP 5 If random number is 5 or 6 then return...
55374 RET Z ...
55375 CP 6 ...
55377 RET Z ...
55378 PUSH BC Store BC...
55379 CALL 33770 ...set the lift as not being at any floor at all...
55382 POP AF ...and restore BC value to AF
55383 LD (23382),A Set lift control panel light corresponding with previous randomly generated number to glow
55386 ADD A,A Multiply A by eight...
55387 ADD A,A ...
55388 ADD A,A ...
55389 INC A ...and add one to get first room on "random" floor
55390 LD (41712),A Set right-exit of lift to first room on floor
55393 ADD A,A Double room number
55394 LD D,0 Load into DE...
55396 LD E,A ...
55397 LD HL,41711 Point HL at start of room connectivity data
55400 ADD HL,DE Add offset for left-exit of first room on random floor...
55401 LD (HL),0 ...and set this exit to lead to the lift
55403 RET Return
Prev: 55233 Up: Map Next: 55404