📄 lianp.c
字号:
} /* of tryy */
}
void IsLink21p12(void)
{
int ix,iy,tryx;
int tryok;
for(tryx=selected2x+1;tryx<=MAX_X+1;tryx++)
/* there are many link path with different tryx */
{
tryok = 1;
/* check the path left down */
for(ix=selected1x+1;ix<=tryx;ix++)
if(matrix[ix][selected1y]!=0)
if(ix<=MAX_X) tryok = 0;
/* else ix>MAX_X, outside matrix, always can link */
/* check the go down path */
if(tryok)
{
for(iy=selected1y+1;iy<=selected2y-1;iy++)
if(matrix[tryx][iy]!=0)
if(tryx<=MAX_X) tryok = 0;
/* else tryx<=0, outside matrix, always can link */
}
else continue; /* if <--- path is no ok, goto next tryx */
/* check the go right path */
if(tryok)
{
for(ix=tryx;ix>=selected2x+1;ix--)
if(matrix[ix][selected2y]!=0)
if(ix<=MAX_X) tryok = 0;
/* else ix<=0, outside matrix, always can link */
}
else continue; /* if down path is no ok, goto next tryx */
if(tryok)
{
type2xy = tryx;
LinkType = LINK_21P12;
break; /* do not need to try next one */
}
} /* of tryy */
}
void IsLink21p41(void)
{
int ix,iy,tryx;
int tryok;
for(tryx=selected2x+1;tryx<=MAX_X+1;tryx++)
/* there are many link path with different tryx */
{
tryok = 1;
/* check the path left down */
for(ix=selected2x+1;ix<=tryx;ix++)
if(matrix[ix][selected2y]!=0)
if(ix<=MAX_X) tryok = 0;
/* else ix>MAX_X, outside matrix, always can link */
/* check the go down path */
if(tryok)
{
for(iy=selected2y+1;iy<=selected1y-1;iy++)
if(matrix[tryx][iy]!=0)
if(tryx<=MAX_X) tryok = 0;
/* else tryx<=0, outside matrix, always can link */
}
else continue; /* if <--- path is no ok, goto next tryx */
/* check the go right path */
if(tryok)
{
for(ix=tryx;ix>=selected1x+1;ix--)
if(matrix[ix][selected1y]!=0)
if(ix<=MAX_X) tryok = 0;
/* else ix<=0, outside matrix, always can link */
}
else continue; /* if down path is no ok, goto next tryx */
if(tryok)
{
type2xy = tryx;
LinkType = LINK_21P41;
break; /* do not need to try next one */
}
} /* of tryy */
}
void IsLink21p42(void)
{
int ix,iy,tryx;
int tryok;
for(tryx=selected1x-1;tryx>=0;tryx--)
/* there are many link path with different tryx */
{
tryok = 1;
/* check the path left down */
for(ix=selected2x-1;ix>=tryx;ix--)
if(matrix[ix][selected2y]!=0)
if(ix>0) tryok = 0;
/* else ix<=0, outside matrix, always can link */
/* check the go down path */
if(tryok)
{
for(iy=selected2y+1;iy<=selected1y-1;iy++)
if(matrix[tryx][iy]!=0)
if(tryx>0) tryok = 0;
/* else tryx<=0, outside matrix, always can link */
}
else continue; /* if <--- path is no ok, goto next tryx */
/* check the go right path */
if(tryok)
{
for(ix=tryx;ix<=selected1x-1;ix++)
if(matrix[ix][selected1y]!=0)
if(ix>0) tryok = 0;
/* else ix<=0, outside matrix, always can link */
}
else continue; /* if down path is no ok, goto next tryx */
if(tryok)
{
type2xy = tryx;
LinkType = LINK_21P42;
break; /* do not need to try next one */
}
} /* of tryy */
}
/* ------------------- */
void IsLink22p32(void)
{
int ix,iy,tryx;
int tryok;
if(selected1y>=selected2y) return;
/* it maybe type22p41, not this type */
for(tryx=selected1x+1;tryx<=selected2x-1;tryx++)
/* there are many link path with different tryx */
{
tryok = 1;
/* check the ---> path first */
for(ix=selected1x+1;ix<=tryx;ix++)
if(matrix[ix][selected1y]!=0) tryok = 0;
/* check the go down path */
if(tryok)
{
for(iy=selected1y+1;iy<=selected2y-1;iy++)
if(matrix[tryx][iy]!=0) tryok = 0;
}
else continue; /* if ---> path is no ok, goto next tryx */
/* check the --> path below */
if(tryok)
{
for(ix=tryx;ix<=selected2x-1;ix++)
if(matrix[ix][selected2y]!=0) tryok = 0;
}
else continue;
if(tryok)
{
type2xy = tryx;
LinkType = LINK_22P32;
break; /* do not need to try next one */
}
} /* of tryx */
}
void IsLink22p31(void)
{
int ix,iy,tryy;
int tryok;
if(selected1y>=selected2y) return;
/* it maybe type22p42, not this type */
for(tryy=selected1y+1;tryy<=selected2y-1;tryy++)
/* there are many link path with different tryy */
{
tryok = 1;
/* check the ---> path first */
for(iy=selected1y+1;iy<=tryy;iy++)
if(matrix[selected1x][iy]!=0) tryok = 0;
/* check the go down path */
if(tryok)
{
for(ix=selected1x+1;ix<=selected2x-1;ix++)
if(matrix[ix][tryy]!=0) tryok = 0;
}
else continue; /* if ---> path is no ok, goto next tryx */
/* check the --> path below */
if(tryok)
{
for(iy=tryy;iy<=selected2y-1;iy++)
if(matrix[selected2x][iy]!=0) tryok = 0;
}
else continue;
if(tryok)
{
type2xy = tryy;
LinkType = LINK_22P31;
break; /* do not need to try next one */
}
} /* of tryx */
}
void IsLink22p41(void)
{
int ix,iy,tryx;
int tryok;
if(selected1y<=selected2y) return;
/* it maybe type22p32, not this type */
for(tryx=selected1x+1;tryx<=selected2x-1;tryx++)
/* there are many link path with different tryy */
{
tryok = 1;
/* check the ---> path first */
for(ix=selected1x+1;ix<=tryx;ix++)
if(matrix[ix][selected1y]!=0) tryok = 0;
/* check the go down path */
if(tryok)
{
for(iy=selected1y-1;iy>=selected2y+1;iy--)
if(matrix[tryx][iy]!=0) tryok = 0;
}
else continue; /* if ---> path is no ok, goto next tryy */
/* check the --> path below */
if(tryok)
{
for(ix=tryx;ix<=selected2x-1;ix++)
if(matrix[ix][selected2y]!=0) tryok = 0;
}
else continue;
if(tryok)
{
type2xy = tryx;
LinkType = LINK_22P41;
break; /* do not need to try next one */
}
} /* of tryx */
}
void IsLink22p42(void)
{
int ix,iy,tryy;
int tryok;
if(selected1y<=selected2y) return;
/* it maybe type22p31, not this type */
for(tryy=selected1y-1;tryy>=selected2y+1;tryy--)
/* there are many link path with different tryy */
{
tryok = 1;
/* check the ---> path first */
for(iy=selected1y-1;iy>=tryy;iy--)
if(matrix[selected1x][iy]!=0) tryok = 0;
/* check the go down path */
if(tryok)
{
for(ix=selected1x+1;ix<=selected2x-1;ix++)
if(matrix[ix][tryy]!=0) tryok = 0;
}
else continue; /* if ---> path is no ok, goto next tryx */
/* check the --> path below */
if(tryok)
{
for(iy=tryy;iy>=selected2y+1;iy--)
if(matrix[selected2x][iy]!=0) tryok = 0;
}
else continue;
if(tryok)
{
type2xy = tryy;
LinkType = LINK_22P42;
break; /* do not need to try next one */
}
} /* of tryx */
}
/* ------------- mouse program ------------- */
/*
作者:Crazy Bug工作室 跳蚤侦探
日期:2004年6月19日(上午考英语四级)
简单说明:
本程序是对唯c高级编程里的一个鼠标程序进行的修改,原先的程序在xp系统下无法显示鼠标
我主要把原来系统实现的Mouse.On和Mouse.Off函数自己用程序实现了,另外自己加了个MouseStatus
函数用以判断鼠标的状态,所以使用此函数的话最好用已经写好的MouseStatus来判断鼠标状态。
程序原理主要也就是自己用程序实现异或。
*/
void MouseMath(void)/*计算鼠标的样子*/
{
int i,j,jj,k;
long UpNum[16]=
{
0x3fff,0x1fff,0x0fff,0x07ff,
0x03ff,0x01ff,0x00ff,0x007f,
0x003f,0x00ff,0x01ff,0x10ff,
0x30ff,0xf87f,0xf87f,0xfc3f
};
long DownNum[16]=
{
0x0000,0x7c00,0x6000,0x7000,
0x7800,0x7c00,0x7e00,0x7f00,
0x7f80,0x7e00,0x7c00,0x4600,
0x0600,0x0300,0x0300,0x0180
};
for(i=0;i<16;i++)
{
j=jj=15;
while(UpNum[i]!=0)
{
up[i][j]=UpNum[i]%2;
j--;
UpNum[i]/=2;
} /* of while */
while(DownNum[i]!=0)
{
down[i][jj--]=DownNum[i]%2;
DownNum[i]/=2;
}
for(k=j;k>=0;k--) up[i][k]=0;
for(k=jj;k>=0;k--) down[i][k]=0;
for(k=0;k<16;k++)/*四种组合方式*/
{
if(up[i][k]==0&&down[i][k]==0) mouse_draw[i][k]=1;
else if(up[i][k]==0&&down[i][k]==1) mouse_draw[i][k]=2;
else if(up[i][k]==1&&down[i][k]==0) mouse_draw[i][k]=3;
else mouse_draw[i][k]=4;
}
}
mouse_draw[1][2]=4;/*特殊点*/
}
/*鼠标光标显示*/
void MouseOn(int x,int y)
{
int i,j;
int color;
for(i=0;i<16;i++)/*画鼠标*/
{
for(j=0;j<16;j++)
{
pixel_save[i][j]=getpixel(x+j,y+i);/*保存原来的颜色*/
if(mouse_draw[i][j]==1) putpixel(x+j,y+i,0);
else if(mouse_draw[i][j]==2) putpixel(x+j,y+i,15);
}
}
}
/*隐藏鼠标*/
void MouseOff(void)
{
int i,j,x,y,color;
x=MouseX;
y=MouseY;
for(i=0;i<16;i++)/*原位置异或消去*/
for(j=0;j<16;j++)
{
if(mouse_draw[i][j]==3||mouse_draw[i][j]==4) continue;
/* color=getpixel(x+j,y+i);
putpixel(x+j,y+i,color^color); */
/* this two lines in the original source code is no use. I don't know why */
putpixel(x+j,y+i,pixel_save[i][j]);
}
}
void MouseLoad(void)
/*鼠标是否加载
MouseExist:1=加载
0=未加载
MouseButton:鼠标按键数目 */
{
_AX=0x00;
geninterrupt(0x33);
MouseExist=_AX;
MouseButton=_BX;
}
/*鼠标状态值初始化*/
void MouseReset(void)
{
_AX=0x00;
geninterrupt(0x33);
}
void MouseSetX(int lx,int rx)
/*设置鼠标左右边界
lx:左边界
gx:右边界 */
{
_CX=lx;
_DX=rx;
_AX=0x07;
geninterrupt(0x33);
}
void MouseSetY(int uy,int dy)
/*设置鼠标上下边界
uy:上边界
dy:下边界 */
{
_CX=uy;
_DX=dy;
_AX=0x08;
geninterrupt(0x33);
}
void MouseSetXY(int x,int y)
/*设置鼠标当前位置
x:横向坐标
y:纵向坐标 */
{
_CX=x;
_DX=y;
_AX=0x04;
geninterrupt(0x33);
}
void MouseSpeed(int vx,int vy)
/*设置鼠标速度(缺省值:vx=8,vy=1)
值越大速度越慢 */
{
_CX=vx;
_DX=vy;
_AX=0x0f;
geninterrupt(0x33);
}
int LeftPress(void)
/*获取鼠标按下键的信息*/
/*是否按下左键
返回值: 1=按下 0=释放*/
{
_AX=0x03;
geninterrupt(0x33);
return(_BX&1);
}
int MiddlePress(void)
/*是否按下中键
返回值: 1=按下 0=释放 */
{
_AX=0x03;
geninterrupt(0x33);
return(_BX&4);
}
int RightPress(void)
/*是否按下右键
返回值: 1=按下 0=释放 */
{
_AX=0x03;
geninterrupt(0x33);
return(_BX&2);
}
/*获取鼠标当前位置*/
void MouseGetXY(void)
{
_AX=0x03;
geninterrupt(0x33);
MouseX=_CX;
MouseY=_DX;
}
int MouseStatus(void)/*鼠标按键情况*/
{
int x,y;
int status;
int press=0;
int i,j,color;
status=0;/*默认鼠标没又移动*/
x=MouseX;
y=MouseY;
while(x==MouseX&&y==MouseY&&status==0&&press==0)
{
if(LeftPress()&&RightPress()) press=1;
else if(LeftPress()) press=2;
else if(RightPress()) press=3;
MouseGetXY();
if(MouseX!=x||MouseY!=y) status=1;
}
if(status)/*移动情况才重新显示鼠标*/
{
for(i=0;i<16;i++)/*原位置异或消去*/
for(j=0;j<16;j++)
{
if(mouse_draw[i][j]==3||mouse_draw[i][j]==4) continue;
/* color=getpixel(x+j,y+i);
putpixel(x+j,y+i,color^color); */
/* this two lines in the original source code is no use. I don't know why */
putpixel(x+j,y+i,pixel_save[i][j]);
}
MouseOn(MouseX,MouseY);/*新位置显示*/
}
if(press!=0) return press;/*有按键得情况*/
else return 0;/*只移动得情况*/
}
void InitialMouse(void)
{
MouseMath();/*计算鼠标形状,一开始必须使用,后面就不用了*/
MouseSetY(0,479);
MouseSetX(0,639);
MouseSetXY(DRAW_START_X+10,DRAW_START_Y+10);
MouseOn(MouseX,MouseY);
PressState = 0;
MouseCurX = 1;
MouseCurY = 1;
}
void GetMouseCur(void)
/* 根据鼠标的位置,决定光标的位置
output: MouseCurX, MouseCurY */
{
MouseCurX = 1+((MouseX-DRAW_START_X)/(UNIT_WIDE+2));
MouseCurY = 1+((MouseY-DRAW_START_Y)/(UNIT_HIGH+2));
if(MouseCurX<1) MouseCurX = 1;
if(MouseCurX>MAX_X) MouseCurX = MAX_X;
if(MouseCurY<1) MouseCurY = 1;
if(MouseCurY>MAX_Y) MouseCurY = MAX_Y;
}
/* ----------- end of mouse program ----------------- */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -