Prev: 53703 Up: Map Next: 53861
53731: Move character whose turn it is to move, if allowed
Alternate characters move in opposite directions on alternate days.
Used by the routine at 53498.
Input
IY 23610
53731 CALL 53871 Update index of character whose turn it is to be updated and load into A
53734 LD E,6 Point HL at this character's flags...
53736 CALL 33541 ...
53739 LD A,(HL) ...and load flags into A
53740 AND 192 If character is asleep, or character can't move...
53742 RET NZ ...then return
53743 LD E,2 Point HL at Gordon's stamina (A=0)... (see trivia)
53745 CALL 33541 ...
53748 LD A,(HL) ...and load into A
53749 BIT 7,A If bit 7 of Gordon's stamina is set...
53751 RET NZ ...then return
53752 LD A,(23455) Load BC with three times index of character whose turn it is to be updated...
53755 LD C,A ...
53756 ADD A,A ...
53757 ADD A,C ...
53758 LD C,A ...
53759 LD B,0 ...
53761 LD HL,25244 Point HL at start of table of characters' current positions at 25244
53764 ADD HL,BC Add BC to HL as offset
53765 LD A,(23701) If Magic Knight is not in the same room as this character...
53768 CP (HL) ...
53769 JP NZ,53777 ...then skip ahead to 53777
53772 BIT 1,(IY+65) If characters-free-to-move flag is reset...
53776 RET Z ...then return
53777 LD A,(23455) Load B with index of character whose turn it is to be updated...
53780 LD B,A ...
53781 LD A,(23457) Load A with number of days left...
53784 ADD A,B ...and add index of character to be updated
53785 BIT 0,A If result is even...
53787 JP Z,53824 ...then skip ahead to 53824
Move character left
53790 LD A,(HL) Load A with character's current room
53791 PUSH HL Store HL (pointer to character's current room)
53792 LD HL,37022 Point HL to left exit value of first entry in room connectivity data table
53795 CALL 53861 Get index of destination room for character and load into A and instruction at 53812
53798 LD (53813),A Load value into instruction at 53812 (see trivia)
53801 POP HL Restore HL (pointer to character's current room)
53802 INC HL Advance HL to character's x-coordinate
53803 LD A,(HL) Load x-coordinate into A...
53804 DEC A ...and decrease
53805 CALL 53886 If character has a disallowed x-coordinate in the "barrier room" then return to routine that called this one
53808 OR A If character's x-coordinate is not zero...
53809 JP NZ,53859 ...then skip ahead to 53859
The operand of the instruction at 53812 represents the character's destination room when moving left. This is modified by the instructions at 53798 and 53867.
53812 LD A,0 Load B with character's destination room...
53814 LD B,A ...
53815 CP 255 ...and if this is 255 (i.e. no room available)...
53817 RET Z ...then return
53818 LD A,29 Set character's x-coordinate to 29 (right-hand side of new room)...
53820 LD (HL),A ...
53821 DEC HL Move HL back to character's room
53822 LD (HL),B Set current room to new room index
53823 RET Return
Move character right
53824 LD A,(HL) Load A with character's current room
53825 PUSH HL Store HL (pointer to character's current room)
53826 LD HL,37023 Point HL to right exit value of first entry in room connectivity data table
53829 CALL 53861 Get index of destination room for character and load into A and instruction at 53812
53832 LD (53848),A Load value into instruction at 53847
53835 POP HL Restore HL (pointer to character's current room)
53836 INC HL Advance HL to character's x-coordinate
53837 LD A,(HL) Load x-coordinate into A...
53838 INC A ...and increase
53839 CALL 53886 If character has a disallowed x-coordinate in the "barrier room" then return to routine that called this one
53842 CP 30 If character's x-coordinate is not 30...
53844 JP NZ,53859 ...then skip ahead to 53859
The operand of the instruction at 53847 represents the character's destination room when moving right. This is modified by the instruction at 53832.
53847 LD A,0 Load B with character's destination room...
53849 LD B,A ...
53850 CP 255 ...and if this is 255 (i.e. no room available)...
53852 RET Z ...then return
53853 LD A,1 Set character's x-coordinate to 1 (left-hand side of new room)...
53855 LD (HL),A ...
53856 DEC HL Move HL back to character's room
53857 LD (HL),B Set current room to new room index
53858 RET Return
53859 LD (HL),A Store updated x-coordinate for character
53860 RET Return
Prev: 53703 Up: Map Next: 53861