Prev: B29A Up: Map Next: B2EE
B2C5: Project an object's position onto the screen
Used by the routines at DRAW_OBJECT, CALC_2D_INFO, TAKE_OR_LEAVE, SKY_DROP and WELL.
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 - 104, each with the drawing nudge (+12, +13) added.
Knight Lore's, with one addition: a picture whose x would come out below 0 is drawn from x 0. That rests on every nudge being negative -- adding one to an x that stays on the screen carries -- and so an object with a nudge of 0 would always be drawn at x 0. The update routines set the nudges, through the short routines from DRAW_AT_L8 on; in room 100, measured, all 38 records in use had negative nudges.
Input
IX the object
Output
F carry set if the pixel y is below 192, that is on the screen
CALC_PIXEL_XY B2C5 LD A,(IX+$01) U + V - 128
B2C8 ADD A,(IX+$02)
B2CB SUB $80
B2CD ADD A,(IX+$12) Plus the nudge: no carry means it went below 0, so 0
B2D0 JR C,CALC_PIXEL_XY_0
B2D2 XOR A
CALC_PIXEL_XY_0 B2D3 LD (IX+$1A),A Pixel x
B2D6 LD A,(IX+$02) (V - U + 128) / 2 + Z - 104
B2D9 SUB (IX+$01)
B2DC ADD A,$80
B2DE SRL A
B2E0 ADD A,(IX+$03)
B2E3 SUB $68
B2E5 ADD A,(IX+$13) Plus the nudge: pixel y
B2E8 LD (IX+$1B),A
B2EB CP $C0 Carry set if it is on the screen
B2ED RET
Prev: B29A Up: Map Next: B2EE