![]() |
Routines |
| Prev: BC52 | Up: Map | Next: BCF4 |
|
Used by the routine at ApplySpriteAttributes3Wide.
Writes a colour attribute to a 3-wide block of attribute cells at the position derived from the screen buffer address in HL. The height is 2 rows if Y-aligned, or 3 rows if not. The width is 2 or 3 columns depending on bit 0 of D (X alignment).
|
||||||||||||||
|
Check if the Y position crosses a character boundary; if so, an extra row of attributes is needed.
|
||||||||||||||
| WriteAttributeBlock3Wide | BC74 | LD A,H | A=H. | |||||||||||
| BC75 | AND %00000111 | Keep only bits 0-2 (sub-character Y offset). | ||||||||||||
| BC77 | OR A | Jump to WriteAttributeBlock3Wide_CalcAddress if Y-aligned. | ||||||||||||
| BC78 | JR Z,WriteAttributeBlock3Wide_CalcAddress | |||||||||||||
| BC7A | SET 1,D | Set bit 1 of D (extra row needed). | ||||||||||||
|
Convert the screen buffer address to the corresponding attribute address.
|
||||||||||||||
| WriteAttributeBlock3Wide_CalcAddress | BC7C | LD A,H | A=H. | |||||||||||
| BC7D | RRCA | Rotate right three positions. | ||||||||||||
| BC7E | RRCA | |||||||||||||
| BC7F | RRCA | |||||||||||||
| BC80 | AND %00000011 | Keep only bits 0-1. | ||||||||||||
| BC82 | OR C | Merge with the attribute base in C. | ||||||||||||
| BC83 | LD H,A | H=A. | ||||||||||||
|
Branch based on whether an extra column is needed.
|
||||||||||||||
| BC84 | BIT 0,D | Test bit 0 of D. | ||||||||||||
| BC86 | JR Z,WriteAttributeBlock3Wide_2Columns | Jump to WriteAttributeBlock3Wide_2Columns if X-aligned (2 columns wide). | ||||||||||||
|
Not X-aligned: write attributes across 3 columns.
Write attribute to the first row (3 cells).
|
||||||||||||||
| WriteAttributeBlock3Wide_3Columns | BC88 | LD A,(HL) | Write the ink bits to *HL (preserve paper/brightness). | |||||||||||
| BC89 | AND %11111000 | |||||||||||||
| BC8B | OR E | |||||||||||||
| BC8C | LD (HL),A | |||||||||||||
| BC8D | INC HL | Move to the next column. | ||||||||||||
| BC8E | LD A,(HL) | Write the ink bits to *HL. | ||||||||||||
| BC8F | AND %11111000 | Keep only bits 3-7. | ||||||||||||
| BC91 | OR E | |||||||||||||
| BC92 | LD (HL),A | |||||||||||||
| BC93 | INC HL | Move to the next column. | ||||||||||||
| BC94 | LD A,(HL) | Write the ink bits to *HL. | ||||||||||||
| BC95 | AND %11111000 | |||||||||||||
| BC97 | OR E | |||||||||||||
| BC98 | LD (HL),A | |||||||||||||
|
Move back to the first column and down one attribute row.
|
||||||||||||||
| BC99 | DEC HL | Move back two columns. | ||||||||||||
| BC9A | DEC HL | |||||||||||||
| BC9B | LD BC,$0020 | HL+=0020 (move down one row). | ||||||||||||
| BC9E | ADD HL,BC | |||||||||||||
|
Write attribute to the second row (3 cells).
|
||||||||||||||
| BC9F | LD A,(HL) | Write the ink bits to *HL. | ||||||||||||
| BCA0 | AND %11111000 | |||||||||||||
| BCA2 | OR E | |||||||||||||
| BCA3 | LD (HL),A | |||||||||||||
| BCA4 | INC HL | Move to the next column. | ||||||||||||
| BCA5 | LD A,(HL) | Write the ink bits to *HL. | ||||||||||||
| BCA6 | AND %11111000 | |||||||||||||
| BCA8 | OR E | |||||||||||||
| BCA9 | LD (HL),A | |||||||||||||
| BCAA | INC HL | Move to the next column. | ||||||||||||
| BCAB | LD A,(HL) | Write the ink bits to *HL. | ||||||||||||
| BCAC | AND %11111000 | |||||||||||||
| BCAE | OR E | |||||||||||||
| BCAF | LD (HL),A | |||||||||||||
|
If Y-aligned, we're done. Otherwise write a third row.
|
||||||||||||||
| BCB0 | BIT 1,D | Test bit 1 of D. | ||||||||||||
| BCB2 | RET Z | Return if Y-aligned (no extra row needed). | ||||||||||||
|
Move back and down to the third row.
|
||||||||||||||
| BCB3 | DEC HL | Move back two columns. | ||||||||||||
| BCB4 | DEC HL | |||||||||||||
| BCB5 | ADD HL,BC | HL+=BC (move down one row). | ||||||||||||
|
Write attribute to the third row (3 cells).
|
||||||||||||||
| BCB6 | LD A,(HL) | Write the ink bits to *HL. | ||||||||||||
| BCB7 | AND %11111000 | |||||||||||||
| BCB9 | OR E | |||||||||||||
| BCBA | LD (HL),A | |||||||||||||
| BCBB | INC HL | Move to the next column. | ||||||||||||
| BCBC | LD A,(HL) | Write the ink bits to *HL. | ||||||||||||
| BCBD | AND %11111000 | |||||||||||||
| BCBF | OR E | |||||||||||||
| BCC0 | LD (HL),A | |||||||||||||
| BCC1 | INC HL | Move to the next column. | ||||||||||||
| BCC2 | LD A,(HL) | Write the ink bits to *HL. | ||||||||||||
| BCC3 | AND %11111000 | |||||||||||||
| BCC5 | OR E | |||||||||||||
| BCC6 | LD (HL),A | |||||||||||||
| BCC7 | RET | Return. | ||||||||||||
|
X-aligned: write attributes across 2 columns only.
Write attribute to the first row (2 cells).
|
||||||||||||||
| WriteAttributeBlock3Wide_2Columns | BCC8 | LD A,(HL) | Write the ink bits to *HL. | |||||||||||
| BCC9 | AND %11111000 | |||||||||||||
| BCCB | OR E | |||||||||||||
| BCCC | LD (HL),A | |||||||||||||
| BCCD | INC HL | Move to the next column. | ||||||||||||
| BCCE | LD A,(HL) | Write the ink bits to *HL. | ||||||||||||
| BCCF | AND %11111000 | |||||||||||||
| BCD1 | OR E | |||||||||||||
| BCD2 | LD (HL),A | |||||||||||||
|
Move back and down one attribute row.
|
||||||||||||||
| BCD3 | DEC HL | Move back one column. | ||||||||||||
| BCD4 | LD BC,$0020 | HL+=0020 (move down one row). | ||||||||||||
| BCD7 | ADD HL,BC | |||||||||||||
|
Write attribute to the second row (2 cells).
|
||||||||||||||
| BCD8 | LD A,(HL) | Write the ink bits to *HL. | ||||||||||||
| BCD9 | AND %11111000 | |||||||||||||
| BCDB | OR E | |||||||||||||
| BCDC | LD (HL),A | |||||||||||||
| BCDD | INC HL | Move to the next column. | ||||||||||||
| BCDE | LD A,(HL) | Write the ink bits to *HL. | ||||||||||||
| BCDF | AND %11111000 | |||||||||||||
| BCE1 | OR E | |||||||||||||
| BCE2 | LD (HL),A | |||||||||||||
|
If Y-aligned, we're done. Otherwise write a third row.
|
||||||||||||||
| BCE3 | BIT 1,D | Test bit 1 of D. | ||||||||||||
| BCE5 | RET Z | Return if Y-aligned. | ||||||||||||
|
Move back and down to the third row.
|
||||||||||||||
| BCE6 | DEC HL | Move back one column. | ||||||||||||
| BCE7 | ADD HL,BC | HL+=BC (move down one row). | ||||||||||||
|
Write attribute to the third row (2 cells).
|
||||||||||||||
| BCE8 | LD A,(HL) | Write the ink bits to *HL. | ||||||||||||
| BCE9 | AND %11111000 | |||||||||||||
| BCEB | OR E | |||||||||||||
| BCEC | LD (HL),A | |||||||||||||
| BCED | INC HL | Move to the next column. | ||||||||||||
| BCEE | LD A,(HL) | Write the ink bits to *HL. | ||||||||||||
| BCEF | AND %11111000 | |||||||||||||
| BCF1 | OR E | |||||||||||||
| BCF2 | LD (HL),A | |||||||||||||
| BCF3 | RET | Return. | ||||||||||||
| Prev: BC52 | Up: Map | Next: BCF4 |