Prev: 53159 Up: Map Next: 53246
53202: Calculate Pixel Coordinates
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 40, each with the adjustments of the object added. While GameOverFlag is set the pixel positions are left as the scene has set them.
Input
IX The address of the object
Output
F The carry flag is set if the sprite is on the screen
Return if the scene has set the positions.
CalculatePixelCoordinates 53202 LD A,(23332) Fetch GameOverFlag.
53205 AND A Return with the carry flag set if it is not zero.
53206 SCF
53207 RET NZ
Work out the pixel x position.
53208 LD A,(IX+1) Fetch the x position of the object.
53211 ADD A,(IX+2) Add the y position.
53214 SUB 128 Subtract 128.
53216 ADD A,(IX+18) Add the pixel x adjustment.
53219 LD (IX+26),A Set the pixel x position.
Work out the pixel y position.
53222 LD A,(IX+2) Fetch the y position of the object.
53225 SUB (IX+1) Subtract the x position.
53228 ADD A,128 Add 128.
53230 SRL A Halve it.
53232 ADD A,(IX+3) Add the z position.
53235 SUB 40 Subtract 40.
53237 ADD A,(IX+19) Add the pixel y adjustment.
53240 LD (IX+27),A Set the pixel y position.
53243 CP 192 Compare it with 192.
53245 RET Return.
View the equivalent code in;
Prev: 53159 Up: Map Next: 53246