📄 asc16.c
字号:
#define VGA256 0x13
#define TEXT_MODE 0x03
#include<process.h>
#include<bios.h>
#include<fcntl.h>
#include<io.h>
unsigned char far *video_buffer=(char far *)0xA0000000L;
void Read_Asc16(int key,unsigned char *buf)
{
int handle;
long address;
handle=open("asc16",O_RDONLY|O_BINARY);
address=key*16l;
lseek(handle,address,SEEK_SET);
read(handle,buf,16);
close(handle);
}
void Put_Asc16(int cx,int cy,int key,int fcolor)
{
int a,b;
unsigned char buf[16];
Read_Asc16(key,buf);
for(a=0;a<16;a++)
for(b=0;b<8;b++)
if((buf[a]>>7-b)&1)
video_buffer[(((cy+a)<<8)+((cy+a)<<6))+cx+b]=fcolor;
}
void Put_Asc16_Size(int cx,int cy,int xsize,int ysize,int key,int fcolor)
{
int a,b,o,k;
unsigned char buf[16];
Read_Asc16(key,buf);
for(a=0;a<16;a++)
for(o=1;o<=ysize;o++)
for(b=0;b<8;b++)
for(k=1;k<=xsize;k++)
if((buf[a]>>7-b)&1)
video_buffer[(((cy+o+a*ysize)<<8)+((cy+o+a*ysize)<<6))+cx+xsize*b+k]=fcolor;
}
void Put_Asc16_Size_Format(int cx,int cy,int xsize,int ysize,int key,int fcolor,int bold,int i)
{
int a,b,o,k;
long address;
unsigned char buf[16];
Read_Asc16(key,buf);
for(a=0;a<16;a++)
for(o=1;o<=ysize;o++)
for(b=0;b<8;b++)
for(k=1;k<=xsize;k++)
if((buf[a]>>7-b)&1)
if(fcolor!=-1)
if(i==0)
{
video_buffer[(((cy+o+a*ysize)<<8)+((cy+o+a*ysize)<<6))+cx+xsize*b+k]=fcolor;
if(bold==1)
video_buffer[(((cy+o+a*ysize)<<8)+((cy+o+a*ysize)<<6))+cx+xsize*b+k+1]=fcolor;
}
else
{
video_buffer[(((cy+o+a*ysize)<<8)+((cy+o+a*ysize)<<6))+cx+xsize*b+k+16-a]=fcolor;
if(bold==1)
video_buffer[(((cy+o+a*ysize)<<8)+((cy+o+a*ysize)<<6))+cx+xsize*b+k+1+16-a]=fcolor;
}
else
if(i==0)
{
video_buffer[(((cy+o+a*ysize)<<8)+((cy+o+a*ysize)<<6))+cx+xsize*b+k]=rand()%100;
if(bold==1)
video_buffer[(((cy+o+a*ysize)<<8)+((cy+o+a*ysize)<<6))+cx+xsize*b+k+1]=rand()%100;
}
else
{
video_buffer[(((cy+o+a*ysize)<<8)+((cy+o+a*ysize)<<6))+cx+xsize*b+k+16-a]=rand()%100;
if(bold==1)
video_buffer[(((cy+o+a*ysize)<<8)+((cy+o+a*ysize)<<6))+cx+xsize*b+k+1+16-a]=rand()%100;
}
}
void Set_Video_Mode(int mode)
{
union REGS inregs,outregs;
inregs.h.ah=0;
inregs.h.al=(unsigned char)mode;
int86(0x10,&inregs,&outregs);
}
void main(void)
{
int key=0,x=0,y=0;
Set_Video_Mode(VGA256);
for(key=0;key<256;key++)
{
Put_Asc16((x++)*8,50+y,key,10);
if((key+1)%40==0)
{
x=0;
y+=17;
}
}
getch();
x=40;
y=25;
Put_Asc16_Size(x,y,2,2,80,15);
getch();
Put_Asc16_Size_Format(x+40,y,10,10,80,-1,1,1);
getch();
Set_Video_Mode(TEXT_MODE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -