![]() |
Routines |
| Prev: 59632 | Up: Map | Next: 59839 |
|
||||||||||||
| 59635 | CALL 59640 | Superimpose sprite tiles for characters whose z-coordinate is 2 (between a building and the sidewalk) | ||||||||||
| 59638 | LD A,4 | Prepare to superimpose sprite tiles for characters whose z-coordinate is 4 (on the sidewalk or road) | ||||||||||
|
This entry point is used by the routine at 59148 with A=1 (to superimpose sprite tiles for characters who are indoors).
|
||||||||||||
| 59640 | EXX | |||||||||||
| 59641 | LD C,A | C'=1 (indoors), 2 (between buildings and the sidewalk) or 4 (on the sidewalk or road) | ||||||||||
| 59642 | LD H,215 | 215 is the first character | ||||||||||
| 59644 | LD L,4 | Point HL' at byte 4 of the character's buffer | ||||||||||
| 59646 | LD A,(HL) | A=character's z-coordinate (1, 2, 4 or 8) | ||||||||||
| 59647 | AND C | Reset the zero flag if the character's sprite should be printed | ||||||||||
|
This entry point is used by the routine at 26002 with H=230 (Sam), DE holding the play area coordinates of a bullet, and the zero flag reset unless Sam's indoors.
|
||||||||||||
| 59648 | JR Z,59742 | Consider the next character if this one should not be printed | ||||||||||
| 59650 | LD L,0 | Point HL' at byte 0 of the character's buffer | ||||||||||
| 59652 | LD A,(HL) | A=character's animatory state | ||||||||||
| 59653 | AND 127 | Drop the direction bit (bit 7) | ||||||||||
| 59655 | CP 120 | Is this character's animatory state >= 120? | ||||||||||
| 59657 | JR NC,59717 | Jump if so | ||||||||||
|
The character's animatory state is < 120, which means he has a 5x3 sprite.
|
||||||||||||
| 59659 | INC L | L'=1 | ||||||||||
| 59660 | INC A | A=character's animatory state + 1 | ||||||||||
| 59661 | AND 7 | Reduce this modulo 8 | ||||||||||
| 59663 | LD A,E | A=X, the play area x-coordinate (0-255) | ||||||||||
| 59664 | JR Z,59692 | Jump if the character's animatory state is congruent to 7 mod 8 | ||||||||||
|
The character's animatory state is congruent to 0-6 mod 8, which means he has a sprite with 5 rows and 3 columns. Check whether any part of the sprite impinges on the tile at (X,Y).
|
||||||||||||
| 59666 | SUB (HL) | Subtract the character's x-coordinate | ||||||||||
| 59667 | CP 3 | Does any part of the sprite impinge on column X? | ||||||||||
| 59669 | JR NC,59742 | Jump if not | ||||||||||
| 59671 | DEC L | L'=0 | ||||||||||
| 59672 | BIT 7,(HL) | Is the character facing left? | ||||||||||
| 59674 | JR Z,59679 | Jump if so | ||||||||||
| 59676 | CPL | Set A to 2-A if the character is facing right | ||||||||||
| 59677 | ADD A,3 | |||||||||||
| 59679 | LD B,A | B'=0, 1 or 2 (the column of the character's sprite at (X,Y)) | ||||||||||
| 59680 | ADD A,A | A=5*B | ||||||||||
| 59681 | ADD A,A | |||||||||||
| 59682 | ADD A,B | |||||||||||
| 59683 | LD B,A | B'=0, 5 or 10 | ||||||||||
| 59684 | LD L,2 | Point HL' at byte 2 of the character's buffer | ||||||||||
| 59686 | LD A,D | A=Y, the play area y-coordinate (2-39) | ||||||||||
| 59687 | SUB (HL) | Subtract the character's y-coordinate | ||||||||||
| 59688 | CP 5 | Set the carry flag if the sprite impinges on row Y | ||||||||||
| 59690 | JR 59740 | |||||||||||
|
The character's animatory state is congruent to 7 mod 8, which means he has a sprite with 3 rows and 5 columns. Check whether any part of the sprite impinges on the tile at (X,Y).
|
||||||||||||
| 59692 | SUB (HL) | Subtract the character's x-coordinate | ||||||||||
| 59693 | CP 5 | Does any part of the character impinge on column X? | ||||||||||
| 59695 | JR NC,59742 | Jump if not | ||||||||||
| 59697 | DEC L | L'=0 | ||||||||||
| 59698 | BIT 7,(HL) | Is the character facing left? | ||||||||||
| 59700 | JR Z,59705 | Jump if so | ||||||||||
| 59702 | CPL | Set A=4-A if the character is facing right | ||||||||||
| 59703 | ADD A,5 | |||||||||||
| 59705 | LD B,A | B'=0, 1, 2, 3 or 4 (the column of the sprite at (X,Y)) | ||||||||||
| 59706 | ADD A,A | A=3*B' | ||||||||||
| 59707 | ADD A,B | |||||||||||
| 59708 | LD B,A | B'=0, 3, 6, 9 or 12 | ||||||||||
| 59709 | LD L,2 | Point HL' at byte 2 of the character's buffer | ||||||||||
| 59711 | LD A,D | A=Y, the play area y-coordinate (2-39) | ||||||||||
| 59712 | SUB (HL) | Subtract the character's y-coordinate | ||||||||||
| 59713 | CP 3 | Set the carry flag if the sprite impinges on row Y | ||||||||||
| 59715 | JR 59740 | |||||||||||
|
The character's animatory state is >= 120, which means he has a sprite with 2 rows and 2 columns. Check whether any part of the sprite impinges on the tile at (X,Y).
|
||||||||||||
| 59717 | LD L,1 | Point HL' at byte 1 of the character's buffer | ||||||||||
| 59719 | LD A,E | A=X, the play area x-coordinate (0-255) | ||||||||||
| 59720 | SUB (HL) | Subtract the character's x-coordinate | ||||||||||
| 59721 | CP 2 | Does any part of the sprite impinge on column X? | ||||||||||
| 59723 | JR NC,59742 | Consider the next character if not | ||||||||||
| 59725 | DEC L | L'=0 | ||||||||||
| 59726 | BIT 7,(HL) | Is the character facing left? | ||||||||||
| 59728 | JR Z,59732 | Jump if so | ||||||||||
| 59730 | XOR 1 | Set A=1-A | ||||||||||
| 59732 | ADD A,A | A=0 or 2 | ||||||||||
| 59733 | LD B,A | B'=0 or 2 | ||||||||||
| 59734 | LD L,2 | Point HL' at byte 2 of the character's buffer | ||||||||||
| 59736 | LD A,D | A=Y, the play area y-coordinate (2-39) | ||||||||||
| 59737 | SUB (HL) | Subtract the character's y-coordinate | ||||||||||
| 59738 | CP 2 | Set the carry flag if the sprite impinges on row Y | ||||||||||
| 59740 | JR C,59750 | Jump if the sprite impinges on row Y | ||||||||||
| 59742 | INC H | Next character | ||||||||||
| 59743 | LD A,H | A=character number | ||||||||||
| 59744 | CP 231 | Have we done all the characters (215-230)? | ||||||||||
| 59746 | JR NZ,59644 | Jump back if not | ||||||||||
| 59748 | EXX | |||||||||||
| 59749 | RET | |||||||||||
|
The character's sprite impinges on the tile at coordinates (X,Y).
|
||||||||||||
| 59750 | ADD A,B | A=0-14 (index of the sprite tile at (X,Y)) | ||||||||||
| 59751 | ADD A,215 | 215<=A<=229 | ||||||||||
| 59753 | EXX | |||||||||||
| 59754 | LD H,A | 215<=H<=229 | ||||||||||
| 59755 | EXX | |||||||||||
| 59756 | LD L,0 | Point HL' at byte 0 of the character's buffer | ||||||||||
| 59758 | LD A,(HL) | A=character's animatory state | ||||||||||
| 59759 | AND 7 | Keep only bits 0-2 | ||||||||||
| 59761 | LD A,(HL) | A=character's animatory state | ||||||||||
| 59762 | JR NZ,59766 | Jump if the animatory state is congruent to 1-7 mod 8 | ||||||||||
| 59764 | ADD A,2 | Add 2 if the animatory state is congruent to 0 mod 8 | ||||||||||
| 59766 | OR 128 | A>=129 | ||||||||||
| 59768 | EXX | |||||||||||
| 59769 | LD L,A | L>=129, 215<=H<=229 | ||||||||||
| 59770 | LD A,(HL) | A=sprite tile reference (0-214, 217-255) | ||||||||||
| 59771 | LD E,A | Copy this to E | ||||||||||
| 59772 | AND A | Set the zero flag if this is the blank tile | ||||||||||
| 59773 | EXX | |||||||||||
| 59774 | JR Z,59742 | Jump back to consider the next character if the sprite tile is blank | ||||||||||
|
A tile of this character's sprite needs to be printed at (X,Y). The apparent intention of the next section of code is to treat animatory states 120-127/248-255 (used only by the hook) specially, but the next instruction copies L' (which holds 0) instead of L (which holds the adjusted animatory state) into A.
|
||||||||||||
| 59776 | LD A,L | A=0 | ||||||||||
| 59777 | CP 248 | This instruction sets the carry flag | ||||||||||
| 59779 | EXX | |||||||||||
| 59780 | JR C,59791 | This jump is always made | ||||||||||
|
The next section of code is never executed.
|
||||||||||||
| 59782 | LD H,219 | Point HL at one of the eight bytes at 56312 (which are all zero) | ||||||||||
| 59784 | LD A,(HL) | Pick up the byte | ||||||||||
| 59785 | AND A | Set the zero flag | ||||||||||
| 59786 | JR Z,59791 | This jump would always be made | ||||||||||
| 59788 | LD (43038),A | Update the attribute byte stored at 43038 | ||||||||||
|
Normal service resumes here.
|
||||||||||||
| 59791 | EXX | |||||||||||
| 59792 | LD A,(HL) | A=character's animatory state | ||||||||||
| 59793 | EXX | |||||||||||
| 59794 | LD D,199 | Point DE at the graphic data for the sprite tile | ||||||||||
| 59796 | LD HL,40990 | Point HL at the back buffer at 40990 | ||||||||||
| 59799 | RLCA | Is the character facing right? | ||||||||||
| 59800 | JR C,59817 | Jump if so | ||||||||||
|
The character is facing left, so we can use the tile as-is (there is no need to flip it).
|
||||||||||||
| 59802 | EX DE,HL | Now DE points at the back buffer, and HL points at the graphic data for the sprite tile | ||||||||||
| 59803 | LD A,(DE) | Pick up a graphic byte from the back buffer | ||||||||||
| 59804 | OR (HL) | OR on the sprite tile graphic byte | ||||||||||
| 59805 | INC H | Point HL at the sprite tile mask byte | ||||||||||
| 59806 | AND (HL) | AND on the sprite tile mask byte | ||||||||||
| 59807 | LD (DE),A | Update the back buffer byte | ||||||||||
| 59808 | INC H | Point HL at the next graphic byte of the sprite tile | ||||||||||
| 59809 | INC D | Point DE at the next byte of the back buffer | ||||||||||
| 59810 | BIT 3,D | Have we finished all 8 bytes? | ||||||||||
| 59812 | JR Z,59803 | Jump back if not | ||||||||||
| 59814 | EX DE,HL | This instruction is redundant | ||||||||||
| 59815 | JR 59836 | Consider the next character | ||||||||||
|
The character is facing right, so we need to flip the tile.
|
||||||||||||
| 59817 | LD B,126 | The table of mirror bytes is in page 126 | ||||||||||
| 59819 | LD A,(DE) | Pick up a sprite tile graphic byte | ||||||||||
| 59820 | LD C,A | Copy it to C | ||||||||||
| 59821 | LD A,(BC) | A=mirror image of the sprite tile graphic byte | ||||||||||
| 59822 | OR (HL) | OR on the back buffer graphic byte | ||||||||||
| 59823 | LD (HL),A | Store the result in the back buffer | ||||||||||
| 59824 | INC D | Point DE at the sprite tile mask byte | ||||||||||
| 59825 | LD A,(DE) | Pick this up in A | ||||||||||
| 59826 | LD C,A | Copy it to C | ||||||||||
| 59827 | LD A,(BC) | A=mirror image of the sprite tile mask byte | ||||||||||
| 59828 | AND (HL) | AND on the back buffer graphic byte | ||||||||||
| 59829 | LD (HL),A | Store the result in the back buffer | ||||||||||
| 59830 | INC D | Point DE at the next graphic byte of the sprite tile | ||||||||||
| 59831 | INC H | Point HL at the next byte of the back buffer | ||||||||||
| 59832 | BIT 3,H | Have we finished all 8 bytes? | ||||||||||
| 59834 | JR Z,59819 | Jump back if not | ||||||||||
| 59836 | EXX | |||||||||||
| 59837 | JR 59742 | Jump back to consider the next character | ||||||||||
| Prev: 59632 | Up: Map | Next: 59839 |