Prev: 40707 Up: Map Next: 40768
40723: Draw Actor Sprite Row
Does the same as DrawOldSpriteRow_Aligned, but for the sprite prepared by PrepDraw2_NoFetch (the new sprite).
Input
DE The address of the row of sprite data
HL The screen address
Output
DE The address of the next row of sprite data
HL The screen address of the row above
The entry point for a sprite which is aligned to a character cell. DrawActorSpriteRow_Shift jumps here when the shift is the one which does nothing.
DrawActorSpriteRow_Aligned 40723 EX DE,HL DE=the row of sprite data, and HL=the address of the next row.
40724 EX (SP),HL Fetch the screen address, and the address of the next row of sprite data is stored on the stack.
40725 LD A,D Fetch the first byte of the row.
40726 XOR (HL) Exclusive OR it onto the screen.
40727 LD (HL),A Write the result to the screen.
40728 INC L Move to the next byte on the screen.
40729 LD A,E Fetch the second byte of the row.
40730 XOR (HL) Exclusive OR it onto the screen.
40731 LD (HL),A Write the result to the screen.
40732 POP DE Fetch the address of the next row of sprite data.
40733 DEC L Move back to the first byte on the screen.
40734 JP ScreenPosition1PixelAbove Jump to ScreenPosition1PixelAbove to move up one pixel row.
This entry point is used by the routine at XORSpriteLoop.
The entry point for a sprite which is not aligned to a character cell.
DrawActorSpriteRow 40737 EX DE,HL HL=the address of the sprite data, and DE=the screen address.
40738 PUSH DE Stash the screen address on the stack.
40739 LD D,(HL) Fetch the first byte of the row.
40740 INC HL Move to the next byte of sprite data.
40741 LD E,(HL) Fetch the second byte of the row.
40742 INC HL Move on to the next row of sprite data.
40743 EX DE,HL HL=the row of sprite data, and DE=the address of the next row.
40744 XOR A A=0.
Self modifying code; the operand of this command is written by 40883. It jumps into the run of shifts below so that the row is moved the right number of pixels, or to DrawActorSpriteRow_Aligned for a sprite which does not need to be shifted.
DrawActorSpriteRow_Shift 40745 JR DrawActorSpriteRow_Shift Jump to the first shift to do.
Shift the row left by up to seven bits; the bits which are shifted out of the row end up in A.
40747 ADD HL,HL Shift HL left by one, moving the bit shifted out into A (seven times).
40748 ADC A,A
40749 ADD HL,HL
40750 ADC A,A
40751 ADD HL,HL
40752 ADC A,A
40753 ADD HL,HL
40754 ADC A,A
40755 ADD HL,HL
40756 ADC A,A
40757 ADD HL,HL
40758 ADC A,A
40759 ADD HL,HL
40760 ADC A,A
40761 EX DE,HL DE=the shifted row, and HL=the address of the next row of sprite data.
40762 EX (SP),HL Fetch the screen address, and the address of the next row of sprite data is stored on the stack.
40763 XOR (HL) Exclusive OR the first byte (in A) onto the screen.
40764 LD (HL),A Write the result to the screen.
40765 INC L Move to the next byte on the screen.
40766 JR DrawSpriteRow_Write Jump to DrawSpriteRow_Write to XOR the other two bytes onto the screen.
Prev: 40707 Up: Map Next: 40768