Prev: CFA7 Up: Map Next: CFFE
CFD2: Project an object's position onto the screen
The isometric projection. U, V and Z (+1 to +3) become a pixel x in +1A and a pixel y in +1B, counted up from the bottom of the screen: pixel x = U + V - 128, and pixel y = (V - U + 128) / 2 + Z - 40, each with the drawing nudge (+12, +13) added. Knight Lore takes 104 where this takes 40, since its floors are lower; and Pentagram's version stops a pixel x below 0 at 0, which this does not.
While GAME_OVER is set nothing is projected, and carry comes back set: the scene after a game (SCENE_TOOL) places its sprites by pixel, writing +1A and +1B itself.
Input
IX the object
Output
F carry set if the pixel y is below 192, that is on the screen
CALC_PIXEL_XY CFD2 LD A,(GAME_OVER) After a game: no projection, and drawn wherever +1A and +1B say
CFD5 AND A
CFD6 SCF
CFD7 RET NZ
CFD8 LD A,(IX+$01) Pixel x: U + V - 128, plus the nudge
CFDB ADD A,(IX+$02)
CFDE SUB $80
CFE0 ADD A,(IX+$12)
CFE3 LD (IX+$1A),A
CFE6 LD A,(IX+$02) Pixel y: (V - U + 128) / 2 + Z - 40, plus the nudge
CFE9 SUB (IX+$01)
CFEC ADD A,$80
CFEE SRL A
CFF0 ADD A,(IX+$03)
CFF3 SUB $28
CFF5 ADD A,(IX+$13)
CFF8 LD (IX+$1B),A
CFFB CP $C0 Carry set if it is on the screen
CFFD RET
Prev: CFA7 Up: Map Next: CFFE