从零开始搭建环境编写操作系统 AT&T GCC (五)显示鼠标和字符

xiaoxiao2021-02-28  134

  前期工作打好了基础,都已经可以画图了,想要显示鼠标和字符知识需要一个字库就可以了。 一、显示字符   新建一个文件夹,叫做font文件夹,以后我们还要增加中文字体的显示等,这样会比较条理。文件夹下新建font.c,font.h,font_code.c,font.c是对显示文字进行操作的一些函数,font_code.c保存有字库数组,font.h头文件。   显示字符的理论非常的简单,首先需要一个字库,我把我使用的字库直接传上来了,百度文库下载的,嫌不好看的可以百度字模生成软件,自己生成想要的字体。把这个字库保存在font_code.c,不要忘记声明头文件。

#include "font.h" const char font_code_global[94][16]={//Ó¢ÎÄ»ò±êµã·ûºÅ //0x21 -- 0x7e {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x80,},//! {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0xa0,0xa0,},//" {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x28,0xfc,0x28,0x50,0xfc,0x50,0x50,},//# {0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x78,0xa8,0xa0,0x60,0x30,0x28,0xa8,0xf0,0x20,},//$ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x48,0xa8,0xb0,0x50,0x28,0x34,0x54,0x48,},//% {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x50,0x50,0x78,0xa8,0xa8,0x90,0x6c,},//& {0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,},//' {0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x40,0x80,0x80,0x80,0x80,0x80,0x80,0x40,0x20,},//( {0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0x20,0x20,0x20,0x20,0x20,0x40,0x80,},//) {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0xa8,0x70,0x70,0xa8,0x20,},//* {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0xf8,0x20,0x20,0x20,},//+ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x80,},//, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,},//- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,},//. {0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x10,0x10,0x20,0x20,0x40,0x40,0x40,0x80,},/// {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x70,},//0 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xc0,0x40,0x40,0x40,0x40,0x40,0xe0,},//1 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x88,0x88,0x10,0x20,0x40,0x80,0xf8,},//2 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x88,0x08,0x30,0x08,0x08,0x88,0x70,},//3 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x30,0x50,0x50,0x90,0x78,0x10,0x18,},//4 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x80,0x80,0xf0,0x08,0x08,0x88,0x70,},//5 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x90,0x80,0xf0,0x88,0x88,0x88,0x70,},//6 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x90,0x10,0x20,0x20,0x20,0x20,0x20,},//7 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x88,0x88,0x70,0x88,0x88,0x88,0x70,},//8 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x88,0x88,0x88,0x78,0x08,0x48,0x70,},//9 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x80,},//: {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x80,},//; {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x08,},//< {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x00,0x00,0xf8,},//= {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x10,0x20,0x40,0x80,},//> {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x88,0x88,0x10,0x20,0x20,0x00,0x20,},//? {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x88,0x98,0xa8,0xa8,0xb8,0x80,0x78,},//@ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x30,0x50,0x50,0x78,0x48,0xcc,},//A {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x48,0x48,0x70,0x48,0x48,0x48,0xf0,},//B {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x88,0x80,0x80,0x80,0x80,0x88,0x70,},//C {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x48,0x48,0x48,0x48,0x48,0x48,0xf0,},//D {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x48,0x50,0x70,0x50,0x40,0x48,0xf8,},//E {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x48,0x50,0x70,0x50,0x40,0x40,0xe0,},//F {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x48,0x80,0x80,0x9c,0x88,0x48,0x30,},//G {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0x48,0x48,0x78,0x48,0x48,0x48,0xcc,},//H {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0xf8,},//I {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x10,0x10,0x10,0x10,0x10,0x10,0x90,0xe0,},//J {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xec,0x48,0x50,0x60,0x50,0x50,0x48,0xec,},//K {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x40,0x40,0x40,0x40,0x40,0x44,0xfc,},//L {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd8,0xd8,0xd8,0xd8,0xa8,0xa8,0xa8,0xa8,},//M {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xdc,0x48,0x68,0x68,0x58,0x58,0x48,0xe8,},//N {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x70,},//O {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x48,0x48,0x70,0x40,0x40,0x40,0xe0,},//P {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x88,0x88,0x88,0x88,0xe8,0x98,0x70,0x18,},//Q {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x48,0x48,0x70,0x50,0x48,0x48,0xec,},//R {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x88,0x80,0x60,0x10,0x08,0x88,0xf0,},//S {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xa8,0x20,0x20,0x20,0x20,0x20,0x70,},//T {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0x48,0x48,0x48,0x48,0x48,0x48,0x30,},//U {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0x48,0x48,0x50,0x50,0x30,0x20,0x20,},//V {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa8,0xa8,0xa8,0x70,0x50,0x50,0x50,0x50,},//W {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd8,0x50,0x50,0x20,0x20,0x50,0x50,0xd8,},//X {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd8,0x50,0x50,0x20,0x20,0x20,0x20,0x70,},//Y {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x90,0x10,0x20,0x20,0x40,0x48,0xf8,},//Z {0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xe0,},//[ {0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x40,0x40,0x20,0x20,0x20,0x10,0x00,},/* \ */ {0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xe0,},//] {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xa0,},//^ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,},//_ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,},//` {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x90,0x70,0x90,0x78,},//a {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x40,0x40,0x70,0x48,0x48,0x48,0x70,},//b {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x90,0x80,0x80,0x70,},//c {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x10,0x10,0x70,0x90,0x90,0x90,0x78,},//d {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x90,0xf0,0x80,0x70,},//e {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x40,0x40,0xf0,0x40,0x40,0x40,0xf0,},//f {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x90,0x60,0x80,0xf0,0x88,0x70,},//g {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x40,0x40,0x70,0x48,0x48,0x48,0xec,},//h {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0xc0,0x40,0x40,0x40,0xe0,},//i {0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x30,0x10,0x10,0x10,0x10,0x10,0xe0,},//j {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x40,0x40,0x5c,0x50,0x70,0x48,0xec,},//k {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x20,0x20,0x20,0x20,0x20,0x20,0xf8,},//l {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xa8,0xa8,0xa8,0xa8,},//m {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x48,0x48,0x48,0xec,},//n {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x90,0x90,0x90,0x60,},//o {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x48,0x48,0x48,0x70,0x40,0xe0,},//p {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x90,0x90,0x90,0x70,0x10,0x38,},//q {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd8,0x60,0x40,0x40,0xe0,},//r {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x80,0x60,0x10,0xf0,},//s {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0xe0,0x40,0x40,0x40,0x30,},//t {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd8,0x48,0x48,0x48,0x3c,},//u {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xec,0x48,0x50,0x30,0x20,},//v {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa8,0xa8,0x70,0x50,0x50,},//w {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd8,0x50,0x20,0x50,0xd8,},//x {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xec,0x48,0x50,0x30,0x20,0x20,0xc0,},//y {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x20,0x40,0x40,0xf0,},//z {0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x40,0x40,0x40,0x80,0x40,0x40,0x40,0x40,0x60,},//{ {0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,},//| {0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x40,0x40,0x40,0x20,0x40,0x40,0x40,0x40,0xc0,},//} {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xa4,0x18,},//~ };

  好长啊,这个是包含了ASCII可以显示的所有字符。1表示显示,0表示不显示,这个字库是8x16格式的,所以一个字母占用空间位16字节,还有32字节字库,64字节字库等。   所以显示字母的理论也就非常简单了,比如我要输入A,A的ascii代码是0x41,这个数组是从0x21开始的,所以第0x41-0x21就存储着A的字库,然后一行行扫描,遇到1就输出一个点,最后就可以把A显示出来了。   我把我的实现方式贴上来:   

#include "font.h" void DrawPoint(int x,int y,int color);//画一个点 void PutChar(int x,int y, char put_char, int color);//画一个字符 void DrawPoint(int x,int y,int color) { char *p; p = (char*)(0xFD000000 + (800 * y + x) * 3);//计算某个像素的内存地址 *(p+2) = (char)(color >> 16);//color是int型,4字节,最高字节保留不用,剩下为rgb,向右移动10位,把R值取出 *(p+1) = (char)((color >> 8) & 0xFF);//向右移动8字节,然后 &0x11111111,得到G *p = (char)(color & 0xFF);//同理,B值 return; } void PutString(int x,int y, char* string, int color)//输出字符串,输出直到结尾为\0停止符 { int i=0; while(string[i] != '\0') { PutChar(x + 10 *i, y, *(string+i),color);//there are 2 pixels between char i++; } } void PutChar(int x,int y, char put_char, int color)//输出一个字符 { int i; if (put_char >= 0x21 && put_char <= 0x7e) { for (i=0;i<16;i++)//扫描点阵,从上到下16行 { if((font_code_global[put_char-0x21][i] & 0x80) == 0x80) //compare font & 1000 0000 DrawPoint(x+0,y+i,color); if((font_code_global[put_char-0x21][i] & 0x40) == 0x40) //compare font & 0100 0000 DrawPoint(x+1,y+i,color); if((font_code_global[put_char-0x21][i] & 0x20) == 0x20) //compare font & 0010 0000 DrawPoint(x+2,y+i,color); if((font_code_global[put_char-0x21][i] & 0x10) == 0x10) //compare font & 0001 0000 DrawPoint(x+3,y+i,color); if((font_code_global[put_char-0x21][i] & 0x08) == 0x08) //compare font & 0000 1000 DrawPoint(x+4,y+i,color); if((font_code_global[put_char-0x21][i] & 0x04) == 0x04) //compare font & 0000 0100 DrawPoint(x+5,y+i,color); if((font_code_global[put_char-0x21][i] & 0x02) == 0x02) //compare font & 0000 0010 DrawPoint(x+6,y+i,color); if((font_code_global[put_char-0x21][i] & 0x01) == 0x01) //compare font & 0000 0001 DrawPoint(x+7,y+i,color); } } }

  字符的输出就完成了,随便写一个demo。   

二、鼠标的输出   新建文件夹,命名为cursor,以后鼠标的操作也很多的,所以提前做好布局。新建cursor.c,cursor.h。   我们现在就只需要画一个鼠标,所以同输出字符的原理相同。   

void DrawCursorPoint(int x,int y,int color); //type:0、箭头 void DrawCursor(int x,int y, int type) { static char cursor_point[16][16] = { "************** ", "*11111111111* ", "*1111111111* ", "*111111111* ", "*11111111* ", "*1111111* ", "*1111111* ", "*11111111* ", "*1111**111* ", "*111* *111* ", "*11* *111* ", "*1* *111* ", "* *111* ", " *111*", " *11*", " ***", }; int i,j; int *cursor_type; char *point; if (type == 0) { point = &cursor_point[0][0]; } for (i=0;i<16;i++) { for (j=0;j<16;j++) { if (*point == '*') DrawCursorPoint(x+j,y+i,0xffff00); if (*point == '1') DrawCursorPoint(x+j,y+i,0xffffff); point++; } } } void DrawCursorPoint(int x,int y,int color) { char *p; p = (char*)(0xFD000000 + (800 * y + x) * 3); *(p+2) = (char)(color >> 16); *(p+1) = (char)((color >> 8) & 0xFF); *p = (char)(color & 0xFF); return; }

  这一段代码我觉的就没有解释的必要了,异曲同工的东西,最关键的是,我们要让鼠标动起来。下节继续吧。    三、printf功能实现   为了方便调试,我们还是要使用printf功能,在font.c中,我自己编写了一个printf的简单版本:   不要忘记自己修改一下.h,把需要输出的函数放进去。   编译的时候会有警告,是因为gcc编译器本来就带有printf等小函数,Makefile编译器加上-fno-builtin就可以了

#include "font.h" typedef int* va_list; #define va_start(ap, A) (ap = (int *)&(A) + 1) #define va_arg(ap, T) (*(T *)ap++) #define va_end(ap) ((void)0) void DrawFontPoint(int x,int y,int color); char *Int2String(int a, char *buf); void PutCharHex(int x, int y, int color, char c); void PutIntHex(int x,int y,int color, int a); void PutChar(int x,int y, char put_char, int color); //画出一个点 void DrawFontPoint(int x,int y,int color) { char *p; p = (char*)(0xFD000000-0x8200 + (800 * y + x) * 3); *(p+2) = (char)(color >> 16); *(p+1) = (char)((color >> 8) & 0xFF); *p = (char)(color & 0xFF); return; } //在(x,y)位置画一个字符 void PutChar(int x,int y, char put_char, int color) { int i; if (put_char >= 0x21 && put_char <= 0x7e) { for (i=0;i<16;i++) { if((font_code_global[put_char-0x21][i] & 0x80) == 0x80) //compare font & 1000 0000 DrawFontPoint(x+0,y+i,color); if((font_code_global[put_char-0x21][i] & 0x40) == 0x40) //compare font & 0100 0000 DrawFontPoint(x+1,y+i,color); if((font_code_global[put_char-0x21][i] & 0x20) == 0x20) //compare font & 0010 0000 DrawFontPoint(x+2,y+i,color); if((font_code_global[put_char-0x21][i] & 0x10) == 0x10) //compare font & 0001 0000 DrawFontPoint(x+3,y+i,color); if((font_code_global[put_char-0x21][i] & 0x08) == 0x08) //compare font & 0000 1000 DrawFontPoint(x+4,y+i,color); if((font_code_global[put_char-0x21][i] & 0x04) == 0x04) //compare font & 0000 0100 DrawFontPoint(x+5,y+i,color); if((font_code_global[put_char-0x21][i] & 0x02) == 0x02) //compare font & 0000 0010 DrawFontPoint(x+6,y+i,color); if((font_code_global[put_char-0x21][i] & 0x01) == 0x01) //compare font & 0000 0001 DrawFontPoint(x+7,y+i,color); } } } //在x,y位置输出一个字符串 void PutString(int x, int y, int color, const char * s) { int i=0; while (*s) { PutChar(x+8*i,y,*s++,color); i++; } } //把int转化为一个字符串 char *Int2String(int a, char *buf) { int num = a; int i = 0; int len = 0; do { buf[i++] = num % 10 + '0'; num /= 10; } while (num); buf[i] = '\0'; len = i; for (i = 0; i < len/2; i++) { char tmp; tmp = buf[i]; buf[i] = buf[len-i-1]; buf[len-i-1] = tmp; } return buf; } //输出一个16进制字符穿 void PutCharHex(int x, int y, int color, char c) { char * hex = "0123456789ABCDEF"; PutChar(x,y,hex[(c>>4) & 0x0F],color); PutChar(x+8,y,hex[(c>>0) & 0x0F],color); } //输出一个int的16进制字符串 void PutIntHex(int x,int y,int color, int a) { PutCharHex(x,y,color, (a>>24) & 0xFF ); PutCharHex(x+16,y,color, (a>>16) & 0xFF ); PutCharHex(x+32,y,color, (a>>8) & 0xFF ); PutCharHex(x+48,y,color, (a>>0) & 0xFF ); } //printf主函数 int printf(int x, int y, int color, const char * format, ...) { char c; va_list ap; va_start(ap, format); int i=0; while ((c = *format++) != '\0') { i++; switch (c) { case '%': c = *format++; switch (c) { char ch; char * p; int a; char buf[100]; case 'c': ch = va_arg(ap, int); PutChar(x+8*i,y,ch,color); break; case 's': p = va_arg(ap, char *); PutString(x+8*i, y, color, p) break; case 'x': a = va_arg(ap, int); PutIntHex(x,y,color,a); break; case 'd': a = va_arg(ap, int); Int2String(a, buf); PutString(x+8*i, y, color, buf); break; default: break; } break; default: PutChar(x+8*i,y,c,color); break; } } return 0; }
转载请注明原文地址: https://www.6miu.com/read-21475.html

最新回复(0)