open watcom学习记录之——图形模式下画点阵显示字符

cxdzxc 2012-05-24 04:22:46
#define xy 640*480
#define color1 0xffff
#define color2 0xf800
#define pixel_size 2
#define lattice_x 8
#define lattice_y 8
#define word_x0 3
#define word_y0 3
#define row_word_count 640/lattice_x
#define sys_mem_pointer_base 0x200000
main()
{
char text_test[]={0,1,2,3,4,5,6,7,8,9,0xa,0xb,0xc,0xd,0xe,0xf,1,1,1};
char *file_point=0x400000;

unsigned short int word_sz_i=0;
int file_size,file_point_i=0,word_xy=0,word_x,word_y,*sys_mem_pointer=sys_mem_pointer_base,sys_mem_pointer_i=0;
int word_point_xy,word_sz_x_i,word_sz_y_i;
unsigned short int *p=(short *)0xc0000000,*pmhc=(short *)0x300000;

char word_bit_i=0x80,word_sz[]=
{
/*0*/
0x7e,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x7e,
/*1*/
0x18,0x38,0x58,0x18,0x18,0x18,0x18,0xff,
/*2*/
0xfc,0x03,0x03,0x7e,0xc0,0xc0,0xc0,0xff,
/*3*/
0Xfe,0x03,0x03,0x7e,0x07,0x03,0x03,0xfe,
/*4*/
0x0c,0x1d,0x3c,0x6c,0x6c,0xff,0x0c,0x0c,
/*5*/
0xff,0xc0,0xc0,0xfe,0x03,0x03,0x03,0xfe,
/*6*/
0x3e,0xc0,0xc0,0xfe,0xc3,0xc3,0xc3,0x3c,
/*7*/
0x7f,0x03,0x06,0x06,0x0c,0x0c,0x18,0x18,
/*8*/
0x7e,0xc3,0xc3,0x7e,0xc3,0xc3,0xc3,0x7e,
/*9*/
0x3c,0xc3,0xc3,0xc3,0x7f,0x03,0x03,0x7e,
/*a*/
0x7e,0x03,0x03,0x7f,0xc3,0xc3,0xc3,0x7f,
/*b*/
0xc0,0xc0,0xfe,0xc3,0xc3,0xc3,0xc3,0xfe,
/*c*/
0x00,0x3e,0x60,0x60,0x60,0x60,0x60,0x3e,
/*d*/
0x03,0x03,0x7f,0xc3,0xc3,0xc3,0xc3,0x7f,
/*e*/
0x00,0x3e,0x63,0x63,0x7e,0x60,0x60,0x3e,
/*f*/
0x00,0x1e,0x30,0x30,0xfe,0x30,0x30,0x30
};

memcpy(file_point,text_test,sizeof(text_test));
sys_mem_pointer[sys_mem_pointer_i++]=(int)pmhc+xy*pixel_size;
sys_mem_pointer[sys_mem_pointer_i++]=(int)pmhc;
sys_mem_pointer[sys_mem_pointer_i++]=(int)pmhc+xy*pixel_size;

_asm{
pushad
mov ax,0x4f02;/*4F02H VESA*/
mov bx,0x4111;/*111----640*480-64K(5:6:5),110------640*480-32K(1:5:5:5)*/
int 0x10
popad
}

memset(pmhc,0xf,xy*pixel_size);
memcpy(p,pmhc,xy*pixel_size);

word_x=word_x0;
word_y=word_y0;
word_xy=word_y*row_word_count;
word_point_xy=word_xy*lattice_x*lattice_y+word_x*lattice_x;
file_size=sizeof(text_test);

while(file_point_i<file_size)
{
word_sz_i=file_point[file_point_i++]*8;
for (word_sz_y_i=0;word_sz_y_i<8;word_sz_y_i++)
{
while(word_bit_i>=0x01)
{
if(word_bit_i&word_sz[word_sz_i])
{p[word_point_xy]=color2;}
word_point_xy++;
word_bit_i=word_bit_i>>1;
}
word_bit_i=0x80;
word_sz_i++;
word_point_xy=word_point_xy+640-8;
}
word_point_xy=word_point_xy-640*8+8+2;
}
getch();
_asm
{
mov ax,3
int 0x10
}
return 0;
}
...全文
233 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2012-07-03
  • 打赏
  • 举报
回复
仅供参考
#include <mem.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <graphics.h>
const unsigned char bit[8]={128,64,32,16,8,4,2,1};
//--------------------------------------------------------
void dis(xoff,code)
unsigned int xoff,code;
{
unsigned char *buffer;
FILE *hzk;
unsigned long offset;
unsigned int q,w;
int x,y,width;

buffer=calloc(32,1);
if ((code&0xFF00)!=0) {
w=(code&0x00FF)-0xA1;
q=((code>>8)&0x00FF)-0xA1;
offset=q*0x5E+w;
offset*=32;
if ((hzk=fopen("HZK16","rb"))==NULL) {
closegraph();
printf("Can not open HZK16\r\n");
exit(1);
}
fseek(hzk,offset,SEEK_SET);
fread(buffer,1,32,hzk);
fclose(hzk);
width=2;
}
else {
if ((hzk=fopen("ASC16","rb"))==NULL) {
closegraph();
printf("Can not open ASC16\r\n");
exit(1);
}
offset=code*16;
fseek(hzk,offset,SEEK_SET);
fread(buffer,1,16,hzk);
fclose(hzk);
width=1;
}
for (y=0;y<16;y++) for (x=0;x<8*width;x++) {
if (buffer[y*width+x/8]&bit[x%8]) putpixel(xoff+x,y,15);
}
free(buffer);
}
//--------------------------------------------------------
void display(p)
unsigned char *p;
{

int i;
unsigned int qw;

i=0;
while (1) {
if (p[i]==0x0D||p[i]==0x1A) break;
if (p[i]>0xA0) {
qw=((unsigned int)p[i]<<8)|((unsigned int)p[i+1]&0x00FF);
dis(8*i,qw);
i+=2;
}
else {
qw=(unsigned int)p[i]&0x00FF;
dis(8*i,qw);
i++;
}
}

}
//--------------------------------------------------------
void main()
{
int gdriver = DETECT, gmode, errorcode;
long fl;
FILE *hz;
unsigned char *p;

initgraph(&gdriver, &gmode, "c:\\borlandc\\bgi");
errorcode = graphresult();
if (errorcode != grOk) {
printf("Graphics error: %s\n", grapherrormsg(errorcode));
exit(1);
}
hz=fopen("hz","rb");
fseek(hz,0,SEEK_END);
fl=ftell(hz);
p=calloc((int)fl,sizeof(unsigned char));
rewind(hz);
fread(p,1,(int)fl,hz);
fclose(hz);
display(p);
free(p);
getch();
closegraph();
}
cxdzxc 2012-07-03
  • 打赏
  • 举报
回复
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <conio.h>
#include <stdlib.h>
#include <mem.h>
#include "asc_font.c"
#define asc_word_size 16
#define asc_word_wide 8
#define asc_word_high 16
#define hz_word_size 16*2
#define hz_word_wide 16
#define hz_word_high 16
#define upkey 72
#define downkey 80
#define esckey 27
/*#define CLK_TCK CLOCKS_PER_SEC*/
#define pm_x 640
#define pm_y 480
#define pm_xy pm_x*pm_y
#define red_colour 0xf800
#define green_colour 0x07c0
#define blue_colour 0x01f
#define black_colour 0x0
#define white_colour 0xffff
#define vesa_mode_num 0x4111
#define pixel_size 2
#define row_word_count 640/lattice_x
#define pmhc_add 0x300000

unsigned int bmp_size,int_num,int_temp,hzk_fp=0,file_size=0,pmhc_word_line_num=1;
unsigned int asc_8x16_i=0,pmhc_i=0,hzk16_buf_i=0,bmp_buf_i=0;
unsigned short int vesa_mode,*p_xc=(short *)0xc0000000,*pmhc=(short *)pmhc_add;

unsigned char buf[hz_word_size],byte_dz,byte_bit_num=8,word_highbyte=0,word_lowbyte=0;
unsigned char *filepath_name,*hz_asc_s,*hzk16_buf=(unsigned char *)(pmhc_add+pm_xy*2),*bmp_buf;

float mysleep(float delay)
{
float time_start, time_end;
time_start = clock();
time_end = clock();
if (delay < 0)
{
printf("value overflow\n");
delay = 0;
}
while ((time_end - time_start) / CLK_TCK < delay)
{
time_end = clock();
}
return delay;
}

void h_byte_dz(char byte_dz)
{
int byte_bit_num=8;
while(byte_bit_num--)
{
if (byte_dz&0x80)
pmhc[pmhc_i++]=blue_colour; /*....................colour.......*/
else
pmhc_i++;
byte_dz=byte_dz<<1;
}
}

void show_hex_size(char *hex_add,int size)
{
unsigned int hex_add_i=0;
unsigned char byte_dz_temp=0,hex_num;
while(size--)
{
if (pmhc_i>pmhc_word_line_num*pm_x*asc_word_high-pm_x*asc_word_high+pm_x-asc_word_wide*2)
{
pmhc_word_line_num++;
pmhc_i=pm_x*asc_word_high*(pmhc_word_line_num-1);
}
hex_num=hex_add[hex_add_i++];
byte_dz_temp=(hex_num&0xf0)>>4;
show_hex_dz(byte_dz_temp);
byte_dz_temp=hex_num&0xf;
show_hex_dz(byte_dz_temp);
if (pmhc_i>(pmhc_word_line_num*pm_x*asc_word_high-pm_x*asc_word_high+pm_x-asc_word_wide))
{
pmhc_word_line_num++;
pmhc_i=pm_x*asc_word_high*(pmhc_word_line_num-1);
}
if (pmhc_i != pm_x*asc_word_high*(pmhc_word_line_num-1))
show_asc(' ');
}
}

int show_bl(bl)
{
;
}

void show_hex_size_no_space(char *hex_add,int size)
{
unsigned int hex_add_i=0;
unsigned char byte_dz_temp=0,hex_num;
while(size--)
{
hex_num=hex_add[hex_add_i++];
byte_dz_temp=(hex_num&0xf0)>>4;
show_hex_dz(byte_dz_temp);
byte_dz_temp=hex_num&0xf;
show_hex_dz(byte_dz_temp);
}
}

void show_hex_dz(unsigned char hex_dz)
{
char asc;
if (hex_dz>9)
asc=hex_dz-9+0x40;
else
asc=hex_dz+0x30;
show_asc(asc);
}

void show_asc_size(char *asc_add,int size)
{
unsigned int asc_add_i=0;
while(size--)
{
asc_8x16_i=asc_add[asc_add_i++];
show_asc(asc_8x16_i);
}
}

void show_asc(char asc)
{
unsigned int byte_dz_i;
if (pmhc_i>(pmhc_word_line_num*pm_x*asc_word_high-pm_x*asc_word_high+pm_x-asc_word_wide))
{
pmhc_word_line_num++;
pmhc_i=pm_x*asc_word_high*(pmhc_word_line_num-1);
}
asc_8x16_i=asc*asc_word_size;
byte_dz_i=asc_8x16_i;
while(byte_dz_i<(asc_8x16_i+asc_word_size))
{
byte_dz=asc_8x16[byte_dz_i++];
h_byte_dz(byte_dz);
pmhc_i=pmhc_i+pm_x-asc_word_wide;
}
pmhc_i=pmhc_i-pm_x*asc_word_high+asc_word_wide;
}

void show_hz1(unsigned char *hz_add)
{
unsigned int hz_add_i=0;
word_highbyte=hz_add[hz_add_i]-0x80-0x20;
word_lowbyte=hz_add[hz_add_i+1]-0x80-0x20;
hzk_fp=hz_word_size*((word_highbyte-1)*94+word_lowbyte-1);
show_hz(hzk_fp);
}

void show_hz_asc(char *hz_asc_add)
{
unsigned int hz_asc_add_i=0;
while(hz_asc_add[hz_asc_add_i])
{
if (hz_asc_add[hz_asc_add_i]<0x80)
show_asc(hz_asc_add[hz_asc_add_i++]);
else
{show_hz1(hz_asc_add+hz_asc_add_i++);
hz_asc_add_i++;
}
}
}

void show_hz(unsigned int hzk_fp)
{
hzk16_buf_i=hzk_fp;
if (pmhc_i>(pmhc_word_line_num*pm_x*hz_word_high-pm_x*hz_word_high+pm_x-hz_word_wide))
{
pmhc_word_line_num++;
pmhc_i=pm_x*hz_word_high*(pmhc_word_line_num-1);
}
while(hzk16_buf_i<hzk_fp+hz_word_size)
{
byte_dz=hzk16_buf[hzk16_buf_i++];
h_byte_dz(byte_dz);
byte_dz=hzk16_buf[hzk16_buf_i++];
h_byte_dz(byte_dz);
pmhc_i=pmhc_i+pm_x-hz_word_wide;
}
pmhc_i=pmhc_i-pm_x*hz_word_high+hz_word_wide;
}

unsigned int swap_int(unsigned int i)
{
return ((i&0xff000000)>>24)|((i&0xff0000)>>8)|((i&0xff00)<<8)|((i&0xff)<<24);
}

void set_vesa(short vesa_mode)
{
_asm{
pushad
mov ax,0x4f02;/*4F02H VESA*/
mov bx,vesa_mode;/*111----640*480-64K(5:6:5),110------640*480-32K(1:5:5:5)*/
int 0x10
popad
}
}

void close_vesa(void)
{
_asm
{
mov ax,3
int 0x10
}
}

unsigned int read_file(char * filepath_name,char * buf)
{
FILE *fp;
unsigned int fread_num;
unsigned int buf_i=0;

if (!(fp = fopen(filepath_name,"rb")))
{
printf("Open file fail:No find %s\n",filepath_name);
getch();
exit (0);
}
fseek(fp,0,SEEK_END);
file_size=ftell(fp);
bmp_size=file_size;
fread_num=ceil((float)file_size/BUFSIZ); //注意这里要用(float)
fseek(fp,0,SEEK_SET);
while (fread_num--)
{
fread(buf+buf_i,BUFSIZ,1,fp);
buf_i=buf_i+BUFSIZ;
fseek(fp,+buf_i,SEEK_SET);
}
fclose(fp);
return buf_i;
}

//.......................................................................................
main()
{
filepath_name=".\\hzk16";
bmp_buf=hzk16_buf+read_file(filepath_name,hzk16_buf);

filepath_name=".\\dosbox.bmp";
read_file(filepath_name,bmp_buf);

vesa_mode=vesa_mode_num;
set_vesa(vesa_mode);

memset(pmhc,0x1f,pm_xy*pixel_size);
memcpy(p_xc,pmhc,pm_xy*pixel_size);

hz_asc_s="Hello World ! pmhc_i=";
show_hz_asc(hz_asc_s);

int_num=pmhc_i;
hz_asc_s=(char *)&int_num;
int_temp=swap_int(int_num);
hz_asc_s=(char *)&int_temp;
show_hex_size_no_space(hz_asc_s,sizeof(int_num));

hz_asc_s=" 显示BMP图片数据:";
show_hz_asc(hz_asc_s);
show_hex_size(bmp_buf,bmp_size);

memcpy(p_xc,pmhc,pm_xy*pixel_size);

returndos:
getch();
close_vesa();
return 0;
}
0c0c0f 2012-07-03
  • 打赏
  • 举报
回复
看不明白,谁来帮帮忙吧!
cxdzxc 2012-07-02
  • 打赏
  • 举报
回复
[code=C/C++]#include <stdio.h>
#include <time.h>
#include <math.h>
#include <conio.h>
#include <stdlib.h>
#include <mem.h>
#include "asc_font.c"
#define asc_word_byte 16
#define hz_word_byte 16*2
#define upkey 72
#define downkey 80
#define esckey 27
/*#define CLK_TCK CLOCKS_PER_SEC*/
#define pm_x 640
#define pm_y 480
#define pm_xy pm_x*pm_y
#define red_colour 0xf800
#define green_colour 0x07c0
#define blue_colour 0x01f
#define black_colour 0x0
#define white_colour 0xffff
#define vesa_mode_num 0x4111
#define pixel_size 2
#define row_word_count 640/lattice_x
#define pmhc_add 0x300000

unsigned int int_num,int_temp,hzk_fp=0,file_size=0;
unsigned int asc_8x16_i=0,pmhc_i=0,hzk16_buf_i=0,bmp_buf_i=0;
unsigned short int vesa_mode,*p_xc=(short *)0xc0000000,*pmhc=(short *)pmhc_add;

unsigned char buf[hz_word_byte],byte_dz,byte_bit_num=8,word_highbyte=0,word_lowbyte=0;
unsigned char *filepath_name,*hz_asc_s,*hzk16_buf=(unsigned char *)(pmhc_add+pm_xy*2),*bmp_buf;

float mysleep(float delay)
{
float time_start, time_end;
time_start = clock();
time_end = clock();
if (delay < 0)
{
printf("value overflow\n");
delay = 0;
}
while ((time_end - time_start) / CLK_TCK < delay)
{
time_end = clock();
}
return delay;
}

void h_byte_dz(char byte_dz)
{
int byte_bit_num=8;
while(byte_bit_num--)
{
if (byte_dz&0x80)
{
pmhc[pmhc_i++]=blue_colour; /*....................colour.......*/
}
else
{
pmhc_i++;
}
byte_dz=byte_dz<<1;
}
}

void show_hex_size(char *hex_add,int size)
{
unsigned int hex_add_i=0;
unsigned char byte_dz_temp=0,hex_num;
while(size--)
{
hex_num=hex_add[hex_add_i++];
byte_dz_temp=(hex_num&0xf0)>>4;
show_hex_dz(byte_dz_temp);
byte_dz_temp=hex_num&0xf;
show_hex_dz(byte_dz_temp);
show_asc(' ');
}
}

void show_hex_size_no_(char *hex_add,int size)
{
unsigned int hex_add_i=0;
unsigned char byte_dz_temp=0,hex_num;
while(size--)
{
hex_num=hex_add[hex_add_i++];
byte_dz_temp=(hex_num&0xf0)>>4;
show_hex_dz(byte_dz_temp);
byte_dz_temp=hex_num&0xf;
show_hex_dz(byte_dz_temp);
}
}

void show_hex_dz(unsigned char hex_dz)
{
char asc;
if (hex_dz>9)
asc=hex_dz-9+0x40;
else
asc=hex_dz+0x30;
show_asc(asc);
}

void show_asc(char asc)
{
unsigned int byte_dz_i;
asc_8x16_i=asc*asc_word_byte;
byte_dz_i=asc_8x16_i;
while(byte_dz_i<(asc_8x16_i+asc_word_byte))
{
byte_dz=asc_8x16[byte_dz_i++];
h_byte_dz(byte_dz);
pmhc_i=pmhc_i+pm_x-asc_word_byte/2;
}
/*if (pmhc_i<=pm_x*16)*/
pmhc_i=pmhc_i-pm_x*asc_word_byte+asc_word_byte/2;
/*else
pmhc_i=pmhc_i;*/
}

void show_asc_size(char *asc_add,int size)
{
unsigned int asc_add_i=0;
while(size--)
{
asc_8x16_i=asc_add[asc_add_i++];
show_asc(asc_8x16_i);
}
}

void show_hz1(unsigned char *hz_add)
{
unsigned int hz_add_i=0;
word_highbyte=hz_add[hz_add_i]-0x80-0x20;
word_lowbyte=hz_add[hz_add_i+1]-0x80-0x20;
hzk_fp=hz_word_byte*((word_highbyte-1)*94+word_lowbyte-1);
show_hz(hzk_fp);
}

void show_hz_asc(char *hz_asc_add)
{
unsigned int hz_asc_add_i=0;
while(hz_asc_add[hz_asc_add_i])
{
if (hz_asc_add[hz_asc_add_i]<0x80)
show_asc(hz_asc_add[hz_asc_add_i++]);
else
{show_hz1(hz_asc_add+hz_asc_add_i++);
hz_asc_add_i++;
}
}
}

void show_hz(unsigned int hzk_fp)
{
hzk16_buf_i=hzk_fp;
while(hzk16_buf_i<hzk_fp+hz_word_byte)
{
byte_dz=hzk16_buf[hzk16_buf_i++];
h_byte_dz(byte_dz);
byte_dz=hzk16_buf[hzk16_buf_i++];
h_byte_dz(byte_dz);
pmhc_i=pmhc_i+pm_x-hz_word_byte/2;
}
pmhc_i=pmhc_i-pm_x*asc_word_byte+hz_word_byte/2;
}

unsigned int swap_int(unsigned int i)
{
return ((i&0xff000000)>>24)|((i&0xff0000)>>8)|((i&0xff00)<<8)|((i&0xff)<<24);
}

void set_vesa(short vesa_mode)
{
_asm{
pushad
mov ax,0x4f02;/*4F02H VESA*/
mov bx,vesa_mode;/*111----640*480-64K(5:6:5),110------640*480-32K(1:5:5:5)*/
int 0x10
popad
}
}

void close_vesa(void)
{
_asm
{
mov ax,3
int 0x10
}
}

unsigned int read_file(char * filepath_name,char * buf)
{
FILE *fp;
unsigned int fread_num;
unsigned int buf_i=0;

if (!(fp = fopen(filepath_name,"rb")))
{
printf("Open file fail:No find %s\n",filepath_name);
getch();
exit (0);
}
fseek(fp,0,SEEK_END);
file_size=ftell(fp);
fread_num=ceil((float)file_size/BUFSIZ); //注意这里要用(float)
fseek(fp,0,SEEK_SET);
while (fread_num--)
{
fread(buf+buf_i,BUFSIZ,1,fp);
buf_i=buf_i+BUFSIZ;
fseek(fp,+buf_i,SEEK_SET);
}
fclose(fp);
return buf_i;
}

//.......................................................................................
main()
{
filepath_name=".\\hzk16";
bmp_buf=hzk16_buf+read_file(filepath_name,hzk16_buf);

filepath_name=".\\dosbox.bmp";
read_file(filepath_name,bmp_buf);

vesa_mode=vesa_mode_num;
set_vesa(vesa_mode);

memset(pmhc,0x1f,pm_xy*pixel_size);
memcpy(p_xc,pmhc,pm_xy*pixel_size);

hz_asc_s="大家好 ";
show_hz_asc(hz_asc_s);

int_num=0x12345678;
hz_asc_s=(char *)&int_num;
show_hex_size_no_(hz_asc_s,sizeof(int_num));
hz_asc_s=" swap ";
show_hz_asc(hz_asc_s);
int_temp=swap_int(int_num);
hz_asc_s=(char *)&int_temp;
show_hex_size_no_(hz_asc_s,sizeof(int_num));

hz_asc_s=" 显示BMP图片数据:";
show_hz_asc(hz_asc_s);
show_hex_size(bmp_buf,5);

memcpy(p_xc,pmhc,pm_xy*pixel_size);

returndos:
getch();
close_vesa();
return 0;
}
cxdzxc 2012-05-25
  • 打赏
  • 举报
回复
#define xy 640*480
#define color1 0xffff
#define color2 0xf800
#define pixel_size 2
#define lattice_x 8
#define lattice_y 8
#define word_x0 3
#define word_y0 3
#define row_word_count 640/lattice_x
#define sys_mem_pointer_base 0x200000

char text_test[]={0xfe,0xcd,2,3,4,0xab,6,7,8,9,0xa,0xb,0xc,0xd,0xe,0xf,1,1,1};
char hex2_to_hex1,*file_point=0x400000;

unsigned short int word_sz_i=0;
int file_size,file_point_i=0,a,word_xy=0,word_x,word_y,*sys_mem_pointer=sys_mem_pointer_base,sys_mem_pointer_i=0;
int word_point_xy,word_sz_x_i,word_sz_y_i;
unsigned short int *p=(short *)0xc0000000,*pmhc=(short *)0x300000;

char word_bit_i=0x80,word_sz[]=
{
/*0*/
0x7e,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x7e,
/*1*/
0x18,0x38,0x58,0x18,0x18,0x18,0x18,0xff,
/*2*/
0xfc,0x03,0x03,0x7e,0xc0,0xc0,0xc0,0xff,
/*3*/
0Xfe,0x03,0x03,0x7e,0x07,0x03,0x03,0xfe,
/*4*/
0x0c,0x1d,0x3c,0x6c,0x6c,0xff,0x0c,0x0c,
/*5*/
0xff,0xc0,0xc0,0xfe,0x03,0x03,0x03,0xfe,
/*6*/
0x3e,0xc0,0xc0,0xfe,0xc3,0xc3,0xc3,0x3c,
/*7*/
0x7f,0x03,0x06,0x06,0x0c,0x0c,0x18,0x18,
/*8*/
0x7e,0xc3,0xc3,0x7e,0xc3,0xc3,0xc3,0x7e,
/*9*/
0x3c,0xc3,0xc3,0xc3,0x7f,0x03,0x03,0x7e,
/*a*/
0x7e,0x03,0x03,0x7f,0xc3,0xc3,0xc3,0x7f,
/*b*/
0xc0,0xc0,0xfe,0xc3,0xc3,0xc3,0xc3,0xfe,
/*c*/
0x00,0x3e,0x60,0x60,0x60,0x60,0x60,0x3e,
/*d*/
0x03,0x03,0x7f,0xc3,0xc3,0xc3,0xc3,0x7f,
/*e*/
0x00,0x3e,0x63,0x63,0x7e,0x60,0x60,0x3e,
/*f*/
0x00,0x1e,0x30,0x30,0xfe,0x30,0x30,0x30
};

int hd()
{
for (word_sz_y_i=0;word_sz_y_i<8;word_sz_y_i++)
{
while(word_bit_i>=0x01)
{
if(word_bit_i&word_sz[word_sz_i])
{
p[word_point_xy]=color2;
}
word_point_xy++;
word_bit_i=word_bit_i>>1;
}
word_bit_i=0x80;
word_sz_i++;
word_point_xy=word_point_xy+640-8;
}
word_point_xy=word_point_xy-640*8+8+2;
}

main()
{
memcpy(file_point,text_test,sizeof(text_test));
sys_mem_pointer[sys_mem_pointer_i++]=(int)pmhc+xy*pixel_size;
sys_mem_pointer[sys_mem_pointer_i++]=(int)pmhc;
sys_mem_pointer[sys_mem_pointer_i++]=(int)pmhc+xy*pixel_size;

_asm{
pushad
mov ax,0x4f02;/*4F02H VESA*/
mov bx,0x4111;/*111----640*480-64K(5:6:5),110------640*480-32K(1:5:5:5)*/
int 0x10
popad
}

memset(pmhc,0xf,xy*pixel_size);
memcpy(p,pmhc,xy*pixel_size);

word_x=word_x0;
word_y=word_y0;
word_xy=word_y*row_word_count;
word_point_xy=word_xy*lattice_x*lattice_y+word_x*lattice_x;
file_size=sizeof(text_test);

while(file_point_i<file_size)
{
hex2_to_hex1=file_point[file_point_i];
if(hex2_to_hex1>0xf)
{
hex2_to_hex1=((hex2_to_hex1&0xf0)>>4);
word_sz_i=hex2_to_hex1*8;
hd();
}
hex2_to_hex1=(file_point[file_point_i++]&0x0f);
word_sz_i=hex2_to_hex1*8;
hd();
}
getch();

_asm
{
mov ax,3
int 0x10
}
return 0;
}
cxdzxc 2012-05-25
  • 打赏
  • 举报
回复
继续改进,现在可以显示寄存器值了
#define xy 640*480
#define color1 0xffff
#define color2 0xf800
#define pixel_size 2
#define jiange 1
#define lattice_x 8
#define lattice_y 8
#define word_x0 3
#define word_y0 3
#define row_word_count 640/lattice_x
#define sys_mem_pointer_base 0x200000

int i=0;
char test_sz_ls,*file_point_ls;
char hex2_to_hex1,*file_point=0x400000,word_bit_i=0x80;

unsigned short int word_sz_i=0;
int bl_eax,file_size,file_point_i=0,a,word_xy=0,word_x,word_y,*sys_mem_pointer=sys_mem_pointer_base,sys_mem_pointer_i=0;
int test_sz[],word_point_xy,word_sz_x_i,word_sz_y_i;
unsigned short int *p=(short *)0xc0000000,*pmhc=(short *)0x300000;

char
text_test[]={0xfe,0xcd,2,3,4,0xab,6,7,8,9,0xa,0xb,0xc,0xd,0xe,0xf,1,1,1},
word_sz[]=
{
/*0*/
0x7e,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x7e,
/*1*/
0x18,0x38,0x58,0x18,0x18,0x18,0x18,0xff,
/*2*/
0xfe,0x03,0x03,0x7e,0xc0,0xc0,0xc0,0xff,
/*3*/
0Xfe,0x03,0x03,0x7e,0x07,0x03,0x03,0xfe,
/*4*/
0x0c,0x1c,0x3c,0x6c,0xcc,0xff,0x0c,0x0c,
/*5*/
0xff,0xc0,0xc0,0xfe,0x03,0x03,0x03,0xfe,
/*6*/
0x7e,0xc0,0xc0,0xfe,0xc3,0xc3,0xc3,0x7e,
/*7*/
0x7f,0x03,0x06,0x06,0x0c,0x0c,0x18,0x18,
/*8*/
0x7e,0xc3,0xc3,0x7e,0xc3,0xc3,0xc3,0x7e,
/*9*/
0x7e,0xc3,0xc3,0xc3,0x7f,0x03,0x03,0x7e,
/*a*/
0x7e,0x03,0x03,0x7f,0xc3,0xc3,0xc3,0x7f,
/*b*/
0xc0,0xc0,0xfe,0xc3,0xc3,0xc3,0xc3,0xfe,
/*c*/
0x00,0x3e,0x60,0x60,0x60,0x60,0x60,0x3e,
/*d*/
0x03,0x03,0x7f,0xc3,0xc3,0xc3,0xc3,0x7f,
/*e*/
0x00,0x3e,0x63,0x63,0x7e,0x60,0x60,0x3e,
/*f*/
0x00,0x1e,0x30,0x30,0xfe,0x30,0x30,0x30
};

int reg(int reg_eax)
{
_asm{
mov eax,esp
mov reg_eax,eax
}
test_sz[0]=reg_eax;
test_sz_ls=(const char *)test_sz;
file_point_ls=file_point;
for (i=4-1;i>=0 ;i-- )
{
memcpy(file_point_ls++,(const char *)test_sz+i,1);
}
return i;
}

int hd()
{
for (word_sz_y_i=0;word_sz_y_i<8;word_sz_y_i++)
{
while(word_bit_i>=0x01)
{
if(word_bit_i&word_sz[word_sz_i])
{
p[word_point_xy]=color2;
}
word_point_xy++;
word_bit_i=word_bit_i>>1;
}
word_bit_i=0x80;
word_sz_i++;
word_point_xy=word_point_xy+640-8;
}
word_point_xy=word_point_xy-640*8+8+jiange;
}

main()
{
memcpy(file_point,text_test,sizeof(text_test));

sys_mem_pointer[sys_mem_pointer_i++]=(int)pmhc+xy*pixel_size;
sys_mem_pointer[sys_mem_pointer_i++]=(int)pmhc;
sys_mem_pointer[sys_mem_pointer_i++]=(int)pmhc+xy*pixel_size;

_asm{
pushad
mov ax,0x4f02;/*4F02H VESA*/
mov bx,0x4111;/*111----640*480-64K(5:6:5),110------640*480-32K(1:5:5:5)*/
int 0x10
popad
}

memset(pmhc,0xf,xy*pixel_size);
memcpy(p,pmhc,xy*pixel_size);

word_x=word_x0;
word_y=word_y0;
word_xy=word_y*row_word_count;
word_point_xy=word_xy*lattice_x*lattice_y+word_x*lattice_x;
file_size=sizeof(text_test);

reg (bl_eax);

while(file_point_i<file_size)
{
hex2_to_hex1=file_point[file_point_i];
hex2_to_hex1=((hex2_to_hex1&0xf0)>>4);
word_sz_i=hex2_to_hex1*8;
hd();

hex2_to_hex1=(file_point[file_point_i++]&0x0f);
word_sz_i=hex2_to_hex1*8;
hd();
word_point_xy=word_point_xy+lattice_x;
}

getch();
_asm
{
mov ax,3
int 0x10
}
return 0;
}

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧