Routines

25700: Go to...


Used by the tables of A&P to make a character go to a specified place

H Character number (183-214)

25700 2E05 LD L,5 Put coordinates of character's destination into bytes 5 and 6 of the character's buffer
25702 CD6462 CALL 25188
25705 2E03 LD L,3 Place the address of the routine at 25826 into bytes 3 and 4 of the character's buffer
25707 367E LD (HL),126
25709 2E00 LD L,0
25711 7E LD A,(HL) A=animatory state of character
25712 E607 AND 7
25714 FE04 CP 4 Is character sitting on a chair? (kids only)
25716 2008 JR NZ,25726 Jump if not
25718 CDB461 CALL 25012 Update SRB for current AS of character (who's sitting down at the moment)
25721 E6F8 AND 248 A=animatory state of character standing up
25723 C33061 JP 24880 Set new animatory state (i.e. make character stand up) and update SRB accordingly
25726 2E06 LD L,6
25728 56 LD D,(HL) D=y-coordinate of character's destination
25729 2D DEC L
25730 5E LD E,(HL) E=x-coordinate of character's destination
25731 2E01 LD L,1 (HL)=character's current x-coordinate
25733 7B LD A,E
25734 BE CP (HL)
25735 23 INC HL
25736 2005 JR NZ,25743 Jump forward if character's current x-coordinate does not match destination's
25738 7A LD A,D A=character's current y-coordinate
25739 BE CP (HL)
25740 CA8C63 JP Z,25484 Jump if the character's already at his destination
25743 CDD263 CALL 25554 Get a location identifier in A

Now A holds a value from 189 to 196, corresponding to the destination of the character:
189 Top floor, left of left study door in boys' skool
190 Middle floor, left of far wall of science lab storeroom
191 Bottom floor (anywhere)
192 Assembly hall stage
193 Near middle-floor window in boys' skool
194 Top floor, right of left study door in boys' skool
195 Middle floor, girls' skool
196 Top floor, girls' skool

25746 56 LD D,(HL) D=character's y-coordinate
25747 2D DEC L
25748 5E LD E,(HL) E=character's x-coordinate
25749 6F LD L,A 189≤L≤196
25750 CDD263 CALL 25554 Pick up in A the value from 189 to 196 corresponding to the character's current position (see table above)
25753 BD CP L Will the character have to negotiate any staircases in order to reach his destination?
25754 282C JR Z,25800 Jump forward if not
25756 57 LD D,A D=current location identifier (189-196)
25757 7D LD A,L A=destination identifier (189-196)
25758 D681 SUB 129
25760 5F LD E,A E=destination identifier minus 129 (60-67)
25761 1A LD A,(DE)

Now A holds a value (189-200, 206 or 207) corresponding to the top or bottom of the first staircase the character will have to negotiate in order to reach his destination:
189 Top of stairs, top floor, between blue room and revision library
190 Bottom of stairs, middle floor, between science lab and wash basins
191 Top of stairs, middle floor, between science lab and wash basins
192 Bottom of stairs, bottom floor, far left of boys' skool
193 Bottom of stairs, bottom floor, leading up to assembly hall stage
194 Bottom of stairs, bottom floor, girls' skool
195 Top of stairs leading down to bottom floor, assembly hall stage
196 Bottom of stairs leading up to middle floor, assembly hall stage
197 Top of stairs, middle floor, leading down to assembly hall stage
198 Bottom of stairs, middle floor, leading up to head's study
199 Top of stairs, top floor, at head's study door
200 Top of stairs, middle floor, girls' skool
206 Bottom of stairs, middle floor, girls' skool
207 Top of stairs, top floor, girls' skool

25762 57 LD D,A Place the staircase identifer in D (189-200, 206, 207)
25763 1E44 LD E,68 Byte 68 holds the x-coordinate of the top or bottom of the staircase identified by D
25765 2E01 LD L,1
25767 EB EX DE,HL
25768 1A LD A,(DE) A=character's current x-coordinate
25769 BE CP (HL) Is the character already at the top or bottom of the appropriate staircase?
25770 2018 JR NZ,25796 Jump forward if not

At this stage the character is standing at the top or bottom of the first staircase he will have to negotiate in order to reach his destination.
25772 2C INC L (HL)=0 if character has to face left to ascend/descend stairs, 128 otherwise
25773 1D DEC E
25774 1A LD A,(DE) A=character's animatory state
25775 AE XOR (HL) Set bit 7 of A if the character has to turn round to negotiate staircase
25776 07 RLCA
25777 EB EX DE,HL
25778 DA3064 JP C,25648 Jump to turn the character round if he's facing the wrong way
25781 EB EX DE,HL
25782 1E0B LD E,11 Point DE at byte 11 of the character's buffer
25784 2C INC L L=70
25785 4E LD C,(HL) BC=25656 if the stairs are to be ascended, 25677 if descended
25786 0664 LD B,100
25788 00 NOP
25789 2C INC L L=71
25790 7E LD A,(HL) A=1+number of steps in staircase
25791 12 LD (DE),A Place this number of steps in byte 11 of the character's buffer
25792 EB EX DE,HL
25793 C3B063 JP 25520

The routine comes here if the character is not yet at the top or bottom of the appropriate staircase:
25796 7E LD A,(HL) A=x-coordinate of top or bottom of staircase
25797 EB EX DE,HL
25798 1803 JR 25803 Jump forward

The routine comes here if the character can now reach his destination without negotiating any staircases:
25800 2E05 LD L,5
25802 7E LD A,(HL) A=x-coordinate of destination
25803 2E0B LD L,11
25805 77 LD (HL),A
25806 01ED63 LD BC,25581 See the routine at 25581
25809 C3B063 JP 25520