Prev: 48482 Up: Map Next: 48558
48489: Draw Sprite List
Used by the routine at HandleCrosshair.
Draws each sprite in the sprite list of an object. A sprite list is made of three bytes for each sprite: the horizontal offset, the vertical offset and the number of the sprite. The offsets are added to the position of the object, and the vertical offset of the object in byte 13. A sprite which would start outside the screen is not drawn. The last byte of the list is 128.
Input
IX The address of the object
DrawSpriteList 48489 LD E,(IX+14) Fetch the address of the sprite list into DE.
48492 LD D,(IX+15)
DrawSpriteList_Next 48495 LD A,(DE) Fetch the horizontal offset of the sprite.
48496 INC DE Move on to the next byte.
48497 CP 128 Return if it is the terminator.
48499 RET Z
48500 LD HL,(41550) Fetch the horizontal position of the object.
48503 CALL AddSignedToHL Add the offset to it.
48506 LD A,H Fetch the high byte.
48507 AND A Skip the sprite if its horizontal position is off the screen.
48508 JR NZ,DrawSpriteList_Skip
48510 LD A,L Fetch the low byte.
48511 CP 203 Jump to DrawSpriteList_Skip to skip the sprite if it is past it.
48513 JR NC,DrawSpriteList_Skip
48515 CP 16 Jump to DrawSpriteList_Skip to skip the sprite if it is past it.
48517 JR C,DrawSpriteList_Skip
48519 LD (41504),A Set the horizontal pixel position.
48522 LD HL,(41552) Fetch the vertical position of the object.
48525 LD A,(DE) Fetch the vertical offset of the sprite.
48526 INC DE Move on to the next byte.
48527 ADD A,(IX+13) Add the vertical offset of the object.
48530 CALL AddSignedToHL Add the offset to the vertical position.
48533 LD A,H Fetch the high byte.
48534 AND A Skip the sprite if its vertical position is off the screen.
48535 JR NZ,DrawSpriteList_SkipSprite
48537 LD A,L Fetch the low byte.
48538 CP 184 Jump to DrawSpriteList_SkipSprite to skip the sprite if it is past it.
48540 JR NC,DrawSpriteList_SkipSprite
48542 LD (41505),A Set the vertical pixel position.
48545 LD A,(DE) Fetch the number of the sprite.
48546 INC DE Move on to the next byte.
Draw the sprite.
48547 PUSH DE Stash the address in the list on the stack.
48548 CALL DrawSprite Call DrawSprite.
48551 POP DE Restore the address in the list from the stack.
Go back for the next sprite.
48552 JR DrawSpriteList_Next Jump to DrawSpriteList_Next.
The sprite is off the screen horizontally, so skip the vertical offset as well.
DrawSpriteList_Skip 48554 INC DE Skip the vertical offset.
Skip the number of the sprite and go on to the next.
DrawSpriteList_SkipSprite 48555 INC DE Skip the number of the sprite.
Go back for the next sprite.
48556 JR DrawSpriteList_Next Jump to DrawSpriteList_Next.
Prev: 48482 Up: Map Next: 48558