📄 format.c
字号:
#include <CsAgb.h>
#include <rbasic.h>
#include <string.h>
#include <rb_string.h>
#include <rb_mem.h>
#include <Qgraph.h>
#include <rb_mem.h>
#include <rb_stdio.h>
#define int_tp 0
#define float_tp 1
#define str_tp 2
#define int_dim_tp 3
#define float_dim_tp 4
#define def_tp 5
#define mark_tp 6
extern u32 dic_get_u32(u32 loc);
typedef struct
{
char ftype[4];//标识
char ver[4];//版本
u8 cnt[8];//计数器
u32 code_bg;//代码开始处
u32 code_len;//代码长度
u32 re;//保留区
} basic_head;//basic文件头
int basic_open(u32 loc)
{
int i;
int cnt=0;
char *temp;
basic_head head;
temp=(char *)&head;
for (i=0;i<sizeof(basic_head);i++) temp[i]=*(char *)(loc+i);
str_up(head.ftype);
if (strcmp(head.ftype,"BAS")) return 1;
rb_int_dim_cnt=head.cnt[int_dim_tp];
rb_float_dim_cnt=head.cnt[float_dim_tp];
rb_int_cnt=head.cnt[int_tp];
rb_float_cnt=head.cnt[float_tp];
rb_str_cnt=head.cnt[str_tp];
rb_def_cnt=head.cnt[def_tp];
rb_mark_cnt=head.cnt[mark_tp];
rb_bas=head.code_bg+loc;
rb_clen=head.code_len;
if (rb_mark_cnt)//计算行标识数据首地址
{
rb_marks=(u32 *)mymalloc(4*rb_mark_cnt);
temp=(char *)rb_marks;
for (i=0;i<rb_mark_cnt*4;i++) temp[i]=*(char *)(rb_bas-rb_mark_cnt*4+i);//取得行标识
}
for (i=0;i<7;i++)
{
rb_mes[i]=loc+sizeof(basic_head)+cnt*10;
cnt+=head.cnt[i];
}
return 0;
}
int basic_look(u32 loc)//打开basic文件供浏览
{
int i;
int cnt=0;
char temp[sizeof(basic_head)];
basic_head head;
for (i=0;i<sizeof(basic_head);i++) temp[i]=*(char *)(loc+i);
DmaCopy(3,temp,&head,sizeof(basic_head),16);
DmaWait(3);
str_up(head.ftype);//RBprint(head.ftype);
if (strcmp(head.ftype,"BAS")!=0) return 1;
rb_mes=(u32 *)mymalloc(4*7);
rb_bas=head.code_bg+loc;
rb_clen=head.code_len;
if (rb_mark_cnt)//计算行标识数据首地址
{
rb_marks=(u32 *)mymalloc(4*rb_mark_cnt);
DmaCopy(3,(u32*)(rb_bas-rb_mark_cnt*4),rb_marks,rb_mark_cnt*4,16);//取得行标识
}
for (i=0;i<7;i++)
{
rb_mes[i]=loc+sizeof(basic_head)+cnt*10;
cnt+=head.cnt[i];
}
return 0;
}
int basic_init()//初始化
{
rb_xp=0;
rb_yp=0;
rb_co=RGB(30,30,30);
rb_bg=0;
rb_pc=0;
rb_bas=0;
rb_fbas=0;
rb_clen=0;
is_basic_run=1;
rb_peek_M=NULL;//内存区
rb_int_var=NULL;//整型变量基址
rb_float_var=NULL;//实型变量基址
rb_str_var=NULL;//字符串变量基址
rb_int_dim=NULL;//整型数组
rb_int_dim_indx=NULL;//整型数组下标基址
rb_float_dim=NULL;//实型数组
rb_float_dim_indx=NULL;
Q_box(0,0,239,159,0);
RBprint("RBASIC FOR GBA V2.0\nPOWERD BY BPNS,2005\nALL RIGHTS RESERVED\n");
rb_error=0;
music_reset();
rb_peek_M=(u8 *)mymalloc(2048);
if (rb_peek_M==NULL) return 1;
rb_cyc_mem();//循环体堆栈空间分配
rb_file_init();//分配文件数据空间
rb_mes=(u32 *)mymalloc(4*7);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -