C语言学习记要之——字符模式下轮流显示字符点阵

C语言学习记录之——字符模式下轮流显示字符点阵
C/C++ code
#include <stdio.h>
/*#include "asc_font.c"*/
#define draw '#'
#define x_origin 10
#define y_origin 5
#define word_byte 1*8
/*#include <time.h>*/
#define upkey 72
#define downkey 80
#define addkey '+'
#define subkey '-'
#define spacekey ' '
#define esckey 27
/*#define CLK_TCK CLOCKS_PER_SEC*/

char 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
};


void mygotoxy(int x,int y)
{
while(y--)
{printf("\n");}
while(x--)
{printf(" ");}
}

void hdz(char byte_dz)
{
int byte_bit_num=8;
while(byte_bit_num--)
{
if (byte_dz&0x80)
{
printf("%c",draw);
}
else
{
printf(" ");
}
byte_dz=byte_dz<<1;
}
}

int main(void)
{
int x=x_origin;
char key,byte_dz;
int word_origin=word_byte*0,byte_dz_i=word_origin;

while(1)
{
system("cls");
mygotoxy(x_origin,y_origin);

while(byte_dz_i<word_origin+word_byte)
{
byte_dz=word_sz[byte_dz_i++];
hdz(byte_dz);
printf("\n");
x=x_origin;
while(x--)
{printf(" ");}
}
sleep(1); /*vc使用Sleep(1)*/

while (kbhit())
 {
 key = getch();
 switch (key)
 {
 case upkey:
 byte_dz_i=byte_dz_i+word_byte;
 break;
 case downkey:
 byte_dz_i=byte_dz_i-word_byte*2;
 word_origin=word_origin-word_byte*2;
 break;
 case addkey:
 byte_dz_i=byte_dz_i+word_byte;
 break;
 case subkey:
 byte_dz_i=byte_dz_i-word_byte*2;
 word_origin=word_origin-word_byte*2;
 break;
 case spacekey:
 word_origin=0;
 byte_dz_i=0;
 break;
 case esckey:
 exit(0);
 }
}
word_origin=byte_dz_i;
if (word_origin>=word_byte*(0xf+1))
word_origin=0;
if (word_origin<0)
word_origin=word_byte*0xf;
byte_dz_i=word_origin;
}
}




------解决方案--------------------
挺好的。