Routines |
Prev: 57863 | Up: Map | Next: 57947 |
Maroc's attribute colour value is set to 71 (INK 7, PAPER 0, BRIGHT 1) and stored at 60071.
This routine calculates and sets Maroc's colour on the screen (incorporating the screen's PAPER colour if needed)
Calculate Maroc's VERTICAL attribute display address position:
|
||||
57888 | LD A,(60097) | Maroc's vertical (Y-axis) position, in pixels. | ||
57891 | SUB 26 | Maroc's vertical position is calculated from the middle of the sprite, so move up 26 pixels to get to the top of his hat | ||
57893 | AND 248 | Character squares/attributes are in multiples of 8 pixels, therefore don't need bits 0-2 (values 0-7). Filter these so the vertical position is a multiple of 8 | ||
57895 | LD H,0 | Store calculated value in HL register | ||
57897 | LD L,A | To move down to the next screen attribute display square, you need to add 32 to the address. So address offset will be (y/8)*32, or y*4. So multiply by 4. | ||
57898 | ADD HL,HL | x2 | ||
57899 | ADD HL,HL | x4 | ||
Calculate Maroc's HORIZONTAL attribute display address position:
|
||||
57900 | LD A,(60096) | Maroc's horizontal (X-axis) position, in 4-pixel (half character rows) | ||
57903 | SRA A | Divide by 2 to get Maroc's horizontal position in full character rows | ||
57905 | LD E,A | |||
Calculate offset from top of screen attribute display address:
|
||||
57906 | LD D,0 | |||
57908 | ADD HL,DE | Combine the offsets calculated above | ||
57909 | LD DE,22560 | Screen attribute display position one square down from the top left of the screen | ||
57912 | ADD HL,DE | Add the combined vertical + horizontal offset to get to the top left of Maroc's sprite | ||
Attribute display address pointer is currently just above Maroc's sprite, so colour this in with the room PAPER colour:
|
||||
57913 | LD A,(60073) | Current room colour attribute value | ||
57916 | LD DE,29 | Offset ready to move down to the next character row (32 spaces) minus 3 spaces (3 spaces to the left) | ||
57919 | LD B,3 | 3 character wide area to colour in | ||
57921 | LD (HL),A | Colour the 3-character wide section with the room colour | ||
57922 | INC HL | |||
57923 | DJNZ 57921 | |||
Now combine the room colour with Maroc's sprite colour, so Maroc takes on the PAPER value of the room:
|
||||
57925 | LD A,(60073) | |||
57928 | LD C,A | |||
57929 | LD A,(60071) | Maroc's standard colour - 71 (BRIGHT 1, INK 7, PAPER 0) | ||
57932 | OR C | Combine Maroc's colour with the background (PAPER) colour of the screen | ||
Next, print Maroc's colour on-screen.
This paints a 3 x 6 coloured vertical space over Maroc's sprite.
Although the width of his sprite frames (38851) varies between 3 and 5 characters, a width of only 3 characters gets coloured in (possibly to reduce the extent of his colour clash). |
||||
57933 | ADD HL,DE | Move to the attribute display address for Maroc's vertical position | ||
57934 | LD C,6 | 6 characters in height | ||
57936 | LD B,3 | ...and 3 wide | ||
57938 | LD (HL),A | Colour in the square | ||
57939 | INC HL | |||
57940 | DJNZ 57938 | Repeat for 3 columns | ||
57942 | ADD HL,DE | Move down to next character line, and back left 2 characters | ||
57943 | DEC C | Repeat for 6 rows | ||
57944 | JR NZ,57936 | |||
57946 | RET |
Prev: 57863 | Up: Map | Next: 57947 |