Prev: 30266 Up: Map Next: 30379
30317: Draw Old Sprite Row
Draws one row of the sprite prepared by PrepareOldSprite by exclusive ORing it onto the screen, then moves on to the row above.
Input
DE Address of the sprite data
HL Screen address
Output
DE Address of the next row of sprite data
HL Screen address of the row above
The entry point for a sprite which is aligned to a character cell.
DrawOldSpriteRow_Aligned 30317 EX DE,HL DE=the row of sprite data, and HL=the address of the next row.
30318 EX (SP),HL HL=the screen address, and the address of the next row of sprite data is stored on the stack.
30319 JR DrawSpriteRow_Write Jump to DrawSpriteRow_Write.
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 30321 PUSH HL Stash the screen address on the stack.
30322 EX DE,HL HL=the address of the sprite data, and DE=the screen address.
30323 PUSH DE Stash the screen address on the stack again.
30324 LD D,(HL) D=the first byte of the row.
30325 INC HL Move to the next byte of sprite data.
30326 LD E,(HL) E=the second byte of the row.
30327 INC HL Move on to the next row of sprite data.
30328 EX DE,HL HL=the row of sprite data, and DE=the address of the next row.
30329 XOR A A=0.
Self modifying code; the operand of this command is written by 30056. It jumps into the sequence of shifts below, so that the row is moved right by the right number of pixels.
DrawOldSpriteRow_Shift 30330 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.
30332 ADD HL,HL Shift HL left by one, moving the bit shifted out into A.
30333 ADC A,A
Shift the row left by up to seven bits; the bits which are shifted out of the row end up in A.
30334 ADD HL,HL Shift HL left by one, moving the bit shifted out into A.
30335 ADC A,A
Shift the row left by up to seven bits; the bits which are shifted out of the row end up in A.
30336 ADD HL,HL Shift HL left by one, moving the bit shifted out into A.
30337 ADC A,A
Shift the row left by up to seven bits; the bits which are shifted out of the row end up in A.
30338 ADD HL,HL Shift HL left by one, moving the bit shifted out into A.
30339 ADC A,A
Shift the row left by up to seven bits; the bits which are shifted out of the row end up in A.
30340 ADD HL,HL Shift HL left by one, moving the bit shifted out into A.
30341 ADC A,A
Shift the row left by up to seven bits; the bits which are shifted out of the row end up in A.
30342 ADD HL,HL Shift HL left by one, moving the bit shifted out into A.
30343 ADC A,A
Shift the row left by up to seven bits; the bits which are shifted out of the row end up in A.
30344 ADD HL,HL Shift HL left by one, moving the bit shifted out into A.
30345 ADC A,A
30346 EX DE,HL DE=the shifted row, and HL=the address of the next row of sprite data.
30347 EX (SP),HL HL=the screen address, and the address of the next row of sprite data is stored on the stack.
30348 XOR (HL) Exclusive OR the first byte (in A) onto the screen.
30349 LD (HL),A Write the result to the screen.
30350 INC L Move to the next byte on the screen.
This entry point is used by the routine at DrawActorSpriteRow_Aligned.
DrawSpriteRow_Write 30351 LD A,D Fetch the second byte.
30352 XOR (HL) Exclusive OR it onto the screen.
30353 LD (HL),A Write the result to the screen.
30354 INC L Move to the next byte on the screen.
30355 LD A,E Fetch the third byte.
30356 XOR (HL) Exclusive OR it onto the screen.
30357 LD (HL),A Write the result to the screen.
30358 POP DE DE=the address of the next row of sprite data.
30359 POP HL HL=the screen address of the row which was just drawn.
Move up one pixel row on the screen.
30360 DEC H Move up one pixel row on the screen (decrease H by one).
30361 LD A,H Fetch the high byte of the screen address.
30362 CPL Flip the bits.
30363 AND %00000111 Keep only bits 0-2.
30365 RET NZ Return if still inside the same character row.
30366 LD A,L Fetch the low byte of the screen address.
30367 SUB 32 Subtract 32 to move up a character row.
30369 LD L,A Update the low byte of the screen address.
30370 CPL Flip the bits.
30371 AND %11100000 Keep only bits 5-7.
30373 RET Z Return if still inside the same third of the screen.
30374 LD A,H Fetch the high byte of the screen address.
30375 ADD A,8 Add 8.
30377 LD H,A Update the high byte of the screen address.
30378 RET Return.
Prev: 30266 Up: Map Next: 30379