Prev: 40603 Up: Map Next: 40707
40654: Draw Old Sprite Row
XORs one row of the old sprite onto the screen, then moves up to the row above. The row is two bytes of graphic data, which are written to two bytes of the screen when the sprite is aligned to a character cell, and otherwise are shifted along and written to three bytes.
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. DrawOldSpriteRow_Shift jumps here when the shift is the one which does nothing.
DrawOldSpriteRow_Aligned 40654 EX DE,HL DE=the row of sprite data, and HL=the address of the next row.
40655 EX (SP),HL Fetch the screen address, and the address of the next row of sprite data is stored on the stack.
40656 LD A,D Fetch the first byte of the row.
40657 XOR (HL) Exclusive OR it onto the screen.
40658 LD (HL),A Write the result to the screen.
40659 INC L Move to the next byte on the screen.
40660 LD A,E Fetch the second byte of the row.
40661 XOR (HL) Exclusive OR it onto the screen.
40662 LD (HL),A Write the result to the screen.
40663 POP DE Fetch the address of the next row of sprite data.
40664 DEC L Move back to the first byte on the screen.
40665 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.
DrawOldSpriteRow 40668 EX DE,HL HL=the address of the sprite data, and DE=the screen address.
40669 PUSH DE Stash the screen address on the stack.
40670 LD D,(HL) Fetch the first byte of the row.
40671 INC HL Move to the next byte of sprite data.
40672 LD E,(HL) Fetch the second byte of the row.
40673 INC HL Move on to the next row of sprite data.
40674 EX DE,HL HL=the row of sprite data, and DE=the address of the next row.
40675 XOR A A=0.
Self modifying code; the operand of this command is written by 40849. It jumps into the run of shifts below so that the row is moved the right number of pixels, or to DrawOldSpriteRow_Aligned for a sprite which does not need to be shifted.
DrawOldSpriteRow_Shift 40676 JR DrawOldSpriteRow_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.
40678 ADD HL,HL Shift HL left by one, moving the bit shifted out into A (seven times).
40679 ADC A,A
40680 ADD HL,HL
40681 ADC A,A
40682 ADD HL,HL
40683 ADC A,A
40684 ADD HL,HL
40685 ADC A,A
40686 ADD HL,HL
40687 ADC A,A
40688 ADD HL,HL
40689 ADC A,A
40690 ADD HL,HL
40691 ADC A,A
40692 EX DE,HL DE=the shifted row, and HL=the address of the next row of sprite data.
40693 EX (SP),HL Fetch the screen address, and the address of the next row of sprite data is stored on the stack.
40694 XOR (HL) Exclusive OR the first byte (in A) onto the screen.
40695 LD (HL),A Write the result to the screen.
40696 INC L Move to the next byte on the screen.
This entry point is used by the routine at DrawActorSpriteRow_Aligned.
XOR the other two bytes onto the screen. DrawActorSpriteRow also finishes here.
DrawSpriteRow_Write 40697 LD A,D Fetch the second byte.
40698 XOR (HL) Exclusive OR it onto the screen.
40699 LD (HL),A Write the result to the screen.
40700 INC L Move to the next byte on the screen.
40701 LD A,E Fetch the third byte.
40702 XOR (HL) Exclusive OR it onto the screen.
40703 LD (HL),A Write the result to the screen.
40704 POP DE Fetch the address of the next row of sprite data.
40705 DEC L Move back to the first byte on the screen.
40706 DEC L
Prev: 40603 Up: Map Next: 40707