Routines |
Prev: E207 | Up: Map | Next: E25B |
Maroc's attribute colour value is set to 71 (INK 7, PAPER 0, BRIGHT 1) and stored at EAA7.
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:
|
||||
E220 | LD A,($EAC1) | Maroc's vertical (Y-axis) position, in pixels. | ||
E223 | SUB $1A | 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 | ||
E225 | AND $F8 | 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 | ||
E227 | LD H,$00 | Store calculated value in HL register | ||
E229 | 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. | ||
E22A | ADD HL,HL | x2 | ||
E22B | ADD HL,HL | x4 | ||
Calculate Maroc's HORIZONTAL attribute display address position:
|
||||
E22C | LD A,($EAC0) | Maroc's horizontal (X-axis) position, in 4-pixel (half character rows) | ||
E22F | SRA A | Divide by 2 to get Maroc's horizontal position in full character rows | ||
E231 | LD E,A | |||
Calculate offset from top of screen attribute display address:
|
||||
E232 | LD D,$00 | |||
E234 | ADD HL,DE | Combine the offsets calculated above | ||
E235 | LD DE,$5820 | Screen attribute display position one square down from the top left of the screen | ||
E238 | 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:
|
||||
E239 | LD A,($EAA9) | Current room colour attribute value | ||
E23C | LD DE,$001D | Offset ready to move down to the next character row (32 spaces) minus 3 spaces (3 spaces to the left) | ||
E23F | LD B,$03 | 3 character wide area to colour in | ||
E241 | LD (HL),A | Colour the 3-character wide section with the room colour | ||
E242 | INC HL | |||
E243 | DJNZ $E241 | |||
Now combine the room colour with Maroc's sprite colour, so Maroc takes on the PAPER value of the room:
|
||||
E245 | LD A,($EAA9) | |||
E248 | LD C,A | |||
E249 | LD A,($EAA7) | Maroc's standard colour - 71 (BRIGHT 1, INK 7, PAPER 0) | ||
E24C | 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 (97C3) varies between 3 and 5 characters, a width of only 3 characters gets coloured in (possibly to reduce the extent of his colour clash). |
||||
E24D | ADD HL,DE | Move to the attribute display address for Maroc's vertical position | ||
E24E | LD C,$06 | 6 characters in height | ||
E250 | LD B,$03 | ...and 3 wide | ||
E252 | LD (HL),A | Colour in the square | ||
E253 | INC HL | |||
E254 | DJNZ $E252 | Repeat for 3 columns | ||
E256 | ADD HL,DE | Move down to next character line, and back left 2 characters | ||
E257 | DEC C | Repeat for 6 rows | ||
E258 | JR NZ,$E250 | |||
E25A | RET |
Prev: E207 | Up: Map | Next: E25B |