求高手赐教!!!
以下这道程序的作用如下:在屏幕(3,5)-(8,68)区域设置背景颜色,输出一个字符串,输出具有不同颜色的大写26个英文字母,保存局部屏幕内容,清除局部屏幕及恢复屏幕内容.(该程序是书中的,在tc++3.0通过编译,但是结果呢,可以输出字符串,英语字符也输得出来,问题是后面的保存,清除,恢复局部屏幕搞不出来,谁能给个解释,看不出来哪里出问题了,运行完后还无缘无故出现了一些符号)#include<stdio.h>
#include<dos.h>
#include<conio.h>
#include<stdlib.h>
void set_mode(int mode);
void goto_xy(int x,int y);
void put_char(char ch,int color);
void display_char(char ch,int color);
void clear_window(int startx,int starty,int endx,int endy,int bkcolor);
void save_scrn(int startx,int starty,int endx,int endy,char *buff);
void restore_scrn(int startx,int starty,int endx,int endy,char *buff);
void set_backcolor(int startx,int starty,int endx,int endy,int color);
void display_string(int x,int y,char *str,int color);
char far *scrn=(char far *)0xB8000000;
void main()
{
int i,j,k=10;
char buffer[4000];
char sq[]="This is a simple program example!";
set_mode(3);
set_backcolor(3,5,10,68,0x30);
display_string(13,18,sq,0x34);
getch();
set_backcolor(13,18,13,50,0x27);
j=64;
for(i=0;i<=26;i++)
{
goto_xy(15,k+i);
display_char(j+i,i%16);
}
getch();
save_scrn(2,2,20,75,buffer);
clear_window(0,0,24,79,0x40);
getch();
restore_scrn(4,6,22,79,buffer);
getch();
}
void set_mode(int mode)
{
union REGS regs;
regs.h.ah=0;
regs.h.al=mode;
int86(0x10,®s,®s);
}
void goto_xy(int x,int y)
{
union REGS regs;
regs.h.ah=2;
regs.h.dh=x;
regs.h.dl=y;
regs.h.bh=0;
int86(0x10,®s,®s);
}
void display_char(char ch,int color)
{
union REGS regs;
regs.h.ah=0x09;
regs.h.al=ch;
regs.h.bl=color;
regs.h.bh=0;
regs.x.cx=1;
int86(0x10,®s,®s);
}
void put_char(char ch,int color)
{
union REGS regs;
regs.h.ah=0x0e;
regs.h.al=ch;
regs.h.bl=color;
regs.h.bh=0;
regs.x.cx=1;
int86(0x10,®s,®s);
}
void clear_window(int startx,int starty,int endx,int endy,int bkcolor)
{
register int i,j;
char *t;
for(i=startx;i<=endx;i++)
for(j=starty;j<=endy;j++)
{
t=scrn+i*160+j*2;
*t++=' ';
*t=bkcolor;
}
}
void save_scrn(int startx,int starty,int endx,int endy,char *buff)
{
register int i,j;
char *t;
for(i=startx;i<=endx;i++)
for(j=starty;j<=endy;j++)
{
t=scrn+i*160+j*2;
*buff++=*t++;
*buff++=*t;
}
}
void restore_scrn(int startx,int starty,int endx,int endy,char *buff)
{
register int i,j;
char *t;
for(i=startx;i<=endx;i++)
for(j=starty;j<=endy;j++)
{
t=scrn+i*160+j*2;
*t++=*buff++;
*t=*buff++;
}
}
void set_backcolor(int startx,int starty,int endx,int endy,int color)
{
register int i,j;
char *t;
for(i=startx;i<=endx;i++)
for(j=starty;j<=endy;j++)
{
t=scrn+i*160+j*2;
*(t+1)=color;
}
}
void display_string(int x,int y,char *str,int color)
{
int i=0;
while(str[i])
{
goto_xy(x,y+i);
display_char(str[i],color);
i++;
}
}
赐教,谢谢!!!