![]() |
Routines |
Prev: 63576 | Up: Map | Next: 63743 |
63586 | LD HL,32747 | 32747 holds the inventory flags |
63589 | LD A,(HL) | Pick these up in A |
63590 | AND 224 | Keep only the stinkbomb bits (bits 5-7) |
63592 | ADD A,A | Shift these bits left, losing the leftmost bit |
63593 | LD C,A | Store the new stinkbomb bits in C briefly |
63594 | LD A,(HL) | Pick up the inventory flags in A again |
63595 | AND 31 | Discard the old stinkbomb bits |
63597 | OR C | Superimpose the new stinkbomb bits |
63598 | LD (HL),A | Restore the inventory flags, minus one stinkbomb |
63599 | CALL 31746 | Print the inventory |
63602 | CALL 57910 | Prepare buffer 213 for the stinkbomb cloud (or return to the main loop if the buffer is already in use by a stinkbomb cloud) |
63605 | LD L,0 | Point HL at byte 0 of ERIC's buffer |
63607 | LD A,(HL) | A=ERIC's animatory state |
63608 | INC L | L=1 |
63609 | RLCA | Set A to -1 if ERIC is facing left, 1 if he's facing right |
63610 | SBC A,A | |
63611 | ADD A,A | |
63612 | CPL | |
63613 | ADD A,(HL) | Add ERIC's x-coordinate to get the x-coordinate for the stinkbomb cloud |
63614 | LD E,A | Copy this to E |
63615 | INC L | L=2 |
63616 | LD D,(HL) | D=ERIC's y-coordinate, which will also be the y-coordinate for the stinkbomb cloud |
63617 | LD HL,54547 | Point HL at byte 19 of the stinkbomb cloud's buffer |
63620 | LD (HL),29 | Initialise the counter that determines when the cloud will disappear |
63622 | LD A,71 | 71: stinkbomb cloud (phase 1) |
63624 | CALL 30534 | Update the SRB for the stinkbomb cloud's appearance and place address 63627 (below) into bytes 17 and 18 of the cloud's buffer |
The address of the entry point below is placed into bytes 17 and 18 of the cloud's buffer by the instruction above.
|
||
63627 | LD L,19 | Byte 19 of the cloud's buffer holds the counter that determines how much longer the cloud will stick around (which starts off at 29) |
63629 | DEC (HL) | Is it time for the cloud to disappear? |
63630 | JP Z,29903 | Jump if so |
63633 | LD A,(HL) | Pick up the counter's value in A |
63634 | CP 28 | Is it time for a teacher to give lines? |
63636 | JR NZ,63646 | Jump if not |
63638 | LD A,1 | Message 1: NO STINKBOMBS |
63640 | SUB 62 | Subtract 62 now (it's added back later on) |
63642 | CP A | Set the zero flag to indicate that any teacher may give ERIC lines (including the one who last gave him lines) |
63643 | JP 32282 | Make any teacher within range give ERIC lines |
Now deal with animating the stinkbomb cloud and checking whether it's near a window.
|
||
63646 | CALL 25648 | Toggle between cloud animation phases 1 (71) and 2 (199) and update the SRB accordingly |
63649 | LD L,0 | Point HL at byte 0 of the cloud's buffer |
63651 | BIT 0,(HL) | Bit 0 of the cloud's animatory state (71 or 199) is always set, so this RET never happens |
63653 | RET Z | |
63654 | INC L | L=1 |
63655 | LD A,(HL) | A=stinkbomb cloud's x-coordinate |
63656 | CP 84 | The head's right study door is at x-coordinate 84 |
63658 | RET C | Return if the cloud is to the left of this |
63659 | CP 96 | The boys' skool door is at x-coordinate 96 |
63661 | RET NC | Return if the cloud is to the right of this |
63662 | INC L | L=2 |
63663 | LD A,(HL) | A=stinkbomb cloud's y-coordinate |
63664 | CP 17 | Is the cloud on the bottom floor? |
63666 | RET Z | Return if so |
The stinkbomb cloud is on the top floor or middle floor, somewhere between the head's right study door and the boys' skool door. Check the windows.
|
||
63667 | EX DE,HL | Point DE at byte 2 of the cloud's buffer |
63668 | LD HL,32756 | 32756 holds the door/window status flags |
63671 | CP 3 | Is the cloud on the top floor? |
63673 | JR Z,63683 | Jump if so |
63675 | BIT 7,(HL) | Is the middle-floor window already open? |
63677 | RET NZ | Return if so |
63678 | LD BC,32861 | B=128 (middle floor window), C=93 (x-coordinate) |
63681 | JR 63689 | |
63683 | BIT 6,(HL) | Is the top-floor window already open? |
63685 | RET NZ | Return if so |
63686 | LD BC,16475 | B=64 (top-floor window), C=91 (x-coordinate) |
Now B holds the identifier of a closed window on the same floor as the stinkbomb cloud, and C holds its x-coordinate. Is MR WACKER in the vicinity?
|
||
63689 | LD HL,51202 | Point HL at byte 2 of MR WACKER's buffer |
63692 | CP (HL) | Is MR WACKER on the same floor as the stinkbomb cloud? |
63693 | RET NZ | Return if not |
63694 | DEC L | L=1 |
63695 | DEC E | E=1 |
63696 | LD A,(DE) | A=x-coordinate of the stinkbomb cloud |
63697 | SUB 3 | Return if MR WACKER is more than 2 spaces to the left of the cloud |
63699 | CP (HL) | |
63700 | RET NC | |
63701 | ADD A,5 | Return if MR WACKER is more than 2 spaces to the right of the cloud |
63703 | CP (HL) | |
63704 | RET C | |
MR WACKER is close enough to the stinkbomb cloud to be affected by its stench. Check whether he's available for a spot of window-opening.
|
||
63705 | LD E,(HL) | E=MR WACKER's x-coordinate |
63706 | LD L,18 | Is there an uninterruptible subcommand routine address in bytes 17 and 18 of MR WACKER's buffer (meaning he is otherwise occupied at the moment)? |
63708 | LD A,(HL) | |
63709 | AND A | |
63710 | RET NZ | Return if so |
63711 | LD L,A | L=0 |
63712 | LD A,(HL) | A=MR WACKER's animatory state |
63713 | RRCA | Is MR WACKER midstride? |
63714 | RET C | Return if so |
63715 | RLCA | A=MR WACKER's animatory state |
63716 | 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 | LD (HL),E | |
63719 | INC L | |
63720 | LD (HL),A | |
63721 | INC L | Store the x-coordinate of the window in byte 21 |
63722 | LD (HL),C | |
63723 | INC L | Byte 22 holds 128 (middle-floor window) or 64 (top-floor window) |
63724 | LD (HL),B | |
63725 | CALL 25012 | Update the SRB for MR WACKER's current animatory state and location |
63728 | SET 7,A | A=animatory state of MR WACKER facing right |
63730 | CALL 30534 | Place address 63733 (below) into bytes 17 and 18 of MR WACKER's buffer and update his animatory state |
The address of the entry point below is placed into bytes 17 and 18 of MR WACKER's buffer by the instruction above.
|
||
63733 | LD L,0 | Point HL at byte 0 of MR WACKER's buffer |
63735 | BIT 0,(HL) | Is MR WACKER midstride? |
63737 | JP NZ,25597 | Finish his stride if so |
63740 | JP 63801 | Otherwise set MR WACKER off on his journey to the window |
Prev: 63576 | Up: Map | Next: 63743 |