Prev: 52488 Up: Map Next: 52557
52531: 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 Address of the object
Work out the pixel position, then the width and height of the sprite.
CalculateSpriteSize 52531 CALL CalculatePixelCoordinates Work out the pixel coordinates of the object.
52534 CALL GetSpriteAddress Find the sprite of the object, and flip it if it needs it.
52537 LD A,(IX+26) Fetch the pixel X coordinate.
52540 AND %00000111 Keep the offset of the bit within the byte.
52542 LD A,(DE) Fetch the width of the sprite in bytes.
52543 INC DE Point DE at the height of the sprite.
52544 JR Z,CalculateSpriteSize_Store Jump to CalculateSpriteSize_Store if the sprite starts on a byte boundary.
52546 INC A Add one byte to the width.
CalculateSpriteSize_Store 52547 AND %00001111 Keep the low nibble of the width.
52549 LD (IX+24),A Store the width in bytes.
52552 LD A,(DE) Fetch the height of the sprite in lines.
52553 LD (IX+25),A Store the height in lines.
52556 RET Return.
View the equivalent code in;
Prev: 52488 Up: Map Next: 52557