模拟进度条(图形版)
程序代码:
#include <stdio.h>
void redos();
void pause(unsigned int time);
void screen_mode(unsigned char mode);
void point(unsigned int x,
unsigned int y,
unsigned char colorID,
unsigned char color
);
void shape(unsigned int x0,
unsigned int y0,
unsigned int x1,
unsigned int y1,
unsigned char colorID,
unsigned char color
);
int main(void)
{
int x,y;
screen_mode(0x12);
printf("\n\n");
for(x=0; x<=500; x+=30)
{
shape(0,10,x,30,0,1);
printf("%d\%\b\b\b",x/5);
pause(1);
}
printf("100\%\b\b\b");
redos();
return 0;
}
void redos()
{
asm mov ah,7h;
asm int 21h;
asm mov ah,4ch;
asm int 21h;
}
void pause(unsigned int time)
{
asm mov ah,0h;
asm int 1ah;
asm add dx,time;
asm mov bx,dx;
label:
asm int 1ah;
asm cmp bx,dx;
asm jne label;
}
void screen_mode(unsigned char mode)
{
asm mov ah,0h;
asm mov al,mode;
asm int 10h;
}
void point(unsigned int x,
unsigned int y,
unsigned char colorID,
unsigned char color
)
{
asm mov ah,0bh;
asm mov bh,0x(colorID);
asm mov bl,0x(color);
asm int 10h;
asm mov ah,0ch;
asm mov al,0x(color);
asm mov cx,x;
asm mov dx,y;
asm int 10h;
}
void shape(unsigned int x0,
unsigned int y0,
unsigned int x1,
unsigned int y1,
unsigned char colorID,
unsigned char color
)
{
int i_x0, i_y0;
for(i_x0=x0; i_x0<=x1; i_x0++)
{
for(i_y0=y0; i_y0<=y1; i_y0++)
{
point(i_x0, i_y0, colorID,color);
}
}
}
void redos();
void pause(unsigned int time);
void screen_mode(unsigned char mode);
void point(unsigned int x,
unsigned int y,
unsigned char colorID,
unsigned char color
);
void shape(unsigned int x0,
unsigned int y0,
unsigned int x1,
unsigned int y1,
unsigned char colorID,
unsigned char color
);
int main(void)
{
int x,y;
screen_mode(0x12);
printf("\n\n");
for(x=0; x<=500; x+=30)
{
shape(0,10,x,30,0,1);
printf("%d\%\b\b\b",x/5);
pause(1);
}
printf("100\%\b\b\b");
redos();
return 0;
}
void redos()
{
asm mov ah,7h;
asm int 21h;
asm mov ah,4ch;
asm int 21h;
}
void pause(unsigned int time)
{
asm mov ah,0h;
asm int 1ah;
asm add dx,time;
asm mov bx,dx;
label:
asm int 1ah;
asm cmp bx,dx;
asm jne label;
}
void screen_mode(unsigned char mode)
{
asm mov ah,0h;
asm mov al,mode;
asm int 10h;
}
void point(unsigned int x,
unsigned int y,
unsigned char colorID,
unsigned char color
)
{
asm mov ah,0bh;
asm mov bh,0x(colorID);
asm mov bl,0x(color);
asm int 10h;
asm mov ah,0ch;
asm mov al,0x(color);
asm mov cx,x;
asm mov dx,y;
asm int 10h;
}
void shape(unsigned int x0,
unsigned int y0,
unsigned int x1,
unsigned int y1,
unsigned char colorID,
unsigned char color
)
{
int i_x0, i_y0;
for(i_x0=x0; i_x0<=x1; i_x0++)
{
for(i_y0=y0; i_y0<=y1; i_y0++)
{
point(i_x0, i_y0, colorID,color);
}
}
}
----------------解决方案--------------------------------------------------------
用VC运行后一堆错,是不是少了什么头文件?
那个asm是什么?
----------------解决方案--------------------------------------------------------
asm 汇编语句
这是内联汇编来的,这个是borladc的内联汇编格式,
所以在vc 里编译是不行的.
----------------解决方案--------------------------------------------------------
啊啊。。
这样的吗?
----------------解决方案--------------------------------------------------------
用TC可以,有个结构叫REG,表示8086的通用寄存器,还有个函数叫int86(int,REG *, REG *);好像是这样的,是用来调用中断的,第一个参数是中断号,第二个是输入寄存器――就是中断前设置寄存器为什么状态,最后一个参数是中断调用结束,控制返回后的寄存器状态。
好久没写了,不一定对,大概就是这个样子。
----------------解决方案--------------------------------------------------------
Linux 下 GCC也可以直接内联asm
----------------解决方案--------------------------------------------------------
其实在实模式下可以直接写显存,每个点都用一个中断会比较慢^_^
----------------解决方案--------------------------------------------------------
的确是很慢...gcc的内联汇编我也会..
为了做实验...机器上装了很多个系统...
又用虚拟机装了很多个系统...
不知道老兄对linux研究如何...
有空可指教下不?
----------------解决方案--------------------------------------------------------
指教不敢当,我也只是初学开源的东西的,觉得很好玩啊,呵呵,找几个伙伴一起学应该很好哦
----------------解决方案--------------------------------------------------------
呵呵...我也比较喜欢开源的东西...近来弄了个ubuntu linux 有3D桌面效果的.
为了搞那个效果看看,找了很久显卡驱动啊...linux真的没win那么多厂商为它
写驱动,我们买来的新电脑也只是配win的驱动,真郁闷.所以我也产生了要学
写驱动的念头.不过这方面一点都还不知道.老兄可否加我Q:82530662
----------------解决方案--------------------------------------------------------