0 Members and 1 Guest are viewing this topic.
3DTo2D: ld a, 0 ld (valid), a ld bc, (xpoint) ld de, (xfrom) call SubFP ld (xpoint), de ld bc, (ypoint) ld de, (yfrom) call SubFP ld (ypoint), de ld bc, (zpoint) ld de, (zfrom) call SubFP ld (zpoint), de ld hl, (xpoint) ld bc, (xto) call MulFP push de ;1 ld hl, (ypoint) ld bc, (yto) call MulFP pop hl ;0 add hl, de push hl ;1 ld hl, (zpoint) ld bc, (zto) call MulFP pop hl ;0 add hl, de push hl ;1 ld a, l ld c, a ld a, (min_range) ld b, a ld a, c cp b jp c, Invalid ld c, a ld a, (max_range) ld b, a ld a, c cp b jp nc, Invalid ld a, 1 ld (valid), a ld hl, (xpoint) ld bc, (xcross) call MulFP push de ;2 ld hl, (ypoint) ld bc, (ycross) call MulFP pop hl ;1 add hl, de push hl ;2 ld hl, (zpoint) ld bc, (zcross) call MulFP pop hl ;1 add hl, de pop de ;0 push de ;1 call DivFP ld (screenx), hl ld hl, (xpoint) ld bc, (xup) call MulFP push de ;2 LD HL, (ypoint) ld bc, (yup) call MulFP pop hl ;1 add hl, de push hl ;2 ld hl, (zpoint) ld bc, (zup) call MulFP pop hl ;1 add hl, bc pop de ;0 call DivFP ld (screeny), hl ld hl, $0100 ld de, (screenx) add hl, de ld bc, $5F00 call MulFP ld (screenx), de ld hl, $0100 ld de, (screeny) add hl, de ld bc, $4100 call MulFP ld (screeny), deInvalid: ret
// d3dto2d_init(xfrom,yfrom,zfrom,xto,yto,zto,xup,yup,zup,angle,aspect,znear,zfar)var d;global.d3dto2d_xfrom = argument0;global.d3dto2d_yfrom = argument1;global.d3dto2d_zfrom = argument2;global.d3dto2d_xto = argument3-global.d3dto2d_xfrom;global.d3dto2d_yto = argument4-global.d3dto2d_yfrom;global.d3dto2d_zto = argument5-global.d3dto2d_zfrom;d = sqrt(global.d3dto2d_xto*global.d3dto2d_xto+global.d3dto2d_yto*global.d3dto2d_yto+global.d3dto2d_zto*global.d3dto2d_zto);global.d3dto2d_xto /= d;global.d3dto2d_yto /= d;global.d3dto2d_zto /= d;global.d3dto2d_xup = argument6;global.d3dto2d_yup = argument7;global.d3dto2d_zup = argument8;d = global.d3dto2d_xup*global.d3dto2d_xto+global.d3dto2d_yup*global.d3dto2d_yto+global.d3dto2d_zup*global.d3dto2d_zto;global.d3dto2d_xup -= d*global.d3dto2d_xto;global.d3dto2d_yup -= d*global.d3dto2d_yto;global.d3dto2d_zup -= d*global.d3dto2d_zto;d = tan(degtorad(argument9)/2)*sqrt(global.d3dto2d_xup*global.d3dto2d_xup+global.d3dto2d_yup*global.d3dto2d_yup+global.d3dto2d_zup*global.d3dto2d_zup);global.d3dto2d_xup /= d;global.d3dto2d_yup /= d;global.d3dto2d_zup /= d;global.d3dto2d_xcross = (global.d3dto2d_yup*global.d3dto2d_zto-global.d3dto2d_zup*global.d3dto2d_yto)/argument10;global.d3dto2d_ycross = (global.d3dto2d_zup*global.d3dto2d_xto-global.d3dto2d_xup*global.d3dto2d_zto)/argument10;global.d3dto2d_zcross = (global.d3dto2d_xup*global.d3dto2d_yto-global.d3dto2d_yup*global.d3dto2d_xto)/argument10;global.d3dto2d_znear = argument11;global.d3dto2d_zfar = argument12;
// d3dto2d_point(x,y,z)var xx,yy,zz,d;xx = argument0-global.d3dto2d_xfrom;yy = argument1-global.d3dto2d_yfrom;zz = argument2-global.d3dto2d_zfrom;d= xx*global.d3dto2d_xto+yy*global.d3dto2d_yto+zz*global.d3dto2d_zto;if (d<global.d3dto2d_znear or d>global.d3dto2d_zfar){ Return = 0}else{Return = 1}global.xx = (xx*global.d3dto2d_xcross+yy*global.d3dto2d_ycross+zz*global.d3dto2d_zcross)/d;global.yy = (xx*global.d3dto2d_xup+yy*global.d3dto2d_yup+zz*global.d3dto2d_zup)/d;return Return;
3DTo2D: ld a, 0 ld (valid), a ld bc, (xpoint) ld de, (xfrom) call SubFP ld (xpoint), de ld bc, (ypoint) ld de, (yfrom) call SubFP ld (ypoint), de ld bc, (zpoint) ld de, (zfrom) call SubFP ld (zpoint), de ld hl, (xpoint) ld bc, (xto) call MulFP push de ;1 ld hl, (ypoint) ld bc, (yto) call MulFP pop hl ;0 add hl, de push hl ;1 ld hl, (zpoint) ld bc, (zto) call MulFP pop hl ;0 add hl, de push hl ;1 ld a, l ld c, a ld a, (min_range) ld b, a ld a, c cp b ret c ld c, a ld a, (max_range) ld b, a ld a, c cp b ret nc ld a, 1 ld (valid), a ld hl, (xpoint) ld bc, (xcross) call MulFP push de ;2 ld hl, (ypoint) ld bc, (ycross) call MulFP pop hl ;1 add hl, de push hl ;2 ld hl, (zpoint) ld bc, (zcross) call MulFP pop hl ;1 add hl, de pop de ;0 push de ;1 call DivFP ld (screenx), hl ld hl, (xpoint) ld bc, (xup) call MulFP push de ;2 LD HL, (ypoint) ld bc, (yup) call MulFP pop hl ;1 add hl, de push hl ;2 ld hl, (zpoint) ld bc, (zup) call MulFP pop hl ;1 add hl, bc pop de ;0 call DivFP ld (screeny), hl ld hl, $0100 ld de, (screenx) add hl, de ld bc, $5F00 call MulFP ld (screenx), de ld hl, $0100 ld de, (screeny) add hl, de ld bc, $4100 call MulFP ld (screeny), de ret