📄 ahello.cpp
字号:
//---------------------------------------//
// 程序名: HELLO.CPP
// 功能:系统引导界面
//---------------------------------------//
#include <stdio.h>
#include <stdlib.h>
#include <graphics.h>
#include <dos.h>
#include <bios.h>
#include <process.h>
#include <conio.h>
#include "dps.h";
FILE *fp16;
void Hello();
void InitGraph();
char InitMouse();
void ShowMouse();
void HideMouse();
char LeftPrsd();
char RightPrsd();
void Bar(int,int,int,int);
void ChgColor(int,int,int,int);
void WaitForPrsBt();
void OpenLIB();
void PutCC16(int,int,int,int,char *);
void Quit();
int main()
{
InitGraph();
Hello();
HideMouse();
Quit();
return(0);
}
void InitGraph()
{
int graphmode,graphdriver=DETECT;
registerbgidriver(EGAVGA_driver);
initgraph(&graphdriver,&graphmode,"");
}
void Quit()
{
ChgColor(15,42,42,63);
fcloseall();
closegraph();
exit(0);
}
char InitMouse()
{
union REGS inregs,outregs;
inregs.x.ax=0;
int86(0x33,&inregs,&outregs);
if (outregs.x.ax==0)
return 0;
else
return 1;
}
void ShowMouse()
{
union REGS inregs,outregs;
inregs.x.ax=1;
int86(0x33,&inregs,&inregs);
}
void HideMouse()
{
union REGS inregs,outregs;
inregs.x.ax=2;
int86(0x33,&inregs,&inregs);
}
char LeftPrsd()
{
union REGS inregs,outregs;
inregs.x.ax=3;
int86(0x33,&inregs,&outregs);
return (outregs.x.bx&1);
}
char RightPrsd()
{
union REGS inregs,outregs;
inregs.x.ax=3;
int86(0x33,&inregs,&outregs);
return (outregs.x.bx&1);
}
void Hello()
{
int x,y,len,high,i,status;
char *draw="工程图形处理软件";
char *beau="广东工业大学";
char *date="一九九七年九月";
char *nomouse="鼠标没有安装或没有运行驱动程序";
if(!InitMouse())
{
OpenLIB();
PutCC16(180,200,2,14,nomouse);
fclose(fp16);
status=getch();
closegraph();
exit(status-'0');
}
ChgColor(1,0,55,55);
ChgColor(2,0,35,35);
ChgColor(3,0,45,45);
ChgColor(4,52,0,0);
ChgColor(7,36,36,36);
x=140;
y=25;
len=360;
high=430;
Bar(x,y,len,high);
OpenLIB();
PutCC16(236,122,4,4,draw);
PutCC16(235,121,4,14,draw);
settextstyle(1,0,4);
setcolor(4);
outtextxy(390,116,"DPS");
setcolor(14);
outtextxy(389,115,"DPS");
settextstyle(1,0,2);
setcolor(4);
outtextxy(286,212,"Ver 1.0");
setcolor(14);
outtextxy(285,211,"Ver 1.0");
setcolor(12);
settextstyle(0,0,1);
outtextxy(460,60,"R");
circle(463,63,7);
PutCC16(257,330,4,4,beau);
PutCC16(256,329,4,14,beau);
PutCC16(253,370,2,4,date);
PutCC16(252,369,2,14,date);
fclose(fp16);
ShowMouse();
WaitForPrsBt();
}
void Bar(int x,int y,int len,int high)
{
int i;
setcolor(2);
rectangle(x,y,x+len,y+high);
setfillstyle(1,2);
bar(x+len,y+high,x+len-1,y+high-1);
setcolor(1);
for (i=1;i<6;i++)
{
line(x+i,y+i,x+len-i,y+i);
line(x+i,y+i,x+i,y+high-i);
}
setfillstyle(1,3);
bar(x+6,y+6,x+len-6,y+high-6);
line(x+len-1,y+high-1,x+len-6,y+high-6);
setcolor(2);
line(x+1,y+1,x+6,y+6);
setcolor(1);
rectangle(x+20,y+20,x+len-20,y+high-20);
setcolor(2);
rectangle(x+19,y+19,x+len-21,y+high-21);
}
void ChgColor(int colorno,int red,int green,int blue)
{
outport(0x3c8,colorno);
outport(0x3c9,red);
outport(0x3c9,green);
outport(0x3c9,blue);
}
void WaitForPrsBt()
{
while(!LeftPrsd() && !RightPrsd())
if (kbhit()) return;
}
void OpenLIB()
{
fp16=fopen("ahzk16","rb");
}
//------------------------------------//
// 函数: PutCC16()
// 功能: 图形方式下显示16点阵汉字
// 入口参数:
// x,y:起点座标
// wid:字符间距
// color:字符颜色
// str:英汉字字串
// 出口参数:
//------------------------------------//
void PutCC16(int x,int y,int wid,int color,char *str)
{
unsigned zcode,bcode;
int i,j,k,rec;
long len;
char buf[32],oldcolor,bb[2];
oldcolor=getcolor();
while(*str)
{
if ((*str&0x80)&&(*(str+1)&0x80))
{
zcode=(*str-0xa1)&0x07f;
bcode=(*(str+1)-0xa1)&0x07f;
rec=zcode*94+bcode;
len=rec*32L;
fseek(fp16,len,SEEK_SET);
fread(buf,1,32,fp16);
for(i=0;i<16;i++)
for(j=0;j<2;j++)
for(k=0;k<8;k++)
if (buf[i*2+j]>>(7-k)&1)
putpixel(x+j*8+k,y+i,color);
x=x+16+wid;
str+=2;
}
else
{
setcolor(color);
sprintf(bb,"%c",*str);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
outtextxy(x,y+4,bb);
x=x+8+wid;
str++;
}
}
setcolor(oldcolor);
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -