• R/O
  • SSH
  • HTTPS

gpsp-kai: Commit


Commit MetaInfo

Revision579 (tree)
Zeit2010-03-24 17:12:07
Autortakka

Log Message

(empty log message)

Ändern Zusammenfassung

Diff

--- trunk/iso_tool/menu.c (revision 578)
+++ trunk/iso_tool/menu.c (revision 579)
@@ -38,6 +38,14 @@
3838 return ret_code; \
3939 } \
4040
41+#define ERR_RET_2(err_data, err_num) \
42+if((err_data) < 0) \
43+{ \
44+ err_msg((err_num)); \
45+ ret = -1; \
46+ goto LABEL_ERR; \
47+} \
48+
4149 int nop(char *dir, char *file, file_type type, int opt_1, int opt_2);
4250
4351 /*---------------------------------------------------------------------------
@@ -462,11 +470,41 @@
462470
463471 int umd2iso(char *dir, char *file, file_type type, int opt_1, int opt_2)
464472 {
465- char umd_path[MAX_PATH];
466- char iso_path[MAX_PATH];
473+ char in_path[MAX_PATH];
474+ char out_path[MAX_PATH];
475+ char ren_path[MAX_PATH];
467476 char work[MAX_PATH];
468477 int ret;
478+ char *read_buf[3]; // 読込バッファ ポインタ
479+ char *write_buf[3]; // 書込バッファ ポインタ
469480
481+ SceUID fp_in = 0; // 読込ファイル ポインタ
482+ SceUID fp_out = 0; // 書込ファイル ポインタ
483+ SceInt64 res = -1; // 非同期ファイルIO用
484+
485+ int in_sec_num = 0; // 読込セクタ数
486+
487+ int max_read_size = 0; // 一回の読込サイズ
488+ int read_size[3]; // 読込んだサイズ
489+ int write_size = 0; // 一回の書込サイズ
490+ int now_sector = 0; // 処理したセクタ数
491+ int write_block_shift = 0; // 処理単位(シフト数)
492+ int read_block_shift = 0; // 処理単位(シフト数)
493+
494+ int num; // 汎用
495+
496+ char *text[15]; // テキスト表示用
497+ char msg[256]; // テキスト表示用
498+
499+ SceCtrlData data;
500+ u64 start_tick;
501+ u64 now_tick;
502+ u64 old_tick = 0;
503+ pspTime date1;
504+ pspTime date2;
505+ pspTime date3;
506+ int first_wait = 0;
507+
470508 ret = check_ms();
471509 if(ret < 0)
472510 return CANCEL;
@@ -481,18 +519,205 @@
481519 return CANCEL;
482520 }
483521
484- strcpy(umd_path, dir);
485- strcat(umd_path, file);
486- strcpy(iso_path, dir);
522+ strcpy(in_path, dir);
523+ strcat(in_path, file);
524+ strcpy(out_path, dir);
487525 ret = osk(work, global.umd_id, "ファイル名指定", 0);
488526 if(ret == PSP_UTILITY_OSK_RESULT_CHANGED)
489- strcat(iso_path, work);
527+ strcat(out_path, work);
490528 else
491- strcat(iso_path, global.umd_id);
492- strcat(iso_path, ".ISO");
529+ strcat(out_path, global.umd_id);
530+ strcat(out_path, ".ISO");
493531
494532 set_clock(333, 166);
495- file_trans(iso_path, umd_path, TRANS_UMD_ISO, 0, 0, opt_1, opt_2);
533+// file_trans(iso_path, umd_path, TRANS_UMD_ISO, 0, 0, opt_1, opt_2);
534+
535+ strcpy(ren_path, out_path);
536+ strcpy(&ren_path[strlen(out_path) - 3], "TMP");
537+
538+ msg_win("", 0, MSG_CLEAR, 0);
539+ sjis_to_utf8(work, strrchr(out_path, '/') + 1);
540+ sprintf(msg, "出力名:%s", work);
541+ msg_win(msg, 0, MSG_WAIT, 0);
542+
543+ if(check_file(out_path) < 0)
544+ {
545+ msg_win("開始しますか?", 0, MSG_WAIT, 0);
546+ ret = select_menu("開始", select_yes_no, 0, 28, 10);
547+ }
548+ else
549+ {
550+ msg_win("同名のファイルがあります", 0, MSG_WAIT, 0);
551+ msg_win("上書きしますか?", 0, MSG_WAIT, 0);
552+ ret = select_menu("上書き", select_no_yes, 0, 28, 10);
553+ }
554+
555+ if(ret != YES)
556+ return CANCEL;
557+
558+
559+ // buff 設定
560+ read_buf[0] = &WORK[O_BUFFER][0];
561+ read_buf[1] = &WORK[I_BUFFER][0];
562+ write_buf[0] = &WORK[O_BUFFER][0];
563+ write_buf[1] = &WORK[I_BUFFER][0];
564+
565+ // block設定
566+ max_read_size = 512;
567+ write_block_shift = 11; /* SECTOR_SIZE */
568+ read_block_shift = 0;
569+
570+ in_sec_num = get_umd_sector("umd:", TYPE_UMD);
571+
572+ // open設定
573+ fp_in = sceIoOpen("umd:", PSP_O_RDONLY, 0777);
574+ ERR_RET_2(fp_in, ERR_OPEN);
575+ fp_out = sceIoOpen(ren_path, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);
576+ ERR_RET_2(fp_out, ERR_OPEN);
577+
578+ // msg
579+ msg_win("", 0, MSG_CLEAR, 0);
580+ msg_win("UMD -> ISO 変換", 1, MSG_WAIT, 0);
581+
582+
583+ // loop前
584+ now_sector = 0;
585+ num = 0;
586+
587+ sceRtcGetCurrentTick(&start_tick);
588+
589+ // msg
590+ msg_win("", 0, MSG_WAIT, 0);
591+ sprintf(msg, "%d / %d セクタ完了", now_sector, in_sec_num);
592+ msg_win(msg, 0, MSG_LINE, 1);
593+
594+ {
595+ read_size[0] = sceIoRead(fp_in, read_buf[0], max_read_size);
596+ ERR_RET_2(read_size[0], ERR_READ);
597+ read_size[1] = sceIoRead(fp_in, read_buf[1], max_read_size);
598+ ERR_RET_2(read_size[1], ERR_READ);
599+ }
600+
601+ // loop
602+ while(read_size[num] > 0)
603+ {
604+ {
605+ now_sector += max_read_size >> read_block_shift;
606+ write_size = read_size[num] << write_block_shift;
607+ }
608+
609+ // BUF_1 遅延書込み終了
610+ msg_win("Wait WRITE", 0, MSG_LINE, 4);
611+ ret = sceIoWaitAsync(fp_out, &res);
612+ if(ret < 0)
613+ {
614+ if(first_wait == 1)
615+ {
616+ err_msg(ERR_WRITE);
617+ return CANCEL;
618+ }
619+ first_wait = 1;
620+ }
621+
622+ // BUF_1 遅延読込み開始
623+ if(type != TRANS_CSO_ISO)
624+ {
625+ msg_win("READ", 0, MSG_LINE, 4);
626+ ret = sceIoReadAsync(fp_in, read_buf[num], max_read_size);
627+ if(ret < 0)
628+ {
629+ err_msg(ERR_READ);
630+ return CANCEL;
631+ }
632+ }
633+
634+ // BUF_0 遅延書込み開始
635+ msg_win("WRITE", 0, MSG_LINE, 4);
636+ ret = sceIoWriteAsync(fp_out, write_buf[num], write_size);
637+ ERR_RET_2(ret, ERR_WRITE);
638+
639+ sprintf(msg, "%d / %d セクタ完了", now_sector, in_sec_num);
640+ msg_win(msg, 0, MSG_LINE, 1);
641+ sceRtcGetCurrentTick(&now_tick);
642+ now_tick -= start_tick;
643+ ret = (max_read_size << write_block_shift) / 1024 * 1000 / ((now_tick - old_tick) / 1000);
644+ old_tick = now_tick;
645+ sceRtcSetTick(&date1, &now_tick);
646+ now_tick = now_tick * in_sec_num / now_sector;
647+ sceRtcSetTick(&date2, &now_tick);
648+ now_tick -= old_tick;
649+ sceRtcSetTick(&date3, &now_tick);
650+ sprintf(msg, "経過 %02d:%02d:%02d / 予想 %02d:%02d:%02d / 残 %02d:%02d:%02d",
651+ date1.hour, date1.minutes, date1.seconds,
652+ date2.hour, date2.minutes, date2.seconds,
653+ date3.hour, date3.minutes, date3.seconds);
654+ msg_win(msg, 0, MSG_LINE, 2);
655+ sprintf(msg, "速度 %4dKB/s", ret);
656+ msg_win(msg, 0, MSG_LINE, 3);
657+
658+ get_button(&data);
659+ if((data.Buttons) == PSP_CTRL_CROSS)
660+ {
661+ msg_win("STOP !!", 0, MSG_LINE, 2);
662+ ret = select_menu("中止しますか?", select_no_yes, 0, 28, 10);
663+ if(ret == 1)
664+ {
665+ text[0] = "変換中止";
666+ text[1] = "◎を押してください";
667+ text[2] = "\0";
668+ dialog(text);
669+ ret = -1;
670+ goto LABEL_ERR;
671+ }
672+ dir_menu(NULL, YES);
673+ msg_win("", 0, MSG_REDROW, 0);
674+ }
675+
676+ // BUF_1 遅延読込み終了
677+ msg_win("Wait READ", 0, MSG_LINE, 4);
678+ {
679+ ret = sceIoWaitAsync(fp_in, &res);
680+ ERR_RET_2(ret, ERR_READ);
681+ msg_win("READ", 0, MSG_LINE, 4);
682+ }
683+ read_size[num] = res;
684+ num = (num + 1) % 2;
685+ }
686+
687+ // msg
688+ sprintf(msg, "%d / %d セクタ完了", in_sec_num, in_sec_num);
689+ msg_win(msg, 0, MSG_LINE, 1);
690+
691+ sceRtcGetCurrentTick(&now_tick);
692+ now_tick -= start_tick;
693+ sceRtcSetTick(&date3, &now_tick);
694+ ret = (in_sec_num * SECTOR_SIZE) / 1024 * 1000 / (now_tick / 1000);
695+ sprintf(msg, "変換時間 %02d:%02d:%02d / 平均速度 %04dKB/s", date3.hour, date3.minutes, date3.seconds, ret);
696+ msg_win(msg, 0, MSG_LINE, 0);
697+ sprintf(msg, "経過 %02d:%02d:%02d / 予想 %02d:%02d:%02d / 残 00:00:00",
698+ date1.hour, date1.minutes, date1.seconds,
699+ date2.hour, date2.minutes, date2.seconds);
700+ msg_win(msg, 0, MSG_LINE, 2);
701+
702+LABEL_ERR:
703+ // close
704+ sceIoWaitAsync(fp_in, &res);
705+ sceIoWaitAsync(fp_out, &res);
706+ sceIoClose(fp_in);
707+ sceIoClose(fp_out);
708+
709+ if(ret != -1)
710+ {
711+ sceIoRename(ren_path, out_path);
712+
713+ text[0] = "変換完了";
714+ text[1] = "◎を押してください";
715+ text[2] = "\0";
716+ dialog(text);
717+ }
718+ else
719+ sceIoRemove(ren_path);
720+
496721 set_clock(222, 111);
497722 return DONE;
498723 }
@@ -645,14 +870,6 @@
645870 return DONE;
646871 }
647872
648-#define ERR_RET_2(err_data, err_num) \
649-if((err_data) < 0) \
650-{ \
651- err_msg((err_num)); \
652- ret = -1; \
653- goto LABEL_ERR; \
654-} \
655-
656873 int file_trans(char* out_path, char *in_path, trans_type type, int level, int limit, int opt_1, int opt_2)
657874 {
658875 char *read_buf[2]; // 読込バッファ ポインタ
@@ -675,7 +892,7 @@
675892 int in_sec_num = 0; // 読込セクタ数
676893
677894 int max_read_size = 0; // 一回の読込サイズ
678- int read_size = 0; // 読込んだサイズ
895+ int read_size[2]; // 読込んだサイズ
679896 int write_size = 0; // 一回の書込サイズ
680897 int now_sector = 0; // 処理したセクタ数
681898 int write_block_shift = 0; // 処理単位(シフト数)
@@ -700,7 +917,7 @@
700917 int first_wait = 0;
701918
702919 strcpy(ren_path, out_path);
703- strcpy(&ren_path[strlen(out_path - 3)], "TMP");
920+ strcpy(&ren_path[strlen(out_path) - 3], "TMP");
704921
705922 msg_win("", 0, MSG_CLEAR, 0);
706923 sjis_to_utf8(work, strrchr(out_path, '/') + 1);
@@ -792,7 +1009,7 @@
7921009 write_buf[1] = &WORK[O_BUFFER + 6144][0];
7931010
7941011 // tag設定
795- tag = (int *)&WORK[O_BUFFER + 8192][0];
1012+ tag = (int *)&WORK[O_BUFFER + 8192][0]; // 最大4MB
7961013 out_cso_flag = 1;
7971014
7981015 // block設定
@@ -893,23 +1110,26 @@
8931110 msg_win(msg, 0, MSG_LINE, 1);
8941111
8951112 if(type == TRANS_CSO_ISO)
896- read_size = cso_read_fp(read_buf[0], fp_in, now_sector << read_block_shift, max_read_size);
1113+ read_size[0] = cso_read_fp(read_buf[0], fp_in, now_sector << read_block_shift, max_read_size);
8971114 else
8981115 {
899- read_size = sceIoRead(fp_in, read_buf[0], max_read_size);
900- ERR_RET_2(read_size, ERR_READ);
1116+ read_size[0] = sceIoRead(fp_in, read_buf[0], max_read_size);
1117+ ERR_RET_2(read_size[0], ERR_READ);
1118+ read_size[1] = sceIoRead(fp_in, read_buf[1], max_read_size);
1119+ ERR_RET_2(read_size[1], ERR_READ);
9011120 }
9021121
9031122 // loop
904- while(read_size > 0)
1123+ while(read_size[num] > 0)
9051124 {
9061125 if(out_cso_flag == 1)
9071126 {
1127+ // BUF_0 圧縮処理
9081128 msg_win("DEFLATE", 0, MSG_LINE, 4);
9091129 loop = 0;
9101130 write_size = 0;
9111131 write_ptr = 0;
912- while(read_size > 0)
1132+ while(read_size[num] > 0)
9131133 {
9141134 cso_sec_size = deflate_cso(cso_buf, sizeof(cso_buf), (read_buf[num] + (loop * SECTOR_SIZE)), SECTOR_SIZE, global.cso_level);
9151135 if(cso_sec_size < 0)
@@ -938,7 +1158,7 @@
9381158 memcpy(write_buf[num] + write_ptr, read_buf[num] + loop * SECTOR_SIZE, SECTOR_SIZE);
9391159 }
9401160 write_ptr += cso_sec_size;
941- read_size -= SECTOR_SIZE >> write_block_shift;
1161+ read_size[num] -= SECTOR_SIZE >> write_block_shift;
9421162 loop++;
9431163 now_sector++;
9441164 }
@@ -946,9 +1166,10 @@
9461166 else
9471167 {
9481168 now_sector += max_read_size >> read_block_shift;
949- write_size = read_size << write_block_shift;
1169+ write_size = read_size[num] << write_block_shift;
9501170 }
9511171
1172+ // BUF_1 遅延書込み終了
9521173 msg_win("Wait WRITE", 0, MSG_LINE, 4);
9531174 ret = sceIoWaitAsync(fp_out, &res);
9541175 if(ret < 0)
@@ -961,10 +1182,11 @@
9611182 first_wait = 1;
9621183 }
9631184
1185+ // BUF_1 遅延読込み開始
9641186 if(type != TRANS_CSO_ISO)
9651187 {
9661188 msg_win("READ", 0, MSG_LINE, 4);
967- ret = sceIoReadAsync(fp_in, read_buf[(num + 1) % 2], max_read_size);
1189+ ret = sceIoReadAsync(fp_in, read_buf[num], max_read_size);
9681190 if(ret < 0)
9691191 {
9701192 err_msg(ERR_READ);
@@ -972,11 +1194,11 @@
9721194 }
9731195 }
9741196
1197+ // BUF_0 遅延書込み開始
9751198 msg_win("WRITE", 0, MSG_LINE, 4);
9761199 ret = sceIoWriteAsync(fp_out, write_buf[num], write_size);
9771200 ERR_RET_2(ret, ERR_WRITE);
9781201
979- num = (num + 1) % 2;
9801202 sprintf(msg, "%d / %d セクタ完了", now_sector, in_sec_num);
9811203 msg_win(msg, 0, MSG_LINE, 1);
9821204 sceRtcGetCurrentTick(&now_tick);
@@ -1014,6 +1236,7 @@
10141236 msg_win("", 0, MSG_REDROW, 0);
10151237 }
10161238
1239+ // BUF_1 遅延読込み終了
10171240 msg_win("Wait READ", 0, MSG_LINE, 4);
10181241 if(type == TRANS_CSO_ISO)
10191242 res = cso_read_fp(read_buf[num], fp_in, now_sector << read_block_shift, max_read_size);
@@ -1023,7 +1246,8 @@
10231246 ERR_RET_2(ret, ERR_READ);
10241247 msg_win("READ", 0, MSG_LINE, 4);
10251248 }
1026- read_size = res;
1249+ read_size[num] = res;
1250+ num = (num + 1) % 2;
10271251 }
10281252
10291253 // msg
@@ -1294,5 +1518,6 @@
12941518 sceUmdWaitDriveStat(PSP_UMD_READY);
12951519 // ModuleMgrForKernel_1B91F6EC("disc0:/PSP_GAME/SYSDIR/EBOOT.BIN", 0, &option);
12961520 sctrlKernelLoadExecVSHDisc("disc0:/PSP_GAME/SYSDIR/EBOOT.BIN", NULL);
1521+// sctrlKernelLoadExecVSHWithApitype();
12971522 return DONE;
12981523 }
--- trunk/iso_tool/main.h (revision 578)
+++ trunk/iso_tool/main.h (revision 579)
@@ -13,9 +13,9 @@
1313 #define DECRYPT_DATA (0)
1414 #define CRYPT_DATA (512)
1515
16-// 10240 * 2KB(0x800) = 20MB
17-#define MAX_SECTOR_NUM (512 * 21)
18-// 20MB - 1MB = 19MB
16+// 512 * 2KB(0x800) * 20 = 21MB
17+#define MAX_SECTOR_NUM (512 * 20)
18+// 21MB - 1MB = 20MB
1919 #define EBOOT_MAX_SIZE (SECTOR_SIZE * (MAX_SECTOR_NUM - CRYPT_DATA))
2020
2121 #define O_BUFFER (0)
Show on old repository browser