static void report_image_error(int status) { char infomsg[80]; const char *errstr; switch (status) { case 1: case 2: case 3: errstr = _("格式错误"); break; case 4: case 5: errstr = _("内存不足"); break; case 6: errstr = _("压缩档案损坏或密码错误"); break; default: errstr = _("不明"); break; } SPRINTF_S(infomsg, _("图像无法装载, 原因: %s"), errstr); win_msg(infomsg, COLOR_WHITE, COLOR_WHITE, config.msgbcolor); ctrl_waitrelease(); dbg_printf(d, _ ("图像无法装载,原因: %s where = %d config.path %s filename %s"), errstr, where, config.path, filename); imgreading = false; reset_image_ptr(); }
int game(char *code, char *pion, int tentative, int slot) { int win; int round; char buffer[24]; int len; if (check_game(code, pion, slot, tentative) == 1) return (1); my_putstr("Trouverez-vous le code secret ?\n"); round = 1; win = 0; while (tentative >= round && win != 1) { my_putstr("---\n"); write(1, "Round ", 6); my_putnbr(round); write(1, "\n>", 1); len = read(0, buffer, 23); buffer[len - 1] = 0; win = is_solution(code, buffer, pion, slot); round++; } win_msg(round - 1, win, code); free(code); free(pion); return (0); }
extern bool usb_activate(void) { if (!is_usb_inited) { usb_open(); } if (xrPowerGetBusClockFrequency() < 66 && !have_prompt) { win_msg("USB转输时请提高总线频率以免传输失败(本提示不再提示)", COLOR_WHITE, COLOR_WHITE, config.msgbcolor); have_prompt = true; } if (usb_isactive()) return false; return (xrUsbActivate(0x1c8) == 0); }
static dword scene_rotateimage(void) { int ret; ret = image_rotate(imgdata, &width, &height, oldangle, (dword) config.rotate * 90); if (ret < 0) { win_msg("内存不足无法完成旋转!", COLOR_WHITE, COLOR_WHITE, config.msgbcolor); config.rotate = conf_rotate_0; } oldangle = (dword) config.rotate * 90; if (config.fit > 0 && (config.fit != conf_fit_custom || config.scale != 100)) { reset_image_show_ptr(); if (config.fit == conf_fit_custom) { width_rotated = width * config.scale / 100; height_rotated = height * config.scale / 100; } else if (config.fit == conf_fit_width) { config.scale = PSP_SCREEN_WIDTH / width; if (config.scale > 200) config.scale = (config.scale / 50) * 50; else { config.scale = (config.scale / 10) * 10; if (config.scale < 10) config.scale = 10; } width_rotated = PSP_SCREEN_WIDTH; height_rotated = height * PSP_SCREEN_WIDTH / width; } else if (config.fit == conf_fit_dblwidth) { config.scale = 960 / width; if (config.scale > 200) config.scale = (config.scale / 50) * 50; else { config.scale = (config.scale / 10) * 10; if (config.scale < 10) config.scale = 10; } width_rotated = 960; height_rotated = height * 960 / width; } else if (config.fit == conf_fit_dblheight) { config.scale = imgh / height; if (config.scale > 200) config.scale = (config.scale / 50) * 50; else { config.scale = (config.scale / 10) * 10; if (config.scale < 10) config.scale = 10; } height_rotated = imgh * 2; width_rotated = width * imgh * 2 / height; } else { config.scale = imgh / height; if (config.scale > 200) config.scale = (config.scale / 50) * 50; else { config.scale = (config.scale / 10) * 10; if (config.scale < 10) config.scale = 10; } height_rotated = imgh; width_rotated = width * imgh / height; } imgshow = (pixel *) memalign(16, sizeof(pixel) * width_rotated * height_rotated); if (imgshow != NULL) { if (config.bicubic) image_zoom_bicubic(imgdata, width, height, imgshow, width_rotated, height_rotated); else image_zoom_bilinear(imgdata, width, height, imgshow, width_rotated, height_rotated); } else { imgshow = imgdata; width_rotated = width; height_rotated = height; } } else { config.scale = 100; imgshow = imgdata; width_rotated = width; height_rotated = height; } curleft = curtop = 0; xpos = (int) config.viewpos % 3; ypos = (int) config.viewpos / 3; if (width_rotated < PSP_SCREEN_WIDTH) paintleft = (PSP_SCREEN_WIDTH - width_rotated) / 2; else { paintleft = 0; switch (xpos) { case 1: curleft = (width_rotated - PSP_SCREEN_WIDTH) / 2; break; case 2: curleft = width_rotated - PSP_SCREEN_WIDTH; break; } } if (height_rotated < imgh) painttop = (imgh - height_rotated) / 2; else { painttop = 0; switch (ypos) { case 1: curtop = (height_rotated - imgh) / 2; break; case 2: curtop = height_rotated - imgh; break; } } if (width > height) { thumb_width = 128; thumb_height = height * 128 / width; } else { thumb_height = 128; thumb_width = width * 128 / height; } image_zoom_bilinear(imgdata, width, height, thumbimg, thumb_width, thumb_height); if (slideshow) lasttime = time(NULL); return 0; }
static int image_handle_input(dword * selidx, dword key) { slideshow_move = false; #ifdef ENABLE_ANALOG if (config.img_enable_analog) { int x, y, orgtop = curtop, orgleft = curleft; if (ctrl_analog(&x, &y)) { slideshow_move = true; x = x / 31 * (int) config.imgmvspd / 2; y = y / 31 * (int) config.imgmvspd / 2; curtop += y; if (curtop + imgh > height_rotated) curtop = (int) height_rotated - imgh; if (curtop < 0) curtop = 0; curleft += x; if (curleft + PSP_SCREEN_WIDTH > width_rotated) curleft = (int) width_rotated - PSP_SCREEN_WIDTH; if (curleft < 0) curleft = 0; thumb = (config.thumb == conf_thumb_scroll); img_needrp = (thumb || orgtop != curtop || orgleft != curleft); } } #endif if (key == 0) goto next; if (!slideshow || (key != CTRL_FORWARD && key != 0)) secticks = 0; if (key == (PSP_CTRL_SELECT | PSP_CTRL_START)) { return exit_confirm(); } else if (key == PSP_CTRL_SELECT) { bool lastbicubic = config.bicubic; img_needrp = true; if (scene_options(selidx)) { imgreading = false; reset_image_ptr(); return *selidx; } if (lastbicubic != config.bicubic) img_needrc = true; if (config.imginfobar) imgh = PSP_SCREEN_HEIGHT - DISP_FONTSIZE; else imgh = PSP_SCREEN_HEIGHT; } else if (key == PSP_CTRL_START) { scene_mp3bar(); img_needrp = true; } else if (key == config.imgkey[1] || key == config.imgkey2[1] || key == CTRL_FORWARD) { bool should_exit = false; if (config.imgpaging == conf_imgpaging_updown || config.imgpaging == conf_imgpaging_leftright) xrKernelDelayThread(200000); if (!image_paging(true, config.imgpaging)) goto next; next_image(selidx, &should_exit); if (should_exit) { return *selidx; } } else if (key == config.imgkey[0] || key == config.imgkey2[0] || key == CTRL_BACK) { if (config.imgpaging == conf_imgpaging_updown || config.imgpaging == conf_imgpaging_leftright) xrKernelDelayThread(200000); if (!image_paging(false, config.imgpaging)) goto next; prev_image(selidx); } else if (key == config.imgkey[2] || key == config.imgkey2[2]) { ctrl_waitrelease(); if (config.fit == conf_fit_custom) config.fit = conf_fit_none; else config.fit++; img_needrc = img_needrp = true; } else if (key == config.imgkey[10] || key == config.imgkey2[10]) { config.bicubic = !config.bicubic; img_needrc = img_needrp = true; } else if (key == config.imgkey[11] || key == config.imgkey2[11]) { if (!slideshow) { slideshow = true; lasttime = time(NULL); ctrl_waitrelease(); } else { slideshow = false; win_msg(_("幻灯片播放已经停止!"), COLOR_WHITE, COLOR_WHITE, config.msgbcolor); ctrl_waitrelease(); } } else if (key == config.imgkey[7] || key == config.imgkey2[7]) { SceCtrlData ctl; int t = 0; config.imginfobar = !config.imginfobar; if (config.imginfobar) imgh = PSP_SCREEN_HEIGHT - DISP_FONTSIZE; else imgh = PSP_SCREEN_HEIGHT; if (height_rotated > imgh && curtop > height_rotated - imgh) curtop = height_rotated - imgh; img_needrc = (config.fit == conf_fit_height); img_needrp = true; do { xrCtrlReadBufferPositive(&ctl, 1); xrKernelDelayThread(10000); t += 10000; } while (ctl.Buttons != 0 && t <= 500000); } else if (key == config.imgkey[9] || key == config.imgkey2[9] || key == CTRL_PLAYPAUSE) { if (slideshow) { slideshow = false; win_msg(_("幻灯片播放已经停止!"), COLOR_WHITE, COLOR_WHITE, config.msgbcolor); ctrl_waitrelease(); } else { imgreading = false; reset_image_ptr(); return *selidx; } } else if (key == config.imgkey[8] || key == config.imgkey2[8]) { if (!slideshow && !showinfo) { img_needrp = true; showinfo = true; } } else if (key == config.imgkey[5] || key == config.imgkey2[5]) { if (config.rotate == conf_rotate_0) config.rotate = conf_rotate_270; else config.rotate--; ctrl_waitreleasekey(key); img_needrc = img_needrp = true; } else if (key == config.imgkey[6] || key == config.imgkey2[6]) { if (config.rotate == conf_rotate_270) config.rotate = conf_rotate_0; else config.rotate++; ctrl_waitreleasekey(key); img_needrc = img_needrp = true; } else if (key == config.imgkey[3] || key == config.imgkey2[3]) { if (config.scale > 200) config.scale -= 50; else if (config.scale > 10) config.scale -= 5; else goto next; config.fit = conf_fit_custom; img_needrc = img_needrp = true; ctrl_waitreleasekey(key); } else if (key == config.imgkey[4] || key == config.imgkey2[4]) { if (config.scale < 200) config.scale += 5; else if (config.scale < 1000) config.scale += 50; else goto next; config.fit = conf_fit_custom; img_needrc = img_needrp = true; ctrl_waitreleasekey(key); } else if (key & (config.imgkey[12] | config.imgkey[13] | config. imgkey[14] | config.imgkey[15] | config.imgkey2[12] | config. imgkey2[13] | config.imgkey2[14] | config.imgkey2[15]) && !(key & ~(config.imgkey[12] | config.imgkey[13] | config. imgkey[14] | config.imgkey[15] | config. imgkey2[12] | config.imgkey2[13] | config. imgkey2[14] | config.imgkey2[15] ))) { slideshow_move = true; image_move(key); } else img_needrf = img_needrc = false; next: return -1; }