Routines

63586: Deal with stinkbomb once dropped


The address of this routine is placed in 32727 by the routine at 28992 when ERIC drops a stinkbomb

63586 21EB7F LD HL,32747 Inventory flags
63589 7E LD A,(HL) ERIC now has one fewer stinkbomb
63590 E6E0 AND 224
63592 87 ADD A,A
63593 4F LD C,A
63594 7E LD A,(HL)
63595 E61F AND 31
63597 B1 OR C
63598 77 LD (HL),A
63599 CD027C CALL 31746 Print inventory
63602 CD36E2 CALL 57910 Prepare buffer 213 for use if available
63605 2E00 LD L,0
63607 7E LD A,(HL) A=ERIC's animatory state
63608 2C INC L
63609 07 RLCA
63610 9F SBC A,A
63611 87 ADD A,A
63612 2F CPL
63613 86 ADD A,(HL) A=x-coordinate for stinkbomb cloud
63614 5F LD E,A
63615 2C INC L
63616 56 LD D,(HL) D=y-coordinate for stinkbomb cloud
63617 2113D5 LD HL,54547 H=213 (buffer for stinkbomb cloud), L=19
63620 361D LD (HL),29
63622 3E47 LD A,71 71: stinkbomb cloud (stage 1)
63624 CD4677 CALL 30534 Update SRB and place address 63627 into cloud's buffer
63627 2E13 LD L,19
63629 35 DEC (HL) Is it time for the cloud to disappear?
63630 CACF74 JP Z,29903 Jump if so
63633 7E LD A,(HL)
63634 FE1C CP 28 Is it time for a teacher to give lines?
63636 2008 JR NZ,63646 Jump if not
63638 3E01 LD A,1 Message no. 1: NO STINKBOMBS

This entry point used by several routines:
63640 D63E SUB 62
63642 BF CP A Set the zero flag
63643 C31A7E JP 32282
63646 CD3064 CALL 25648 Toggle between stages 1 and 2 and update SRB accordingly
63649 2E00 LD L,0
63651 CB46 BIT 0,(HL)
63653 C8 RET Z
63654 2C INC L
63655 7E LD A,(HL) A=stinkbomb cloud's x-coordinate
63656 FE54 CP 84 Head's study door is roughly at x-coordinate 84
63658 D8 RET C Return if the cloud is to the left of this
63659 FE60 CP 96 Boys' skool door is at x-coordinate 96
63661 D0 RET NC Return if the cloud is to the right of this
63662 2C INC L
63663 7E LD A,(HL) A=stinkbomb cloud's y-coordinate
63664 FE11 CP 17 Is the cloud on the bottom floor?
63666 C8 RET Z Return if so
63667 EB EX DE,HL
63668 21F47F LD HL,32756
63671 FE03 CP 3 Is the cloud on the top floor?
63673 2808 JR Z,63683 Jump if so
63675 CB7E BIT 7,(HL) Is the middle-floor window already open?
63677 C0 RET NZ Return if so
63678 015D80 LD BC,32861 B=128, C=93
63681 1806 JR 63689
63683 CB76 BIT 6,(HL) Is the top-floor window already open?
63685 C0 RET NZ Return if so
63686 015B40 LD BC,16475 B=64, C=91
63689 2102C8 LD HL,51202 H=200 (MR WACKER), L=2
63692 BE CP (HL) Is the stinkbomb cloud on the same floor as MR WACKER?
63693 C0 RET NZ Return if not
63694 2D DEC L
63695 1D DEC E
63696 1A LD A,(DE) A=x-coordinate of stinkbomb cloud
63697 D603 SUB 3
63699 BE CP (HL)
63700 D0 RET NC Return if MR WACKER is too far left of the cloud
63701 C605 ADD A,5
63703 BE CP (HL)
63704 D8 RET C Return if MR WACKER is too far right of the cloud
63705 5E LD E,(HL) E=MR WACKER's x-coordinate
63706 2E12 LD L,18
63708 7E LD A,(HL)
63709 A7 AND A Is MR WACKER available for a spot of window-opening?
63710 C0 RET NZ Return if not
63711 6F LD L,A
63712 7E LD A,(HL) A=MR WACKER's animatory state
63713 0F RRCA
63714 D8 RET C Return if MR WACKER is midstride
63715 07 RLCA
63716 2E13 LD L,19 Store Mr WACKER's current x-coordinate and animatory state in bytes 19 and 20 of his buffer for later retrieval
63718 73 LD (HL),E
63719 2C INC L
63720 77 LD (HL),A
63721 2C INC L Store the x-coordinate of the window in byte 21
63722 71 LD (HL),C
63723 2C INC L Byte 22 holds 128 (middle-floor window) or 64 (top-floor window)
63724 70 LD (HL),B
63725 CDB461 CALL 25012 Update SRB for MR WACKER's current animatory state and location
63728 CBFF SET 7,A A=animatory state of MR WACKER facing right
63730 CD4677 CALL 30534 Place address 63733 in MR WACKER's buffer, update SRB
63733 2E00 LD L,0 HL points at byte 0 of MR WACKER's buffer
63735 CB46 BIT 0,(HL) Is MR WACKER midstride?
63737 C2FD63 JP NZ,25597 Jump if so
63740 C339F9 JP 63801