📄 screen.c
字号:
#include <CsAgb.h>
#include <rb_stdio.h>
#include <rbasic.h>
#include <graph.h>
#include <Qgraph.h>
extern u8 get_para(char *exp,double *nump,char *strp,char *tp);
extern double rb_cal(char *exp);
extern void save_scr(u16 *sav,u8 xp,u8 yp,u8 xsp,u8 ysp);
extern void load_scr(u16 *sav,u8 xp,u8 yp,u8 xsp,u8 ysp);
extern u32 myfopen(char *fname,u32 *size);
extern void rb_get_str(char *exp,char *str);
extern u8 my_bmp(u32 xp,u32 yp,u32 loc);
u16 *rbscr=NULL;//屏幂存储区
void rb_locate(char *exp)
{
double x[2];
if (get_para(exp,x,NULL,"2NN")) return;
if (x[0]<0 || x[0]>29 || x[1]<0 || x[1]>15 ) {rb_error=12;return;}
rb_xp=x[0];
rb_yp=x[1];
}
void rb_color(char *exp)
{
rb_co=rb_cal(exp);
}
void rb_screen(char *exp)
{
int i;
u16 color=rb_cal(exp);
if (rb_error) return;
for (i=0;i<160*240;i++)
{
if (*(mVRAM+i)==rb_bg) *(mVRAM+i)=color;
}
rb_bg=color;
}
void rb_draw(char *exp)
{
double x[4];
if (get_para(exp,x,NULL,"4NNNN")) return;
if (x[0]<0 || x[0]>239 || x[1]<0 || x[1]>159 ) {rb_error=12;return;}
r_draw(x[0],x[1],x[2],x[3]);
}
void rb_line(char *exp)
{
double x[6];
if (get_para(exp,x,NULL,"6NNNNNN")) return;
r_line(x[0],x[1],x[2],x[3],x[4],x[5]);
}
void rb_box(char *exp)
{
double x[6];
if (get_para(exp,x,NULL,"6NNNNNN")) return;
r_box(x[0],x[1],x[2],x[3],x[4],x[5]);
}
void rb_circle(char *exp)
{
double x[5];
if (get_para(exp,x,NULL,"5NNNNNN")) return;
r_circle(x[0],x[1],x[2],x[3],x[4]);
}
void rb_ellipse(char *exp)
{
double x[6];
if (get_para(exp,x,NULL,"6NNNNNN")) return;
Q_ellipse(x[0],x[1],x[2],x[3],x[4],x[5]);
}
void rb_trian(char *exp)
{
double x[8];
if (get_para(exp,x,NULL,"8NNNNNNNNN")) return;
r_triangle(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7]);
}
void rb_quad(char *exp)
{
double x[10];
char tp[]=" NNNNNNNNNNN";
tp[0]='9'+1;
if (get_para(exp,x,NULL,tp)) return;
quadrangle(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9]);
}
void rb_mvscr(char *exp)
{
double x1,x2,y1,y2,step,dre,temp;
double p[6];
if (get_para(exp,p,NULL,"6NNNNNN")) return;
x1=p[0];x2=p[1];
y1=p[2];y2=p[3];
step=p[4];
dre=p[5];
if (dre<1 || dre>4) {rb_error=12;return;}
if (step<0) {rb_error=12;return;}
if (x1<0 || x2<0 || x1>239 || x2>239) {rb_error=12;return;}
if (y1<0 || y2<0 || y1>159 || y2>159) {rb_error=12;return;}
if (x1>x2) {temp=x1;x1=x2;x2=temp;}
if (y1>y2) {temp=y1;y1=y2;y2=temp;}
mov_scr(x1,y1,x2,y2,step,dre);
}
void rb_svscr(char *exp)
{
int x1,x2,y1,y2,temp1;
double p[4];
if (get_para(exp,p,NULL,"4NNNNNN")) return;
x1=p[0];x2=p[1];
y1=p[2];y2=p[3];
if (x1<0 || x2<0 || x1>239 || x2>239) {rb_error=12;return;}
if (y1<0 || y2<0 || y1>159 || y2>159) {rb_error=12;return;}
if (x1>x2) {temp1=x1;x1=x2;x2=temp1;}
if (y1>y2) {temp1=y1;y1=y2;y2=temp1;}
if (rbscr!=NULL) new_free(rbscr);
rbscr=(u16 *)new_malloc(2*(y2-y1+1)*(u32)(x2-x1+1));
if (rbscr==NULL) {rb_error=1;return;}
save_scr(rbscr,x1,y1,x2,y2);
}
void rb_ldscr(char *exp)
{
int x1,x2,y1,y2,temp1;
double p[4];
if (get_para(exp,p,NULL,"4NNNNNN")) return;
x1=p[0];x2=p[1];
y1=p[2];y2=p[3];
if (x1<0 || x2<0 || x1>239 || x2>239) {rb_error=12;return;}
if (y1<0 || y2<0 || y1>159 || y2>159) {rb_error=12;return;}
if (x1>x2) {temp1=x1;x1=x2;x2=temp1;}
if (y1>y2) {temp1=y1;y1=y2;y2=temp1;}
if (rbscr==NULL) return;
load_scr(rbscr,x1,y1,x2,y2);
new_free(rbscr);
}
void rb_bmp(char *exp)
{
u32 size,loc;
double x[2];
char name[str_max_len];
if (get_para(exp,x,name,"3NNS")) return;
if (x[0]<0 || x[0]>239 || x[1]<0 || x[1]>159)
{
rb_error=12;
return;
}
loc=myfopen(name,&size);
if (my_bmp(x[0],x[1],loc)==1) {rb_error=17;return;}
}
void rb_write(char *exp)
{
double x[3];
char str[str_max_len];
if (get_para(exp,x,str,"4NNNS")) return;
if (x[0]<0 || x[0]>239 || x[1]<0 || x[1]>159) {rb_error=12;return;}
cwrite(x[0],x[1],x[2],str);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -