Prev: 47373 Up: Map Next: 47442
47416: Calculate Sprite Size
Used by the routine at FlagOverlappingObjects.
Works out the size on the screen of the sprite of an object, without drawing it, and stores it in the object. The width is one more than the width of the sprite data if the sprite has to be shifted.
Input
IX Object record
Find the sprite and whether it is shifted.
CalculateSpriteSize 47416 CALL CalculatePixelCoordinates Call CalculatePixelCoordinates to work out the screen position of the object.
47419 CALL GetSpriteAddress Call GetSpriteAddress to get the address of its sprite.
47422 LD A,(IX+26) Fetch the screen x co-ordinate.
47425 AND %00000111 Keep the number of bits that the sprite is shifted by.
47427 LD A,(DE) Fetch the width of the sprite, and move on to its height.
47428 INC DE
47429 JR Z,CalculateSpriteSize_Store Jump to CalculateSpriteSize_Store if the sprite is not shifted.
47431 INC A Add one to the width for the shift.
Store the width and height.
CalculateSpriteSize_Store 47432 AND %00001111 Keep only the width.
47434 LD (IX+24),A Write the width to the object.
47437 LD A,(DE) Fetch the height of the sprite.
47438 LD (IX+25),A Write the height to the object.
47441 RET Return.
View the equivalent code in;
Prev: 47373 Up: Map Next: 47442