Prev: D6BE Up: Map Next: D6EF
D6C9: Project an object's position onto the screen
Used by the routines at place_under_player, calc_2d_info and project_and_draw.
The isometric projection. The object's x, y and z (bytes 1 to 3) become a pixel x in byte $1A and a pixel y in byte $1B, counted up from the bottom of the screen:
pixel x = x + y - 128, and pixel y = (y - x + 128) / 2 + z - 104.
So a step in x moves one pixel right and half a pixel down, a step in y one pixel right and half a pixel up, and a step in z one pixel straight up -- the two-to-one slopes of the view. Bytes $12 and $13 are added on top: set by set_pixel_adj, they shift an object's picture without moving the object, for sprites whose artwork does not sit where the object stands.
Input
IX the object
F on exit, carry set if the pixel y is below 192, that is on the
screen
calc_pixel_XY D6C9 LD A,(IX+$01) pixel x
D6CC ADD A,(IX+$02)
D6CF SUB $80
D6D1 ADD A,(IX+$12)
D6D4 LD (IX+$1A),A
D6D7 LD A,(IX+$02) pixel y
D6DA SUB (IX+$01)
D6DD ADD A,$80
D6DF SRL A
D6E1 ADD A,(IX+$03)
D6E4 SUB $68
D6E6 ADD A,(IX+$13)
D6E9 LD (IX+$1B),A carry set if it is on the screen
D6EC CP $C0
D6EE RET
Prev: D6BE Up: Map Next: D6EF