TempleOSCDV4.08.ISO
This commit is contained in:
1 parent
b632ab9a4f
commit
2d56cda5f3
258 files changed
+6973
-5476
No files matched your search
+1
-1
@@ -153,7 +153,7 @@ public class CSpritePtMeshU8s : CSpriteBase
|
||||
public class CSprite
|
||||
{
|
||||
CSprite *next,*last;
|
||||
Bool selected;
|
||||
Bool sel;
|
||||
U0 start;
|
||||
union {
|
||||
U8 type;
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ _GR_UPDATE_LINE64::
|
||||
|
||||
MOV RAX,U64 SF_ARG2[RBP]
|
||||
MOV RSI,U64 [RAX] //rsi=src
|
||||
MOV RBX,U64 [&reverse_bits_table]
|
||||
MOV RBX,U64 [&rev_bits_table]
|
||||
MOV RCX,U64 SF_ARG3[RBP] //rcx=d
|
||||
MOV RAX,U64 SF_ARG4[RBP]
|
||||
MOV RDI,U64 [RAX] //rdi=image
|
||||
@@ -62,7 +62,7 @@ _GR_UPDATE_LINE64_FLUSH_CACHE::
|
||||
|
||||
MOV RAX,U64 SF_ARG2[RBP]
|
||||
MOV RSI,U64 [RAX] //rsi=src
|
||||
MOV RBX,U64 [&reverse_bits_table]
|
||||
MOV RBX,U64 [&rev_bits_table]
|
||||
MOV RCX,U64 SF_ARG3[RBP] //rcx=d
|
||||
MOV RAX,U64 SF_ARG4[RBP]
|
||||
MOV RDI,U64 [RAX] //rdi=image
|
||||
|
||||
@@ -1808,3 +1808,174 @@ public I64 GrHLine(CDC *dc=gr.dc,I64 x1,I64 x2,I64 y,I64 z1=0,I64 z2=0)
|
||||
gr_done:
|
||||
return res;
|
||||
}
|
||||
|
||||
public I64 GrVLine(CDC *dc=gr.dc,I64 x,I64 y1,I64 y2,I64 z1=0,I64 z2=0)
|
||||
{//3D. No transformation or pen width.
|
||||
//Returns cnt of pixs changed
|
||||
//Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
I64 dist,dy,dz,z,res=0,i,j,d;
|
||||
U8 *dst;
|
||||
CColorROPU32 c,c2,color=dc->color,bkcolor=dc->bkcolor,dither_colors;
|
||||
I32 *db;
|
||||
Bool plot=TRUE,char_clear,dither,probability_dither;
|
||||
CTask *win_task;
|
||||
|
||||
if (!dc->depth_buf) {
|
||||
if (y2<y1) SwapI64(&y1,&y2);
|
||||
return GrRect(dc,x,y1,1,y2-y1+1);
|
||||
}
|
||||
|
||||
if (dc->flags & DCF_SCREEN_BITMAP) {
|
||||
win_task=dc->win_task;
|
||||
x +=win_task->scroll_x;
|
||||
y1+=win_task->scroll_y;
|
||||
y2+=win_task->scroll_y;
|
||||
z1+=win_task->scroll_z;
|
||||
z2+=win_task->scroll_z;
|
||||
}
|
||||
if (dc->flags & DCF_RECORD_EXTENTS) {
|
||||
if (x<dc->min_x) dc->min_x=x;
|
||||
if (x>dc->max_x) dc->max_x=x;
|
||||
if (y1<dc->min_y) dc->min_y=y1;
|
||||
if (y1>dc->max_y) dc->max_y=y1;
|
||||
if (y2<dc->min_y) dc->min_y=y2;
|
||||
if (y2>dc->max_y) dc->max_y=y2;
|
||||
}
|
||||
if (x<0) goto gr_done;
|
||||
if (y2<y1) {
|
||||
SwapI64(&y1,&y2);
|
||||
SwapI64(&z1,&z2);
|
||||
}
|
||||
if (y2<0)
|
||||
goto gr_done;
|
||||
if (y1<0) {
|
||||
i=-y1;
|
||||
y1=0;
|
||||
} else
|
||||
i=0;
|
||||
j=0;
|
||||
if (dc->flags & DCF_SCREEN_BITMAP) {
|
||||
y1+=win_task->pix_top;
|
||||
y2+=win_task->pix_top;
|
||||
if (y1>win_task->pix_bottom)
|
||||
goto gr_done;
|
||||
if (y2>win_task->pix_bottom) {
|
||||
j=y2-win_task->pix_bottom;
|
||||
y2=win_task->pix_bottom;
|
||||
}
|
||||
x+=win_task->pix_left;
|
||||
if (!(0<=x<=win_task->pix_right) || y2<0)
|
||||
goto gr_done;
|
||||
}
|
||||
if (y1>=dc->height || x>=dc->width)
|
||||
goto gr_done;
|
||||
dy=y2+j-(y1-i);
|
||||
d=dc->width_internal*y1+x;
|
||||
if (db=dc->depth_buf) {
|
||||
db+=d;
|
||||
if (dy)
|
||||
dz=(z2-z1)<<32/dy;
|
||||
else
|
||||
dz=0;
|
||||
z=z1<<32;
|
||||
}
|
||||
if (i)
|
||||
z+=i*dz;
|
||||
if (y2>=dc->height)
|
||||
y2=dc->height-1;
|
||||
|
||||
if (dc->flags & DCF_LOCATE_NEAREST) {
|
||||
if (y1<=dc->cur_y<=y2)
|
||||
dist=0;
|
||||
else if (dc->cur_y<y1)
|
||||
dist=SqrI64(y1-dc->cur_y);
|
||||
else
|
||||
dist=SqrI64(dc->cur_y-y2);
|
||||
dist+=SqrI64(x-dc->cur_x);
|
||||
if (dist<=dc->nearest_dist) {
|
||||
dc->nearest_dist=dist;
|
||||
dc->nearest_sprite_elem_num=dc->cur_sprite_elem_num;
|
||||
}
|
||||
}
|
||||
if (dc->flags & DCF_DONT_DRAW)
|
||||
goto gr_done;
|
||||
|
||||
if (!(dc->flags & DCF_SCREEN_BITMAP) ||
|
||||
win_task->next_task==sys_winmgr_task ||
|
||||
dc->flags&DCF_ON_TOP || !IsPixCovered0(win_task,x,y1))
|
||||
char_clear=TRUE;
|
||||
else
|
||||
char_clear=FALSE;
|
||||
if (color.c1.rop&(ROPBF_DITHER|ROPBF_PROBABILITY_DITHER)) {
|
||||
dither=TRUE;
|
||||
if (color.c1.rop&ROPBF_PROBABILITY_DITHER) {
|
||||
probability_dither=TRUE;
|
||||
color.c1.rop=color.c0.rop;
|
||||
dither_colors=color;
|
||||
if (RandU16<dc->dither_probability_u16)
|
||||
color.c0=dither_colors.c1;
|
||||
else
|
||||
color.c0=dither_colors.c0;
|
||||
} else {
|
||||
probability_dither=FALSE;
|
||||
color.c1.rop=color.c0.rop;
|
||||
if ((x^y1)&1)
|
||||
SwapU16(&color.c0,&color.c1);
|
||||
}
|
||||
} else
|
||||
dither=FALSE;
|
||||
while (y1<=y2) {
|
||||
if (char_clear) {
|
||||
if (db) {
|
||||
if (0<=z.i32[1]<=*db) {
|
||||
*db=z.i32[1];
|
||||
plot=TRUE;
|
||||
} else
|
||||
plot=FALSE;
|
||||
}
|
||||
if (plot) {
|
||||
dst=dc->body+d;
|
||||
c=color.c0.color;
|
||||
switch [color.c0.rop] {
|
||||
case ROPB_EQU:
|
||||
case ROPB_MONO:
|
||||
*dst=c;
|
||||
break;
|
||||
case ROPB_COLLISION:
|
||||
c2=*dst;
|
||||
if (c2!=TRANSPARENT && c2!=bkcolor.c0.color)
|
||||
dc->collision_cnt++;
|
||||
break;
|
||||
case ROPB_XOR:
|
||||
*dst^=c;
|
||||
break;
|
||||
}
|
||||
res++;
|
||||
}
|
||||
}
|
||||
if (dither) {
|
||||
if (probability_dither) {
|
||||
if (RandU16<dc->dither_probability_u16)
|
||||
color.c0=dither_colors.c1;
|
||||
else
|
||||
color.c0=dither_colors.c0;
|
||||
} else
|
||||
SwapU16(&color.c0,&color.c1);
|
||||
}
|
||||
d+=dc->width_internal;
|
||||
y1++;
|
||||
if (db)
|
||||
db+=dc->width_internal;
|
||||
z+=dz;
|
||||
if (!(y1&(FONT_HEIGHT-1)) && y1<=y2) {
|
||||
if (!(dc->flags & DCF_SCREEN_BITMAP)||
|
||||
win_task->next_task==sys_winmgr_task ||
|
||||
dc->flags&DCF_ON_TOP || !IsPixCovered0(win_task,x,y1))
|
||||
char_clear=TRUE;
|
||||
else
|
||||
char_clear=FALSE;
|
||||
}
|
||||
}
|
||||
gr_done:
|
||||
return res;
|
||||
}
|
||||
@@ -30,6 +30,8 @@ public class CGrGlbls
|
||||
*collision_pen_brushes[GR_NUM_PEN_BRUSHES],
|
||||
*even_pen_brushes[GR_NUM_PEN_BRUSHES],
|
||||
*odd_pen_brushes[GR_NUM_PEN_BRUSHES];
|
||||
I8 circle_lo[GR_NUM_PEN_BRUSHES][GR_NUM_PEN_BRUSHES],
|
||||
circle_hi[GR_NUM_PEN_BRUSHES][GR_NUM_PEN_BRUSHES];
|
||||
|
||||
#define GR_MAX_SCREEN_ZOOM 8
|
||||
U8 *screen_zoom_tables[GR_MAX_SCREEN_ZOOM+1];
|
||||
|
||||
+12
-1
@@ -20,6 +20,17 @@ U0 GrSetUpTables()
|
||||
|
||||
for (i=0;i<GR_NUM_PEN_BRUSHES;i++) {
|
||||
k=i+1;
|
||||
|
||||
rr=k*k;
|
||||
for (y=1;y<k;y++)
|
||||
for (x=1;x<k;x++)
|
||||
if (SqrI64(y*2-k)+SqrI64(x*2-k)<rr) {
|
||||
if (x-1-i>>1<gr.circle_lo[i][i-y])
|
||||
gr.circle_lo[i][i-y]=x-1-i>>1;
|
||||
if (x-1-i>>1>gr.circle_hi[i][i-y])
|
||||
gr.circle_hi[i][i-y]=x-1-i>>1;
|
||||
}
|
||||
|
||||
dc=DCNew(i,i);
|
||||
gr.pen_brushes[i]=dc;
|
||||
dc->color=COLOR_MONO;
|
||||
@@ -57,7 +68,7 @@ U0 GrSetUpTables()
|
||||
GrPlot0(dc,x-1,y-1);
|
||||
}
|
||||
if (!Bt(&sys_run_level,RLf_VGA)) { //if text mode
|
||||
MemSet(VGAM_TEXT,0,TEXT_ROWS*TEXT_COLS*sizeof(U16));
|
||||
MemSet(text.vga_text_alias,0,TEXT_ROWS*TEXT_COLS*sizeof(U16));
|
||||
MemSet(gr.vga_text_cache,0,TEXT_ROWS*TEXT_COLS*sizeof(U16));
|
||||
} else {
|
||||
OutU8(VGAP_IDX,VGAR_MAP_MASK);
|
||||
|
||||
+15
-34
@@ -5,11 +5,8 @@ public I64 gr_x_offsets[8]={-1, 0, 1,-1,1,-1,0,1},
|
||||
gr_x_offsets2[4]={ 0,-1, 1, 0},
|
||||
gr_y_offsets2[4]={-1, 0, 0, 1};
|
||||
|
||||
public Bool Line(U8 *aux_data,
|
||||
I64 x1,I64 y1,I64 z1,
|
||||
I64 x2,I64 y2,I64 z2,
|
||||
Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),
|
||||
I64 step=1,I64 start=0)
|
||||
public Bool Line(U8 *aux_data,I64 x1,I64 y1,I64 z1,I64 x2,I64 y2,I64 z2,
|
||||
Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),I64 step=1,I64 start=0)
|
||||
{//Step through line segment calling callback.
|
||||
//Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
I64 i,j,d,dx=x2-x1,dy=y2-y1,dz=z2-z1,_x,_y,_z,
|
||||
@@ -115,8 +112,7 @@ public I64 *Mat4x4New(I64 *src,CTask *mem_task=NULL)
|
||||
|
||||
public I64 *Mat4x4RotX(I64 *m1,F64 è)
|
||||
{//Rot matrix about X axis. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
F64 my_cos=Cos(è)*GR_SCALE,
|
||||
my_sin=Sin(è)*GR_SCALE;
|
||||
F64 my_cos=Cos(è)*GR_SCALE,my_sin=Sin(è)*GR_SCALE;
|
||||
I64 r[16],r2[16];
|
||||
MemSet(r,0,sizeof(r));
|
||||
r[5]=my_cos;
|
||||
@@ -130,8 +126,7 @@ public I64 *Mat4x4RotX(I64 *m1,F64
|
||||
|
||||
public I64 *Mat4x4RotY(I64 *m1,F64 ê)
|
||||
{//Rot matrix about Y axis. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
F64 my_cos=Cos(ê)*GR_SCALE,
|
||||
my_sin=Sin(ê)*GR_SCALE;
|
||||
F64 my_cos=Cos(ê)*GR_SCALE,my_sin=Sin(ê)*GR_SCALE;
|
||||
I64 r[16],r2[16];
|
||||
MemSet(r,0,sizeof(r));
|
||||
r[0]=my_cos;
|
||||
@@ -145,8 +140,7 @@ public I64 *Mat4x4RotY(I64 *m1,F64
|
||||
|
||||
public I64 *Mat4x4RotZ(I64 *m1,F64 é)
|
||||
{//Rot matrix about Z axis. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
F64 my_cos=Cos(é)*GR_SCALE,
|
||||
my_sin=Sin(é)*GR_SCALE;
|
||||
F64 my_cos=Cos(é)*GR_SCALE,my_sin=Sin(é)*GR_SCALE;
|
||||
I64 r[16],r2[16];
|
||||
MemSet(r,0,sizeof(r));
|
||||
r[0]=my_cos;
|
||||
@@ -285,13 +279,9 @@ public U0 DCReflect(CDC *dc,I64 *_x,I64 *_y,I64 *_z)
|
||||
#help_index "Graphics/Math"
|
||||
#define SCALE1 24
|
||||
#define SCALE2 8
|
||||
public Bool Circle(U8 *aux_data,
|
||||
I64 cx,I64 cy,I64 cz,
|
||||
I64 radius,
|
||||
Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),
|
||||
I64 step=1,
|
||||
F64 start_radians=0,
|
||||
F64 len_radians=2*ã)
|
||||
public Bool Circle(U8 *aux_data,I64 cx,I64 cy,I64 cz,I64 radius,
|
||||
Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),
|
||||
I64 step=1,F64 start_radians=0,F64 len_radians=2*ã)
|
||||
{//Step through circle arc calling callback.
|
||||
I64 i,j,len=Ceil(len_radians*radius),
|
||||
x,y,x1,y1,s1,s2,c;
|
||||
@@ -328,14 +318,9 @@ public Bool Circle(U8 *aux_data,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public Bool Ellipse(U8 *aux_data,
|
||||
I64 cx,I64 cy,I64 cz,
|
||||
I64 x_radius,I64 y_radius,
|
||||
Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),
|
||||
F64 rot_angle=0,
|
||||
I64 step=1,
|
||||
F64 start_radians=0,
|
||||
F64 len_radians=2*ã)
|
||||
public Bool Ellipse(U8 *aux_data,I64 cx,I64 cy,I64 cz,
|
||||
I64 x_radius,I64 y_radius,Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),
|
||||
F64 rot_angle=0,I64 step=1,F64 start_radians=0,F64 len_radians=2*ã)
|
||||
{//Step through ellipse arc calling callback.
|
||||
I64 i,j,len,
|
||||
x,y,_x,_y,x1,y1,x2,y2, s1,s2,c, s12,s22,c2;
|
||||
@@ -400,14 +385,10 @@ public Bool Ellipse(U8 *aux_data,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public Bool RegPoly(U8 *aux_data,
|
||||
I64 cx,I64 cy,I64 cz,
|
||||
I64 x_radius,I64 y_radius,I64 sides,
|
||||
Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),
|
||||
F64 rot_angle=0,
|
||||
I64 step=1,
|
||||
F64 start_radians=0,
|
||||
F64 len_radians=2*ã)
|
||||
public Bool RegPoly(U8 *aux_data,I64 cx,I64 cy,I64 cz,
|
||||
I64 x_radius,I64 y_radius,I64 sides,
|
||||
Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),
|
||||
F64 rot_angle=0,I64 step=1,F64 start_radians=0,F64 len_radians=2*ã)
|
||||
{//Step through regular polygon calling callback.
|
||||
I64 i,n,x,y,x1,y1,x2,y2,
|
||||
xx1,yy1,xx2,yy2,
|
||||
|
||||
+276
-18
@@ -274,6 +274,141 @@ ff_done:
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 GrFillSemiCircle(CDC *dc=gr.dc,I64 cx,I64 cy,I64 z=0,I64 diameter,I64 n)
|
||||
{//2D. Clipping but not transformation.
|
||||
I64 res=0,i,k,r=diameter>>1,rr;
|
||||
if (diameter>=1)
|
||||
switch (n) {
|
||||
case 0:
|
||||
if (diameter<GR_NUM_PEN_BRUSHES)
|
||||
for (i=0;i<r;i++)
|
||||
res+=GrHLine(dc,gr.circle_lo[diameter][i]+cx,
|
||||
gr.circle_hi[diameter][i]+cx,cy+i-r,z,z);
|
||||
else {
|
||||
k=diameter+1;
|
||||
rr=SqrI64((k+1)>>1);
|
||||
for (i=0;i<r;i++)
|
||||
res+=GrHLine(dc,-Sqrt(rr-SqrI64(r-i))+cx,
|
||||
Sqrt(rr-SqrI64(r-i))+cx,cy+i-r,z,z);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (diameter<GR_NUM_PEN_BRUSHES)
|
||||
for (i=r+1;i<diameter;i++)
|
||||
res+=GrHLine(dc,gr.circle_lo[diameter][i]+cx,
|
||||
gr.circle_hi[diameter][i]+cx,cy+i-r,z,z);
|
||||
else {
|
||||
k=diameter+1;
|
||||
rr=SqrI64((k+1)>>1);
|
||||
for (i=r+1;i<k;i++)
|
||||
res+=GrHLine(dc,-Sqrt(rr-SqrI64(i-r))+cx,
|
||||
Sqrt(rr-SqrI64(i-r))+cx,cy+i-r,z,z);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (diameter<GR_NUM_PEN_BRUSHES)
|
||||
for (i=0;i<r;i++)
|
||||
res+=GrVLine(dc,cx+i-r,gr.circle_lo[diameter][i]+cy,
|
||||
gr.circle_hi[diameter][i]+cy,z,z);
|
||||
else {
|
||||
k=diameter+1;
|
||||
rr=SqrI64((k+1)>>1);
|
||||
for (i=0;i<r;i++)
|
||||
res+=GrVLine(dc,cx+i-r,-Sqrt(rr-SqrI64(r-i))+cy,
|
||||
Sqrt(rr-SqrI64(r-i))+cy,z,z);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (diameter<GR_NUM_PEN_BRUSHES)
|
||||
for (i=r+1;i<diameter;i++)
|
||||
res+=GrVLine(dc,cx+i-r,gr.circle_lo[diameter][i]+cy,
|
||||
gr.circle_hi[diameter][i]+cy,z,z);
|
||||
else {
|
||||
k=diameter+1;
|
||||
rr=SqrI64((k+1)>>1);
|
||||
for (i=r+1;i<k;i++)
|
||||
res+=GrVLine(dc,cx+i-r,-Sqrt(rr-SqrI64(i-r))+cy,
|
||||
Sqrt(rr-SqrI64(i-r))+cy,z,z);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (diameter<GR_NUM_PEN_BRUSHES)
|
||||
for (i=0;i<r;i++)
|
||||
res+=GrHLine(dc,gr.circle_lo[diameter][i]+cx,
|
||||
gr.circle_hi[diameter][i]+cx,cy+i-r,z,z);
|
||||
else {
|
||||
k=diameter+1;
|
||||
rr=SqrI64((k+1)>>1);
|
||||
for (i=0;i<r;i++)
|
||||
res+=GrHLine(dc,-Sqrt(rr-SqrI64(r-i))+cx,
|
||||
Sqrt(rr-SqrI64(r-i))+cx,cy+i-r,z,z);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if (diameter<GR_NUM_PEN_BRUSHES)
|
||||
for (i=r+1;i<diameter;i++)
|
||||
res+=GrHLine(dc,gr.circle_lo[diameter][i]+cx,
|
||||
gr.circle_hi[diameter][i]+cx,cy+i-r,z,z);
|
||||
else {
|
||||
k=diameter+1;
|
||||
rr=SqrI64((k+1)>>1);
|
||||
for (i=r+1;i<k;i++)
|
||||
res+=GrHLine(dc,-Sqrt(rr-SqrI64(i-r))+cx,
|
||||
Sqrt(rr-SqrI64(i-r))+cx,cy+i-r,z,z);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if (diameter<GR_NUM_PEN_BRUSHES)
|
||||
for (i=0;i<r;i++)
|
||||
res+=GrVLine(dc,cx+i-r,gr.circle_lo[diameter][i]+cy,
|
||||
gr.circle_hi[diameter][i]+cy,z,z);
|
||||
else {
|
||||
k=diameter+1;
|
||||
rr=SqrI64((k+1)>>1);
|
||||
for (i=0;i<r;i++)
|
||||
res+=GrVLine(dc,cx+i-r,-Sqrt(rr-SqrI64(r-i))+cy,
|
||||
Sqrt(rr-SqrI64(r-i))+cy,z,z);
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if (diameter<GR_NUM_PEN_BRUSHES)
|
||||
for (i=r+1;i<diameter;i++)
|
||||
res+=GrVLine(dc,cx+i-r,gr.circle_lo[diameter][i]+cy,
|
||||
gr.circle_hi[diameter][i]+cy,z,z);
|
||||
else {
|
||||
k=diameter+1;
|
||||
rr=SqrI64((k+1)>>1);
|
||||
for (i=r+1;i<k;i++)
|
||||
res+=GrVLine(dc,cx+i-r,-Sqrt(rr-SqrI64(i-r))+cy,
|
||||
Sqrt(rr-SqrI64(i-r))+cy,z,z);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public I64 GrFillCircle(CDC *dc=gr.dc,I64 cx,I64 cy,I64 z=0,I64 diameter)
|
||||
{//2D. Clipping but not transformation.
|
||||
I64 res=0,i,k,r=diameter>>1,rr;
|
||||
if (diameter>=1) {
|
||||
if (diameter<GR_NUM_PEN_BRUSHES)
|
||||
for (i=0;i<diameter;i++)
|
||||
res+=GrHLine(dc,gr.circle_lo[diameter][i]+cx,
|
||||
gr.circle_hi[diameter][i]+cx,cy+i-r,z,z);
|
||||
else {
|
||||
k=diameter+1;
|
||||
rr=SqrI64((k+1)>>1);
|
||||
for (i=0;i<=r;i++)
|
||||
res+=GrHLine(dc,-Sqrt(rr-SqrI64(r-i))+cx,
|
||||
Sqrt(rr-SqrI64(r-i))+cx,cy+i-r,z,z);
|
||||
for (;i<k;i++)
|
||||
res+=GrHLine(dc,-Sqrt(rr-SqrI64(i-r))+cx,
|
||||
Sqrt(rr-SqrI64(i-r))+cx,cy+i-r,z,z);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public Bool GrPlot3B(CDC *dc=gr.dc,I64 x,I64 y,I64 z)
|
||||
{//3D. Clipping and transformation but no pen_width.
|
||||
I64 _x,_y,_z;
|
||||
@@ -305,7 +440,7 @@ gr_done:
|
||||
|
||||
public Bool GrPlot3(CDC *dc=gr.dc,I64 x,I64 y,I64 z)
|
||||
{//3D. Clipping and transformation and pen width.
|
||||
I64 _x,_y,_z,i,j,w,dist;
|
||||
I64 _x,_y,_z,w,dist;
|
||||
CColorROPU32 old_color=dc->color;
|
||||
Bool record,was_transform=FALSE,was_symmetry=FALSE;
|
||||
CTask *win_task;
|
||||
@@ -401,15 +536,8 @@ public Bool GrPlot3(CDC *dc=gr.dc,I64 x,I64 y,I64 z)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (dc->pen_width & 1) {//TODO Dither
|
||||
for (i=-w;i<=w;i++)
|
||||
for (j=-w;j<=w;j++)
|
||||
GrPlot1(dc,x+i,y+j);
|
||||
} else {
|
||||
for (i=-w;i<w;i++)
|
||||
for (j=-w;j<w;j++)
|
||||
GrPlot1(dc,x+i,y+j);
|
||||
}
|
||||
} else
|
||||
GrFillCircle(dc,x,y,dc->db_z,dc->pen_width);
|
||||
gr_done:
|
||||
dc->color=old_color;
|
||||
if (was_transform)
|
||||
@@ -519,6 +647,128 @@ public Bool Gr3BSpline(CDC *dc=gr.dc,CD3I32 *ctrl,I64 cnt,Bool closed=FALSE)
|
||||
return BSpline3(dc,ctrl,cnt,&GrLinePlot,closed);
|
||||
}
|
||||
|
||||
I64 GrLineFat3(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,I64 x2,I64 y2,I64 z2,
|
||||
I64 width,I64 start=0)
|
||||
{//Step through line segment calling callback.
|
||||
//Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
I64 res=0,i,j,d,dx=x2-x1,dy=y2-y1,dz=z2-z1,_x,_y,_z,d_lo,d_hi,
|
||||
adx=AbsI64(dx),ady=AbsI64(dy),adz=AbsI64(dz);
|
||||
if (width>0) {
|
||||
if (adx>=ady) {
|
||||
if (adx>=adz) {
|
||||
if (d=adx) {
|
||||
if (dx>=0)
|
||||
dx=0x100000000;
|
||||
else
|
||||
dx=-0x100000000;
|
||||
dy=dy<<32/d;
|
||||
dz=dz<<32/d;
|
||||
}
|
||||
} else {
|
||||
if (d=adz) {
|
||||
dx=dx<<32/d;
|
||||
dy=dy<<32/d;
|
||||
if (dz>=0)
|
||||
dz=0x100000000;
|
||||
else
|
||||
dz=-0x100000000;
|
||||
}
|
||||
}
|
||||
x1<<=32; y1<<=32; z1<<=32;
|
||||
for (j=0;j<start;j++) {
|
||||
x1+=dx; y1+=dy; z1+=dz;
|
||||
}
|
||||
if (start>=d)
|
||||
res+=GrFillCircle(dc,x1.i32[1],y1.i32[1],z1.i32[1],width);
|
||||
else {
|
||||
if (width==1)
|
||||
for (i=start;i<=d;i++) {
|
||||
dc->db_z=z1.i32[1];
|
||||
res+=GrPlot1(dc,x1.i32[1],y1.i32[1]);
|
||||
_x=x1.i32[1]; _y=y1.i32[1]; _z=z1.i32[1];
|
||||
x1+=dx; y1+=dy; z1+=dz;
|
||||
}
|
||||
else {
|
||||
i=width*Sqrt(SqrI64(adx)+SqrI64(ady))/adx;
|
||||
d_lo=i>>1; d_hi=(i-1)>>1;
|
||||
|
||||
if (dx>=0)
|
||||
res+=GrFillSemiCircle(dc,x1.i32[1],y1.i32[1],z1.i32[1],width,2);
|
||||
else
|
||||
res+=GrFillSemiCircle(dc,x1.i32[1],y1.i32[1],z1.i32[1],width,7);
|
||||
for (i=start;i<=d;i++) {
|
||||
res+=GrVLine(dc,x1.i32[1],y1.i32[1]-d_lo,y1.i32[1]+d_hi,
|
||||
z1.i32[1],z1.i32[1]);
|
||||
_x=x1.i32[1]; _y=y1.i32[1]; _z=z1.i32[1];
|
||||
x1+=dx; y1+=dy; z1+=dz;
|
||||
}
|
||||
x1-=dx; y1-=dy; z1-=dz;
|
||||
if (dx>=0)
|
||||
res+=GrFillSemiCircle(dc,x1.i32[1],y1.i32[1],z1.i32[1],width,3);
|
||||
else
|
||||
res+=GrFillSemiCircle(dc,x1.i32[1],y1.i32[1],z1.i32[1],width,6);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (ady>=adz) {
|
||||
if (d=ady) {
|
||||
dx=dx<<32/d;
|
||||
if (dy>=0)
|
||||
dy=0x100000000;
|
||||
else
|
||||
dy=-0x100000000;
|
||||
dz=dz<<32/d;
|
||||
}
|
||||
} else {
|
||||
if (d=adz) {
|
||||
dx=dx<<32/d;
|
||||
dy=dy<<32/d;
|
||||
if (dz>=0)
|
||||
dz=0x100000000;
|
||||
else
|
||||
dz=-0x100000000;
|
||||
}
|
||||
}
|
||||
x1<<=32; y1<<=32; z1<<=32;
|
||||
for (j=0;j<start;j++) {
|
||||
x1+=dx; y1+=dy; z1+=dz;
|
||||
}
|
||||
if (start>=d)
|
||||
res+=GrFillCircle(dc,x1.i32[1],y1.i32[1],z1.i32[1],width);
|
||||
else {
|
||||
if (width==1)
|
||||
for (i=start;i<=d;i++) {
|
||||
dc->db_z=z1.i32[1];
|
||||
res+=GrPlot1(dc,x1.i32[1],y1.i32[1]);
|
||||
_x=x1.i32[1]; _y=y1.i32[1]; _z=z1.i32[1];
|
||||
x1+=dx; y1+=dy; z1+=dz;
|
||||
}
|
||||
else {
|
||||
i=width*Sqrt(SqrI64(ady)+SqrI64(adx))/ady;
|
||||
d_lo=i>>1; d_hi=(i-1)>>1;
|
||||
|
||||
if (dy>=0)
|
||||
res+=GrFillSemiCircle(dc,x1.i32[1],y1.i32[1],z1.i32[1],width,0);
|
||||
else
|
||||
res+=GrFillSemiCircle(dc,x1.i32[1],y1.i32[1],z1.i32[1],width,5);
|
||||
for (i=start;i<=d;i++) {
|
||||
res+=GrHLine(dc,x1.i32[1]-d_lo,x1.i32[1]+d_hi,y1.i32[1],
|
||||
z1.i32[1],z1.i32[1]);
|
||||
_x=x1.i32[1]; _y=y1.i32[1]; _z=z1.i32[1];
|
||||
x1+=dx; y1+=dy; z1+=dz;
|
||||
}
|
||||
x1-=dx; y1-=dy; z1-=dz;
|
||||
if (dy>=0)
|
||||
res+=GrFillSemiCircle(dc,x1.i32[1],y1.i32[1],z1.i32[1],width,1);
|
||||
else
|
||||
res+=GrFillSemiCircle(dc,x1.i32[1],y1.i32[1],z1.i32[1],width,4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public Bool GrLine3(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,I64 x2,I64 y2,I64 z2,
|
||||
I64 step=1,I64 start=0)
|
||||
{//3D. Transformation with pen width.
|
||||
@@ -536,20 +786,28 @@ public Bool GrLine3(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,I64 x2,I64 y2,I64 z2,
|
||||
_x2=x2; _y2=y2; _z2=z2;
|
||||
DCReflect(dc,&_x2,&_y2,&_z2);
|
||||
dc->flags&=~DCF_SYMMETRY;
|
||||
if (step==1 && !start && !dc->brush && dc->pen_width<2 &&
|
||||
!dc->depth_buf) {//TODO: clip z for depth buf
|
||||
if (DCClipLine(dc,&_x1,&_y1,&_x2,&_y2))
|
||||
res=Line(dc,_x1,_y1,0,_x2,_y2,0,&GrLinePlot0,step,start);
|
||||
if (step==1 && !dc->brush) {
|
||||
if (!start && dc->pen_width<2 && !dc->depth_buf) {//TODO: clip z depbuf
|
||||
if (DCClipLine(dc,&_x1,&_y1,&_x2,&_y2))
|
||||
res=Line(dc,_x1,_y1,0,_x2,_y2,0,&GrLinePlot0,step,start);
|
||||
} else {
|
||||
if (GrLineFat3(dc,_x1,_y1,_z1,_x2,_y2,_z2,dc->pen_width,start))
|
||||
res=TRUE;
|
||||
}
|
||||
} else
|
||||
res=Line(dc,_x1,_y1,_z1,_x2,_y2,_z2,&GrPlot3,step,start);
|
||||
was_symmetry=TRUE;
|
||||
if (dc->flags&DCF_JUST_MIRROR)
|
||||
goto gr_done;
|
||||
}
|
||||
if (step==1 && !start && !dc->brush && dc->pen_width<2 &&
|
||||
!dc->depth_buf) {//TODO: clip z for depth buf
|
||||
if (DCClipLine(dc,&x1,&y1,&x2,&y2))
|
||||
res|=Line(dc,x1,y1,0,x2,y2,0,&GrLinePlot0,step,start);
|
||||
if (step==1 && !dc->brush) {
|
||||
if (!start && dc->pen_width<2 && !dc->depth_buf) {//TODO: clip z depbuf
|
||||
if (DCClipLine(dc,&x1,&y1,&x2,&y2))
|
||||
res|=Line(dc,x1,y1,0,x2,y2,0,&GrLinePlot0,step,start);
|
||||
} else {
|
||||
if (GrLineFat3(dc,x1,y1,z1,x2,y2,z2,dc->pen_width,start))
|
||||
res=TRUE;
|
||||
}
|
||||
} else
|
||||
res|=Line(dc,x1,y1,z1,x2,y2,z2,&GrPlot3,step,start);
|
||||
gr_done:
|
||||
|
||||
+11
-14
@@ -221,8 +221,8 @@ U0 GrUpdateTextBG()
|
||||
for (row=num_rows;row--;) {
|
||||
for (col=num_cols;col--;) {
|
||||
cur_ch=*src++;
|
||||
if (cur_ch & (ATTRF_SELECTED|ATTRF_INVERT|ATTRF_BLINK)) {
|
||||
if (cur_ch & ATTRF_SELECTED)
|
||||
if (cur_ch & (ATTRF_SEL|ATTRF_INVERT|ATTRF_BLINK)) {
|
||||
if (cur_ch & ATTRF_SEL)
|
||||
cur_ch.u8[1]=cur_ch.u8[1]^0xFF;
|
||||
if (cur_ch & ATTRF_INVERT)
|
||||
cur_ch.u8[1]=cur_ch.u8[1]<<4+cur_ch.u8[1]>>4;
|
||||
@@ -286,8 +286,8 @@ U0 GrUpdateTextFG()
|
||||
for (row=num_rows;row--;) {
|
||||
for (col=num_cols;col--;) {
|
||||
cur_ch=*src++;
|
||||
if (cur_ch & (ATTRF_UNDERLINE|ATTRF_SELECTED|ATTRF_INVERT|ATTRF_BLINK)) {
|
||||
if (cur_ch & ATTRF_SELECTED)
|
||||
if (cur_ch & (ATTRF_UNDERLINE|ATTRF_SEL|ATTRF_INVERT|ATTRF_BLINK)) {
|
||||
if (cur_ch & ATTRF_SEL)
|
||||
cur_ch.u8[1]=cur_ch.u8[1]^0xFF;
|
||||
if (cur_ch & ATTRF_INVERT)
|
||||
cur_ch.u8[1]=cur_ch.u8[1]<<4+cur_ch.u8[1]>>4;
|
||||
@@ -327,34 +327,31 @@ U0 DCBlotColor8(CDC *dc,CDC *img)
|
||||
U0 GrUpdateTextModeText()
|
||||
{
|
||||
U32 *src=gr.text_base;
|
||||
I64 cur_ch,i,d0=TEXT_COLS*TEXT_ROWS;
|
||||
U16 *dst=VGAM_TEXT,*dst2=gr.vga_text_cache;
|
||||
I64 cur_ch,i=TEXT_COLS*TEXT_ROWS;
|
||||
U16 *dst=text.vga_text_alias,*dst2=gr.vga_text_cache;
|
||||
Bool blink_flag=Blink;
|
||||
if (LBtr(&sys_semas[SYS_SEMA_FLUSH_VGA_IMAGE],0)) {
|
||||
i=d0;
|
||||
while (i--) {
|
||||
cur_ch=*src++;
|
||||
if (cur_ch & ATTRF_SELECTED)
|
||||
if (cur_ch & ATTRF_SEL)
|
||||
cur_ch.u8[1]=cur_ch.u8[1]^0xFF;
|
||||
if (cur_ch & ATTRF_INVERT)
|
||||
cur_ch.u8[1]=cur_ch.u8[1]<<4+cur_ch.u8[1]>>4;
|
||||
if (cur_ch & ATTRF_BLINK)
|
||||
if (blink_flag)
|
||||
cur_ch.u8[1]= cur_ch.u8[1]<<4+ cur_ch.u8[1]>>4;
|
||||
cur_ch&=0x7FFF;
|
||||
*dst++=*dst2++=cur_ch;
|
||||
cur_ch.u8[1]=cur_ch.u8[1]<<4+cur_ch.u8[1]>>4;
|
||||
*dst++=*dst2++=cur_ch&0x7FFF;
|
||||
}
|
||||
} else {
|
||||
i=d0;
|
||||
while (i--) {
|
||||
cur_ch=*src++;
|
||||
if (cur_ch & ATTRF_SELECTED)
|
||||
if (cur_ch & ATTRF_SEL)
|
||||
cur_ch.u8[1]=cur_ch.u8[1]^0xFF;
|
||||
if (cur_ch & ATTRF_INVERT)
|
||||
cur_ch.u8[1]=cur_ch.u8[1]<<4+cur_ch.u8[1]>>4;
|
||||
if (cur_ch & ATTRF_BLINK)
|
||||
if (blink_flag)
|
||||
cur_ch.u8[1]= cur_ch.u8[1]<<4+ cur_ch.u8[1]>>4;
|
||||
cur_ch.u8[1]=cur_ch.u8[1]<<4+cur_ch.u8[1]>>4;
|
||||
cur_ch&=0x7FFF;
|
||||
if (*dst2!=cur_ch)
|
||||
*dst++=*dst2++=cur_ch;
|
||||
|
||||
@@ -172,7 +172,7 @@ public U0 Sprite3(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,
|
||||
GrPlot3(dc,x1+x,y1+y,z);
|
||||
}
|
||||
break;
|
||||
sub_switch_start:
|
||||
start:
|
||||
p=&tempg->nu.u;
|
||||
for (i=0;i<tempg->nu.num;i++,p++) {
|
||||
p->x+=x;
|
||||
@@ -191,7 +191,7 @@ public U0 Sprite3(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,
|
||||
case SPT_BSPLINE3_CLOSED:
|
||||
Gr3BSpline3(dc,&tempg->nu.u,tempg->nu.num,TRUE);
|
||||
break;
|
||||
sub_switch_end:
|
||||
end:
|
||||
p=&tempg->nu.u;
|
||||
for (i=0;i<tempg->nu.num;i++,p++) {
|
||||
p->x-=x;
|
||||
|
||||
+11
-26
@@ -334,32 +334,17 @@ public U0 TextBorder(CTask *task=NULL,
|
||||
I64 i;
|
||||
if (!task) task=Fs;
|
||||
attr<<=8;
|
||||
if (solid) {
|
||||
TextChar(task,,l-1,t-1,'É'+attr);
|
||||
TextChar(task,,r+1,t-1,'»'+attr);
|
||||
TextChar(task,,l-1,b+1,'È'+attr);
|
||||
TextChar(task,,r+1,b+1,'¼'+attr);
|
||||
for (i=l;i<=r;i++) {
|
||||
TextChar(task,,i,t-1,'Í'+attr);
|
||||
TextChar(task,,i,b+1,'Í'+attr);
|
||||
}
|
||||
for (i=t;i<=b;i++) {
|
||||
TextChar(task,,l-1,i,'º'+attr); //Note: $LK,"RawDr",A="MN:RawDr"$() uses this char.
|
||||
TextChar(task,,r+1,i,'º'+attr);
|
||||
}
|
||||
} else {
|
||||
TextChar(task,,l-1,t-1,'Ú'+attr);
|
||||
TextChar(task,,r+1,t-1,'¿'+attr);
|
||||
TextChar(task,,l-1,b+1,'À'+attr);
|
||||
TextChar(task,,r+1,b+1,'Ù'+attr);
|
||||
for (i=l;i<=r;i++) {
|
||||
TextChar(task,,i,t-1,'Ä'+attr);
|
||||
TextChar(task,,i,b+1,'Ä'+attr);
|
||||
}
|
||||
for (i=t;i<=b;i++) {
|
||||
TextChar(task,,l-1,i,'³'+attr);
|
||||
TextChar(task,,r+1,i,'³'+attr);
|
||||
}
|
||||
TextChar(task,,l-1,t-1,text.border_chars[6+solid]+attr);
|
||||
TextChar(task,,r+1,t-1,text.border_chars[8+solid]+attr);
|
||||
TextChar(task,,l-1,b+1,text.border_chars[10+solid]+attr);
|
||||
TextChar(task,,r+1,b+1,text.border_chars[12+solid]+attr);
|
||||
for (i=l;i<=r;i++) {
|
||||
TextChar(task,,i,t-1,text.border_chars[2+solid]+attr);
|
||||
TextChar(task,,i,b+1,text.border_chars[2+solid]+attr);
|
||||
}
|
||||
for (i=t;i<=b;i++) {
|
||||
TextChar(task,,l-1,i,text.border_chars[4+solid]+attr);
|
||||
TextChar(task,,r+1,i,text.border_chars[4+solid]+attr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -361,7 +361,7 @@ bm_menu:
|
||||
GrPlot3(img,a1-xx1,a2-yy1,0);
|
||||
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
|
||||
break;
|
||||
sub_switch_start:
|
||||
start:
|
||||
if (down)
|
||||
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
|
||||
x1=a1; y1=a2;
|
||||
@@ -386,7 +386,7 @@ bm_menu:
|
||||
dc->pen_width=1;
|
||||
GrBorder(dc,x1,y1,x1,y1);
|
||||
break;
|
||||
sub_switch_end:
|
||||
end:
|
||||
break;
|
||||
case GBM_PASTE:
|
||||
case GBM_PASTE_TRANSPARENT:
|
||||
|
||||
@@ -209,7 +209,7 @@ CSprite *Code2SpriteElem(CCmpCtrl *cc,I64 type)
|
||||
CQueVectU8 *tempv;
|
||||
MemSet(&g,0,sizeof(CSprite));
|
||||
switch (type) {
|
||||
sub_switch_start:
|
||||
start:
|
||||
case SPT_COLOR:
|
||||
case SPT_DITHER_COLOR:
|
||||
st=LexFirstRem(cc,"}");
|
||||
@@ -311,7 +311,7 @@ CSprite *Code2SpriteElem(CCmpCtrl *cc,I64 type)
|
||||
Lex(cc); //Skip ,
|
||||
g.pwha.angle=ã/180*LexExpressionF64(cc);
|
||||
break;
|
||||
sub_switch_end:
|
||||
end:
|
||||
size=SpriteElemSize(&g)+offset(CSprite.start);
|
||||
res=MAlloc(size);
|
||||
MemCpy(res,&g,size);
|
||||
|
||||
+52
-52
@@ -69,7 +69,7 @@ CSprite *Sprite2SpriteQue(U8 *elems)
|
||||
tempg1=MAlloc(SpriteElemSize(tempg)+offset(CSprite.start));
|
||||
s=SpriteElemSize(tempg);
|
||||
MemCpy(&tempg1->start,&tempg->start,s);
|
||||
tempg1->selected=FALSE;
|
||||
tempg1->sel=FALSE;
|
||||
QueIns(tempg1,res->last);
|
||||
tempg(U8 *)+=s;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ U0 SpriteSetOrigin(CSprite *root,I64 dx,I64 dy,I64 dz)
|
||||
CD3I32 *p;
|
||||
CSprite *tempg=root->next;
|
||||
while (tempg!=root) {
|
||||
if (tempg->selected)
|
||||
if (tempg->sel)
|
||||
switch (tempg->type) {
|
||||
case SPT_ARROW:
|
||||
case SPT_LINE:
|
||||
@@ -203,7 +203,7 @@ CSprite *SpriteTransformCircle(I64 *r,CSprite *tempg)
|
||||
tempg1->pwha.height=ToI64(m2)/0x10000;
|
||||
tempg1->pwha.angle=-a1;
|
||||
|
||||
tempg1->selected=tempg->selected;
|
||||
tempg1->sel=tempg->sel;
|
||||
return tempg1;
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ CSprite *SpriteTransformEllipse(I64 *r,CSprite *tempg)
|
||||
if (tempg1->pwha.height<1) tempg1->pwha.height=1;
|
||||
tempg1->pwha.angle=-a1;
|
||||
|
||||
tempg1->selected=tempg->selected;
|
||||
tempg1->sel=tempg->sel;
|
||||
return tempg1;
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ CSprite *SpriteTransformRect(I64 *r,CSprite *tempg,F64
|
||||
tempg1->ppa.y2=tempg1->ppa.y1+h;
|
||||
tempg1->ppa.angle=-a1;
|
||||
|
||||
tempg1->selected=tempg->selected;
|
||||
tempg1->sel=tempg->sel;
|
||||
return tempg1;
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ U0 SpriteTransform(I64 *r,CSprite *root)
|
||||
CD3I32 *p;
|
||||
CSprite *tempg=root->next,root2,*tempg1,*tempg2,*tempg3;
|
||||
while (tempg!=root) {
|
||||
if (tempg->selected)
|
||||
if (tempg->sel)
|
||||
switch (tempg->type) {
|
||||
case SPT_WIDTH:
|
||||
tempg->w.width*=Sqrt(Mat4x4NormSqr65536(r))/65536;
|
||||
@@ -506,7 +506,7 @@ U0 SpriteTransform(I64 *r,CSprite *root)
|
||||
tempg3->npu.num=num;
|
||||
QueIns(tempg3,tempg);
|
||||
QueRem(tempg);
|
||||
tempg3->selected=tempg->selected;
|
||||
tempg3->sel=tempg->sel;
|
||||
Free(tempg);
|
||||
tempg=tempg3;
|
||||
break;
|
||||
@@ -553,25 +553,25 @@ U0 SpriteTransform(I64 *r,CSprite *root)
|
||||
}
|
||||
}
|
||||
|
||||
I64 SpriteQueSelectCnt(CSprite *root,Bool val=TRUE)
|
||||
I64 SpriteQueSelCnt(CSprite *root,Bool val=TRUE)
|
||||
{
|
||||
I64 res=0;
|
||||
CSprite *tempg=root->next;
|
||||
val=ToBool(val);
|
||||
while (tempg!=root) {
|
||||
if (ToBool(tempg->selected)==val)
|
||||
if (ToBool(tempg->sel)==val)
|
||||
res++;
|
||||
tempg=tempg->next;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 SpriteQueSelectAll(CSprite *root,Bool val=TRUE)
|
||||
I64 SpriteQueSelAll(CSprite *root,Bool val=TRUE)
|
||||
{
|
||||
I64 res=0;
|
||||
CSprite *tempg=root->next;
|
||||
while (tempg!=root) {
|
||||
tempg->selected=val;
|
||||
tempg->sel=val;
|
||||
res++;
|
||||
tempg=tempg->next;
|
||||
}
|
||||
@@ -590,7 +590,7 @@ CSprite *SpriteSideBar2SpriteQue(CDoc *doc,CSprite *root,I64 *_cur_elem_num)
|
||||
tempg=SpriteSetSettings(,root,doc_e->left_exp);
|
||||
if (tempg!=root) {
|
||||
tempg=MAllocIdent(tempg);
|
||||
tempg->selected=Bt(&doc_e->type,DOCEt_SELECTED);
|
||||
tempg->sel=Bt(&doc_e->type,DOCEt_SEL);
|
||||
if (*_cur_elem_num==doc_e->left_exp) {
|
||||
*_cur_elem_num=num;
|
||||
found=TRUE;
|
||||
@@ -627,8 +627,8 @@ U0 SpriteSideBarPickNew(CDoc *doc,CSprite *root,I64 old_num)
|
||||
DocPrint(doc,"$$LTBLUE$$");
|
||||
doc_e=DocPrint(doc,"$$MU-UL,\"%Q\",LE=%d$$\n",st,cur_elem_num++);
|
||||
}
|
||||
BEqu(&doc_e->de_flags,DOCEf_SELECTED,tempg->selected);
|
||||
BEqu(&doc_e->type,DOCEt_SELECTED,tempg->selected);
|
||||
BEqu(&doc_e->de_flags,DOCEf_SEL,tempg->sel);
|
||||
BEqu(&doc_e->type,DOCEt_SEL,tempg->sel);
|
||||
Free(st);
|
||||
tempg=tempg->next;
|
||||
}
|
||||
@@ -715,13 +715,13 @@ Bool SpriteEdText(CSprite **_root,I64 *_cur_elem_num)
|
||||
return res;
|
||||
}
|
||||
|
||||
#define GED_SELECT_UNSELECT_ALL 0
|
||||
#define GED_SELECT 1
|
||||
#define GED_UNSELECT 2
|
||||
#define GED_SEL_UNSEL_ALL 0
|
||||
#define GED_SEL 1
|
||||
#define GED_UNSEL 2
|
||||
#define GED_SHIFT_PTS 3
|
||||
#define GED_SHIFT_RECTS 4
|
||||
#define GED_SHIFT_SELECTED 5
|
||||
#define GED_TRANSFORM_SELECTED 6
|
||||
#define GED_SHIFT_SEL 5
|
||||
#define GED_TRANSFORM_SEL 6
|
||||
#define GED_SET_ORIGIN 7
|
||||
#define GED_SHIFT_SUB_ORIGIN 8
|
||||
#define GED_TEXT_ED 9
|
||||
@@ -731,7 +731,7 @@ Bool SpriteEdText(CSprite **_root,I64 *_cur_elem_num)
|
||||
|
||||
U0 GrInit3()
|
||||
{
|
||||
DefineLstLoad("ST_SPRITE_ED_MENU","Select/Unslesct All\0"
|
||||
DefineLstLoad("ST_SPRITE_ED_MENU","Select/Unselect All\0"
|
||||
"Select\0Unselect\0Shift Points\0Shift Rects\0Shift Selected\0"
|
||||
"Transform Selected\0Set Origin\0Insert Shift SubOrigin\0"
|
||||
"Edit as Text\0Insert Clipboard\0Main Menu\0");
|
||||
@@ -746,13 +746,13 @@ I64 PopUpSpriteEd(CSprite **_root,I64 *_cur_elem_num)
|
||||
CDoc *doc=DocNew;
|
||||
DocPrint(doc,"$$PURPLE$$$$TX+CX,\"Sprite Edit Menu\"$$\n"
|
||||
"$$LK+PU+CX,\"Click for Help\",A=\"FI:::/Doc/SpriteEd.TXT.Z\"$$\n\n"
|
||||
"$$LTBLUE$$$$MU-UL,\"Select/Unselect All\",LE=GED_SELECT_UNSELECT_ALL$$\n"
|
||||
"$$MU-UL,\"Select Elems\",LE=GED_SELECT$$\n"
|
||||
"$$MU-UL,\"Unselect Elems\",LE=GED_UNSELECT$$\n\n"
|
||||
"$$LTBLUE$$$$MU-UL,\"Select/Unselect All\",LE=GED_SEL_UNSEL_ALL$$\n"
|
||||
"$$MU-UL,\"Select Elems\",LE=GED_SEL$$\n"
|
||||
"$$MU-UL,\"Unsel Elems\",LE=GED_UNSEL$$\n\n"
|
||||
"$$MU-UL,\"Shift Points\",LE=GED_SHIFT_PTS$$\n"
|
||||
"$$MU-UL,\"Shift Points with Rects\",LE=GED_SHIFT_RECTS$$\n"
|
||||
"$$MU-UL,\"Shift Selected Elems\",LE=GED_SHIFT_SELECTED$$\n"
|
||||
"$$MU-UL,\"Transform Selected Elems\",LE=GED_TRANSFORM_SELECTED$$\n\n"
|
||||
"$$MU-UL,\"Shift Selected Elems\",LE=GED_SHIFT_SEL$$\n"
|
||||
"$$MU-UL,\"Transform Selected Elems\",LE=GED_TRANSFORM_SEL$$\n\n"
|
||||
"$$MU-UL,\"Set Origin\",LE=GED_SET_ORIGIN$$\n"
|
||||
"$$MU-UL,\"Insert Shift SubOrigin\",LE=GED_SHIFT_SUB_ORIGIN$$\n\n"
|
||||
"$$MU-UL,\"Edit as Text\",LE=GED_TEXT_ED$$\n"
|
||||
@@ -775,7 +775,7 @@ I64 PopUpSpriteEd(CSprite **_root,I64 *_cur_elem_num)
|
||||
#define GSPT_SIMPLE_PT 0
|
||||
#define GSPT_WIDTH_HEIGHT 1
|
||||
|
||||
#define GSPF_SELECTED 1
|
||||
#define GSPF_SEL 1
|
||||
|
||||
class CEdSprite
|
||||
{
|
||||
@@ -920,7 +920,7 @@ U0 SpriteCtrlPtsDraw(CDC *dc,CEdSprite *root)
|
||||
y=*temppe->h+*temppe->y+temppe->yy;
|
||||
break;
|
||||
}
|
||||
if (temppe->flags&GSPF_SELECTED)
|
||||
if (temppe->flags&GSPF_SEL)
|
||||
dc->color=RED;
|
||||
else
|
||||
dc->color=BLACK;
|
||||
@@ -937,7 +937,7 @@ U0 SpriteCtrlPtsMove(CEdSprite *root,I64 dx,I64 dy)
|
||||
CEdSprite *temppe;
|
||||
temppe=root->next;
|
||||
while (temppe!=root) {
|
||||
if (temppe->flags&GSPF_SELECTED)
|
||||
if (temppe->flags&GSPF_SEL)
|
||||
switch (temppe->type) {
|
||||
case GSPT_SIMPLE_PT:
|
||||
if (temppe->x) *temppe->x+=dx;
|
||||
@@ -990,7 +990,7 @@ Bool SpriteShiftPts(U8 *elems,I64 x,I64 y,I64 *_cur_elem_num,I64 mode)
|
||||
temppe=temppe->next;
|
||||
}
|
||||
cur_elem_num=best_pe->num;
|
||||
best_pe->flags|=GSPF_SELECTED;
|
||||
best_pe->flags|=GSPF_SEL;
|
||||
break;
|
||||
case GED_SHIFT_RECTS:
|
||||
xx2=xx=a1; yy2=yy=a2;
|
||||
@@ -1013,12 +1013,12 @@ Bool SpriteShiftPts(U8 *elems,I64 x,I64 y,I64 *_cur_elem_num,I64 mode)
|
||||
case GSPT_SIMPLE_PT:
|
||||
if (xx<=*temppe->x+temppe->xx<=xx2 &&
|
||||
yy<=*temppe->y+temppe->yy<=yy2)
|
||||
temppe->flags|=GSPF_SELECTED;
|
||||
temppe->flags|=GSPF_SEL;
|
||||
break;
|
||||
case GSPT_WIDTH_HEIGHT:
|
||||
if (xx<=*temppe->x+*temppe->w+temppe->xx<=xx2 &&
|
||||
yy<=*temppe->y+*temppe->h+temppe->yy<=yy2)
|
||||
temppe->flags|=GSPF_SELECTED;
|
||||
temppe->flags|=GSPF_SEL;
|
||||
break;
|
||||
}
|
||||
temppe=temppe->next;
|
||||
@@ -1040,7 +1040,7 @@ Bool SpriteShiftPts(U8 *elems,I64 x,I64 y,I64 *_cur_elem_num,I64 mode)
|
||||
} while (msg_code!=MSG_IP_L_UP);
|
||||
temppe=root.next;
|
||||
while (temppe!=&root) {
|
||||
temppe->flags&=~GSPF_SELECTED;
|
||||
temppe->flags&=~GSPF_SEL;
|
||||
temppe=temppe->next;
|
||||
}
|
||||
break;
|
||||
@@ -1089,7 +1089,7 @@ I64 SpriteEd(CDoc *doc,CDocEntry *doc_ce,I64 x,I64 y,
|
||||
old_de_flags=doc_ce->de_flags;
|
||||
tempb=doc_ce->bin_data;
|
||||
DocUnlock(doc);
|
||||
SpriteQueSelectAll(*_root,FALSE);
|
||||
SpriteQueSelAll(*_root,FALSE);
|
||||
do {
|
||||
if (winmgr.fps<10)
|
||||
doc_ce->de_flags|=DOCEF_DONT_DRAW;
|
||||
@@ -1099,14 +1099,14 @@ I64 SpriteEd(CDoc *doc,CDocEntry *doc_ce,I64 x,I64 y,
|
||||
if (0<=i<GED_EXIT) {
|
||||
StrCpy(Fs->task_title,DefineSub(i,"ST_SPRITE_ED_MENU"));
|
||||
switch (i) {
|
||||
case GED_SELECT_UNSELECT_ALL:
|
||||
if (!SpriteQueSelectCnt(*_root))
|
||||
SpriteQueSelectAll(*_root);
|
||||
case GED_SEL_UNSEL_ALL:
|
||||
if (!SpriteQueSelCnt(*_root))
|
||||
SpriteQueSelAll(*_root);
|
||||
else
|
||||
SpriteQueSelectAll(*_root,FALSE);
|
||||
SpriteQueSelAll(*_root,FALSE);
|
||||
break;
|
||||
case GED_SELECT:
|
||||
case GED_UNSELECT:
|
||||
case GED_SEL:
|
||||
case GED_UNSEL:
|
||||
doc_ce->de_flags=old_de_flags;
|
||||
doc->cur_sprite=tempb->data;
|
||||
do {
|
||||
@@ -1116,23 +1116,23 @@ I64 SpriteEd(CDoc *doc,CDocEntry *doc_ce,I64 x,I64 y,
|
||||
if (msg_code==MSG_IP_L_DOWN) {
|
||||
*_cur_elem_num=doc->nearest_sprite_elem_num;
|
||||
cur_elem=SpriteSetSettings(,*_root,*_cur_elem_num);
|
||||
cur_elem->selected=ToBool(i==GED_SELECT);
|
||||
cur_elem->sel=ToBool(i==GED_SEL);
|
||||
GetMsg(,,1<<MSG_IP_L_UP);
|
||||
}
|
||||
} while (msg_code!=MSG_IP_R_UP);
|
||||
doc->cur_sprite=NULL;
|
||||
break;
|
||||
case GED_SET_ORIGIN:
|
||||
SpriteQueSelectAll(*_root);
|
||||
SpriteQueSelAll(*_root);
|
||||
doc_ce->de_flags=old_de_flags;
|
||||
GetMsg(&a1,&a2,1<<MSG_IP_L_UP);
|
||||
SpriteSetOrigin(*_root,x-a1,y-a2,0);
|
||||
SpriteEdUpdate(doc,doc_ce,*_root);
|
||||
SpriteQueSelectAll(*_root,FALSE);
|
||||
SpriteQueSelAll(*_root,FALSE);
|
||||
break;
|
||||
case GED_SHIFT_SELECTED:
|
||||
if (!SpriteQueSelectCnt(*_root))
|
||||
SpriteQueSelectAll(*_root);
|
||||
case GED_SHIFT_SEL:
|
||||
if (!SpriteQueSelCnt(*_root))
|
||||
SpriteQueSelAll(*_root);
|
||||
doc_ce->de_flags=old_de_flags;
|
||||
GetMsg(&a1,&a2,1<<MSG_IP_L_DOWN);
|
||||
xx=a1; yy=a2;
|
||||
@@ -1143,8 +1143,8 @@ I64 SpriteEd(CDoc *doc,CDocEntry *doc_ce,I64 x,I64 y,
|
||||
xx=a1; yy=a2;
|
||||
SpriteEdUpdate(doc,doc_ce,*_root);
|
||||
} while (msg_code!=MSG_IP_L_UP);
|
||||
if (!SpriteQueSelectCnt(*_root,FALSE))
|
||||
SpriteQueSelectAll(*_root,FALSE);
|
||||
if (!SpriteQueSelCnt(*_root,FALSE))
|
||||
SpriteQueSelAll(*_root,FALSE);
|
||||
break;
|
||||
case GED_SHIFT_PTS:
|
||||
case GED_SHIFT_RECTS:
|
||||
@@ -1161,15 +1161,15 @@ I64 SpriteEd(CDoc *doc,CDocEntry *doc_ce,I64 x,I64 y,
|
||||
} else
|
||||
SpriteEdUpdate(doc,doc_ce,*_root);
|
||||
break;
|
||||
case GED_TRANSFORM_SELECTED:
|
||||
if (!SpriteQueSelectCnt(*_root))
|
||||
SpriteQueSelectAll(*_root);
|
||||
case GED_TRANSFORM_SEL:
|
||||
if (!SpriteQueSelCnt(*_root))
|
||||
SpriteQueSelAll(*_root);
|
||||
if (PopUpTransform(r)) {
|
||||
SpriteTransform(r,*_root);
|
||||
SpriteEdUpdate(doc,doc_ce,*_root);
|
||||
}
|
||||
if (!SpriteQueSelectCnt(*_root,FALSE))
|
||||
SpriteQueSelectAll(*_root,FALSE);
|
||||
if (!SpriteQueSelCnt(*_root,FALSE))
|
||||
SpriteQueSelAll(*_root,FALSE);
|
||||
break;
|
||||
case GED_SHIFT_SUB_ORIGIN:
|
||||
doc_ce->de_flags=old_de_flags;
|
||||
|
||||
@@ -581,7 +581,7 @@ U0 SMTextFamily(I64 eletype,CDoc *doc,CDocEntry *doc_ce,CSprite *root,CDC *dc,
|
||||
|
||||
I64 SMBitMap(I64 eletype,CDoc *doc,CDocEntry *doc_ce,CSprite *root,
|
||||
CDC *dc,I64 xx,I64 yy,I64 a1,I64 a2,CColorROPU32 bm_bkcolor,
|
||||
Bool select,I64 xx1=0,I64 yy1=0,I64 xx2=0,I64 yy2=0,I64 *_cur_elem_num)
|
||||
Bool sel,I64 xx1=0,I64 yy1=0,I64 xx2=0,I64 yy2=0,I64 *_cur_elem_num)
|
||||
{
|
||||
I64 i,msg_code,x=xx,y=yy,x1=a1,y1=a2,x2=a1,y2=a2,old_width;
|
||||
CSprite *tempg,*tempg1,*insert_pt;
|
||||
@@ -590,7 +590,7 @@ I64 SMBitMap(I64 eletype,CDoc *doc,CDocEntry *doc_ce,CSprite *root,
|
||||
insert_pt=SpriteSetSettings(,root,*_cur_elem_num,xx,yy,,,&x,&y);
|
||||
x+=xx; y+=yy;
|
||||
|
||||
if (select) {
|
||||
if (sel) {
|
||||
xx1=a1; yy1=a2;
|
||||
xx2=a1; yy2=a2;
|
||||
old_width=dc->pen_width;
|
||||
@@ -1077,7 +1077,7 @@ I64 SpriteMainEd(CDoc *doc)
|
||||
break;
|
||||
case MSG_IP_L_DOWN:
|
||||
switch (eletype) {
|
||||
sub_switch_start:
|
||||
start:
|
||||
case SPT_LINE:
|
||||
tempg=SMLine(dc,x,y,a1,a2,color);
|
||||
break;
|
||||
@@ -1124,7 +1124,7 @@ I64 SpriteMainEd(CDoc *doc)
|
||||
case SPT_POLYPT:
|
||||
tempg=SMPolyPoint(dc,x,y,a1,a2,color);
|
||||
break;
|
||||
sub_switch_end:
|
||||
end:
|
||||
if (tempg) {
|
||||
QueIns(tempg,insert_pt->last);
|
||||
SpriteEdUpdate(doc,doc_ce,root);
|
||||
|
||||
+317
-204
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user