Prev: 9E9B Up: Map Next: 9F03
9ECE: 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 9ECE EX DE,HL DE=the row of sprite data, and HL=the address of the next row.
9ECF EX (SP),HL Fetch the screen address, and the address of the next row of sprite data is stored on the stack.
9ED0 LD A,D Fetch the first byte of the row.
9ED1 XOR (HL) Exclusive OR it onto the screen.
9ED2 LD (HL),A Write the result to the screen.
9ED3 INC L Move to the next byte on the screen.
9ED4 LD A,E Fetch the second byte of the row.
9ED5 XOR (HL) Exclusive OR it onto the screen.
9ED6 LD (HL),A Write the result to the screen.
9ED7 POP DE Fetch the address of the next row of sprite data.
9ED8 DEC L Move back to the first byte on the screen.
9ED9 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 9EDC EX DE,HL HL=the address of the sprite data, and DE=the screen address.
9EDD PUSH DE Stash the screen address on the stack.
9EDE LD D,(HL) Fetch the first byte of the row.
9EDF INC HL Move to the next byte of sprite data.
9EE0 LD E,(HL) Fetch the second byte of the row.
9EE1 INC HL Move on to the next row of sprite data.
9EE2 EX DE,HL HL=the row of sprite data, and DE=the address of the next row.
9EE3 XOR A A=00.
Self modifying code; the operand of this command is written by 9F91. 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 9EE4 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.
9EE6 ADD HL,HL Shift HL left by one, moving the bit shifted out into A (seven times).
9EE7 ADC A,A
9EE8 ADD HL,HL
9EE9 ADC A,A
9EEA ADD HL,HL
9EEB ADC A,A
9EEC ADD HL,HL
9EED ADC A,A
9EEE ADD HL,HL
9EEF ADC A,A
9EF0 ADD HL,HL
9EF1 ADC A,A
9EF2 ADD HL,HL
9EF3 ADC A,A
9EF4 EX DE,HL DE=the shifted row, and HL=the address of the next row of sprite data.
9EF5 EX (SP),HL Fetch the screen address, and the address of the next row of sprite data is stored on the stack.
9EF6 XOR (HL) Exclusive OR the first byte (in A) onto the screen.
9EF7 LD (HL),A Write the result to the screen.
9EF8 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 9EF9 LD A,D Fetch the second byte.
9EFA XOR (HL) Exclusive OR it onto the screen.
9EFB LD (HL),A Write the result to the screen.
9EFC INC L Move to the next byte on the screen.
9EFD LD A,E Fetch the third byte.
9EFE XOR (HL) Exclusive OR it onto the screen.
9EFF LD (HL),A Write the result to the screen.
9F00 POP DE Fetch the address of the next row of sprite data.
9F01 DEC L Move back to the first byte on the screen.
9F02 DEC L
Prev: 9E9B Up: Map Next: 9F03