| Routines

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

Continues from F862. 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 | 0xC8 (MR WACKER)
F939 | LD L,$15 | Pick up the x-coordinate of the window to be opened from byte 0x15 of MR WACKER's buffer
F93B | LD A,(HL)
F93C | LD L,$01 | Byte 0x01 of MR WACKER's buffer holds his current x-coordinate
F93E | CP (HL) | Has MR WACKER reached the window yet?
F93F | JP NZ,$6420 | Keep going if not
F942 | CALL $61B4 | Update the SRB for MR WACKER's current animatory state and location
F945 | OR $07 | A=animatory state of MR WACKER with his arm up
F947 | CALL $7746 | Place address F94A (below) into bytes 0x11 and 0x12 of MR WACKER's buffer and update his animatory state
The address of this entry point is placed into bytes 0x11 and 0x12 of MR WACKER's buffer by the instruction above when he has reached the window that needs opening.
F94A | LD L,$11 | Replace the address of this entry point in bytes 0x11 and 0x12 of MR WACKER's buffer with F956
F94C | LD (HL),$56
F94E | LD B,$01 | B=1 (open window)
F950 | LD L,$16 | Pick up the window identifier (0x40/0x80) from byte 0x16 of MR WACKER's buffer
F952 | LD A,(HL)
F953 | JP $70BF | Open the window and lower MR WACKER's arm
This entry point is used after the window has been opened.
F956 | CALL $61B4 | Update the SRB for MR WACKER's current animatory state and location
F959 | XOR $80 | A=animatory state of MR WACKER facing left
F95B | CALL $7746 | Place address F95E (below) into bytes 0x11 and 0x12 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.
F95E | LD L,$00 | Point HL at byte 0x00 of MR WACKER's buffer
F960 | BIT 0,(HL) | Is MR WACKER midstride?
F962 | JP NZ,$63FD | Finish his stride if so
F965 | LD L,$13 | Byte 0x13 stores MR WACKER's x-coordinate before he went off to the window; pick this up in A
F967 | LD A,(HL)
F968 | LD L,$01 | Byte 0x01 of MR WACKER's buffer holds his x-coordinate
F96A | CP (HL) | Is MR WACKER at his pre-window-opening position?
F96B | JP NZ,$6420 | Continue his return journey if not
MR WACKER has now returned to the spot where the stinkbomb first offended his nostrils.
F96E | LD L,$12 | Remove the routine address (F95E above) from bytes 0x11 and 0x12 of MR WACKER's buffer
F970 | LD (HL),$00
F972 | JP $75A0 | Restore MR WACKER's original animatory state and update SRB