| 36 | } |
| 37 | |
| 38 | static int update_thread(SceSize args_size, UpdateArguments *args) { |
| 39 | uint64_t previous_value = current_value; |
| 40 | SceUInt64 cur_micros = 0, delta_micros = 0, last_micros = 0; |
| 41 | double kbs = 0.0; |
| 42 | |
| 43 | while (current_value < args->max && isMessageDialogRunning()) { |
| 44 | // Show KB/s |
| 45 | if (args->show_kbs) { |
| 46 | cur_micros = sceKernelGetProcessTimeWide(); |
| 47 | if (cur_micros >= (last_micros + 1000 * 1000)) { |
| 48 | delta_micros = cur_micros - last_micros; |
| 49 | last_micros = cur_micros; |
| 50 | kbs = (double)(current_value - previous_value) / 1024.0; |
| 51 | previous_value = current_value; |
| 52 | |
| 53 | if (kbs > 0) { |
| 54 | char msg[32]; |
| 55 | sprintf(msg, "%.0f KB/s", kbs); |
| 56 | sceMsgDialogProgressBarSetInfo(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, (SceChar8 *)msg); |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | double progress = (double)((100.0 * (double)current_value) / (double)args->max); |
| 62 | sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, (uint32_t)progress); |
| 63 | |
| 64 | sceKernelDelayThread(COUNTUP_WAIT); |
| 65 | } |
| 66 | |
| 67 | return sceKernelExitDeleteThread(0); |
| 68 | } |
| 69 | |
| 70 | SceUID createStartUpdateThread(uint64_t max, int show_kbs) { |
| 71 | current_value = 0; |
nothing calls this directly
no test coverage detected