stdio.c
来自「redboy for gba 是BPNS为GBA编写的一个小软件。软件的邹形是B」· C语言 代码 · 共 75 行
C
75 行
#include <CsAgb.h>
#include <math.h>
#include <rb_math.h>
#include <ascii.h>
#include <rbasic.h>
#include <Qgraph.h>
extern const unsigned char FONTS_ST[];
const u8 font_mask[8]={128,64,32,16,8,4,2,1};//點陣測試位
extern void load_scr(u16 *sav,u8 xp,u8 yp,u8 xsp,u8 ysp);
void rb_scroll()
{
u8 i=0;
//CS_RestoreScreenMem(&gScreen,0,0,239,149,mVRAM+2400,MODE_3);
load_scr(mVRAM+2400,0,0,239,149);
r_box(0,150,239,159,rb_bg,1);
}
void print(u8 xp,u8 yp,u16 color,char ch)//显示单个字符
{
int i,j;
int get;
int fmask;
int loc=240*yp+xp;
//Q_box(xp,yp,xp+8,yp+8,rb_bg);
for (i=0;i<8;i++)
{
get=ascii[ch][i];
fmask=0x1;
for (j=0;j<8;j++)
{
if (get & fmask) *(mVRAM+j+loc)=color;
else *(mVRAM+j+loc)=rb_bg;
fmask<<=1;
}
loc+=240;
}
return;
}
void printf(u8 xp,u8 yp,u16 color, char *str)
{
int i=0;
while (*(str+i)!='\0')
{
print(xp+8*i,yp,color,*(str+i));
i++;
}
return;
}
void prtchar(u16 color,char ch)//显示单个字符并移到光标
{
if (ch=='\n') {rb_xp=0;rb_yp++;}
else
{
print(rb_xp*8,rb_yp*10+2,color,ch);
rb_xp++;
}
if (rb_xp==30) {rb_xp=0,rb_yp++;}
if (rb_yp==16) {rb_yp=15;rb_scroll();}
}
void endl()
{
prtchar(0,'\n');
}
void Vprint(u8 xp,u8 yp,u16 color,char *str)
{
int i=0;
int x=xp,y=yp;
while (*(str+i)!='\0')
{
if (x>29) {x=0;y++;}
if (y>15) {y=15;rb_scroll();}
if (*(str+i)=='\n')
{
x=0;y++;i++; //自动
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?