[
  {
    "path": "CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 2.8)\n\nif(NOT DEFINED CMAKE_TOOLCHAIN_FILE)\n  if(DEFINED ENV{VITASDK})\n    set(CMAKE_TOOLCHAIN_FILE \"$ENV{VITASDK}/share/vita.toolchain.cmake\" CACHE PATH \"toolchain file\")\n  else()\n    message(FATAL_ERROR \"Please define VITASDK to point to your SDK path!\")\n  endif()\nendif()\n\nproject(LOLIcon)\ninclude(\"$ENV{VITASDK}/share/vita.cmake\" REQUIRED)\n\nset(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS} -Wl,-q -Wall -O3 -std=gnu99\")\nset(CMAKE_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS} -nostdlib\")\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions\")\n\nlink_directories(\n\t${CMAKE_CURRENT_BINARY_DIR}\n)\n\nadd_executable(${PROJECT_NAME}\n\tLOLIcon.c\n\tblit.c\n\tfont.c\n\tutils.c\n)\n\ntarget_link_libraries(${PROJECT_NAME}\n        k\n\t\tSceAppMgrForDriver_stub\n        SceSysmemForDriver_stub\n\t\tSceProcessmgrForKernel_stub\n        SceThreadmgrForDriver_stub\n        SceIofilemgrForDriver_stub\n        SceCpuForDriver_stub\n        taihenForKernel_stub\n\t\tSceDebugForDriver_stub\n\t\tSceDisplayForDriver_stub\n\t\tSceModulemgrForKernel_stub\n\t\tSceCtrlForDriver_stub\n\t\tSceDebugForDriver_stub\n\t\tScePowerForDriver_stub\n\t\tSceSysrootForKernel_stub\n\t\tSceProcessmgrForDriver_stub\n\t\ttaihenModuleUtils_stub\n\t\tSceSysconForDriver_stub\n        gcc\n        -nostdlib\n)\nvita_create_self(${PROJECT_NAME}.skprx ${PROJECT_NAME}\n  UNSAFE\n  CONFIG ${CMAKE_SOURCE_DIR}/LOLIcon.yml\n)\n\n"
  },
  {
    "path": "LICENSE.md",
    "content": "MIT License\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "LOLIcon.c",
    "content": "// LOLIcon\n// by @dots_tb\n// Thanks to:\n// @CelesteBlue123 partner in crime, shh he doesn't know I added his namespace\n// Our testing team, especially: @Yoyogames28 castelo\n// @Cimmerian_Iter is also worth mentioning...\n\n// @frangar for original oclockvita\n// HENkaku wiki and its contributors (especially yifan lu for Pervasive RE)\n// Team Molecule (because everyone does)\n// Scorp for Button Swap\n// Please read the readme for more credits\n\n//MADE IN THE USA\n\n#include <taihen.h>\n#include <string.h>\n#include <sys/syslimits.h>\n#include <stdio.h>\n#include \"blit.h\"\n#include \"utils.h\"\n\n#define LEFT_LABEL_X CENTER(24)\n#define RIGHT_LABEL_X CENTER(0)\n#define printf ksceDebugPrintf\n\nstatic SceUID g_hooks[14];\n\nstatic const char *ERRORS[5]={ \n\t#define NO_ERROR 0\n\t\"No error.\", \n\t#define SAVE_ERROR 1\n\t\"There was a problem saving.\", \n\t#define SAVE_GOOD 2\n\t\"Configuration saved.\", \n\t#define LOAD_ERROR 3\n\t\"There was a problem loading.\", \n\t#define LOAD_GOOD 4\n\t\"Configuration loaded.\"\n};\n\nint error_code = NO_ERROR;\n\n#define CONFIG_PATH \"ur0:LOLIcon/\"\n\ntypedef struct titleid_config {\n\tint mode;\n\tint hideErrors;\n\tint showBat;\n\tint buttonSwap;\n\tint showFPS;\n} titleid_config;\n\nstatic char config_path[PATH_MAX];\nstatic titleid_config current_config;\n\nstatic char titleid[32];\nuint32_t current_pid = 0, shell_pid = 0;\n\nint showMenu = 0, pos = 0, isReseting = 0, forceReset = 0, isPspEmu = 0, isShell = 1;\nint page = 0;\nint willexit = 0;\nstatic uint64_t ctrl_timestamp, msg_time = 0;\n\nuint32_t *clock_speed;\nunsigned int *clock_r1;\nunsigned int *clock_r2;\t\n\n#define TIMER_SECOND         1000000 // 1 second\nint fps;\nlong curTime = 0, lateTime = 0, fps_count = 0;\n\nstatic int profile_default[] = {266, 166, 166, 111, 166};\nstatic int profile_game[] = {444, 222, 222, 166, 222};\nstatic int profile_max_performance[] = {444, 222, 222, 166, 333};\nstatic int profile_holy_shit_performance[] = {500, 222, 222, 166, 333};\nstatic int profile_max_battery[] = {111, 111, 111, 111, 111};\nstatic int* profiles[5] = {profile_default,profile_game,profile_max_performance, profile_holy_shit_performance, profile_max_battery};\n\n\nint (*_kscePowerGetGpuEs4ClockFrequency)(int*, int*);\nint (*_kscePowerSetGpuEs4ClockFrequency)(int, int);\nint (*_kscePowerGetGpuClockFrequency)(void);\nint (*_kscePowerSetGpuClockFrequency)(int);\nint (*_ksceKernelGetModuleInfo)(SceUID, SceUID, SceKernelModuleInfo *);\nint (*_ksceKernelGetModuleList)(SceUID pid, int flags1, int flags2, SceUID *modids, size_t *num);\nint (*_ksceKernelExitProcess)(int);\n\n#define ksceKernelExitProcess _ksceKernelExitProcess\n#define ksceKernelGetModuleInfo _ksceKernelGetModuleInfo\n#define ksceKernelGetModuleList _ksceKernelGetModuleList\n#define kscePowerGetGpuEs4ClockFrequency _kscePowerGetGpuEs4ClockFrequency\n#define kscePowerSetGpuEs4ClockFrequency _kscePowerSetGpuEs4ClockFrequency\n#define kscePowerGetGpuClockFrequency _kscePowerGetGpuClockFrequency\n#define kscePowerSetGpuClockFrequency _kscePowerSetGpuClockFrequency\n\nvoid reset_config() {\n\tmemset(&current_config, 0, sizeof(current_config));\n}\n\nint load_config() {\n\tsnprintf(config_path, sizeof(config_path), CONFIG_PATH\"%s/config.bin\", titleid);\n\tprintf(\"loaded %s\\n\", config_path);\n\tif(ReadFile(config_path, &current_config, sizeof(current_config))<0) {\n\t\tsnprintf(config_path, sizeof(config_path), CONFIG_PATH\"default.bin\");\n\t\tif(ReadFile(config_path, &current_config, sizeof(current_config))<0) {\n\t\t\treset_config();\n\t\t\treturn -1;\n\t\t}\n\t}\n\treturn 0;\n}\n\nint save_config() {\n\tsnprintf(config_path, sizeof(config_path), CONFIG_PATH\"%s\", titleid);\n\tksceIoMkdir(config_path, 6);\n\tsnprintf(config_path, sizeof(config_path), CONFIG_PATH\"%s/config.bin\", titleid);\n\tif(WriteFile(config_path, &current_config, sizeof(current_config))<0)\n\t\treturn -1;\n\treturn 0;\t\n}\n\nint save_default_config() {\n\tsnprintf(config_path, sizeof(config_path), CONFIG_PATH\"default.bin\");\n\tif(WriteFile(config_path, &current_config, sizeof(current_config))<0)\n\t\treturn -1;\n\treturn 0;\t\n}\n\nvoid refreshClocks() {\n\tisReseting = 1;\n\tkscePowerSetArmClockFrequency(profiles[current_config.mode][0]);\n\tkscePowerSetBusClockFrequency(profiles[current_config.mode][1]);\n\tkscePowerSetGpuEs4ClockFrequency(profiles[current_config.mode][2], profiles[current_config.mode][2]);\n\tkscePowerSetGpuXbarClockFrequency(profiles[current_config.mode][3]);\n\tkscePowerSetGpuClockFrequency(profiles[current_config.mode][4]);\n\tisReseting = 0;\n}\n\nvoid load_and_refresh() {\n\terror_code = LOAD_GOOD;\n\tif(load_config()<0) \n\t\terror_code = LOAD_ERROR;\t\t\t\n\trefreshClocks();\n\tprintf(\"forcing reset\\n\");\n}\n\n\n// This function is from VitaJelly by DrakonPL and Rinne's framecounter\nvoid doFps() {\n\tfps_count++;\n\tif ((curTime - lateTime) > TIMER_SECOND) {\n\t\tlateTime = curTime;\n\t\tfps = (int)fps_count;\n\t\tfps_count = 0;\n\t}\n\tblit_stringf(20, 15, \"%d\",  fps);\n}\n\nvoid drawErrors() {\n\tif(error_code > 0) {\n\t\tif(!curTime || (msg_time == 0 && !showMenu))\n\t\t\tmsg_time = (curTime = ksceKernelGetProcessTimeWideCore()) + TIMER_SECOND * 2;\n\t\tif((!current_config.hideErrors && curTime < msg_time) || showMenu)\n\t\t\tblit_stringf(20, 0, \"%s : %d\",  ERRORS[error_code], error_code);\n\t}\n}\n\nint kscePowerSetClockFrequency_patched(tai_hook_ref_t ref_hook, int port, int freq){\n\tint ret = 0;\n\tif(!isReseting)\n\t\tprofile_default[port] = freq;\n\tif(port==0) {\n\t\tif(freq == 500) {\n\t\t\tret = TAI_CONTINUE(int, ref_hook, 444);\n\t\t\tksceKernelDelayThread(10000);\n\t\t\t*clock_speed = profiles[current_config.mode][port];\n\t\t\t*clock_r1 = 0xF;\n\t\t\t*clock_r2 = 0x0;\n\t\t\treturn ret;\n\t\t}\n\t} \n\tif(port==2) {\n\t\tret = TAI_CONTINUE(int, ref_hook, profiles[current_config.mode][port], profiles[current_config.mode][port]);\n\t} else\n\t\tret = TAI_CONTINUE(int, ref_hook, profiles[current_config.mode][port]);\n\treturn ret;\n}\n\nstatic tai_hook_ref_t power_hook1;\nstatic int power_patched1(int freq) {\n\treturn kscePowerSetClockFrequency_patched(power_hook1,0,freq);\n}\n\nstatic tai_hook_ref_t power_hook2;\nstatic int power_patched2(int freq) {\n\treturn kscePowerSetClockFrequency_patched(power_hook2,1,freq);\n}\n\nstatic tai_hook_ref_t power_hook3;\nstatic int power_patched3(int freq) {\n\treturn kscePowerSetClockFrequency_patched(power_hook3,2,freq);\n}\n\nstatic tai_hook_ref_t power_hook4;\nstatic int power_patched4(int freq) {\n\treturn kscePowerSetClockFrequency_patched(power_hook4,3,freq);\n}\n\nint checkButtons(int port, tai_hook_ref_t ref_hook, SceCtrlData *ctrl, int count) {\n\tint ret = 0, state;\n\tif (ref_hook == 0)\n\t\tret = 1;\n\telse {\n\t\tret = TAI_CONTINUE(int, ref_hook, port, ctrl, count);\n\t\tif(!showMenu){\n\t\t\tif (!isPspEmu && (ctrl->buttons & SCE_CTRL_UP)&&(ctrl->buttons & SCE_CTRL_SELECT))\n\t\t\t\tctrl_timestamp = showMenu = 1;\n\t\t\tif (current_config.buttonSwap && \n\t\t\t\t((isShell && shell_pid == ksceKernelGetProcessId())||(!isShell && current_pid == ksceKernelGetProcessId())) && \n\t\t\t\t(ctrl->buttons & 0x6000) && ((ctrl->buttons & 0x6000) != 0x6000))\n\t\t\t\t\tctrl->buttons = ctrl->buttons ^ 0x6000;\n\t\t} else {\n\t\t\tunsigned int buttons = ctrl->buttons;\n\t\t\tctrl->buttons = 0;\n\t\t\tif(ctrl->timeStamp > ctrl_timestamp + 300*1000) {\n\t\t\t\tif( ksceKernelGetProcessId() == shell_pid) {\n\t\t\t\t\tif (buttons & SCE_CTRL_LEFT){\n\t\t\t\t\t\tswitch(page) {\n\t\t\t\t\t\t\tcase 1:\n\t\t\t\t\t\t\t\tif(current_config.mode > 0) {\n\t\t\t\t\t\t\t\t\tctrl_timestamp = ctrl->timeStamp;\n\t\t\t\t\t\t\t\t\tcurrent_config.mode--;\n\t\t\t\t\t\t\t\t\trefreshClocks();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if ((buttons & SCE_CTRL_RIGHT)){\n\t\t\t\t\t\tswitch(page) {\n\t\t\t\t\t\t\tcase 1:\n\t\t\t\t\t\t\t\tif(current_config.mode <4) {\n\t\t\t\t\t\t\t\t\tctrl_timestamp = ctrl->timeStamp;\n\t\t\t\t\t\t\t\t\tcurrent_config.mode++;\n\t\t\t\t\t\t\t\t\trefreshClocks();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if((buttons & SCE_CTRL_UP) && pos > 0) {\n\t\t\t\t\t\tctrl_timestamp = ctrl->timeStamp;\n\t\t\t\t\t\tpos--;\n\t\t\t\t\t} else if (buttons & SCE_CTRL_CIRCLE)\n\t\t\t\t\t\tpage = pos = 0;\n\t\t\t\t\t else if (buttons & SCE_CTRL_CROSS) {\n\t\t\t\t\t\t switch(page) {\n\t\t\t\t\t\t\tcase 0:\n\t\t\t\t\t\t\t\tswitch(pos) {\n\t\t\t\t\t\t\t\t\tcase 0:\n\t\t\t\t\t\t\t\t\t\terror_code = SAVE_GOOD;\n\t\t\t\t\t\t\t\t\t\tif(save_config() < 0)\n\t\t\t\t\t\t\t\t\t\t\terror_code = SAVE_ERROR;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase 1: {\n\t\t\t\t\t\t\t\t\t\terror_code = SAVE_GOOD;\n\t\t\t\t\t\t\t\t\t\tif(save_default_config() < 0)\n\t\t\t\t\t\t\t\t\t\t\terror_code = SAVE_ERROR;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase 2:\n\t\t\t\t\t\t\t\t\t\treset_config();\n\t\t\t\t\t\t\t\t\t\trefreshClocks();\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase 3:\n\t\t\t\t\t\t\t\t\t\tpage = 1;\n\t\t\t\t\t\t\t\t\t\tpos = 0;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase 4:\n\t\t\t\t\t\t\t\t\t\tpage = 2;\n\t\t\t\t\t\t\t\t\t\tpos = 0;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase 5:\n\t\t\t\t\t\t\t\t\t\tpage = 3;\n\t\t\t\t\t\t\t\t\t\tpos = 0;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase 6:\n\t\t\t\t\t\t\t\t\t\twillexit = current_pid;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase 7:\n\t\t\t\t\t\t\t\t\t\tkscePowerRequestSuspend();\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase 8:\n\t\t\t\t\t\t\t\t\t\tkscePowerRequestColdReset();\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase 9:\n\t\t\t\t\t\t\t\t\t\tkscePowerRequestStandby();\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 2:\n\t\t\t\t\t\t\t\tswitch(pos) {\n\t\t\t\t\t\t\t\t\tcase 0:\n\t\t\t\t\t\t\t\t\t\tcurrent_config.showFPS = !current_config.showFPS;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase 1:\n\t\t\t\t\t\t\t\t\t\tcurrent_config.showBat = !current_config.showBat;\n\t\t\t\t\t\t\t\t\t\tbreak;\t\t\n\t\t\t\t\t\t\t\t\tcase 2:\n\t\t\t\t\t\t\t\t\t\tcurrent_config.hideErrors = !current_config.hideErrors;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 3:\n\t\t\t\t\t\t\t\tswitch(pos) {\n\t\t\t\t\t\t\t\t\tcase 0:\n\t\t\t\t\t\t\t\t\t\tcurrent_config.buttonSwap = !current_config.buttonSwap;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t }\n\t\t\t\t\t\t ctrl_timestamp = ctrl->timeStamp;\n\t\t\t\t\t }  else if (buttons & SCE_CTRL_DOWN) {\n\t\t\t\t\t\tpos++;\n\t\t\t\t\t\tctrl_timestamp = ctrl->timeStamp;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif((buttons & SCE_CTRL_SELECT)&&(buttons & SCE_CTRL_DOWN))\n\t\t\t\t\terror_code = showMenu = 0;\n\t\t\t}\n\t\t}\n\t\tif(KERNEL_PID!=ksceKernelGetProcessId()&& shell_pid!=ksceKernelGetProcessId()) {\n\t\t\tif(forceReset == 1) {\n\t\t\t\tif(current_pid==ksceKernelGetProcessId()) {\n\t\t\t\t\tif(ksceKernelGetProcessTitleId(current_pid, titleid, sizeof(titleid))==0 && titleid[0] != 0) \n\t\t\t\t\t\tforceReset = 2;\n\t\t\t\t} else \n\t\t\t\t\tcurrent_pid=ksceKernelGetProcessId();\n\t\t\t}\n\t\t\tif(willexit == current_pid && current_pid == ksceKernelGetProcessId()) \n\t\t\t\tksceKernelExitProcess(0);\n\t\t\telse\n\t\t\t\twillexit = 0;\n\t\t} else if(forceReset == 2) {\n\t\t\tisShell = 0;\n\t\t\tload_and_refresh();\n\t\t\tmsg_time = curTime = fps_count = lateTime = forceReset = 0;\n\t\t}\n\t}\n\treturn ret;\n}\n\nstatic tai_hook_ref_t ref_hook1;\nstatic int keys_patched1(int port, SceCtrlData *ctrl, int count) {\n\tint ret, state;\n\tif(isPspEmu) {\n\t\tENTER_SYSCALL(state);\n\t\tret = TAI_CONTINUE(int, ref_hook1, port, ctrl, count);\n\t\tEXIT_SYSCALL(state);\n\t} else \n\t\tret = checkButtons(port, ref_hook1, ctrl, count);\n\treturn ret;\n}   \n\nstatic tai_hook_ref_t ref_hook2;\nstatic int keys_patched2(int port, SceCtrlData *ctrl, int count) {\n\treturn checkButtons(port, ref_hook2, ctrl, count);\n}   \n\nstatic tai_hook_ref_t ref_hook3;\nstatic int keys_patched3(int port, SceCtrlData *ctrl, int count) {\n\treturn checkButtons(port, ref_hook3, ctrl, count);\n}  \n\nstatic tai_hook_ref_t ref_hook4;\nstatic int keys_patched4(int port, SceCtrlData *ctrl, int count) {\n\treturn checkButtons(port, ref_hook4, ctrl, count);\n}    \n\nstatic tai_hook_ref_t ref_hook5;\nstatic int keys_patched5(int port, SceCtrlData *ctrl, int count) {\n\treturn checkButtons(port, ref_hook5, ctrl, count);\n}    \n\nstatic tai_hook_ref_t ref_hook6;\nstatic int keys_patched6(int port, SceCtrlData *ctrl, int count) {\n\treturn checkButtons(port, ref_hook6, ctrl, count);\n}    \n\nstatic tai_hook_ref_t ref_hook7;\nstatic int keys_patched7(int port, SceCtrlData *ctrl, int count) {\n\treturn checkButtons(port, ref_hook7, ctrl, count);\n}    \n\nstatic tai_hook_ref_t ref_hook8;\nstatic int keys_patched8(int port, SceCtrlData *ctrl, int count) {\n\treturn checkButtons(port, ref_hook8, ctrl, count);\n}    \n\nvoid drawMenu() {\n\tint entries = 0;\n\t#define MENU_OPTION_F(TEXT,...)\\\n\t\tblit_set_color(0x00FFFFFF, (pos != entries) ? 0x00FF0000 : 0x0000FF00);\\\n\t\tblit_stringf(LEFT_LABEL_X, 120+16*entries++, (TEXT), __VA_ARGS__);\t\n\t#define MENU_OPTION(TEXT,...)\\\n\t\tblit_set_color(0x00FFFFFF, (pos != entries) ? 0x00FF0000 : 0x0000FF00);\\\n\t\tblit_stringf(LEFT_LABEL_X, 120+16*entries++, (TEXT));\t\n\tblit_set_color(0x00FFFFFF, 0x00FF0000);\n\tswitch(page) {\n\t\tcase 0:\n\t\t\tblit_stringf(LEFT_LABEL_X, 88, \"LOLIcon by @dots_tb\");\n\t\t\tMENU_OPTION_F(\"Save for %s\", titleid);\n\t\t\tMENU_OPTION(\"Save as Default\");\n\t\t\tMENU_OPTION(\"Clear settings\");\n\t\t\tMENU_OPTION(\"Oclock Options\");\n\t\t\tMENU_OPTION(\"OSD Options\");\n\t\t\tMENU_OPTION(\"Ctrl Options\");\n\t\t\tMENU_OPTION(\"Exit Game\");\n\t\t\tMENU_OPTION(\"Suspend vita\");\n\t\t\tMENU_OPTION(\"Restart vita\");\n\t\t\tMENU_OPTION(\"Shutdown vita\");\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tblit_stringf(LEFT_LABEL_X, 88, \"ACTUAL OVERCLOCK\");\t\t\n\t\t\tblit_stringf(LEFT_LABEL_X, 120, \"PROFILE    \");\n\t\t\tswitch(current_config.mode) {\n\t\t\t\tcase 4: \n\t\t\t\t\tblit_stringf(RIGHT_LABEL_X, 120, \"Max Batt.\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase 3: \n\t\t\t\t\tblit_stringf(RIGHT_LABEL_X, 120, \"Holy Shit.\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2: \n\t\t\t\t\tblit_stringf(RIGHT_LABEL_X, 120, \"Max Perf.\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase 1:\n\t\t\t\t\tblit_stringf(RIGHT_LABEL_X, 120, \"Game Def.\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase 0:\n\t\t\t\t\tblit_stringf(RIGHT_LABEL_X, 120, \"Default  \");\n\t\t\t\t\tbreak;\n\t\t\t\t}\t\n\t\t\tblit_stringf(LEFT_LABEL_X, 136, \"CPU CLOCK  \");\n\t\t\tblit_stringf(RIGHT_LABEL_X, 136, \"%-4d  MHz - %d:%d\", kscePowerGetArmClockFrequency(), *clock_r1, *clock_r2);\n\t\t\tblit_stringf(LEFT_LABEL_X, 152, \"BUS CLOCK  \");\n\t\t\tblit_stringf(RIGHT_LABEL_X, 152, \"%-4d  MHz\", kscePowerGetBusClockFrequency());\n\t\t\tblit_stringf(LEFT_LABEL_X, 168, \"GPUes4CLK  \");\n\t\t\t\n\t\t\tint r1, r2;\n\t\t\tkscePowerGetGpuEs4ClockFrequency(&r1, &r2);\n\t\t\tblit_stringf(RIGHT_LABEL_X, 168, \"%-d   MHz\", r1);\n\t\t\tblit_stringf(LEFT_LABEL_X, 184, \"XBAR  CLK  \");\n\t\t\tblit_stringf(RIGHT_LABEL_X, 184, \"%-4d  MHz\", kscePowerGetGpuXbarClockFrequency());\n\t\t\tblit_stringf(LEFT_LABEL_X, 200, \"GPU CLOCK  \");\n\t\t\tblit_stringf(RIGHT_LABEL_X, 200, \"%-4d  MHz\", kscePowerGetGpuClockFrequency());\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tblit_stringf(LEFT_LABEL_X, 88, \"OSD\");\t\n\t\t\tMENU_OPTION_F(\"Show FPS %d\",current_config.showFPS);\n\t\t\tMENU_OPTION_F(\"Show Battery %d\",current_config.showBat);\n\t\t\tMENU_OPTION_F(\"Hide Errors %d\",current_config.hideErrors);\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tblit_stringf(LEFT_LABEL_X, 88, \"CONTROL\");\t\n\t\t\tMENU_OPTION_F(\"BUTTON SWAP %d\",current_config.buttonSwap);\n\t\t\tbreak;\t\t\t\n\t}\n\tif(pos >= entries)\n\t\tpos = entries -1;\t\n}\n\nstatic tai_hook_ref_t ref_hook0;\nint _sceDisplaySetFrameBufInternalForDriver(int fb_id1, int fb_id2, const SceDisplayFrameBuf *pParam, int sync){\n\tif(!isPspEmu && fb_id1 && pParam) {\n\t\tif(!shell_pid && fb_id2) {//3.68 fix\n\t\t\tif(ksceKernelGetProcessTitleId(ksceKernelGetProcessId(), titleid, sizeof(titleid))==0 && titleid[0] != 0) {\n\t\t\t\tif(strncmp(\"main\",titleid, sizeof(titleid))==0) {\n\t\t\t\t\tshell_pid = ksceKernelGetProcessId();\n\t\t\t\t\tload_and_refresh();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSceDisplayFrameBuf kfb;\n\t\tmemset(&kfb,0,sizeof(kfb));\n\t\tmemcpy(&kfb, pParam, sizeof(SceDisplayFrameBuf));\n\t\tblit_set_frame_buf(&kfb);\n\t\tif(showMenu) drawMenu();\n\t\t\n\t\tblit_set_color(0x0000FF00, 0xff000000);\n\t\tif((isShell && shell_pid == ksceKernelGetProcessId())||(!isShell && current_pid == ksceKernelGetProcessId())) {\n\t\t\tdrawErrors();\n\t\t\tcurTime = ksceKernelGetProcessTimeWideCore();\n\t\t\tif(current_config.showFPS) doFps();\n\t\t\tif(current_config.showBat) blit_stringf(20, 30, \"%02d\\%\", kscePowerGetBatteryLifePercent());\n\t\t}\n\t\t\n\t}\n\treturn TAI_CONTINUE(int, ref_hook0, fb_id1, fb_id2, pParam, sync);\n}\n\nint getFindModNameFromPID(int pid, char *mod_name, int size) {\n\tSceKernelModuleInfo sceinfo;\n\tsceinfo.size = sizeof(sceinfo);\n\tint ret;\n\tsize_t count;\n\tSceUID modids[128];\t\t\n\tif((ret = ksceKernelGetModuleList(pid, 0xff, 1, modids, &count)) == 0) {\n\t\tfor(int i = 0; i < count; i++) {\n\t\t\tif((ret = ksceKernelGetModuleInfo(pid, modids[count - 1], &sceinfo))==0) {\n\t\t\t\tif(strncmp(mod_name, sceinfo.module_name, size)==0)\n\t\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\t\treturn 0;\n\t}\n\treturn ret;\n}\n\nstatic tai_hook_ref_t process_hook0;\nint SceProcEventForDriver_414CC813(int pid, int id, int r3, int r4, int r5, int r6){\n\tSceKernelProcessInfo info;\n\tinfo.size = 0xE8;\n\tchar module_name[28];\n\tif(strncmp(\"main\",titleid, sizeof(titleid))==0) {\n\t\tswitch(id) {\n\t\t\tcase 0x1://startup\n\t\t\t\tif(!shell_pid && ksceKernelGetProcessInfo(pid, &info) ==0 ) {\n\t\t\t\t\tif(info.ppid == KERNEL_PID) {\n\t\t\t\t\t\tshell_pid = pid;\n\t\t\t\t\t\tstrncpy(titleid, \"main\", sizeof(\"main\"));\n\t\t\t\t\t\tload_and_refresh();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase 0x5:\n\t\t\t\tisPspEmu = getFindModNameFromPID(pid, \"adrenaline\", sizeof(\"adrenaline\"))||getFindModNameFromPID(pid, \"ScePspemu\", sizeof(\"ScePspemu\"));\n\t\t\t\tcurrent_pid = pid;\n\t\t\t\tif(!isPspEmu) \n\t\t\t\t\tforceReset = 1;\n\t\t\t\t else {\n\t\t\t\t\tksceKernelGetProcessTitleId(pid, titleid, sizeof(titleid));\n\t\t\t\t\tshowMenu = isShell = current_config.mode = 0;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t} else {\n\t\tif((id==0x4 || id == 0x3)&& (current_pid==pid||isPspEmu)) {\n\t\t\tmsg_time = curTime = fps_count = lateTime = 0;\n\t\t\tisShell = 1;\n\t\t\tstrncpy(titleid, \"main\", sizeof(\"main\"));\n\t\t\tisPspEmu =0;\n\t\t\tload_and_refresh();\n\t\t}\n\t}\n\treturn TAI_CONTINUE(int, process_hook0, pid, id, r3, r4, r5, r6);\n}\n\nvoid _start() __attribute__ ((weak, alias (\"module_start\")));\nint module_start(SceSize argc, const void *args) {\n\tksceIoMkdir(CONFIG_PATH,6);\n\tmodule_get_export_func(KERNEL_PID, \"ScePower\", 0x1590166F, 0x475BCC82, &_kscePowerGetGpuEs4ClockFrequency);\n\tmodule_get_export_func(KERNEL_PID, \"ScePower\", 0x1590166F, 0x264C24FC, &_kscePowerSetGpuEs4ClockFrequency);\n\tmodule_get_export_func(KERNEL_PID, \"ScePower\", 0x1590166F, 0x64641E6A, &_kscePowerGetGpuClockFrequency);\n\tmodule_get_export_func(KERNEL_PID, \"ScePower\", 0x1590166F, 0x621BD8FD , &_kscePowerSetGpuClockFrequency);\n\n\ttai_module_info_t tai_info;\n\t\n\ttai_info.size = sizeof(tai_module_info_t);\n\n\tclock_r1 = (unsigned int *)pa2va(0xE3103000);\n\tclock_r2 = (unsigned int *)pa2va(0xE3103004);\t\n\t\n\ttaiGetModuleInfoForKernel(KERNEL_PID, \"ScePower\", &tai_info);\n\tmodule_get_offset(KERNEL_PID, tai_info.modid, 1,  0x4124 + 0xA4, (uintptr_t)&clock_speed);\t\n\t\n\tmemset(&titleid, 0, sizeof(titleid));\n\tstrncpy(titleid, \"main\", sizeof(titleid));\n\treset_config();\n\t\n\tcurrent_config.mode = 3;\n\t\n\trefreshClocks();\n\t\n\tif(module_get_export_func(KERNEL_PID, \"SceKernelModulemgr\", 0xC445FA63, 0xD269F915 , &_ksceKernelGetModuleInfo))\n\t\tmodule_get_export_func(KERNEL_PID, \"SceKernelModulemgr\", 0x92C9FFC2, 0xDAA90093 , &_ksceKernelGetModuleInfo);\n\tif(module_get_export_func(KERNEL_PID, \"SceKernelModulemgr\", 0xC445FA63, 0x97CF7B4E , &_ksceKernelGetModuleList))\n\t\tmodule_get_export_func(KERNEL_PID, \"SceKernelModulemgr\", 0x92C9FFC2, 0xB72C75A4 , &_ksceKernelGetModuleList);\n\tif(module_get_export_func(KERNEL_PID, \"SceProcessmgr\", 0x7A69DE86, 0x4CA7DC42 , &_ksceKernelExitProcess))\n\t\tmodule_get_export_func(KERNEL_PID, \"SceProcessmgr\", 0xEB1F8EF7, 0x905621F9 , &_ksceKernelExitProcess);\n\n\t\n\tg_hooks[0] = taiHookFunctionExportForKernel(KERNEL_PID, &ref_hook0, \"SceDisplay\",0x9FED47AC,0x16466675, _sceDisplaySetFrameBufInternalForDriver); \n\t\n\t\n\tg_hooks[10] = taiHookFunctionExportForKernel(KERNEL_PID, &power_hook1, \"ScePower\", 0x1590166F, 0x74DB5AE5,power_patched1); // scePowerSetArmClockFrequency\n\tg_hooks[11] = taiHookFunctionExportForKernel(KERNEL_PID,\t&power_hook2, \"ScePower\", 0x1590166F, 0xB8D7B3FB, power_patched2); // scePowerSetBusClockFrequency\n\tg_hooks[12] = taiHookFunctionExportForKernel(KERNEL_PID, &power_hook3, \"ScePower\", 0x1590166F, 0x264C24FC, power_patched3); // scePowerSetGpuClockFrequency\n\tg_hooks[13] = taiHookFunctionExportForKernel(KERNEL_PID, &power_hook4, \"ScePower\", 0x1590166F, 0xA7739DBE, power_patched4); // scePowerSetGpuXbarClockFrequency\n\t\n\ttaiGetModuleInfoForKernel(KERNEL_PID, \"SceCtrl\", &tai_info);\n\tg_hooks[1] = taiHookFunctionExportForKernel(KERNEL_PID, &ref_hook1, \"SceCtrl\", TAI_ANY_LIBRARY, 0xEA1D3A34, keys_patched1); // sceCtrlPeekBufferPositive\n\tg_hooks[2] =  taiHookFunctionOffsetForKernel(KERNEL_PID, &ref_hook2, tai_info.modid, 0, 0x3EF8, 1, keys_patched2); // sceCtrlPeekBufferPositive2\n\tg_hooks[3] = taiHookFunctionExportForKernel(KERNEL_PID, &ref_hook3, \"SceCtrl\", TAI_ANY_LIBRARY, 0x9B96A1AA, keys_patched3); // sceCtrlReadBufferPositive\n\tg_hooks[4] =  taiHookFunctionOffsetForKernel(KERNEL_PID, &ref_hook4, tai_info.modid, 0, 0x4E14, 1, keys_patched4); // sceCtrlReadBufferPositiveExt2\n\tg_hooks[5] =  taiHookFunctionOffsetForKernel(KERNEL_PID, &ref_hook5, tai_info.modid, 0, 0x4B48, 1, keys_patched5); // sceCtrlPeekBufferPositiveExt2\n\tg_hooks[6] =  taiHookFunctionOffsetForKernel(KERNEL_PID, &ref_hook6, tai_info.modid, 0, 0x3928, 1, keys_patched6); // sceCtrlPeekBufferPositiveExt\n    g_hooks[7] =  taiHookFunctionOffsetForKernel(KERNEL_PID, &ref_hook7, tai_info.modid, 0, 0x449C, 1, keys_patched7); // sceCtrlReadBufferPositive2\n    g_hooks[8] =  taiHookFunctionOffsetForKernel(KERNEL_PID, &ref_hook8, tai_info.modid, 0, 0x3BCC, 1, keys_patched8); // sceCtrlReadBufferPositiveExt\n\t\t  \n\tg_hooks[9] = taiHookFunctionImportForKernel(KERNEL_PID, &process_hook0, \"SceProcessmgr\", TAI_ANY_LIBRARY, 0x414CC813, SceProcEventForDriver_414CC813); \n\t\t\n\t\n\treturn SCE_KERNEL_START_SUCCESS;\n}\n\nint module_stop(SceSize argc, const void *args) {\n\t// free hooks that didn't fail\n\tif (g_hooks[0] >= 0) taiHookReleaseForKernel(g_hooks[0], ref_hook0);\n\tif (g_hooks[1] >= 0) taiHookReleaseForKernel(g_hooks[1], ref_hook1);\n\tif (g_hooks[2] >= 0) taiHookReleaseForKernel(g_hooks[2], ref_hook2);\n\tif (g_hooks[3] >= 0) taiHookReleaseForKernel(g_hooks[3], ref_hook3);\n\tif (g_hooks[4] >= 0) taiHookReleaseForKernel(g_hooks[4], ref_hook4);\n\tif (g_hooks[5] >= 0) taiHookReleaseForKernel(g_hooks[5], ref_hook5);\n\tif (g_hooks[6] >= 0) taiHookReleaseForKernel(g_hooks[6], ref_hook6);\n\tif (g_hooks[7] >= 0) taiHookReleaseForKernel(g_hooks[7], ref_hook7);\n\tif (g_hooks[8] >= 0) taiHookReleaseForKernel(g_hooks[8], ref_hook8);\n\tif (g_hooks[9] >= 0) taiHookReleaseForKernel(g_hooks[9], process_hook0);\n\tif (g_hooks[10] >= 0) taiHookReleaseForKernel(g_hooks[10], power_hook1);\n\tif (g_hooks[11] >= 0) taiHookReleaseForKernel(g_hooks[11], power_hook2);\n\tif (g_hooks[12] >= 0) taiHookReleaseForKernel(g_hooks[12], power_hook3);\n\tif (g_hooks[13] >= 0) taiHookReleaseForKernel(g_hooks[13], power_hook4);\n\n\treturn SCE_KERNEL_STOP_SUCCESS;\n}\n"
  },
  {
    "path": "LOLIcon.yml",
    "content": "LOLIcon:\n  attributes: 0\n  version:\n    major: 1\n    minor: 2\n  main:\n    start: module_start\n    stop: module_stop\n"
  },
  {
    "path": "README.md",
    "content": "# LOLIcon \n## (LOLIconsole Offends Little Idiots Console)\n\nby @dots_tb\n\nA  small onscreen console that runs from the kernel level. So it probably won't crash games as many certain user plugins do. It also removes dependency of kuio.\n\n(Also some advice FOR DEVS, use ioPlus which allows you to use normal sceIo functions in user plugins <https://github.com/CelesteBlue-dev/PSVita-RE-tools/tree/master/ioPlus/ioPlus-0.1>).\n\nOh yeah, and it adds 500mhz (aka real overclocking). Enjoy...The kernel level allows for more options in regards to overclocking. \n\n ### (The menu may lag, but it will go fullspeed when you exit). \n\n### WARNING: THIS IS OBVIOUSLY EXPERIMENTAL AND CARRIES THE DANGERS OF OVERCLOCKING (FOR REAL OVERCLOCKING). Please proceed with caution.\n\n### Further note: Yifan Lu has labeled this mode as 494mhz, but seeing how the rest of the pervasive values correspond to a value slightly off, Celeste and I have decided to label it 500mhz instead.\n\n### PS: Userland apps will report false speeds, this is LIBEL and FAKE NEWS. We have provided an indicator for the direct registers that control the ARM clock speeds on the overclock page to compare to the wikipage located below.\n\nOther features: Quickly exit game, maintains configuration for each process(including shell)*, FPS counter, x and o button swap, allows for proper default game clocking, you can also overclock shell's boot up. There might be more... and more to come.\n\n*Suspending to shell and resuming game will LOAD A CONFIGURATION (DEFAULT OR SAVED). You will lose your changes when changing a task (including suspending to shell) unless you save.\n\nVideo courtesy of @Yoyogames28 :\n\nhttps://www.youtube.com/watch?v=mNPscIVubOY\n\nVideo courtesy of castelo:\n\nhttps://www.youtube.com/watch?v=ATiv301_eOA\n\n\nInstallation\n--------------------------------------------------------------------------------\n\nPut \"lolicon.skprx\" in 'tai' folder in the root of your Vita. (Or just use autoplugin, because I'm sure a ver that supports this is out already)\n\n```text\n*KERNEL\nur0:tai/lolicon.skprx\n```\n\nAfter that just reboot and press SELECT + UP to enable menu. Press SELECT + DOWN to close menu.\n\nThanks to: \n\nhttps://wiki.henkaku.xyz/vita/Pervasive#ARM_Clocks\n\nhttps://github.com/frangarcj/oclockvita\n\nhttps://github.com/Scorpeg\n\nhttps://github.com/BeatPlay/BetterAmphetaminPlugin\n\nhttps://github.com/DrakonPL/VitaJelly\n\nhttps://github.com/Rinnegatamante/Framecounter/blob/master/main.c\n\nhttps://github.com/joel16/PSV-VSH-Menu/tree/master/source\n\n## Major Thanks:\n\n@CelesteBlue123 - Help. TREMENDOUS and loyal DEV. Only the BEST! I recommend you retain the services of this man. HE DOES NOT CRACK!\n\n@nyassen (sys) - some guy\n\n@SilicaVita - this mysterious person helped with the name, not afraid to keep spamming that he did.\n\n## PR and special testing:\n\n@Yoyogames28 - Discount DF and cute boi\n\ncastelo - Great tester, thanks to @Cimmerian_Iter for letters of rec. \n\n@froid_san 3.68 tester... I forgot to test on 3.68. Sad!\n\n## Testing team:\n\n@juliosueiras\n\nGrandMaster\n\n@nkekev\n\n@coburn64\n\nOrphen07\n\nCrossFusionX\n"
  },
  {
    "path": "blit.c",
    "content": "/*\n\tPSP VSH 24bpp text bliter\n*/\n#include <libk/stdarg.h>\n#include <libk/stdio.h>\n#include <libk/string.h>\n\n\n#include \"blit.h\"\n\n#define ALPHA_BLEND 1\n\nextern unsigned char msx[];\n\n/////////////////////////////////////////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////\nstatic int pwidth, pheight, bufferwidth, pixelformat;\nstatic unsigned int* vram32;\n\nstatic uint32_t fcolor = 0x00ffffff;\nstatic uint32_t bcolor = 0xff000000;\n\n#if ALPHA_BLEND\n/////////////////////////////////////////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////\nstatic uint32_t adjust_alpha(uint32_t col)\n{\n\tuint32_t alpha = col>>24;\n\tuint8_t mul;\n\tuint32_t c1,c2;\n\n\tif(alpha==0)    return col;\n\tif(alpha==0xff) return col;\n\n\tc1 = col & 0x00ff00ff;\n\tc2 = col & 0x0000ff00;\n\tmul = (uint8_t)(255-alpha);\n\tc1 = ((c1*mul)>>8)&0x00ff00ff;\n\tc2 = ((c2*mul)>>8)&0x0000ff00;\n\treturn (alpha<<24)|c1|c2;\n}\n#endif\n\n#define printf ksceDebugPrintf\n\n/////////////////////////////////////////////////////////////////////////////\n// blit text\n/////////////////////////////////////////////////////////////////////////////\nvoid blit_set_color(int fg_col,int bg_col)\n{\n\tfcolor = fg_col;\n\tbcolor = bg_col;\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// blit text\n/////////////////////////////////////////////////////////////////////////////\nint blit_string(int sx,int sy,const char *msg)\n{\n\tint x,y,p;\n\tint offset;\n\tchar code;\n\tunsigned char font;\n\tuint32_t fg_col,bg_col;\n\n#if ALPHA_BLEND\n\tuint32_t col,c1,c2;\n\tuint32_t alpha;\n\n\tfg_col = adjust_alpha(fcolor);\n\tbg_col = adjust_alpha(bcolor);\n#else\n\tfg_col = fcolor;\n\tbg_col = bcolor;\n#endif\n\n//Kprintf(\"MODE %d WIDTH %d\\n\",pixelformat,bufferwidth);\n\tif( (bufferwidth==0) || (pixelformat!=0)) return -1;\n\n\tfor(x=0;msg[x] && x<(pwidth/16);x++)\n\t{\n\t\tcode = msg[x] & 0x7f; // 7bit ANK\n\t\tfor(y=0;y<8;y++)\n\t\t{\n\t\t\toffset = (sy+(y*2))*bufferwidth + sx+x*16;\n\t\t\tfont = y>=7 ? 0x00 : msx[ code*8 + y ];\n\t\t\tfor(p=0;p<8;p++)\n\t\t\t{\n\t\t\t\t#if ALPHA_BLEND\n\t\t\t\tcol = (font & 0x80) ? fg_col : bg_col;\n\t\t\t\talpha = col>>24;\n\t\t\t\tif(alpha==0)\n\t\t\t\t{\n\t\t\t\t\tksceKernelMemcpyKernelToUser((uintptr_t)(&vram32[offset]), &col, sizeof(col));\n\t\t\t\t\tksceKernelMemcpyKernelToUser((uintptr_t)(&vram32[offset + 1]), &col, sizeof(col));\n\t\t\t\t\tksceKernelMemcpyKernelToUser((uintptr_t)(&vram32[offset + bufferwidth]), &col, sizeof(col));\n\t\t\t\t\tksceKernelMemcpyKernelToUser((uintptr_t)(&vram32[offset + bufferwidth + 1]), &col, sizeof(col));\n\t\t\t\t}\n\t\t\t\telse if(alpha!=0xff)\n\t\t\t\t{\n\t\t\t\t\tksceKernelMemcpyUserToKernel(&c2, (uintptr_t)(vram32[offset]), sizeof(unsigned int));\n\t\t\t\t\tc1 = c2 & 0x00ff00ff;\n\t\t\t\t\tc2 = c2 & 0x0000ff00;\n\t\t\t\t\tc1 = ((c1*alpha)>>8)&0x00ff00ff;\n\t\t\t\t\tc2 = ((c2*alpha)>>8)&0x0000ff00;\n\t\t\t\t\tuint32_t color = (col&0xffffff) + c1 + c2;\n\t\t\t\t\tksceKernelMemcpyKernelToUser((uintptr_t)(vram32 + offset), &color, sizeof(uint32_t));\n\t\t\t\t\tksceKernelMemcpyKernelToUser((uintptr_t)(vram32 + offset + 1), &color, sizeof(uint32_t));\n\t\t\t\t\tksceKernelMemcpyKernelToUser((uintptr_t)(vram32 + offset + bufferwidth), &color, sizeof(uint32_t));\n\t\t\t\t\tksceKernelMemcpyKernelToUser((uintptr_t)(vram32 + offset + bufferwidth + 1), &color, sizeof(uint32_t));\n\n\t\t\t\t}\n#else\n\t\t\t\tuint32_t color = (font & 0x80) ? fg_col : bg_col;\n\t\t\t\tksceKernelMemcpyKernelToUser((uintptr_t)(vram32 + offset + 1), &color, sizeof(uint32_t));\n\t\t\t\tksceKernelMemcpyKernelToUser((uintptr_t)(vram32 + offset + bufferwidth), &color, sizeof(uint32_t));\n\t\t\t\tksceKernelMemcpyKernelToUser((uintptr_t)(vram32 + offset + bufferwidth + 1), &color, sizeof(uint32_t));\n#endif\n\n\t\t\t\tfont <<= 1;\n\t\t\t\toffset+=2;\n\t\t\t}\n\t\t}\n\t}\n\treturn x;\n}\n\nint blit_string_ctr(int sy,const char *msg)\n{\n\tint sx = (960 / 2) - (strlen(msg) * (16 / 2));\n\treturn blit_string(sx,sy,msg);\n}\n\nint blit_stringf(int sx, int sy, const char *msg, ...)\n{\n\tva_list list;\n\tchar string[512];\n\n\tva_start(list, msg);\n\tvsnprintf(string, 512, msg, list);\n\tva_end(list);\n\n\treturn blit_string(sx, sy, string);\n}\n\nint blit_set_frame_buf(const SceDisplayFrameBuf *param)\n{\n\t\n\tpwidth = param->width;\n\tpheight = param->height;\n\tvram32 = param->base;\n\tbufferwidth = param->pitch;\n\tpixelformat = param->pixelformat;\n\n\tif( (bufferwidth==0) || (pixelformat!=0)) return -1;\n\n\tfcolor = 0x00ffffff;\n\tbcolor = 0xff000000;\n\n  return 0;\n}"
  },
  {
    "path": "blit.h",
    "content": "#ifndef __BLIT_H__\n#define __BLIT_H__\n\n#include <vitasdkkern.h>\n\n#define COLOR_CYAN    0x00ffff00\n#define COLOR_MAGENDA 0x00ff00ff\n#define COLOR_YELLOW  0x0000ffff\n\n#define RGB(R,G,B)    (((B)<<16)|((G)<<8)|(R))\n#define RGBT(R,G,B,T) (((T)<<24)|((B)<<16)|((G)<<8)|(R))\n\n#define CENTER(num) ((960/2)-(num*(16/2)))\n\nvoid blit_set_color(int fg_col,int bg_col);\nint blit_string(int sx,int sy,const char *msg);\nint blit_string_ctr(int sy,const char *msg);\nint blit_stringf(int sx, int sy, const char *msg, ...);\nint blit_set_frame_buf(const SceDisplayFrameBuf *param);\n\n#endif\n"
  },
  {
    "path": "font.c",
    "content": "/*\n * PSP Software Development Kit - http://www.pspdev.org\n * -----------------------------------------------------------------------\n * Licensed under the BSD license, see LICENSE in PSPSDK root for details.\n *\n * font.c - Debug Font.\n *\n * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>\n * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>\n * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>\n *\n * $Id: font.c 339 2005-06-27 02:24:25Z warren $\n */\n#include <psp2/types.h>\n\nconst uint8_t msx[]=\n\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x3c\\x42\\xa5\\x81\\xa5\\x99\\x42\\x3c\"\n\"\\x3c\\x7e\\xdb\\xff\\xff\\xdb\\x66\\x3c\\x6c\\xfe\\xfe\\xfe\\x7c\\x38\\x10\\x00\"\n\"\\x10\\x38\\x7c\\xfe\\x7c\\x38\\x10\\x00\\x10\\x38\\x54\\xfe\\x54\\x10\\x38\\x00\"\n\"\\x10\\x38\\x7c\\xfe\\xfe\\x10\\x38\\x00\\x00\\x00\\x00\\x30\\x30\\x00\\x00\\x00\"\n\"\\xff\\xff\\xff\\xe7\\xe7\\xff\\xff\\xff\\x38\\x44\\x82\\x82\\x82\\x44\\x38\\x00\"\n\"\\xc7\\xbb\\x7d\\x7d\\x7d\\xbb\\xc7\\xff\\x0f\\x03\\x05\\x79\\x88\\x88\\x88\\x70\"\n\"\\x38\\x44\\x44\\x44\\x38\\x10\\x7c\\x10\\x30\\x28\\x24\\x24\\x28\\x20\\xe0\\xc0\"\n\"\\x3c\\x24\\x3c\\x24\\x24\\xe4\\xdc\\x18\\x10\\x54\\x38\\xee\\x38\\x54\\x10\\x00\"\n\"\\x10\\x10\\x10\\x7c\\x10\\x10\\x10\\x10\\x10\\x10\\x10\\xff\\x00\\x00\\x00\\x00\"\n\"\\x00\\x00\\x00\\xff\\x10\\x10\\x10\\x10\\x10\\x10\\x10\\xf0\\x10\\x10\\x10\\x10\"\n\"\\x10\\x10\\x10\\x1f\\x10\\x10\\x10\\x10\\x10\\x10\\x10\\xff\\x10\\x10\\x10\\x10\"\n\"\\x10\\x10\\x10\\x10\\x10\\x10\\x10\\x10\\x00\\x00\\x00\\xff\\x00\\x00\\x00\\x00\"\n\"\\x00\\x00\\x00\\x1f\\x10\\x10\\x10\\x10\\x00\\x00\\x00\\xf0\\x10\\x10\\x10\\x10\"\n\"\\x10\\x10\\x10\\x1f\\x00\\x00\\x00\\x00\\x10\\x10\\x10\\xf0\\x00\\x00\\x00\\x00\"\n\"\\x81\\x42\\x24\\x18\\x18\\x24\\x42\\x81\\x01\\x02\\x04\\x08\\x10\\x20\\x40\\x80\"\n\"\\x80\\x40\\x20\\x10\\x08\\x04\\x02\\x01\\x00\\x10\\x10\\xff\\x10\\x10\\x00\\x00\"\n\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x20\\x20\\x20\\x20\\x00\\x00\\x20\\x00\"\n\"\\x50\\x50\\x50\\x00\\x00\\x00\\x00\\x00\\x50\\x50\\xf8\\x50\\xf8\\x50\\x50\\x00\"\n\"\\x20\\x78\\xa0\\x70\\x28\\xf0\\x20\\x00\\xc0\\xc8\\x10\\x20\\x40\\x98\\x18\\x00\"\n\"\\x40\\xa0\\x40\\xa8\\x90\\x98\\x60\\x00\\x10\\x20\\x40\\x00\\x00\\x00\\x00\\x00\"\n\"\\x10\\x20\\x40\\x40\\x40\\x20\\x10\\x00\\x40\\x20\\x10\\x10\\x10\\x20\\x40\\x00\"\n\"\\x20\\xa8\\x70\\x20\\x70\\xa8\\x20\\x00\\x00\\x20\\x20\\xf8\\x20\\x20\\x00\\x00\"\n\"\\x00\\x00\\x00\\x00\\x00\\x20\\x20\\x40\\x00\\x00\\x00\\x78\\x00\\x00\\x00\\x00\"\n\"\\x00\\x00\\x00\\x00\\x00\\x60\\x60\\x00\\x00\\x00\\x08\\x10\\x20\\x40\\x80\\x00\"\n\"\\x70\\x88\\x98\\xa8\\xc8\\x88\\x70\\x00\\x20\\x60\\xa0\\x20\\x20\\x20\\xf8\\x00\"\n\"\\x70\\x88\\x08\\x10\\x60\\x80\\xf8\\x00\\x70\\x88\\x08\\x30\\x08\\x88\\x70\\x00\"\n\"\\x10\\x30\\x50\\x90\\xf8\\x10\\x10\\x00\\xf8\\x80\\xe0\\x10\\x08\\x10\\xe0\\x00\"\n\"\\x30\\x40\\x80\\xf0\\x88\\x88\\x70\\x00\\xf8\\x88\\x10\\x20\\x20\\x20\\x20\\x00\"\n\"\\x70\\x88\\x88\\x70\\x88\\x88\\x70\\x00\\x70\\x88\\x88\\x78\\x08\\x10\\x60\\x00\"\n\"\\x00\\x00\\x20\\x00\\x00\\x20\\x00\\x00\\x00\\x00\\x20\\x00\\x00\\x20\\x20\\x40\"\n\"\\x18\\x30\\x60\\xc0\\x60\\x30\\x18\\x00\\x00\\x00\\xf8\\x00\\xf8\\x00\\x00\\x00\"\n\"\\xc0\\x60\\x30\\x18\\x30\\x60\\xc0\\x00\\x70\\x88\\x08\\x10\\x20\\x00\\x20\\x00\"\n\"\\x70\\x88\\x08\\x68\\xa8\\xa8\\x70\\x00\\x20\\x50\\x88\\x88\\xf8\\x88\\x88\\x00\"\n\"\\xf0\\x48\\x48\\x70\\x48\\x48\\xf0\\x00\\x30\\x48\\x80\\x80\\x80\\x48\\x30\\x00\"\n\"\\xe0\\x50\\x48\\x48\\x48\\x50\\xe0\\x00\\xf8\\x80\\x80\\xf0\\x80\\x80\\xf8\\x00\"\n\"\\xf8\\x80\\x80\\xf0\\x80\\x80\\x80\\x00\\x70\\x88\\x80\\xb8\\x88\\x88\\x70\\x00\"\n\"\\x88\\x88\\x88\\xf8\\x88\\x88\\x88\\x00\\x70\\x20\\x20\\x20\\x20\\x20\\x70\\x00\"\n\"\\x38\\x10\\x10\\x10\\x90\\x90\\x60\\x00\\x88\\x90\\xa0\\xc0\\xa0\\x90\\x88\\x00\"\n\"\\x80\\x80\\x80\\x80\\x80\\x80\\xf8\\x00\\x88\\xd8\\xa8\\xa8\\x88\\x88\\x88\\x00\"\n\"\\x88\\xc8\\xc8\\xa8\\x98\\x98\\x88\\x00\\x70\\x88\\x88\\x88\\x88\\x88\\x70\\x00\"\n\"\\xf0\\x88\\x88\\xf0\\x80\\x80\\x80\\x00\\x70\\x88\\x88\\x88\\xa8\\x90\\x68\\x00\"\n\"\\xf0\\x88\\x88\\xf0\\xa0\\x90\\x88\\x00\\x70\\x88\\x80\\x70\\x08\\x88\\x70\\x00\"\n\"\\xf8\\x20\\x20\\x20\\x20\\x20\\x20\\x00\\x88\\x88\\x88\\x88\\x88\\x88\\x70\\x00\"\n\"\\x88\\x88\\x88\\x88\\x50\\x50\\x20\\x00\\x88\\x88\\x88\\xa8\\xa8\\xd8\\x88\\x00\"\n\"\\x88\\x88\\x50\\x20\\x50\\x88\\x88\\x00\\x88\\x88\\x88\\x70\\x20\\x20\\x20\\x00\"\n\"\\xf8\\x08\\x10\\x20\\x40\\x80\\xf8\\x00\\x70\\x40\\x40\\x40\\x40\\x40\\x70\\x00\"\n\"\\x00\\x00\\x80\\x40\\x20\\x10\\x08\\x00\\x70\\x10\\x10\\x10\\x10\\x10\\x70\\x00\"\n\"\\x20\\x50\\x88\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xf8\\x00\"\n\"\\x40\\x20\\x10\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x70\\x08\\x78\\x88\\x78\\x00\"\n\"\\x80\\x80\\xb0\\xc8\\x88\\xc8\\xb0\\x00\\x00\\x00\\x70\\x88\\x80\\x88\\x70\\x00\"\n\"\\x08\\x08\\x68\\x98\\x88\\x98\\x68\\x00\\x00\\x00\\x70\\x88\\xf8\\x80\\x70\\x00\"\n\"\\x10\\x28\\x20\\xf8\\x20\\x20\\x20\\x00\\x00\\x00\\x68\\x98\\x98\\x68\\x08\\x70\"\n\"\\x80\\x80\\xf0\\x88\\x88\\x88\\x88\\x00\\x20\\x00\\x60\\x20\\x20\\x20\\x70\\x00\"\n\"\\x10\\x00\\x30\\x10\\x10\\x10\\x90\\x60\\x40\\x40\\x48\\x50\\x60\\x50\\x48\\x00\"\n\"\\x60\\x20\\x20\\x20\\x20\\x20\\x70\\x00\\x00\\x00\\xd0\\xa8\\xa8\\xa8\\xa8\\x00\"\n\"\\x00\\x00\\xb0\\xc8\\x88\\x88\\x88\\x00\\x00\\x00\\x70\\x88\\x88\\x88\\x70\\x00\"\n\"\\x00\\x00\\xb0\\xc8\\xc8\\xb0\\x80\\x80\\x00\\x00\\x68\\x98\\x98\\x68\\x08\\x08\"\n\"\\x00\\x00\\xb0\\xc8\\x80\\x80\\x80\\x00\\x00\\x00\\x78\\x80\\xf0\\x08\\xf0\\x00\"\n\"\\x40\\x40\\xf0\\x40\\x40\\x48\\x30\\x00\\x00\\x00\\x90\\x90\\x90\\x90\\x68\\x00\"\n\"\\x00\\x00\\x88\\x88\\x88\\x50\\x20\\x00\\x00\\x00\\x88\\xa8\\xa8\\xa8\\x50\\x00\"\n\"\\x00\\x00\\x88\\x50\\x20\\x50\\x88\\x00\\x00\\x00\\x88\\x88\\x98\\x68\\x08\\x70\"\n\"\\x00\\x00\\xf8\\x10\\x20\\x40\\xf8\\x00\\x18\\x20\\x20\\x40\\x20\\x20\\x18\\x00\"\n\"\\x20\\x20\\x20\\x00\\x20\\x20\\x20\\x00\\xc0\\x20\\x20\\x10\\x20\\x20\\xc0\\x00\"\n\"\\x40\\xa8\\x10\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x20\\x50\\xf8\\x00\\x00\\x00\"\n\"\\x70\\x88\\x80\\x80\\x88\\x70\\x20\\x60\\x90\\x00\\x00\\x90\\x90\\x90\\x68\\x00\"\n\"\\x10\\x20\\x70\\x88\\xf8\\x80\\x70\\x00\\x20\\x50\\x70\\x08\\x78\\x88\\x78\\x00\"\n\"\\x48\\x00\\x70\\x08\\x78\\x88\\x78\\x00\\x20\\x10\\x70\\x08\\x78\\x88\\x78\\x00\"\n\"\\x20\\x00\\x70\\x08\\x78\\x88\\x78\\x00\\x00\\x70\\x80\\x80\\x80\\x70\\x10\\x60\"\n\"\\x20\\x50\\x70\\x88\\xf8\\x80\\x70\\x00\\x50\\x00\\x70\\x88\\xf8\\x80\\x70\\x00\"\n\"\\x20\\x10\\x70\\x88\\xf8\\x80\\x70\\x00\\x50\\x00\\x00\\x60\\x20\\x20\\x70\\x00\"\n\"\\x20\\x50\\x00\\x60\\x20\\x20\\x70\\x00\\x40\\x20\\x00\\x60\\x20\\x20\\x70\\x00\"\n\"\\x50\\x00\\x20\\x50\\x88\\xf8\\x88\\x00\\x20\\x00\\x20\\x50\\x88\\xf8\\x88\\x00\"\n\"\\x10\\x20\\xf8\\x80\\xf0\\x80\\xf8\\x00\\x00\\x00\\x6c\\x12\\x7e\\x90\\x6e\\x00\"\n\"\\x3e\\x50\\x90\\x9c\\xf0\\x90\\x9e\\x00\\x60\\x90\\x00\\x60\\x90\\x90\\x60\\x00\"\n\"\\x90\\x00\\x00\\x60\\x90\\x90\\x60\\x00\\x40\\x20\\x00\\x60\\x90\\x90\\x60\\x00\"\n\"\\x40\\xa0\\x00\\xa0\\xa0\\xa0\\x50\\x00\\x40\\x20\\x00\\xa0\\xa0\\xa0\\x50\\x00\"\n\"\\x90\\x00\\x90\\x90\\xb0\\x50\\x10\\xe0\\x50\\x00\\x70\\x88\\x88\\x88\\x70\\x00\"\n\"\\x50\\x00\\x88\\x88\\x88\\x88\\x70\\x00\\x20\\x20\\x78\\x80\\x80\\x78\\x20\\x20\"\n\"\\x18\\x24\\x20\\xf8\\x20\\xe2\\x5c\\x00\\x88\\x50\\x20\\xf8\\x20\\xf8\\x20\\x00\"\n\"\\xc0\\xa0\\xa0\\xc8\\x9c\\x88\\x88\\x8c\\x18\\x20\\x20\\xf8\\x20\\x20\\x20\\x40\"\n\"\\x10\\x20\\x70\\x08\\x78\\x88\\x78\\x00\\x10\\x20\\x00\\x60\\x20\\x20\\x70\\x00\"\n\"\\x20\\x40\\x00\\x60\\x90\\x90\\x60\\x00\\x20\\x40\\x00\\x90\\x90\\x90\\x68\\x00\"\n\"\\x50\\xa0\\x00\\xa0\\xd0\\x90\\x90\\x00\\x28\\x50\\x00\\xc8\\xa8\\x98\\x88\\x00\"\n\"\\x00\\x70\\x08\\x78\\x88\\x78\\x00\\xf8\\x00\\x60\\x90\\x90\\x90\\x60\\x00\\xf0\"\n\"\\x20\\x00\\x20\\x40\\x80\\x88\\x70\\x00\\x00\\x00\\x00\\xf8\\x80\\x80\\x00\\x00\"\n\"\\x00\\x00\\x00\\xf8\\x08\\x08\\x00\\x00\\x84\\x88\\x90\\xa8\\x54\\x84\\x08\\x1c\"\n\"\\x84\\x88\\x90\\xa8\\x58\\xa8\\x3c\\x08\\x20\\x00\\x00\\x20\\x20\\x20\\x20\\x00\"\n\"\\x00\\x00\\x24\\x48\\x90\\x48\\x24\\x00\\x00\\x00\\x90\\x48\\x24\\x48\\x90\\x00\"\n\"\\x28\\x50\\x20\\x50\\x88\\xf8\\x88\\x00\\x28\\x50\\x70\\x08\\x78\\x88\\x78\\x00\"\n\"\\x28\\x50\\x00\\x70\\x20\\x20\\x70\\x00\\x28\\x50\\x00\\x20\\x20\\x20\\x70\\x00\"\n\"\\x28\\x50\\x00\\x70\\x88\\x88\\x70\\x00\\x50\\xa0\\x00\\x60\\x90\\x90\\x60\\x00\"\n\"\\x28\\x50\\x00\\x88\\x88\\x88\\x70\\x00\\x50\\xa0\\x00\\xa0\\xa0\\xa0\\x50\\x00\"\n\"\\xfc\\x48\\x48\\x48\\xe8\\x08\\x50\\x20\\x00\\x50\\x00\\x50\\x50\\x50\\x10\\x20\"\n\"\\xc0\\x44\\xc8\\x54\\xec\\x54\\x9e\\x04\\x10\\xa8\\x40\\x00\\x00\\x00\\x00\\x00\"\n\"\\x00\\x20\\x50\\x88\\x50\\x20\\x00\\x00\\x88\\x10\\x20\\x40\\x80\\x28\\x00\\x00\"\n\"\\x7c\\xa8\\xa8\\x68\\x28\\x28\\x28\\x00\\x38\\x40\\x30\\x48\\x48\\x30\\x08\\x70\"\n\"\\x00\\x00\\x00\\x00\\x00\\x00\\xff\\xff\\xf0\\xf0\\xf0\\xf0\\x0f\\x0f\\x0f\\x0f\"\n\"\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\x00\\x00\\x00\\x00\"\n\"\\x00\\x00\\x00\\x3c\\x3c\\x00\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\"\n\"\\xc0\\xc0\\xc0\\xc0\\xc0\\xc0\\xc0\\xc0\\x0f\\x0f\\x0f\\x0f\\xf0\\xf0\\xf0\\xf0\"\n\"\\xfc\\xfc\\xfc\\xfc\\xfc\\xfc\\xfc\\xfc\\x03\\x03\\x03\\x03\\x03\\x03\\x03\\x03\"\n\"\\x3f\\x3f\\x3f\\x3f\\x3f\\x3f\\x3f\\x3f\\x11\\x22\\x44\\x88\\x11\\x22\\x44\\x88\"\n\"\\x88\\x44\\x22\\x11\\x88\\x44\\x22\\x11\\xfe\\x7c\\x38\\x10\\x00\\x00\\x00\\x00\"\n\"\\x00\\x00\\x00\\x00\\x10\\x38\\x7c\\xfe\\x80\\xc0\\xe0\\xf0\\xe0\\xc0\\x80\\x00\"\n\"\\x01\\x03\\x07\\x0f\\x07\\x03\\x01\\x00\\xff\\x7e\\x3c\\x18\\x18\\x3c\\x7e\\xff\"\n\"\\x81\\xc3\\xe7\\xff\\xff\\xe7\\xc3\\x81\\xf0\\xf0\\xf0\\xf0\\x00\\x00\\x00\\x00\"\n\"\\x00\\x00\\x00\\x00\\x0f\\x0f\\x0f\\x0f\\x0f\\x0f\\x0f\\x0f\\x00\\x00\\x00\\x00\"\n\"\\x00\\x00\\x00\\x00\\xf0\\xf0\\xf0\\xf0\\x33\\x33\\xcc\\xcc\\x33\\x33\\xcc\\xcc\"\n\"\\x00\\x20\\x20\\x50\\x50\\x88\\xf8\\x00\\x20\\x20\\x70\\x20\\x70\\x20\\x20\\x00\"\n\"\\x00\\x00\\x00\\x50\\x88\\xa8\\x50\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\"\n\"\\x00\\x00\\x00\\x00\\xff\\xff\\xff\\xff\\xf0\\xf0\\xf0\\xf0\\xf0\\xf0\\xf0\\xf0\"\n\"\\x0f\\x0f\\x0f\\x0f\\x0f\\x0f\\x0f\\x0f\\xff\\xff\\xff\\xff\\x00\\x00\\x00\\x00\"\n\"\\x00\\x00\\x68\\x90\\x90\\x90\\x68\\x00\\x30\\x48\\x48\\x70\\x48\\x48\\x70\\xc0\"\n\"\\xf8\\x88\\x80\\x80\\x80\\x80\\x80\\x00\\xf8\\x50\\x50\\x50\\x50\\x50\\x98\\x00\"\n\"\\xf8\\x88\\x40\\x20\\x40\\x88\\xf8\\x00\\x00\\x00\\x78\\x90\\x90\\x90\\x60\\x00\"\n\"\\x00\\x50\\x50\\x50\\x50\\x68\\x80\\x80\\x00\\x50\\xa0\\x20\\x20\\x20\\x20\\x00\"\n\"\\xf8\\x20\\x70\\xa8\\xa8\\x70\\x20\\xf8\\x20\\x50\\x88\\xf8\\x88\\x50\\x20\\x00\"\n\"\\x70\\x88\\x88\\x88\\x50\\x50\\xd8\\x00\\x30\\x40\\x40\\x20\\x50\\x50\\x50\\x20\"\n\"\\x00\\x00\\x00\\x50\\xa8\\xa8\\x50\\x00\\x08\\x70\\xa8\\xa8\\xa8\\x70\\x80\\x00\"\n\"\\x38\\x40\\x80\\xf8\\x80\\x40\\x38\\x00\\x70\\x88\\x88\\x88\\x88\\x88\\x88\\x00\"\n\"\\x00\\xf8\\x00\\xf8\\x00\\xf8\\x00\\x00\\x20\\x20\\xf8\\x20\\x20\\x00\\xf8\\x00\"\n\"\\xc0\\x30\\x08\\x30\\xc0\\x00\\xf8\\x00\\x18\\x60\\x80\\x60\\x18\\x00\\xf8\\x00\"\n\"\\x10\\x28\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\xa0\\x40\"\n\"\\x00\\x20\\x00\\xf8\\x00\\x20\\x00\\x00\\x00\\x50\\xa0\\x00\\x50\\xa0\\x00\\x00\"\n\"\\x00\\x18\\x24\\x24\\x18\\x00\\x00\\x00\\x00\\x30\\x78\\x78\\x30\\x00\\x00\\x00\"\n\"\\x00\\x00\\x00\\x00\\x30\\x00\\x00\\x00\\x3e\\x20\\x20\\x20\\xa0\\x60\\x20\\x00\"\n\"\\xa0\\x50\\x50\\x50\\x00\\x00\\x00\\x00\\x40\\xa0\\x20\\x40\\xe0\\x00\\x00\\x00\"\n\"\\x00\\x38\\x38\\x38\\x38\\x38\\x38\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\";\n"
  },
  {
    "path": "utils.c",
    "content": "#include <taihen.h>\r\n#include <vitasdkkern.h>\r\n#include <string.h>\r\n\r\nint ReadFile(const char *file, void *buf, int size) {\r\n\tSceUID fd = ksceIoOpen(file, SCE_O_RDONLY, 0);\r\n\tif (fd < 0)\r\n\treturn fd;\r\n\tint read = ksceIoRead(fd, buf, size);\r\n\tksceIoClose(fd);\r\n\treturn read;\r\n}\r\n\r\nint WriteFile(const char *file, void *buf, int size) {\r\n\tSceUID fd = ksceIoOpen(file, SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 0777);\r\n\tif (fd < 0)\r\n\treturn fd;\r\n\tint written = ksceIoWrite(fd, buf, size);\r\n\tksceIoClose(fd);\r\n\treturn written;\r\n}\r\n\r\nunsigned int pa2va(unsigned int pa) {\r\n\tunsigned int va;\r\n\tunsigned int vaddr;\r\n\tunsigned int paddr;\r\n\tunsigned int i;\r\n\tva = 0;\r\n\tfor (i = 0; i < 0x100000; i++) {\r\n\t\tvaddr = i << 12;\r\n\t\t__asm__(\"mcr p15,0,%1,c7,c8,0\\n\\t\"\r\n\t\t\"mrc p15,0,%0,c7,c4,0\\n\\t\" : \"=r\" (paddr) : \"r\" (vaddr));\r\n\t\tif ((pa & 0xFFFFF000) == (paddr & 0xFFFFF000)) {\r\n\t\t\tva = vaddr + (pa & 0xFFF);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn va;\r\n}"
  },
  {
    "path": "utils.h",
    "content": "unsigned int pa2va(unsigned int pa);\r\nint WriteFile(const char *file, void *buf, int size);\r\nint ReadFile(const char *file, void *buf, int size);"
  }
]