Prev: CFA7 Up: Map Next: CFFE
CFD2: 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 - 80 and the pixel y position (from the bottom of the screen) is half of y - x + 80, plus z, less 28, 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 CFD2 LD A,($5B24) Fetch GameOverFlag.
CFD5 AND A Return with the carry flag set if it is not zero.
CFD6 SCF
CFD7 RET NZ
Work out the pixel x position.
CFD8 LD A,(IX+$01) Fetch the x position of the object.
CFDB ADD A,(IX+$02) Add the y position.
CFDE SUB $80 Subtract 80.
CFE0 ADD A,(IX+$12) Add the pixel x adjustment.
CFE3 LD (IX+$1A),A Set the pixel x position.
Work out the pixel y position.
CFE6 LD A,(IX+$02) Fetch the y position of the object.
CFE9 SUB (IX+$01) Subtract the x position.
CFEC ADD A,$80 Add 80.
CFEE SRL A Halve it.
CFF0 ADD A,(IX+$03) Add the z position.
CFF3 SUB $28 Subtract 28.
CFF5 ADD A,(IX+$13) Add the pixel y adjustment.
CFF8 LD (IX+$1B),A Set the pixel y position.
CFFB CP $C0 Compare it with C0.
CFFD RET Return.
View the equivalent code in;
Prev: CFA7 Up: Map Next: CFFE