| Prev: 936B | Up: Map | Next: 9388 |
936F: Handle old position attributes when sprite is at screen top (row 0).
|
When Y AND $F8 = 0, the sprite is in attribute row 0 (pixel rows 0-7). Instead of writing attributes to row 0, this routine wraps around and writes to the bottom of the viewport. This preserves row 0 as black, creating an 8-pixel blank zone where sprites are invisible. Adds $03DF (31 rows × 32 bytes - 1 = 991) to wrap the address, then subtracts $03DF after each row to maintain the wrap.
|
||||
| set_attr_wrap_old | 936F | LD BC,$03DF | Add $03DF to HL to correct wrapped address. Restore and re-save BC. | |
| 9372 | ADD HL,BC | |||
| 9373 | POP BC | |||
| 9374 | PUSH BC | |||
| set_attr_wrap_old_loop | 9375 | LD (HL),A | Inner loop: write attribute A to HL, increment HL, decrement C, repeat for row width. | |
| 9376 | INC HL | |||
| 9377 | DEC C | |||
| 9378 | JR NZ,set_attr_wrap_old_loop | |||
| 937A | POP BC | After row: restore BC, add stride DE, decrement B, re-save BC. Subtract $03DF from HL to maintain wrap. Jump back to set_attr_old_outer_loop for next row. | ||
| 937B | ADD HL,DE | |||
| 937C | DEC B | |||
| 937D | PUSH BC | |||
| 937E | LD BC,$03DF | |||
| 9381 | OR A | |||
| 9382 | SBC HL,BC | |||
| 9384 | POP BC | |||
| 9385 | JP set_attr_old_outer_loop | |||
| Prev: 936B | Up: Map | Next: 9388 |