| Routines

63801: Deal with MR WACKER's journey to a window

Continues from 63586. Controls MR WACKER as he walks from the vicinity of the stinkbomb cloud over to the nearest closed window, opens it, and walks back again.
Input
H | 200 (MR WACKER)
63801 | LD L,21 | Pick up the x-coordinate of the window to be opened from byte 21 of MR WACKER's buffer
63803 | LD A,(HL)
63804 | LD L,1 | Byte 1 of MR WACKER's buffer holds his current x-coordinate
63806 | CP (HL) | Has MR WACKER reached the window yet?
63807 | JP NZ,25632 | Keep going if not
63810 | CALL 25012 | Update the SRB for MR WACKER's current animatory state and location
63813 | OR 7 | A=animatory state of MR WACKER with his arm up
63815 | CALL 30534 | Place address 63818 (below) into bytes 17 and 18 of MR WACKER's buffer and update his animatory state
The address of this entry point is placed into bytes 17 and 18 of MR WACKER's buffer by the instruction above when he has reached the window that needs opening.
63818 | LD L,17 | Replace the address of this entry point in bytes 17 and 18 of MR WACKER's buffer with 63830
63820 | LD (HL),86
63822 | LD B,1 | B=1 (open window)
63824 | LD L,22 | Pick up the window identifier (64/128) from byte 22 of MR WACKER's buffer
63826 | LD A,(HL)
63827 | JP 28863 | Open the window and lower MR WACKER's arm
This entry point is used after the window has been opened.
63830 | CALL 25012 | Update the SRB for MR WACKER's current animatory state and location
63833 | XOR 128 | A=animatory state of MR WACKER facing left
63835 | CALL 30534 | Place address 63838 (below) into bytes 17 and 18 of MR WACKER's buffer and update his animatory state
This entry point is used after MR WACKER has turned round to begin his return journey from the window.
63838 | LD L,0 | Point HL at byte 0 of MR WACKER's buffer
63840 | BIT 0,(HL) | Is MR WACKER midstride?
63842 | JP NZ,25597 | Finish his stride if so
63845 | LD L,19 | Byte 19 stores MR WACKER's x-coordinate before he went off to the window; pick this up in A
63847 | LD A,(HL)
63848 | LD L,1 | Byte 1 of MR WACKER's buffer holds his x-coordinate
63850 | CP (HL) | Is MR WACKER at his pre-window-opening position?
63851 | JP NZ,25632 | Continue his return journey if not
MR WACKER has now returned to the spot where the stinkbomb first offended his nostrils.
63854 | LD L,18 | Remove the routine address (63838 above) from bytes 17 and 18 of MR WACKER's buffer
63856 | LD (HL),0
63858 | JP 30112 | Restore MR WACKER's original animatory state and update SRB