Prev: D69E Up: Map Next: D6EF
D6C9: 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 - 80 and the pixel y position (from the bottom of the screen) is half of y - x + 80, plus z, less 68, 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 D6C9 LD A,(IX+$01) Fetch the x position of the object.
D6CC ADD A,(IX+$02) Add the y position.
D6CF SUB $80 Subtract 80.
D6D1 ADD A,(IX+$12) Add the pixel x adjustment.
D6D4 LD (IX+$1A),A Set the pixel x position.
Work out the pixel y position.
D6D7 LD A,(IX+$02) Fetch the y position of the object.
D6DA SUB (IX+$01) Subtract the x position.
D6DD ADD A,$80 Add 80.
D6DF SRL A Halve it.
D6E1 ADD A,(IX+$03) Add the z position.
D6E4 SUB $68 Subtract 68.
D6E6 ADD A,(IX+$13) Add the pixel y adjustment.
D6E9 LD (IX+$1B),A Set the pixel y position.
D6EC CP $C0 Compare it with the number of lines of the screen.
D6EE RET Return.
View the equivalent code in;
Prev: D69E Up: Map Next: D6EF