void I_Error (char *error, ...) { #ifdef CG_EMULATOR /*// Message first. va_start (argptr,error); printf ("Error: "); printf (error,argptr); printf ("\n"); sprintf(ferror,error,argptr); va_end (argptr); */ printf ("Error: %s",error); //Inform the user something bad had occured //Exit function here #else I_ShutdownGraphics(); Bdisp_AllClr_VRAM(); locate_OS( 1, 1 ); PrintLine( "ERROR:", 21 ); locate_OS( 1, 2 ); PrintLine( (unsigned char *)error, 21 ); { if(key == 31)GetKey( &key ); } #endif //#ifdef CG_EMULATOR //I_Quit(); }
void Disp_FileNotFound() { /* 显示“文件未找到”消息(界面绘制) */ //MsgBoxPush(4); beg: font16 = open_font("\\\\fls0\\24PX.hzk"); select_font(font16); ClearArea(35, 45, 349, 141); print_chs_2(94, 71, 0,"文件未找到"); print_chs_2(94, 119, 0, "按"); locate_OS(8, 5); Print_OS(":[EXIT]", 0, 0); close_font(font16); while (1) { int key; GetKey(&key); switch (key) { case KEY_CTRL_EXIT: //MsgBoxPop(); return; break; } } }
void Disp_About() { /* 显示关于信息(界面绘制) */ beg: font16 = open_font("\\\\fls0\\24PX.hzk"); select_font(font16); MsgBoxPush(5); ClearArea(35,45,349,166); locate_OS(3,2); Print_OS("iBooks Pro C",0,0); print_chs_2(38, 71, 0, "版本 "); locate_OS(7, 3); Print_OS("1.50", 0, 0); print_chs_2(38, 95, 0, "制作:清水视野工作室"); print_chs_2(38, 119, 0, "本程序依"); locate_OS(10, 5); Print_OS("GNU GPL v3",0,0); print_chs_2(38, 143, 0, "协议开放源代码。"); close_font(font16); while (1) { int key; GetKey(&key); switch (key) { case KEY_CTRL_EXIT: MsgBoxPop(); return;break; } } }
void Confirm_AllDivide(const char* fn) { /* 尝试全部分页(界面绘制) 参数说明: fn: 当前打开文件的文件名 */ beg: font16 = open_font("\\\\fls0\\24PX.hzk"); select_font(font16); ClearArea(35,45,349,166); print_chs_2(38,47,0,"尝试全部分页可能需要"); print_chs_2(38,71,0,"很长时间。"); print_chs_2(38,95,0,"确定继续?"); locate_OS(6,5); Print_OS("[F1]:",0,0);print_chs_2(181,119,0,"是"); locate_OS(6,6); Print_OS("[F6]:",0,0);print_chs_2(181,143,0,"否"); close_font(font16); while (1) { int key; GetKey(&key); switch (key) { case KEY_CTRL_F1: divide_page(fn,9999-cached,0); // 尝试分到 9999 页 return;break; case KEY_CTRL_F6: return;break; } } }
void main(void) { /* 程序主函数 */ int key; if (!check_consistency()) // 如果文件有缺失,显示错误信息并退出 { locate_OS(1,1); Print_OS("Can't find font file.",0,0); while (1) GetKey(&key); } browse_main(); // 否则进入文件浏览器 return; }
void I_ErrorI (char *error, int i1,int i2,int i3,int i4) { #ifndef CG_EMULATOR char buf[21]; Bdisp_AllClr_VRAM(); locate_OS( 1, 1 ); PrintLine( "ERROR:", 21 ); locate_OS( 1, 2 ); PrintLine( (unsigned char *)error, 21 ); locate_OS( 1, 3 );CGDAppendNum0_999("i1",i1,0,buf);PrintLine( (unsigned char *)buf, 21 ); locate_OS( 1, 4 );CGDAppendNum0_999("i2",i2,0,buf);PrintLine( (unsigned char *)buf, 21 ); locate_OS( 1, 5 );CGDAppendNum0_999("i3",i3,0,buf);PrintLine( (unsigned char *)buf, 21 ); locate_OS( 1, 6 );CGDAppendNum0_999("i4",i4,0,buf);PrintLine( (unsigned char *)buf, 21 ); { if(key == 31)GetKey( &key ); } #else I_Error (error,i1,i2,i3,i4); #endif }
int Subdir_Open(const char* fn) { /* 子目录文件名输入(界面绘制) 参数说明: fn: 接收从键盘输入文件名的缓冲区 */ FONTCHARACTER fname[64]; char keybuff[32]; // 接受文件名的字符缓冲区 int inspos = 0; memset(keybuff, 0, sizeof(keybuff)); MsgBoxPush(4); beg: font16 = open_font("\\\\fls0\\24PX.hzk"); select_font(font16); ClearArea(0, 192, 384, 216); draw_pic(0, 192, 61, 22, 0, Menu_Sub_Jump); ClearArea(35, 45, 349, 141); print_chs_2(38, 71, 0, "输入欲打开的文件名:"); locate_OS(3, 4); Print_OS("[ ].txt", 0, 0); locate_OS(4, 4); Print_OS(keybuff, 0, 0); close_font(font16); while (1) { int key; GetKey(&key); switch (key) { case KEY_CTRL_EXIT: MsgBoxPop(); return 0; break; case KEY_CTRL_DEL: if (inspos > 0) { keybuff[--inspos] = 0; // 最后一个字节置为 NULL,标识已删除 goto beg; } break; case KEY_CTRL_F1: case KEY_CTRL_EXE: strcpy(fn, keybuff); //MsgBoxPop(); return 1; break; default: if (key >= 0x30 && key <= 0x39 || key >= 0x41 && key <= 0x5A || key >= 0x61 && key <= 0x7A) // 输入数字 0~9 或英文字母 a-z、A-Z { if (inspos <= 8) { keybuff[inspos++] = key; // 最后一个字节添加输入 goto beg; } } } } }
void Page_Jump(const char* fn) { /* 跳页(界面绘制) 参数说明: fn: 当前打开文件的文件名 */ FONTCHARACTER fname[64]; char tip[64],tmp[64]; char keybuff[32]; // 接受页码的字符缓冲区 int inspos=0,target; memset(keybuff, 0, sizeof(keybuff)); MsgBoxPush(5); beg: font16 = open_font("\\\\fls0\\24PX.hzk"); select_font(font16); ClearArea(0,192,384,216); draw_pic(0,192,61,22,0,Menu_Sub_Jump); draw_pic(63,192,61,22,0,Menu_Jump); ClearArea(35,45,349,166); print_chs_2(38,47,0,"当前页/已缓存页数:"); locate_OS(3,3); memset(tmp,0,sizeof(tmp));memset(tip,0,sizeof(tip)); itoa(page+1,tmp,10);strcat(tip,tmp); strcat(tip,"/");memset(tmp,0,sizeof(tmp)); itoa(cached,tmp,10);strcat(tip,tmp); Print_OS(tip,0,0); print_chs_2(38,119,0,"输入目标页码:"); locate_OS(3,6); Print_OS("[ ]",0,0); locate_OS(4,6); Print_OS(keybuff,0,0); close_font(font16); while (1) { int key; GetKey(&key); switch (key) { case KEY_CTRL_EXIT: MsgBoxPop(); return;break; case KEY_CTRL_F2: Confirm_AllDivide(fn); // 尝试全部分页 goto beg;break; case KEY_CTRL_DEL: if (inspos>0) { keybuff[--inspos]=0; // 最后一个字节置为 NULL,标识已删除 goto beg; } break; case KEY_CTRL_F1: case KEY_CTRL_EXE: if (inspos==0) break; target=atoi(keybuff); if (target>cached) // 如果目标位置超出已缓存页面数,尝试分页 { if (!divide_page(fn, target-cached, 1)) page = cached - 1; // 若分页已达文件末尾,则将当前页面修正到最后一页 else page=target-1; // 否则修正当前页面为输入的目标位置 } else page=target-1; // 修正当前页面为输入的目标位置 MsgBoxPop(); return;break; default: if (key>=0x30&&key<=0x39) // 输入数字 0~9 { if (inspos<=3) { if (key==0x30&&inspos==0) break; // 尝试第一位输入 0 时跳出 keybuff[inspos++]=key; // 最后一个字节添加输入 goto beg; } } } } }
void Read_Bookmark(const char* fn,int* pages,int* n) { /* 读取书签(界面绘制) 参数说明: fn: 当前打开文件的文件名 pages: 接受当前所在页码的缓冲区 n: 接受已缓存页面数的缓冲区 */ int handle,_n=0,_page=*pages; int i,sel=0; FONTCHARACTER fname[64]; char tip[64],tmp[64]; MsgBoxPush(5); beg: font16 = open_font("\\\\fls0\\24PX.hzk"); select_font(font16); ClearArea(0,192,384,216); draw_pic(0,192,61,22,0,Menu_ReadB); ClearArea(35,49,349,166); print_chs_2(38,47,0,"读取书签"); close_font(font16); for (i=0;i<4;++i) { memset(tmp,0,sizeof(tmp));memset(tip,0,sizeof(tip)); strcat(tip,"["); itoa(i+1,tmp,10);strcat(tip,tmp); strcat(tip,"]"); if (bookmark[i]) { strcat(tip," Page "); memset(tmp,0,sizeof(tmp)); itoa(bookmark[i],tmp,10);strcat(tip,tmp); } else strcat(tip," Empty"); locate_OS(3,3+i); Print_OS(tip,0,0); } Bdisp_AreaReverseVRAM(35,72+sel*24,349,94+sel*24); while (1) { int key; GetKey(&key); switch (key) { case KEY_CTRL_UP: if (sel>0) --sel; goto beg;break; case KEY_CTRL_DOWN: if (sel<3) ++sel; goto beg;break; case KEY_CTRL_EXE: if (bookmark[sel]) { *pages=bookmark[sel]-1; // 读取书签 MsgBoxPop(); return; } else goto beg;break; case KEY_CTRL_F1: case KEY_CTRL_EXIT: *pages=_page; MsgBoxPop(); return;break; } } }
void Save_Bookmark(const char* fn,unsigned int pages,int n) { /* 存储书签(界面绘制) 参数说明: fn: 当前打开文件的文件名 pages: 当前所在页码 n: 已缓存页面数 */ int handle,size,i=0; int sel=0,flag; char tip[64],tmp[64]; MsgBoxPush(5); beg: flag=0; font16 = open_font("\\\\fls0\\24PX.hzk"); select_font(font16); ClearArea(0,192,384,216); draw_pic(0,192,124,22,0,Menu_PutB); ClearArea(35,49,349,166); print_chs_2(38,47,0,"存储书签"); close_font(font16); for (i=0;i<4;++i) { memset(tmp,0,sizeof(tmp));memset(tip,0,sizeof(tip)); strcat(tip,"["); itoa(i+1,tmp,10);strcat(tip,tmp); strcat(tip,"]"); if (bookmark[i]) { strcat(tip," Page "); memset(tmp,0,sizeof(tmp)); itoa(bookmark[i],tmp,10);strcat(tip,tmp); } else strcat(tip," Empty"); locate_OS(3,3+i); Print_OS(tip,0,0); } Bdisp_AreaReverseVRAM(35,72+sel*24,349,94+sel*24); while (1) { int key; GetKey(&key); switch (key) { case KEY_CTRL_UP: if (sel>0) --sel; goto beg;break; case KEY_CTRL_DOWN: if (sel<3) ++sel; goto beg;break; case KEY_CTRL_F1: case KEY_CTRL_EXE: bookmark[sel]=pages+1; // 存储书签 goto prg;break; case KEY_CTRL_F2: case KEY_CTRL_DEL: bookmark[sel]=0;flag=1;goto prg;break; // 删除书签 case KEY_CTRL_EXIT: MsgBoxPop(); return; } } prg: Save_Config(fn,n); if (flag) goto beg; MsgBoxPop(); }
void GoL_showRules(settings* sets) { const unsigned short nb_p[2] = {0x0000, 0xffff}; const unsigned char Alive[96] = { 0x00,0x0f,0xff,0xff,0xff,0xff, 0x00,0x0f,0xff,0xff,0xff,0xff, 0x3f,0xcf,0xff,0xff,0xff,0xc3, 0x3f,0xcf,0xff,0xff,0xff,0xc3, 0x3f,0xcc,0xff,0xff,0xff,0xc3, 0x3f,0xcc,0xff,0xff,0xff,0xc3, 0x3f,0xcc,0xff,0xff,0xff,0xff, 0x3f,0xcc,0xff,0xff,0xff,0xff, 0x00,0x0c,0xcc,0xf3,0x00,0xff, 0x00,0x0c,0xcc,0xf3,0x00,0xff, 0x3f,0xcc,0xfc,0xf3,0x0f,0xc3, 0x3f,0xcc,0xfc,0xf3,0x0f,0xc3, 0x3f,0xcc,0xcc,0xf3,0x3f,0xc3, 0x3f,0xcc,0xcc,0xf3,0x3f,0xc3, 0x3f,0xcc,0xcf,0x0f,0x00,0xff, 0x3f,0xcc,0xcf,0x0f,0x00,0xff };//48*16 const unsigned char Surv[96] = { 0x00,0x0f,0xff,0xff,0xff,0xff, 0x00,0x0f,0xff,0xff,0xff,0xff, 0x3f,0xff,0xff,0xff,0xff,0xf0, 0x3f,0xff,0xff,0xff,0xff,0xf0, 0x3f,0xff,0xff,0xff,0xff,0xf0, 0x3f,0xff,0xff,0xff,0xff,0xf0, 0x00,0x0f,0xff,0xff,0xff,0xff, 0x00,0x0f,0xff,0xff,0xff,0xff, 0xff,0xcc,0xf3,0x00,0xcf,0x3f, 0xff,0xcc,0xf3,0x00,0xcf,0x3f, 0xff,0xcc,0xf3,0x3c,0xcf,0x30, 0xff,0xcc,0xf3,0x3c,0xcf,0x30, 0xff,0xcc,0xf3,0x3f,0xcf,0x30, 0xff,0xcc,0xf3,0x3f,0xcf,0x30, 0x00,0x0c,0x03,0x3f,0xf0,0xff, 0x00,0x0c,0x03,0x3f,0xf0,0xff };//48*16 CopySpriteNbit(Alive, 0,74, 48, 16, nb_p,1); CopySpriteNbit(Surv, 0,146, 48, 16, nb_p,1); for(int i = 0; i<9; i++) { unsigned char str[] = "\xE7\x2F";//little num chars str[1] = 0x30+i; unsigned char check[] = "\xE6\xA5"; //Check box locate_OS(i+4,3); check[1] = sets->gol_neighbour_num_survive[i]? 0xA9 : 0xA5; Print_OS(check, TEXT_MODE_NORMAL, 0); locate_OS(i+4,4); Print_OS(str, TEXT_MODE_NORMAL, 0); locate_OS(i+4,6); check[1] = sets->gol_neighbour_num_born[i]? 0xA9 : 0xA5; Print_OS(check, TEXT_MODE_NORMAL, 0); locate_OS(i+4,7); Print_OS(str, TEXT_MODE_NORMAL, 0); } showColors(sets); }