![]() |
Routines |
| Prev: A57E | Up: Map | Next: A629 |
|
Erases one sprite and draws another straight on the screen instead of using a buffer. The rows of the two sprites are dealt with one at a time, alternating between an erased row and a drawn row, so that they stay in step. The sprite that is lower on the screen starts first, as the rows of a sprite go up the screen, and its first rows are done by themselves until the other sprite starts. The sprites are set up by SetSecondRowGroup and SetFirstRowGroup, which store the number of rows at 5C1C and 5C1D. The first sprite is erased using the alternate registers and the second sprite is drawn using the main registers.
|
||||||||||||||||||
| DrawSpritesDirectly | A59F | LD A,L | Fetch the low byte of the screen address of the second sprite. | |||||||||||||||
| A5A0 | LD ($5C29),A | Store it as the start of a row. | ||||||||||||||||
| A5A3 | EXX | Switch to the first sprite. | ||||||||||||||||
| A5A4 | LD A,L | Fetch the low byte of its screen address. | ||||||||||||||||
| A5A5 | LD ($5C28),A | Store it as the start of a row. | ||||||||||||||||
| A5A8 | EXX | Switch back to the second sprite. | ||||||||||||||||
| A5A9 | LD A,($5C1D) | Fetch the number of rows of the second sprite. | ||||||||||||||||
| A5AC | EX AF,AF' | Keep it in the alternate accumulator. | ||||||||||||||||
| A5AD | LD A,($5C1C) | Fetch the number of rows of the first sprite. | ||||||||||||||||
| A5B0 | AND A | Test it. | ||||||||||||||||
| A5B1 | JP Z,DrawSpritesDirectly_Row | Jump to DrawSpritesDirectly_Row if the first sprite has no rows. | ||||||||||||||||
| A5B4 | LD A,($5C1D) | Fetch the number of rows of the second sprite. | ||||||||||||||||
| A5B7 | AND A | Test it. | ||||||||||||||||
| A5B8 | JP Z,DrawSpritesDirectly_Row | Jump to DrawSpritesDirectly_Row if the second sprite has no rows. | ||||||||||||||||
| A5BB | LD A,($A289) | Fetch the vertical position of the first sprite. | ||||||||||||||||
| A5BE | LD C,A | Store it in C. | ||||||||||||||||
| A5BF | LD A,($A28A) | Fetch the vertical position of the second sprite. | ||||||||||||||||
| A5C2 | SUB C | Subtract the position of the first sprite. | ||||||||||||||||
| A5C3 | JP Z,DrawSpritesDirectly_Row | Jump to DrawSpritesDirectly_Row if they start on the same row. | ||||||||||||||||
| A5C6 | JR NC,DrawSpritesDirectly_Second | Jump to DrawSpritesDirectly_Second if the second sprite is the lower one. | ||||||||||||||||
|
The first sprite is the lower one, so do its first rows by themselves.
|
||||||||||||||||||
| A5C8 | NEG | Make the difference positive. | ||||||||||||||||
| A5CA | LD C,A | Store it in C. | ||||||||||||||||
| A5CB | LD A,($5C1C) | Fetch the number of rows of the first sprite. | ||||||||||||||||
| A5CE | SUB C | Take off the difference. | ||||||||||||||||
| A5CF | LD ($A289),A | Store it for later. | ||||||||||||||||
| A5D2 | JR C,DrawSpritesDirectly_First | Jump to DrawSpritesDirectly_First if the first sprite has fewer rows than that. | ||||||||||||||||
| A5D4 | LD A,C | Otherwise use the difference as the number of rows to do. | ||||||||||||||||
| A5D5 | LD ($5C1C),A | Store it. | ||||||||||||||||
| DrawSpritesDirectly_First | A5D8 | XOR A | Clear A. | |||||||||||||||
| A5D9 | EX AF,AF' | Make the second sprite have no rows for now. | ||||||||||||||||
| A5DA | CALL DrawSpritesDirectly_Row | Do the rows of the first sprite. | ||||||||||||||||
| A5DD | EXX | Switch to the second sprite. | ||||||||||||||||
| A5DE | LD A,($A289) | Fetch the number of rows that are left for the first sprite. | ||||||||||||||||
| A5E1 | LD ($5C1C),A | Store it. | ||||||||||||||||
| A5E4 | LD A,($5C1D) | Fetch the number of rows of the second sprite. | ||||||||||||||||
| A5E7 | EX AF,AF' | Restore it. | ||||||||||||||||
| A5E8 | JP DrawSpritesDirectly_Row | Jump to DrawSpritesDirectly_Row to do the rows of both sprites. | ||||||||||||||||
|
The second sprite is the lower one, so do its first rows by themselves.
|
||||||||||||||||||
| DrawSpritesDirectly_Second | A5EB | LD C,A | Store the difference in C. | |||||||||||||||
| A5EC | LD A,($5C1D) | Fetch the number of rows of the second sprite. | ||||||||||||||||
| A5EF | SUB C | Take off the difference. | ||||||||||||||||
| A5F0 | LD ($A28A),A | Store it for later. | ||||||||||||||||
| A5F3 | JR C,DrawSpritesDirectly_SecondRows | Jump to DrawSpritesDirectly_SecondRows if the second sprite has fewer rows than that. | ||||||||||||||||
| A5F5 | LD A,C | Otherwise use the difference as the number of rows to do. | ||||||||||||||||
| A5F6 | EX AF,AF' | Store it. | ||||||||||||||||
| DrawSpritesDirectly_SecondRows | A5F7 | LD A,($5C1C) | Fetch the number of rows of the first sprite. | |||||||||||||||
| A5FA | LD ($A289),A | Keep it. | ||||||||||||||||
| A5FD | XOR A | Clear A. | ||||||||||||||||
| A5FE | LD ($5C1C),A | Make the first sprite have no rows for now. | ||||||||||||||||
| A601 | CALL DrawSpritesDirectly_Row | Do the rows of the second sprite. | ||||||||||||||||
| A604 | LD A,($A289) | Fetch the number of rows of the first sprite. | ||||||||||||||||
| A607 | LD ($5C1C),A | Restore it. | ||||||||||||||||
| A60A | LD A,($A28A) | Fetch the number of rows that are left for the second sprite. | ||||||||||||||||
| A60D | EX AF,AF' | Store it. | ||||||||||||||||
| A60E | JP DrawSpritesDirectly_Row | Jump to DrawSpritesDirectly_Row to do the rows of both sprites. | ||||||||||||||||
|
This entry point is used by the routine at DrawNextRow.
|
||||||||||||||||||
| DrawSpritesDirectly_SecondRow | A611 | EX AF,AF' | Switch to the count of the second sprite. | |||||||||||||||
| A612 | LD A,($5C1C) | Fetch the number of rows of the first sprite. | ||||||||||||||||
| A615 | DEC A | Take one off. | ||||||||||||||||
| A616 | RET M | Return if there are none left. | ||||||||||||||||
| A617 | LD ($5C1C),A | Store it. | ||||||||||||||||
| A61A | JP (IY) | Erase a row of the first sprite. | ||||||||||||||||
|
This entry point is used by the routine at DrawAlignedRowDirectly.
|
||||||||||||||||||
| DrawSpritesDirectly_Row | A61C | LD A,($5C1C) | Fetch the number of rows of the first sprite. | |||||||||||||||
| A61F | DEC A | Take one off. | ||||||||||||||||
| A620 | JP M,NextRowOfSecondSprite | Jump to NextRowOfSecondSprite if there are none left. | ||||||||||||||||
| A623 | LD ($5C1C),A | Store it. | ||||||||||||||||
| A626 | EXX | Switch to the first sprite. | ||||||||||||||||
| A627 | JP (IY) | Erase a row of the first sprite. | ||||||||||||||||
| Prev: A57E | Up: Map | Next: A629 |