Routines |
Prev: 31572 | Up: Map | Next: 31720 |
|
||||||||
31573 | LD L,0 | Point HL at byte 0 of ERIC's buffer | ||||||
31575 | LD A,(HL) | A=ERIC's animatory state | ||||||
31576 | RLCA | Set A to -1 if ERIC is facing left, or 1 if he's facing right | ||||||
31577 | SBC A,A | |||||||
31578 | ADD A,A | |||||||
31579 | CPL | |||||||
31580 | INC L | L=1 | ||||||
31581 | ADD A,(HL) | Now A=x-coordinate of the spot in front of ERIC | ||||||
31582 | INC L | L=2 | ||||||
31583 | LD DE,(54273) | Pick up the coordinates of the animal using buffer 212 (mouse or frog) | ||||||
31587 | CP E | Is there a mouse or frog at this x-coordinate? | ||||||
31588 | RET NZ | Return if not | ||||||
31589 | LD A,(HL) | A=ERIC's y-coordinate | ||||||
31590 | CP D | Is the mouse/frog on this floor? | ||||||
31591 | RET NZ | Return if not | ||||||
31592 | LD A,(54272) | Pick up the mouse/frog's animatory state in A | ||||||
31595 | AND 127 | Discard all but the 'direction' bit (bit 7) | ||||||
31597 | CP 47 | 47: Is it a mouse? | ||||||
31599 | JP NZ,31733 | Jump if not (it's the frog) | ||||||
ERIC has managed to catch the mouse.
|
||||||||
31602 | LD H,212 | H=212 (the mouse's buffer) | ||||||
31604 | CALL 25012 | Update the SRB for the mouse's current animatory state and location | ||||||
Determine where to release another mouse.
|
||||||||
31607 | LD HL,32767 | 32767 holds the column of the play area at the far left of the screen | ||||||
31610 | CALL 25233 | A=R, a random number from 0 to 7; we'll use this to determine where the new free mouse will be placed | ||||||
31613 | AND 7 | |||||||
31615 | LD D,A | Copy this random number to D | ||||||
31616 | CP 2 | Jump if R>=2 | ||||||
31618 | JR NC,31628 | |||||||
R=0 or 1. The next section of code is intended to set the x-coordinate for the the new free mouse to 170 provided that X<128, or try again with a new random number (R) if X>=128. However, at this point HL may have been set to 32522 (byte 10 of the screen refresh buffer) or 32600 (byte 4 of the buffer for the Blue Room blackboard) by the LD L,10 or LD L,88 instruction below, and so the contents of 32522 or 32600 (instead of X at 32767) may be compared with 128. Thus it is possible for the new free mouse to appear at x-coordinate 170 even when X>=128, which means it could appear on-screen. This is a bug.
|
||||||||
31620 | LD A,(HL) | A=X (column of the play area at the far left of the screen), or the contents of 32522 or 32600 | ||||||
31621 | RLCA | |||||||
31622 | JR C,31610 | Jump if A>=128 to get another random number | ||||||
31624 | LD L,170 | This will be the x-coordinate for the new free mouse | ||||||
31626 | JR 31651 | Go and figure out the y-coordinate | ||||||
31628 | CP 5 | |||||||
31630 | LD A,(HL) | A=X (column of the play area at the far left of the screen), or the contents of 32522 or 32600 | ||||||
31631 | JR NC,31645 | Jump if R>=5 | ||||||
R=2, 3 or 4. The next section of code is intended to set the x-coordinate for the new free mouse to 88 provided that X<56 or X>=104, or try again with a new random number (R) if 56<=X<104. However, as noted above, HL may now hold 32522 or 32600 instead of 32767, and so the contents of 32522 or 32600 (instead of X) may be compared with 56 and 104. Thus it is possible for the new free mouse to appear at x-coordinate 88 even when 56<=X<104, which means it could appear on-screen. This is a bug.
|
||||||||
31633 | CP 56 | |||||||
31635 | LD L,88 | This is a possible x-coordinate for the new free mouse | ||||||
31637 | JR C,31651 | Jump if A<56 to figure out the y-coordinate | ||||||
31639 | CP 104 | Jump if 56<=A<104 to get another random number | ||||||
31641 | JR C,31610 | |||||||
31643 | JR 31651 | Go and figure out the y-coordinate for the mouse | ||||||
R=5, 6 or 7. The next section of code is intended to set the x-coordinate for the new free mouse to 10 provided that X>=56, or try again with a new random number (R) if X<56. However, as noted above, HL may now hold 32522 or 32600 instead of 32767, and so the contents of 32522 or 32600 (instead of X) may be compared with 56. Thus it is possible for the new free mouse to appear at x-coordinate 10 even when X<56, which means it could appear on-screen. This is a bug.
|
||||||||
31645 | LD L,10 | This is a possible x-coordinate for the new free mouse | ||||||
31647 | CP 56 | Jump if A<56 to get another random number | ||||||
31649 | JR C,31610 | |||||||
The x-coordinate for the new free mouse (10, 88 or 170) has been determined. Now to determine the mouse's y-coordinate.
|
||||||||
31651 | LD A,D | A=R (the random number from 0 to 7) | ||||||
31652 | SUB 3 | Convert this to a random number from 0 to 2 by taking the remainder when divided by 3 | ||||||
31654 | JR NC,31652 | |||||||
31656 | ADD A,3 | |||||||
31658 | LD H,17 | This is a possible y-coordinate for the new free mouse (bottom floor) | ||||||
31660 | JR Z,31669 | Jump if the random number is 0 | ||||||
31662 | DEC A | |||||||
31663 | LD H,10 | This is a possible y-coordinate for the new free mouse (middle floor) | ||||||
31665 | JR Z,31669 | Jump if the random number was 1 | ||||||
31667 | LD H,3 | This is the y-coordinate for the new free mouse (top floor) | ||||||
31669 | LD (54273),HL | Fill in the location of the new free mouse | ||||||
31672 | LD A,10 | Add 100 to the score, print it and make a sound effect | ||||||
31674 | CALL 28952 | |||||||
31677 | LD HL,32737 | 32737 holds the number of mice ERIC has caught | ||||||
31680 | INC (HL) | Increase this by 1 | ||||||
31681 | LD A,(HL) | |||||||
Now it's time to update the on-screen mouse inventory. This entry point is used by the routine at 31462.
|
||||||||
31682 | LD A,(32737) | A=number of mice in ERIC's pocket | ||||||
31685 | LD C,A | C will count the number of mice remaining to be printed in the inventory | ||||||
31686 | LD L,168 | 168=LSB of the display file address for the spot in the inventory for the first captive mouse | ||||||
31688 | LD A,C | A=number of mice left to print | ||||||
31689 | AND A | Set the zero flag if there are none left | ||||||
31690 | LD B,8 | There are 8 bytes in the mouse UDG/inventory slot | ||||||
31692 | LD H,80 | Set HL to the appropriate display file address | ||||||
31694 | JR NZ,31702 | Jump if we need to draw a mouse here | ||||||
31696 | LD (HL),A | Otherwise blank out this spot in the mouse inventory | ||||||
31697 | INC H | |||||||
31698 | DJNZ 31696 | |||||||
31700 | JR 31712 | Move to the next spot in the mouse inventory | ||||||
31702 | LD DE,40928 | The captured mouse UDG is at 40928 | ||||||
31705 | DEC C | Decrease the captured mouse counter | ||||||
31706 | LD A,(DE) | Display a captured mouse in the inventory | ||||||
31707 | LD (HL),A | |||||||
31708 | INC H | |||||||
31709 | INC E | |||||||
31710 | DJNZ 31706 | |||||||
31712 | INC L | Point to the next spot in the mouse inventory | ||||||
31713 | BIT 4,L | Have we drawn all 8 spots yet (L=176)? | ||||||
31715 | JR Z,31688 | Jump back to draw the next one if not | ||||||
31717 | LD H,210 | 210=ERIC | ||||||
31719 | RET |
Prev: 31572 | Up: Map | Next: 31720 |