| Routines

37403: Flip a switch in a Kong Beast cavern if Willy is touching it

Used by the routine at 37173. Returns with the zero flag set if Willy flips the switch.
Input
HL | Address of the switch's location in the attribute buffer at 23552
37403 | LD A,(32876) | Pick up the LSB of the address of Willy's location in the attribute buffer at 23552 from 32876
37406 | INC A | Is it equal to or one less than the LSB of the address of the switch's location?
37407 | AND 254
37409 | CP L
37410 | RET NZ | Return (with the zero flag reset) if not
37411 | LD A,(32877) | Pick up the MSB of the address of Willy's location in the attribute buffer at 23552 from 32877
37414 | CP H | Does it match the MSB of the address of the switch's location?
37415 | RET NZ | Return (with the zero flag reset) if not
37416 | LD A,(32869) | Pick up the sixth byte of the graphic data for the switch tile from 32869
37419 | LD H,117 | Point HL at the sixth row of pixels of the switch tile in the screen buffer at 28672
37421 | CP (HL) | Has the switch already been flipped?
37422 | RET NZ | Return (with the zero flag reset) if so
Willy is flipping the switch.
37423 | LD (HL),8 | Update the sixth, seventh and eighth rows of pixels of the switch tile in the screen buffer at 28672 to make it appear flipped
37425 | INC H
37426 | LD (HL),6
37428 | INC H
37429 | LD (HL),6
37431 | XOR A | Set the zero flag: Willy has flipped the switch
37432 | OR A | This instruction is redundant
37433 | RET |