![]() |
Routines |
| Prev: B9DA | Up: Map | Next: BA8C |
|
Used by the routine at XORSpriteLoop.
Draws one row of the old sprite, using XOR, and moves up to the next row.
The row is drawn by unrolled code with one piece of 0C bytes for each byte of the row (up to eight bytes, with the last piece being longer so it can stop at the right of the screen). The operand of the jump at DrawOldEntityRow_0 is changed by PrepDraw23 so that the jump lands on the first piece that is needed. If the sprite is aligned to a character boundary the jump goes six bytes further in, which leaves out the first write.
|
||||||||||||||||||||||
| DrawOldEntityRow | BA0D | LD A,C | Copy the row count to A. | |||||||||||||||||||
| BA0E | EX AF,AF' | Store the row count in AF'. | ||||||||||||||||||||
| BA0F | LD A,(DE) | Fetch the first byte of the row. | ||||||||||||||||||||
| BA10 | LD C,A | Copy it to C to use as the index into the shift table. | ||||||||||||||||||||
| BA11 | PUSH HL | Stash the screen address on the stack. | ||||||||||||||||||||
| DrawOldEntityRow_0 | BA12 | JR DrawOldEntityRow_0 | Jump into the unrolled code. The operand of this instruction is changed by PrepDraw23. | |||||||||||||||||||
| DrawOldEntityRow_Byte_1 | BA14 | LD A,(DE) | Byte 1 of the row: look up the shifted byte for the left cell and XOR it onto the screen. | |||||||||||||||||||
| BA15 | LD C,A | |||||||||||||||||||||
| BA16 | LD A,(BC) | |||||||||||||||||||||
| BA17 | XOR (HL) | |||||||||||||||||||||
| BA18 | LD (HL),A | |||||||||||||||||||||
| BA19 | INC L | |||||||||||||||||||||
| DrawOldEntityRow_Byte_1_Right | BA1A | INC B | Look up the shifted byte for the cell to the right and XOR it onto the screen, then move on to the next byte of pixel data. | |||||||||||||||||||
| BA1B | LD A,(BC) | |||||||||||||||||||||
| BA1C | XOR (HL) | |||||||||||||||||||||
| BA1D | LD (HL),A | |||||||||||||||||||||
| BA1E | DEC B | |||||||||||||||||||||
| BA1F | INC DE | |||||||||||||||||||||
| DrawOldEntityRow_Byte_2 | BA20 | LD A,(DE) | Byte 2 of the row: look up the shifted byte for the left cell and XOR it onto the screen. | |||||||||||||||||||
| BA21 | LD C,A | |||||||||||||||||||||
| BA22 | LD A,(BC) | |||||||||||||||||||||
| BA23 | XOR (HL) | |||||||||||||||||||||
| BA24 | LD (HL),A | |||||||||||||||||||||
| BA25 | INC L | |||||||||||||||||||||
| DrawOldEntityRow_Byte_2_Right | BA26 | INC B | Look up the shifted byte for the cell to the right and XOR it onto the screen, then move on to the next byte of pixel data. | |||||||||||||||||||
| BA27 | LD A,(BC) | |||||||||||||||||||||
| BA28 | XOR (HL) | |||||||||||||||||||||
| BA29 | LD (HL),A | |||||||||||||||||||||
| BA2A | DEC B | |||||||||||||||||||||
| BA2B | INC DE | |||||||||||||||||||||
| DrawOldEntityRow_Byte_3 | BA2C | LD A,(DE) | Byte 3 of the row: look up the shifted byte for the left cell and XOR it onto the screen. | |||||||||||||||||||
| BA2D | LD C,A | |||||||||||||||||||||
| BA2E | LD A,(BC) | |||||||||||||||||||||
| BA2F | XOR (HL) | |||||||||||||||||||||
| BA30 | LD (HL),A | |||||||||||||||||||||
| BA31 | INC L | |||||||||||||||||||||
| DrawOldEntityRow_Byte_3_Right | BA32 | INC B | Look up the shifted byte for the cell to the right and XOR it onto the screen, then move on to the next byte of pixel data. | |||||||||||||||||||
| BA33 | LD A,(BC) | |||||||||||||||||||||
| BA34 | XOR (HL) | |||||||||||||||||||||
| BA35 | LD (HL),A | |||||||||||||||||||||
| BA36 | DEC B | |||||||||||||||||||||
| BA37 | INC DE | |||||||||||||||||||||
| DrawOldEntityRow_Byte_4 | BA38 | LD A,(DE) | Byte 4 of the row: look up the shifted byte for the left cell and XOR it onto the screen. | |||||||||||||||||||
| BA39 | LD C,A | |||||||||||||||||||||
| BA3A | LD A,(BC) | |||||||||||||||||||||
| BA3B | XOR (HL) | |||||||||||||||||||||
| BA3C | LD (HL),A | |||||||||||||||||||||
| BA3D | INC L | |||||||||||||||||||||
| DrawOldEntityRow_Byte_4_Right | BA3E | INC B | Look up the shifted byte for the cell to the right and XOR it onto the screen, then move on to the next byte of pixel data. | |||||||||||||||||||
| BA3F | LD A,(BC) | |||||||||||||||||||||
| BA40 | XOR (HL) | |||||||||||||||||||||
| BA41 | LD (HL),A | |||||||||||||||||||||
| BA42 | DEC B | |||||||||||||||||||||
| BA43 | INC DE | |||||||||||||||||||||
| DrawOldEntityRow_Byte_5 | BA44 | LD A,(DE) | Byte 5 of the row: look up the shifted byte for the left cell and XOR it onto the screen. | |||||||||||||||||||
| BA45 | LD C,A | |||||||||||||||||||||
| BA46 | LD A,(BC) | |||||||||||||||||||||
| BA47 | XOR (HL) | |||||||||||||||||||||
| BA48 | LD (HL),A | |||||||||||||||||||||
| BA49 | INC L | |||||||||||||||||||||
| DrawOldEntityRow_Byte_5_Right | BA4A | INC B | Look up the shifted byte for the cell to the right and XOR it onto the screen, then move on to the next byte of pixel data. | |||||||||||||||||||
| BA4B | LD A,(BC) | |||||||||||||||||||||
| BA4C | XOR (HL) | |||||||||||||||||||||
| BA4D | LD (HL),A | |||||||||||||||||||||
| BA4E | DEC B | |||||||||||||||||||||
| BA4F | INC DE | |||||||||||||||||||||
| DrawOldEntityRow_Byte_6 | BA50 | LD A,(DE) | Byte 6 of the row: look up the shifted byte for the left cell and XOR it onto the screen. | |||||||||||||||||||
| BA51 | LD C,A | |||||||||||||||||||||
| BA52 | LD A,(BC) | |||||||||||||||||||||
| BA53 | XOR (HL) | |||||||||||||||||||||
| BA54 | LD (HL),A | |||||||||||||||||||||
| BA55 | INC L | |||||||||||||||||||||
| DrawOldEntityRow_Byte_6_Right | BA56 | INC B | Look up the shifted byte for the cell to the right and XOR it onto the screen, then move on to the next byte of pixel data. | |||||||||||||||||||
| BA57 | LD A,(BC) | |||||||||||||||||||||
| BA58 | XOR (HL) | |||||||||||||||||||||
| BA59 | LD (HL),A | |||||||||||||||||||||
| BA5A | DEC B | |||||||||||||||||||||
| BA5B | INC DE | |||||||||||||||||||||
| DrawOldEntityRow_Byte_7 | BA5C | LD A,(DE) | Byte 7 of the row: look up the shifted byte for the left cell and XOR it onto the screen. | |||||||||||||||||||
| BA5D | LD C,A | |||||||||||||||||||||
| BA5E | LD A,(BC) | |||||||||||||||||||||
| BA5F | XOR (HL) | |||||||||||||||||||||
| BA60 | LD (HL),A | |||||||||||||||||||||
| BA61 | INC L | |||||||||||||||||||||
| DrawOldEntityRow_Byte_7_Right | BA62 | INC B | Look up the shifted byte for the cell to the right and XOR it onto the screen, then move on to the next byte of pixel data. | |||||||||||||||||||
| BA63 | LD A,(BC) | |||||||||||||||||||||
| BA64 | XOR (HL) | |||||||||||||||||||||
| BA65 | LD (HL),A | |||||||||||||||||||||
| BA66 | DEC B | |||||||||||||||||||||
| BA67 | INC DE | |||||||||||||||||||||
| DrawOldEntityRow_Byte_8 | BA68 | LD A,(DE) | Byte 8 of the row: look up the shifted byte for the left cell and XOR it onto the screen. | |||||||||||||||||||
| BA69 | LD C,A | |||||||||||||||||||||
| BA6A | LD A,(BC) | |||||||||||||||||||||
| BA6B | XOR (HL) | |||||||||||||||||||||
| BA6C | LD (HL),A | |||||||||||||||||||||
| BA6D | INC L | |||||||||||||||||||||
| DrawOldEntityRow_Byte_8_Right | BA6E | LD A,L | A=L. | |||||||||||||||||||
| BA6F | AND %00011111 | Keep only bits 0-4. | ||||||||||||||||||||
| BA71 | JR Z,DrawOldEntityRow_Byte_8_Next | Jump to DrawOldEntityRow_Byte_8_Next if the first cell was at the right of the screen, as the second cell is then not written. | ||||||||||||||||||||
| BA73 | INC B | Look up the shifted byte for the cell to the right and XOR it onto the screen. | ||||||||||||||||||||
| BA74 | LD A,(BC) | |||||||||||||||||||||
| BA75 | XOR (HL) | |||||||||||||||||||||
| BA76 | LD (HL),A | |||||||||||||||||||||
| BA77 | DEC B | |||||||||||||||||||||
| DrawOldEntityRow_Byte_8_Next | BA78 | INC DE | Move on to the next byte of pixel data. | |||||||||||||||||||
| BA79 | EX AF,AF' | Fetch the row count from AF'. | ||||||||||||||||||||
| BA7A | LD C,A | Copy the row count to C. | ||||||||||||||||||||
| BA7B | POP HL | Restore the screen address from the stack. | ||||||||||||||||||||
| BA7C | DEC H | Move up one pixel line. | ||||||||||||||||||||
| BA7D | LD A,H | A=H. | ||||||||||||||||||||
| BA7E | CPL | Flip the bits. | ||||||||||||||||||||
| BA7F | AND %00000111 | Keep only the pixel line bits (bits 0-2). | ||||||||||||||||||||
| BA81 | RET NZ | Return if the move up stayed inside the same character cell. | ||||||||||||||||||||
| BA82 | LD A,L | Subtract 20 from the low byte to move up to the previous character row. | ||||||||||||||||||||
| BA83 | SUB $20 | |||||||||||||||||||||
| BA85 | LD L,A | |||||||||||||||||||||
| BA86 | RET C | Return if the move up stayed inside the same third of the screen. | ||||||||||||||||||||
| BA87 | LD A,H | Add 08 to the high byte to move up to the previous third of the screen. | ||||||||||||||||||||
| BA88 | ADD A,$08 | |||||||||||||||||||||
| BA8A | LD H,A | |||||||||||||||||||||
| BA8B | RET | Return. | ||||||||||||||||||||
|
View the equivalent code in;
|
||||||||||||||||||||||
| Prev: B9DA | Up: Map | Next: BA8C |