Prev: 63837 Up: Map Next: 63953
63838: Change Sam's disguise
Continues from the routine at 64218. Replaces certain sprite tiles that are used by Sam's animatory states (thus changing his appearance), and then draws Sam's new disguise in the bottom right corner of the screen.
Input
H 230 (Sam)
63838 LD L,8 Set Sam's main action timer (in byte 8 of his buffer) to 8
63840 LD (HL),L
63841 LD HL,32713 32713 holds Sam's current disguise ID
63844 LD A,(HL) Pick this up in A
63845 INC A A=next disguise ID (0-7)
63846 AND 7
63848 LD (HL),A Store the new disguise ID
This entry point is used by the routine at 30989.
63849 CALL 32010 Set the attribute bytes for Sam's current disguise
63852 LD A,(32713) A=Sam's disguise ID (0-7)
63855 ADD A,223 Point BC at the reference for the first replacement tile (in the data table at 57150, 57406, 57662, 57918, 58174, 58430, 58686 or 58942)
63857 LD B,A
63858 LD C,62
63860 EXX
63861 LD HL,56893 HL' will index the sprite tile reference data table at 56894
63864 EXX
63865 EXX
63866 INC L Point HL' at the next sprite tile reference
63867 LD A,(HL) Collect the tile reference in A
63868 EXX
63869 AND A Have we reached the end of the table?
63870 JR Z,63914 Jump if so
63872 LD E,A Point DE at the first byte of graphic data for this sprite tile
63873 LD D,199
63875 LD A,(BC) A=reference for the replacement tile
63876 INC C Point BC at the reference for the next replacement tile
63877 CP 126 Set the carry flag if the tile reference is < 126
63879 LD L,A L=reference for the replacement tile
63880 JR NC,63900 Jump if we're dealing with a tile reference >= 126
We're dealing with a replacement tile (of Sam in disguise) whose reference is < 126. The graphic data for such tiles is arranged in 8 pairs (graphic byte, mask byte) in bytes 80-125 across pages 223-230.
63882 LD H,223 Point HL at the graphic data for the replacement tile
63884 LD A,(HL) Copy a byte of graphic data from the replacement tile into the target sprite tile
63885 LD (DE),A
63886 INC D Point DE at the next byte of mask data for the target sprite tile
63887 INC L Point HL at the next byte of mask data for the replacement tile
63888 LD A,(HL) Copy a byte of mask data from the replacement tile into the target sprite tile
63889 LD (DE),A
63890 INC D Point DE at the next byte of graphic data for the target sprite tile
63891 DEC L Point HL at the next byte of graphic data for the replacement tile
63892 INC H
63893 LD A,H Have we copied the replacement tile over the target sprite tile yet?
63894 CP 231
63896 JR NZ,63884 Jump back if not
63898 JR 63865 Jump back to deal with the next replacement tile
We're dealing with a replacement tile whose reference is >= 126. The graphic data for such tiles is arranged in groups of 16 (8 pairs of graphic bytes and mask bytes) across pages 215-230.
63900 LD H,215 Point HL at the graphic data for the replacement tile
63902 PUSH BC Save the replacement tile reference pointer
63903 LD B,16 There are 16 bytes of graphic and mask data to copy
63905 LD A,(HL) Copy the replacement tile over the target sprite tile
63906 LD (DE),A
63907 INC D
63908 INC H
63909 DJNZ 63905
63911 POP BC Restore the replacement tile reference pointer to BC
63912 JR 63865 Jump back to deal with the next replacement tile
Now we can draw Sam's disguise in the bottom right of the screen.
63914 LD HL,55170 This is the address of the tile reference for the top-left tile in Sam's sprite (animatory state 0)
63917 LD DE,20669 20669 is the display file address for the leftmost byte in the top row of pixels of Sam's disguise in the bottom right of the screen
63920 PUSH HL Save the sprite tile reference pointer
63921 LD L,(HL) Point HL at the first byte of graphic data for this tile
63922 LD H,199
63924 LD A,(HL) Copy the tile to the screen
63925 LD (DE),A
63926 INC H
63927 INC H
63928 INC D
63929 BIT 3,D
63931 JR Z,63924
63933 POP HL Restore the sprite tile reference pointer to HL
63934 INC H Point HL at the next tile reference
63935 LD D,80 Set DE to the display file address for the next tile
63937 LD A,E
63938 ADD A,32
63940 LD E,A
63941 JR NC,63920 Jump back unless we've finished a column of three tiles
63943 CP 31 Have we just finished the third column?
63945 RET Z Return if so
63946 SUB 95 Set DE to the display file address for the first tile in the next column
63948 LD E,A
63949 INC H Point HL at the reference for the first tile in this column
63950 INC H
63951 JR 63920 Jump back to draw this column of tiles
Prev: 63837 Up: Map Next: 63953