Prev: 54942 Up: Map Next: 55023
54985: Calculate Pixel Coordinates
Used by the routines at HandlePickupAndDrop, CalculateSpriteSize and DrawObject.
Works out the pixel position of an object on the screen from its x, y and z positions. The pixel x position is x + y - 128 and the pixel y position (from the bottom of the screen) is half of y - x + 128, plus z, less 104, each with the adjustments of the object added.
Input
IX The address of the object
Output
F The carry flag is set if the sprite is on the screen
Work out the pixel x position.
CalculatePixelCoordinates 54985 LD A,(IX+1) Fetch the x position of the object.
54988 ADD A,(IX+2) Add the y position.
54991 SUB 128 Subtract 128.
54993 ADD A,(IX+18) Add the pixel x adjustment.
54996 LD (IX+26),A Set the pixel x position.
Work out the pixel y position.
54999 LD A,(IX+2) Fetch the y position of the object.
55002 SUB (IX+1) Subtract the x position.
55005 ADD A,128 Add 128.
55007 SRL A Halve it.
55009 ADD A,(IX+3) Add the z position.
55012 SUB 104 Subtract 104.
55014 ADD A,(IX+19) Add the pixel y adjustment.
55017 LD (IX+27),A Set the pixel y position.
55020 CP 192 Compare it with the number of lines of the screen.
55022 RET Return.
View the equivalent code in;
Prev: 54942 Up: Map Next: 55023