TempleOSCD_150720.ISO
This commit is contained in:
1 parent
401601816c
commit
f8c05f98f4
554 files changed
+26046
-24853
No files matched your search
+16
-10
@@ -5,7 +5,8 @@ U0 GrInit1()
|
||||
"End\0Color\0Dither Color\0"
|
||||
"Width\0Planar Symmetry\0Transform On\0Transform Off\0Shift\0"
|
||||
"Point\0PolyPoint\0Line\0PolyLine\0Rect\0Rotated Rect\0"
|
||||
"Circle\0Ellipse\0Polygon\0BSpline2\0BSpline2 Closed\0BSpline3\0BSpline3 Closed\0"
|
||||
"Circle\0Ellipse\0Polygon\0BSpline2\0BSpline2 Closed\0"
|
||||
"BSpline3\0BSpline3 Closed\0"
|
||||
"Flood Fill\0Flood Fill Not Color\0BitMap\0Mesh\0Shiftable Mesh\0"
|
||||
"Arrow\0Text\0Text Box\0Text Diamond\0");
|
||||
DefineLstLoad("ST_SPRITE_ELEM_CODES",
|
||||
@@ -18,12 +19,13 @@ U0 GrInit1()
|
||||
}
|
||||
GrInit1;
|
||||
|
||||
#help_index "Graphics/Sprite"
|
||||
#help_index "Sprites/Binary"
|
||||
|
||||
class CMeshTri
|
||||
{
|
||||
I32 color; //Give one of 0-7 colors. Colors 8-15 are 0-7 with intensity bit set.
|
||||
I32 nums[3]; //Vertex number
|
||||
I32 color; //Give one of 0-7 colors.
|
||||
//Colors 8-15 are 0-7 with intensity bit set.
|
||||
I32 nums[3]; //Vertex number
|
||||
};
|
||||
|
||||
class CQueMeshTri
|
||||
@@ -49,7 +51,7 @@ public class CSpriteDitherColor : CSpriteBase
|
||||
U16 dither_color;
|
||||
};
|
||||
|
||||
public class CSpriteWidth : CSpriteBase
|
||||
public class CSpriteW : CSpriteBase
|
||||
{
|
||||
I32 width;
|
||||
};
|
||||
@@ -136,7 +138,7 @@ public class CSpritePtMeshU8s : CSpriteBase
|
||||
#define SPT_END 0 //$LK,"CSpriteBase",A="MN:CSpriteBase"$
|
||||
#define SPT_COLOR 1 //$LK,"CSpriteColor",A="MN:CSpriteColor"$
|
||||
#define SPT_DITHER_COLOR 2 //$LK,"CSpriteDitherColor",A="MN:CSpriteDitherColor"$
|
||||
#define SPT_WIDTH 3 //$LK,"CSpriteWidth",A="MN:CSpriteWidth"$
|
||||
#define SPT_WIDTH 3 //$LK,"CSpriteW",A="MN:CSpriteW"$
|
||||
#define SPT_PLANAR_SYMMETRY 4 //$LK,"CSpritePtPt",A="MN:CSpritePtPt"$
|
||||
#define SPT_TRANSFORM_ON 5 //$LK,"CSpriteBase",A="MN:CSpriteBase"$
|
||||
#define SPT_TRANSFORM_OFF 6 //$LK,"CSpriteBase",A="MN:CSpriteBase"$
|
||||
@@ -157,14 +159,17 @@ public class CSpritePtMeshU8s : CSpriteBase
|
||||
#define SPT_FLOOD_FILL 21 //$LK,"CSpritePt",A="MN:CSpritePt"$
|
||||
#define SPT_FLOOD_FILL_NOT 22 //$LK,"CSpritePt",A="MN:CSpritePt"$
|
||||
#define SPT_BITMAP 23 //$LK,"CSpritePtWHU8s",A="MN:CSpritePtWHU8s"$
|
||||
#define SPT_MESH 24 //$LK,"CSpriteMeshU8s",A="MN:CSpriteMeshU8s"$ See $MA-X+PU,"::/Apps/GrModels",LM="Cd(\"::/Apps/GrModels\");Dir;View;\n"$.
|
||||
#define SPT_MESH 24 //$LK,"CSpriteMeshU8s",A="MN:CSpriteMeshU8s"$ See $MA-X+PU,"::/Apps/GrModels",LM="Cd(\"::/Apps/GrModels\");Dir;View;\n"$.
|
||||
#define SPT_SHIFTABLE_MESH 25 //$LK,"CSpritePtMeshU8s",A="MN:CSpritePtMeshU8s"$ See $MA-X+PU,"::/Apps/GrModels",LM="Cd(\"::/Apps/GrModels\");Dir;View;\n"$.
|
||||
#define SPT_ARROW 26 //$LK,"CSpritePtPt",A="MN:CSpritePtPt"$
|
||||
#define SPT_TEXT 27 //$LK,"CSpritePtStr",A="MN:CSpritePtStr"$
|
||||
#define SPT_TEXT_BOX 28 //$LK,"CSpritePtStr",A="MN:CSpritePtStr"$
|
||||
#define SPT_TEXT_DIAMOND 29 //$LK,"CSpritePtStr",A="MN:CSpritePtStr"$
|
||||
#define SPT_NUM_TYPES 30
|
||||
//See $LK,"Graphics/Sprite",A="HI:Graphics/Sprite"$. See $LK,"::/Adam/Gr/GrSpritePlot.CPP",A="FL:::/Adam/Gr/GrSpritePlot.CPP,1"$ and
|
||||
|
||||
#help_index "Graphics/Sprite;Sprites;Sprites/Binary"
|
||||
|
||||
//See $LK,"Sprites",A="HI:Sprites"$. See $LK,"::/Adam/Gr/GrSpritePlot.CPP",A="FL:::/Adam/Gr/GrSpritePlot.CPP,1"$ and
|
||||
//$LK,"::/Demo/Graphics/SpriteRaw.CPP"$ for how CSprite are stored.
|
||||
public class CSprite
|
||||
{
|
||||
@@ -175,7 +180,7 @@ public class CSprite
|
||||
CSpriteBase b;
|
||||
CSpriteColor c;
|
||||
CSpriteDitherColor d;
|
||||
CSpriteWidth w;
|
||||
CSpriteW w;
|
||||
CSpritePt p;
|
||||
CSpritePtPt pp;
|
||||
CSpritePtPtAng ppa;
|
||||
@@ -195,13 +200,14 @@ public class CSprite
|
||||
|
||||
extern I64 GrBlot3(CDC *dc,I64 x1,I64 y1,I64 z1,CDC *img);
|
||||
extern U8 *GrBitMap4ToBitMap8(U8 *dst,U8 *src,I64 src_size,I64 bkcolor);
|
||||
extern I64 *Mat4x4New(I64 *src,CTask *mem_task=NULL);
|
||||
extern U8 *SpriteQue2Sprite(CSprite *root,I64 *_size=NULL);
|
||||
|
||||
#include "GrGlbls"
|
||||
#include "GrTextBase"
|
||||
#include "GrAsm"
|
||||
#include "GrDC"
|
||||
#include "GrPalette"
|
||||
#include "GrDC"
|
||||
#include "GrInit"
|
||||
#include "GrMath"
|
||||
#include "GrScreen"
|
||||
|
||||
+4
-4
@@ -1,6 +1,5 @@
|
||||
#help_index "Graphics/Misc"
|
||||
asm {
|
||||
USE64
|
||||
//************************************
|
||||
_GR_UPDATE_LINE64::
|
||||
PUSH RBP
|
||||
@@ -398,9 +397,10 @@ _GR_ROP_EQU_U8_NO_CLIPPING::
|
||||
@@10: POP RBP
|
||||
RET1 24
|
||||
}
|
||||
_extern _GR_ROP_EQU_U8_NO_CLIPPING U0 GrRopEquU8NoClipping(I64 ch,U8 *dst,I64 width_internal);
|
||||
//No clipping
|
||||
public _extern _IS_PIX_COVERED0 Bool IsPixCovered0(CTask *task,I64 x,I64 y);
|
||||
_extern _GR_ROP_EQU_U8_NO_CLIPPING U0 GrRopEquU8NoClipping(I64 ch,
|
||||
U8 *dst,I64 width_internal);
|
||||
public _extern _IS_PIX_COVERED0 Bool IsPixCovered0(
|
||||
CTask *task,I64 x,I64 y);//No clipping
|
||||
|
||||
_extern _GR_UPDATE_LINE64 U0 GrUpdateLine64(
|
||||
U64 **_vga,U64 **_src,I64 d,U8 **_dst);
|
||||
|
||||
+175
-159
@@ -4,16 +4,11 @@ public Bool GrPlot0(CDC *dc=gr.dc,I64 x,I64 y)
|
||||
{//2D. No clipping or transformation or pen width.
|
||||
U8 *dst;
|
||||
I32 *db;
|
||||
I64 d,dist;
|
||||
I64 d;
|
||||
CColorROPU32 c,color=dc->color,bkcolor=dc->bkcolor;
|
||||
|
||||
if (dc->flags & DCF_LOCATE_NEAREST) {
|
||||
dist=DistSqrI64(x,y,dc->cur_x,dc->cur_y);
|
||||
if (dist<=dc->nearest_dist) {
|
||||
dc->nearest_sprite_elem_num=dc->cur_sprite_elem_num;
|
||||
dc->nearest_dist=dist;
|
||||
}
|
||||
}
|
||||
if (dc->flags & DCF_LOCATE_NEAREST)
|
||||
dc->dist=DistSqrI64(x,y,dc->cur_x,dc->cur_y);
|
||||
if (dc->flags & DCF_RECORD_EXTENTS) {
|
||||
if (x<dc->min_x) dc->min_x=x;
|
||||
if (x>dc->max_x) dc->max_x=x;
|
||||
@@ -71,8 +66,9 @@ public I64 GrPeek0(CDC *dc=gr.dc,I64 x,I64 y)
|
||||
public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
|
||||
{//2D. Clipping but not transformation..
|
||||
I64 i,j,k,k1,kk,kk1,w1,h1,w2,h2,
|
||||
leading_pixels,leading_pixel_mask,whole_I64s,trailing_pixels,trailing_pixel_mask,
|
||||
reg bit_shift,dist,win_z_buf_line_inc,win_z_buf_line_dec,win_z_num,
|
||||
leading_pixels,leading_pixel_mask,whole_I64s,
|
||||
trailing_pixels,trailing_pixel_mask,
|
||||
reg bit_shift,win_z_buf_line_inc,win_z_buf_line_dec,win_z_num,
|
||||
color_mask;
|
||||
U8 reg *dst,*src;
|
||||
I32 db;
|
||||
@@ -99,13 +95,8 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
|
||||
x+=win_task->pix_left;
|
||||
y+=win_task->pix_top;
|
||||
}
|
||||
if (dc->flags & DCF_LOCATE_NEAREST) {//TODO:Untested
|
||||
dist=DistSqrI64(x+img->width>>1,y+img->height>>1,dc->cur_x,dc->cur_y);
|
||||
if (dist<=dc->nearest_dist) {
|
||||
dc->nearest_sprite_elem_num=dc->cur_sprite_elem_num;
|
||||
dc->nearest_dist=dist;
|
||||
}
|
||||
}
|
||||
if (dc->flags & DCF_LOCATE_NEAREST)
|
||||
dc->dist=DistSqrI64(x+img->width>>1,y+img->height>>1,dc->cur_x,dc->cur_y);
|
||||
if (dc->flags & DCF_SCREEN_BITMAP) {
|
||||
if (x+w1<0) w1=-x;
|
||||
if (x+w2>win_task->pix_right+1)
|
||||
@@ -166,7 +157,8 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
|
||||
win_z_buf_ptr=NULL;
|
||||
else {
|
||||
win_z_num=win_task->win_z_num;
|
||||
win_z_buf_ptr=gr.win_z_buf(U8 *)+((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16);
|
||||
win_z_buf_ptr=gr.win_z_buf(U8 *)+((h1+y)/FONT_HEIGHT*TEXT_COLS+
|
||||
(w1+x)/FONT_WIDTH)*sizeof(U16);
|
||||
win_z_buf_line_dec=whole_I64s;
|
||||
if (leading_pixels)
|
||||
win_z_buf_line_dec++;
|
||||
@@ -187,7 +179,9 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
|
||||
if (win_z_num>=*win_z_buf_ptr++) {
|
||||
if (bit_shift)
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
|
||||
(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~leading_pixel_mask&color_mask;
|
||||
(*src(U64 *)++>>bit_shift|
|
||||
*src(I64 *)<<(64-bit_shift))&
|
||||
~leading_pixel_mask&color_mask;
|
||||
else
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
|
||||
*src(I64 *)++&~leading_pixel_mask&color_mask;
|
||||
@@ -199,7 +193,8 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
|
||||
if (bit_shift)
|
||||
for (i=0;i<whole_I64s;i++)
|
||||
if (win_z_num>=*win_z_buf_ptr++)
|
||||
*dst(I64 *)++=(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&color_mask;
|
||||
*dst(I64 *)++=(*src(U64 *)++>>bit_shift|
|
||||
*src(I64 *)<<(64-bit_shift))&color_mask;
|
||||
else {
|
||||
src(I64 *)++;
|
||||
dst(I64 *)++;
|
||||
@@ -215,7 +210,9 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
|
||||
if (trailing_pixels && win_z_num>=*win_z_buf_ptr++) {
|
||||
if (bit_shift)
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~trailing_pixel_mask&color_mask;
|
||||
(*src(U64 *)++>>bit_shift|
|
||||
*src(I64 *)<<(64-bit_shift))&
|
||||
~trailing_pixel_mask&color_mask;
|
||||
else
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
*src(I64 *)++&~trailing_pixel_mask&color_mask;
|
||||
@@ -234,14 +231,17 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
|
||||
if (leading_pixels) {
|
||||
if (bit_shift)
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
|
||||
(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~leading_pixel_mask&color_mask;
|
||||
(*src(U64 *)++>>bit_shift|
|
||||
*src(I64 *)<<(64-bit_shift))&
|
||||
~leading_pixel_mask&color_mask;
|
||||
else
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
|
||||
*src(I64 *)++&~leading_pixel_mask&color_mask;
|
||||
}
|
||||
if (bit_shift)
|
||||
for (i=0;i<whole_I64s;i++)
|
||||
*dst(I64 *)++=(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&color_mask;
|
||||
*dst(I64 *)++=(*src(U64 *)++>>bit_shift|
|
||||
*src(I64 *)<<(64-bit_shift))&color_mask;
|
||||
else
|
||||
for (i=0;i<whole_I64s;i++)
|
||||
*dst(I64 *)++=*src(I64 *)++&color_mask;
|
||||
@@ -249,7 +249,9 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
|
||||
if (trailing_pixels) {
|
||||
if (bit_shift)
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~trailing_pixel_mask&color_mask;
|
||||
(*src(U64 *)++>>bit_shift|
|
||||
*src(I64 *)<<(64-bit_shift))&
|
||||
~trailing_pixel_mask&color_mask;
|
||||
else
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
*src(I64 *)++&~trailing_pixel_mask&color_mask;
|
||||
@@ -268,7 +270,8 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
|
||||
}
|
||||
} else {
|
||||
win_z_num =win_task->win_z_num;
|
||||
win_z_buf_ptr =gr.win_z_buf(U8 *)+((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16);
|
||||
win_z_buf_ptr =gr.win_z_buf(U8 *)+
|
||||
((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16);
|
||||
win_z_buf_line_dec=whole_I64s;
|
||||
if (leading_pixels)
|
||||
win_z_buf_line_dec++;
|
||||
@@ -307,7 +310,8 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
|
||||
win_z_buf_ptr=NULL;
|
||||
else {
|
||||
win_z_num=win_task->win_z_num;
|
||||
win_z_buf_ptr=gr.win_z_buf(U8 *)+((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16);
|
||||
win_z_buf_ptr=gr.win_z_buf(U8 *)+
|
||||
((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16);
|
||||
win_z_buf_line_dec=whole_I64s;
|
||||
if (leading_pixels)
|
||||
win_z_buf_line_dec++;
|
||||
@@ -328,7 +332,8 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
|
||||
if (win_z_num>=*win_z_buf_ptr++) {
|
||||
if (bit_shift)
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
|
||||
(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~leading_pixel_mask;
|
||||
(*src(U64 *)++>>bit_shift|
|
||||
*src(I64 *)<<(64-bit_shift))&~leading_pixel_mask;
|
||||
else
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
|
||||
*src(I64 *)++&~leading_pixel_mask;
|
||||
@@ -340,7 +345,8 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
|
||||
if (bit_shift)
|
||||
for (i=0;i<whole_I64s;i++)
|
||||
if (win_z_num>=*win_z_buf_ptr++)
|
||||
*dst(I64 *)++=*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift);
|
||||
*dst(I64 *)++=*src(U64 *)++>>bit_shift|
|
||||
*src(I64 *)<<(64-bit_shift);
|
||||
else {
|
||||
src(I64 *)++;
|
||||
dst(I64 *)++;
|
||||
@@ -356,7 +362,8 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
|
||||
if (trailing_pixels && win_z_num>=*win_z_buf_ptr++) {
|
||||
if (bit_shift)
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~trailing_pixel_mask;
|
||||
(*src(U64 *)++>>bit_shift|
|
||||
*src(I64 *)<<(64-bit_shift))&~trailing_pixel_mask;
|
||||
else
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
*src(I64 *)++&~trailing_pixel_mask;
|
||||
@@ -375,14 +382,16 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
|
||||
if (leading_pixels) {
|
||||
if (bit_shift)
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
|
||||
(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~leading_pixel_mask;
|
||||
(*src(U64 *)++>>bit_shift|
|
||||
*src(I64 *)<<(64-bit_shift))&~leading_pixel_mask;
|
||||
else
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
|
||||
*src(I64 *)++&~leading_pixel_mask;
|
||||
}
|
||||
if (bit_shift)
|
||||
for (i=0;i<whole_I64s;i++)
|
||||
*dst(I64 *)++=*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift);
|
||||
*dst(I64 *)++=*src(U64 *)++>>bit_shift|
|
||||
*src(I64 *)<<(64-bit_shift);
|
||||
else
|
||||
for (i=0;i<whole_I64s;i++)
|
||||
*dst(I64 *)++=*src(I64 *)++;
|
||||
@@ -390,7 +399,8 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
|
||||
if (trailing_pixels) {
|
||||
if (bit_shift)
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift))&~trailing_pixel_mask;
|
||||
(*src(U64 *)++>>bit_shift|
|
||||
*src(I64 *)<<(64-bit_shift))&~trailing_pixel_mask;
|
||||
else
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
*src(I64 *)++&~trailing_pixel_mask;
|
||||
@@ -413,8 +423,9 @@ here1a:
|
||||
k+=img->width_internal;
|
||||
}
|
||||
} else {
|
||||
win_z_num =win_task->win_z_num;
|
||||
win_z_buf_ptr =gr.win_z_buf(U8 *)+((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16);
|
||||
win_z_num =win_task->win_z_num;
|
||||
win_z_buf_ptr =gr.win_z_buf(U8 *)+
|
||||
((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16);
|
||||
win_z_buf_line_dec=whole_I64s;
|
||||
if (leading_pixels)
|
||||
win_z_buf_line_dec++;
|
||||
@@ -458,7 +469,8 @@ here1a:
|
||||
win_z_buf_ptr=NULL;
|
||||
else {
|
||||
win_z_num=win_task->win_z_num;
|
||||
win_z_buf_ptr=gr.win_z_buf(U8 *)+((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16);
|
||||
win_z_buf_ptr=gr.win_z_buf(U8 *)+
|
||||
((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16);
|
||||
win_z_buf_line_dec=whole_I64s;
|
||||
if (leading_pixels)
|
||||
win_z_buf_line_dec++;
|
||||
@@ -479,7 +491,8 @@ here1a:
|
||||
if (win_z_num>=*win_z_buf_ptr++) {
|
||||
if (bit_shift)
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
|
||||
(*dst(I64 *)^(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift)))&~leading_pixel_mask;
|
||||
(*dst(I64 *)^(*src(U64 *)++>>bit_shift|
|
||||
*src(I64 *)<<(64-bit_shift)))&~leading_pixel_mask;
|
||||
else
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
|
||||
(*dst(I64 *)^*src(I64 *)++)&~leading_pixel_mask;
|
||||
@@ -491,7 +504,8 @@ here1a:
|
||||
if (bit_shift)
|
||||
for (i=0;i<whole_I64s;i++)
|
||||
if (win_z_num>=*win_z_buf_ptr++)
|
||||
*dst(I64 *)++^=*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift);
|
||||
*dst(I64 *)++^=*src(U64 *)++>>bit_shift|
|
||||
*src(I64 *)<<(64-bit_shift);
|
||||
else {
|
||||
src(I64 *)++;
|
||||
dst(I64 *)++;
|
||||
@@ -507,7 +521,8 @@ here1a:
|
||||
if (trailing_pixels && win_z_num>=*win_z_buf_ptr++) {
|
||||
if (bit_shift)
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
(*dst(I64 *)^(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift)))&~trailing_pixel_mask;
|
||||
(*dst(I64 *)^(*src(U64 *)++>>bit_shift|
|
||||
*src(I64 *)<<(64-bit_shift)))&~trailing_pixel_mask;
|
||||
else
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
(*dst(I64 *)^*src(I64 *)++)&~trailing_pixel_mask;
|
||||
@@ -526,21 +541,24 @@ here1a:
|
||||
if (leading_pixels) {
|
||||
if (bit_shift)
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
|
||||
(*dst(I64 *)^(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift)))&~leading_pixel_mask;
|
||||
(*dst(I64 *)^(*src(U64 *)++>>bit_shift|
|
||||
*src(I64 *)<<(64-bit_shift)))&~leading_pixel_mask;
|
||||
else
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
|
||||
(*dst(I64 *)^*src(I64 *)++)&~leading_pixel_mask;
|
||||
}
|
||||
if (bit_shift)
|
||||
for (i=0;i<whole_I64s;i++)
|
||||
*dst(I64 *)++^=*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift);
|
||||
*dst(I64 *)++^=*src(U64 *)++>>bit_shift|
|
||||
*src(I64 *)<<(64-bit_shift);
|
||||
else
|
||||
for (i=0;i<whole_I64s;i++)
|
||||
*dst(I64 *)++^=*src(I64 *)++;
|
||||
if (trailing_pixels) {
|
||||
if (bit_shift)
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
(*dst(I64 *)^(*src(U64 *)++>>bit_shift|*src(I64 *)<<(64-bit_shift)))&~trailing_pixel_mask;
|
||||
(*dst(I64 *)^(*src(U64 *)++>>bit_shift|
|
||||
*src(I64 *)<<(64-bit_shift)))&~trailing_pixel_mask;
|
||||
else
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
(*dst(I64 *)^*src(I64 *)++)&~trailing_pixel_mask;
|
||||
@@ -588,7 +606,8 @@ U8 *GrBitMap1ToBitMap8(U8 *dst,U8 *src,I64 src_size,I64 bkcolor)
|
||||
return dst;
|
||||
}
|
||||
|
||||
public CDC *DCExtract(CDC *dc=gr.dc,I64 x1,I64 y1,I64 x2,I64 y2,CTask *task=NULL)
|
||||
public CDC *DCExtract(CDC *dc=gr.dc,I64 x1,I64 y1,I64 x2,I64 y2,
|
||||
CTask *task=NULL)
|
||||
{//Extract new device context rect from device context.
|
||||
CDC *result;
|
||||
CTask *win_task;
|
||||
@@ -597,9 +616,9 @@ public CDC *DCExtract(CDC *dc=gr.dc,I64 x1,I64 y1,I64 x2,I64 y2,CTask *task=NULL
|
||||
if (dc->flags & DCF_SCREEN_BITMAP) {
|
||||
win_task=dc->win_task;
|
||||
x1+=win_task->pix_left+win_task->scroll_x;
|
||||
y1+=win_task->pix_top+win_task->scroll_y;
|
||||
y1+=win_task->pix_top +win_task->scroll_y;
|
||||
x2+=win_task->pix_left+win_task->scroll_x;
|
||||
y2+=win_task->pix_top+win_task->scroll_y;
|
||||
y2+=win_task->pix_top +win_task->scroll_y;
|
||||
}
|
||||
result=DCNew(x2-x1+1,y2-y1+1,task);
|
||||
DCFill(result);
|
||||
@@ -613,7 +632,7 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
|
||||
{//2D. Clipping but not transformation.
|
||||
U8 reg *src,reg *dst,*font_ptr;
|
||||
I64 i,m,leading_pixels,trailing_pixels,leading_pixel_mask,trailing_pixel_mask,
|
||||
j,k1,kk1,w1,h1,w2,h2,reg bit_shift,dist,reg color_mask;
|
||||
j,k1,kk1,w1,h1,w2,h2,reg bit_shift,reg color_mask;
|
||||
CColorROPU32 color,c;
|
||||
CTask *win_task;
|
||||
|
||||
@@ -638,13 +657,8 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
|
||||
x+=win_task->pix_left;
|
||||
y+=win_task->pix_top;
|
||||
}
|
||||
if (dc->flags & DCF_LOCATE_NEAREST) {//TODO:Untested
|
||||
dist=DistSqrI64(x+w2>>1,y+h2>>1,dc->cur_x,dc->cur_y);
|
||||
if (dist<=dc->nearest_dist) {
|
||||
dc->nearest_sprite_elem_num=dc->cur_sprite_elem_num;
|
||||
dc->nearest_dist=dist;
|
||||
}
|
||||
}
|
||||
if (dc->flags & DCF_LOCATE_NEAREST)
|
||||
dc->dist=DistSqrI64(x+w2>>1,y+h2>>1,dc->cur_x,dc->cur_y);
|
||||
if (dc->flags & DCF_SCREEN_BITMAP) {
|
||||
if (x+w1<0) w1=-x;
|
||||
if (x+w2>win_task->pix_right+1)
|
||||
@@ -660,9 +674,9 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
|
||||
h2=dc->height-y;
|
||||
if (w1<w2<=FONT_WIDTH && h1<h2<=FONT_HEIGHT) {
|
||||
if (dc->flags & DCF_RECORD_EXTENTS) {
|
||||
if (x+w1<dc->min_x) dc->min_x=x+w1;
|
||||
if (x+w1 <dc->min_x) dc->min_x=x+w1;
|
||||
if (x+w2-1>dc->max_x) dc->max_x=x+w2-1;
|
||||
if (y+h1<dc->min_y) dc->min_y=y+h1;
|
||||
if (y+h1 <dc->min_y) dc->min_y=y+h1;
|
||||
if (y+h2-1>dc->max_y) dc->max_y=y+h2-1;
|
||||
}
|
||||
if (dc->flags & DCF_DONT_DRAW)
|
||||
@@ -709,7 +723,8 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
|
||||
case ROPB_MONO:
|
||||
for (j=h2-h1;j;j--) {
|
||||
m=gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF];
|
||||
*dst(I64 *)=*dst(I64 *)&leading_pixel_mask|(color_mask&m|*dst(I64 *)&~m)&~leading_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&leading_pixel_mask|
|
||||
(color_mask&m|*dst(I64 *)&~m)&~leading_pixel_mask;
|
||||
src++;
|
||||
dst+=dc->width_internal;
|
||||
}
|
||||
@@ -717,7 +732,9 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
|
||||
case ROPB_XOR:
|
||||
if (color_mask) {
|
||||
for (j=h2-h1;j;j--) {
|
||||
*dst(I64 *)=*dst(I64 *)&leading_pixel_mask|(*dst(I64 *)^gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF])&~leading_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&leading_pixel_mask|
|
||||
(*dst(I64 *)^gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF])&
|
||||
~leading_pixel_mask;
|
||||
src++;
|
||||
dst+=dc->width_internal;
|
||||
}
|
||||
@@ -736,19 +753,21 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
|
||||
case ROPB_MONO:
|
||||
for (j=h2-h1;j;j--) {
|
||||
m=gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF];
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|(color_mask&m|*dst(I64 *)&~m)&~trailing_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
(color_mask&m|*dst(I64 *)&~m)&~trailing_pixel_mask;
|
||||
src++;
|
||||
dst+=dc->width_internal;
|
||||
}
|
||||
break;
|
||||
case ROPB_XOR:
|
||||
if (color_mask) {
|
||||
if (color_mask)
|
||||
for (j=h2-h1;j;j--) {
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|(*dst(I64 *)^gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF])&~trailing_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
(*dst(I64 *)^gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF])&
|
||||
~trailing_pixel_mask;
|
||||
src++;
|
||||
dst+=dc->width_internal;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -764,21 +783,24 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
|
||||
for (j=h1;j<h2;j++) {
|
||||
if (!IsPixCovered0(win_task,k1,y+j)) {
|
||||
m=gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF];
|
||||
*dst(I64 *)=*dst(I64 *)&leading_pixel_mask|(color_mask&m|*dst(I64 *)&~m)&~leading_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&leading_pixel_mask|
|
||||
(color_mask&m|*dst(I64 *)&~m)&~leading_pixel_mask;
|
||||
}
|
||||
src++;
|
||||
dst+=dc->width_internal;
|
||||
}
|
||||
break;
|
||||
case ROPB_XOR:
|
||||
if (color_mask) {
|
||||
if (color_mask)
|
||||
for (j=h1;j<h2;j++) {
|
||||
if (!IsPixCovered0(win_task,k1,y+j))
|
||||
*dst(I64 *)=*dst(I64 *)&leading_pixel_mask|(*dst(I64 *)^gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF])&~leading_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&leading_pixel_mask|
|
||||
(*dst(I64 *)^gr.to_8_bits
|
||||
[*src(U16 *)>>bit_shift&0xFF])&
|
||||
~leading_pixel_mask;
|
||||
src++;
|
||||
dst+=dc->width_internal;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
k1+=8;
|
||||
@@ -795,21 +817,24 @@ public I64 GrPutChar(CDC *dc=gr.dc,I64 x,I64 y,U8 ch)
|
||||
for (j=h1;j<h2;j++) {
|
||||
if (!IsPixCovered0(win_task,k1,y+j)) {
|
||||
m=gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF];
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|(color_mask&m|*dst(I64 *)&~m)&~trailing_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
(color_mask&m|*dst(I64 *)&~m)&~trailing_pixel_mask;
|
||||
}
|
||||
src++;
|
||||
dst+=dc->width_internal;
|
||||
}
|
||||
break;
|
||||
case ROPB_XOR:
|
||||
if (color_mask) {
|
||||
if (color_mask)
|
||||
for (j=h1;j<h2;j++) {
|
||||
if (!IsPixCovered0(win_task,k1,y+j))
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|(*dst(I64 *)^gr.to_8_bits[*src(U16 *)>>bit_shift&0xFF])&~trailing_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
(*dst(I64 *)^gr.to_8_bits
|
||||
[*src(U16 *)>>bit_shift&0xFF])&
|
||||
~trailing_pixel_mask;
|
||||
src++;
|
||||
dst+=dc->width_internal;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -885,8 +910,9 @@ public I64 GrVPrint(CDC *dc=gr.dc,I64 x,I64 y,U8 *fmt,...)
|
||||
public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
{//2D. Width Height. Clipping but not transformation.
|
||||
//Returns cnt of pixs changed.
|
||||
I64 i,result=0,j,k1,kk1,w1,h1,w2,h2,dist,
|
||||
leading_pixels,original_leading_pixels,whole_I64s,trailing_pixels,leading_pixel_mask,trailing_pixel_mask,
|
||||
I64 i,result=0,j,k1,kk1,w1,h1,w2,h2,
|
||||
leading_pixels,original_leading_pixels,whole_I64s,
|
||||
trailing_pixels,leading_pixel_mask,trailing_pixel_mask,
|
||||
win_z_buf_line_inc,win_z_buf_line_dec,win_z_num,color_mask;
|
||||
U8 reg *dst;
|
||||
U16 reg *win_z_buf_ptr;
|
||||
@@ -916,17 +942,10 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
y+=win_task->pix_top;
|
||||
}
|
||||
if (dc->flags & DCF_LOCATE_NEAREST) {//TODO:Untested
|
||||
if (dc->cur_x>=x && dc->cur_y>=y &&
|
||||
dc->cur_x<=x+w && dc->cur_y<=y+h) {
|
||||
dc->nearest_sprite_elem_num=dc->cur_sprite_elem_num;
|
||||
dc->nearest_dist=0;
|
||||
} else {
|
||||
dist=DistSqrI64(x+w>>1,y+h>>1,dc->cur_x,dc->cur_y);
|
||||
if (dist<=dc->nearest_dist) {
|
||||
dc->nearest_sprite_elem_num=dc->cur_sprite_elem_num;
|
||||
dc->nearest_dist=dist;
|
||||
}
|
||||
}
|
||||
if (x<=dc->cur_x<=x+w && y<=dc->cur_y<=y+h)
|
||||
dc->dist=0;
|
||||
else
|
||||
dc->dist=DistSqrI64(x+w>>1,y+h>>1,dc->cur_x,dc->cur_y);
|
||||
}
|
||||
if (dc->flags & DCF_SCREEN_BITMAP) {
|
||||
if (x+w1<0) w1=-x;
|
||||
@@ -943,9 +962,9 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
h2=dc->height-y;
|
||||
if (w1<w2<=w && h1<h2<=h) {
|
||||
if (dc->flags & DCF_RECORD_EXTENTS) {
|
||||
if (x+w1<dc->min_x) dc->min_x=x+w1;
|
||||
if (x+w1 <dc->min_x) dc->min_x=x+w1;
|
||||
if (x+w2-1>dc->max_x) dc->max_x=x+w2-1;
|
||||
if (y+h1<dc->min_y) dc->min_y=y+h1;
|
||||
if (y+h1 <dc->min_y) dc->min_y=y+h1;
|
||||
if (y+h2-1>dc->max_y) dc->max_y=y+h2-1;
|
||||
}
|
||||
if (dc->flags & DCF_DONT_DRAW)
|
||||
@@ -992,7 +1011,8 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
win_z_buf_ptr=NULL;
|
||||
else {
|
||||
win_z_num=win_task->win_z_num;
|
||||
win_z_buf_ptr=gr.win_z_buf(U8 *)+((h1+y)/FONT_HEIGHT*TEXT_COLS+(w1+x)/FONT_WIDTH)*sizeof(U16);
|
||||
win_z_buf_ptr=gr.win_z_buf(U8 *)+((h1+y)/FONT_HEIGHT*TEXT_COLS+
|
||||
(w1+x)/FONT_WIDTH)*sizeof(U16);
|
||||
win_z_buf_line_dec=whole_I64s;
|
||||
if (leading_pixels)
|
||||
win_z_buf_line_dec++;
|
||||
@@ -1018,7 +1038,8 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
dst=dc->body+kk1&~7;
|
||||
if (leading_pixels) {
|
||||
if (win_z_num>=*win_z_buf_ptr++) {
|
||||
*dst(I64 *)=*dst(I64 *)&leading_pixel_mask|color_mask&~leading_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&leading_pixel_mask|
|
||||
color_mask&~leading_pixel_mask;
|
||||
result+=leading_pixels;
|
||||
}
|
||||
dst(I64 *)++;
|
||||
@@ -1029,7 +1050,8 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
result+=8;
|
||||
}
|
||||
if (trailing_pixels && win_z_num>=*win_z_buf_ptr++) {
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|color_mask&~trailing_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
color_mask&~trailing_pixel_mask;
|
||||
result+=trailing_pixels;
|
||||
}
|
||||
if ((j+y)&7==7)
|
||||
@@ -1047,11 +1069,13 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
color_mask=gr.to_8_colors[color.c0.color];
|
||||
dst=dc->body+kk1&~7;
|
||||
if (leading_pixels)
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|color_mask&~leading_pixel_mask;
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
|
||||
color_mask&~leading_pixel_mask;
|
||||
for (i=0;i<whole_I64s;i++,dst(I64 *)++)
|
||||
*dst(I64 *)=color_mask;
|
||||
if (trailing_pixels)
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|color_mask&~trailing_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
color_mask&~trailing_pixel_mask;
|
||||
kk1+=dc->width_internal;
|
||||
if (RandU16<dc->dither_probability_u16)
|
||||
color.c0=dither_colors.c1;
|
||||
@@ -1069,7 +1093,8 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
dst=dc->body+kk1&~7;
|
||||
if (leading_pixels) {
|
||||
if (win_z_num>=*win_z_buf_ptr++) {
|
||||
*dst(I64 *)=*dst(I64 *)&leading_pixel_mask|*dst(I64 *)^color_mask&~leading_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&leading_pixel_mask|
|
||||
*dst(I64 *)^color_mask&~leading_pixel_mask;
|
||||
result+=leading_pixels;
|
||||
}
|
||||
dst(I64 *)++;
|
||||
@@ -1080,7 +1105,8 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
result+=8;
|
||||
}
|
||||
if (trailing_pixels && win_z_num>=*win_z_buf_ptr++) {
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|*dst(I64 *)^color_mask&~trailing_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
*dst(I64 *)^color_mask&~trailing_pixel_mask;
|
||||
result+=trailing_pixels;
|
||||
}
|
||||
if ((j+y)&7==7)
|
||||
@@ -1098,11 +1124,13 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
color_mask=gr.to_8_colors[color.c0.color];
|
||||
dst=dc->body+kk1&~7;
|
||||
if (leading_pixels)
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|*dst(I64 *)^color_mask&~leading_pixel_mask;
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
|
||||
*dst(I64 *)^color_mask&~leading_pixel_mask;
|
||||
for (i=0;i<whole_I64s;i++,dst(I64 *)++)
|
||||
*dst(I64 *)^=color_mask;
|
||||
if (trailing_pixels)
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|*dst(I64 *)^color_mask&~trailing_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
*dst(I64 *)^color_mask&~trailing_pixel_mask;
|
||||
kk1+=dc->width_internal;
|
||||
if (RandU16<dc->dither_probability_u16)
|
||||
color.c0=dither_colors.c1;
|
||||
@@ -1127,7 +1155,8 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
dst=dc->body+kk1&~7;
|
||||
if (leading_pixels) {
|
||||
if (win_z_num>=*win_z_buf_ptr++) {
|
||||
*dst(I64 *)=*dst(I64 *)&leading_pixel_mask|color_mask&~leading_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&leading_pixel_mask|
|
||||
color_mask&~leading_pixel_mask;
|
||||
result+=leading_pixels;
|
||||
}
|
||||
dst(I64 *)++;
|
||||
@@ -1138,7 +1167,8 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
result+=8;
|
||||
}
|
||||
if (trailing_pixels && win_z_num>=*win_z_buf_ptr++) {
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|color_mask&~trailing_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
color_mask&~trailing_pixel_mask;
|
||||
result+=trailing_pixels;
|
||||
}
|
||||
if ((j+y)&7==7)
|
||||
@@ -1154,11 +1184,13 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
gr.to_8_bits[0xAA]&gr.to_8_colors[color.c1.color];
|
||||
dst=dc->body+kk1&~7;
|
||||
if (leading_pixels)
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|color_mask&~leading_pixel_mask;
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
|
||||
color_mask&~leading_pixel_mask;
|
||||
for (i=0;i<whole_I64s;i++,dst(I64 *)++)
|
||||
*dst(I64 *)=color_mask;
|
||||
if (trailing_pixels)
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|color_mask&~trailing_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
color_mask&~trailing_pixel_mask;
|
||||
kk1+=dc->width_internal;
|
||||
SwapU16(&color.c0,&color.c1);
|
||||
}
|
||||
@@ -1174,7 +1206,8 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
dst=dc->body+kk1&~7;
|
||||
if (leading_pixels) {
|
||||
if (win_z_num>=*win_z_buf_ptr++) {
|
||||
*dst(I64 *)=*dst(I64 *)&leading_pixel_mask|*dst(I64 *)^color_mask&~leading_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&leading_pixel_mask|
|
||||
*dst(I64 *)^color_mask&~leading_pixel_mask;
|
||||
result+=leading_pixels;
|
||||
}
|
||||
dst(I64 *)++;
|
||||
@@ -1185,7 +1218,8 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
result+=8;
|
||||
}
|
||||
if (trailing_pixels && win_z_num>=*win_z_buf_ptr++) {
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|*dst(I64 *)^color_mask&~trailing_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
*dst(I64 *)^color_mask&~trailing_pixel_mask;
|
||||
result+=trailing_pixels;
|
||||
}
|
||||
if ((j+y)&7==7)
|
||||
@@ -1201,11 +1235,13 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
gr.to_8_bits[0xAA]&gr.to_8_colors[color.c1.color];
|
||||
dst=dc->body+kk1&~7;
|
||||
if (leading_pixels)
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|*dst(I64 *)^color_mask&~leading_pixel_mask;
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
|
||||
*dst(I64 *)^color_mask&~leading_pixel_mask;
|
||||
for (i=0;i<whole_I64s;i++,dst(I64 *)++)
|
||||
*dst(I64 *)^=color_mask;
|
||||
if (trailing_pixels)
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|*dst(I64 *)^color_mask&~trailing_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
*dst(I64 *)^color_mask&~trailing_pixel_mask;
|
||||
kk1+=dc->width_internal;
|
||||
SwapU16(&color.c0,&color.c1);
|
||||
}
|
||||
@@ -1225,7 +1261,8 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
dst=dc->body+kk1&~7;
|
||||
if (leading_pixels) {
|
||||
if (win_z_num>=*win_z_buf_ptr++) {
|
||||
*dst(I64 *)=*dst(I64 *)&leading_pixel_mask|color_mask&~leading_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&leading_pixel_mask|
|
||||
color_mask&~leading_pixel_mask;
|
||||
result+=leading_pixels;
|
||||
}
|
||||
dst(I64 *)++;
|
||||
@@ -1236,7 +1273,8 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
result+=8;
|
||||
}
|
||||
if (trailing_pixels && win_z_num>=*win_z_buf_ptr++) {
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|color_mask&~trailing_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
color_mask&~trailing_pixel_mask;
|
||||
result+=trailing_pixels;
|
||||
}
|
||||
if ((j+y)&7==7)
|
||||
@@ -1249,11 +1287,13 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
for (j=h2-h1;j;j--) {
|
||||
dst(I64 *)=dc->body+kk1&~7;
|
||||
if (leading_pixels)
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|color_mask&~leading_pixel_mask;
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
|
||||
color_mask&~leading_pixel_mask;
|
||||
for (i=0;i<whole_I64s;i++,dst(I64 *)++)
|
||||
*dst(I64 *)=color_mask;
|
||||
if (trailing_pixels)
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|color_mask&~trailing_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
color_mask&~trailing_pixel_mask;
|
||||
kk1+=dc->width_internal;
|
||||
}
|
||||
result=(h2-h1)*(w2-w1);
|
||||
@@ -1266,7 +1306,8 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
dst=dc->body+kk1&~7;
|
||||
if (leading_pixels) {
|
||||
if (win_z_num>=*win_z_buf_ptr++) {
|
||||
*dst(I64 *)=*dst(I64 *)&leading_pixel_mask|*dst(I64 *)^color_mask&~leading_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&leading_pixel_mask|
|
||||
*dst(I64 *)^color_mask&~leading_pixel_mask;
|
||||
result+=leading_pixels;
|
||||
}
|
||||
dst(I64 *)++;
|
||||
@@ -1277,7 +1318,8 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
result+=8;
|
||||
}
|
||||
if (trailing_pixels && win_z_num>=*win_z_buf_ptr++) {
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|*dst(I64 *)^color_mask&~trailing_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
*dst(I64 *)^color_mask&~trailing_pixel_mask;
|
||||
result+=trailing_pixels;
|
||||
}
|
||||
if ((j+y)&7==7)
|
||||
@@ -1290,11 +1332,13 @@ public I64 GrRect(CDC *dc=gr.dc,I64 x,I64 y,I64 w,I64 h)
|
||||
for (j=h2-h1;j;j--) {
|
||||
dst=dc->body+kk1&~7;
|
||||
if (leading_pixels)
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|*dst(I64 *)^color_mask&~leading_pixel_mask;
|
||||
*dst(I64 *)++=*dst(I64 *)&leading_pixel_mask|
|
||||
*dst(I64 *)^color_mask&~leading_pixel_mask;
|
||||
for (i=0;i<whole_I64s;i++,dst(I64 *)++)
|
||||
*dst(I64 *)^=color_mask;
|
||||
if (trailing_pixels)
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|*dst(I64 *)^color_mask&~trailing_pixel_mask;
|
||||
*dst(I64 *)=*dst(I64 *)&trailing_pixel_mask|
|
||||
*dst(I64 *)^color_mask&~trailing_pixel_mask;
|
||||
kk1+=dc->width_internal;
|
||||
}
|
||||
result=(h2-h1)*(w2-w1);
|
||||
@@ -1327,11 +1371,8 @@ I64 GrRayLenMinus(CDC *dc,I64 x,I64 y)
|
||||
if (dc->flags & DCF_SCREEN_BITMAP) {
|
||||
x3+=win_task->pix_left;
|
||||
y3+=win_task->pix_top;
|
||||
if (x3<0 || y3<0 ||
|
||||
x3>win_task->pix_right ||
|
||||
y3>win_task->pix_bottom ||
|
||||
!(dc->flags&DCF_ON_TOP) &&
|
||||
IsPixCovered0(win_task,x3,y3))
|
||||
if (!(0<=x3<=win_task->pix_right) || !(0<=y3<=win_task->pix_bottom) ||
|
||||
!(dc->flags&DCF_ON_TOP) && IsPixCovered0(win_task,x3,y3))
|
||||
goto gr_done;
|
||||
}
|
||||
if (x3>=dc->width || y3>=dc->height)
|
||||
@@ -1345,10 +1386,8 @@ I64 GrRayLenMinus(CDC *dc,I64 x,I64 y)
|
||||
if (dc->flags & DCF_SCREEN_BITMAP) {
|
||||
if (x3<0) break;
|
||||
x3+=win_task->pix_left;
|
||||
if (x3<0 || x3>win_task->pix_right ||
|
||||
x3>=dc->width ||
|
||||
!(dc->flags&DCF_ON_TOP) &&
|
||||
IsPixCovered0(win_task,x3,y3))
|
||||
if (!(0<=x3<=win_task->pix_right) || x3>=dc->width ||
|
||||
!(dc->flags&DCF_ON_TOP) && IsPixCovered0(win_task,x3,y3))
|
||||
break;
|
||||
} else
|
||||
if (!(0<=x3<dc->width))
|
||||
@@ -1379,8 +1418,9 @@ gr_done:
|
||||
I64 GrRayLen(CDC *dc,I64 *x1,I64 y,I64 z=0,I32 *db=NULL)
|
||||
{
|
||||
//Returns cnt of pixs changed
|
||||
I64 result=0,d,x=*x1,x2,x3,y3,dist;
|
||||
Bool plot,dither,probability_dither,not_color=ToBool(dc->flags&DCF_FILL_NOT_COLOR);
|
||||
I64 result=0,d,x=*x1,x2,x3,y3;
|
||||
Bool plot,dither,probability_dither,
|
||||
not_color=ToBool(dc->flags&DCF_FILL_NOT_COLOR);
|
||||
U8 *dst,*dst2;
|
||||
CColorROPU32 c,c2,color=dc->color,bkcolor=dc->bkcolor;
|
||||
I32 *db2;
|
||||
@@ -1400,11 +1440,8 @@ I64 GrRayLen(CDC *dc,I64 *x1,I64 y,I64 z=0,I32 *db=NULL)
|
||||
if (dc->flags & DCF_SCREEN_BITMAP) {
|
||||
x3+=win_task->pix_left;
|
||||
y3+=win_task->pix_top;
|
||||
if (x3<0 || y3<0 ||
|
||||
x3>win_task->pix_right ||
|
||||
y3>win_task->pix_bottom ||
|
||||
!(dc->flags&DCF_ON_TOP) &&
|
||||
IsPixCovered0(win_task,x3,y3))
|
||||
if (!(0<=x3<=win_task->pix_right) || !(0<=y3<=win_task->pix_bottom) ||
|
||||
!(dc->flags&DCF_ON_TOP) && IsPixCovered0(win_task,x3,y3))
|
||||
goto gr_done;
|
||||
}
|
||||
if (x3>=dc->width || y3>=dc->height)
|
||||
@@ -1432,10 +1469,8 @@ I64 GrRayLen(CDC *dc,I64 *x1,I64 y,I64 z=0,I32 *db=NULL)
|
||||
if (dc->flags & DCF_SCREEN_BITMAP) {
|
||||
if (x3<0) break;
|
||||
x3+=win_task->pix_left;
|
||||
if (x3<0 || x3>win_task->pix_right ||
|
||||
x3>=dc->width ||
|
||||
!(dc->flags&DCF_ON_TOP) &&
|
||||
IsPixCovered0(win_task,x3,y3))
|
||||
if (!(0<=x3<=win_task->pix_right) || x3>=dc->width ||
|
||||
!(dc->flags&DCF_ON_TOP) && IsPixCovered0(win_task,x3,y3))
|
||||
break;
|
||||
} else {
|
||||
if (!(0<=x3<dc->width))
|
||||
@@ -1459,13 +1494,8 @@ I64 GrRayLen(CDC *dc,I64 *x1,I64 y,I64 z=0,I32 *db=NULL)
|
||||
|
||||
if ((not_color && c!=dc->color2 ||
|
||||
!not_color && c==dc->color2) && plot) {
|
||||
if (dc->flags & DCF_LOCATE_NEAREST) {
|
||||
dist=DistSqrI64(x3,y3,dc->cur_x,dc->cur_y);
|
||||
if (dist<=dc->nearest_dist) {
|
||||
dc->nearest_sprite_elem_num=dc->cur_sprite_elem_num;
|
||||
dc->nearest_dist=dist;
|
||||
}
|
||||
}
|
||||
if (dc->flags & DCF_LOCATE_NEAREST)
|
||||
dc->dist=DistSqrI64(x3,y3,dc->cur_x,dc->cur_y);
|
||||
if (dc->flags & DCF_RECORD_EXTENTS) {
|
||||
if (x3<dc->min_x) dc->min_x=x3;
|
||||
if (x3>dc->max_x) dc->max_x=x3;
|
||||
@@ -1513,10 +1543,8 @@ I64 GrRayLen(CDC *dc,I64 *x1,I64 y,I64 z=0,I32 *db=NULL)
|
||||
if (dc->flags & DCF_SCREEN_BITMAP) {
|
||||
if (x3<0) break;
|
||||
x3+=win_task->pix_left;
|
||||
if (x3<0 || x3>win_task->pix_right ||
|
||||
x3>=dc->width ||
|
||||
!(dc->flags&DCF_ON_TOP) &&
|
||||
IsPixCovered0(win_task,x3,y3))
|
||||
if (!(0<=x3<=win_task->pix_right) || x3>=dc->width ||
|
||||
!(dc->flags&DCF_ON_TOP) && IsPixCovered0(win_task,x3,y3))
|
||||
break;
|
||||
} else
|
||||
if (!(0<=x3<dc->width))
|
||||
@@ -1538,13 +1566,8 @@ I64 GrRayLen(CDC *dc,I64 *x1,I64 y,I64 z=0,I32 *db=NULL)
|
||||
|
||||
if ((not_color && c!=dc->color2 ||
|
||||
!not_color && c==dc->color2) && plot) {
|
||||
if (dc->flags & DCF_LOCATE_NEAREST) {
|
||||
dist=DistSqrI64(x3,y3,dc->cur_x,dc->cur_y);
|
||||
if (dist<=dc->nearest_dist) {
|
||||
dc->nearest_sprite_elem_num=dc->cur_sprite_elem_num;
|
||||
dc->nearest_dist=dist;
|
||||
}
|
||||
}
|
||||
if (dc->flags & DCF_LOCATE_NEAREST)
|
||||
dc->dist=DistSqrI64(x3,y3,dc->cur_x,dc->cur_y);
|
||||
if (dc->flags & DCF_RECORD_EXTENTS) {
|
||||
if (x3<dc->min_x) dc->min_x=x3;
|
||||
if (x3>dc->max_x) dc->max_x=x3;
|
||||
@@ -1589,8 +1612,8 @@ gr_done:
|
||||
public I64 GrHLine(CDC *dc=gr.dc,I64 x1,I64 x2,I64 y,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 dx,dz,z,result=0,i,j,d,dist;
|
||||
//Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
I64 dist,dx,dz,z,result=0,i,j,d;
|
||||
U8 *dst;
|
||||
CColorROPU32 c,c2,color=dc->color,bkcolor=dc->bkcolor,dither_colors;
|
||||
I32 *db;
|
||||
@@ -1641,9 +1664,7 @@ public I64 GrHLine(CDC *dc=gr.dc,I64 x1,I64 x2,I64 y,I64 z1=0,I64 z2=0)
|
||||
x2=win_task->pix_right;
|
||||
}
|
||||
y+=win_task->pix_top;
|
||||
if (y>win_task->pix_bottom ||
|
||||
y<0 ||
|
||||
x2<0)
|
||||
if (!(0<=y<=win_task->pix_bottom) || x2<0)
|
||||
goto gr_done;
|
||||
}
|
||||
if (x1>=dc->width || y>=dc->height)
|
||||
@@ -1671,18 +1692,14 @@ public I64 GrHLine(CDC *dc=gr.dc,I64 x1,I64 x2,I64 y,I64 z1=0,I64 z2=0)
|
||||
else
|
||||
dist=SqrI64(dc->cur_x-x2);
|
||||
dist+=SqrI64(y-dc->cur_y);
|
||||
if (dist<=dc->nearest_dist) {
|
||||
dc->nearest_sprite_elem_num=dc->cur_sprite_elem_num;
|
||||
dc->nearest_dist=dist;
|
||||
}
|
||||
dc->dist=dist;
|
||||
}
|
||||
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,x1,y))
|
||||
dc->flags&DCF_ON_TOP || !IsPixCovered0(win_task,x1,y))
|
||||
char_clear=TRUE;
|
||||
else
|
||||
char_clear=FALSE;
|
||||
@@ -1750,8 +1767,7 @@ public I64 GrHLine(CDC *dc=gr.dc,I64 x1,I64 x2,I64 y,I64 z1=0,I64 z2=0)
|
||||
if (!(x1&(FONT_WIDTH-1)) && x1<=x2) {
|
||||
if (!(dc->flags & DCF_SCREEN_BITMAP)||
|
||||
win_task->next_task==sys_winmgr_task ||
|
||||
dc->flags&DCF_ON_TOP ||
|
||||
!IsPixCovered0(win_task,x1,y))
|
||||
dc->flags&DCF_ON_TOP || !IsPixCovered0(win_task,x1,y))
|
||||
char_clear=TRUE;
|
||||
else
|
||||
char_clear=FALSE;
|
||||
|
||||
+31
-20
@@ -12,7 +12,7 @@ public I64 GrFillPoly3(CDC *dc=gr.dc,I64 n,CD3I32 *poly)
|
||||
x=poly[j].x; y=poly[j].y; z=poly[j].z;
|
||||
if (dc->flags&DCF_TRANSFORMATION)
|
||||
(*dc->transform)(dc,&x,&y,&z);
|
||||
GrReflect(dc,&x,&y,&z);
|
||||
DCReflect(dc,&x,&y,&z);
|
||||
tri[0].x=x; tri[0].y=y; tri[0].z=z;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public I64 GrFillPoly3(CDC *dc=gr.dc,I64 n,CD3I32 *poly)
|
||||
x=poly[j].x; y=poly[j].y; z=poly[j].z;
|
||||
if (dc->flags&DCF_TRANSFORMATION)
|
||||
(*dc->transform)(dc,&x,&y,&z);
|
||||
GrReflect(dc,&x,&y,&z);
|
||||
DCReflect(dc,&x,&y,&z);
|
||||
}
|
||||
tri[1].x=x; tri[1].y=y; tri[1].z=z;
|
||||
|
||||
@@ -29,7 +29,7 @@ public I64 GrFillPoly3(CDC *dc=gr.dc,I64 n,CD3I32 *poly)
|
||||
x=poly[j].x; y=poly[j].y; z=poly[j].z;
|
||||
if (dc->flags&DCF_TRANSFORMATION)
|
||||
(*dc->transform)(dc,&x,&y,&z);
|
||||
GrReflect(dc,&x,&y,&z);
|
||||
DCReflect(dc,&x,&y,&z);
|
||||
tri[2].x=x; tri[2].y=y; tri[2].z=z;
|
||||
|
||||
result+=GrFillTri0(dc,&tri[0],&tri[1],&tri[2]);
|
||||
@@ -90,7 +90,8 @@ public I64 GrRect3(CDC *dc=gr.dc,I64 x,I64 y,I64 z,I64 w,I64 h)
|
||||
return GrFillPoly3(dc,4,poly);
|
||||
}
|
||||
|
||||
public U0 GrBorder(CDC *dc=gr.dc,I64 x1,I64 y1,I64 x2,I64 y2,I64 step=1,I64 start=0)
|
||||
public U0 GrBorder(CDC *dc=gr.dc,I64 x1,I64 y1,I64 x2,I64 y2,
|
||||
I64 step=1,I64 start=0)
|
||||
{//2D. Transformation with pen width.
|
||||
//Can be used with ROPF_DITHER+WHITE<<16+BLACK for dotted rect.
|
||||
GrLine3(dc,x1,y1,0,x2,y1,0,step,start);
|
||||
@@ -99,7 +100,8 @@ public U0 GrBorder(CDC *dc=gr.dc,I64 x1,I64 y1,I64 x2,I64 y2,I64 step=1,I64 star
|
||||
GrLine3(dc,x1,y2,0,x1,y1,0,step,start);
|
||||
}
|
||||
|
||||
public Bool GrArrow3(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,I64 x2,I64 y2,I64 z2,F64 w=2.75,I64 step=1,I64 start=0)
|
||||
public Bool GrArrow3(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,
|
||||
I64 x2,I64 y2,I64 z2,F64 w=2.75,I64 step=1,I64 start=0)
|
||||
{//3D. Transformation with pen width.
|
||||
I64 _x1,_y1,_z1,_x2,_y2,_z2,dx,dy;
|
||||
F64 d;
|
||||
@@ -112,16 +114,18 @@ public Bool GrArrow3(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,I64 x2,I64 y2,I64 z2,F64
|
||||
}
|
||||
if (dc->flags & DCF_SYMMETRY) {
|
||||
_x1=x1; _y1=y1; _z1=z1;
|
||||
GrReflect(dc,&_x1,&_y1,&_z1);
|
||||
DCReflect(dc,&_x1,&_y1,&_z1);
|
||||
_x2=x2; _y2=y2; _z2=z2;
|
||||
GrReflect(dc,&_x2,&_y2,&_z2);
|
||||
DCReflect(dc,&_x2,&_y2,&_z2);
|
||||
dc->flags&=~DCF_SYMMETRY;
|
||||
result=Line(dc,_x1,_y1,_z1,_x2,_y2,_z2,&GrPlot3,step,start);
|
||||
dx=_x2-_x1; dy=_y2-_y1;
|
||||
if (d=Sqrt(dx*dx+dy*dy)) {
|
||||
d=w*dc->pen_width/d;
|
||||
result|=Line(dc,_x2-dx*d+dy*d+0.5,_y2-dy*d-dx*d+0.5,_z2,_x2,_y2,_z2,&GrPlot3,step);
|
||||
result|=Line(dc,_x2-dx*d-dy*d+0.5,_y2-dy*d+dx*d+0.5,_z2,_x2,_y2,_z2,&GrPlot3,step);
|
||||
result|=Line(dc,_x2-dx*d+dy*d+0.5,_y2-dy*d-dx*d+0.5,_z2,
|
||||
_x2,_y2,_z2,&GrPlot3,step);
|
||||
result|=Line(dc,_x2-dx*d-dy*d+0.5,_y2-dy*d+dx*d+0.5,_z2,
|
||||
_x2,_y2,_z2,&GrPlot3,step);
|
||||
}
|
||||
was_symmetry=TRUE;
|
||||
if (dc->flags&DCF_JUST_MIRROR)
|
||||
@@ -131,8 +135,10 @@ public Bool GrArrow3(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,I64 x2,I64 y2,I64 z2,F64
|
||||
dx=x2-x1; dy=y2-y1;
|
||||
if (d=Sqrt(dx*dx+dy*dy)) {
|
||||
d=w*dc->pen_width/d;
|
||||
result|=Line(dc,x2-dx*d+dy*d+0.5,y2-dy*d-dx*d+0.5,z2,x2,y2,z2,&GrPlot3,step);
|
||||
result|=Line(dc,x2-dx*d-dy*d+0.5,y2-dy*d+dx*d+0.5,z2,x2,y2,z2,&GrPlot3,step);
|
||||
result|=Line(dc,x2-dx*d+dy*d+0.5,y2-dy*d-dx*d+0.5,z2,
|
||||
x2,y2,z2,&GrPlot3,step);
|
||||
result|=Line(dc,x2-dx*d-dy*d+0.5,y2-dy*d+dx*d+0.5,z2,
|
||||
x2,y2,z2,&GrPlot3,step);
|
||||
}
|
||||
gr_done:
|
||||
if (was_transform)
|
||||
@@ -174,7 +180,8 @@ public Bool GrTextBox3(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,U8 *s,I64 border=2)
|
||||
|
||||
#define MAX_DIAMOND_SLOPE 2.75
|
||||
|
||||
public Bool GrTextDiamond3(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,U8 *_s,I64 border=2)
|
||||
public Bool GrTextDiamond3(CDC *dc=gr.dc,
|
||||
I64 x1,I64 y1,I64 z1,U8 *_s,I64 border=2)
|
||||
{//3D. Transformation. DCF_SYMMETRY is silly.
|
||||
Bool first=TRUE;
|
||||
U8 ch,*ptr,*ptr_end,*st,*s;
|
||||
@@ -239,7 +246,8 @@ public Bool GrTextDiamond3(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,U8 *_s,I64 border=
|
||||
}
|
||||
|
||||
#help_index "Graphics/Mesh"
|
||||
public I64 Gr3Mesh(CDC *dc=gr.dc,I64 vertex_cnt,CD3I32 *p,I64 tri_cnt,CMeshTri *tri)
|
||||
public I64 Gr3Mesh(CDC *dc=gr.dc,I64 vertex_cnt,CD3I32 *p,
|
||||
I64 tri_cnt,CMeshTri *tri)
|
||||
{//Returns cnt of pixs changed.
|
||||
CColorROPU32 old_color=dc->color;
|
||||
I64 i,x,y,z,result=0;
|
||||
@@ -261,20 +269,23 @@ public I64 Gr3Mesh(CDC *dc=gr.dc,I64 vertex_cnt,CD3I32 *p,I64 tri_cnt,CMeshTri *
|
||||
p_sym=p;
|
||||
for (i=0;i<vertex_cnt;i++,p_sym++,dst++) {
|
||||
x=p_sym->x; y=p_sym->y; z=p_sym->z;
|
||||
GrReflect(dc,&x,&y,&z);
|
||||
DCReflect(dc,&x,&y,&z);
|
||||
dst->x=x; dst->y=y; dst->z=z;
|
||||
}
|
||||
p_sym=pt_sym;
|
||||
for (i=0;i<tri_cnt;i++,tri_sym++) {
|
||||
(*dc->lighting)(dc,&p_sym[tri_sym->nums[0]],&p_sym[tri_sym->nums[2]],&p_sym[tri_sym->nums[1]],tri_sym->color);
|
||||
result+=GrFillTri0(dc,&p_sym[tri_sym->nums[0]],&p_sym[tri_sym->nums[2]],&p_sym[tri_sym->nums[1]]);
|
||||
(*dc->lighting)(dc,&p_sym[tri_sym->nums[0]],&p_sym[tri_sym->nums[2]],
|
||||
&p_sym[tri_sym->nums[1]],tri_sym->color);
|
||||
result+=GrFillTri0(dc,&p_sym[tri_sym->nums[0]],&p_sym[tri_sym->nums[2]],
|
||||
&p_sym[tri_sym->nums[1]]);
|
||||
}
|
||||
Free(pt_sym);
|
||||
if (dc->flags&DCF_JUST_MIRROR)
|
||||
goto mesh_done;
|
||||
}
|
||||
for (i=0;i<tri_cnt;i++,tri++) {
|
||||
(*dc->lighting)(dc,&p[tri->nums[0]],&p[tri->nums[1]],&p[tri->nums[2]],tri->color);
|
||||
(*dc->lighting)(dc,&p[tri->nums[0]],&p[tri->nums[1]],
|
||||
&p[tri->nums[2]],tri->color);
|
||||
result+=GrFillTri0(dc,&p[tri->nums[0]],&p[tri->nums[1]],&p[tri->nums[2]]);
|
||||
}
|
||||
mesh_done:
|
||||
@@ -285,9 +296,9 @@ mesh_done:
|
||||
|
||||
#help_index "Graphics/Misc;Input Pointer/Displayed Image"
|
||||
public U0 DrawStdInputPtr(CDC *dc,I64 x,I64 y)
|
||||
{//This is a callback.
|
||||
{//This is a callback. See $LK,"::/Demo/Graphics/Grid.CPP.Z"$.
|
||||
//Called by $LK,"DrawInputPtr",A="MN:DrawInputPtr"$() which is
|
||||
//called by $LK,"WinFinalUpdate",A="MN:WinFinalUpdate"$().
|
||||
//called by $LK,"WinFinalUpdate",A="MN:WinFinalUpdate"$().
|
||||
dc->pen_width=1;
|
||||
dc->flags&=~(DCF_TRANSFORMATION|DCF_SYMMETRY);
|
||||
GrArrow3(dc,x+8,y+8,0,x,y,0);
|
||||
@@ -296,7 +307,7 @@ public U0 DrawStdInputPtr(CDC *dc,I64 x,I64 y)
|
||||
gr.fp_draw_input_ptr=&DrawStdInputPtr;
|
||||
|
||||
public U0 DrawWaitInputPtr(CDC *dc,I64 x,I64 y)
|
||||
{//This is a callback.
|
||||
{//This is a callback. See $LK,"::/Demo/Graphics/Grid.CPP.Z"$.
|
||||
I64 old_pen_width=dc->pen_width;
|
||||
CColorROPU32 old_color=dc->color;
|
||||
dc->pen_width=3;
|
||||
|
||||
+105
-83
@@ -3,7 +3,7 @@
|
||||
|
||||
#define GR_SCALE (1<<32)
|
||||
|
||||
public U0 GrRot(I64 r[4][4],I64 *_x,I64 *_y,I64 *_z)
|
||||
public U0 Mat4x4MulXYZ(I64 r[4][4],I64 *_x,I64 *_y,I64 *_z)
|
||||
{//Rotate 3D point using 4x4 matrix. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
I64 x1,y1,z1,xx=*_x,yy=*_y,zz=*_z;
|
||||
x1=(r[0][0]*xx+r[0][1]*yy+r[0][2]*zz+r[0][3])>>32;
|
||||
@@ -12,26 +12,16 @@ public U0 GrRot(I64 r[4][4],I64 *_x,I64 *_y,I64 *_z)
|
||||
*_x=x1;*_y=y1;*_z=z1;
|
||||
}
|
||||
|
||||
public U0 GrTransform(CDC *dc,I64 *_x,I64 *_y,I64 *_z)
|
||||
{//This is a callback.
|
||||
public U0 DCTransform(CDC *dc,I64 *_x,I64 *_y,I64 *_z)
|
||||
{//This is the dft dc->transform() callback.
|
||||
//Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
GrRot(dc->r,_x,_y,_z);
|
||||
Mat4x4MulXYZ(dc->r,_x,_y,_z);
|
||||
*_x+=dc->x;
|
||||
*_y+=dc->y;
|
||||
*_z+=dc->z;
|
||||
}
|
||||
|
||||
public I64 *GrIdentNew(CTask *mem_task=NULL)
|
||||
{//MAlloc an identity matrix. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
I64 *r=CAlloc(sizeof(I64)*16,mem_task);
|
||||
r[0] .i32[1]=1;
|
||||
r[5] .i32[1]=1;
|
||||
r[10].i32[1]=1;
|
||||
r[15].i32[1]=1;
|
||||
return r;
|
||||
}
|
||||
|
||||
public I64 *GrIdentEqu(I64 r[4][4])
|
||||
public I64 *Mat4x4IdentEqu(I64 r[4][4])
|
||||
{//Set matrix to identity. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
MemSet(r,0,sizeof(I64)*16);
|
||||
r[0][0].i32[1]=1;
|
||||
@@ -41,26 +31,32 @@ public I64 *GrIdentEqu(I64 r[4][4])
|
||||
return r;
|
||||
}
|
||||
|
||||
public I64 GrRotNormSqr65536(I64 r[4][4])
|
||||
public I64 *Mat4x4IdentNew(CTask *mem_task=NULL)
|
||||
{//MAlloc an identity matrix. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
return Mat4x4IdentEqu(MAlloc(sizeof(I64)*16,mem_task));
|
||||
}
|
||||
|
||||
public I64 Mat4x4NormSqr65536(I64 r[4][4])
|
||||
{//Norm Squared of r.
|
||||
//(1.0/Sqrt(3))*65536=37837.22
|
||||
return SqrI64((r[0][0]*37838+r[0][1]*37838+r[0][2]*37838)>>32)+
|
||||
SqrI64((r[1][0]*37837+r[1][1]*37837+r[1][2]*37837)>>32)+
|
||||
SqrI64((r[2][0]*37837+r[2][1]*37837+r[2][2]*37837)>>32);
|
||||
SqrI64((r[1][0]*37837+r[1][1]*37837+r[1][2]*37837)>>32)+
|
||||
SqrI64((r[2][0]*37837+r[2][1]*37837+r[2][2]*37837)>>32);
|
||||
}
|
||||
|
||||
public U0 GrSetRotMat(CDC *dc=NULL,I64 r[4][4])
|
||||
{//Set device context's rot matrix. Will be $LK,"Free",A="MN:Free"$d() in $LK,"DCDel",A="MN:DCDel"$(). Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
public U0 DCMat4x4Set(CDC *dc=NULL,I64 r[4][4])
|
||||
{//Set device context's rot matrix. Will be $LK,"Free",A="MN:Free"$d() in $LK,"DCDel",A="MN:DCDel"$().Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
//The main purpose is to set matrix norm for pen width scaling.
|
||||
//NULL as dc means gr.dc
|
||||
//NULL as dc means gr.dc
|
||||
if (!dc) dc=gr.dc;
|
||||
dc->r=r;
|
||||
dc->r_norm=Sqrt(GrRotNormSqr65536(r))*65536; //scaled 32 bits
|
||||
dc->r_norm=Sqrt(Mat4x4NormSqr65536(r))*65536; //scaled 32 bits
|
||||
}
|
||||
|
||||
#help_index "Graphics/Mesh"
|
||||
public U0 GrLighting(CDC *dc,CD3I32 *p1,CD3I32 *p2,CD3I32 *p3,CColorROPU32 color)
|
||||
{//This is a callback.
|
||||
public U0 DCLighting(CDC *dc,
|
||||
CD3I32 *p1,CD3I32 *p2,CD3I32 *p3,CColorROPU32 color)
|
||||
{//This is the dft dc->lighting() callback.
|
||||
CD3I32 v1,v2;
|
||||
I64 i,vn_x,vn_y,vn_z;
|
||||
F64 d;
|
||||
@@ -73,8 +69,8 @@ public U0 GrLighting(CDC *dc,CD3I32 *p1,CD3I32 *p2,CD3I32 *p3,CColorROPU32 color
|
||||
v2.y=p3->y-p2->y;
|
||||
v2.z=p3->z-p2->z;
|
||||
|
||||
//V1 and V2 are vects along two sides
|
||||
//of the tri joined at p2.
|
||||
//V1 and V2 are vects along two sides
|
||||
//of the tri joined at p2.
|
||||
|
||||
vn_x=v1.y*v2.z-v1.z*v2.y;
|
||||
vn_y=v1.z*v2.x-v1.x*v2.z;
|
||||
@@ -85,21 +81,21 @@ public U0 GrLighting(CDC *dc,CD3I32 *p1,CD3I32 *p2,CD3I32 *p3,CColorROPU32 color
|
||||
vn_y*=d;
|
||||
vn_z*=d;
|
||||
//Vn is the cross product of V1 and V3
|
||||
//which means it is perpendicular. It
|
||||
//is the normal vect to the surface.
|
||||
//It has been scaled to length 65536.
|
||||
//which means it is perpendicular. It
|
||||
//is the normal vect to the surface.
|
||||
//It has been scaled to length 65536.
|
||||
|
||||
//Light source has been scaled to length 65536.
|
||||
//Light source has been scaled to length 65536.
|
||||
i=(vn_x*dc->ls.x+vn_y*dc->ls.y+vn_z*dc->ls.z)>>16;
|
||||
//The dot product of the light source
|
||||
//vect and the surface normal
|
||||
//gives an illumination number.
|
||||
//65536*65536>>16=65536
|
||||
//vect and the surface normal
|
||||
//gives an illumination number.
|
||||
//65536*65536>>16=65536
|
||||
|
||||
//TempleOS will generate a random U16
|
||||
//and compare to dither_probability_u16 and
|
||||
//will pick from two colors.
|
||||
//Probability dithering does not work with pen_width>1 at this time.
|
||||
//TempleOS will generate a random U16
|
||||
//and compare to dither_probability_u16 and
|
||||
//will pick from two colors.
|
||||
//Probability dithering does not work with pen_width>1 at this time.
|
||||
if (color.c0.rop&ROPBF_TWO_SIDED) {
|
||||
color.c0.rop&=~ROPBF_TWO_SIDED;
|
||||
i=AbsI64(i)<<1;
|
||||
@@ -148,18 +144,19 @@ public U0 DCRst(CDC *dc)
|
||||
dc->x=0;
|
||||
dc->y=0;
|
||||
dc->z=0;
|
||||
dc->transform=&GrTransform;
|
||||
dc->lighting =&GrLighting;
|
||||
GrIdentEqu(dc->r);
|
||||
dc->transform=&DCTransform;
|
||||
dc->lighting =&DCLighting;
|
||||
Mat4x4IdentEqu(dc->r);
|
||||
dc->r_norm=GR_SCALE;
|
||||
dc->flags&=~(DCF_SYMMETRY|DCF_TRANSFORMATION|DCF_JUST_MIRROR);
|
||||
MemCpy(dc->palette,gr_palette_std,sizeof(CBGR48)*NUM_COLORS);
|
||||
}
|
||||
|
||||
public U0 DCExtentsInit(CDC *dc=NULL)
|
||||
{//Init markers for extent of next newly drawn graphics.
|
||||
//NULL means gr.dc
|
||||
//See $LK,"::/Demo/Graphics/Extents.CPP"$
|
||||
//You should clear the record flag yourself
|
||||
//See $LK,"::/Demo/Graphics/Extents.CPP"$
|
||||
//You should clear the record flag yourself
|
||||
if (!dc) dc=gr.dc;
|
||||
dc->flags|=DCF_RECORD_EXTENTS;
|
||||
dc->min_x=MAX_I64;
|
||||
@@ -189,7 +186,7 @@ public CDC *DCAlias(CDC *dc=NULL,CTask *task=NULL)
|
||||
public CDC *DCNew(I64 width,I64 height,CTask *task=NULL,Bool null_bitmap=FALSE)
|
||||
{//Create new width x height device context.
|
||||
//Internally only allows widths which are divisible by 8.
|
||||
//Don't forget these $MA-X+PU,"sizeof(CDC)",LM="Find(\"sizeof(CDC)\",\"/*\");View;"$.
|
||||
//Don't forget these $MA-X+PU,"sizeof(CDC)",LM="Find(\"sizeof(CDC)\",\"/*\");View;"$.
|
||||
CDC *result;
|
||||
if (!task) task=Fs;
|
||||
result=CAlloc(sizeof(CDC),task);
|
||||
@@ -235,7 +232,7 @@ public U0 DCDepthBufRst(CDC *dc)
|
||||
MemSetU32(dc->depth_buf,MAX_I32,dc->width_internal*dc->height);
|
||||
}
|
||||
|
||||
public U0 DCAllocDepthBuf(CDC *dc)
|
||||
public U0 DCDepthBufAlloc(CDC *dc)
|
||||
{//Alloc a 32-bit depth buffer for device context.
|
||||
Free(dc->depth_buf);
|
||||
dc->depth_buf=MAlloc(dc->width_internal*dc->height*sizeof(I32),dc->mem_task);
|
||||
@@ -249,7 +246,7 @@ public CDC *DCCopy(CDC *dc,CTask *task=NULL)
|
||||
if (dc->dc_signature!=DCS_SIGNATURE_VAL)
|
||||
throw('Graphics');
|
||||
result=MAllocIdentical(dc,task);
|
||||
GrSetRotMat(result,MAllocIdentical(dc->r,task));
|
||||
DCMat4x4Set(result,Mat4x4New(dc->r,task));
|
||||
result->mem_task=task;
|
||||
result->body=MAllocIdentical(dc->body,task);
|
||||
result->depth_buf=MAllocIdentical(dc->depth_buf,task);
|
||||
@@ -285,37 +282,55 @@ public I64 DCColorChg(CDC *dc,I64 src_color,I64 dst_color=TRANSPARENT)
|
||||
return result;
|
||||
}
|
||||
|
||||
public U8 *DCSave(CDC *dc,I64 *_size=NULL,Bool compressed=TRUE)
|
||||
public U8 *DCSave(CDC *dc,I64 *_size=NULL,I64 dcsf_flags=DCSF_COMPRESSED)
|
||||
{//Stores device context to mem, perhaps, with compression.
|
||||
U8 *result,*ptr,*body;
|
||||
Bool old_preempt;
|
||||
CArcCompress *ac;
|
||||
I64 i=dc->width_internal*dc->height,old_flags=dc->flags;
|
||||
CArcCompress *arc;
|
||||
I64 body_size=dc->width_internal*dc->height,total_size,flags;
|
||||
CBGR48 palette[NUM_COLORS];
|
||||
|
||||
if (compressed) {
|
||||
ac=CompressBuf(dc->body,i);
|
||||
i=ac->compressed_size;
|
||||
body=ac;
|
||||
if (dcsf_flags&DCSF_COMPRESSED) {
|
||||
arc=CompressBuf(dc->body,body_size);
|
||||
body_size=arc->compressed_size;
|
||||
body=arc;
|
||||
} else {
|
||||
ac=NULL;
|
||||
arc=NULL;
|
||||
body=dc->body;
|
||||
}
|
||||
|
||||
ptr=result=MAlloc(offset(CDC.end)-offset(CDC.start)+i);
|
||||
total_size=offset(CDC.end)-offset(CDC.start)+body_size;
|
||||
if (dcsf_flags&DCSF_COMPRESSED)
|
||||
flags=DCF_COMPRESSED;
|
||||
else
|
||||
flags=0;
|
||||
|
||||
old_preempt=Preempt(OFF); //in case it is a screen bitmap
|
||||
if (compressed) dc->flags|=DCF_COMPRESSED;
|
||||
dc->flags&=DCF_COMPRESSED;
|
||||
MemCpy(result,&dc->start,offset(CDC.end)-offset(CDC.start));
|
||||
dc->flags=old_flags;
|
||||
Preempt(old_preempt);
|
||||
if (dcsf_flags&DCSF_PALETTE_GET)
|
||||
GrPaletteGet(palette);
|
||||
else
|
||||
MemCpy(palette,&dc->palette,NUM_COLORS*sizeof(CBGR48));
|
||||
if (MemCmp(palette,gr_palette_std,NUM_COLORS*sizeof(CBGR48))) {
|
||||
flags|=DCF_PALETTE;
|
||||
total_size+=NUM_COLORS*sizeof(CBGR48);
|
||||
}
|
||||
|
||||
ptr=result=MAlloc(total_size);
|
||||
|
||||
#assert !offset(CDC.start)
|
||||
MemCpy(ptr,&dc->start,offset(CDC.end)-offset(CDC.start));
|
||||
ptr(CDC *)->flags=flags;
|
||||
ptr+=offset(CDC.end)-offset(CDC.start);
|
||||
MemCpy(ptr,body,i);
|
||||
ptr+=i;
|
||||
|
||||
Free(ac);
|
||||
if (_size) *_size=ptr-result;
|
||||
#assert offset(CDC.end)==offset(CDC.palette)
|
||||
if (flags&DCF_PALETTE) {
|
||||
MemCpy(ptr,palette,NUM_COLORS*sizeof(CBGR48));
|
||||
ptr+=NUM_COLORS*sizeof(CBGR48);
|
||||
}
|
||||
|
||||
MemCpy(ptr,body,body_size);
|
||||
ptr+=body_size;
|
||||
|
||||
Free(arc);
|
||||
if (_size) *_size=total_size;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -323,28 +338,34 @@ public CDC *DCLoad(U8 *src,I64 *_size=NULL,CTask *task=NULL)
|
||||
{//Loads device context from mem.
|
||||
CDC *result;
|
||||
U8 *ptr=src;
|
||||
CArcCompress *ac;
|
||||
CArcCompress *arc;
|
||||
I64 body_size;
|
||||
if (!task) task=Fs;
|
||||
result=CAlloc(sizeof(CDC),task);
|
||||
result->win_task=task;
|
||||
result->mem_task=task;
|
||||
MemCpy(&result->start,src,
|
||||
offset(CDC.end)-offset(CDC.start));
|
||||
MemCpy(&result->start,ptr,offset(CDC.end)-offset(CDC.start));
|
||||
ptr+=offset(CDC.end)-offset(CDC.start);
|
||||
|
||||
if (result->flags&DCF_PALETTE) {
|
||||
MemCpy(&result->palette,ptr,NUM_COLORS*sizeof(CBGR48));
|
||||
ptr+=NUM_COLORS*sizeof(CBGR48);
|
||||
} else
|
||||
MemCpy(&result->palette,gr_palette_std,NUM_COLORS*sizeof(CBGR48));
|
||||
|
||||
body_size=result->width_internal*result->height;
|
||||
if (result->flags&DCF_COMPRESSED) {
|
||||
result->flags&=~DCF_COMPRESSED;
|
||||
ac=ptr;
|
||||
result->body=ExpandBuf(ac,task);
|
||||
ptr+=ac->compressed_size;
|
||||
arc=ptr;
|
||||
result->body=ExpandBuf(arc,task);
|
||||
ptr+=arc->compressed_size;
|
||||
} else {
|
||||
result->body=MAlloc(body_size,task);
|
||||
MemCpy(result->body,ptr,body_size);
|
||||
ptr+=body_size;
|
||||
}
|
||||
result->pen_width=1;
|
||||
result->r=GrIdentNew(task);
|
||||
result->r=Mat4x4IdentNew(task);
|
||||
result->r_norm.u32[1]=1;
|
||||
result->dc_signature=DCS_SIGNATURE_VAL;
|
||||
if (_size) *_size=ptr-src;
|
||||
@@ -354,11 +375,11 @@ public CDC *DCLoad(U8 *src,I64 *_size=NULL,CTask *task=NULL)
|
||||
#help_index "Graphics/GRA Files"
|
||||
#help_file "::/Doc/GRAFiles"
|
||||
#help_index "Graphics/Device Contexts;Graphics/GRA Files"
|
||||
public I64 GRAWrite(U8 *filename,CDC *dc)
|
||||
public I64 GRAWrite(U8 *filename,CDC *dc,I64 dcsf_flags=DCSF_COMPRESSED)
|
||||
{//TempleOS GRA File.
|
||||
I64 size;
|
||||
U8 *st=DftExt(filename,"GRA.Z"),
|
||||
*src=DCSave(dc,&size);
|
||||
*src=DCSave(dc,&size,dcsf_flags);
|
||||
FileWrite(st,src,size);
|
||||
Free(st);
|
||||
Free(src);
|
||||
@@ -369,7 +390,7 @@ public CDC *GRARead(U8 *filename,CTask *task=NULL)
|
||||
{//TempleOS GRA File.
|
||||
CDC *dc=NULL;
|
||||
U8 *st=DftExt(filename,"GRA.Z"),
|
||||
*src=FileRead(st);
|
||||
*src=FileRead(st);
|
||||
if (src)
|
||||
dc=DCLoad(src,,task);
|
||||
Free(src);
|
||||
@@ -377,9 +398,9 @@ public CDC *GRARead(U8 *filename,CTask *task=NULL)
|
||||
return dc;
|
||||
}
|
||||
|
||||
#help_index "Graphics/Sprite;Graphics/GRA Files;DolDoc/Output"
|
||||
#help_index "Graphics/Sprite;Graphics/GRA Files;DolDoc/Output;StdOut/DolDoc"
|
||||
public U0 DocGRA(CDoc *doc=NULL,U8 *filename)
|
||||
{//Put a GRA file into a document as a sprite.
|
||||
{//Put a GRA file into a document as asprite.
|
||||
CDC *dc=GRARead(filename);
|
||||
CSprite *elems=DC2Sprite(dc);
|
||||
DocSprite(doc,elems);
|
||||
@@ -388,7 +409,7 @@ public U0 DocGRA(CDoc *doc=NULL,U8 *filename)
|
||||
}
|
||||
|
||||
#help_index "Graphics/Device Contexts;Graphics/Screen"
|
||||
public CDC *DCCaptureScreen(Bool include_zoom=TRUE,CTask *task=NULL)
|
||||
public CDC *DCScreenCapture(Bool include_zoom=TRUE,CTask *task=NULL)
|
||||
{//Capture screen to a device context.
|
||||
CDC *dc;
|
||||
U8 *dst;
|
||||
@@ -399,19 +420,20 @@ public CDC *DCCaptureScreen(Bool include_zoom=TRUE,CTask *task=NULL)
|
||||
dc=DCCopy(gr.dc1,task);
|
||||
dc->flags&=~DCF_SCREEN_BITMAP;
|
||||
dst=MAlloc(dc->width_internal*dc->height,task);
|
||||
//Pick background color that never occurs. COLOR_INVALID
|
||||
GrBitMap4ToBitMap8(dst,dc->body,(dc->width_internal*dc->height)>>1,COLOR_INVALID);
|
||||
//Pick background color that never occurs. COLOR_INVALID
|
||||
GrBitMap4ToBitMap8(dst,dc->body,
|
||||
(dc->width_internal*dc->height)>>1,COLOR_INVALID);
|
||||
Free(dc->body);
|
||||
dc->body=dst;
|
||||
return dc;
|
||||
}
|
||||
|
||||
#help_index "Graphics/GRA Files;Graphics/Screen"
|
||||
public I64 GRACaptureScreen(U8 *filename,Bool include_zoom=TRUE)
|
||||
public I64 GRAScreenCapture(U8 *filename,Bool include_zoom=TRUE)
|
||||
{//Capture screen to a TempleOS GRA File.
|
||||
I64 size;
|
||||
CDC *dc=DCCaptureScreen(include_zoom);
|
||||
size=GRAWrite(filename,dc);
|
||||
CDC *dc=DCScreenCapture(include_zoom);
|
||||
size=GRAWrite(filename,dc,DCSF_COMPRESSED|DCSF_PALETTE_GET);
|
||||
DCDel(dc);
|
||||
return size;
|
||||
}
|
||||
+1
-1
@@ -11,7 +11,7 @@ CtrlAltLetCBSet('Z',&CtrlAltZ,"Sys/Zoom In or Out");
|
||||
|
||||
U0 Screen2Clipboard(I64)
|
||||
{
|
||||
CDC *dc=DCCaptureScreen;
|
||||
CDC *dc=DCScreenCapture;
|
||||
U8 *elems=DC2Sprite(dc);
|
||||
Bool unlock_doc=DocLock(sys_clipboard_doc);
|
||||
ClipboardDel;
|
||||
|
||||
+3
-3
@@ -12,7 +12,7 @@ public class CGrGlbls
|
||||
U32 *text_base; //See $LK,"TextBase Layer",A="HI:TextBase Layer"$. (Similar to 0xB8000 but 32 bits)
|
||||
U16 *win_z_buf;
|
||||
|
||||
#define SPHT_ELEM_CODE 1
|
||||
#define SPHT_ELEM_CODE 1
|
||||
CHashTable *sprite_hash;
|
||||
|
||||
U16 *win_uncovered_bitmap;
|
||||
@@ -25,13 +25,13 @@ public class CGrGlbls
|
||||
U0 (*fp_draw_grab_input_ptr)(CDC *dc,I64 x,I64 y,Bool closed);
|
||||
U8 *empty_sprite; //Gets assigned $LK,"gr.empty_sprite",A="FF:::/Adam/WallPaper.CPP,empty_sprite"$
|
||||
|
||||
#define GR_NUM_PEN_BRUSHES 64
|
||||
#define GR_NUM_PEN_BRUSHES 64
|
||||
CDC *pen_brushes[GR_NUM_PEN_BRUSHES],
|
||||
*collision_pen_brushes[GR_NUM_PEN_BRUSHES],
|
||||
*even_pen_brushes[GR_NUM_PEN_BRUSHES],
|
||||
*odd_pen_brushes[GR_NUM_PEN_BRUSHES];
|
||||
|
||||
#define GR_MAX_SCREEN_ZOOM 8
|
||||
#define GR_MAX_SCREEN_ZOOM 8
|
||||
U8 *screen_zoom_tables[GR_MAX_SCREEN_ZOOM+1];
|
||||
I64 screen_zoom,sx,sy;
|
||||
|
||||
|
||||
+8
-8
@@ -62,7 +62,7 @@ U0 GrSetUpTables()
|
||||
OutU8(VGAP_INDEX,VGAR_MAP_MASK);
|
||||
OutU8(VGAP_DATA,0x0F);
|
||||
//Virtual Box crashes on the following for some reason.
|
||||
// MemSet(VGAM_GRAPHICS,0,GR_HEIGHT*GR_WIDTH>>3);
|
||||
// MemSet(VGAM_GRAPHICS,0,GR_HEIGHT*GR_WIDTH>>3);
|
||||
MemSet(gr.screen_image->body,0,GR_WIDTH*GR_HEIGHT>>1);
|
||||
}
|
||||
for (i=1;i<=GR_MAX_SCREEN_ZOOM;i++) {
|
||||
@@ -128,17 +128,17 @@ U0 WinZBufFill(CTask *task)
|
||||
if (w=r-l+1)
|
||||
for (y=t;y<=b;y++)
|
||||
MemSetU16(gr.win_z_buf(U8 *)+(y*TEXT_COLS+l)*sizeof(U16),
|
||||
task->win_z_num,w);
|
||||
task->win_z_num,w);
|
||||
}
|
||||
|
||||
public U0 WinZBufUpdate()
|
||||
{//Might have to call this if you are doing graphics outside winmgr callback routines.
|
||||
{//Might have to call if doing graphics outside winmgr callback routines.
|
||||
//Call it if, for example, when a pop-up window closes and you need to refresh
|
||||
//before graphics.
|
||||
//before graphics.
|
||||
I64 i,z=1;
|
||||
U16 *ptr;
|
||||
CTask *task,*task1;
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
Bool old_preempt=Preempt;
|
||||
if (gr.win_z_buf) {
|
||||
LBtr(&sys_semas[SYS_SEMA_UPDATE_WIN_Z_BUF],0);
|
||||
task1=task=sys_winmgr_task;
|
||||
@@ -167,9 +167,9 @@ U0 GrInit2()
|
||||
HashDefineLstAdd("ST_SPRITE_ELEM_CODES",SPHT_ELEM_CODE,gr.sprite_hash);
|
||||
gr.screen_zoom=1;
|
||||
|
||||
SetStdPalette;
|
||||
fp_set_std_palette=&SetStdPalette;
|
||||
SetVGAPalette4Indices;
|
||||
PaletteSetStd;
|
||||
fp_set_std_palette=&PaletteSetStd;
|
||||
GrPaletteIndicesSet;
|
||||
|
||||
gr.to_8_bits =MAlloc(256*sizeof(I64));
|
||||
gr.to_8_colors=MAlloc(256*sizeof(I64));
|
||||
|
||||
+94
-138
@@ -13,7 +13,7 @@ public Bool Line(U8 *aux_data,
|
||||
{//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,
|
||||
adx=AbsI64(dx),ady=AbsI64(dy),adz=AbsI64(dz);
|
||||
adx=AbsI64(dx),ady=AbsI64(dy),adz=AbsI64(dz);
|
||||
Bool first=TRUE;
|
||||
if (adx>=ady) {
|
||||
if (adx>=adz) {
|
||||
@@ -58,7 +58,7 @@ public Bool Line(U8 *aux_data,
|
||||
}
|
||||
x1<<=32; y1<<=32; z1<<=32;
|
||||
for (j=0;j<start;j++) {
|
||||
x1+=dx; y1+=dy; z1+=dz;
|
||||
x1+=dx; y1+=dy; z1+=dz;
|
||||
}
|
||||
if (step!=1 && step!=0) {
|
||||
dx*=step;
|
||||
@@ -68,7 +68,7 @@ public Bool Line(U8 *aux_data,
|
||||
}
|
||||
for (i=start;i<=d;i++) {
|
||||
if ((_x!=x1.i32[1] || _y!=y1.i32[1] || _z!=z1.i32[1] || first) &&
|
||||
!(*fp_plot)(aux_data,x1.i32[1],y1.i32[1],z1.i32[1]))
|
||||
!(*fp_plot)(aux_data,x1.i32[1],y1.i32[1],z1.i32[1]))
|
||||
return FALSE;
|
||||
first=FALSE;
|
||||
_x=x1.i32[1]; _y=y1.i32[1]; _z=z1.i32[1];
|
||||
@@ -80,82 +80,44 @@ public Bool Line(U8 *aux_data,
|
||||
}
|
||||
|
||||
#help_index "Graphics/Math/3D Transformation"
|
||||
public I64 *GrRotXNew(F64 è,CTask *mem_task=NULL)
|
||||
{//MAlloc 4x4 matrix to rot about X axis. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
F64 my_cos=Cos(è)*GR_SCALE,
|
||||
my_sin=Sin(è)*GR_SCALE;
|
||||
I64 *r=CAlloc(sizeof(I64)*16,mem_task);
|
||||
|
||||
r[5]=my_cos;
|
||||
r[10]=my_cos;
|
||||
r[9]=my_sin;
|
||||
r[6]=-my_sin;
|
||||
r[0]=GR_SCALE;
|
||||
r[15]=GR_SCALE;
|
||||
return r;
|
||||
}
|
||||
|
||||
public I64 *GrRotYNew(F64 ê,CTask *mem_task=NULL)
|
||||
{//MAlloc 4x4 matrix to rot about Y axis. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
F64 my_cos=Cos(ê)*GR_SCALE,
|
||||
my_sin=Sin(ê)*GR_SCALE;
|
||||
I64 *r=CAlloc(sizeof(I64)*16,mem_task);
|
||||
|
||||
r[0]=my_cos;
|
||||
r[10]=my_cos;
|
||||
r[8]=-my_sin;
|
||||
r[2]=my_sin;
|
||||
r[5]=GR_SCALE;
|
||||
r[15]=GR_SCALE;
|
||||
return r;
|
||||
}
|
||||
|
||||
public I64 *GrRotZNew(F64 é,CTask *mem_task=NULL)
|
||||
{//MAlloc 4x4 matrix to rot about Z axis. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
F64 my_cos=Cos(é)*GR_SCALE,
|
||||
my_sin=Sin(é)*GR_SCALE;
|
||||
I64 *r=CAlloc(sizeof(I64)*16,mem_task);
|
||||
|
||||
r[0]=my_cos;
|
||||
r[5]=my_cos;
|
||||
r[4]=my_sin;
|
||||
r[1]=-my_sin;
|
||||
r[10]=GR_SCALE;
|
||||
r[15]=GR_SCALE;
|
||||
return r;
|
||||
}
|
||||
|
||||
public I64 *GrScaleNew(I64 *m1,F64 s,CTask *mem_task=NULL)
|
||||
{//MAlloc matrix that is scaled version of a 4x4 matrix. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
I64 i,*r=CAlloc(sizeof(I64)*16,mem_task);
|
||||
for (i=0;i<16;i++)
|
||||
r[i]=m1[i]*s;
|
||||
return r;
|
||||
}
|
||||
|
||||
public I64 *GrMulMat(I64 *m1,I64 *m2,CTask *mem_task=NULL)
|
||||
{//Multiply 4x4 matrices, return MAlloced matrix. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
public I64 *Mat4x4MulMat4x4Equ(I64 *dst,I64 *m1,I64 *m2)
|
||||
{//Multiply 4x4 matrices and store in dst. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
//Conceptually, the transform m1 is applied after m2
|
||||
I64 i,j,k,*r=CAlloc(sizeof(I64)*16,mem_task);
|
||||
F64 d;
|
||||
I64 i,j,k;
|
||||
F64 sum;
|
||||
for (i=0;i<4;i++) {
|
||||
for (j=0;j<4;j++) {
|
||||
for (k=0;k<4;k++) {
|
||||
d=m1[k+4*j];
|
||||
d*=m2[i+4*k]; //TODO! Possible overflow if norm > one.
|
||||
d/=GR_SCALE;
|
||||
r[i+4*j]+=d;
|
||||
}
|
||||
sum=0;
|
||||
for (k=0;k<4;k++)
|
||||
sum+=ToF64(m1[k+4*j])*ToF64(m2[i+4*k]);
|
||||
dst[i+4*j]=sum/GR_SCALE;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
return dst;
|
||||
}
|
||||
|
||||
public I64 *GrRotXEqu(I64 *m1,F64 è)
|
||||
public I64 *Mat4x4MulMat4x4New(I64 *m1,I64 *m2,CTask *mem_task=NULL)
|
||||
{//Multiply 4x4 matrices. Return MAlloced matrix. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
//Conceptually, the transform m1 is applied after m2
|
||||
return Mat4x4MulMat4x4Equ(MAlloc(sizeof(I64)*16,mem_task),m1,m2);
|
||||
}
|
||||
|
||||
public I64 *Mat4x4Equ(I64 *dst,I64 *src)
|
||||
{//Copy 4x4 Rot matrix.
|
||||
MemCpy(dst,src,sizeof(I64)*16);
|
||||
return dst;
|
||||
}
|
||||
|
||||
public I64 *Mat4x4New(I64 *src,CTask *mem_task=NULL)
|
||||
{//Return MAlloced copy of 4x4 Rot matrix.
|
||||
return Mat4x4Equ(MAlloc(sizeof(I64)*16,mem_task),src);
|
||||
}
|
||||
|
||||
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;
|
||||
I64 r[16],*r2;
|
||||
my_sin=Sin(è)*GR_SCALE;
|
||||
I64 r[16],r2[16];
|
||||
MemSet(r,0,sizeof(r));
|
||||
r[5]=my_cos;
|
||||
r[10]=my_cos;
|
||||
@@ -163,18 +125,14 @@ public I64 *GrRotXEqu(I64 *m1,F64
|
||||
r[6]=-my_sin;
|
||||
r[0]=GR_SCALE;
|
||||
r[15]=GR_SCALE;
|
||||
|
||||
r2=GrMulMat(r,m1);
|
||||
MemCpy(m1,r2,sizeof(I64)*16);
|
||||
Free(r2);
|
||||
return m1;
|
||||
return Mat4x4Equ(m1,Mat4x4MulMat4x4Equ(r2,r,m1));
|
||||
}
|
||||
|
||||
public I64 *GrRotYEqu(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;
|
||||
I64 r[16],*r2;
|
||||
my_sin=Sin(ê)*GR_SCALE;
|
||||
I64 r[16],r2[16];
|
||||
MemSet(r,0,sizeof(r));
|
||||
r[0]=my_cos;
|
||||
r[10]=my_cos;
|
||||
@@ -182,18 +140,14 @@ public I64 *GrRotYEqu(I64 *m1,F64
|
||||
r[2]=my_sin;
|
||||
r[5]=GR_SCALE;
|
||||
r[15]=GR_SCALE;
|
||||
|
||||
r2=GrMulMat(r,m1);
|
||||
MemCpy(m1,r2,sizeof(I64)*16);
|
||||
Free(r2);
|
||||
return m1;
|
||||
return Mat4x4Equ(m1,Mat4x4MulMat4x4Equ(r2,r,m1));
|
||||
}
|
||||
|
||||
public I64 *GrRotZEqu(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;
|
||||
I64 r[16],*r2;
|
||||
my_sin=Sin(é)*GR_SCALE;
|
||||
I64 r[16],r2[16];
|
||||
MemSet(r,0,sizeof(r));
|
||||
r[0]=my_cos;
|
||||
r[5]=my_cos;
|
||||
@@ -201,14 +155,10 @@ public I64 *GrRotZEqu(I64 *m1,F64
|
||||
r[1]=-my_sin;
|
||||
r[10]=GR_SCALE;
|
||||
r[15]=GR_SCALE;
|
||||
|
||||
r2=GrMulMat(r,m1);
|
||||
MemCpy(m1,r2,sizeof(I64)*16);
|
||||
Free(r2);
|
||||
return m1;
|
||||
return Mat4x4Equ(m1,Mat4x4MulMat4x4Equ(r2,r,m1));
|
||||
}
|
||||
|
||||
public I64 *GrScaleEqu(I64 *m1,F64 s)
|
||||
public I64 *Mat4x4Scale(I64 *m1,F64 s)
|
||||
{//Scale 4x4 matrix by value.
|
||||
I64 i;
|
||||
for (i=0;i<16;i++)
|
||||
@@ -216,7 +166,7 @@ public I64 *GrScaleEqu(I64 *m1,F64 s)
|
||||
return m1;
|
||||
}
|
||||
|
||||
public U0 GrScalePenWidth(CDC *dc=gr.dc)
|
||||
public U0 DCPenWidthScale(CDC *dc=gr.dc)
|
||||
{//Scale device context's pen width by norm of transformation.
|
||||
I64 d;
|
||||
if (dc->flags&DCF_TRANSFORMATION) {
|
||||
@@ -229,7 +179,7 @@ public U0 GrScalePenWidth(CDC *dc=gr.dc)
|
||||
}
|
||||
}
|
||||
|
||||
public I64 *GrSetTranslation(I64 r[4][4],I64 x,I64 y,I64 z)
|
||||
public I64 *Mat4x4TranslationEqu(I64 r[4][4],I64 x,I64 y,I64 z)
|
||||
{//Set translation values in 4x4 matrix. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
r[0][3]=x<<32;
|
||||
r[1][3]=y<<32;
|
||||
@@ -238,7 +188,7 @@ public I64 *GrSetTranslation(I64 r[4][4],I64 x,I64 y,I64 z)
|
||||
return r;
|
||||
}
|
||||
|
||||
public I64 *GrAddTranslation(I64 r[4][4],I64 x,I64 y,I64 z)
|
||||
public I64 *Mat4x4TranslationAdd(I64 r[4][4],I64 x,I64 y,I64 z)
|
||||
{//Add translation to 4x4 matrix. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
r[0][3]+=x<<32;
|
||||
r[1][3]+=y<<32;
|
||||
@@ -247,7 +197,7 @@ public I64 *GrAddTranslation(I64 r[4][4],I64 x,I64 y,I64 z)
|
||||
return r;
|
||||
}
|
||||
|
||||
public Bool GrSetSymmetry(CDC *dc=gr.dc,I64 x1,I64 y1,I64 x2,I64 y2)
|
||||
public Bool DCSymmetrySet(CDC *dc=gr.dc,I64 x1,I64 y1,I64 x2,I64 y2)
|
||||
{//2D. Set device context's symmetry.
|
||||
F64 d;
|
||||
if (y1==y2 && x1==x2)
|
||||
@@ -256,8 +206,8 @@ public Bool GrSetSymmetry(CDC *dc=gr.dc,I64 x1,I64 y1,I64 x2,I64 y2)
|
||||
dc->sym.sny=x1-x2;
|
||||
dc->sym.snz=0;
|
||||
if (d=Sqrt(SqrI64(dc->sym.snx)+
|
||||
SqrI64(dc->sym.sny)+
|
||||
SqrI64(dc->sym.snz))) {
|
||||
SqrI64(dc->sym.sny)+
|
||||
SqrI64(dc->sym.snz))) {
|
||||
d=GR_SCALE/d;
|
||||
dc->sym.snx *= d;
|
||||
dc->sym.sny *= d;
|
||||
@@ -269,15 +219,16 @@ public Bool GrSetSymmetry(CDC *dc=gr.dc,I64 x1,I64 y1,I64 x2,I64 y2)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public Bool GrSetSymmetry3(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,I64 x2,I64 y2,I64 z2,I64 x3,I64 y3,I64 z3)
|
||||
public Bool DCSymmetry3Set(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,
|
||||
I64 x2,I64 y2,I64 z2,I64 x3,I64 y3,I64 z3)
|
||||
{//3D. Set device context's symmetry.
|
||||
F64 d,x,y,z,xx,yy,zz;
|
||||
I64 xx1,yy1,zz1,xx2,yy2,zz2,*r;
|
||||
xx1=x1-x2; yy1=y1-y2; zz1=z1-z2;
|
||||
xx2=x3-x2; yy2=y3-y2; zz2=z3-z2;
|
||||
if (!xx1 && !yy1 && !zz1 ||
|
||||
!xx2 && !yy2 && !zz2 ||
|
||||
xx1==xx2 && yy1==yy2 && zz1==zz2)
|
||||
!xx2 && !yy2 && !zz2 ||
|
||||
xx1==xx2 && yy1==yy2 && zz1==zz2)
|
||||
return FALSE;
|
||||
|
||||
x=yy1*zz2-zz1*yy2;
|
||||
@@ -304,12 +255,12 @@ public Bool GrSetSymmetry3(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,I64 x2,I64 y2,I64
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public U0 GrReflect(CDC *dc,I64 *_x,I64 *_y,I64 *_z)
|
||||
public U0 DCReflect(CDC *dc,I64 *_x,I64 *_y,I64 *_z)
|
||||
{//Reflect 3D point about device context's symmetry. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
I64 x=*_x<<32,y=*_y<<32,z=*_z<<32,
|
||||
xx=*_x-dc->sym.sx,yy=*_y-dc->sym.sy,zz=*_z-dc->sym.sz,
|
||||
d=(xx*dc->sym.snx+yy*dc->sym.sny+zz*dc->sym.snz)>>16,
|
||||
xn,yn,zn,xx2,yy2,zz2;
|
||||
xx=*_x-dc->sym.sx,yy=*_y-dc->sym.sy,zz=*_z-dc->sym.sz,
|
||||
d=(xx*dc->sym.snx+yy*dc->sym.sny+zz*dc->sym.snz)>>16,
|
||||
xn,yn,zn,xx2,yy2,zz2;
|
||||
xn=d*dc->sym.snx>>15;
|
||||
yn=d*dc->sym.sny>>15;
|
||||
zn=d*dc->sym.snz>>15;
|
||||
@@ -320,11 +271,11 @@ public U0 GrReflect(CDC *dc,I64 *_x,I64 *_y,I64 *_z)
|
||||
yy2=y+yn;
|
||||
zz2=z+zn;
|
||||
if (SqrI64(xx>>16 -dc->sym.sx<<16)+
|
||||
SqrI64(yy>>16 -dc->sym.sy<<16)+
|
||||
SqrI64(zz>>16 -dc->sym.sz<<16)<
|
||||
SqrI64(xx2>>16-dc->sym.sx<<16)+
|
||||
SqrI64(yy2>>16-dc->sym.sy<<16)+
|
||||
SqrI64(zz2>>16-dc->sym.sz<<16)) {
|
||||
SqrI64(yy>>16 -dc->sym.sy<<16)+
|
||||
SqrI64(zz>>16 -dc->sym.sz<<16)<
|
||||
SqrI64(xx2>>16-dc->sym.sx<<16)+
|
||||
SqrI64(yy2>>16-dc->sym.sy<<16)+
|
||||
SqrI64(zz2>>16-dc->sym.sz<<16)) {
|
||||
*_x=xx.i32[1]; *_y=yy.i32[1]; *_z=zz.i32[1];
|
||||
} else {
|
||||
*_x=xx2.i32[1]; *_y=yy2.i32[1]; *_z=zz2.i32[1];
|
||||
@@ -343,7 +294,7 @@ public Bool Circle(U8 *aux_data,
|
||||
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;
|
||||
x,y,x1,y1,s1,s2,c;
|
||||
F64 t;
|
||||
if (radius<=0||!step) return TRUE;
|
||||
t=1.0/radius;
|
||||
@@ -387,7 +338,7 @@ public Bool Ellipse(U8 *aux_data,
|
||||
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;
|
||||
x,y,_x,_y,x1,y1,x2,y2, s1,s2,c, s12,s22,c2;
|
||||
F64 t;
|
||||
Bool first=TRUE;
|
||||
if (x_radius<=0 || y_radius<=0 || !step)
|
||||
@@ -432,7 +383,7 @@ public Bool Ellipse(U8 *aux_data,
|
||||
|
||||
for (i=0;i<=len;i+=step) {
|
||||
if ((x>>SCALE2!=_x || y>>SCALE2!=_y || first) &&
|
||||
!(*fp_plot)(aux_data,cx+x>>SCALE2,cy+y>>SCALE2,cz))
|
||||
!(*fp_plot)(aux_data,cx+x>>SCALE2,cy+y>>SCALE2,cz))
|
||||
return FALSE;
|
||||
|
||||
_x=x>>SCALE2; _y=y>>SCALE2; first=FALSE;
|
||||
@@ -459,8 +410,8 @@ public Bool RegPoly(U8 *aux_data,
|
||||
F64 len_radians=2*ã)
|
||||
{//Step through regular polygon calling callback.
|
||||
I64 i,n,x,y,x1,y1,x2,y2,
|
||||
xx1,yy1,xx2,yy2,
|
||||
s1,s2,c, s12,s22,c2;
|
||||
xx1,yy1,xx2,yy2,
|
||||
s1,s2,c, s12,s22,c2;
|
||||
F64 angle_step;
|
||||
|
||||
if (sides<=0 || x_radius<=0 || y_radius<=0)
|
||||
@@ -512,7 +463,7 @@ public Bool RegPoly(U8 *aux_data,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#help_index "Graphics/Data Types;Math/Data Types"
|
||||
#help_index "Graphics/Data Types/D3I32;Math/Data Types/D3I32;Data Types/D3I32"
|
||||
public F64 D3I32Dist(CD3I32 *p1,CD3I32 *p2)
|
||||
{//Dist between p1 and p2.
|
||||
return Sqrt(SqrI64(p1->x-p2->x)+SqrI64(p1->y-p2->y)+SqrI64(p1->z-p2->z));
|
||||
@@ -534,16 +485,17 @@ public I64 D3I32NormSqr(CD3I32 *p)
|
||||
}
|
||||
|
||||
#help_index "Graphics/Math"
|
||||
public Bool Bezier2(U8 *aux_data,CD3I32 *ctrl,Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),Bool first=TRUE)
|
||||
public Bool Bezier2(U8 *aux_data,CD3I32 *ctrl,
|
||||
Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),Bool first=TRUE)
|
||||
{//Go in 2nd order bezier calling callback.
|
||||
I64 x,y,z,xx,yy,zz,dx,dy,dz,d_max;
|
||||
F64 x0=ctrl[0].x,y0=ctrl[0].y,z0=ctrl[0].z,
|
||||
x1=ctrl[1].x-x0,y1=ctrl[1].y-y0,z1=ctrl[1].z-z0,
|
||||
x2=ctrl[2].x-x0,y2=ctrl[2].y-y0,z2=ctrl[2].z-z0,
|
||||
t,d=D3I32Dist(&ctrl[0],&ctrl[1])+
|
||||
D3I32Dist(&ctrl[1],&ctrl[2])+
|
||||
D3I32Dist(&ctrl[2],&ctrl[0]),
|
||||
s=0.5/d,t1,t2;
|
||||
x1=ctrl[1].x-x0,y1=ctrl[1].y-y0,z1=ctrl[1].z-z0,
|
||||
x2=ctrl[2].x-x0,y2=ctrl[2].y-y0,z2=ctrl[2].z-z0,
|
||||
t,d=D3I32Dist(&ctrl[0],&ctrl[1])+
|
||||
D3I32Dist(&ctrl[1],&ctrl[2])+
|
||||
D3I32Dist(&ctrl[2],&ctrl[0]),
|
||||
s=0.5/d,t1,t2;
|
||||
xx=x0; yy=y0; zz=z0;
|
||||
if (first && !(*fp_plot)(aux_data,xx,yy,zz))
|
||||
return FALSE;
|
||||
@@ -573,23 +525,24 @@ public Bool Bezier2(U8 *aux_data,CD3I32 *ctrl,Bool (*fp_plot)(U8 *aux,I64 x,I64
|
||||
}
|
||||
x=ctrl[2].x; y=ctrl[2].y; z=ctrl[2].z;
|
||||
if ((xx!=x || yy!=y || zz!=z) &&
|
||||
!(*fp_plot)(aux_data,x,y,z))
|
||||
!(*fp_plot)(aux_data,x,y,z))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public Bool Bezier3(U8 *aux_data,CD3I32 *ctrl,Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),Bool first=TRUE)
|
||||
public Bool Bezier3(U8 *aux_data,CD3I32 *ctrl,
|
||||
Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),Bool first=TRUE)
|
||||
{//Go in 3rd order bezier calling callback.
|
||||
I64 x,y,z,xx,yy,zz,dx,dy,dz,d_max;
|
||||
F64 x0=ctrl[0].x,y0=ctrl[0].y,z0=ctrl[0].z,
|
||||
x1=ctrl[1].x-x0,y1=ctrl[1].y-y0,z1=ctrl[1].z-z0,
|
||||
x2=ctrl[2].x-x0,y2=ctrl[2].y-y0,z2=ctrl[2].z-z0,
|
||||
x3=ctrl[3].x-x0,y3=ctrl[3].y-y0,z3=ctrl[3].z-z0,
|
||||
t,d=D3I32Dist(&ctrl[0],&ctrl[1])+
|
||||
D3I32Dist(&ctrl[1],&ctrl[2])+
|
||||
D3I32Dist(&ctrl[2],&ctrl[3])+
|
||||
D3I32Dist(&ctrl[3],&ctrl[0]),
|
||||
s=0.5/d,nt,t1,t2,t3;
|
||||
x1=ctrl[1].x-x0,y1=ctrl[1].y-y0,z1=ctrl[1].z-z0,
|
||||
x2=ctrl[2].x-x0,y2=ctrl[2].y-y0,z2=ctrl[2].z-z0,
|
||||
x3=ctrl[3].x-x0,y3=ctrl[3].y-y0,z3=ctrl[3].z-z0,
|
||||
t,d=D3I32Dist(&ctrl[0],&ctrl[1])+
|
||||
D3I32Dist(&ctrl[1],&ctrl[2])+
|
||||
D3I32Dist(&ctrl[2],&ctrl[3])+
|
||||
D3I32Dist(&ctrl[3],&ctrl[0]),
|
||||
s=0.5/d,nt,t1,t2,t3;
|
||||
xx=x0; yy=y0; zz=z0;
|
||||
if (first && !(*fp_plot)(aux_data,xx,yy,zz))
|
||||
return FALSE;
|
||||
@@ -621,12 +574,13 @@ public Bool Bezier3(U8 *aux_data,CD3I32 *ctrl,Bool (*fp_plot)(U8 *aux,I64 x,I64
|
||||
}
|
||||
x=ctrl[3].x; y=ctrl[3].y; z=ctrl[3].z;
|
||||
if ((xx!=x || yy!=y || zz!=z) &&
|
||||
!(*fp_plot)(aux_data,x,y,z))
|
||||
!(*fp_plot)(aux_data,x,y,z))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public Bool BSpline2(U8 *aux_data,CD3I32 *ctrl,I64 cnt,Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),Bool closed=FALSE)
|
||||
public Bool BSpline2(U8 *aux_data,CD3I32 *ctrl,I64 cnt,
|
||||
Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),Bool closed=FALSE)
|
||||
{//Go in 2nd order spline calling callback.
|
||||
I64 i,j;
|
||||
CD3I32 *c;
|
||||
@@ -692,7 +646,8 @@ public Bool BSpline2(U8 *aux_data,CD3I32 *ctrl,I64 cnt,Bool (*fp_plot)(U8 *aux,I
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public Bool BSpline3(U8 *aux_data,CD3I32 *ctrl,I64 cnt,Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),Bool closed=FALSE)
|
||||
public Bool BSpline3(U8 *aux_data,CD3I32 *ctrl,I64 cnt,
|
||||
Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),Bool closed=FALSE)
|
||||
{//Go in 3rd order spline calling callback.
|
||||
I64 i,j;
|
||||
F64 x,y,z;
|
||||
@@ -786,10 +741,11 @@ public Bool BSpline3(U8 *aux_data,CD3I32 *ctrl,I64 cnt,Bool (*fp_plot)(U8 *aux,I
|
||||
#define CC_TOP 4
|
||||
#define CC_BOTTOM 8
|
||||
|
||||
public Bool ClipLine(I64 *_x1,I64 *_y1,I64 *_x2,I64 *_y2,I64 left,I64 top,I64 right,I64 bottom)
|
||||
public Bool ClipLine(I64 *_x1,I64 *_y1,I64 *_x2,I64 *_y2,
|
||||
I64 left,I64 top,I64 right,I64 bottom)
|
||||
{//Clip x1,y1 x2,y2 with left,top,right,bottom.
|
||||
I64 x,y,x1=*_x1,y1=*_y1,x2=*_x2,y2=*_y2,
|
||||
cc,cc1,cc2;
|
||||
cc,cc1,cc2;
|
||||
if (y1>bottom)
|
||||
cc1=CC_BOTTOM;
|
||||
else if (y1<top)
|
||||
|
||||
+39
-47
@@ -1,22 +1,14 @@
|
||||
#help_index "Graphics/Color"
|
||||
public I32 gr_rainbow_10[10]=
|
||||
{
|
||||
BLACK,BROWN,RED,LTRED,YELLOW,
|
||||
GREEN,BLUE,PURPLE,LTGRAY,WHITE
|
||||
};
|
||||
public U8 gr_rainbow_10[10]={
|
||||
BLACK,BROWN,RED,LTRED,YELLOW,GREEN,BLUE,PURPLE,LTGRAY,WHITE};
|
||||
|
||||
DefineLstLoad("ST_RAINBOW_10",
|
||||
"BLACK\0BROWN\0RED\0LTRED\0YELLOW\0"
|
||||
"GREEN\0BLUE\0PURPLE\0LTGRAY\0WHITE\0");
|
||||
"BLACK\0BROWN\0RED\0LTRED\0YELLOW\0GREEN\0BLUE\0PURPLE\0LTGRAY\0WHITE\0");
|
||||
|
||||
U0 SetVGAPalette4Indices()
|
||||
{/*4-bit (16 color)
|
||||
There is a level of indirection we wish to identity map.
|
||||
This sets the 16-colors to use
|
||||
the first 16 DAC rgb entries, so
|
||||
we never need to worry about indexes,
|
||||
just DAC palette settings.
|
||||
*/
|
||||
U0 GrPaletteIndicesSet()
|
||||
{//There is a level of indirection that we identity map.
|
||||
// Set 16-colors to use first 16 DAC BGR entries, so we
|
||||
// never need to worry about indexes, just DAC palette settings.
|
||||
I64 i;
|
||||
if (!Bt(&sys_run_level,RLf_VGA)) return;
|
||||
PUSHFD
|
||||
@@ -24,7 +16,7 @@ just DAC palette settings.
|
||||
while (LBts(&sys_semas[SYS_SEMA_VGA],0))
|
||||
Yield;
|
||||
InU8(VGAP_INPUT_STAT); //Rsts attr index/data
|
||||
for (i=0;i<16;i++) {
|
||||
for (i=0;i<NUM_COLORS;i++) {
|
||||
OutU8(VGAP_ATTR_INDEX,i);
|
||||
OutU8(VGAP_ATTR_DATA_WRITE,i);
|
||||
}
|
||||
@@ -35,8 +27,8 @@ just DAC palette settings.
|
||||
POPFD
|
||||
}
|
||||
|
||||
public U0 SetVGAPaletteColor(I64 color_num,CBGR bgr)
|
||||
{//6-bits per b, g and r.
|
||||
public U0 GrPaletteColorSet(I64 color_num,CBGR48 bgr48)
|
||||
{//VGA has 6-bits for blue, for green, and for red.
|
||||
if (!Bt(&sys_run_level,RLf_VGA)) return;
|
||||
PUSHFD
|
||||
CLI
|
||||
@@ -44,16 +36,16 @@ public U0 SetVGAPaletteColor(I64 color_num,CBGR bgr)
|
||||
Yield;
|
||||
OutU8(VGAP_PALETTE_MASK,0xFF);
|
||||
OutU8(VGAP_REG_WRITE,color_num);
|
||||
OutU8(VGAP_PALETTE_DATA,bgr.r>>2);
|
||||
OutU8(VGAP_PALETTE_DATA,bgr.g>>2);
|
||||
OutU8(VGAP_PALETTE_DATA,bgr.b>>2);
|
||||
OutU8(VGAP_PALETTE_DATA,bgr48.r>>10);
|
||||
OutU8(VGAP_PALETTE_DATA,bgr48.g>>10);
|
||||
OutU8(VGAP_PALETTE_DATA,bgr48.b>>10);
|
||||
LBtr(&sys_semas[SYS_SEMA_VGA],0);
|
||||
POPFD
|
||||
}
|
||||
|
||||
public CBGR GetVGAPaletteColor(I64 color_num)
|
||||
{//6-bits per b, g and r.
|
||||
CBGR result=0;
|
||||
public CBGR48 GrPaletteColorGet(I64 color_num)
|
||||
{//VGA has 6-bits for blue, for green, and for red.
|
||||
CBGR48 result=0;
|
||||
if (!Bt(&sys_run_level,RLf_VGA)) return 0;
|
||||
PUSHFD
|
||||
CLI
|
||||
@@ -61,41 +53,41 @@ public CBGR GetVGAPaletteColor(I64 color_num)
|
||||
Yield;
|
||||
OutU8(VGAP_PALETTE_MASK,0xFF);
|
||||
OutU8(VGAP_REG_READ,color_num);
|
||||
result.r=InU8(VGAP_PALETTE_DATA)<<2;
|
||||
result.g=InU8(VGAP_PALETTE_DATA)<<2;
|
||||
result.b=InU8(VGAP_PALETTE_DATA)<<2;
|
||||
result.r=0xFFFF<<10*InU8(VGAP_PALETTE_DATA)/0xFC00;
|
||||
result.g=0xFFFF<<10*InU8(VGAP_PALETTE_DATA)/0xFC00;
|
||||
result.b=0xFFFF<<10*InU8(VGAP_PALETTE_DATA)/0xFC00;
|
||||
LBtr(&sys_semas[SYS_SEMA_VGA],0);
|
||||
POPFD
|
||||
return result;
|
||||
}
|
||||
|
||||
public CBGR vga_palette4_std[16]={
|
||||
0x000000,0x0000AA,0x00AA00,0x00AAAA,
|
||||
0xAA0000,0xAA00AA,0xAA5500,0xAAAAAA,
|
||||
0x555555,0x5555FF,0x55FF55,0x55FFFF,
|
||||
0xFF5555,0xFF55FF,0xFFFF55,0xFFFFFF};
|
||||
public CBGR48 gr_palette_std[NUM_COLORS]={
|
||||
0x000000000000,0x00000000AAAA,0x0000AAAA0000,0x0000AAAAAAAA,
|
||||
0xAAAA00000000,0xAAAA0000AAAA,0xAAAA55550000,0xAAAAAAAAAAAA,
|
||||
0x555555555555,0x55555555FFFF,0x5555FFFF5555,0x5555FFFFFFFF,
|
||||
0xFFFF55555555,0xFFFF5555FFFF,0xFFFFFFFF5555,0xFFFFFFFFFFFF};
|
||||
|
||||
public CBGR vga_palette4_gray[16]={
|
||||
0x000000,0x111111,0x222222,0x333333,
|
||||
0x444444,0x555555,0x666666,0x777777,
|
||||
0x888888,0x999999,0xAAAAAA,0xBBBBBB,
|
||||
0xCCCCCC,0xDDDDDD,0xEEEEEE,0xFFFFFF};
|
||||
public CBGR48 gr_palette_gray[NUM_COLORS]={
|
||||
0x000000000000,0x111111111111,0x222222222222,0x333333333333,
|
||||
0x444444444444,0x555555555555,0x666666666666,0x777777777777,
|
||||
0x888888888888,0x999999999999,0xAAAAAAAAAAAA,0xBBBBBBBBBBBB,
|
||||
0xCCCCCCCCCCCC,0xDDDDDDDDDDDD,0xEEEEEEEEEEEE,0xFFFFFFFFFFFF};
|
||||
|
||||
public U0 GetVGAPalette4(CBGR *bgr)
|
||||
{//4-bit (16 color)
|
||||
public U0 GrPaletteGet(CBGR48 *bgr48)
|
||||
{//16 colors
|
||||
I64 i;
|
||||
for (i=0;i<16;i++)
|
||||
bgr[i]=GetVGAPaletteColor(i);
|
||||
for (i=0;i<NUM_COLORS;i++)
|
||||
bgr48[i]=GrPaletteColorGet(i);
|
||||
}
|
||||
|
||||
public U0 SetVGAPalette4(CBGR *bgr)
|
||||
{//4-bit (16 color)
|
||||
public U0 GrPaletteSet(CBGR48 *bgr48)
|
||||
{//16 colors
|
||||
I64 i;
|
||||
for (i=0;i<16;i++)
|
||||
SetVGAPaletteColor(i,bgr[i]);
|
||||
for (i=0;i<NUM_COLORS;i++)
|
||||
GrPaletteColorSet(i,bgr48[i]);
|
||||
}
|
||||
|
||||
public U0 SetStdPalette()
|
||||
public U0 PaletteSetStd()
|
||||
{//Activate std palette.
|
||||
SetVGAPalette4(vga_palette4_std);
|
||||
GrPaletteSet(gr_palette_std);
|
||||
}
|
||||
+93
-83
@@ -1,6 +1,7 @@
|
||||
#help_index "Graphics"
|
||||
|
||||
public Bool GrClamp(CDC *dc=gr.dc,I64 *left,I64 *top,I64 *right,I64 *bottom,I64 width=0,I64 height=0)
|
||||
public Bool GrClamp(CDC *dc=gr.dc,I64 *left,I64 *top,I64 *right,I64 *bottom,
|
||||
I64 width=0,I64 height=0)
|
||||
{//Returns screen, not window coordinates.
|
||||
CTask *win_task;
|
||||
*left=0;
|
||||
@@ -29,7 +30,8 @@ public Bool GrClamp(CDC *dc=gr.dc,I64 *left,I64 *top,I64 *right,I64 *bottom,I64
|
||||
return *left<=*right && *top<=*bottom;
|
||||
}
|
||||
|
||||
Bool DCClipLine(CDC *dc=gr.dc,I64 *x1,I64 *y1,I64 *x2,I64 *y2,I64 width=0,I64 height=0)
|
||||
Bool DCClipLine(CDC *dc=gr.dc,I64 *x1,I64 *y1,I64 *x2,I64 *y2,
|
||||
I64 width=0,I64 height=0)
|
||||
{//Also converts window to screen coordinates
|
||||
I64 left,top,right,bottom;
|
||||
CTask *win_task;
|
||||
@@ -63,15 +65,15 @@ public Bool GrPlot(CDC *dc=gr.dc,I64 x,I64 y)
|
||||
x+=win_task->pix_left+win_task->scroll_x;
|
||||
y+=win_task->pix_top+win_task->scroll_y;
|
||||
if (win_task->pix_left<=x<=win_task->pix_right &&
|
||||
win_task->pix_top <=y<=win_task->pix_bottom &&
|
||||
0<=x<dc->width && 0<=y<dc->height &&
|
||||
(win_task->next_task==sys_winmgr_task ||
|
||||
dc->flags&DCF_ON_TOP ||
|
||||
!IsPixCovered0(win_task,x,y)))
|
||||
win_task->pix_top <=y<=win_task->pix_bottom &&
|
||||
0<=x<dc->width && 0<=y<dc->height &&
|
||||
(win_task->next_task==sys_winmgr_task ||
|
||||
dc->flags&DCF_ON_TOP ||
|
||||
!IsPixCovered0(win_task,x,y)))
|
||||
GrPlot0(dc,x,y);
|
||||
} else
|
||||
if (0<=x<dc->width && 0<=y<dc->height)
|
||||
GrPlot0(dc,x,y);
|
||||
GrPlot0(dc,x,y);
|
||||
dc->depth_buf=db;
|
||||
return TRUE;
|
||||
}
|
||||
@@ -94,15 +96,15 @@ Bool GrPlot1(CDC *dc=gr.dc,I64 x,I64 y)
|
||||
x+=win_task->pix_left+win_task->scroll_x;
|
||||
y+=win_task->pix_top+win_task->scroll_y;
|
||||
if (win_task->pix_left<=x<=win_task->pix_right &&
|
||||
win_task->pix_top <=y<=win_task->pix_bottom &&
|
||||
0<=x<dc->width && 0<=y<dc->height &&
|
||||
(win_task->next_task==sys_winmgr_task ||
|
||||
dc->flags&DCF_ON_TOP ||
|
||||
!IsPixCovered0(win_task,x,y)))
|
||||
win_task->pix_top <=y<=win_task->pix_bottom &&
|
||||
0<=x<dc->width && 0<=y<dc->height &&
|
||||
(win_task->next_task==sys_winmgr_task ||
|
||||
dc->flags&DCF_ON_TOP ||
|
||||
!IsPixCovered0(win_task,x,y)))
|
||||
GrPlot0(dc,x,y);
|
||||
} else
|
||||
if (0<=x<dc->width && 0<=y<dc->height)
|
||||
GrPlot0(dc,x,y);
|
||||
GrPlot0(dc,x,y);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -115,15 +117,15 @@ public I64 GrPeek(CDC *dc=gr.dc,I64 x,I64 y)
|
||||
x+=win_task->pix_left+win_task->scroll_x;
|
||||
y+=win_task->pix_top+win_task->scroll_y;
|
||||
if (!(win_task->pix_left<=x<=win_task->pix_right) ||
|
||||
!(win_task->pix_top <=y<=win_task->pix_bottom) ||
|
||||
!(0<=x<dc->width) || !(0<=y<dc->height) ||
|
||||
win_task->next_task!=sys_winmgr_task &&
|
||||
!(dc->flags&DCF_ON_TOP) &&
|
||||
IsPixCovered0(win_task,x,y))
|
||||
!(win_task->pix_top <=y<=win_task->pix_bottom) ||
|
||||
!(0<=x<dc->width) || !(0<=y<dc->height) ||
|
||||
win_task->next_task!=sys_winmgr_task &&
|
||||
!(dc->flags&DCF_ON_TOP) &&
|
||||
IsPixCovered0(win_task,x,y))
|
||||
return -1;
|
||||
} else
|
||||
if (!(0<=x<dc->width) || !(0<=y<dc->height))
|
||||
return -1;
|
||||
return -1;
|
||||
return GrPeek0(dc,x,y);
|
||||
}
|
||||
|
||||
@@ -171,7 +173,7 @@ I64 GrFloodFillRay(CDC *dc,I64 x,I64 y,I64 z,I32 *db)
|
||||
//Returns cnt of pixs changed
|
||||
I64 result=0;
|
||||
//We don't dynamically calculate the size to avoid
|
||||
//fragmentation of memory.
|
||||
//fragmentation of memory.
|
||||
CFFRay *f_dc=MAlloc(sizeof(CFFRay)*0x80000),*f=f_dc;
|
||||
f->x=x;
|
||||
f->y=y;
|
||||
@@ -234,11 +236,12 @@ I64 GrFloodFillRay(CDC *dc,I64 x,I64 y,I64 z,I32 *db)
|
||||
return result;
|
||||
}
|
||||
|
||||
public I64 GrFloodFill(CDC *dc=gr.dc,I64 x,I64 y,Bool not_color=FALSE,I64 z=0,I32 *db=NULL)
|
||||
public I64 GrFloodFill(CDC *dc=gr.dc,I64 x,I64 y,
|
||||
Bool not_color=FALSE,I64 z=0,I32 *db=NULL)
|
||||
{//2D. Ignore z and db.
|
||||
//not_color=TRUE means fill up to everything which is not the current color.
|
||||
//not_color=FALSE means fill all parts equal to the color under the point.
|
||||
//Returns cnt of pixs changed
|
||||
//not_color=FALSE means fill all parts equal to the color under the point.
|
||||
//Returns cnt of pixs changed
|
||||
I64 result=0,j,old_flags=dc->flags;
|
||||
CColorROPU32 old_color2=dc->color2;
|
||||
CDC *old_brush;
|
||||
@@ -254,14 +257,14 @@ public I64 GrFloodFill(CDC *dc=gr.dc,I64 x,I64 y,Bool not_color=FALSE,I64 z=0,I3
|
||||
dc->color2=j;
|
||||
if (dc->color.c1.rop&ROPBF_DITHER) {
|
||||
if (dc->color2.c0.color==dc->color.c0.color &&
|
||||
dc->color.c0.color==dc->color.c1.color)
|
||||
dc->color.c0.color==dc->color.c1.color)
|
||||
goto ff_done;
|
||||
} else if (dc->color2.c0.color==dc->color.c0.color)
|
||||
goto ff_done;
|
||||
dc->flags&=~DCF_FILL_NOT_COLOR;
|
||||
}
|
||||
if (not_color && j!=dc->color2 ||
|
||||
!not_color)
|
||||
!not_color)
|
||||
result=GrFloodFillRay(dc,x,y,z,db);
|
||||
}
|
||||
ff_done:
|
||||
@@ -282,7 +285,7 @@ public Bool GrPlot3B(CDC *dc=gr.dc,I64 x,I64 y,I64 z)
|
||||
}
|
||||
if (dc->flags & DCF_SYMMETRY) {
|
||||
_x=x; _y=y; _z=z;
|
||||
GrReflect(dc,&_x,&_y,&_z);
|
||||
DCReflect(dc,&_x,&_y,&_z);
|
||||
dc->flags&=~DCF_SYMMETRY;
|
||||
dc->db_z=_z;
|
||||
GrPlot1(dc,_x,_y);
|
||||
@@ -302,7 +305,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,i,j,w;
|
||||
CColorROPU32 old_color=dc->color;
|
||||
Bool record,was_transform=FALSE,was_symmetry=FALSE;
|
||||
CTask *win_task;
|
||||
@@ -313,7 +316,7 @@ public Bool GrPlot3(CDC *dc=gr.dc,I64 x,I64 y,I64 z)
|
||||
}
|
||||
if (dc->flags & DCF_SYMMETRY) {
|
||||
_x=x; _y=y; _z=z;
|
||||
GrReflect(dc,&_x,&_y,&_z);
|
||||
DCReflect(dc,&_x,&_y,&_z);
|
||||
dc->flags&=~DCF_SYMMETRY;
|
||||
GrPlot3(dc,_x,_y,_z);
|
||||
was_symmetry=TRUE;
|
||||
@@ -341,8 +344,10 @@ public Bool GrPlot3(CDC *dc=gr.dc,I64 x,I64 y,I64 z)
|
||||
}
|
||||
} else {
|
||||
if (dc->color.c0.rop==ROPB_COLLISION) {
|
||||
if (dc->color.c0.color!=dc->bkcolor.c0.color && dc->color.c0.color!=TRANSPARENT)
|
||||
record=GrBlot3(dc,x-w,y-w,z,gr.collision_pen_brushes[dc->pen_width]);
|
||||
if (dc->color.c0.color!=dc->bkcolor.c0.color &&
|
||||
dc->color.c0.color!=TRANSPARENT)
|
||||
record=GrBlot3(dc,x-w,y-w,z,
|
||||
gr.collision_pen_brushes[dc->pen_width]);
|
||||
else
|
||||
record=FALSE;
|
||||
} else
|
||||
@@ -362,7 +367,8 @@ public Bool GrPlot3(CDC *dc=gr.dc,I64 x,I64 y,I64 z)
|
||||
}
|
||||
} else {
|
||||
if (dc->color.c0.rop==ROPB_COLLISION) {
|
||||
if (dc->color.c0.color!=dc->bkcolor.c0.color && dc->color.c0.color!=TRANSPARENT)
|
||||
if (dc->color.c0.color!=dc->bkcolor.c0.color &&
|
||||
dc->color.c0.color!=TRANSPARENT)
|
||||
record=GrBlot(dc,x-w,y-w,gr.collision_pen_brushes[dc->pen_width]);
|
||||
else
|
||||
record=FALSE;
|
||||
@@ -376,13 +382,8 @@ public Bool GrPlot3(CDC *dc=gr.dc,I64 x,I64 y,I64 z)
|
||||
x+=win_task->pix_left+win_task->scroll_x;
|
||||
y+=win_task->pix_top+win_task->scroll_y;
|
||||
}
|
||||
if (dc->flags & DCF_LOCATE_NEAREST) {
|
||||
dist=DistSqrI64(x,y,dc->cur_x,dc->cur_y);
|
||||
if (dist<dc->nearest_dist) {
|
||||
dc->nearest_sprite_elem_num=dc->cur_sprite_elem_num;
|
||||
dc->nearest_dist=dist;
|
||||
}
|
||||
}
|
||||
if (dc->flags & DCF_LOCATE_NEAREST)
|
||||
dc->dist=DistSqrI64(x,y,dc->cur_x,dc->cur_y);
|
||||
if (dc->flags & DCF_RECORD_EXTENTS) {
|
||||
if (x-w<dc->min_x) dc->min_x=x-w;
|
||||
if (y-w<dc->min_y) dc->min_y=y-w;
|
||||
@@ -417,9 +418,9 @@ Bool GrLinePlot0(CDC *dc,I64 x,I64 y,I64 z)
|
||||
{//This is a callback.
|
||||
CTask *win_task=dc->win_task;
|
||||
if (!(dc->flags & DCF_SCREEN_BITMAP) ||
|
||||
win_task->next_task==sys_winmgr_task ||
|
||||
dc->flags&DCF_ON_TOP ||
|
||||
!IsPixCovered0(win_task,x,y)) {
|
||||
win_task->next_task==sys_winmgr_task ||
|
||||
dc->flags&DCF_ON_TOP ||
|
||||
!IsPixCovered0(win_task,x,y)) {
|
||||
dc->db_z=z;
|
||||
GrPlot0(dc,x,y);
|
||||
}
|
||||
@@ -433,7 +434,8 @@ Bool GrLinePlot(CDC *dc,I64 x,I64 y,I64 z)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public Bool GrLine(CDC *dc=gr.dc,I64 x1,I64 y1,I64 x2,I64 y2,I64 step=1,I64 start=0)
|
||||
public Bool GrLine(CDC *dc=gr.dc,I64 x1,I64 y1,I64 x2,I64 y2,
|
||||
I64 step=1,I64 start=0)
|
||||
{//2D. Clipping but not transformation.
|
||||
Bool result=FALSE;
|
||||
I32 *db=dc->depth_buf;
|
||||
@@ -469,7 +471,8 @@ public Bool GrEllipse(CDC *dc=gr.dc,
|
||||
Bool result;
|
||||
I32 *db=dc->depth_buf;
|
||||
dc->depth_buf=NULL;
|
||||
result=Ellipse(dc,cx,cy,0,x_radius,y_radius,&GrLinePlot,rot_angle,step,start_radians,len_radians);
|
||||
result=Ellipse(dc,cx,cy,0,x_radius,y_radius,&GrLinePlot,
|
||||
rot_angle,step,start_radians,len_radians);
|
||||
dc->depth_buf=db;
|
||||
return result;
|
||||
}
|
||||
@@ -486,7 +489,7 @@ public Bool GrRegPoly(CDC *dc=gr.dc,
|
||||
I32 *db=dc->depth_buf;
|
||||
dc->depth_buf=NULL;
|
||||
result=RegPoly(dc,cx,cy,0,x_radius,y_radius,sides,
|
||||
&GrLinePlot,rot_angle,step,start_radians,len_radians);
|
||||
&GrLinePlot,rot_angle,step,start_radians,len_radians);
|
||||
dc->depth_buf=db;
|
||||
return result;
|
||||
}
|
||||
@@ -511,7 +514,8 @@ public Bool Gr3BSpline(CDC *dc=gr.dc,CD3I32 *ctrl,I64 cnt,Bool closed=FALSE)
|
||||
return BSpline3(dc,ctrl,cnt,&GrLinePlot,closed);
|
||||
}
|
||||
|
||||
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)
|
||||
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.
|
||||
I64 _x1,_y1,_z1,_x2,_y2,_z2;
|
||||
Bool result=FALSE,was_transform=FALSE,was_symmetry=FALSE;
|
||||
@@ -523,11 +527,12 @@ public Bool GrLine3(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,I64 x2,I64 y2,I64 z2,I64
|
||||
}
|
||||
if (dc->flags & DCF_SYMMETRY) {
|
||||
_x1=x1; _y1=y1; _z1=z1;
|
||||
GrReflect(dc,&_x1,&_y1,&_z1);
|
||||
DCReflect(dc,&_x1,&_y1,&_z1);
|
||||
_x2=x2; _y2=y2; _z2=z2;
|
||||
GrReflect(dc,&_x2,&_y2,&_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 (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))
|
||||
result=Line(dc,_x1,_y1,0,_x2,_y2,0,&GrLinePlot0,step,start);
|
||||
} else
|
||||
@@ -536,7 +541,8 @@ public Bool GrLine3(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,I64 x2,I64 y2,I64 z2,I64
|
||||
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 (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))
|
||||
result|=Line(dc,x1,y1,0,x2,y2,0,&GrLinePlot0,step,start);
|
||||
} else
|
||||
@@ -628,10 +634,11 @@ public Bool GrEllipse3(CDC *dc=gr.dc,
|
||||
m2*=Abs(Sin(a2-a1));
|
||||
|
||||
result=Ellipse(dc,cx,cy,cz,
|
||||
m1/0x10000,m2/0x10000,&GrPlot3,-a1,step,start_radians,len_radians);
|
||||
m1/0x10000,m2/0x10000,&GrPlot3,-a1,step,start_radians,len_radians);
|
||||
dc->flags|=DCF_TRANSFORMATION;
|
||||
} else
|
||||
result=Ellipse(dc,cx,cy,cz,x_radius,y_radius,&GrPlot3,rot_angle,step,start_radians,len_radians);
|
||||
result=Ellipse(dc,cx,cy,cz,x_radius,y_radius,&GrPlot3,
|
||||
rot_angle,step,start_radians,len_radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -639,9 +646,11 @@ public Bool GrCircle3(CDC *dc=gr.dc,I64 cx,I64 cy,I64 cz,I64 radius,
|
||||
I64 step=1,F64 start_radians=0,F64 len_radians=2*ã)
|
||||
{//3D. Transformation with pen width.
|
||||
if (dc->flags & DCF_TRANSFORMATION)
|
||||
return GrEllipse3(dc,cx,cy,cz,radius,radius,0,step,start_radians,len_radians);
|
||||
return GrEllipse3(dc,cx,cy,cz,radius,radius,0,step,
|
||||
start_radians,len_radians);
|
||||
else
|
||||
return Circle(dc,cx,cy,cz,radius,&GrPlot3,step,start_radians,len_radians);
|
||||
return Circle(dc,cx,cy,cz,radius,&GrPlot3,step,
|
||||
start_radians,len_radians);
|
||||
}
|
||||
|
||||
public Bool GrRegPoly3(CDC *dc=gr.dc,
|
||||
@@ -690,27 +699,29 @@ public Bool GrRegPoly3(CDC *dc=gr.dc,
|
||||
m2*=Abs(Sin(a2-a1));
|
||||
|
||||
result=RegPoly(dc,cx,cy,cz,
|
||||
m1/0x10000,m2/0x10000,sides,&GrPlot3,-a1,step,start_radians,len_radians);
|
||||
m1/0x10000,m2/0x10000,sides,&GrPlot3,-a1,
|
||||
step,start_radians,len_radians);
|
||||
dc->flags|=DCF_TRANSFORMATION;
|
||||
} else
|
||||
result=RegPoly(dc,cx,cy,cz,x_radius,y_radius,sides,&GrPlot3,rot_angle,step,start_radians,len_radians);
|
||||
result=RegPoly(dc,cx,cy,cz,x_radius,y_radius,sides,&GrPlot3,
|
||||
rot_angle,step,start_radians,len_radians);
|
||||
return result;
|
||||
}
|
||||
|
||||
public I64 GrFloodFill3(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,Bool not_color=FALSE)
|
||||
{//3D. Transformation.
|
||||
//not_color=TRUE means fill up to everything which is not the current color.
|
||||
//not_color=FALSE means fill all parts equal to the color under the point.
|
||||
//Returns cnt of pixs changed
|
||||
//not_color=FALSE means fill all parts equal to the color under the point.
|
||||
//Returns cnt of pixs changed
|
||||
I64 result,old_flags=dc->flags,
|
||||
_x,_y,_z;
|
||||
_x,_y,_z;
|
||||
if (dc->flags & DCF_TRANSFORMATION) {
|
||||
(*dc->transform)(dc,&x1,&y1,&z1);
|
||||
dc->flags&=~DCF_TRANSFORMATION;
|
||||
}
|
||||
if (dc->flags & DCF_SYMMETRY) {
|
||||
_x=x1; _y=y1; _z=z1;
|
||||
GrReflect(dc,&_x,&_y,&_z);
|
||||
DCReflect(dc,&_x,&_y,&_z);
|
||||
dc->flags&=~DCF_SYMMETRY;
|
||||
result=GrFloodFill(dc,_x,_y,not_color,_z,dc->depth_buf);
|
||||
if (dc->flags&DCF_JUST_MIRROR)
|
||||
@@ -725,16 +736,16 @@ gr_done:
|
||||
#help_index "Graphics;Graphics/Device Contexts"
|
||||
|
||||
public I64 GrBlot3(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,CDC *img)
|
||||
{//3D. Clipping and transformation. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
{//3D. Clipping and transformation.
|
||||
CColorROPU32 old_color=dc->color;
|
||||
I64 color,reg i,j,w=img->width,h=img->height,
|
||||
d1,dx1,dy1,dz1,
|
||||
reg d2,dx2,dy2,dz2,
|
||||
adx1,ady1,adz1,
|
||||
adx2,ady2,adz2,
|
||||
x2,y2,z2,x3,y3,z3,
|
||||
dw,reg dh,x,y,_x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3,
|
||||
last_x,last_y,result=0;
|
||||
d1,dx1,dy1,dz1,
|
||||
reg d2,dx2,dy2,dz2,
|
||||
adx1,ady1,adz1,
|
||||
adx2,ady2,adz2,
|
||||
x2,y2,z2,x3,y3,z3,
|
||||
dw,reg dh,x,y,_x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3,
|
||||
last_x,last_y,result=0;
|
||||
Bool first;
|
||||
CDC *old_brush=dc->brush;
|
||||
|
||||
@@ -748,11 +759,11 @@ public I64 GrBlot3(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,CDC *img)
|
||||
}
|
||||
if (dc->flags & DCF_SYMMETRY) {
|
||||
_x1=x1; _y1=y1; _z1=z1;
|
||||
GrReflect(dc,&_x1,&_y1,&_z1);
|
||||
DCReflect(dc,&_x1,&_y1,&_z1);
|
||||
_x2=x2; _y2=y2; _z2=z2;
|
||||
GrReflect(dc,&_x2,&_y2,&_z2);
|
||||
DCReflect(dc,&_x2,&_y2,&_z2);
|
||||
_x3=x3; _y3=y3; _z3=z3;
|
||||
GrReflect(dc,&_x3,&_y3,&_z3);
|
||||
DCReflect(dc,&_x3,&_y3,&_z3);
|
||||
dx1=_x2-_x1; dy1=_y2-_y1; dz1=_z2-_z1;
|
||||
dx2=_x3-_x1; dy2=_y3-_y1; dz2=_z3-_z1;
|
||||
adx1=AbsI64(dx1); ady1=AbsI64(dy1); adz1=AbsI64(dz1);
|
||||
@@ -944,7 +955,7 @@ public Bool Gr2Bezier3(CDC *dc=gr.dc,CD3I32 *ctrl)
|
||||
{//2nd order. Clipping and transform and pen width.
|
||||
Bool result=FALSE;
|
||||
I64 i,x,y,z,
|
||||
old_flags=dc->flags;
|
||||
old_flags=dc->flags;
|
||||
CD3I32 *ctrl2=NULL,*ctrl3=NULL;
|
||||
if (dc->flags & DCF_TRANSFORMATION) {
|
||||
ctrl2=MAlloc(sizeof(CD3I32)*3);
|
||||
@@ -966,7 +977,7 @@ public Bool Gr2Bezier3(CDC *dc=gr.dc,CD3I32 *ctrl)
|
||||
x=ctrl[i].x;
|
||||
y=ctrl[i].y;
|
||||
z=ctrl[i].z;
|
||||
GrReflect(dc,&x,&y,&z);
|
||||
DCReflect(dc,&x,&y,&z);
|
||||
ctrl3[i].x=x;
|
||||
ctrl3[i].y=y;
|
||||
ctrl3[i].z=z;
|
||||
@@ -989,7 +1000,7 @@ public Bool Gr3Bezier3(CDC *dc=gr.dc,CD3I32 *ctrl)
|
||||
{//3rd order. Clipping and transform and pen width.
|
||||
Bool result=FALSE;
|
||||
I64 i,x,y,z,
|
||||
old_flags=dc->flags;
|
||||
old_flags=dc->flags;
|
||||
CD3I32 *ctrl2=NULL,*ctrl3=NULL;
|
||||
if (dc->flags & DCF_TRANSFORMATION) {
|
||||
ctrl2=MAlloc(sizeof(CD3I32)*4);
|
||||
@@ -1011,7 +1022,7 @@ public Bool Gr3Bezier3(CDC *dc=gr.dc,CD3I32 *ctrl)
|
||||
x=ctrl[i].x;
|
||||
y=ctrl[i].y;
|
||||
z=ctrl[i].z;
|
||||
GrReflect(dc,&x,&y,&z);
|
||||
DCReflect(dc,&x,&y,&z);
|
||||
ctrl3[i].x=x;
|
||||
ctrl3[i].y=y;
|
||||
ctrl3[i].z=z;
|
||||
@@ -1034,7 +1045,7 @@ public I64 Gr2BSpline3(CDC *dc=gr.dc,CD3I32 *ctrl,I64 cnt,Bool closed=FALSE)
|
||||
{//2nd order. Clipping and transform and pen width.
|
||||
Bool result=FALSE;
|
||||
I64 i,x,y,z,
|
||||
old_flags=dc->flags;
|
||||
old_flags=dc->flags;
|
||||
CD3I32 *ctrl2=NULL,*ctrl3=NULL;
|
||||
if (dc->flags & DCF_TRANSFORMATION) {
|
||||
ctrl2=MAlloc(sizeof(CD3I32)*cnt);
|
||||
@@ -1056,7 +1067,7 @@ public I64 Gr2BSpline3(CDC *dc=gr.dc,CD3I32 *ctrl,I64 cnt,Bool closed=FALSE)
|
||||
x=ctrl[i].x;
|
||||
y=ctrl[i].y;
|
||||
z=ctrl[i].z;
|
||||
GrReflect(dc,&x,&y,&z);
|
||||
DCReflect(dc,&x,&y,&z);
|
||||
ctrl3[i].x=x;
|
||||
ctrl3[i].y=y;
|
||||
ctrl3[i].z=z;
|
||||
@@ -1079,7 +1090,7 @@ public Bool Gr3BSpline3(CDC *dc=gr.dc,CD3I32 *ctrl,I64 cnt,Bool closed=FALSE)
|
||||
{//3rd order. Clipping and transform and pen width.
|
||||
Bool result=FALSE;
|
||||
I64 i,x,y,z,
|
||||
old_flags=dc->flags;
|
||||
old_flags=dc->flags;
|
||||
CD3I32 *ctrl2=NULL,*ctrl3=NULL;
|
||||
if (dc->flags & DCF_TRANSFORMATION) {
|
||||
ctrl2=MAlloc(sizeof(CD3I32)*cnt);
|
||||
@@ -1101,7 +1112,7 @@ public Bool Gr3BSpline3(CDC *dc=gr.dc,CD3I32 *ctrl,I64 cnt,Bool closed=FALSE)
|
||||
x=ctrl[i].x;
|
||||
y=ctrl[i].y;
|
||||
z=ctrl[i].z;
|
||||
GrReflect(dc,&x,&y,&z);
|
||||
DCReflect(dc,&x,&y,&z);
|
||||
ctrl3[i].x=x;
|
||||
ctrl3[i].y=y;
|
||||
ctrl3[i].z=z;
|
||||
@@ -1121,17 +1132,16 @@ gr_done:
|
||||
}
|
||||
|
||||
public I64 GrFillTri0(CDC *dc=gr.dc,CD3I32 *p1,CD3I32 *p2,CD3I32 *p4)
|
||||
{//3D. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
//Returns cnt of pixs changed
|
||||
{//3D. Returns cnt of pixs changed
|
||||
I64 x1,x2,y,z1,z2,dx1,dy1,dz1,dx2,dy2,dz2,result=0,i,y_min,y_max;
|
||||
CTask *win_task;
|
||||
//p1 is min x
|
||||
//p1 is min x
|
||||
if (p4->x<p2->x)
|
||||
SwapI64(&p4,&p2);
|
||||
if (p2->x<p1->x)
|
||||
SwapI64(&p2,&p1);
|
||||
|
||||
//p2y<=p4y
|
||||
//p2y<=p4y
|
||||
if (p4->y<p2->y)
|
||||
SwapI64(&p4,&p2);
|
||||
|
||||
|
||||
+96
-99
@@ -1,87 +1,84 @@
|
||||
#help_index "Graphics/Screen"
|
||||
|
||||
U0 GrUpdateWins()
|
||||
U0 GrUpdateTaskODEs(CTask *task)
|
||||
{
|
||||
sys_task_being_screen_updated=task;
|
||||
try
|
||||
ODEsUpdate(task);
|
||||
catch {
|
||||
LBts(&task->win_inhibit,WIf_SELF_ODE);
|
||||
"Exception in WinMgr: Update Task ODEs\n";
|
||||
PutExcept;
|
||||
Sleep(3000);
|
||||
VGAFlush;
|
||||
}
|
||||
sys_task_being_screen_updated=NULL;
|
||||
}
|
||||
|
||||
U0 GrUpdateTaskWin(CTask *task)
|
||||
{ //Draw core#0 task win.
|
||||
CDC *dc;
|
||||
CD3I64 saved_scroll;
|
||||
sys_task_being_screen_updated=task;
|
||||
try {
|
||||
if (!Bt(&task->display_flags,DISPLAYf_NO_BORDER))
|
||||
TextBorder(Fs,task->win_left,task->win_right,task->win_top,
|
||||
task->win_bottom,task->border_attr,task==sys_focus_task);
|
||||
TextRect(task->win_left,task->win_right,
|
||||
task->win_top,task->win_bottom,task->text_attr<<8);
|
||||
if (task==sys_winmgr_task) {
|
||||
if (gr.fp_wall_paper)
|
||||
(*gr.fp_wall_paper)(task);
|
||||
} else if (!(task->win_inhibit&WIF_SELF_DOC))
|
||||
DocUpdateTaskDocs(task);
|
||||
if (TaskValidate(task)) {
|
||||
if (task->draw_it) {
|
||||
dc=DCAlias(gr.dc2,task);
|
||||
(*task->draw_it)(task,dc);
|
||||
DCDel(dc);
|
||||
}
|
||||
if (TaskValidate(task)) {
|
||||
WinScrollNull(task,&saved_scroll);
|
||||
DrawCtrls(task);
|
||||
WinScrollRestore(task,&saved_scroll);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
if (task!=Fs && TaskValidate(task)) {
|
||||
LBtr(&task->display_flags,DISPLAYf_SHOW);
|
||||
"Exception in WinMgr: Update Task Win\n";
|
||||
PutExcept;
|
||||
Sleep(3000);
|
||||
VGAFlush;
|
||||
}
|
||||
}
|
||||
sys_task_being_screen_updated=NULL;
|
||||
}
|
||||
|
||||
U0 GrUpdateTasks()
|
||||
{//Only called by WinMgr
|
||||
I64 i;
|
||||
CTask *task,*task1;
|
||||
CD3I64 saved_scroll;
|
||||
CDC *dc;
|
||||
Preempt(OFF);
|
||||
try {
|
||||
winmgr.ode_time=0;
|
||||
if (Bt(&sys_semas[SYS_SEMA_UPDATE_WIN_Z_BUF],0))
|
||||
WinZBufUpdate;
|
||||
task1=task=sys_winmgr_task;
|
||||
do {
|
||||
if (!TaskValidate(task))
|
||||
break;
|
||||
sys_task_being_screen_updated=task;
|
||||
Preempt(ON);
|
||||
ODEsUpdate(task);
|
||||
Preempt(OFF);
|
||||
if (!TaskValidate(task))
|
||||
break;
|
||||
do { //Loop through core#0 tasks.
|
||||
if (!TaskValidate(task)) break;
|
||||
if (Bt(&task->display_flags,DISPLAYf_SHOW) &&
|
||||
Bt(gr.win_uncovered_bitmap,task->win_z_num))
|
||||
try {
|
||||
if (!Bt(&task->display_flags,DISPLAYf_NO_BORDER))
|
||||
TextBorder(Fs,task->win_left,task->win_right,task->win_top,
|
||||
task->win_bottom,task->border_attr,task==sys_focus_task);
|
||||
TextRect(task->win_left,task->win_right,
|
||||
task->win_top,task->win_bottom,task->text_attr<<8);
|
||||
Preempt(ON);
|
||||
if (task==sys_winmgr_task) {
|
||||
if (gr.fp_wall_paper)
|
||||
(*gr.fp_wall_paper)(task);
|
||||
} else if (!(task->win_inhibit&WIF_SELF_DOC))
|
||||
DocUpdateTaskDocs(task);
|
||||
if (TaskValidate(task)) {
|
||||
if (task->draw_it) {
|
||||
dc=DCAlias(gr.dc2,task);
|
||||
(*task->draw_it)(task,dc);
|
||||
DCDel(dc);
|
||||
}
|
||||
if (TaskValidate(task)) {
|
||||
Preempt(OFF);
|
||||
WinScrollNull(task,&saved_scroll);
|
||||
DrawCtrls(task);
|
||||
WinScrollRestore(task,&saved_scroll);
|
||||
}
|
||||
}
|
||||
Preempt(OFF);
|
||||
} catch {
|
||||
if (task!=Fs && TaskValidate(task)) {
|
||||
LBtr(&task->display_flags,DISPLAYf_SHOW);
|
||||
"Exception in WinMgr: DrawIt\n";
|
||||
PutExcept;
|
||||
Sleep(3000);
|
||||
VGAFlush;
|
||||
}
|
||||
}
|
||||
if (!TaskValidate(task))
|
||||
break;
|
||||
Bt(gr.win_uncovered_bitmap,task->win_z_num))
|
||||
GrUpdateTaskWin(task);
|
||||
if (!TaskValidate(task)) break;
|
||||
task=task->next_task;
|
||||
} while (task!=task1);
|
||||
|
||||
for (i=1;i<mp_cnt;i++) {
|
||||
for (i=0;i<mp_cnt;i++) { //Loop through all cores.
|
||||
task1=task=cpu_structs[i].seth_task;
|
||||
do {
|
||||
if (!TaskValidate(task))
|
||||
break;
|
||||
try {
|
||||
sys_task_being_screen_updated=task;
|
||||
Preempt(ON);
|
||||
ODEsUpdate(task);
|
||||
Preempt(OFF);
|
||||
} catch {
|
||||
LBts(&task->win_inhibit,WIf_SELF_ODE);
|
||||
"Exception in WinMgr: ODE\n";
|
||||
PutExcept;
|
||||
Sleep(3000);
|
||||
VGAFlush;
|
||||
}
|
||||
if (!TaskValidate(task))
|
||||
break;
|
||||
if (!TaskValidate(task)) break;
|
||||
GrUpdateTaskODEs(task);
|
||||
if (!TaskValidate(task)) break;
|
||||
task=task->next_task;
|
||||
} while (task!=task1);
|
||||
}
|
||||
@@ -91,7 +88,7 @@ U0 GrUpdateWins()
|
||||
}
|
||||
winmgr.last_ode_time=winmgr.ode_time;
|
||||
ode_alloced_factor=LowPass1(0.1,ode_alloced_factor,
|
||||
Clamp(Gs->idle_factor-0.1,0.2,0.8),1/winmgr.fps);
|
||||
Clamp(Gs->idle_factor-0.1,0.2,0.8),1/winmgr.fps);
|
||||
sys_task_being_screen_updated=NULL;
|
||||
}
|
||||
|
||||
@@ -109,7 +106,7 @@ U0 GrFixZoomScale()
|
||||
|
||||
public U0 GrScaleZoom(F64 scale)
|
||||
{//Multiply zoom factor larger or smaller.
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
Bool old_preempt=Preempt;
|
||||
F64 s=gr.screen_zoom;
|
||||
gr.screen_zoom=gr.screen_zoom*scale;
|
||||
GrFixZoomScale;
|
||||
@@ -130,12 +127,12 @@ U0 GrZoomInScreen()
|
||||
{
|
||||
GrFixZoomScale;
|
||||
I64 plane,row,col,k,l,
|
||||
d2=gr.zoomed_dc->width>>3/gr.screen_zoom,
|
||||
d4=gr.zoomed_dc->width_internal>>3,
|
||||
d5=d4-d2*gr.screen_zoom,
|
||||
d3=gr.zoomed_dc->height/gr.screen_zoom,
|
||||
d6=(gr.zoomed_dc->height-d3)*gr.dc1->width_internal>>3,
|
||||
d7=gr.zoomed_dc->height%gr.screen_zoom*d4;
|
||||
d2=gr.zoomed_dc->width>>3/gr.screen_zoom,
|
||||
d4=gr.zoomed_dc->width_internal>>3,
|
||||
d5=d4-d2*gr.screen_zoom,
|
||||
d3=gr.zoomed_dc->height/gr.screen_zoom,
|
||||
d6=(gr.zoomed_dc->height-d3)*gr.dc1->width_internal>>3,
|
||||
d7=gr.zoomed_dc->height%gr.screen_zoom*d4;
|
||||
U8 *src,*src2,*dst,*src3,*map=gr.screen_zoom_tables[gr.screen_zoom];
|
||||
|
||||
src=gr.dc1->body+gr.sx>>3+gr.sy*gr.dc1->width_internal>>3;
|
||||
@@ -171,8 +168,8 @@ U0 GrZoomInScreen()
|
||||
U0 GrUpdateTextBG()
|
||||
{
|
||||
I64 reg RSI *dst=gr.dc2->body,reg R13 c,row,col,
|
||||
num_rows=TEXT_ROWS,num_cols=TEXT_COLS,i,j,cur_ch,
|
||||
reg R12 w1=gr.dc2->width_internal,w2=-7*w1+8,w3=7*w1,w4=0;
|
||||
num_rows=TEXT_ROWS,num_cols=TEXT_COLS,i,j,cur_ch,
|
||||
reg R12 w1=gr.dc2->width_internal,w2=-7*w1+8,w3=7*w1,w4=0;
|
||||
U32 *src=gr.text_base;
|
||||
Bool blink_flag=Blink;
|
||||
U8 *dst2=dst;
|
||||
@@ -235,21 +232,21 @@ U0 GrUpdateTextBG()
|
||||
cur_ch.u8[1]=cur_ch.u8[1]<<4+cur_ch.u8[1]>>4;
|
||||
}
|
||||
c=gr.to_8_colors[cur_ch.u8[1]>>4];
|
||||
MOV U64 [RSI],R13
|
||||
ADD RSI,R12
|
||||
MOV U64 [RSI],R13
|
||||
ADD RSI,R12
|
||||
MOV U64 [RSI],R13
|
||||
ADD RSI,R12
|
||||
MOV U64 [RSI],R13
|
||||
ADD RSI,R12
|
||||
MOV U64 [RSI],R13
|
||||
ADD RSI,R12
|
||||
MOV U64 [RSI],R13
|
||||
ADD RSI,R12
|
||||
MOV U64 [RSI],R13
|
||||
ADD RSI,R12
|
||||
MOV U64 [RSI],R13
|
||||
MOV U64 [RSI],R13
|
||||
ADD RSI,R12
|
||||
MOV U64 [RSI],R13
|
||||
ADD RSI,R12
|
||||
MOV U64 [RSI],R13
|
||||
ADD RSI,R12
|
||||
MOV U64 [RSI],R13
|
||||
ADD RSI,R12
|
||||
MOV U64 [RSI],R13
|
||||
ADD RSI,R12
|
||||
MOV U64 [RSI],R13
|
||||
ADD RSI,R12
|
||||
MOV U64 [RSI],R13
|
||||
ADD RSI,R12
|
||||
MOV U64 [RSI],R13
|
||||
dst(U8 *)+=w2;
|
||||
}
|
||||
src+=w4;
|
||||
@@ -261,8 +258,8 @@ U0 GrUpdateTextFG()
|
||||
{//See $LK,"TextBase Layer",A="HI:TextBase Layer"$.
|
||||
U32 *src=gr.text_base;
|
||||
I64 i,j,cur_ch,*dst=gr.dc2->body,
|
||||
w1=gr.dc2->width_internal,w2=7*w1,w4=0,
|
||||
num_rows=TEXT_ROWS,num_cols=TEXT_COLS,row,col;
|
||||
w1=gr.dc2->width_internal,w2=7*w1,w4=0,
|
||||
num_rows=TEXT_ROWS,num_cols=TEXT_COLS,row,col;
|
||||
U8 *dst_start=gr.dc2->body,*dst_end=dst_start+w1*gr.dc2->height-7*w1-8;
|
||||
Bool blink_flag=Blink;
|
||||
|
||||
@@ -408,14 +405,14 @@ U0 GrUpdateScreen()
|
||||
CDC *dc;
|
||||
Preempt(ON);
|
||||
if (!Bt(&sys_run_level,RLf_VGA)) //if text mode
|
||||
GrUpdateWins;
|
||||
GrUpdateTasks;
|
||||
else {
|
||||
GrUpdateTextBG;
|
||||
GrUpdateTextFG;
|
||||
GrUpdateWins;
|
||||
GrUpdateTasks;
|
||||
DCBlotColor8(gr.dc2,gr.dc);
|
||||
}
|
||||
Preempt(OFF);
|
||||
Preempt;
|
||||
|
||||
dc=DCAlias(gr.dc2,Fs);
|
||||
dc->flags|=DCF_ON_TOP;
|
||||
@@ -427,7 +424,7 @@ U0 GrUpdateScreen()
|
||||
GrUpdateTextModeText;
|
||||
else {
|
||||
DCBlotColor4(gr.dc1->body,gr.dc2->body,gr.dc_cache->body,
|
||||
gr.dc2->height*gr.dc2->width_internal>>3);
|
||||
gr.dc2->height*gr.dc2->width_internal>>3);
|
||||
GrUpdateVGAGraphics;
|
||||
}
|
||||
}
|
||||
+57
-47
@@ -1,25 +1,18 @@
|
||||
#help_index "Graphics/Sprite"
|
||||
#help_index "Graphics/Sprite;Sprites"
|
||||
/*
|
||||
$LK,"CSprite",A="MN:CSprite"$s are stored as a sequence of var
|
||||
length operations with a 1-byte type leading
|
||||
each operation. The types available are lsted
|
||||
here, $LK,"SPT_PT",A="MN:SPT_PT"$. They are stored, one after another,
|
||||
in a chunk of memory terminated by a type $LK,"SPT_END",A="MN:SPT_END"$.
|
||||
|
||||
length operations with a 1-byte $LK,"type",A="MN:SPT_PT"$ leading
|
||||
each operation. They are stored, one after another,
|
||||
in a chunk of memory terminated by a $LK,"zero",A="MN:SPT_END"$.
|
||||
$LK,"Sprite3",A="MN:Sprite3"$() shows how the $LK,"CSprite",A="MN:CSprite"$ unions are used.
|
||||
It's kind-of a mess using a union.
|
||||
|
||||
$LK,"SpriteElemSize",A="MN:SpriteElemSize"$() will return the size of a single
|
||||
element, while $LK,"SpriteSize",A="MN:SpriteSize"$() will return the size
|
||||
of an entire lst. Look at $LK,"sprite_elem_base_sizes",A="MN:sprite_elem_base_sizes"$.
|
||||
|
||||
See $LK,"SpriteElem2Code",A="MN:SpriteElem2Code"$() to infer the raw storage
|
||||
format. They are stored as raw binary values
|
||||
when saved to files, not text code.
|
||||
of an entire list. Look at $LK,"sprite_elem_base_sizes",A="MN:sprite_elem_base_sizes"$.
|
||||
|
||||
See $MA-X+PU,"::/Apps/GrModels",LM="Cd(\"::/Apps/GrModels\");Dir;View;\n"$ for an example of
|
||||
making CSprite by hand. Those are type
|
||||
$LK,"SPT_MESH",A="MN:SPT_MESH"$, one of the most complicated.
|
||||
making CSprite by hand. It uses $LK,"SPT_MESH",A="MN:SPT_MESH"$,
|
||||
one of the most complicated.
|
||||
*/
|
||||
|
||||
public U0 Sprite3(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,Bool just_one=FALSE)
|
||||
@@ -35,8 +28,11 @@ public U0 Sprite3(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,Bool just_one=FALSE)
|
||||
CD3I32 *p;
|
||||
CGrSym old_sym;
|
||||
MemCpy(&old_sym,&dc->sym,sizeof(CGrSym));
|
||||
if (dc->flags & DCF_LOCATE_NEAREST) {
|
||||
dc->nearest_sprite_elem_num=0;
|
||||
dc->dist=dc->nearest_dist=MAX_I64;
|
||||
}
|
||||
while (tempg->type) {
|
||||
dc->cur_sprite_elem_num=cur_sprite_elem_num++;
|
||||
switch (tempg->type) {
|
||||
case SPT_COLOR:
|
||||
dc->color=dc->color&~(COLORROP_COLORS_MASK|ROPF_DITHER)|tempg->c.color;
|
||||
@@ -48,7 +44,7 @@ public U0 Sprite3(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,Bool just_one=FALSE)
|
||||
break;
|
||||
case SPT_WIDTH:
|
||||
dc->pen_width=tempg->w.width;
|
||||
GrScalePenWidth(dc);
|
||||
DCPenWidthScale(dc);
|
||||
break;
|
||||
case SPT_TRANSFORM_ON:
|
||||
if (!(dc->flags&DCF_TRANSFORMATION)) {
|
||||
@@ -92,13 +88,17 @@ public U0 Sprite3(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,Bool just_one=FALSE)
|
||||
y+=tempg->p.y1;
|
||||
break;
|
||||
case SPT_LINE:
|
||||
GrLine3(dc,tempg->pp.x1+x,tempg->pp.y1+y,z,tempg->pp.x2+x,tempg->pp.y2+y,z);
|
||||
GrLine3(dc,tempg->pp.x1+x,tempg->pp.y1+y,z,
|
||||
tempg->pp.x2+x,tempg->pp.y2+y,z);
|
||||
break;
|
||||
case SPT_ARROW:
|
||||
GrArrow3(dc,tempg->pp.x1+x,tempg->pp.y1+y,z,tempg->pp.x2+x,tempg->pp.y2+y,z);
|
||||
GrArrow3(dc,tempg->pp.x1+x,tempg->pp.y1+y,z,
|
||||
tempg->pp.x2+x,tempg->pp.y2+y,z);
|
||||
break;
|
||||
case SPT_PLANAR_SYMMETRY:
|
||||
if (GrSetSymmetry3(dc,tempg->pp.x1+x,tempg->pp.y1+y,z,tempg->pp.x2+x,tempg->pp.y2+y,z,tempg->pp.x2+x,tempg->pp.y2+y,z+1))
|
||||
if (DCSymmetry3Set(dc,tempg->pp.x1+x,tempg->pp.y1+y,z,
|
||||
tempg->pp.x2+x,tempg->pp.y2+y,z,
|
||||
tempg->pp.x2+x,tempg->pp.y2+y,z+1))
|
||||
dc->flags|=DCF_SYMMETRY;
|
||||
else
|
||||
dc->flags&=~DCF_SYMMETRY;
|
||||
@@ -114,22 +114,25 @@ public U0 Sprite3(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,Bool just_one=FALSE)
|
||||
Free(img);
|
||||
break;
|
||||
case SPT_RECT:
|
||||
GrRect3(dc,tempg->pp.x1+x,tempg->pp.y1+y,z,tempg->pp.x2-tempg->pp.x1,tempg->pp.y2-tempg->pp.y1);
|
||||
GrRect3(dc,tempg->pp.x1+x,tempg->pp.y1+y,z,
|
||||
tempg->pp.x2-tempg->pp.x1,tempg->pp.y2-tempg->pp.y1);
|
||||
break;
|
||||
case SPT_ROTATED_RECT:
|
||||
x1=tempg->ppa.x1+x;
|
||||
y1=tempg->ppa.y1+y;
|
||||
z1=z;
|
||||
GrRot(dc->r,&x1,&y1,&z1);
|
||||
Mat4x4MulXYZ(dc->r,&x1,&y1,&z1);
|
||||
old_r=dc->r;
|
||||
dc->flags|=DCF_TRANSFORMATION;
|
||||
r2=GrRotZNew(-tempg->ppa.angle);
|
||||
GrSetTranslation(r2,x1,y1,z1);
|
||||
GrSetRotMat(dc,GrMulMat(old_r,r2));
|
||||
GrRect3(dc,0,0,0,tempg->ppa.x2-tempg->ppa.x1,tempg->ppa.y2-tempg->ppa.y1);
|
||||
r2=Mat4x4IdentNew;
|
||||
Mat4x4RotZ(r2,-tempg->ppa.angle);
|
||||
Mat4x4TranslationEqu(r2,x1,y1,z1);
|
||||
DCMat4x4Set(dc,Mat4x4MulMat4x4New(old_r,r2));
|
||||
GrRect3(dc,0,0,0,
|
||||
tempg->ppa.x2-tempg->ppa.x1,tempg->ppa.y2-tempg->ppa.y1);
|
||||
Free(dc->r);
|
||||
Free(r2);
|
||||
GrSetRotMat(dc,old_r);
|
||||
DCMat4x4Set(dc,old_r);
|
||||
dc->flags=dc->flags&~DCF_TRANSFORMATION|old_flags;
|
||||
break;
|
||||
case SPT_CIRCLE:
|
||||
@@ -137,11 +140,11 @@ public U0 Sprite3(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,Bool just_one=FALSE)
|
||||
break;
|
||||
case SPT_ELLIPSE:
|
||||
GrEllipse3(dc,tempg->pwha.x1+x,tempg->pwha.y1+y,z,tempg->pwha.width,
|
||||
tempg->pwha.height,tempg->pwha.angle);
|
||||
tempg->pwha.height,tempg->pwha.angle);
|
||||
break;
|
||||
case SPT_POLYGON:
|
||||
GrRegPoly3(dc,tempg->pwhas.x1+x,tempg->pwhas.y1+y,z,tempg->pwhas.width,
|
||||
tempg->pwhas.height,tempg->pwhas.sides,tempg->pwhas.angle);
|
||||
tempg->pwhas.height,tempg->pwhas.sides,tempg->pwhas.angle);
|
||||
break;
|
||||
case SPT_POLYLINE:
|
||||
ptr=&tempg->nu.u;
|
||||
@@ -202,7 +205,7 @@ public U0 Sprite3(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,Bool just_one=FALSE)
|
||||
p->z+=z;
|
||||
}
|
||||
Gr3Mesh(dc,tempg->mu.vertex_cnt,&tempg->mu.u,tempg->mu.tri_cnt,
|
||||
(&tempg->mu.u)(U8 *)+sizeof(CD3I32)*tempg->mu.vertex_cnt);
|
||||
(&tempg->mu.u)(U8 *)+sizeof(CD3I32)*tempg->mu.vertex_cnt);
|
||||
p=&tempg->mu.u;
|
||||
for (i=0;i<tempg->mu.vertex_cnt;i++,p++) {
|
||||
p->x-=x;
|
||||
@@ -230,7 +233,7 @@ public U0 Sprite3(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,Bool just_one=FALSE)
|
||||
p->z+=z1;
|
||||
}
|
||||
Gr3Mesh(dc,tempg->pmu.vertex_cnt,&tempg->pmu.u,tempg->pmu.tri_cnt,
|
||||
(&tempg->pmu.u)(U8 *)+sizeof(CD3I32)*tempg->pmu.vertex_cnt);
|
||||
(&tempg->pmu.u)(U8 *)+sizeof(CD3I32)*tempg->pmu.vertex_cnt);
|
||||
p=&tempg->pmu.u;
|
||||
for (i=0;i<tempg->pmu.vertex_cnt;i++,p++) {
|
||||
p->x-=x1;
|
||||
@@ -244,6 +247,11 @@ public U0 Sprite3(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,Bool just_one=FALSE)
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (dc->flags & DCF_LOCATE_NEAREST && dc->dist<dc->nearest_dist) {
|
||||
dc->nearest_dist=dc->dist;
|
||||
dc->nearest_sprite_elem_num=cur_sprite_elem_num;
|
||||
}
|
||||
cur_sprite_elem_num++;
|
||||
if (just_one) break;
|
||||
tempg(U8 *)+=SpriteElemSize(tempg);
|
||||
}
|
||||
@@ -257,7 +265,7 @@ public U0 Sprite3(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,Bool just_one=FALSE)
|
||||
public U0 Sprite3B(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems)
|
||||
{//Plot a sprite into a CDC, post transform xyz translation.
|
||||
I64 old_x=dc->x,old_y=dc->y,old_z=dc->z,
|
||||
old_flags=dc->flags&DCF_TRANSFORMATION;
|
||||
old_flags=dc->flags&DCF_TRANSFORMATION;
|
||||
dc->x=x; dc->y=y; dc->z=z;
|
||||
dc->flags|=DCF_TRANSFORMATION;
|
||||
Sprite3(dc,0,0,0,elems);
|
||||
@@ -267,14 +275,13 @@ public U0 Sprite3B(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems)
|
||||
|
||||
public U0 SpriteMat3B(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,I64 *m)
|
||||
{//Plot rotated by matrix.
|
||||
I64 *old_r=dc->r,old_m[16],
|
||||
old_flags=dc->flags&DCF_TRANSFORMATION;
|
||||
I64 r[16],*old_r=dc->r,old_m[16],
|
||||
old_flags=dc->flags&DCF_TRANSFORMATION;
|
||||
MemCpy(old_m,m,16*sizeof(I64));
|
||||
dc->flags|=DCF_TRANSFORMATION;
|
||||
GrAddTranslation(m,x,y,z);
|
||||
dc->r=GrMulMat(old_r,m);
|
||||
Mat4x4TranslationAdd(m,x,y,z);
|
||||
dc->r=Mat4x4MulMat4x4Equ(r,old_r,m);
|
||||
Sprite3(dc,0,0,0,elems);
|
||||
Free(dc->r);
|
||||
dc->r=old_r;
|
||||
MemCpy(m,old_m,16*sizeof(I64));
|
||||
dc->flags=dc->flags&~DCF_TRANSFORMATION|old_flags;
|
||||
@@ -282,23 +289,26 @@ public U0 SpriteMat3B(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,I64 *m)
|
||||
|
||||
public U0 SpriteX3B(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,F64 è=0)
|
||||
{//Plot rotated around X axis.
|
||||
I64 *r=GrRotXNew(è);
|
||||
I64 r[16];
|
||||
Mat4x4IdentEqu(r);
|
||||
Mat4x4RotX(r,è);
|
||||
SpriteMat3B(dc,x,y,z,elems,r);
|
||||
Free(r);
|
||||
}
|
||||
|
||||
public U0 SpriteY3B(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,F64 ê=0)
|
||||
{//Plot rotated around Y axis.
|
||||
I64 *r=GrRotYNew(ê);
|
||||
I64 r[16];
|
||||
Mat4x4IdentEqu(r);
|
||||
Mat4x4RotY(r,ê);
|
||||
SpriteMat3B(dc,x,y,z,elems,r);
|
||||
Free(r);
|
||||
}
|
||||
|
||||
public U0 SpriteZ3B(CDC *dc=gr.dc,I64 x,I64 y,I64 z,U8 *elems,F64 é=0)
|
||||
{//Plot rotated around Z axis.
|
||||
I64 *r=GrRotZNew(é);
|
||||
I64 r[16];
|
||||
Mat4x4IdentEqu(r);
|
||||
Mat4x4RotZ(r,é);
|
||||
SpriteMat3B(dc,x,y,z,elems,r);
|
||||
Free(r);
|
||||
}
|
||||
|
||||
public U0 SpriteExtents(U8 *elems,I64 *min_x=NULL,I64 *max_x=NULL,
|
||||
@@ -340,14 +350,14 @@ public U8 *SpriteInterpolate(U8 *elems0,U8 *elems1,F64 t)
|
||||
CD3I32 *p0,*p1,*pr;
|
||||
U8 *result;
|
||||
CSprite *tempg0=elems0-offset(CSprite.start),
|
||||
*tempg1=elems1-offset(CSprite.start),*tempgr;
|
||||
*tempg1=elems1-offset(CSprite.start),*tempgr;
|
||||
if (t<0.5) {
|
||||
i=SpriteSize(elems0),
|
||||
result=MAlloc(i);
|
||||
result=MAlloc(i);
|
||||
MemCpy(result,elems0,i);
|
||||
} else {
|
||||
i=SpriteSize(elems1),
|
||||
result=MAlloc(i);
|
||||
result=MAlloc(i);
|
||||
MemCpy(result,elems1,i);
|
||||
}
|
||||
tempgr=result-offset(CSprite.start);
|
||||
@@ -443,10 +453,10 @@ public U8 *SpriteInterpolate(U8 *elems0,U8 *elems1,F64 t)
|
||||
return result;
|
||||
}
|
||||
|
||||
#help_index "Graphics/Sprite;DolDoc/Output"
|
||||
#help_index "Graphics/Sprite;DolDoc/Output;StdOut/DolDoc"
|
||||
public CDocEntry *DocSprite(CDoc *doc=NULL,U8 *elems,U8 *fmt=NULL)
|
||||
{//Put a sprite into a document. You can, optionally, supply a fmt string
|
||||
//for $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.TXT"$ cmd with a %d for the bin_num.
|
||||
//for $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.TXT"$ cmd with a %d for the bin_num.
|
||||
I64 size;
|
||||
U8 *st;
|
||||
Bool unlock;
|
||||
|
||||
+20
-13
@@ -2,9 +2,9 @@
|
||||
#help_file "::/Doc/TextBase"
|
||||
|
||||
asm {
|
||||
USE64
|
||||
//************************************
|
||||
_TEXT_CHAR:://Bool TextChar(CTask *task,Bool allow_border=FALSE,I64 x,I64 y,I64 d);
|
||||
_TEXT_CHAR::
|
||||
//Bool TextChar(CTask *task,Bool allow_border=FALSE,I64 x,I64 y,I64 d);
|
||||
//Must be called 30fps in Fs->draw_it() callback.
|
||||
PUSH RBP
|
||||
MOV RBP,RSP
|
||||
@@ -81,7 +81,8 @@ _TEXT_CHAR:://Bool TextChar(CTask *task,Bool allow_border=FALSE,I64 x,I64 y,I64
|
||||
POP RBP
|
||||
RET1 40
|
||||
//************************************
|
||||
_TEXT_LEN_STR:://Bool TextLenStr(CTask *task,I64 x,I64 y,I64 len,I64 attr,U8 *s)
|
||||
_TEXT_LEN_STR::
|
||||
//Bool TextLenStr(CTask *task,I64 x,I64 y,I64 len,I64 attr,U8 *s)
|
||||
//Must be called 30fps in Fs->draw_it() callback.
|
||||
PUSH RBP
|
||||
MOV RBP,RSP
|
||||
@@ -156,7 +157,8 @@ _TEXT_LEN_STR:://Bool TextLenStr(CTask *task,I64 x,I64 y,I64 len,I64 attr,U8 *s)
|
||||
POP RBP
|
||||
RET1 48
|
||||
//************************************
|
||||
_TEXT_LEN_ATTR_STR:://Bool TextLenAttrStr(CTask *task,I64 x,I64 y,I64 len,U32 *_attr)
|
||||
_TEXT_LEN_ATTR_STR::
|
||||
//Bool TextLenAttrStr(CTask *task,I64 x,I64 y,I64 len,U32 *_attr)
|
||||
//Must be called 30fps in Fs->draw_it() callback.
|
||||
PUSH RBP
|
||||
MOV RBP,RSP
|
||||
@@ -307,23 +309,28 @@ _TEXT_LEN_ATTR:://Bool TextLenAttr(CTask *task,I64 x,I64 y,I64 len,I64 attr)
|
||||
POP RBP
|
||||
RET1 40
|
||||
}
|
||||
public _extern _TEXT_CHAR Bool TextChar(CTask *task,Bool allow_border=FALSE,I64 x,I64 y,I64 d); //Plot char. Must be called 30fps in Fs->draw_it() callback.
|
||||
public _extern _TEXT_LEN_STR Bool TextLenStr(CTask *task,I64 x,I64 y,I64 len,I64 attr,U8 *s); //Plot str with len. Must be called 30fps in Fs->draw_it() callback.
|
||||
public _extern _TEXT_LEN_ATTR_STR Bool TextLenAttrStr(CTask *task,I64 x,I64 y,I64 len,U32 *_attr); //Plot attr str with len. Must be called 30fps in Fs->draw_it() callback.
|
||||
public _extern _TEXT_LEN_ATTR Bool TextLenAttr(CTask *task,I64 x,I64 y,I64 len,I64 attr); //Plot attrs with len. Must be called 30fps in Fs->draw_it() callback.
|
||||
public _extern _TEXT_CHAR Bool TextChar(CTask *task,Bool allow_border=FALSE,
|
||||
I64 x,I64 y,I64 d); //Plot char. 30fps in Fs->draw_it() callback.
|
||||
public _extern _TEXT_LEN_STR Bool TextLenStr(CTask *task,I64 x,I64 y,I64 len,
|
||||
I64 attr,U8 *s); //Plot str with len. 30fps in Fs->draw_it() callback.
|
||||
public _extern _TEXT_LEN_ATTR_STR Bool TextLenAttrStr(CTask *task,I64 x,I64 y,
|
||||
I64 len,U32 *_attr); //Plot attr str with len. 30fps in Fs->draw_it() callback.
|
||||
public _extern _TEXT_LEN_ATTR Bool TextLenAttr(CTask *task,I64 x,I64 y,I64 len,
|
||||
I64 attr); //Plot attrs with len. 30fps in Fs->draw_it() callback.
|
||||
|
||||
public U0 TextPrint(CTask *task,I64 x,I64 y,I64 attr,U8 *fmt,...)
|
||||
{//Plot chars. Must be called 30fps in Fs->draw_it() callback.
|
||||
{//Plot chars. 30fps in Fs->draw_it() callback.
|
||||
//You probably want $LK,"GrPrint",A="MN:GrPrint"$() or just $LK,"Print",A="MN:Print"$().
|
||||
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv);
|
||||
TextLenStr(task,x,y,StrLen(buf),attr<<8,buf);
|
||||
Free(buf);
|
||||
}
|
||||
|
||||
public U0 TextBorder(CTask *task=NULL,I64 l,I64 r,I64 t,I64 b,I64 attr,Bool solid)
|
||||
{//Plot border square. Must be called 30fps in Fs->draw_it() callback.
|
||||
public U0 TextBorder(CTask *task=NULL,
|
||||
I64 l,I64 r,I64 t,I64 b,I64 attr,Bool solid)
|
||||
{//Plot border square. 30fps in Fs->draw_it() callback.
|
||||
//Draws window borders or DolDoc text button borders.
|
||||
//Set task=sys_winmgr_task for no clipping.
|
||||
//Set task=sys_winmgr_task for no clipping.
|
||||
I64 i;
|
||||
if (!task) task=Fs;
|
||||
attr<<=8;
|
||||
@@ -357,7 +364,7 @@ public U0 TextBorder(CTask *task=NULL,I64 l,I64 r,I64 t,I64 b,I64 attr,Bool soli
|
||||
}
|
||||
|
||||
public U0 TextRect(I64 l,I64 r,I64 t,I64 b,I64 d)
|
||||
{//Fill text rect. Must be called 30fps in Fs->draw_it() callback.
|
||||
{//Fill text rect. 30fps in Fs->draw_it() callback.
|
||||
I64 y,w;
|
||||
if (l>r || t>b) return;
|
||||
if (t<0) t=0;
|
||||
|
||||
+21
-18
@@ -1,4 +1,4 @@
|
||||
#help_index "Graphics/Sprite"
|
||||
#help_index "Graphics/Sprite;Sprites"
|
||||
|
||||
#define GBM_EXIT 0
|
||||
#define GBM_MAIN_MENU 1
|
||||
@@ -43,7 +43,7 @@ GrInit4;
|
||||
I64 PopUpSpriteBitMap(CColorROPU32 color,I64 width)
|
||||
{
|
||||
I64 i;
|
||||
U8 *st1,*st2,buf[136];
|
||||
U8 *st1,*st2,buf[STR_LEN];
|
||||
CDoc *doc=DocNew;
|
||||
|
||||
Color2Str(buf,color);
|
||||
@@ -98,11 +98,12 @@ U0 GrBitMapEdPrepPersistentDC(CDC *dc,I64 xx1,I64 yy1,CDC *img)
|
||||
GrBlot(dc,xx1,yy1,img);
|
||||
}
|
||||
|
||||
U0 GrBitMapEdTrimToExtents(CDC **_img,I64 *_xx1,I64 *_yy1,I64 *_xx2,I64 *_yy2,CColorROPU32 bkcolor)
|
||||
U0 GrBitMapEdTrimToExtents(CDC **_img,I64 *_xx1,I64 *_yy1,
|
||||
I64 *_xx2,I64 *_yy2,CColorROPU32 bkcolor)
|
||||
{
|
||||
CDC *img=*_img;
|
||||
I64 i,c,
|
||||
x1=0,y1=0,x2=img->width-1,y2=img->height-1; //inclusive
|
||||
x1=0,y1=0,x2=img->width-1,y2=img->height-1; //inclusive
|
||||
while (y1<y2) {
|
||||
for (i=x1;i<=x2;i++) {
|
||||
c=GrPeek(img,i,y1);
|
||||
@@ -111,7 +112,7 @@ U0 GrBitMapEdTrimToExtents(CDC **_img,I64 *_xx1,I64 *_yy1,I64 *_xx2,I64 *_yy2,CC
|
||||
y1++;
|
||||
}
|
||||
|
||||
tr_y2:
|
||||
tr_y2:
|
||||
while (y1<y2) {
|
||||
for (i=x1;i<=x2;i++) {
|
||||
c=GrPeek(img,i,y2);
|
||||
@@ -120,7 +121,7 @@ tr_y2:
|
||||
y2--;
|
||||
}
|
||||
|
||||
tr_x1:
|
||||
tr_x1:
|
||||
while (x1<x2) {
|
||||
for (i=y1;i<=y2;i++) {
|
||||
c=GrPeek(img,x1,i);
|
||||
@@ -129,7 +130,7 @@ tr_x1:
|
||||
x1++;
|
||||
}
|
||||
|
||||
tr_x2:
|
||||
tr_x2:
|
||||
while (x1<x2) {
|
||||
for (i=y1;i<=y2;i++) {
|
||||
c=GrPeek(img,x2,i);
|
||||
@@ -138,14 +139,15 @@ tr_x2:
|
||||
x2--;
|
||||
}
|
||||
|
||||
tr_done:
|
||||
tr_done:
|
||||
*_img=DCExtract(img,x1,y1,x2,y2);
|
||||
*_xx1+=x1; *_yy1+=y1;
|
||||
*_xx2+=x2-(img->width-1); *_yy2+=y2-(img->height-1); //not inclusive
|
||||
DCDel(img);
|
||||
}
|
||||
|
||||
U0 GrBitMapEdAddOutline(CDC *img,I64 width,CColorROPU32 color,CColorROPU32 bkcolor)
|
||||
U0 GrBitMapEdAddOutline(CDC *img,I64 width,
|
||||
CColorROPU32 color,CColorROPU32 bkcolor)
|
||||
{
|
||||
I64 i,j,k,c;
|
||||
CColorROPU32 old_color;
|
||||
@@ -197,10 +199,11 @@ U0 GrBitMapEdEtch(CDC *img,I64 width,CColorROPU32 bkcolor)
|
||||
}
|
||||
}
|
||||
|
||||
I64 SpriteBitMapEd(CDoc *,CDocEntry *doc_e,CDC *dc,I64 *_xx1,I64 *_yy1,I64 *_xx2,I64 *_yy2,CDC **_img,CColorROPU32 bkcolor)
|
||||
I64 SpriteBitMapEd(CDoc *,CDocEntry *doc_e,CDC *dc,I64 *_xx1,I64 *_yy1,
|
||||
I64 *_xx2,I64 *_yy2,CDC **_img,CColorROPU32 bkcolor)
|
||||
{
|
||||
I64 i,j,mode=GBM_LINE,color=BLACK,width=1,msg_code,a1,a2,x1,y1,x11,y11,x22,y22,
|
||||
result,xx1=*_xx1,yy1=*_yy1,xx2=*_xx2,yy2=*_yy2,
|
||||
I64 i,j,mode=GBM_LINE,color=BLACK,width=1,msg_code,a1,a2,x1,y1,x11,y11,
|
||||
x22,y22,result,xx1=*_xx1,yy1=*_yy1,xx2=*_xx2,yy2=*_yy2,
|
||||
old_de_flags=doc_e->de_flags;
|
||||
Bool down=FALSE;
|
||||
U8 *st=NULL;
|
||||
@@ -220,8 +223,8 @@ I64 SpriteBitMapEd(CDoc *,CDocEntry *doc_e,CDC *dc,I64 *_xx1,I64 *_yy1,I64 *_xx2
|
||||
dc->pen_width=1;
|
||||
GrBorder(dc,xx1-1,yy1-1,xx2,yy2);//This is done little bit too often.
|
||||
|
||||
while (msg_code=ScanMsg(&a1,&a2,1<<MSG_IP_L_DOWN|1<<MSG_IP_L_UP|1<<MSG_IP_R_DOWN|
|
||||
1<<MSG_IP_MOVE|1<<MSG_KEY_DOWN)) {
|
||||
while (msg_code=ScanMsg(&a1,&a2,1<<MSG_IP_L_DOWN|1<<MSG_IP_L_UP|
|
||||
1<<MSG_IP_R_DOWN|1<<MSG_IP_MOVE|1<<MSG_KEY_DOWN)) {
|
||||
switch (msg_code) {
|
||||
case MSG_KEY_DOWN:
|
||||
switch (a1) {
|
||||
@@ -232,7 +235,7 @@ I64 SpriteBitMapEd(CDoc *,CDocEntry *doc_e,CDC *dc,I64 *_xx1,I64 *_yy1,I64 *_xx2
|
||||
result=GE_CONT;
|
||||
goto bm_key_up_done;
|
||||
case 'c': //eye-dropper
|
||||
dc2=DCCaptureScreen(FALSE);
|
||||
dc2=DCScreenCapture(FALSE);
|
||||
color=GrPeek(dc2,ip.pos.x,ip.pos.y)^15;//Mouse cursor is XORed.
|
||||
DCDel(dc2);
|
||||
break;
|
||||
@@ -299,14 +302,14 @@ bm_menu:
|
||||
|
||||
case GBM_SAVE_BMP:
|
||||
*filename.name=0;
|
||||
if (DocFormDo(&filename) && *filename.name)
|
||||
if (DocForm(&filename) && *filename.name)
|
||||
BMPWrite(filename.name,img);
|
||||
goto bm_menu;
|
||||
|
||||
case GBM_SAVE_GRA:
|
||||
*filename.name=0;
|
||||
if (DocFormDo(&filename) && *filename.name)
|
||||
GRAWrite(filename.name,img);
|
||||
if (DocForm(&filename) && *filename.name)
|
||||
GRAWrite(filename.name,img,DCSF_COMPRESSED|DCSF_PALETTE_GET);
|
||||
goto bm_menu;
|
||||
|
||||
case GBM_DITHER_COLOR:
|
||||
|
||||
+162
-159
@@ -1,8 +1,8 @@
|
||||
#help_index "Graphics/Sprite"
|
||||
#help_index "Graphics/Sprite;Sprites"
|
||||
|
||||
U0 SpriteElem2Code(CDoc *doc,CSprite *tempg)
|
||||
{
|
||||
U8 buf1[256],buf2[136];
|
||||
U8 buf1[STR_LEN],buf2[STR_LEN];
|
||||
I32 *ptr;
|
||||
I64 i,j,k,col,width_internal;
|
||||
CD3I32 *p;
|
||||
@@ -12,11 +12,12 @@ U0 SpriteElem2Code(CDoc *doc,CSprite *tempg)
|
||||
switch (tempg->type) {
|
||||
case SPT_COLOR:
|
||||
DocPrint(doc,"{%s}",
|
||||
Color2Str(buf1,tempg->c.color));
|
||||
Color2Str(buf1,tempg->c.color));
|
||||
break;
|
||||
case SPT_DITHER_COLOR:
|
||||
DocPrint(doc,"{%s}",
|
||||
Color2Str(buf2,ROPF_DITHER|tempg->d.dither_color.u8[0]|tempg->d.dither_color.u8[1]<<COLORROP_BITS));
|
||||
Color2Str(buf2,ROPF_DITHER|tempg->d.dither_color.u8[0]|
|
||||
tempg->d.dither_color.u8[1]<<COLORROP_BITS));
|
||||
break;
|
||||
case SPT_TRANSFORM_ON:
|
||||
DocPrint(doc,"{ON}");
|
||||
@@ -27,16 +28,17 @@ U0 SpriteElem2Code(CDoc *doc,CSprite *tempg)
|
||||
case SPT_LINE:
|
||||
case SPT_ARROW:
|
||||
case SPT_PLANAR_SYMMETRY:
|
||||
DocPrint(doc,"{(%d,%d),(%d,%d)}",tempg->pp.x1,tempg->pp.y1,tempg->pp.x2,tempg->pp.y2);
|
||||
DocPrint(doc,"{(%d,%d),(%d,%d)}",tempg->pp.x1,tempg->pp.y1,
|
||||
tempg->pp.x2,tempg->pp.y2);
|
||||
break;
|
||||
case SPT_RECT:
|
||||
DocPrint(doc,"{(%d,%d):(%d,%d)}",tempg->pp.x1,tempg->pp.y1,
|
||||
tempg->pp.x2-tempg->pp.x1,tempg->pp.y2-tempg->pp.y1);
|
||||
tempg->pp.x2-tempg->pp.x1,tempg->pp.y2-tempg->pp.y1);
|
||||
break;
|
||||
case SPT_ROTATED_RECT:
|
||||
DocPrint(doc,"{(%d,%d):(%d,%d),%0.4f}",tempg->ppa.x1,tempg->ppa.y1,
|
||||
tempg->ppa.x2-tempg->ppa.x1,tempg->ppa.y2-tempg->ppa.y1,
|
||||
180/ã*Wrap(tempg->ppa.angle));
|
||||
tempg->ppa.x2-tempg->ppa.x1,tempg->ppa.y2-tempg->ppa.y1,
|
||||
180/ã*Wrap(tempg->ppa.angle));
|
||||
break;
|
||||
case SPT_PT:
|
||||
case SPT_FLOOD_FILL:
|
||||
@@ -54,12 +56,13 @@ U0 SpriteElem2Code(CDoc *doc,CSprite *tempg)
|
||||
break;
|
||||
case SPT_ELLIPSE:
|
||||
DocPrint(doc,"{(%d,%d):(%d,%d),%0.4f}",tempg->pwha.x1,tempg->pwha.y1,
|
||||
tempg->pwha.width,tempg->pwha.height,180/ã*Wrap(tempg->pwha.angle));
|
||||
tempg->pwha.width,tempg->pwha.height,180/ã*Wrap(tempg->pwha.angle));
|
||||
break;
|
||||
case SPT_POLYGON:
|
||||
DocPrint(doc,"{%d,(%d,%d):(%d,%d),%0.4f}",tempg->pwhas.sides,
|
||||
tempg->pwhas.x1,tempg->pwhas.y1,tempg->pwhas.width,tempg->pwhas.height,
|
||||
180/ã*Wrap(tempg->pwhas.angle));
|
||||
tempg->pwhas.x1,tempg->pwhas.y1,
|
||||
tempg->pwhas.width,tempg->pwhas.height,
|
||||
180/ã*Wrap(tempg->pwhas.angle));
|
||||
break;
|
||||
case SPT_TEXT:
|
||||
case SPT_TEXT_BOX:
|
||||
@@ -109,7 +112,7 @@ U0 SpriteElem2Code(CDoc *doc,CSprite *tempg)
|
||||
break;
|
||||
case SPT_BITMAP:
|
||||
DocPrint(doc,"{(%d,%d):(%d,%d),\n",tempg->pwhu.x1,tempg->pwhu.y1,
|
||||
tempg->pwhu.width,tempg->pwhu.height);
|
||||
tempg->pwhu.width,tempg->pwhu.height);
|
||||
width_internal=(tempg->pwhu.width+7)&~7;
|
||||
if (width_internal<80)
|
||||
k=width_internal;
|
||||
@@ -148,7 +151,7 @@ U0 SpriteElem2Code(CDoc *doc,CSprite *tempg)
|
||||
tri=p;
|
||||
for (i=0;i<tempg->mu.tri_cnt;i++,tri++) {
|
||||
DocPrint(doc,"(%s,%d,%d,%d)",Color2Str(buf1,tri->color),
|
||||
tri->nums[0],tri->nums[1],tri->nums[2]);
|
||||
tri->nums[0],tri->nums[1],tri->nums[2]);
|
||||
if (i+1<tempg->mu.tri_cnt) DocPrint(doc,",");
|
||||
if (++col>=3 && i+1<tempg->mu.tri_cnt) {
|
||||
DocPrint(doc,"\n");
|
||||
@@ -173,7 +176,7 @@ U0 SpriteElem2Code(CDoc *doc,CSprite *tempg)
|
||||
tri=p;
|
||||
for (i=0;i<tempg->pmu.tri_cnt;i++,tri++) {
|
||||
DocPrint(doc,"(%s,%d,%d,%d)",Color2Str(buf1,tri->color),
|
||||
tri->nums[0],tri->nums[1],tri->nums[2]);
|
||||
tri->nums[0],tri->nums[1],tri->nums[2]);
|
||||
if (i+1<tempg->pmu.tri_cnt) DocPrint(doc,",");
|
||||
if (++col>=3 && i+1<tempg->pmu.tri_cnt) {
|
||||
DocPrint(doc,"\n");
|
||||
@@ -195,7 +198,7 @@ public U0 Sprite2Code(CDoc *doc=NULL,U8 *elems)
|
||||
}
|
||||
}
|
||||
|
||||
CSprite *Code2SpriteElem(CLex *lx,I64 type)
|
||||
CSprite *Code2SpriteElem(CCmpCtrl *cc,I64 type)
|
||||
{
|
||||
I64 i,num1,num2,size;
|
||||
CSprite *result,g;
|
||||
@@ -209,10 +212,10 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
|
||||
sub_switch_start:
|
||||
case SPT_COLOR:
|
||||
case SPT_DITHER_COLOR:
|
||||
st=LexFirstRem(lx,"}");
|
||||
st=LexFirstRem(cc,"}");
|
||||
color=Str2ColorU32(st);
|
||||
Free(st);
|
||||
Lex(lx); //Skip color
|
||||
Lex(cc); //Skip color
|
||||
g.c.color=color.c0.color;
|
||||
if (color&ROPF_DITHER) {
|
||||
g.d.dither_color.u8[1]=color.c1.color;
|
||||
@@ -222,8 +225,8 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
|
||||
break;
|
||||
case SPT_TRANSFORM_ON:
|
||||
case SPT_TRANSFORM_OFF:
|
||||
Lex(lx); //Skip {
|
||||
if (LexExpressionI64(lx))
|
||||
Lex(cc); //Skip {
|
||||
if (LexExpressionI64(cc))
|
||||
g.type=SPT_TRANSFORM_ON;
|
||||
else
|
||||
g.type=SPT_TRANSFORM_OFF;
|
||||
@@ -231,44 +234,44 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
|
||||
case SPT_LINE:
|
||||
case SPT_ARROW:
|
||||
case SPT_PLANAR_SYMMETRY:
|
||||
Lex(lx); //Skip {
|
||||
Lex(cc); //Skip {
|
||||
g.type=type;
|
||||
LexD2I32(lx,&g.pp.x1);
|
||||
if (lx->token!=',')
|
||||
LexExcept(lx,"expecting ',' at ");
|
||||
Lex(lx); //Skip ,
|
||||
LexD2I32(lx,&g.pp.x2);
|
||||
LexD2I32(cc,&g.pp.x1);
|
||||
if (cc->token!=',')
|
||||
LexExcept(cc,"expecting ',' at ");
|
||||
Lex(cc); //Skip ,
|
||||
LexD2I32(cc,&g.pp.x2);
|
||||
break;
|
||||
case SPT_RECT:
|
||||
case SPT_ROTATED_RECT:
|
||||
Lex(lx); //Skip {
|
||||
LexD2I32(lx,&g.pp.x1);
|
||||
if (lx->token!=':')
|
||||
LexExcept(lx,"expecting ':' at ");
|
||||
Lex(lx); //Skip :
|
||||
LexD2I32(lx,&g.pp.x2);
|
||||
Lex(cc); //Skip {
|
||||
LexD2I32(cc,&g.pp.x1);
|
||||
if (cc->token!=':')
|
||||
LexExcept(cc,"expecting ':' at ");
|
||||
Lex(cc); //Skip :
|
||||
LexD2I32(cc,&g.pp.x2);
|
||||
g.ppa.x2+=g.pp.x1;
|
||||
g.ppa.y2+=g.pp.y1;
|
||||
if (lx->token==',') {
|
||||
Lex(lx); //Skip ,
|
||||
g.ppa.angle=ã/180*LexExpressionF64(lx);
|
||||
if (cc->token==',') {
|
||||
Lex(cc); //Skip ,
|
||||
g.ppa.angle=ã/180*LexExpressionF64(cc);
|
||||
g.type=SPT_ROTATED_RECT;
|
||||
} else
|
||||
g.type=SPT_RECT;
|
||||
break;
|
||||
case SPT_PT:
|
||||
case SPT_SHIFT:
|
||||
Lex(lx); //Skip {
|
||||
Lex(cc); //Skip {
|
||||
g.type=type;
|
||||
LexD2I32(lx,&g.p.x1);
|
||||
LexD2I32(cc,&g.p.x1);
|
||||
break;
|
||||
case SPT_FLOOD_FILL:
|
||||
case SPT_FLOOD_FILL_NOT:
|
||||
Lex(lx); //Skip {
|
||||
LexD2I32(lx,&g.p.x1);
|
||||
if (lx->token==',') {
|
||||
Lex(lx); //Skip ,
|
||||
i=LexExpressionI64(lx);
|
||||
Lex(cc); //Skip {
|
||||
LexD2I32(cc,&g.p.x1);
|
||||
if (cc->token==',') {
|
||||
Lex(cc); //Skip ,
|
||||
i=LexExpressionI64(cc);
|
||||
} else
|
||||
i=0;
|
||||
if (i)
|
||||
@@ -277,36 +280,36 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
|
||||
g.type=SPT_FLOOD_FILL;
|
||||
break;
|
||||
case SPT_WIDTH:
|
||||
Lex(lx); //Skip {
|
||||
g.w.width=LexExpressionI64(lx);
|
||||
Lex(cc); //Skip {
|
||||
g.w.width=LexExpressionI64(cc);
|
||||
g.type=SPT_WIDTH;
|
||||
break;
|
||||
case SPT_CIRCLE:
|
||||
Lex(lx); //Skip {
|
||||
Lex(cc); //Skip {
|
||||
g.type=SPT_CIRCLE;
|
||||
LexD2I32(lx,&g.pr.x1);
|
||||
if (lx->token!=':')
|
||||
LexExcept(lx,"expecting ':' at ");
|
||||
Lex(lx); //Skip :
|
||||
g.pr.radius=LexExpressionI64(lx);
|
||||
LexD2I32(cc,&g.pr.x1);
|
||||
if (cc->token!=':')
|
||||
LexExcept(cc,"expecting ':' at ");
|
||||
Lex(cc); //Skip :
|
||||
g.pr.radius=LexExpressionI64(cc);
|
||||
break;
|
||||
case SPT_POLYGON:
|
||||
Lex(lx); //Skip {
|
||||
g.pwhas.sides=LexExpressionI64(lx);
|
||||
if (lx->token!=',')
|
||||
LexExcept(lx,"expecting ',' at ");
|
||||
Lex(cc); //Skip {
|
||||
g.pwhas.sides=LexExpressionI64(cc);
|
||||
if (cc->token!=',')
|
||||
LexExcept(cc,"expecting ',' at ");
|
||||
case SPT_ELLIPSE:
|
||||
Lex(lx); //Skip {
|
||||
Lex(cc); //Skip {
|
||||
g.type=type;
|
||||
LexD2I32(lx,&g.pwha.x1);
|
||||
if (lx->token!=':')
|
||||
LexExcept(lx,"expecting ':' at ");
|
||||
Lex(lx); //Skip :
|
||||
LexD2I32(lx,&g.pwha.width);
|
||||
if (lx->token!=',')
|
||||
LexExcept(lx,"expecting ',' at ");
|
||||
Lex(lx); //Skip ,
|
||||
g.pwha.angle=ã/180*LexExpressionF64(lx);
|
||||
LexD2I32(cc,&g.pwha.x1);
|
||||
if (cc->token!=':')
|
||||
LexExcept(cc,"expecting ':' at ");
|
||||
Lex(cc); //Skip :
|
||||
LexD2I32(cc,&g.pwha.width);
|
||||
if (cc->token!=',')
|
||||
LexExcept(cc,"expecting ',' at ");
|
||||
Lex(cc); //Skip ,
|
||||
g.pwha.angle=ã/180*LexExpressionF64(cc);
|
||||
break;
|
||||
sub_switch_end:
|
||||
size=SpriteElemSize(&g)+offset(CSprite.start);
|
||||
@@ -316,15 +319,15 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
|
||||
case SPT_TEXT:
|
||||
case SPT_TEXT_BOX:
|
||||
case SPT_TEXT_DIAMOND:
|
||||
Lex(lx); //Skip {
|
||||
Lex(cc); //Skip {
|
||||
g.type=type;
|
||||
LexD2I32(lx,&g.ps.x1);
|
||||
if (lx->token!=',')
|
||||
LexExcept(lx,"expecting ',' at ");
|
||||
if (Lex(lx)==TK_STR) //Skip ,
|
||||
st=LexExtStr(lx);
|
||||
LexD2I32(cc,&g.ps.x1);
|
||||
if (cc->token!=',')
|
||||
LexExcept(cc,"expecting ',' at ");
|
||||
if (Lex(cc)==TK_STR) //Skip ,
|
||||
st=LexExtStr(cc);
|
||||
else
|
||||
LexExcept(lx,"expecting string at ");
|
||||
LexExcept(cc,"expecting string at ");
|
||||
size=SpriteElemQuedBaseSize(type);
|
||||
i=StrLen(st)+1;
|
||||
result=MAlloc(size+i);
|
||||
@@ -333,19 +336,19 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
|
||||
Free(st);
|
||||
break;
|
||||
case SPT_POLYLINE:
|
||||
Lex(lx); //Skip {
|
||||
Lex(cc); //Skip {
|
||||
g.type=SPT_POLYLINE;
|
||||
QueInit(&rootp);
|
||||
while (lx->token=='(') {
|
||||
while (cc->token=='(') {
|
||||
tempp=CAlloc(sizeof(CQueD3I32));
|
||||
LexD2I32(lx,&tempp->p);
|
||||
LexD2I32(cc,&tempp->p);
|
||||
QueIns(tempp,rootp.last);
|
||||
g.nu.num++;
|
||||
if (lx->token==',')
|
||||
Lex(lx); //Skip ,
|
||||
if (cc->token==',')
|
||||
Lex(cc); //Skip ,
|
||||
}
|
||||
if (g.nu.num<2)
|
||||
LexExcept(lx,"expecting point at ");
|
||||
LexExcept(cc,"expecting point at ");
|
||||
size=SpriteElemQuedBaseSize(SPT_POLYLINE);
|
||||
result=MAlloc(size+g.nu.num*sizeof(CD2I32));
|
||||
MemCpy(result,&g,size);
|
||||
@@ -363,21 +366,21 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
|
||||
case SPT_BSPLINE3:
|
||||
case SPT_BSPLINE2_CLOSED:
|
||||
case SPT_BSPLINE3_CLOSED:
|
||||
Lex(lx); //Skip {
|
||||
Lex(cc); //Skip {
|
||||
QueInit(&rootp);
|
||||
while (lx->token=='(') {
|
||||
while (cc->token=='(') {
|
||||
tempp=CAlloc(sizeof(CQueD3I32));
|
||||
LexD3I32(lx,&tempp->p);
|
||||
LexD3I32(cc,&tempp->p);
|
||||
QueIns(tempp,rootp.last);
|
||||
g.nu.num++;
|
||||
if (lx->token==',')
|
||||
Lex(lx); //Skip ,
|
||||
if (cc->token==',')
|
||||
Lex(cc); //Skip ,
|
||||
}
|
||||
if (g.nu.num<2)
|
||||
LexExcept(lx,"expecting point at ");
|
||||
LexExcept(cc,"expecting point at ");
|
||||
size=SpriteElemQuedBaseSize(type);
|
||||
result=MAlloc(size+g.nu.num*sizeof(CD3I32));
|
||||
if (LexExpressionI64(lx)) {
|
||||
if (LexExpressionI64(cc)) {
|
||||
if (type==SPT_BSPLINE2||type==SPT_BSPLINE2_CLOSED)
|
||||
g.type=SPT_BSPLINE2_CLOSED;
|
||||
else
|
||||
@@ -400,21 +403,21 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
|
||||
}
|
||||
break;
|
||||
case SPT_POLYPT:
|
||||
Lex(lx); //Skip {
|
||||
LexD2I32(lx,&g.npu.x);
|
||||
if (lx->token!=',')
|
||||
LexExcept(lx,"expecting ',' at ");
|
||||
Lex(cc); //Skip {
|
||||
LexD2I32(cc,&g.npu.x);
|
||||
if (cc->token!=',')
|
||||
LexExcept(cc,"expecting ',' at ");
|
||||
tempv=QueVectU8New;
|
||||
while (TRUE) {
|
||||
if (!(i=LexGetChar(lx)))
|
||||
LexExcept(lx,"expecting '}' at ");
|
||||
if (!(i=LexGetChar(cc)))
|
||||
LexExcept(cc,"expecting '}' at ");
|
||||
if (i=='}')
|
||||
break;
|
||||
if ('0'<=i<='7')
|
||||
QueVectU8Put(tempv,g.npu.num++,i-'0');
|
||||
}
|
||||
Bts(&lx->flags,Lf_USE_LAST_U16);
|
||||
Lex(lx); //Load '}'
|
||||
Bts(&cc->flags,CCf_USE_LAST_U16);
|
||||
Lex(cc); //Load '}'
|
||||
g.type=SPT_POLYPT;
|
||||
size=SpriteElemQuedBaseSize(SPT_POLYPT);
|
||||
result=CAlloc(size+(g.npu.num*3+7)>>3);
|
||||
@@ -425,19 +428,19 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
|
||||
QueVectU8Del(tempv);
|
||||
break;
|
||||
case SPT_BITMAP:
|
||||
Lex(lx); //Skip {
|
||||
LexD2I32(lx,&g.pwhu.x1);
|
||||
if (lx->token!=':')
|
||||
LexExcept(lx,"expecting ':' at ");
|
||||
Lex(lx); //Skip :
|
||||
LexD2I32(lx,&g.pwhu.width);
|
||||
if (lx->token!=',')
|
||||
LexExcept(lx,"expecting ',' at ");
|
||||
Lex(cc); //Skip {
|
||||
LexD2I32(cc,&g.pwhu.x1);
|
||||
if (cc->token!=':')
|
||||
LexExcept(cc,"expecting ':' at ");
|
||||
Lex(cc); //Skip :
|
||||
LexD2I32(cc,&g.pwhu.width);
|
||||
if (cc->token!=',')
|
||||
LexExcept(cc,"expecting ',' at ");
|
||||
tempv=QueVectU8New;
|
||||
num1=0;
|
||||
while (TRUE) {
|
||||
if (!(i=ToUpper(LexGetChar(lx))))
|
||||
LexExcept(lx,"expecting '}' at ");
|
||||
if (!(i=ToUpper(LexGetChar(cc))))
|
||||
LexExcept(cc,"expecting '}' at ");
|
||||
if (i=='}')
|
||||
break;
|
||||
if ('0'<=i<='9')
|
||||
@@ -449,8 +452,8 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
|
||||
else if (i=='_')
|
||||
QueVectU8Put(tempv,num1++,0);
|
||||
}
|
||||
Bts(&lx->flags,Lf_USE_LAST_U16);
|
||||
Lex(lx); //Load '}'
|
||||
Bts(&cc->flags,CCf_USE_LAST_U16);
|
||||
Lex(cc); //Load '}'
|
||||
g.type=SPT_BITMAP;
|
||||
size=SpriteElemQuedBaseSize(SPT_BITMAP);
|
||||
result=CAlloc(size+num1);
|
||||
@@ -462,62 +465,62 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
|
||||
break;
|
||||
case SPT_MESH:
|
||||
case SPT_SHIFTABLE_MESH:
|
||||
Lex(lx); //Skip {
|
||||
if (LexExpressionI64(lx)) {
|
||||
Lex(cc); //Skip {
|
||||
if (LexExpressionI64(cc)) {
|
||||
g.type=SPT_SHIFTABLE_MESH;
|
||||
if (lx->token!=',')
|
||||
LexExcept(lx,"expecting ',' at ");
|
||||
Lex(lx); //Skip ,
|
||||
LexD3I32(lx,&g.pmu.x);
|
||||
if (lx->token!=':')
|
||||
LexExcept(lx,"expecting ':' at ");
|
||||
Lex(lx); //Skip :
|
||||
if (cc->token!=',')
|
||||
LexExcept(cc,"expecting ',' at ");
|
||||
Lex(cc); //Skip ,
|
||||
LexD3I32(cc,&g.pmu.x);
|
||||
if (cc->token!=':')
|
||||
LexExcept(cc,"expecting ':' at ");
|
||||
Lex(cc); //Skip :
|
||||
} else {
|
||||
g.type=SPT_MESH;
|
||||
if (lx->token!=',')
|
||||
LexExcept(lx,"expecting ',' at ");
|
||||
Lex(lx); //Skip ,
|
||||
if (cc->token!=',')
|
||||
LexExcept(cc,"expecting ',' at ");
|
||||
Lex(cc); //Skip ,
|
||||
}
|
||||
num1=0;
|
||||
QueInit(&rootp);
|
||||
while (lx->token=='(') {
|
||||
while (cc->token=='(') {
|
||||
tempp=CAlloc(sizeof(CQueD3I32));
|
||||
LexD3I32(lx,&tempp->p);
|
||||
LexD3I32(cc,&tempp->p);
|
||||
QueIns(tempp,rootp.last);
|
||||
num1++;
|
||||
if (lx->token==',')
|
||||
Lex(lx); //Skip ,
|
||||
if (cc->token==',')
|
||||
Lex(cc); //Skip ,
|
||||
}
|
||||
if (lx->token!=':')
|
||||
LexExcept(lx,"expecting ':' at ");
|
||||
Lex(lx); //Skip :
|
||||
if (cc->token!=':')
|
||||
LexExcept(cc,"expecting ':' at ");
|
||||
Lex(cc); //Skip :
|
||||
num2=0;
|
||||
QueInit(&roott);
|
||||
while (lx->token=='(') {
|
||||
while (cc->token=='(') {
|
||||
tempt=CAlloc(sizeof(CQueMeshTri));
|
||||
st=LexFirstRem(lx,",");
|
||||
st=LexFirstRem(cc,",");
|
||||
tempt->color=Str2ColorU32(st);
|
||||
Free(st);
|
||||
Lex(lx); //Skip color
|
||||
if (lx->token!=',')
|
||||
LexExcept(lx,"expecting ',' at ");
|
||||
Lex(lx); //Skip ,
|
||||
tempt->nums[0]=LexExpressionI64(lx);
|
||||
if (lx->token!=',')
|
||||
LexExcept(lx,"expecting ',' at ");
|
||||
Lex(lx); //Skip ,
|
||||
tempt->nums[1]=LexExpressionI64(lx);
|
||||
if (lx->token!=',')
|
||||
LexExcept(lx,"expecting ',' at ");
|
||||
Lex(lx); //Skip ,
|
||||
tempt->nums[2]=LexExpressionI64(lx);
|
||||
if (lx->token!=')')
|
||||
LexExcept(lx,"expecting ')' at ");
|
||||
Lex(lx); //Skip )
|
||||
Lex(cc); //Skip color
|
||||
if (cc->token!=',')
|
||||
LexExcept(cc,"expecting ',' at ");
|
||||
Lex(cc); //Skip ,
|
||||
tempt->nums[0]=LexExpressionI64(cc);
|
||||
if (cc->token!=',')
|
||||
LexExcept(cc,"expecting ',' at ");
|
||||
Lex(cc); //Skip ,
|
||||
tempt->nums[1]=LexExpressionI64(cc);
|
||||
if (cc->token!=',')
|
||||
LexExcept(cc,"expecting ',' at ");
|
||||
Lex(cc); //Skip ,
|
||||
tempt->nums[2]=LexExpressionI64(cc);
|
||||
if (cc->token!=')')
|
||||
LexExcept(cc,"expecting ')' at ");
|
||||
Lex(cc); //Skip )
|
||||
QueIns(tempt,roott.last);
|
||||
num2++;
|
||||
if (lx->token==',')
|
||||
Lex(lx); //Skip ,
|
||||
if (cc->token==',')
|
||||
Lex(cc); //Skip ,
|
||||
}
|
||||
if (g.type==SPT_MESH) {
|
||||
g.mu.vertex_cnt=num1;
|
||||
@@ -549,10 +552,10 @@ CSprite *Code2SpriteElem(CLex *lx,I64 type)
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (lx->token!='}')
|
||||
LexExcept(lx,"expecting '}' at ");
|
||||
if (Lex(lx)!=';')
|
||||
LexExcept(lx,"expecting ';' at ");
|
||||
if (cc->token!='}')
|
||||
LexExcept(cc,"expecting '}' at ");
|
||||
if (Lex(cc)!=';')
|
||||
LexExcept(cc,"expecting ';' at ");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -561,24 +564,24 @@ public U8 *Code2Sprite(CDoc *doc,I64 *_size=NULL)
|
||||
CSprite root;
|
||||
U8 *result;
|
||||
Bool okay=TRUE,unlock_doc=DocLock(doc);
|
||||
CLex *lx=LexNew(,LF_DONT_FREE_BUF);
|
||||
CHashTable *old_hash_table_lst=lx->htc.hash_table_lst;
|
||||
CCmpCtrl *cc=CmpCtrlNew(,CCF_DONT_FREE_BUF);
|
||||
CHashTable *old_hash_table_lst=cc->htc.hash_table_lst;
|
||||
CHashGeneric *temph;
|
||||
I64 i,size=0;
|
||||
QueInit(&root);
|
||||
LexAttachDoc(lx,,doc);
|
||||
LexAttachDoc(cc,,doc);
|
||||
try {
|
||||
do {
|
||||
lx->htc.hash_table_lst=NULL;
|
||||
if (Lex(lx)==TK_IDENT && //Skip ;
|
||||
(temph=HashFind(lx->cur_str,gr.sprite_hash,SPHT_ELEM_CODE))) {
|
||||
cc->htc.hash_table_lst=NULL;
|
||||
if (Lex(cc)==TK_IDENT && //Skip ;
|
||||
(temph=HashFind(cc->cur_str,gr.sprite_hash,SPHT_ELEM_CODE))) {
|
||||
i=temph->user_data0;
|
||||
lx->htc.hash_table_lst=old_hash_table_lst;
|
||||
if (Lex(lx)=='{') //Skip ident
|
||||
QueIns(Code2SpriteElem(lx,i),root.last);
|
||||
} else if (lx->token)
|
||||
LexExcept(lx,"expecting sprite element type name at ");
|
||||
} while (lx->token);
|
||||
cc->htc.hash_table_lst=old_hash_table_lst;
|
||||
if (Lex(cc)=='{') //Skip ident
|
||||
QueIns(Code2SpriteElem(cc,i),root.last);
|
||||
} else if (cc->token)
|
||||
LexExcept(cc,"expecting sprite element type name at ");
|
||||
} while (cc->token);
|
||||
okay=TRUE;
|
||||
} catch {
|
||||
Fs->catch_except=TRUE;
|
||||
@@ -587,7 +590,7 @@ public U8 *Code2Sprite(CDoc *doc,I64 *_size=NULL)
|
||||
if (unlock_doc)
|
||||
DocUnlock(doc);
|
||||
if (okay) {
|
||||
LexDel(lx); //TODO: can crash
|
||||
CmpCtrlDel(cc); //TODO: can crash
|
||||
result=SpriteQue2Sprite(&root,&size);
|
||||
} else {
|
||||
result=NULL;
|
||||
|
||||
+83
-72
@@ -1,4 +1,4 @@
|
||||
#help_index "Graphics/Sprite"
|
||||
#help_index "Graphics/Sprite;Sprites"
|
||||
|
||||
Bool SpritePolyPtPlot(CSprite *root,I64 x,I64 y,I64)
|
||||
{
|
||||
@@ -10,7 +10,8 @@ Bool SpritePolyPtPlot(CSprite *root,I64 x,I64 y,I64)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CSprite *SpriteElemNum2QueEntry(CSprite *root,I64 elem_num,I64 *_x=NULL,I64 *_y=NULL)
|
||||
CSprite *SpriteElemNum2QueEntry(CSprite *root,I64 elem_num,
|
||||
I64 *_x=NULL,I64 *_y=NULL)
|
||||
{
|
||||
I64 xx=0,yy=0;
|
||||
CSprite *result=root->next;
|
||||
@@ -30,8 +31,8 @@ CSprite *Sprite2SpriteQue(U8 *elems)
|
||||
{
|
||||
I64 s;
|
||||
CSprite *result=CAlloc(sizeof(CSprite)),
|
||||
*tempg=elems-offset(CSprite.start),*tempg1;
|
||||
result->next=result->last=result;
|
||||
*tempg=elems-offset(CSprite.start),*tempg1;
|
||||
QueInit(result);
|
||||
while (tempg->type) {
|
||||
tempg1=MAlloc(SpriteElemSize(tempg)+offset(CSprite.start));
|
||||
s=SpriteElemSize(tempg);
|
||||
@@ -151,16 +152,16 @@ CSprite *SpriteTransformCircle(I64 r[4][4],CSprite *tempg)
|
||||
tempg1->type=SPT_ELLIPSE;
|
||||
|
||||
x=tempg->pr.x1; y=tempg->pr.y1; z=0;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
tempg1->pwha.x1=x;
|
||||
tempg1->pwha.y1=y;
|
||||
|
||||
x=radius; y=0; z=0;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
R2P(&m1,&a1,x,y);
|
||||
|
||||
x=0; y=radius; z=0;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
m2=Sqrt(x*x+y*y);
|
||||
|
||||
tempg1->pwha.width =ToI64(m1)/0x10000;
|
||||
@@ -181,7 +182,7 @@ CSprite *SpriteTransformEllipse(I64 r[4][4],CSprite *tempg)
|
||||
tempg1->pwhas.sides=tempg->pwhas.sides;
|
||||
|
||||
x=tempg->pwha.x1; y=tempg->pwha.y1; z=0;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
tempg1->pwha.x1=x;
|
||||
tempg1->pwha.y1=y;
|
||||
|
||||
@@ -191,13 +192,13 @@ CSprite *SpriteTransformEllipse(I64 r[4][4],CSprite *tempg)
|
||||
x=x_radius*c;
|
||||
y=x_radius*s;
|
||||
z=0;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
R2P(&m1,&a1,x,y);
|
||||
|
||||
x=-y_radius*s;
|
||||
y=y_radius*c;
|
||||
z=0;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
R2P(&m2,&a2,x,y);
|
||||
m2*=Abs(Sin(a2-a1));
|
||||
|
||||
@@ -214,13 +215,13 @@ CSprite *SpriteTransformRect(I64 r[4][4],CSprite *tempg,F64
|
||||
{
|
||||
I64 x,y,z,w,h;
|
||||
F64 m1,a1,m2,a2,s,c,
|
||||
x_radius=(tempg->pp.x2-tempg->pp.x1)<<16,
|
||||
y_radius=(tempg->pp.y2-tempg->pp.y1)<<16;
|
||||
x_radius=(tempg->pp.x2-tempg->pp.x1)<<16,
|
||||
y_radius=(tempg->pp.y2-tempg->pp.y1)<<16;
|
||||
CSprite *tempg1=CAlloc(SpriteElemQuedBaseSize(SPT_ROTATED_RECT));
|
||||
tempg1->type=SPT_ROTATED_RECT;
|
||||
|
||||
x=tempg->pp.x1; y=tempg->pp.y1; z=0;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
tempg1->ppa.x1=x;
|
||||
tempg1->ppa.y1=y;
|
||||
|
||||
@@ -230,13 +231,13 @@ CSprite *SpriteTransformRect(I64 r[4][4],CSprite *tempg,F64
|
||||
x=x_radius*c;
|
||||
y=x_radius*s;
|
||||
z=0;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
R2P(&m1,&a1,x,y);
|
||||
|
||||
x=-y_radius*s;
|
||||
y=y_radius*c;
|
||||
z=0;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
R2P(&m2,&a2,x,y);
|
||||
m2*=Abs(Sin(a2-a1));
|
||||
|
||||
@@ -259,13 +260,13 @@ CSprite *SpriteTransformBitmap(I64 r[4][4],CSprite *tempg)
|
||||
CSprite *tempg1;
|
||||
|
||||
x=0; y=0; z=0;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
minx=maxx=x;
|
||||
miny=maxy=y;
|
||||
minz=maxz=z;
|
||||
|
||||
x=0; y=tempg->pwhu.height; z=0;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
if (x<minx) minx=x;
|
||||
if (x>maxx) maxx=x;
|
||||
if (y<minx) miny=y;
|
||||
@@ -274,7 +275,7 @@ CSprite *SpriteTransformBitmap(I64 r[4][4],CSprite *tempg)
|
||||
if (z>maxx) maxz=z;
|
||||
|
||||
x=tempg->pwhu.width; y=0; z=0;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
if (x<minx) minx=x;
|
||||
if (x>maxx) maxx=x;
|
||||
if (y<minx) miny=y;
|
||||
@@ -283,7 +284,7 @@ CSprite *SpriteTransformBitmap(I64 r[4][4],CSprite *tempg)
|
||||
if (z>maxx) maxz=z;
|
||||
|
||||
x=tempg->pwhu.width; y=tempg->pwhu.height; z=0;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
if (x<minx) minx=x;
|
||||
if (x>maxx) maxx=x;
|
||||
if (y<minx) miny=y;
|
||||
@@ -304,7 +305,7 @@ CSprite *SpriteTransformBitmap(I64 r[4][4],CSprite *tempg)
|
||||
GrRect(tempb,0,0,maxx-minx+1,maxy-miny+1);
|
||||
|
||||
Free(tempb->r);
|
||||
GrSetRotMat(tempb,r);
|
||||
DCMat4x4Set(tempb,r);
|
||||
tempb->flags|=DCF_TRANSFORMATION;
|
||||
|
||||
tempb->x=-minx;
|
||||
@@ -321,12 +322,12 @@ CSprite *SpriteTransformBitmap(I64 r[4][4],CSprite *tempg)
|
||||
tempg1->type=tempg->type;
|
||||
|
||||
x=tempg->pwhu.x1; y=tempg->pwhu.y1; z=0;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
tempg1->pwhu.x1=x;
|
||||
tempg1->pwhu.y1=y;
|
||||
|
||||
x=0; y=0; z=0;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
tempg1->pwhu.x1+=minx-x;
|
||||
tempg1->pwhu.y1+=miny-y;
|
||||
|
||||
@@ -336,21 +337,21 @@ CSprite *SpriteTransformBitmap(I64 r[4][4],CSprite *tempg)
|
||||
U0 SpriteTransform(I64 r[4][4],CSprite *root)
|
||||
{
|
||||
I64 i,j,k,num,
|
||||
x,y,z,x1,y1,z1,x2,y2,z2,x3,y3,z3;
|
||||
x,y,z,x1,y1,z1,x2,y2,z2,x3,y3,z3;
|
||||
I32 *ptr;
|
||||
CD3I32 *p;
|
||||
CSprite *tempg=root->next,root2,*tempg1,*tempg2,*tempg3;
|
||||
while (tempg!=root) {
|
||||
switch (tempg->type) {
|
||||
case SPT_WIDTH:
|
||||
tempg->w.width*=Sqrt(GrRotNormSqr65536(r))/65536;
|
||||
tempg->w.width*=Sqrt(Mat4x4NormSqr65536(r))/65536;
|
||||
if (tempg->w.width<0) tempg->w.width=0;
|
||||
break;
|
||||
case SPT_PLANAR_SYMMETRY:
|
||||
case SPT_ARROW:
|
||||
case SPT_LINE:
|
||||
x=tempg->pp.x2; y=tempg->pp.y2; z=0;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
tempg->pp.x2=x;
|
||||
tempg->pp.y2=y;
|
||||
case SPT_PT:
|
||||
@@ -360,7 +361,7 @@ U0 SpriteTransform(I64 r[4][4],CSprite *root)
|
||||
case SPT_TEXT_BOX:
|
||||
case SPT_TEXT_DIAMOND:
|
||||
x=tempg->p.x1; y=tempg->p.y1; z=0;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
tempg->p.x1=x;
|
||||
tempg->p.y1=y;
|
||||
break;
|
||||
@@ -404,7 +405,7 @@ U0 SpriteTransform(I64 r[4][4],CSprite *root)
|
||||
ptr=&tempg->nu.u;
|
||||
for (i=0;i<tempg->nu.num;i++) {
|
||||
x=ptr[i<<1]; y=ptr[i<<1+1]; z=0;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
ptr[i<<1]=x;
|
||||
ptr[i<<1+1]=y;
|
||||
}
|
||||
@@ -413,7 +414,7 @@ U0 SpriteTransform(I64 r[4][4],CSprite *root)
|
||||
QueInit(&root2);
|
||||
x=tempg->npu.x; y=tempg->npu.y; z=0;
|
||||
x1=x; y1=y; z1=z; //unrotated cur coordinates
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
ptr=&tempg->npu.u;
|
||||
k=tempg->npu.num*3;
|
||||
x2=x; y2=y; z2=z; //rotated start coordinates
|
||||
@@ -423,7 +424,7 @@ U0 SpriteTransform(I64 r[4][4],CSprite *root)
|
||||
x1+=gr_x_offsets[j];
|
||||
y1+=gr_y_offsets[j];
|
||||
x=x1; y=y1; z=z1;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
Line(&root2,x3-x2,y3-y2,0,x-x2,y-y2,0,&SpritePolyPtPlot);
|
||||
x3=x; y3=y; z3=z;
|
||||
}
|
||||
@@ -454,8 +455,8 @@ U0 SpriteTransform(I64 r[4][4],CSprite *root)
|
||||
while (tempg1!=&root2) {
|
||||
tempg2=tempg1->next;
|
||||
BFieldOrU32(ptr,i,
|
||||
polypt_map[SignI64(tempg1->p.x1-x3)+1+
|
||||
3*(SignI64(tempg1->p.y1-y3)+1)]);
|
||||
polypt_map[SignI64(tempg1->p.x1-x3)+1+
|
||||
3*(SignI64(tempg1->p.y1-y3)+1)]);
|
||||
i+=3;
|
||||
x3=tempg1->p.x1;y3=tempg1->p.y1;
|
||||
QueRem(tempg1);
|
||||
@@ -476,7 +477,7 @@ U0 SpriteTransform(I64 r[4][4],CSprite *root)
|
||||
p=&tempg->nu.u;
|
||||
for (i=0;i<tempg->nu.num;i++,p++) {
|
||||
x=p->x; y=p->y; z=p->z;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
p->x=x;
|
||||
p->y=y;
|
||||
p->z=z;
|
||||
@@ -484,14 +485,14 @@ U0 SpriteTransform(I64 r[4][4],CSprite *root)
|
||||
break;
|
||||
case SPT_SHIFTABLE_MESH:
|
||||
x=tempg->pmu.x; y=tempg->pmu.y; z=tempg->pmu.z;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
tempg->pmu.x=x;
|
||||
tempg->pmu.y=y;
|
||||
tempg->pmu.z=z;
|
||||
p=&tempg->pmu.u;
|
||||
for (i=0;i<tempg->pmu.vertex_cnt;i++,p++) {
|
||||
x=p->x; y=p->y; z=p->z;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
p->x=x;
|
||||
p->y=y;
|
||||
p->z=z;
|
||||
@@ -501,7 +502,7 @@ U0 SpriteTransform(I64 r[4][4],CSprite *root)
|
||||
p=&tempg->mu.u;
|
||||
for (i=0;i<tempg->mu.vertex_cnt;i++,p++) {
|
||||
x=p->x; y=p->y; z=p->z;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
p->x=x;
|
||||
p->y=y;
|
||||
p->z=z;
|
||||
@@ -518,7 +519,7 @@ CSprite *SpriteSideBar2SpriteQue(CDoc *doc,CSprite *root,I64 *_cur_elem_num)
|
||||
CDocEntry *doc_e=doc->root.next;
|
||||
Bool found=FALSE;
|
||||
I64 num=0;
|
||||
result->next=result->last=result;
|
||||
QueInit(result);
|
||||
while (doc_e!=doc) {
|
||||
if (doc_e->type_u8==DOCT_MENU_VAL && doc_e->left_exp>=0) {
|
||||
tempg=SpriteElemNum2QueEntry(root,doc_e->left_exp);
|
||||
@@ -549,11 +550,12 @@ U0 SpriteSideBarPickNew(CDoc *doc,CSprite *root,I64 old_num)
|
||||
U8 *st;
|
||||
|
||||
DocPrint(doc,"$$PURPLE$$$$TX+CX,\"Sprite SideBar\"$$\n"
|
||||
"$$LK+PU+CX,\"Click for Help\",A=\"FI:::/Doc/SpriteSideBar.TXT.Z\"$$\n\n");
|
||||
"$$LK+PU+CX,\"Click for Help\","
|
||||
"A=\"FI:::/Doc/SpriteSideBar.TXT.Z\"$$\n\n");
|
||||
|
||||
tempg=root->next;
|
||||
while (tempg!=root) {
|
||||
st=SpriteElem2OneLineSummary(tempg);
|
||||
st=SpriteElem2Summary(tempg);
|
||||
if (cur_elem_num==old_num) {
|
||||
DocPrint(doc,"$$LTRED$$");
|
||||
doc_e=DocPrint(doc,"$$MU-UL,\"%Q\",LE=%d$$\n",st,cur_elem_num++);
|
||||
@@ -616,11 +618,12 @@ Bool SpriteEdText(CSprite **_root,I64 *_cur_elem_num)
|
||||
CDoc *doc=DocNew,*doc2,*old_put=DocPut;
|
||||
StrPrint(doc->filename.name,"AI:0x%X",doc);
|
||||
DocPrint(doc,"//$$PURPLE$$$$TX+CX,\"Sprite Edit as Text\"$$$$FG$$\n"
|
||||
"//$$LK+PU+CX,\"Click for Help\",A=\"FI:::/Doc/SpriteEdText.TXT.Z\"$$\n\n");
|
||||
"//$$LK+PU+CX,\"Click for Help\","
|
||||
"A=\"FI:::/Doc/SpriteEdText.TXT.Z\"$$\n\n");
|
||||
Sprite2Code(doc,elems);
|
||||
Free(elems);
|
||||
while (TRUE) {
|
||||
if (result=PopUpPrint("DocDo(0x%X,0x%X);",doc,0)) {
|
||||
if (result=PopUpPrint("DocEd(0x%X,0x%X);",doc,0)) {
|
||||
Fs->put_doc=doc2=DocNew;
|
||||
"$$WW,1$$";
|
||||
if (elems=Code2Sprite(doc)) {
|
||||
@@ -633,7 +636,7 @@ Bool SpriteEdText(CSprite **_root,I64 *_cur_elem_num)
|
||||
*_cur_elem_num=QueCnt(root); //TODO: Might want to improve this.
|
||||
break;
|
||||
} else {
|
||||
PopUpPrint("DocDo(0x%X,0x%X);",doc2,0);
|
||||
PopUpPrint("DocEd(0x%X,0x%X);",doc2,0);
|
||||
DocDel(doc2);
|
||||
Fs->put_doc=old_put;
|
||||
}
|
||||
@@ -681,7 +684,8 @@ I64 PopUpSpriteEd(CSprite **_root,I64 *_cur_elem_num)
|
||||
"$$MU-UL,\"Set Origin\",LE=GED_SET_ORIGIN$$\n"
|
||||
"$$MU-UL,\"Shift Origin\",LE=GED_SHIFT_ORIGIN$$\n"
|
||||
"$$MU-UL,\"Insert Shift SubOrigin\",LE=GED_SHIFT_SUB_ORIGIN$$\n"
|
||||
"$$MU-UL,\"Pick or Delete Objects Graphically\",LE=GED_PICK_GRAPHICALLY$$\n"
|
||||
"$$MU-UL,\"Pick or Delete Objects Graphically\","
|
||||
"LE=GED_PICK_GRAPHICALLY$$\n"
|
||||
"$$MU-UL,\"Delete\",LE=GED_DELETE$$\n"
|
||||
"$$MU-UL,\"Insert Clipboard Sprite's\",LE=GED_INS_CLIPBOARD$$\n"
|
||||
"\n$$PURPLE$$$$MU-UL,\"+] Sprite Main Menu\",LE=GED_MAIN_MENU$$$$LTBLUE$$\n"
|
||||
@@ -721,6 +725,19 @@ U0 SpritePtQueNew(U8 *elems,I64 x,I64 y,CEdSprite *root)
|
||||
QueInit(root);
|
||||
while (tempg->type) {
|
||||
switch (tempg->type) {
|
||||
case SPT_ELLIPSE:
|
||||
case SPT_POLYGON:
|
||||
temppe=CAlloc(sizeof(CEdSprite));
|
||||
temppe->type=GSPT_WIDTH_HEIGHT;
|
||||
temppe->xx=x;
|
||||
temppe->yy=y;
|
||||
temppe->x=&tempg->pwha.x1;
|
||||
temppe->y=&tempg->pwha.y1;
|
||||
temppe->w=&tempg->pwha.width;
|
||||
temppe->h=&tempg->pwha.height;
|
||||
temppe->num=num;
|
||||
QueIns(temppe,root->last);
|
||||
goto pq_x1_y1;
|
||||
case SPT_RECT:
|
||||
case SPT_ROTATED_RECT:
|
||||
case SPT_LINE:
|
||||
@@ -742,6 +759,7 @@ U0 SpritePtQueNew(U8 *elems,I64 x,I64 y,CEdSprite *root)
|
||||
case SPT_FLOOD_FILL:
|
||||
case SPT_FLOOD_FILL_NOT:
|
||||
case SPT_CIRCLE:
|
||||
pq_x1_y1:
|
||||
temppe=CAlloc(sizeof(CEdSprite));
|
||||
temppe->type=GSPT_SIMPLE_PT;
|
||||
temppe->xx=x;
|
||||
@@ -755,19 +773,6 @@ U0 SpritePtQueNew(U8 *elems,I64 x,I64 y,CEdSprite *root)
|
||||
x+=tempg->p.x1;
|
||||
y+=tempg->p.y1;
|
||||
break;
|
||||
case SPT_ELLIPSE:
|
||||
case SPT_POLYGON:
|
||||
temppe=CAlloc(sizeof(CEdSprite));
|
||||
temppe->type=GSPT_WIDTH_HEIGHT;
|
||||
temppe->xx=x;
|
||||
temppe->yy=y;
|
||||
temppe->x=&tempg->pwha.x1;
|
||||
temppe->y=&tempg->pwha.y1;
|
||||
temppe->w=&tempg->pwha.width;
|
||||
temppe->h=&tempg->pwha.height;
|
||||
temppe->num=num;
|
||||
QueIns(temppe,root->last);
|
||||
break;
|
||||
case SPT_POLYLINE:
|
||||
ptr=&tempg->nu.u;
|
||||
for (i=0;i<tempg->nu.num;i++) {
|
||||
@@ -888,10 +893,11 @@ Bool SpriteShiftPts(U8 *elems,I64 x,I64 y,I64 *_cur_elem_num,I64 mode)
|
||||
SpritePtQueNew(elems,x,y,&root);
|
||||
cur_elem_num=0;
|
||||
if (root.next!=&root) {
|
||||
old_preempt=Preempt(OFF);
|
||||
old_preempt=Preempt;
|
||||
while (TRUE) {
|
||||
SpriteCtrlPtsDraw(dc,&root); //has WinMgrSync
|
||||
switch (msg_code=ScanMsg(&a1,&a2,1<<MSG_IP_R_UP|1<<MSG_IP_L_DOWN|1<<MSG_KEY_DOWN)) {
|
||||
switch (msg_code=ScanMsg(&a1,&a2,
|
||||
1<<MSG_IP_R_UP|1<<MSG_IP_L_DOWN|1<<MSG_KEY_DOWN)) {
|
||||
case MSG_IP_L_DOWN:
|
||||
switch (mode) {
|
||||
case GED_SHIFT_PTS:
|
||||
@@ -901,10 +907,12 @@ Bool SpriteShiftPts(U8 *elems,I64 x,I64 y,I64 *_cur_elem_num,I64 mode)
|
||||
while (temppe!=&root) {
|
||||
switch (temppe->type) {
|
||||
case GSPT_SIMPLE_PT:
|
||||
dd=SqrI64(*temppe->x+temppe->xx-xx)+SqrI64(*temppe->y+temppe->yy-yy);
|
||||
dd=SqrI64(*temppe->x+temppe->xx-xx)+
|
||||
SqrI64(*temppe->y+temppe->yy-yy);
|
||||
break;
|
||||
case GSPT_WIDTH_HEIGHT:
|
||||
dd=SqrI64(*temppe->x+*temppe->w+temppe->xx-xx)+SqrI64(*temppe->y+*temppe->h+temppe->yy-yy);
|
||||
dd=SqrI64(*temppe->x+*temppe->w+temppe->xx-xx)+
|
||||
SqrI64(*temppe->y+*temppe->h+temppe->yy-yy);
|
||||
break;
|
||||
}
|
||||
if (dd<best_dd) {
|
||||
@@ -936,12 +944,12 @@ Bool SpriteShiftPts(U8 *elems,I64 x,I64 y,I64 *_cur_elem_num,I64 mode)
|
||||
switch (temppe->type) {
|
||||
case GSPT_SIMPLE_PT:
|
||||
if (xx<=*temppe->x+temppe->xx<=xx2 &&
|
||||
yy<=*temppe->y+temppe->yy<=yy2)
|
||||
yy<=*temppe->y+temppe->yy<=yy2)
|
||||
temppe->flags|=GSPF_SELECTED;
|
||||
break;
|
||||
case GSPT_WIDTH_HEIGHT:
|
||||
if (xx<=*temppe->x+*temppe->w+temppe->xx<=xx2 &&
|
||||
yy<=*temppe->y+*temppe->h+temppe->yy<=yy2)
|
||||
yy<=*temppe->y+*temppe->h+temppe->yy<=yy2)
|
||||
temppe->flags|=GSPF_SELECTED;
|
||||
break;
|
||||
}
|
||||
@@ -969,7 +977,7 @@ Bool SpriteShiftPts(U8 *elems,I64 x,I64 y,I64 *_cur_elem_num,I64 mode)
|
||||
}
|
||||
break;
|
||||
case MSG_KEY_DOWN:
|
||||
gs_key:
|
||||
gs_key:
|
||||
switch (a1.u8[0]) {
|
||||
case CH_SHIFT_ESC:
|
||||
result=FALSE;
|
||||
@@ -1001,7 +1009,8 @@ gs_done:
|
||||
return result;
|
||||
}
|
||||
|
||||
I64 SpriteEd(CDoc *doc,CDocEntry *doc_e,I64 x,I64 y,CSprite **_root,I64 *_cur_elem_num)
|
||||
I64 SpriteEd(CDoc *doc,CDocEntry *doc_e,I64 x,I64 y,
|
||||
CSprite **_root,I64 *_cur_elem_num)
|
||||
{
|
||||
CDocEntry *doc_e2;
|
||||
CDocBin *tempb;
|
||||
@@ -1023,15 +1032,16 @@ I64 SpriteEd(CDoc *doc,CDocEntry *doc_e,I64 x,I64 y,CSprite **_root,I64 *_cur_el
|
||||
StrCpy(Fs->task_title,DefineSub(i,"ST_SPRITE_ED_MENU"));
|
||||
switch (i) {
|
||||
case GED_PICK_GRAPHICALLY:
|
||||
AcctOneTimePopUp(ARf_CSPRITE_PICK_GRAPHICALLY,
|
||||
RegOneTimePopUp(ARf_CSPRITE_PICK_GRAPHICALLY,
|
||||
"You can delete elements by\n"
|
||||
"holding $$GREEN$$Delete$$FG$$ and clicking.\n");
|
||||
doc_e->de_flags=old_de_flags;
|
||||
doc->cur_sprite=tempb->data;
|
||||
doc->cur_sprite_elem_num=0;
|
||||
doc->nearest_sprite_elem_num=0;
|
||||
del_down=FALSE;
|
||||
do {
|
||||
msg_code=GetMsg(&a1,&a2,1<<MSG_IP_L_UP|1<<MSG_IP_R_UP|1<<MSG_KEY_DOWN|1<<MSG_KEY_UP);
|
||||
msg_code=GetMsg(&a1,&a2,
|
||||
1<<MSG_IP_L_UP|1<<MSG_IP_R_UP|1<<MSG_KEY_DOWN|1<<MSG_KEY_UP);
|
||||
if (a2.u8[0]==SC_DELETE&& !(a2&SCF_IP_L_DOWN)) {
|
||||
if (msg_code==MSG_KEY_DOWN)
|
||||
del_down=TRUE;
|
||||
@@ -1039,8 +1049,9 @@ I64 SpriteEd(CDoc *doc,CDocEntry *doc_e,I64 x,I64 y,CSprite **_root,I64 *_cur_el
|
||||
del_down=FALSE;
|
||||
}
|
||||
if (msg_code==MSG_IP_L_UP && kbd.scan_code&SCF_DELETE ||
|
||||
msg_code==MSG_KEY_DOWN && a2&SCF_IP_L_DOWN && a2.u8[0]==SC_DELETE) {
|
||||
*_cur_elem_num=doc->cur_sprite_elem_num;
|
||||
msg_code==MSG_KEY_DOWN && a2&SCF_IP_L_DOWN &&
|
||||
a2.u8[0]==SC_DELETE) {
|
||||
*_cur_elem_num=doc->nearest_sprite_elem_num;
|
||||
cur_elem=SpriteElemNum2QueEntry(*_root,*_cur_elem_num);
|
||||
if (cur_elem!=*_root) {
|
||||
QueRem(cur_elem);
|
||||
@@ -1048,12 +1059,12 @@ I64 SpriteEd(CDoc *doc,CDocEntry *doc_e,I64 x,I64 y,CSprite **_root,I64 *_cur_el
|
||||
SpriteEdUpdate(doc,tempb,*_root);
|
||||
}
|
||||
doc->cur_sprite=tempb->data;
|
||||
doc->cur_sprite_elem_num=0;
|
||||
doc->nearest_sprite_elem_num=0;
|
||||
if (msg_code==MSG_KEY_DOWN)
|
||||
GetMsg(&a1,&a2,1<<MSG_IP_L_UP);
|
||||
}
|
||||
} while (del_down || msg_code!=MSG_IP_L_UP && msg_code!=MSG_IP_R_UP);
|
||||
*_cur_elem_num=doc->cur_sprite_elem_num;
|
||||
*_cur_elem_num=doc->nearest_sprite_elem_num;
|
||||
doc->cur_sprite=NULL;
|
||||
break;
|
||||
case GED_SET_ORIGIN:
|
||||
@@ -1076,7 +1087,7 @@ I64 SpriteEd(CDoc *doc,CDocEntry *doc_e,I64 x,I64 y,CSprite **_root,I64 *_cur_el
|
||||
break;
|
||||
case GED_SHIFT_PTS:
|
||||
case GED_SHIFT_RECTS:
|
||||
AcctOneTimePopUp(ARf_CSPRITE_PTS_RECTANGLES,
|
||||
RegOneTimePopUp(ARf_CSPRITE_PTS_RECTANGLES,
|
||||
"You can switch between points\n"
|
||||
"and rectangles with '$$GREEN$$p$$FG$$' and '$$GREEN$$r$$FG$$'.\n"
|
||||
"Press '$$GREEN$$r$$FG$$' after one rectangle\n"
|
||||
@@ -1115,7 +1126,7 @@ I64 SpriteEd(CDoc *doc,CDocEntry *doc_e,I64 x,I64 y,CSprite **_root,I64 *_cur_el
|
||||
*_cur_elem_num+=1;
|
||||
break;
|
||||
case GED_INS_CLIPBOARD:
|
||||
AcctOneTimePopUp(ARf_CSPRITE_INS_CLIPBOARD,
|
||||
RegOneTimePopUp(ARf_CSPRITE_INS_CLIPBOARD,
|
||||
"You will probably want to shift around\n"
|
||||
"the location of element groups. Use\n"
|
||||
"'Insert shift sub-origin' after picking the\n"
|
||||
|
||||
+47
-29
@@ -1,4 +1,4 @@
|
||||
#help_index "Graphics/Sprite"
|
||||
#help_index "Graphics/Sprite;Sprites"
|
||||
|
||||
#define SPT_MENU -2
|
||||
#define SPT_INS_SCREEN_BITMAP -3
|
||||
@@ -37,12 +37,17 @@ I64 PopUpSpriteMain(CSprite **_root,I64 *_cur_elem_num)
|
||||
"$$MU-UL,\"BSpline2 Closed\",LE=SPT_BSPLINE2_CLOSED$$\n"
|
||||
"$$MU-UL,\"BSpline3 Closed\",LE=SPT_BSPLINE3_CLOSED$$\n"
|
||||
"$$MU-UL,\"Insert Screen-Captured BitMap\",LE=SPT_INS_SCREEN_BITMAP$$\n"
|
||||
"$$MU-UL,\"Insert Transparent Screen-Captured BitMap\",LE=SPT_INS_TRANSPARENT_SCREEN_BITMAP$$\n"
|
||||
"$$MU-UL,\"Insert Transparent Screen-Captured BitMap\","
|
||||
"LE=SPT_INS_TRANSPARENT_SCREEN_BITMAP$$\n"
|
||||
"$$PURPLE$$$$MU-UL,\"+] Create or Edit 3D Mesh\",LE=SPT_MESH$$\n"
|
||||
"$$MU-UL,\"+] Create or Edit Shiftable 3D Mesh\",LE=SPT_SHIFTABLE_MESH$$\n"
|
||||
"$$MU-UL,\"+] Convert to BitMap or Edit BitMap\",LE=SPT_BITMAP$$$$LTBLUE$$\n"
|
||||
"\n$$MU-UL,\"Transform On (for use with 3D icons)\",LE=SPT_TRANSFORM_ON$$\n"
|
||||
"$$MU-UL,\"Transform Off (for use with 3D icons)\",LE=SPT_TRANSFORM_OFF$$\n"
|
||||
"$$MU-UL,\"+] Create or Edit Shiftable 3D Mesh\","
|
||||
"LE=SPT_SHIFTABLE_MESH$$\n"
|
||||
"$$MU-UL,\"+] Convert to BitMap or Edit BitMap\","
|
||||
"LE=SPT_BITMAP$$$$LTBLUE$$\n"
|
||||
"\n$$MU-UL,\"Transform On (for use with 3D icons)\","
|
||||
"LE=SPT_TRANSFORM_ON$$\n"
|
||||
"$$MU-UL,\"Transform Off (for use with 3D icons)\","
|
||||
"LE=SPT_TRANSFORM_OFF$$\n"
|
||||
"\n"
|
||||
"$$PURPLE$$$$MU-UL,\"+] Sprite Edit Menu\",LE=SPT_ED_MENU$$$$LTBLUE$$\n"
|
||||
"$$MU-UL,\"Exit Sprite\",LE=SPT_EXIT$$\n"
|
||||
@@ -86,7 +91,8 @@ Bool PopUpExtents(I64 *_x1,I64 *_x2,I64 *_y1,I64 *_y2)
|
||||
return i;
|
||||
}
|
||||
|
||||
U0 SpriteSetSettings(CDC *dc,CSprite *root,I64 cur_elem_num,CColorROPU32 *_color,I64 *_width,I64 x,I64 y)
|
||||
U0 SpriteSetSettings(CDC *dc,CSprite *root,
|
||||
I64 cur_elem_num,CColorROPU32 *_color,I64 *_width,I64 x,I64 y)
|
||||
{
|
||||
CSprite *tempg;
|
||||
*_color=BLACK;
|
||||
@@ -101,14 +107,15 @@ U0 SpriteSetSettings(CDC *dc,CSprite *root,I64 cur_elem_num,CColorROPU32 *_color
|
||||
break;
|
||||
case SPT_DITHER_COLOR:
|
||||
dc->color=*_color=
|
||||
tempg->d.dither_color.u8[0]|
|
||||
tempg->d.dither_color.u8[1]<<COLORROP_BITS|ROPF_DITHER;
|
||||
tempg->d.dither_color.u8[0]|
|
||||
tempg->d.dither_color.u8[1]<<COLORROP_BITS|ROPF_DITHER;
|
||||
break;
|
||||
case SPT_WIDTH:
|
||||
dc->pen_width=*_width=tempg->w.width;
|
||||
break;
|
||||
case SPT_PLANAR_SYMMETRY:
|
||||
if (GrSetSymmetry3(dc,tempg->pp.x1+x,tempg->pp.y1+y,0,tempg->pp.x2+x,tempg->pp.y2+y,0,tempg->pp.x2+x,tempg->pp.y2+y,1))
|
||||
if (DCSymmetry3Set(dc,tempg->pp.x1+x,tempg->pp.y1+y,0,
|
||||
tempg->pp.x2+x,tempg->pp.y2+y,0,tempg->pp.x2+x,tempg->pp.y2+y,1))
|
||||
dc->flags|=DCF_SYMMETRY;
|
||||
else
|
||||
dc->flags&=~DCF_SYMMETRY;
|
||||
@@ -133,13 +140,13 @@ U0 SpriteScreenInit(CDC *dc,I64,I64)
|
||||
yy=-dc->sym.snx*8192;
|
||||
dc->color=RED;
|
||||
GrLine3(dc,dc->sym.sx-xx.i32[1],dc->sym.sy-yy.i32[1],0,
|
||||
dc->sym.sx+xx.i32[1],dc->sym.sy+yy.i32[1],0,3,0);
|
||||
dc->sym.sx+xx.i32[1],dc->sym.sy+yy.i32[1],0,3,0);
|
||||
dc->color=WHITE;
|
||||
GrLine3(dc,dc->sym.sx-xx.i32[1],dc->sym.sy-yy.i32[1],0,
|
||||
dc->sym.sx+xx.i32[1],dc->sym.sy+yy.i32[1],0,3,1);
|
||||
dc->sym.sx+xx.i32[1],dc->sym.sy+yy.i32[1],0,3,1);
|
||||
dc->color=BLACK;
|
||||
GrLine3(dc,dc->sym.sx-xx.i32[1],dc->sym.sy-yy.i32[1],0,
|
||||
dc->sym.sx+xx.i32[1],dc->sym.sy+yy.i32[1],0,3,2);
|
||||
dc->sym.sx+xx.i32[1],dc->sym.sy+yy.i32[1],0,3,2);
|
||||
dc->flags|=DCF_SYMMETRY;
|
||||
}
|
||||
dc->color=old_color;
|
||||
@@ -178,7 +185,8 @@ I64 SpriteMainEd(CDoc *doc,CDocEntry *doc_e,I64 x,I64 y)
|
||||
SpriteSetSettings(dc,root,cur_elem_num,&color,&width,x,y);
|
||||
DCFill;
|
||||
if (eletype==SPT_MENU) {
|
||||
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS-WIF_SELF_BORDER-WIF_SELF_GRAB_SCROLL;
|
||||
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS
|
||||
-WIF_SELF_BORDER-WIF_SELF_GRAB_SCROLL;
|
||||
if (winmgr.fps<10)
|
||||
doc_e->de_flags|=DOCEF_DONT_DRAW;
|
||||
StrCpy(Fs->task_title,old_task_title);
|
||||
@@ -191,7 +199,7 @@ I64 SpriteMainEd(CDoc *doc,CDocEntry *doc_e,I64 x,I64 y)
|
||||
switch (eletype) {
|
||||
case SPT_FLOOD_FILL:
|
||||
case SPT_FLOOD_FILL_NOT:
|
||||
AcctOneTimePopUp(ARf_FLOODFILL,
|
||||
RegOneTimePopUp(ARf_FLOODFILL,
|
||||
ST_WARN_ST "This is affected by what's underneath\n"
|
||||
"when it is drawn. You will probably want to\n"
|
||||
"convert it to a bitmap.\n\n"
|
||||
@@ -200,7 +208,7 @@ I64 SpriteMainEd(CDoc *doc,CDocEntry *doc_e,I64 x,I64 y)
|
||||
"brush strokes look cool.\n");
|
||||
break;
|
||||
case SPT_PLANAR_SYMMETRY:
|
||||
AcctOneTimePopUp(ARf_PLANAR_SYMMETRY,
|
||||
RegOneTimePopUp(ARf_PLANAR_SYMMETRY,
|
||||
"Right-click to turn-off symmetry.\n");
|
||||
break;
|
||||
}
|
||||
@@ -489,7 +497,7 @@ ei_restart:
|
||||
result=GE_ABORT;
|
||||
goto ei_done;
|
||||
}
|
||||
msg_code=GetMsg(&a1,&a2,1<<MSG_KEY_DOWN | 1<<MSG_IP_L_DOWN | 1<<MSG_IP_R_UP);
|
||||
msg_code=GetMsg(&a1,&a2,1<<MSG_KEY_DOWN|1<<MSG_IP_L_DOWN|1<<MSG_IP_R_UP);
|
||||
if (msg_code==MSG_IP_R_UP) {
|
||||
if (eletype==SPT_PLANAR_SYMMETRY) {
|
||||
tempg=CAlloc(SpriteElemQuedBaseSize(SPT_PLANAR_SYMMETRY));
|
||||
@@ -510,7 +518,7 @@ ei_restart:
|
||||
result=GE_ABORT;
|
||||
goto ei_done;
|
||||
case 'c': //eye-dropper
|
||||
dc3=DCCaptureScreen(FALSE);
|
||||
dc3=DCScreenCapture(FALSE);
|
||||
color=GrPeek(dc3,ip.pos.x,ip.pos.y)^15;//Mouse cursor is XORed.
|
||||
DCDel(dc3);
|
||||
tempg=MAlloc(SpriteElemQuedBaseSize(SPT_COLOR));
|
||||
@@ -627,8 +635,10 @@ ei_restart:
|
||||
dc2->pen_width=1;
|
||||
do {
|
||||
dc2->color=ROPF_DITHER+WHITE<<16+BLACK;
|
||||
GrBorder(dc2,xx1+Fs->pix_left+Fs->scroll_x,yy1+Fs->pix_top+Fs->scroll_y,
|
||||
xx2+Fs->pix_left+Fs->scroll_x,yy2+Fs->pix_top+Fs->scroll_y);
|
||||
GrBorder(dc2,xx1+Fs->pix_left+Fs->scroll_x,
|
||||
yy1+Fs->pix_top+Fs->scroll_y,
|
||||
xx2+Fs->pix_left+Fs->scroll_x,
|
||||
yy2+Fs->pix_top+Fs->scroll_y);
|
||||
msg_code=GetMsg(&a1,&a2,
|
||||
1<<MSG_IP_L_UP+1<<MSG_IP_MOVE);
|
||||
SpriteScreenInit(dc,x,y);
|
||||
@@ -657,10 +667,12 @@ ei_restart:
|
||||
GrScaleZoom(1.0/i);
|
||||
WinMgrSync(2,TRUE);
|
||||
|
||||
dc3=DCCaptureScreen;
|
||||
dc3=DCScreenCapture;
|
||||
img=DCExtract(dc3,
|
||||
Fs->pix_left+Fs->scroll_x+xx1,Fs->pix_top+Fs->scroll_y+yy1,
|
||||
Fs->pix_left+Fs->scroll_x+xx2-1,Fs->pix_top+Fs->scroll_y+yy2-1);
|
||||
Fs->pix_left+Fs->scroll_x+xx1,
|
||||
Fs->pix_top+Fs->scroll_y+yy1,
|
||||
Fs->pix_left+Fs->scroll_x+xx2-1,
|
||||
Fs->pix_top+Fs->scroll_y+yy2-1);
|
||||
if (eletype==SPT_INS_TRANSPARENT_SCREEN_BITMAP)
|
||||
DCColorChg(img,bm_bkcolor);
|
||||
GrScaleZoom(i);
|
||||
@@ -669,7 +681,8 @@ ei_restart:
|
||||
DCDel(dc3);
|
||||
dc2->pen_width=old_width;
|
||||
eletype=SPT_MENU;
|
||||
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS-WIF_SELF_BORDER-WIF_SELF_GRAB_SCROLL;
|
||||
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS
|
||||
-WIF_SELF_BORDER-WIF_SELF_GRAB_SCROLL;
|
||||
break;
|
||||
case SPT_CIRCLE:
|
||||
do {
|
||||
@@ -823,7 +836,8 @@ ei_restart:
|
||||
} while (msg_code!=MSG_IP_R_UP);
|
||||
case SPT_POLYLINE:
|
||||
if (num>1) {
|
||||
tempg=CAlloc(SpriteElemQuedBaseSize(SPT_POLYLINE)+num*sizeof(CD2I32));
|
||||
tempg=CAlloc(SpriteElemQuedBaseSize(SPT_POLYLINE)+
|
||||
num*sizeof(CD2I32));
|
||||
ptr=&tempg->nu.u;
|
||||
tempg2=root2.next;
|
||||
for (i=0;i<num;i++) {
|
||||
@@ -850,7 +864,8 @@ ei_restart:
|
||||
case SPT_BSPLINE2_CLOSED:
|
||||
case SPT_BSPLINE3_CLOSED:
|
||||
if (num>2) {
|
||||
tempg=CAlloc(SpriteElemQuedBaseSize(eletype)+num*sizeof(CD3I32));
|
||||
tempg=CAlloc(SpriteElemQuedBaseSize(eletype)+
|
||||
num*sizeof(CD3I32));
|
||||
p=&tempg->nu.u;
|
||||
tempg2=root2.next;
|
||||
for (i=0;i<num;i++) {
|
||||
@@ -973,7 +988,8 @@ ei_bitmap:
|
||||
insert_pt=root->next=root->last=root;
|
||||
cur_elem_num=1;
|
||||
} else {
|
||||
SpriteSetSettings(img,root,cur_elem_num,&color,&width,-(xx1-x),-(yy1-y));
|
||||
SpriteSetSettings(img,root,cur_elem_num,&color,&width,
|
||||
-(xx1-x),-(yy1-y));
|
||||
Sprite3(img,-(xx1-x),-(yy1-y),0,&tempg1->start,TRUE);
|
||||
insert_pt=tempg1->next;
|
||||
QueRem(tempg1);
|
||||
@@ -981,7 +997,8 @@ ei_bitmap:
|
||||
}
|
||||
MemCpy(&tempg->pwhu.u,img->body,((xx2-xx1+7)&~7)*(yy2-yy1));
|
||||
|
||||
switch (i=SpriteBitMapEd(doc,doc_e,dc,&xx1,&yy1,&xx2,&yy2,&img,bm_bkcolor)) {
|
||||
switch (i=SpriteBitMapEd(doc,doc_e,dc,&xx1,&yy1,
|
||||
&xx2,&yy2,&img,bm_bkcolor)) {
|
||||
case GE_EXIT:
|
||||
case GE_CONT:
|
||||
Free(tempg);
|
||||
@@ -1042,7 +1059,8 @@ ei_shiftable_mesh:
|
||||
old_mesh=NULL;
|
||||
}
|
||||
if (mesh=SpriteMeshEd(old_mesh,&size,TRUE)) {
|
||||
tempg=MAlloc(SpriteElemQuedBaseSize(SPT_SHIFTABLE_MESH)-sizeof(I32)*2+size);
|
||||
tempg=MAlloc(SpriteElemQuedBaseSize(SPT_SHIFTABLE_MESH)
|
||||
-sizeof(I32)*2+size);
|
||||
tempg->type=SPT_SHIFTABLE_MESH;
|
||||
MemCpy(&tempg->pmu.vertex_cnt,mesh,size);
|
||||
Free(mesh);
|
||||
|
||||
+147
-122
@@ -13,7 +13,7 @@ class CMeshEdVertex
|
||||
CD3I32 p; //World coordinates of the point.
|
||||
U0 end;
|
||||
CD3I32 p0,
|
||||
pt; //Transformed coordinates. (Screen)
|
||||
pt; //Transformed coordinates. (Screen)
|
||||
I32 num,flags;
|
||||
};
|
||||
|
||||
@@ -58,7 +58,8 @@ CMeshEdVertex *MeshVertexNew(CMeshFrame *e,I64 x,I64 y,I64 z)
|
||||
return tempv;
|
||||
}
|
||||
|
||||
CMeshEdTri *MeshTriNew(CMeshFrame *e,CColorROPU32 color,CMeshEdVertex *v1,CMeshEdVertex *v2,CMeshEdVertex *v3)
|
||||
CMeshEdTri *MeshTriNew(CMeshFrame *e,CColorROPU32 color,
|
||||
CMeshEdVertex *v1,CMeshEdVertex *v2,CMeshEdVertex *v3)
|
||||
{
|
||||
static I64 cpu_num=0;
|
||||
CMeshEdTri *tempt=CAlloc(sizeof(CMeshEdTri));
|
||||
@@ -201,7 +202,7 @@ U0 MeshVertexSelectRect(CMeshFrame *e,I64 mode,I64 x1,I64 x2,I64 y1,I64 y2)
|
||||
if (y1>y2) SwapI64(&y1,&y2);
|
||||
while (tempv!=&e->vertex_root) {
|
||||
if (x1<=tempv->pt.x<=x2 &&
|
||||
y1<=tempv->pt.y<=y2) {
|
||||
y1<=tempv->pt.y<=y2) {
|
||||
if (mode==MESH_AND)
|
||||
tempv->flags&=~VF_SELECTED;
|
||||
else
|
||||
@@ -219,11 +220,11 @@ U0 MeshTriSelectRect(CMeshFrame *e,I64 mode,I64 x1,I64 x2,I64 y1,I64 y2)
|
||||
if (y1>y2) SwapI64(&y1,&y2);
|
||||
while (tempt!=&e->tri_root) {
|
||||
if (x1<=tempt->t[0]->pt.x<=x2 &&
|
||||
y1<=tempt->t[0]->pt.y<=y2 &&
|
||||
x1<=tempt->t[1]->pt.x<=x2 &&
|
||||
y1<=tempt->t[1]->pt.y<=y2 &&
|
||||
x1<=tempt->t[2]->pt.x<=x2 &&
|
||||
y1<=tempt->t[2]->pt.y<=y2) {
|
||||
y1<=tempt->t[0]->pt.y<=y2 &&
|
||||
x1<=tempt->t[1]->pt.x<=x2 &&
|
||||
y1<=tempt->t[1]->pt.y<=y2 &&
|
||||
x1<=tempt->t[2]->pt.x<=x2 &&
|
||||
y1<=tempt->t[2]->pt.y<=y2) {
|
||||
if (mode==MESH_AND)
|
||||
tempt->flags&=~TF_SELECTED;
|
||||
else
|
||||
@@ -233,12 +234,12 @@ U0 MeshTriSelectRect(CMeshFrame *e,I64 mode,I64 x1,I64 x2,I64 y1,I64 y2)
|
||||
tempt->flags&=~TF_SELECTED;
|
||||
else if (mode==MESH_AND) {
|
||||
if (x1<=tempt->t[0]->pt.x<=x2 &&
|
||||
y1<=tempt->t[0]->pt.y<=y2 ||
|
||||
x1<=tempt->t[1]->pt.x<=x2 &&
|
||||
y1<=tempt->t[1]->pt.y<=y2 ||
|
||||
x1<=tempt->t[2]->pt.x<=x2 &&
|
||||
y1<=tempt->t[2]->pt.y<=y2)
|
||||
tempt->flags&=~TF_SELECTED;
|
||||
y1<=tempt->t[0]->pt.y<=y2 ||
|
||||
x1<=tempt->t[1]->pt.x<=x2 &&
|
||||
y1<=tempt->t[1]->pt.y<=y2 ||
|
||||
x1<=tempt->t[2]->pt.x<=x2 &&
|
||||
y1<=tempt->t[2]->pt.y<=y2)
|
||||
tempt->flags&=~TF_SELECTED;
|
||||
}
|
||||
}
|
||||
tempt=tempt->next;
|
||||
@@ -313,7 +314,7 @@ U0 MeshTransformSelect(CMeshFrame *e)
|
||||
while (tempv!=&e->vertex_root) {
|
||||
if (tempv->flags&VF_SELECTED) {
|
||||
x=tempv->p.x; y=tempv->p.y; z=tempv->p.z;
|
||||
GrRot(r,&x,&y,&z);
|
||||
Mat4x4MulXYZ(r,&x,&y,&z);
|
||||
tempv->p.x=x; tempv->p.y=y; tempv->p.z=z;
|
||||
}
|
||||
tempv=tempv->next;
|
||||
@@ -352,9 +353,9 @@ U0 MeshCurSnap(CMeshFrame *e)
|
||||
I64 x1,y1,z1,x2,y2,z2;
|
||||
if (e->w2s) {
|
||||
x1=e->cur_snap<<16; y1=0; z1=0;
|
||||
GrRot(e->w2s,&x1,&y1,&z1);
|
||||
Mat4x4MulXYZ(e->w2s,&x1,&y1,&z1);
|
||||
x2=0; y2=e->cur_snap<<16; z2=0;
|
||||
GrRot(e->w2s,&x2,&y2,&z2);
|
||||
Mat4x4MulXYZ(e->w2s,&x2,&y2,&z2);
|
||||
ip_grid.x=Max(1,MaxI64(x1,x2)>>16);
|
||||
ip_grid.y=Max(1,MaxI64(y1,y2)>>16);
|
||||
ip_grid.z=Min(ip_grid.x,ip_grid.y);
|
||||
@@ -378,26 +379,26 @@ U0 MeshScaleZoom(CMeshFrame *e,F64 scale)
|
||||
U0 MPDrawIt(CMeshFrame *e)
|
||||
{//Multiprocessing draw it, called by each core.
|
||||
|
||||
//Makes a copy of e->dc so we can change dc->color member and stuff.
|
||||
//Makes a copy of e->dc so we can change dc->color member and stuff.
|
||||
CDC *dc=DCAlias(e->dc,e->dc->win_task);
|
||||
|
||||
CMeshEdTri *tempt=e->tri_root.next;
|
||||
I64 i,*old_r=dc->r;
|
||||
|
||||
//$LK,"DCAlias",A="MN:DCAlias"$() alllocs a new identity rotation matrix.
|
||||
//We want e->dc's rotation matrix.
|
||||
//$LK,"DCAlias",A="MN:DCAlias"$() alllocs a new identity rotation matrix.
|
||||
//We want e->dc's rotation matrix.
|
||||
dc->r=e->dc->r;
|
||||
|
||||
MemCpy(&dc->ls,&e->dc->ls,sizeof(CD3I32));
|
||||
|
||||
//... and translation (shift) vals.
|
||||
//... and translation (shift) vals.
|
||||
dc->x=e->dc->x;
|
||||
dc->y=e->dc->y;
|
||||
dc->z=e->dc->z;
|
||||
dc->flags|=DCF_TRANSFORMATION;
|
||||
|
||||
if (e->grid_on)
|
||||
//Draw grid with different cores.
|
||||
//Draw grid with different cores.
|
||||
for (i=-500+25*Gs->num;i<=500;i+=25*mp_cnt) {
|
||||
if (i) {
|
||||
dc->color=DKGRAY;
|
||||
@@ -432,7 +433,8 @@ U0 MPDrawIt(CMeshFrame *e)
|
||||
dc->color=ROPF_DITHER+RED<<16+WHITE;
|
||||
GrFillTri0(dc,&tempt->t[0]->pt,&tempt->t[1]->pt,&tempt->t[2]->pt);
|
||||
} else {
|
||||
(*dc->lighting)(dc,&tempt->t[0]->pt,&tempt->t[1]->pt,&tempt->t[2]->pt,tempt->mt.color);
|
||||
(*dc->lighting)(dc,&tempt->t[0]->pt,&tempt->t[1]->pt,
|
||||
&tempt->t[2]->pt,tempt->mt.color);
|
||||
GrFillTri0(dc,&tempt->t[0]->pt,&tempt->t[1]->pt,&tempt->t[2]->pt);
|
||||
}
|
||||
}
|
||||
@@ -440,7 +442,7 @@ U0 MPDrawIt(CMeshFrame *e)
|
||||
}
|
||||
dc->r=old_r;
|
||||
|
||||
//e->dc's depth buf was copied but we don't want it freed during $LK,"DCDel",A="MN:DCDel"$().
|
||||
//e->dc's depth buf was copied but we don't want it freed during $LK,"DCDel",A="MN:DCDel"$().
|
||||
dc->depth_buf=NULL;
|
||||
|
||||
DCDel(dc);
|
||||
@@ -451,14 +453,14 @@ I64 *MeshW2S(CMeshFrame *e,CTask *task)
|
||||
{//World to screen coordinate transform matrix.
|
||||
CCtrl *c=CtrlFindUnique(task,CTRLT_VIEWING_ANGLES);
|
||||
CViewAngles *s=c->state;
|
||||
I64 *r=GrIdentNew(task);
|
||||
GrScaleEqu(r,e->view_scale);
|
||||
GrRotZEqu(r,s->az);
|
||||
GrRotYEqu(r,s->ay);
|
||||
I64 *r=Mat4x4IdentNew(task);
|
||||
Mat4x4Scale(r,e->view_scale);
|
||||
Mat4x4RotZ(r,s->az);
|
||||
Mat4x4RotY(r,s->ay);
|
||||
if (e->flip_y)
|
||||
GrRotXEqu(r,s->ax);
|
||||
Mat4x4RotX(r,s->ax);
|
||||
else
|
||||
GrRotXEqu(r,s->ax+ã);
|
||||
Mat4x4RotX(r,s->ax+ã);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -466,14 +468,14 @@ I64 *MeshS2W(CMeshFrame *e,CTask *task)
|
||||
{//Screen to world coordinate transform matrix.
|
||||
CCtrl *c=CtrlFindUnique(task,CTRLT_VIEWING_ANGLES);
|
||||
CViewAngles *s=c->state;
|
||||
I64 *r=GrIdentNew(task);
|
||||
I64 *r=Mat4x4IdentNew(task);
|
||||
if (e->flip_y)
|
||||
GrRotXEqu(r,-s->ax);
|
||||
Mat4x4RotX(r,-s->ax);
|
||||
else
|
||||
GrRotXEqu(r,-(s->ax+ã));
|
||||
GrRotYEqu(r,-s->ay);
|
||||
GrRotZEqu(r,-s->az);
|
||||
GrScaleEqu(r,1/e->view_scale);
|
||||
Mat4x4RotX(r,-(s->ax+ã));
|
||||
Mat4x4RotY(r,-s->ay);
|
||||
Mat4x4RotZ(r,-s->az);
|
||||
Mat4x4Scale(r,1/e->view_scale);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -483,32 +485,34 @@ I64 *MeshSetW2S(CMeshFrame *e,CTask *task)
|
||||
e->w2s=MeshW2S(e,task);
|
||||
Free(e->s2w);
|
||||
e->s2w=MeshS2W(e,task);
|
||||
return MAllocIdentical(e->w2s,task); //returned matrix is assigned to dc->r and will be freed by $LK,"DCDel",A="MN:DCDel"$().
|
||||
//returned matrix is assigned to dc->r and will be freed by $LK,"DCDel",A="MN:DCDel"$().
|
||||
return Mat4x4New(e->w2s,task);
|
||||
}
|
||||
|
||||
U0 MeshCursorW(CMeshFrame *e,CTask *task,I64 *_x,I64 *_y,I64 *_z)
|
||||
{
|
||||
I64 x_shadow,y_shadow,z_shadow,
|
||||
xc=ip.pos.x-task->pix_left-task->scroll_x-e->cx,yc=ip.pos.y-task->pix_top-task->scroll_y-e->cy,zc=0,
|
||||
xc=ip.pos.x-task->pix_left-task->scroll_x-e->cx,
|
||||
yc=ip.pos.y-task->pix_top-task->scroll_y-e->cy,zc=0,
|
||||
x=0,y=0,z=e->my_ip_z,
|
||||
i,x2,y2,z2;
|
||||
GrRot(e->w2s,&x,&y,&z); //screen of Z vect
|
||||
Mat4x4MulXYZ(e->w2s,&x,&y,&z); //screen of Z vect
|
||||
|
||||
//Converges onto a solution for zc, an unknown.
|
||||
//Converges onto a solution for zc, an unknown.
|
||||
for (i=0;i<128;i++) {
|
||||
x_shadow=xc-x; //Shadow of mouse cursor on xy plane
|
||||
y_shadow=yc-y;
|
||||
z_shadow=zc-z;
|
||||
GrRot(e->s2w,&x_shadow,&y_shadow,&z_shadow);
|
||||
Mat4x4MulXYZ(e->s2w,&x_shadow,&y_shadow,&z_shadow);
|
||||
x2=0; y2=0; z2=-z_shadow;
|
||||
GrRot(e->w2s,&x2,&y2,&z2);
|
||||
Mat4x4MulXYZ(e->w2s,&x2,&y2,&z2);
|
||||
zc+=Round(Sqrt(x2*x2+y2*y2+z2*z2))*SignI64(z2);
|
||||
}
|
||||
|
||||
x=xc-x;
|
||||
y=yc-y;
|
||||
z=zc-z;
|
||||
GrRot(e->s2w,&x,&y,&z);
|
||||
Mat4x4MulXYZ(e->s2w,&x,&y,&z);
|
||||
x=RoundI64(x,e->cur_snap);
|
||||
y=RoundI64(y,e->cur_snap);
|
||||
z=RoundI64(e->my_ip_z,e->cur_snap);
|
||||
@@ -552,7 +556,7 @@ U0 MeshClipboardCopy(CMeshFrame *e)
|
||||
}
|
||||
while (tempt!=&e->tri_root) {
|
||||
if (tempt->flags&TF_SELECTED &&
|
||||
tempt->t[0]->copy && tempt->t[1]->copy && tempt->t[2]->copy) {
|
||||
tempt->t[0]->copy && tempt->t[1]->copy && tempt->t[2]->copy) {
|
||||
tempt2=ACAlloc(sizeof(CMeshEdTri));
|
||||
tempt2->t[0]=tempt->t[0]->copy;
|
||||
tempt2->t[1]=tempt->t[1]->copy;
|
||||
@@ -608,7 +612,7 @@ U0 MeshClipboardPaste(CMeshFrame *e)
|
||||
{
|
||||
CMeshEdVertex *tempv2=sys_clipboard_vertex_root.next,*tempv;
|
||||
CMeshEdTri *tempt2=sys_clipboard_tri_root.next,*tempt;
|
||||
|
||||
|
||||
MeshVertexSelectAll(e,FALSE);
|
||||
MeshTriSelectAll(e,FALSE);
|
||||
while (tempv2!=&sys_clipboard_vertex_root) {
|
||||
@@ -620,7 +624,8 @@ U0 MeshClipboardPaste(CMeshFrame *e)
|
||||
}
|
||||
|
||||
while (tempt2!=&sys_clipboard_tri_root) {
|
||||
tempt=MeshTriNew(e,tempt2->mt.color,tempt2->t[0]->copy,tempt2->t[1]->copy,tempt2->t[2]->copy);
|
||||
tempt=MeshTriNew(e,tempt2->mt.color,tempt2->t[0]->copy,
|
||||
tempt2->t[1]->copy,tempt2->t[2]->copy);
|
||||
tempt->flags|=TF_SELECTED;
|
||||
tempt2=tempt2->next;
|
||||
}
|
||||
@@ -635,7 +640,7 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
F64 d;
|
||||
I64 i,x,y,z;
|
||||
CMeshEdVertex *tempv;
|
||||
|
||||
|
||||
task->horz_scroll.min=-(MESH_WORKSPACE_SIZE-task->pix_width)/2;
|
||||
task->horz_scroll.max= (MESH_WORKSPACE_SIZE-task->pix_width)/2;
|
||||
task->vert_scroll.min=-(MESH_WORKSPACE_SIZE-task->pix_height)/2;
|
||||
@@ -646,16 +651,16 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
dc->flags|=DCF_TRANSFORMATION;
|
||||
|
||||
Free(dc->r); //Set rotmat doesn't free old dc->r matrix.
|
||||
GrSetRotMat(dc,MeshSetW2S(e,task));
|
||||
DCMat4x4Set(dc,MeshSetW2S(e,task));
|
||||
|
||||
dc->x=e->cx;
|
||||
dc->y=e->cy;
|
||||
//z-vals less than zero are in front of screen and not drawn.
|
||||
//we want to shift all Z-vals into a drawable range.
|
||||
//GR_Z_ALL is set to half of the Z-range which is an I32.
|
||||
//we want to shift all Z-vals into a drawable range.
|
||||
//GR_Z_ALL is set to half of the Z-range which is an I32.
|
||||
dc->z=GR_Z_ALL;
|
||||
|
||||
//Light source set to input pointer (mouse).
|
||||
//Light source set to input pointer (mouse).
|
||||
MeshCursorW(e,task,&x,&y,&z);
|
||||
dc->ls.x=x;
|
||||
dc->ls.y=y;
|
||||
@@ -665,7 +670,7 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
dc->ls.y*=d;
|
||||
dc->ls.z*=d;
|
||||
|
||||
DCAllocDepthBuf(dc);
|
||||
DCDepthBufAlloc(dc);
|
||||
|
||||
tempv=e->vertex_root.next;
|
||||
while (tempv!=&e->vertex_root) {
|
||||
@@ -694,9 +699,11 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
if (tempv->flags&VF_SELECTED) {
|
||||
if (e->mode=='t') {
|
||||
if (Blink(10)) //This blinks at 10 Hz.
|
||||
dc->color=ROPF_DITHER+e->cur_color.c0.color<<16+e->cur_color.c0.color^8;
|
||||
dc->color=ROPF_DITHER+e->cur_color.c0.color<<16+
|
||||
e->cur_color.c0.color^8;
|
||||
else
|
||||
dc->color=ROPF_DITHER+(e->cur_color.c0.color^8)<<16+e->cur_color.c0.color;
|
||||
dc->color=ROPF_DITHER+(e->cur_color.c0.color^8)<<16+
|
||||
e->cur_color.c0.color;
|
||||
} else {
|
||||
if (Blink)
|
||||
dc->color=ROPF_DITHER+RED<<16+WHITE;
|
||||
@@ -713,7 +720,8 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
task->win_inhibit=WIF_SELF_DOC;
|
||||
} else {
|
||||
MeshCurSnap(e);
|
||||
task->win_inhibit=WIG_TASK_DFT|WIF_SELF_DOC-WIF_SELF_FOCUS-WIF_SELF_BORDER-WIF_SELF_CTRLS-WIF_FOCUS_TASK_MENU-WIF_SELF_GRAB_SCROLL;
|
||||
task->win_inhibit=WIG_TASK_DFT|WIF_SELF_DOC-WIF_SELF_FOCUS-WIF_SELF_BORDER
|
||||
-WIF_SELF_CTRLS-WIF_FOCUS_TASK_MENU-WIF_SELF_GRAB_SCROLL;
|
||||
}
|
||||
|
||||
MeshCursorW(e,task,&x,&y,&z);
|
||||
@@ -808,8 +816,8 @@ I64 MeshSize(CMeshFrame *e)
|
||||
tempt=tempt->next;
|
||||
}
|
||||
return sizeof(I32)*2+
|
||||
(offset(CMeshEdVertex.end)-offset(CMeshEdVertex.start))*e->vertex_cnt+
|
||||
(offset(CMeshEdTri.end)-offset(CMeshEdTri.start))*e->tri_cnt;
|
||||
(offset(CMeshEdVertex.end)-offset(CMeshEdVertex.start))*e->vertex_cnt+
|
||||
(offset(CMeshEdTri.end)-offset(CMeshEdTri.start))*e->tri_cnt;
|
||||
}
|
||||
|
||||
I32 *MeshSave(CMeshFrame *e,I64 *_size=NULL)
|
||||
@@ -824,7 +832,8 @@ I32 *MeshSave(CMeshFrame *e,I64 *_size=NULL)
|
||||
|
||||
e->vertex_cnt=0;
|
||||
while (tempv!=&e->vertex_root) {
|
||||
MemCpy(dst,&tempv->start,offset(CMeshEdVertex.end)-offset(CMeshEdVertex.start));
|
||||
MemCpy(dst,&tempv->start,offset(CMeshEdVertex.end)
|
||||
-offset(CMeshEdVertex.start));
|
||||
dst+=offset(CMeshEdVertex.end)-offset(CMeshEdVertex.start);
|
||||
tempv=tempv->next;
|
||||
}
|
||||
@@ -869,10 +878,10 @@ U0 MeshUpdateMenu(CMeshFrame *e)
|
||||
I32 *SpriteMeshEd(I32 *root=NULL,I64 *_size=NULL,Bool flip_y=FALSE)
|
||||
{/*Fmt for mesh:
|
||||
{
|
||||
I32 vertex_cnt;
|
||||
I32 tri_cnt;
|
||||
CD3I32 vertices[];
|
||||
CMeshTri tris[];
|
||||
I32 vertex_cnt;
|
||||
I32 tri_cnt;
|
||||
CD3I32 vertices[];
|
||||
CMeshTri tris[];
|
||||
}
|
||||
|
||||
If root points to a mesh, it will load it.
|
||||
@@ -906,58 +915,58 @@ $WW,0$*/
|
||||
s->cz=GREEN;
|
||||
|
||||
MenuPush(
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Edit {"
|
||||
" Delete(,,SC_DELETE);"
|
||||
" DelLast(,CH_BACKSPACE);"
|
||||
" Cut(,CH_CTRLX);"
|
||||
" Copy(,CH_CTRLC);"
|
||||
" Paste(,CH_CTRLV);"
|
||||
" SelectAll(,'A');"
|
||||
" UnSelectAll(,'U');"
|
||||
" SelectRect(,'a');"
|
||||
" UnSelectRect(,'u');"
|
||||
" OrSelectRect(,'o');"
|
||||
" JumpToZ(,'j');"
|
||||
" FlipTri(,'f');"
|
||||
"}"
|
||||
"Mode {"
|
||||
" PlaceVertex(,'v');"
|
||||
" MoveVertex(,'m');"
|
||||
" MoveVertexZ(,'M');"
|
||||
" MakeTri(,'t');"
|
||||
"}"
|
||||
"Settings {"
|
||||
" Color(,'c');"
|
||||
" Snap(,'s');"
|
||||
"}"
|
||||
"View {"
|
||||
" ZoomIn(,'z');"
|
||||
" ZoomOut(,'Z');"
|
||||
" NullAngles(,'n');"
|
||||
" FlipY(,'y');"
|
||||
" Grid(,'g');"
|
||||
" Vertex(,'V');"
|
||||
" ToggleBorder(,CH_CTRLB);"
|
||||
"}"
|
||||
"Transforms {"
|
||||
" Transform(,'T');"
|
||||
" SwapXY(,'1');"
|
||||
" SwapXZ(,'2');"
|
||||
" SwapYZ(,'3');"
|
||||
" InvertX(,'4');"
|
||||
" InvertY(,'5');"
|
||||
" InvertZ(,'6');"
|
||||
" FlipTri(,'F');"
|
||||
"}");
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
" Exit(,CH_ESC);"
|
||||
"}"
|
||||
"Edit {"
|
||||
" Delete(,,SC_DELETE);"
|
||||
" DelLast(,CH_BACKSPACE);"
|
||||
" Cut(,CH_CTRLX);"
|
||||
" Copy(,CH_CTRLC);"
|
||||
" Paste(,CH_CTRLV);"
|
||||
" SelectAll(,'A');"
|
||||
" UnSelectAll(,'U');"
|
||||
" SelectRect(,'a');"
|
||||
" UnSelectRect(,'u');"
|
||||
" OrSelectRect(,'o');"
|
||||
" JumpToZ(,'j');"
|
||||
" FlipTri(,'f');"
|
||||
"}"
|
||||
"Mode {"
|
||||
" PlaceVertex(,'v');"
|
||||
" MoveVertex(,'m');"
|
||||
" MoveVertexZ(,'M');"
|
||||
" MakeTri(,'t');"
|
||||
"}"
|
||||
"Settings {"
|
||||
" Color(,'c');"
|
||||
" Snap(,'s');"
|
||||
"}"
|
||||
"View {"
|
||||
" ZoomIn(,'z');"
|
||||
" ZoomOut(,'Z');"
|
||||
" NullAngles(,'n');"
|
||||
" FlipY(,'y');"
|
||||
" Grid(,'g');"
|
||||
" Vertex(,'V');"
|
||||
" ToggleBorder(,CH_CTRLB);"
|
||||
"}"
|
||||
"Transforms {"
|
||||
" Transform(,'T');"
|
||||
" SwapXY(,'1');"
|
||||
" SwapXZ(,'2');"
|
||||
" SwapYZ(,'3');"
|
||||
" InvertX(,'4');"
|
||||
" InvertY(,'5');"
|
||||
" InvertZ(,'6');"
|
||||
" FlipTri(,'F');"
|
||||
"}");
|
||||
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
AutoComplete;
|
||||
Preempt(OFF); //We don't really want window update while modifying links
|
||||
AcctOneTimePopUp(ARf_MESH_ED,
|
||||
Preempt; //We don't really want window update while modifying links
|
||||
RegOneTimePopUp(ARf_MESH_ED,
|
||||
"$$GREEN$$Right Mouse$$FG$$: Hold and move to shift cursor z\n"
|
||||
"$$GREEN$$'j'$$FG$$: Jump cursor Z to nearest vertex's Z\n"
|
||||
"$$GREEN$$'v'$$FG$$: Place Vertex Mode\n"
|
||||
@@ -968,7 +977,8 @@ $WW,0$*/
|
||||
"$$GREEN$$'s'$$FG$$: Set snap\n"
|
||||
"\nSee menu at top of screen for more.\n");
|
||||
|
||||
Fs->win_inhibit=WIG_TASK_DFT|WIF_SELF_DOC-WIF_SELF_FOCUS-WIF_SELF_BORDER-WIF_SELF_CTRLS-WIF_FOCUS_TASK_MENU-WIF_SELF_GRAB_SCROLL;
|
||||
Fs->win_inhibit=WIG_TASK_DFT|WIF_SELF_DOC-WIF_SELF_FOCUS-WIF_SELF_BORDER
|
||||
-WIF_SELF_CTRLS-WIF_FOCUS_TASK_MENU-WIF_SELF_GRAB_SCROLL;
|
||||
Fs->horz_scroll.pos=0;
|
||||
Fs->vert_scroll.pos=0;
|
||||
MeshInit(&e,flip_y);
|
||||
@@ -982,7 +992,8 @@ $WW,0$*/
|
||||
try {//In case of <CTRL-ALT-c>
|
||||
while (TRUE) {
|
||||
MeshUpdateMenu(&e);
|
||||
msg_code=GetMsg(&a1,&a2,1<<MSG_IP_MOVE|1<<MSG_KEY_DOWN|1<<MSG_IP_L_DOWN|1<<MSG_IP_L_UP|1<<MSG_IP_R_DOWN|1<<MSG_IP_R_UP);
|
||||
msg_code=GetMsg(&a1,&a2,1<<MSG_IP_MOVE|1<<MSG_KEY_DOWN|1<<MSG_IP_L_DOWN|
|
||||
1<<MSG_IP_L_UP|1<<MSG_IP_R_DOWN|1<<MSG_IP_R_UP);
|
||||
gm_restart:
|
||||
switch (msg_code) {
|
||||
case MSG_KEY_DOWN:
|
||||
@@ -999,7 +1010,9 @@ gm_restart:
|
||||
if (MeshSelectCnt(&e))
|
||||
MeshClipboardDel(&e);
|
||||
else if (e.mode!='t')
|
||||
MeshVertexDel(&e,MeshVertexFindScrPt(&e,ip.presnap.x-Fs->pix_left-Fs->scroll_x,ip.presnap.y-Fs->pix_top-Fs->scroll_y));
|
||||
MeshVertexDel(&e,MeshVertexFindScrPt(&e,
|
||||
ip.presnap.x-Fs->pix_left-Fs->scroll_x,
|
||||
ip.presnap.y-Fs->pix_top-Fs->scroll_y));
|
||||
MeshVertexSelectAll(&e,FALSE);
|
||||
MeshTriSelectAll(&e,FALSE);
|
||||
vn=0;
|
||||
@@ -1071,7 +1084,9 @@ gm_restart:
|
||||
i=MESH_AND;
|
||||
else
|
||||
i=MESH_OR;
|
||||
if ((msg_code=GetMsg(&a1,&a2,1<<MSG_KEY_DOWN|1<<MSG_IP_L_DOWN|1<<MSG_IP_L_UP|1<<MSG_IP_R_DOWN|1<<MSG_IP_R_UP))!=MSG_IP_L_DOWN) {
|
||||
if ((msg_code=GetMsg(&a1,&a2,1<<MSG_KEY_DOWN|1<<MSG_IP_L_DOWN|
|
||||
1<<MSG_IP_L_UP|1<<MSG_IP_R_DOWN|1<<MSG_IP_R_UP))
|
||||
!=MSG_IP_L_DOWN) {
|
||||
Beep; Beep;
|
||||
goto gm_restart;
|
||||
}
|
||||
@@ -1079,7 +1094,9 @@ gm_restart:
|
||||
e.x2=a1; e.y2=a2;
|
||||
e.select_rect=TRUE;
|
||||
while (TRUE) {
|
||||
msg_code=GetMsg(&a1,&a2,1<<MSG_IP_MOVE|1<<MSG_KEY_DOWN|1<<MSG_IP_L_DOWN|1<<MSG_IP_L_UP|1<<MSG_IP_R_DOWN|1<<MSG_IP_R_UP);
|
||||
msg_code=GetMsg(&a1,&a2,1<<MSG_IP_MOVE|1<<MSG_KEY_DOWN|
|
||||
1<<MSG_IP_L_DOWN|1<<MSG_IP_L_UP|1<<MSG_IP_R_DOWN|
|
||||
1<<MSG_IP_R_UP);
|
||||
if (msg_code==MSG_IP_MOVE) {
|
||||
e.x2=a1; e.y2=a2;
|
||||
} else if (msg_code==MSG_IP_L_UP) {
|
||||
@@ -1159,7 +1176,9 @@ gm_restart:
|
||||
case 'j':
|
||||
if (moving)
|
||||
MeshVertexIgnoreSet(&e,TRUE);
|
||||
if (tempv=MeshVertexFindScrPt(&e,ip.pos.x-Fs->pix_left-Fs->scroll_x,ip.pos.y-Fs->pix_top-Fs->scroll_y)) {
|
||||
if (tempv=MeshVertexFindScrPt(&e,
|
||||
ip.pos.x-Fs->pix_left-Fs->scroll_x,
|
||||
ip.pos.y-Fs->pix_top-Fs->scroll_y)) {
|
||||
Noise(25,2000,8000);
|
||||
e.my_ip_z=RoundI64(tempv->p.z,e.cur_snap);
|
||||
} else {
|
||||
@@ -1212,7 +1231,7 @@ gm_restart:
|
||||
case 'm':
|
||||
if (!moving) {
|
||||
if (!MeshSelectCnt(&e) &&
|
||||
(tempv=MeshVertexFindScrPt(&e,a1,a2))) {
|
||||
(tempv=MeshVertexFindScrPt(&e,a1,a2))) {
|
||||
tempv->flags|=VF_SELECTED;
|
||||
e.my_ip_z=RoundI64(tempv->p.z,e.cur_snap);
|
||||
}
|
||||
@@ -1229,7 +1248,7 @@ gm_restart:
|
||||
case 'M':
|
||||
if (!adjusting_z && !moving) {
|
||||
if (!MeshSelectCnt(&e) &&
|
||||
(tempv=MeshVertexFindScrPt(&e,a1,a2))) {
|
||||
(tempv=MeshVertexFindScrPt(&e,a1,a2))) {
|
||||
tempv->flags|=VF_SELECTED;
|
||||
e.my_ip_z=RoundI64(tempv->p.z,e.cur_snap);
|
||||
}
|
||||
@@ -1262,7 +1281,9 @@ gm_restart:
|
||||
case 'M':
|
||||
if (moving) {
|
||||
if (adjusting_z) {
|
||||
e.my_ip_z=RoundI64(Sign(p0b.y-ip.presnap.y)*Sqrt(Sqr(p0b.x-ip.presnap.x)+Sqr(p0b.y-ip.presnap.y))+p0b.z,e.cur_snap);
|
||||
e.my_ip_z=RoundI64(Sign(p0b.y-ip.presnap.y)
|
||||
*Sqrt(Sqr(p0b.x-ip.presnap.x)+Sqr(p0b.y-ip.presnap.y))
|
||||
+p0b.z,e.cur_snap);
|
||||
Snd(0);
|
||||
adjusting_z=FALSE;
|
||||
MeshCursorW(&e,Fs,&x,&y,&z);
|
||||
@@ -1317,7 +1338,9 @@ gm_restart:
|
||||
break;
|
||||
case MSG_IP_R_UP:
|
||||
if (e.mode!='M' && adjusting_z) {
|
||||
e.my_ip_z=RoundI64(Sign(p0b.y-ip.presnap.y)*Sqrt(Sqr(p0b.x-ip.presnap.x)+Sqr(p0b.y-ip.presnap.y))+p0b.z,e.cur_snap);
|
||||
e.my_ip_z=RoundI64(Sign(p0b.y-ip.presnap.y)
|
||||
*Sqrt(Sqr(p0b.x-ip.presnap.x)+Sqr(p0b.y-ip.presnap.y))
|
||||
+p0b.z,e.cur_snap);
|
||||
Snd(0);
|
||||
adjusting_z=FALSE;
|
||||
if (moving) {
|
||||
@@ -1332,7 +1355,9 @@ gm_restart:
|
||||
break;
|
||||
case MSG_IP_MOVE:
|
||||
if (adjusting_z) {
|
||||
e.my_ip_z=RoundI64(Sign(p0b.y-ip.presnap.y)*Sqrt(Sqr(p0b.x-ip.presnap.x)+Sqr(p0b.y-ip.presnap.y))+p0b.z,e.cur_snap);
|
||||
e.my_ip_z=RoundI64(Sign(p0b.y-ip.presnap.y)
|
||||
*Sqrt(Sqr(p0b.x-ip.presnap.x)+Sqr(p0b.y-ip.presnap.y))
|
||||
+p0b.z,e.cur_snap);
|
||||
Snd(ClampI64(3*e.my_ip_z+1500,0,15000));
|
||||
}
|
||||
if (moving) {
|
||||
|
||||
+47
-43
@@ -1,40 +1,39 @@
|
||||
#help_index "Graphics/Sprite"
|
||||
#help_index "Graphics/Sprite;Sprites"
|
||||
#help_file "::/Doc/Sprite"
|
||||
|
||||
U8 polypt_map[9]={0,1,2,3,0,4,5,6,7};
|
||||
|
||||
I64 sprite_elem_base_sizes[SPT_NUM_TYPES]=
|
||||
{
|
||||
sizeof(CSpriteBase), //SPT_END
|
||||
sizeof(CSpriteColor), //SPT_COLOR
|
||||
sizeof(CSpriteDitherColor), //SPT_DITHER_COLOR
|
||||
sizeof(CSpriteWidth), //SPT_WIDTH
|
||||
sizeof(CSpritePtPt), //SPT_PLANAR_SYMMETRY
|
||||
sizeof(CSpriteBase), //SPT_TRANSFORM_ON
|
||||
sizeof(CSpriteBase), //SPT_TRANSFORM_OFF
|
||||
sizeof(CSpritePt), //SPT_SHIFT
|
||||
sizeof(CSpritePt), //SPT_PT
|
||||
sizeof(CSpriteNumPtU8s), //SPT_POLYPT
|
||||
sizeof(CSpritePtPt), //SPT_LINE
|
||||
sizeof(CSpriteNumU8s), //SPT_POLYLINE
|
||||
sizeof(CSpritePtPt), //SPT_RECT
|
||||
sizeof(CSpritePtPtAng), //SPT_ROTATED_RECT
|
||||
sizeof(CSpritePtRad), //SPT_CIRCLE
|
||||
sizeof(CSpritePtWHAng), //SPT_ELLIPSE
|
||||
sizeof(CSpritePtWHAngSides), //SPT_POLYGON
|
||||
sizeof(CSpriteNumU8s), //SPT_BSPLINE2
|
||||
sizeof(CSpriteNumU8s), //SPT_BSPLINE2_CLOSED
|
||||
sizeof(CSpriteNumU8s), //SPT_BSPLINE3
|
||||
sizeof(CSpriteNumU8s), //SPT_BSPLINE3_CLOSED
|
||||
sizeof(CSpritePt), //SPT_FLOOD_FILL
|
||||
sizeof(CSpritePt), //SPT_FLOOD_FILL_NOT
|
||||
sizeof(CSpritePtWHU8s), //SPT_BITMAP
|
||||
sizeof(CSpriteMeshU8s), //SPT_MESH
|
||||
sizeof(CSpritePtMeshU8s), //SPT_SHIFTABLE_MESH
|
||||
sizeof(CSpritePtPt), //SPT_ARROW
|
||||
sizeof(CSpritePtStr), //SPT_TEXT
|
||||
sizeof(CSpritePtStr), //SPT_TEXT_BOX
|
||||
sizeof(CSpritePtStr), //SPT_TEXT_DIAMOND
|
||||
I64 sprite_elem_base_sizes[SPT_NUM_TYPES]={
|
||||
sizeof(CSpriteBase), //SPT_END
|
||||
sizeof(CSpriteColor), //SPT_COLOR
|
||||
sizeof(CSpriteDitherColor), //SPT_DITHER_COLOR
|
||||
sizeof(CSpriteW), //SPT_WIDTH
|
||||
sizeof(CSpritePtPt), //SPT_PLANAR_SYMMETRY
|
||||
sizeof(CSpriteBase), //SPT_TRANSFORM_ON
|
||||
sizeof(CSpriteBase), //SPT_TRANSFORM_OFF
|
||||
sizeof(CSpritePt), //SPT_SHIFT
|
||||
sizeof(CSpritePt), //SPT_PT
|
||||
sizeof(CSpriteNumPtU8s), //SPT_POLYPT
|
||||
sizeof(CSpritePtPt), //SPT_LINE
|
||||
sizeof(CSpriteNumU8s), //SPT_POLYLINE
|
||||
sizeof(CSpritePtPt), //SPT_RECT
|
||||
sizeof(CSpritePtPtAng), //SPT_ROTATED_RECT
|
||||
sizeof(CSpritePtRad), //SPT_CIRCLE
|
||||
sizeof(CSpritePtWHAng), //SPT_ELLIPSE
|
||||
sizeof(CSpritePtWHAngSides), //SPT_POLYGON
|
||||
sizeof(CSpriteNumU8s), //SPT_BSPLINE2
|
||||
sizeof(CSpriteNumU8s), //SPT_BSPLINE2_CLOSED
|
||||
sizeof(CSpriteNumU8s), //SPT_BSPLINE3
|
||||
sizeof(CSpriteNumU8s), //SPT_BSPLINE3_CLOSED
|
||||
sizeof(CSpritePt), //SPT_FLOOD_FILL
|
||||
sizeof(CSpritePt), //SPT_FLOOD_FILL_NOT
|
||||
sizeof(CSpritePtWHU8s), //SPT_BITMAP
|
||||
sizeof(CSpriteMeshU8s), //SPT_MESH
|
||||
sizeof(CSpritePtMeshU8s), //SPT_SHIFTABLE_MESH
|
||||
sizeof(CSpritePtPt), //SPT_ARROW
|
||||
sizeof(CSpritePtStr), //SPT_TEXT
|
||||
sizeof(CSpritePtStr), //SPT_TEXT_BOX
|
||||
sizeof(CSpritePtStr), //SPT_TEXT_DIAMOND
|
||||
};
|
||||
|
||||
I64 SpriteElemQuedBaseSize(I64 type)
|
||||
@@ -67,10 +66,12 @@ I64 SpriteElemSize(CSprite *tempg)
|
||||
i+=tempg->nu.num*sizeof(CD3I32);
|
||||
break;
|
||||
case SPT_MESH:
|
||||
i+=tempg->mu.vertex_cnt*sizeof(CD3I32)+tempg->mu.tri_cnt*sizeof(CMeshTri);
|
||||
i+=tempg->mu.vertex_cnt*sizeof(CD3I32)+
|
||||
tempg->mu.tri_cnt*sizeof(CMeshTri);
|
||||
break;
|
||||
case SPT_SHIFTABLE_MESH:
|
||||
i+=tempg->pmu.vertex_cnt*sizeof(CD3I32)+tempg->pmu.tri_cnt*sizeof(CMeshTri);
|
||||
i+=tempg->pmu.vertex_cnt*sizeof(CD3I32)+
|
||||
tempg->pmu.tri_cnt*sizeof(CMeshTri);
|
||||
break;
|
||||
}
|
||||
return i;
|
||||
@@ -101,9 +102,9 @@ public U8 *DC2Sprite(CDC *tempb)
|
||||
{//Convert device context to sprite.
|
||||
CSprite *tempg;
|
||||
tempg=CAlloc(sprite_elem_base_sizes[SPT_BITMAP]+
|
||||
tempb->width_internal*tempb->height+
|
||||
sprite_elem_base_sizes[SPT_END])
|
||||
(U8 *)-offset(CSprite.start);
|
||||
tempb->width_internal*tempb->height+
|
||||
sprite_elem_base_sizes[SPT_END])
|
||||
(U8 *)-offset(CSprite.start);
|
||||
tempg->type=SPT_BITMAP;
|
||||
tempg->pwhu.width=tempb->width;
|
||||
tempg->pwhu.height=tempb->height;
|
||||
@@ -113,9 +114,9 @@ public U8 *DC2Sprite(CDC *tempb)
|
||||
return tempg(U8 *)+offset(CSprite.start);
|
||||
}
|
||||
|
||||
public U8 *SpriteElem2OneLineSummary(CSprite *tempg)
|
||||
public U8 *SpriteElem2Summary(CSprite *tempg)
|
||||
{//Study $LK,"::/Demo/Graphics/SpriteText.CPP"$.
|
||||
U8 buf[256],buf2[136];
|
||||
U8 buf[STR_LEN],buf2[STR_LEN];
|
||||
I32 *ptr;
|
||||
StrPrint(buf,"%Z",tempg->type,"ST_SPRITE_ELEM_TYPES");
|
||||
switch (tempg->type) {
|
||||
@@ -123,7 +124,8 @@ public U8 *SpriteElem2OneLineSummary(CSprite *tempg)
|
||||
CatPrint(buf," %s",Color2Str(buf2,tempg->c.color));
|
||||
break;
|
||||
case SPT_DITHER_COLOR:
|
||||
CatPrint(buf," %s",Color2Str(buf2,ROPF_DITHER|tempg->d.dither_color.u8[0]|tempg->d.dither_color.u8[1]<<COLORROP_BITS));
|
||||
CatPrint(buf," %s",Color2Str(buf2,ROPF_DITHER|tempg->d.dither_color.u8[0]|
|
||||
tempg->d.dither_color.u8[1]<<COLORROP_BITS));
|
||||
break;
|
||||
case SPT_PT:
|
||||
case SPT_FLOOD_FILL:
|
||||
@@ -136,7 +138,8 @@ public U8 *SpriteElem2OneLineSummary(CSprite *tempg)
|
||||
case SPT_PLANAR_SYMMETRY:
|
||||
case SPT_RECT:
|
||||
case SPT_ROTATED_RECT:
|
||||
CatPrint(buf," (%d,%d),(%d,%d)",tempg->pp.x1,tempg->pp.y1,tempg->pp.x2,tempg->pp.y2);
|
||||
CatPrint(buf," (%d,%d),(%d,%d)",tempg->pp.x1,tempg->pp.y1,
|
||||
tempg->pp.x2,tempg->pp.y2);
|
||||
break;
|
||||
case SPT_CIRCLE:
|
||||
CatPrint(buf," (%d,%d):%dR",tempg->pr.x1,tempg->pr.y1,tempg->pr.radius);
|
||||
@@ -157,7 +160,8 @@ public U8 *SpriteElem2OneLineSummary(CSprite *tempg)
|
||||
case SPT_ELLIPSE:
|
||||
case SPT_POLYGON:
|
||||
case SPT_BITMAP:
|
||||
CatPrint(buf," (%d,%d):%dW,%dH",tempg->pwhu.x1,tempg->pwhu.y1,tempg->pwhu.width,tempg->pwhu.height);
|
||||
CatPrint(buf," (%d,%d):%dW,%dH",tempg->pwhu.x1,tempg->pwhu.y1,
|
||||
tempg->pwhu.width,tempg->pwhu.height);
|
||||
break;
|
||||
case SPT_BSPLINE2:
|
||||
case SPT_BSPLINE3:
|
||||
|
||||
Reference in new issue
Block a user