Prev: 62594 Up: Map Next: 62778
62622: Move character whose turn it is to move, if allowed
Alternate characters move in opposite directions on alternate hours. Characters can only move if they are not in the same room as Magic Knight, or if the player is not currently controlling Magic Knight (i.e. navigating menus or failing to press FIRE when "PRESS FIRE TO CONTINUE" message is shown).
Used by the routine at 62330.
Input
IY 23610
62622 BIT 2,(IY+65) If characters-can't-move flag is set...
62626 RET NZ ...then return
62627 CALL 62812 Update index of character whose turn it is to be updated and load into A
62630 LD E,6 Point HL at this character's flags...
62632 CALL 45406 ...
62635 LD A,(HL) ...and load flags into A
62636 AND 128 If character is asleep...
62638 RET NZ ...then return
62639 DEC HL Move HL back two bytes to character's attribute...
62640 DEC HL ...
62641 LD A,(HL) ...and load attribute into A
62642 OR A If attribute is zero...
62643 RET Z ...then return
62644 LD A,(23455) Load BC with three times index of character whose turn it is to be updated...
62647 LD C,A ...
62648 ADD A,A ...
62649 ADD A,C ...
62650 LD C,A ...
62651 LD B,0 ...
62653 LD HL,24898 Point HL at start of table of characters' current positions at 24898
62656 ADD HL,BC Add BC to HL as offset
62657 LD A,(23702) If Magic Knight is not in the same room as this character...
62660 CP (HL) ...
62661 JR NZ,62668 ...then skip ahead to 62668
62663 BIT 1,(IY+65) If characters-movement-unrestricted flag is reset...
62667 RET Z ...then return
62668 LD A,(HL) If character's room is 100...
62669 CP 100 ...
62671 RET Z ...then return
62672 CP 99 If character's room is 99...
62674 JP Z,62853 ...then reset character to his / her initial position
62677 LD A,(23455) Load B with index of character whose turn it is to be updated...
62680 LD B,A ...
62681 LD A,(23457) Load A with number of hours left...
62684 ADD A,B ...and add index of character to be updated
62685 BIT 0,A If result is even...
62687 JP Z,62734 ...then skip ahead to 62734
Move character left
62690 LD A,(HL) Load A with character's current room
62691 PUSH HL Store HL (pointer to character's current room)
62692 LD HL,48913 Set movement restriction data base address to 48913 (one room to the left)...
62695 LD (62785),HL ...and load address into instruction at 62784
62698 LD HL,48811 Point HL to left exit value of first entry in room connectivity data table
62701 CALL 62778 Get index of destination room for character and load into A
62704 LD (62723),A Load value into instruction at 62722
62707 POP HL Restore HL (pointer to character's current room)
62708 INC HL Advance HL to character's x-coordinate
62709 LD A,(HL) Load x-coordinate into A...
62710 CP 2 ...and if this is 2...
62712 JR Z,62722 ...then skip ahead to 62722
62714 DEC A Decrease x-coordinate by two...
62715 DEC A ...
62716 CALL 62827 Set this as character's new x-coordinate if value is allowed, otherwise return
62719 CP 2 If character's x-coordinate is not 2...
62721 RET NZ ...then return
The operand of the instruction at 62722 represents the character's destination room when moving left. This is modified by the instructions at 62704.
62722 LD A,0 Load B with character's destination room...
62724 LD B,A ...
62725 CP 255 ...and if this is 255 (i.e. no room available)...
62727 RET Z ...then return
62728 LD A,28 Set character's x-coordinate to 28 (right-hand side of new room)...
62730 LD (HL),A ...
62731 DEC HL Move HL back to character's room
62732 LD (HL),B Set current room to new room index
62733 RET Return
Move character right
62734 LD A,(HL) Load A with character's current room
62735 PUSH HL Store HL (pointer to character's current room)
62736 LD HL,48917 Set movement restriction data base address to 48917 (one room to the right)...
62739 LD (62785),HL ...and load address into instruction at 62784
62742 LD HL,48812 Point HL to right exit value of first entry in room connectivity data table
62745 CALL 62778 Get index of destination room for character and load into A
62748 LD (62767),A Load value into instruction at 62766
62751 POP HL Restore HL (pointer to character's current room)
62752 INC HL Advance HL to character's x-coordinate
62753 LD A,(HL) Load x-coordinate into A...
62754 CP 28 ...and if this is 28...
62756 JR Z,62766 ...then skip ahead to 62766
62758 INC A Increase x-coordinate by two...
62759 INC A ...
62760 CALL 62827 Set this as character's new x-coordinate if value is allowed, otherwise return
62763 CP 28 If character's x-coordinate is not 28...
62765 RET NZ ...then return
The operand of the instruction at 62766 represents the character's destination room when moving right. This is modified by the instructions at 62748.
62766 LD A,0 Load B with character's destination room...
62768 LD B,A ...
62769 CP 255 ...and if this is 255 (i.e. no room available)...
62771 RET Z ...then return
62772 LD A,2 Set character's x-coordinate to 2 (left-hand side of new room)...
62774 LD (HL),A ...
62775 DEC HL Move HL back to character's room
62776 LD (HL),B Set current room to new room index
62777 RET Return
Prev: 62594 Up: Map Next: 62778