Prev: 50707 Up: Map Next: 50775
50749: Calculate Sprite Size
Used by the routine at FlagOverlappingObjects.
Works out where an object is on the screen and how much of the screen its sprite covers. The width in bytes is one more than the width of the sprite if the sprite does not start on a byte boundary, because it has to be shifted across.
Input
IX The address of the object
Widen the sprite if it is shifted.
CalculateSpriteSize 50749 CALL CalculatePixelCoordinates Call CalculatePixelCoordinates.
50752 CALL GetSpriteAddress Call GetSpriteAddress.
50755 LD A,(IX+26) Fetch the pixel x position.
50758 AND %00000111 Keep only bits 0-2.
50760 LD A,(DE) Fetch the width of the sprite in bytes.
50761 INC DE Move on to the height.
50762 JR Z,CalculateSpriteSize_Store Jump to CalculateSpriteSize_Store if they were zero.
50764 INC A Increment A.
CalculateSpriteSize_Store 50765 AND %00001111 Keep only bits 0-3.
50767 LD (IX+24),A Store the width in bytes.
50770 LD A,(DE) Fetch the height of the sprite in lines.
50771 LD (IX+25),A Store the height in lines.
50774 RET Return.
View the equivalent code in;
Prev: 50707 Up: Map Next: 50775