Prev: 36579 Up: Map Next: 36763
36717: PickNextRoom
Used by the routines at 36457, 36579, 37018, 37992, 39400 and 40826.
Choose the destination room for the actor whose record IX points at, and store it in record byte +2. The actor's current room is byte +1; bit 6 of +1 selects which network it is travelling in.
36717 LD A,(IX+1) A = actor's current room (bit 6 = duct network)
36720 LD HL,29171 assume corridor adjacency map (RoomAdjCorridors)
36723 BIT 6,A travelling in the ducts?
36725 JR Z,36732 no: keep corridor map
36727 LD HL,29346 yes: use duct map (RoomAdjDucts)
36730 AND 63 strip the network flag -> room ID 0-33
36732 LD E,A
36733 LD D,0
36735 LD B,5
36737 ADD HL,DE
36738 DJNZ 36737 HL = map + room*5 (the room's 5 direction slots)
36740 PUSH HL
36741 CALL 33589 AdvanceScriptPtr: next ROM script nibble
36744 CALL 36763 ScriptNibbleToDirection: nibble -> slot 0-4
36747 LD E,A
36748 POP HL
36749 ADD HL,DE
36750 LD A,(HL) A = destination room for that direction
36751 BIT 6,(IX+1) moving through the ducts?
36755 JR Z,36759
36757 OR 64 yes: tag the destination with the duct flag
36759 LD (IX+2),A record +2 = destination room
36762 RET
Prev: 36579 Up: Map Next: 36763