├── .github └── workflows │ ├── build.yml │ ├── build_irshell.yml │ └── build_m33.yml ├── Dockerfile ├── Makefile ├── README.md ├── build_podman.sh ├── common.h ├── disc_ident.c ├── disc_ident.h ├── exports.exp ├── game_tweaks ├── README.md ├── UCAS40265.ini ├── UCES01245.ini ├── UCJS10100.ini └── UCUS98632.ini ├── hooking.c ├── hooking.h ├── logging.h ├── m33_sdk_prebuilt ├── README.txt ├── include │ ├── kubridge.h │ ├── pspinit.h │ ├── psploadcore.h │ ├── psploadexec_kernel.h │ ├── pspmodulemgr.h │ ├── pspmodulemgr_kernel.h │ ├── pspsysmem.h │ ├── pspsysmem_kernel.h │ ├── pspusbdevice.h │ ├── systemctrl.h │ ├── systemctrl_se.h │ └── vshctrl.h └── lib │ ├── libpspinit.a │ ├── libpspkdebug.a │ ├── libpspkubridge.a │ ├── libpsploadexec_kernel.a │ ├── libpspmodulemgr_kernel.a │ ├── libpspmodulemgr_user.a │ ├── libpspsysmem_kernel.a │ ├── libpspsysmem_user.a │ ├── libpspsystemctrl_kernel.a │ ├── libpspsystemctrl_user.a │ ├── libpspumd_kernel.a │ ├── libpspusbdevice.a │ ├── libpspusbdevice_driver.a │ └── libpspvshctrl.a ├── main.c ├── plugin.ini ├── procfw_sdk_prebuilt ├── README.txt ├── include │ ├── kubridge.h │ ├── pspcrypt.h │ ├── pspmodulemgr_kernel.h │ ├── pspusbdevice.h │ ├── pspvshbridge.h │ ├── systemctrl.h │ ├── systemctrl_se.h │ ├── vshctrl.h │ ├── zconf.h │ └── zlib.h └── lib │ ├── libpspkubridge.a │ ├── libpspmodulemgr_kernel.a │ ├── libpspsemaphore.a │ ├── libpspsystemctrl_kernel.a │ ├── libpspsystemctrl_user.a │ ├── libpspumd_kernel.a │ ├── libpspusbdevice.a │ ├── libpspusbdevice_driver.a │ ├── libpspvshbridge.a │ └── libz.a ├── script └── start_shell_podman.sh /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build package 2 | 3 | on: [ push, pull_request, workflow_dispatch ] 4 | 5 | # written referencing apollo save tool psp's CI 6 | 7 | jobs: 8 | build_pkg: 9 | runs-on: ubuntu-22.04 10 | steps: 11 | 12 | - name: Checkout 13 | uses: actions/checkout@v3 14 | 15 | # install latest pspdev sdk 16 | - name: Download PSP SDK 17 | run: | 18 | curl -sL https://github.com/pspdev/pspdev/releases/download/v20240701/pspdev-ubuntu-latest-x86_64.tar.gz | tar xvz -C ./ 19 | 20 | - name: Set env vars 21 | run: | 22 | echo "sha_name=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_ENV 23 | echo "PSPDEV=${GITHUB_WORKSPACE}/pspdev" >> $GITHUB_ENV 24 | echo "${GITHUB_WORKSPACE}/pspdev/bin" >> $GITHUB_PATH 25 | 26 | - name: Build GTRemastered.prx 27 | run: | 28 | cp procfw_sdk_prebuilt/include/* pspdev/psp/sdk/include/ 29 | cp procfw_sdk_prebuilt/lib/* pspdev/psp/sdk/lib/ 30 | make 31 | 32 | - name: Push package artifact 33 | uses: actions/upload-artifact@v3 34 | with: 35 | name: GTRemastered_${{ env.sha_name }} 36 | path: | 37 | GTRemastered.prx 38 | plugin.ini 39 | if-no-files-found: error 40 | -------------------------------------------------------------------------------- /.github/workflows/build_irshell.yml: -------------------------------------------------------------------------------- 1 | name: Build IRSHELL package 2 | 3 | on: [ push, pull_request, workflow_dispatch ] 4 | 5 | # written referencing apollo save tool psp's CI 6 | 7 | jobs: 8 | build_pkg: 9 | runs-on: ubuntu-22.04 10 | steps: 11 | 12 | - name: Checkout 13 | uses: actions/checkout@v3 14 | 15 | # install latest pspdev sdk 16 | - name: Download PSP SDK 17 | run: | 18 | curl -sL https://github.com/pspdev/pspdev/releases/download/v20240701/pspdev-ubuntu-latest-x86_64.tar.gz | tar xvz -C ./ 19 | 20 | - name: Set env vars 21 | run: | 22 | echo "sha_name=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_ENV 23 | echo "PSPDEV=${GITHUB_WORKSPACE}/pspdev" >> $GITHUB_ENV 24 | echo "${GITHUB_WORKSPACE}/pspdev/bin" >> $GITHUB_PATH 25 | 26 | - name: Build GTRemastered.prx 27 | run: | 28 | cp procfw_sdk_prebuilt/include/* pspdev/psp/sdk/include/ 29 | cp procfw_sdk_prebuilt/lib/* pspdev/psp/sdk/lib/ 30 | make CFLAGS_EXTRA=-DIRSHELL=1 31 | 32 | - name: Push package artifact 33 | uses: actions/upload-artifact@v3 34 | with: 35 | name: GTRemastered_IRSHELL_${{ env.sha_name }} 36 | path: | 37 | GTRemastered.prx 38 | plugin.ini 39 | if-no-files-found: error 40 | -------------------------------------------------------------------------------- /.github/workflows/build_m33.yml: -------------------------------------------------------------------------------- 1 | name: Build package for 4.01 m33 2 | 3 | on: [ workflow_dispatch ] 4 | 5 | # written referencing apollo save tool psp's CI 6 | 7 | jobs: 8 | build_pkg: 9 | runs-on: ubuntu-22.04 10 | steps: 11 | 12 | - name: Checkout 13 | uses: actions/checkout@v3 14 | 15 | # install latest pspdev sdk 16 | - name: Download PSP SDK 17 | run: | 18 | curl -sL https://github.com/pspdev/pspdev/releases/download/v20240701/pspdev-ubuntu-latest-x86_64.tar.gz | tar xvz -C ./ 19 | 20 | - name: Set env vars 21 | run: | 22 | echo "sha_name=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_ENV 23 | echo "PSPDEV=${GITHUB_WORKSPACE}/pspdev" >> $GITHUB_ENV 24 | echo "${GITHUB_WORKSPACE}/pspdev/bin" >> $GITHUB_PATH 25 | 26 | - name: Build GTRemastered.prx 27 | run: | 28 | cp m33_sdk_prebuilt/include/* pspdev/psp/sdk/include/ 29 | cp m33_sdk_prebuilt/lib/* pspdev/psp/sdk/lib/ 30 | make 31 | 32 | - name: Push package artifact 33 | uses: actions/upload-artifact@v3 34 | with: 35 | name: GTRemastered_4.01m33_${{ env.sha_name }} 36 | path: | 37 | GTRemastered.prx 38 | plugin.ini 39 | if-no-files-found: error 40 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:22.04 2 | RUN export noninteractive; apt update; apt install -y wget libreadline8 libusb-0.1-4 tmux make libmpc3 3 | RUN wget https://github.com/pspdev/pspdev/releases/download/v20240701/pspdev-ubuntu-latest-x86_64.tar.gz -O - | gzip -d | tar -C /usr/local -x 4 | RUN echo 'export PATH="/usr/local/pspdev/bin:$PATH"' > /etc/profile.d/pspsdk.sh 5 | RUN echo 'export LD_LIBRARY_PATH="/usr/local/pspsdk/lib:$LD_LIBRARY_PATH"' >> /etc/profile.d/pspsdk.sh 6 | ENTRYPOINT ["/bin/bash", "-l"] 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TARGET = GTRemastered 2 | OBJS = main.o hooking.o disc_ident.o exports.o 3 | 4 | CFLAGS = $(CFLAGS_EXTRA) -O2 -Os -G0 -Wall -fshort-wchar -fno-pic -mno-check-zero-division -fno-builtin -DDEBUG_LOG=1 5 | CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti 6 | ASFLAGS = $(CFLAGS) 7 | 8 | BUILD_PRX = 1 9 | PRX_EXPORTS = exports.exp 10 | 11 | # use kernel "libc" 12 | USE_KERNEL_LIBS = 1 13 | 14 | LIBS = -lpspsystemctrl_kernel 15 | 16 | PSP_FW_VERSION=661 17 | 18 | PSPSDK = $(shell psp-config --pspsdk-path) 19 | include $(PSPSDK)/lib/build_prx.mak 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### Remastered Controls for GTpsp 2 | 3 | - override internal steering deadzone for fine steering 4 | - inject vector throttle and brake values for a better RWD experience 5 | 6 | ### Usage 7 | 8 | - load prx with game, see https://www.ppsspp.org/docs/reference/plugins/ for PPSSPP, see https://consolemods.org/wiki/Vita:Adrenaline#Adding_Plugins for PSVita and https://www.reddit.com/r/PSP/wiki/plugins/ for PSP 9 | 10 | ### Keybinds 11 | 12 | - on PPSSPP, throttle is bound to right stick left, brake is bound to right stick down, remap right stick left and down in ppsspp accordingly to your desired throttle and brake control 13 | - on windows, please use version 1.17 and up 14 | - camera rotation on bumper and cockpit view can additionally be enabled on PPSSPP through the settings file 15 | - binds to left stick up and down when enabled, remap PPSSPP left stick up and down to your desired camera control inputs accordingly 16 | - on PSVita, throttle is bound to right stick up, brake is bound to right stick down 17 | - on PSP, it only reduces steering deadzones, there is no keybinding 18 | 19 | ### Settings 20 | 21 | - one can write `ms0:/PSP/GTRemastered_settings.txt` or `ef0:/PSP/GTRemastered_settings.txt` to modify the plugin's behavior 22 | ``` 23 | 24 | ``` 25 | 26 | - eg. enable camera control on PPSSPP, map the start of analog input to 10/127, end of analog input to 117/127 27 | ``` 28 | 1 10 117 29 | ``` 30 | 31 | ### Compability 32 | - EU v2.00 (UCES01245 2.00) 33 | - US v2.00 (UCUS98632 2.00) 34 | - JP v1.01 (UCJS10100 1.01) 35 | - ASIA v1.00 (UCAS40265 1.00) 36 | 37 | ### Hooking references 38 | 39 | - https://github.com/TheOfficialFloW/RemasteredControls 40 | - https://github.com/albe/joysens 41 | - https://github.com/Freakler/ppsspp-GTARemastered 42 | 43 | ### Credits 44 | 45 | - https://github.com/kotcrab/ghidra-allegrex for making psp games modding easier 46 | - https://github.com/pspdev , m33 and pro cfw for psp homebrew development tools 47 | - https://github.com/hrydgard/ppsspp for an awesome hle psp 48 | 49 | ### Extra game tweaking CWCheat codes 50 | 51 | - check the game_tweaks directory of this repository 52 | -------------------------------------------------------------------------------- /build_podman.sh: -------------------------------------------------------------------------------- 1 | IMAGE_NAME="pspsdk" 2 | 3 | if [ "$REBUILD_IMAGE" == "true" ] && podman image exists $IMAGE_NAME 4 | then 5 | podman image rm -f $IMAGE_NAME 6 | fi 7 | 8 | if ! podman image exists $IMAGE_NAME 9 | then 10 | podman image build -f Dockerfile -t $IMAGE_NAME 11 | fi 12 | 13 | podman run \ 14 | --rm -it \ 15 | --security-opt label=disable \ 16 | -v ./:/workdir \ 17 | -v ./build_podman.sh:/workdir/build_podman.sh:ro \ 18 | -v ./script:/workdir/script:ro \ 19 | -w /workdir \ 20 | $IMAGE_NAME \ 21 | /workdir/script 22 | -------------------------------------------------------------------------------- /common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_ 2 | #define _COMMON_ 3 | #define MODULE_NAME "GTRemastered" 4 | #endif 5 | -------------------------------------------------------------------------------- /disc_ident.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include "logging.h" 6 | 7 | #define CONV_LE(addr, dest) { \ 8 | dest = addr[0] | addr[1] << 8 | addr[2] << 16 | addr[3] << 24; \ 9 | } 10 | 11 | #define CONV_LE16(addr, dest) { \ 12 | dest = addr[0] | addr[1] << 8; \ 13 | } 14 | 15 | int get_disc_id_version(char *id_out, char *version_out){ 16 | char sfo_path[] = "disc0:/PSP_GAME/PARAM.SFO"; 17 | int fd = sceIoOpen(sfo_path, PSP_O_RDONLY,0); 18 | 19 | int id_found = 0; 20 | int version_found = 0; 21 | 22 | if(fd < 0){ 23 | LOG("cannot open %s for reading", sfo_path); 24 | return -1; 25 | } 26 | 27 | sceIoLseek(fd, 0x08, PSP_SEEK_SET); 28 | unsigned char buf[4]; 29 | if(sceIoRead(fd, &buf, 4) != 4){ 30 | sceIoClose(fd); 31 | LOG("failed reading key table start from sfo"); 32 | return -1; 33 | } 34 | u32 key_table_start = 0; 35 | CONV_LE(buf, key_table_start); 36 | LOG_VERBOSE("key_table_start is %ld", key_table_start); 37 | 38 | if(sceIoRead(fd, &buf, 4) != 4){ 39 | sceIoClose(fd); 40 | LOG("failed reading data table start from sfo"); 41 | return -1; 42 | } 43 | u32 data_table_start = 0; 44 | CONV_LE(buf, data_table_start); 45 | LOG_VERBOSE("data_table_start is %ld", data_table_start); 46 | 47 | if(sceIoRead(fd, &buf, 4) != 4){ 48 | sceIoClose(fd); 49 | LOG("failed reading tables entries from sfo"); 50 | return -1; 51 | } 52 | u32 tables_entries = 0; 53 | CONV_LE(buf, tables_entries); 54 | LOG_VERBOSE("tables_entries is %ld", tables_entries); 55 | 56 | u32 i; 57 | for(i = 0;i < tables_entries;i++){ 58 | sceIoLseek(fd, 0x14 + i * 0x10, PSP_SEEK_SET); 59 | if(sceIoRead(fd, &buf, 2) != 2){ 60 | sceIoClose(fd); 61 | LOG("failed reading key offset from sfo"); 62 | return -1; 63 | } 64 | u32 key_offset = 0; 65 | CONV_LE16(buf, key_offset); 66 | 67 | if(sceIoRead(fd, &buf, 2) != 2){ 68 | sceIoClose(fd); 69 | LOG("failed reading data format from sfo"); 70 | return -1; 71 | } 72 | u32 data_format = 0; 73 | CONV_LE16(buf, data_format); 74 | 75 | if(sceIoRead(fd, &buf, 4) != 4){ 76 | sceIoClose(fd); 77 | LOG("failed reading data len from sfo"); 78 | return -1; 79 | } 80 | u32 data_len = 0; 81 | CONV_LE(buf, data_len); 82 | 83 | sceIoLseek(fd, 4, PSP_SEEK_CUR); 84 | if(sceIoRead(fd, &buf, 4) != 4){ 85 | sceIoClose(fd); 86 | LOG("failed reading data offset from sfo"); 87 | return -1; 88 | } 89 | u32 data_offset = 0; 90 | CONV_LE(buf, data_offset); 91 | 92 | sceIoLseek(fd, key_offset + key_table_start, PSP_SEEK_SET); 93 | char keybuf[50]; 94 | u32 j; 95 | for(j = 0;j < 50;j++){ 96 | if(sceIoRead(fd, &keybuf[j], 1) != 1){ 97 | sceIoClose(fd); 98 | LOG("failed reading key from sfo"); 99 | } 100 | if(keybuf[j] == 0){ 101 | break; 102 | } 103 | } 104 | LOG_VERBOSE("key is %s", keybuf); 105 | 106 | sceIoLseek(fd, data_offset + data_table_start, PSP_SEEK_SET); 107 | char databuf[data_len]; 108 | for(j = 0;j < data_len; j++){ 109 | if(sceIoRead(fd, &databuf[j], 1) != 1){ 110 | sceIoClose(fd); 111 | LOG("failed reading data from sfo"); 112 | } 113 | } 114 | if(data_format == 0x0204){ 115 | LOG_VERBOSE("utf8 data: %s", databuf); 116 | }else{ 117 | LOG_VERBOSE("data is not utf8, not printing"); 118 | } 119 | 120 | if(strncmp("DISC_ID", keybuf, 8) == 0){ 121 | strcpy(id_out, databuf); 122 | id_found = 1; 123 | } 124 | 125 | if(strncmp("DISC_VERSION", keybuf, 8) == 0){ 126 | strcpy(version_out, databuf); 127 | version_found = 1; 128 | } 129 | 130 | if(version_found && id_found){ 131 | break; 132 | } 133 | } 134 | 135 | sceIoClose(fd); 136 | return version_found && id_found ? 0 : -1; 137 | } 138 | -------------------------------------------------------------------------------- /disc_ident.h: -------------------------------------------------------------------------------- 1 | int get_disc_id_version(char *id_out, char *version_out); 2 | -------------------------------------------------------------------------------- /exports.exp: -------------------------------------------------------------------------------- 1 | PSP_BEGIN_EXPORTS 2 | 3 | PSP_EXPORT_START(syslib, 0, 0x8000) 4 | PSP_EXPORT_FUNC(module_start) 5 | PSP_EXPORT_FUNC(module_stop) 6 | PSP_EXPORT_VAR(module_info) 7 | PSP_EXPORT_END 8 | 9 | PSP_EXPORT_START(GTRemasteredLib, 0, 0x4001) 10 | PSP_EXPORT_FUNC(sceCtrlReadBufferPositivePatched) 11 | PSP_EXPORT_FUNC(digital_to_analog_patched) 12 | PSP_EXPORT_FUNC(populate_car_digital_control_patched) 13 | PSP_EXPORT_FUNC(populate_car_analog_control_patched) 14 | PSP_EXPORT_END 15 | 16 | PSP_END_EXPORTS 17 | -------------------------------------------------------------------------------- /game_tweaks/README.md: -------------------------------------------------------------------------------- 1 | ### Game tweaks implemented in CWCheat codes 2 | 3 | - Wider fov __ 4 | - Default FOVs are bumper:33 cockpit:52.xx roof:35 follow:33, the code forces all fov to it's indicated value 5 | - "Disable Culling" introduced in https://github.com/hrydgard/ppsspp/pull/18572 in graphic settings speed hacks can remove most of the visible popping on the side of the screen, it is available on latest git builds, and should be available on release builds when 1.17 comes 6 | - Force racing line on/off 7 | - Useful when multiple players want different racing/driving line setting, or when one wants to toggle racing/driving line mid race 8 | - Break jackpot event to avoid music change from jackpot race 9 | - I didn't find precisly where a jackpot event in multiplayer race would change music, this only prevents music change by putting the event in a weird state 10 | - Whether a race is a jackpot race or not and the choosen player is only shown at the end of the race, on the race reward screen 11 | - Because the event is stuck in a weird state, the bottom right icon would stay on screen even if the race turns out to not be a jackpot race 12 | -------------------------------------------------------------------------------- /game_tweaks/UCAS40265.ini: -------------------------------------------------------------------------------- 1 | _S UCAS-40265// not tested, should work on v1.0 2 | 3 | _C0 break jackpot event to avoid music change 4 | _L 0xe00118c0 0x0000F382 5 | _L 0x20000F380 0x04c10033 6 | 7 | _C0 restore jackpot event 8 | _L 0xe00104c1 0x0000F382 9 | _L 0x20000F380 0x18c00033 10 | 11 | _C0 force racing line on 12 | _L 0xe0010000 0x004dd08c 13 | _L 0x2004dd08c 0x00000001 14 | 15 | _C0 force racing line off 16 | _L 0xe0010001 0x004dd08c 17 | _L 0x2004dd08c 0x00000000 18 | 19 | _C0 wider fov 50 20 | _L 0xE0030008 0x00122264 21 | _L 0x200122264 0x00000000 22 | _L 0x200122270 0x00000000 23 | _L 0x200122288 0x04410004 24 | _L 0xE0014248 0x10122278 25 | _L 0x200122278 0x3c014248 26 | _L 0xE0010000 0x1012227c 27 | _L 0x20012227c 0x34210000 28 | 29 | _C0 wider fov 60 30 | _L 0xE0030008 0x00122264 31 | _L 0x200122264 0x00000000 32 | _L 0x200122270 0x00000000 33 | _L 0x200122288 0x04410004 34 | _L 0xE0014270 0x10122278 35 | _L 0x200122278 0x3c014270 36 | _L 0xE0010000 0x1012227c 37 | _L 0x20012227c 0x34210000 38 | 39 | _C0 wider fov 70 40 | _L 0xE0030008 0x00122264 41 | _L 0x200122264 0x00000000 42 | _L 0x200122270 0x00000000 43 | _L 0x200122288 0x04410004 44 | _L 0xE001428c 0x10122278 45 | _L 0x200122278 0x3c01428c 46 | _L 0xE0010000 0x1012227c 47 | _L 0x20012227c 0x34210000 48 | 49 | _C0 wider fov 80 50 | _L 0xE0030008 0x00122264 51 | _L 0x200122264 0x00000000 52 | _L 0x200122270 0x00000000 53 | _L 0x200122288 0x04410004 54 | _L 0xE00142a0 0x10122278 55 | _L 0x200122278 0x3c0142a0 56 | _L 0xE0010000 0x1012227c 57 | _L 0x20012227c 0x34210000 58 | 59 | _C0 restore fov 60 | _L 0xE0050000 0x00122264 61 | _L 0x200122264 0x15020008 62 | _L 0x200122270 0x14400005 63 | _L 0x200122288 0x15020004 64 | _L 0x200122278 0x3c014251 65 | _L 0x20012227c 0x3421b9a7 66 | -------------------------------------------------------------------------------- /game_tweaks/UCES01245.ini: -------------------------------------------------------------------------------- 1 | _S UCES-01245// only tested on v2.0 2 | 3 | _C0 break jackpot event to avoid music change 4 | _L 0xE00118c0 0x0000F382 5 | _L 0x20000F380 0x04c10033 6 | 7 | _C0 restore jackpot event 8 | _L 0xE00104c1 0x0000F382 9 | _L 0x20000F380 0x18c00033 10 | 11 | _C0 force racing line on 12 | _L 0xE0010000 0x004DD20C 13 | _L 0x2004DD20C 0x00000001 14 | 15 | _C0 force racing line off 16 | _L 0xE0010001 0x004DD20C 17 | _L 0x2004DD20C 0x00000000 18 | 19 | _C0 wider fov 50 20 | _L 0xE0030008 0x00122264 21 | _L 0x200122264 0x00000000 22 | _L 0x200122270 0x00000000 23 | _L 0x200122288 0x04410004 24 | _L 0xE0014248 0x10122278 25 | _L 0x200122278 0x3c014248 26 | _L 0xE0010000 0x1012227c 27 | _L 0x20012227c 0x34210000 28 | 29 | _C0 wider fov 60 30 | _L 0xE0030008 0x00122264 31 | _L 0x200122264 0x00000000 32 | _L 0x200122270 0x00000000 33 | _L 0x200122288 0x04410004 34 | _L 0xE0014270 0x10122278 35 | _L 0x200122278 0x3c014270 36 | _L 0xE0010000 0x1012227c 37 | _L 0x20012227c 0x34210000 38 | 39 | _C0 wider fov 70 40 | _L 0xE0030008 0x00122264 41 | _L 0x200122264 0x00000000 42 | _L 0x200122270 0x00000000 43 | _L 0x200122288 0x04410004 44 | _L 0xE001428c 0x10122278 45 | _L 0x200122278 0x3c01428c 46 | _L 0xE0010000 0x1012227c 47 | _L 0x20012227c 0x34210000 48 | 49 | _C0 wider fov 80 50 | _L 0xE0030008 0x00122264 51 | _L 0x200122264 0x00000000 52 | _L 0x200122270 0x00000000 53 | _L 0x200122288 0x04410004 54 | _L 0xE00142a0 0x10122278 55 | _L 0x200122278 0x3c0142a0 56 | _L 0xE0010000 0x1012227c 57 | _L 0x20012227c 0x34210000 58 | 59 | _C0 restore fov 60 | _L 0xE0050000 0x00122264 61 | _L 0x200122264 0x15020008 62 | _L 0x200122270 0x14400005 63 | _L 0x200122288 0x15020004 64 | _L 0x200122278 0x3c014251 65 | _L 0x20012227c 0x3421b9a7 66 | -------------------------------------------------------------------------------- /game_tweaks/UCJS10100.ini: -------------------------------------------------------------------------------- 1 | _S UCJS-10100// not tested, should work with v1.01 2 | 3 | _C0 break jackpot event to avoid music change 4 | _L 0xe00118c0 0x0000F382 5 | _L 0x20000F380 0x04c10033 6 | 7 | _C0 restore jackpot event 8 | _L 0xe00104c1 0x0000F382 9 | _L 0x20000F380 0x18c00033 10 | 11 | _C0 force racing line on 12 | _L 0xe0010000 0x004dcb8c 13 | _L 0x2004dcb8c 0x00000001 14 | 15 | _C0 force racing line off 16 | _L 0xe0010001 0x004dcb8c 17 | _L 0x2004dcb8c 0x00000000 18 | 19 | _C0 wider fov 50 20 | _L 0xe0030008 0x00122248 21 | _L 0x200122248 0x00000000 22 | _L 0x200122254 0x00000000 23 | _L 0x20012226c 0x04410004 24 | _L 0xe0014248 0x1012225c 25 | _L 0x20012225c 0x3c014248 26 | _L 0xe0010000 0x10122260 27 | _L 0x200122260 0x34210000 28 | 29 | _C0 wider fov 60 30 | _L 0xe0030008 0x00122248 31 | _L 0x200122248 0x00000000 32 | _L 0x200122254 0x00000000 33 | _L 0x20012226c 0x04410004 34 | _L 0xe0014270 0x1012225c 35 | _L 0x20012225c 0x3c014270 36 | _L 0xe0010000 0x10122260 37 | _L 0x200122260 0x34210000 38 | 39 | _C0 wider fov 70 40 | _L 0xe0030008 0x00122248 41 | _L 0x200122248 0x00000000 42 | _L 0x200122254 0x00000000 43 | _L 0x20012226c 0x04410004 44 | _L 0xe001428c 0x1012225c 45 | _L 0x20012225c 0x3c01428c 46 | _L 0xe0010000 0x10122260 47 | _L 0x200122260 0x34210000 48 | 49 | _C0 wider fov 80 50 | _L 0xe0030008 0x00122248 51 | _L 0x200122248 0x00000000 52 | _L 0x200122254 0x00000000 53 | _L 0x20012226c 0x04410004 54 | _L 0xe00142a0 0x1012225c 55 | _L 0x20012225c 0x3c0142a0 56 | _L 0xe0010000 0x10122260 57 | _L 0x200122260 0x34210000 58 | 59 | _C0 restore fov 60 | _L 0xe0050000 0x00122248 61 | _L 0x200122248 0x15020008 62 | _L 0x200122254 0x14400005 63 | _L 0x20012226c 0x15020004 64 | _L 0x20012225c 0x3c014251 65 | _L 0x200122260 0x3421b9a7 66 | -------------------------------------------------------------------------------- /game_tweaks/UCUS98632.ini: -------------------------------------------------------------------------------- 1 | _S UCUS-98632// not tested, should work with v2.00 2 | 3 | _C0 break jackpot event to avoid music change 4 | _L 0xe00118c0 0x0000F382 5 | _L 0x20000F380 0x04c10033 6 | 7 | _C0 restore jackpot event 8 | _L 0xe00104c1 0x0000F382 9 | _L 0x20000F380 0x18c00033 10 | 11 | _C0 force racing line on 12 | _L 0xe0010000 0x004dd21c 13 | _L 0x2004dd21c 0x00000001 14 | 15 | _C0 force racing line off 16 | _L 0xe0010001 0x004dd21c 17 | _L 0x2004dd21c 0x00000000 18 | 19 | _C0 wider fov 50 20 | _L 0xe0030008 0x00122264 21 | _L 0x200122264 0x00000000 22 | _L 0x200122270 0x00000000 23 | _L 0x200122288 0x04410004 24 | _L 0xe0014248 0x10122278 25 | _L 0x200122278 0x3c014248 26 | _L 0xe0010000 0x1012227c 27 | _L 0x20012227c 0x34210000 28 | 29 | _C0 wider fov 60 30 | _L 0xe0030008 0x00122264 31 | _L 0x200122264 0x00000000 32 | _L 0x200122270 0x00000000 33 | _L 0x200122288 0x04410004 34 | _L 0xe0014270 0x10122278 35 | _L 0x200122278 0x3c014270 36 | _L 0xe0010000 0x1012227c 37 | _L 0x20012227c 0x34210000 38 | 39 | _C0 wider fov 70 40 | _L 0xe0030008 0x00122264 41 | _L 0x200122264 0x00000000 42 | _L 0x200122270 0x00000000 43 | _L 0x200122288 0x04410004 44 | _L 0xe001428c 0x10122278 45 | _L 0x200122278 0x3c01428c 46 | _L 0xe0010000 0x1012227c 47 | _L 0x20012227c 0x34210000 48 | 49 | _C0 wider fov 80 50 | _L 0xe0030008 0x00122264 51 | _L 0x200122264 0x00000000 52 | _L 0x200122270 0x00000000 53 | _L 0x200122288 0x04410004 54 | _L 0xe00142a0 0x10122278 55 | _L 0x200122278 0x3c0142a0 56 | _L 0xe0010000 0x1012227c 57 | _L 0x20012227c 0x34210000 58 | 59 | _C0 restore fov 60 | _L 0xe0050000 0x00122264 61 | _L 0x200122264 0x15020008 62 | _L 0x200122270 0x14400005 63 | _L 0x200122288 0x15020004 64 | _L 0x200122278 0x3c014251 65 | _L 0x20012227c 0x3421b9a7 66 | -------------------------------------------------------------------------------- /hooking.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sceKernelQuerySystemCall(void *function); 5 | 6 | u32 MakeSyscallStub(void *function) { 7 | SceUID block_id = sceKernelAllocPartitionMemory(PSP_MEMORY_PARTITION_USER, "", PSP_SMEM_High, 2 * sizeof(u32), NULL); 8 | u32 stub = (u32)sceKernelGetBlockHeadAddr(block_id); 9 | _sw(0x03E00008, stub); 10 | _sw(0x0000000C | (sceKernelQuerySystemCall(function) << 6), stub + 4); 11 | return stub; 12 | } 13 | -------------------------------------------------------------------------------- /hooking.h: -------------------------------------------------------------------------------- 1 | #ifndef _HOOKING_ 2 | #define _HOOKING_ 3 | #include "logging.h" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | u32 MakeSyscallStub(void *function); 10 | 11 | #define MAKE_JUMP(a, f) _sw(0x08000000 | (((u32)(f) & 0x0FFFFFFC) >> 2), a); 12 | 13 | #define GET_JUMP_TARGET(x) (0x80000000 | (((x) & 0x03FFFFFF) << 2)) 14 | 15 | u32 offset_digital_to_analog = 0; 16 | u32 offset_populate_car_digital_control = 0; 17 | u32 offset_populate_car_analog_control = 0; 18 | 19 | #define HIJACK_FUNCTION(a, f, ptr) \ 20 | { \ 21 | LOG("hijacking function at 0x%lx with 0x%lx", (u32)a, (u32)f); \ 22 | u32 _func_ = (u32)a; \ 23 | u32 _ff = (u32)f; \ 24 | int _interrupts = pspSdkDisableInterrupts(); \ 25 | sceKernelDcacheWritebackInvalidateAll(); \ 26 | if(!is_emulator){ \ 27 | _ff = MakeSyscallStub(f); \ 28 | } \ 29 | static u32 patch_buffer[3]; \ 30 | _sw(_lw(_func_), (u32)patch_buffer); \ 31 | _sw(_lw(_func_ + 4), (u32)patch_buffer + 8);\ 32 | MAKE_JUMP((u32)patch_buffer + 4, _func_ + 8); \ 33 | _sw(0x08000000 | (((u32)(_ff) >> 2) & 0x03FFFFFF), _func_); \ 34 | _sw(0, _func_ + 4); \ 35 | ptr = (void *)patch_buffer; \ 36 | sceKernelDcacheWritebackInvalidateAll(); \ 37 | sceKernelIcacheClearAll(); \ 38 | pspSdkEnableInterrupts(_interrupts); \ 39 | LOG("original instructions: 0x%lx 0x%lx", _lw((u32)patch_buffer), _lw((u32)patch_buffer + 8)); \ 40 | } 41 | 42 | // XXX ppsspp loading savestate reloads module imports and overwrites this kind of hooking in case HLE 43 | // syscall changed 44 | // https://github.com/hrydgard/ppsspp/blob/master/Core/HLE/sceKernelModule.cpp 45 | // if this kind of hooking on ppsspp cannot be avoided, repatch in a slow thread loop maybe, at least peek 46 | // can be used instead for this particular plugin 47 | 48 | // jacking JR_SYSCALL in ppsspp, so just save the two instructions, instead of seeking the target 49 | // also scan other modules for the same pattern and patch them if ppsspp 50 | // for real hw, go the jump target then attempt the more standard two instructions hijack 51 | // hopefully works with the static args loaded sceCtrl functions, at least referencing uofw and joysens 52 | #define HIJACK_SYSCALL_STUB(a, f, ptr) \ 53 | { \ 54 | LOG("hijacking syscall stub at 0x%lx with 0x%lx", (u32)a, (u32)f); \ 55 | u32 _func_ = (u32)a; \ 56 | u32 _ff = (u32)f; \ 57 | int _interrupts = pspSdkDisableInterrupts(); \ 58 | sceKernelDcacheWritebackInvalidateAll(); \ 59 | if(!is_emulator){ \ 60 | _func_ = GET_JUMP_TARGET(_lw(_func_)); \ 61 | } \ 62 | u32 _pattern[2]; \ 63 | _sw(_lw(_func_), (u32)_pattern); \ 64 | _sw(_lw(_func_ + 4), (u32)_pattern + 4); \ 65 | static u32 patch_buffer[3]; \ 66 | if(is_emulator){ \ 67 | _sw(_lw(_func_), (u32)patch_buffer); \ 68 | _sw(_lw(_func_ + 4), (u32)patch_buffer + 4); \ 69 | }else{ \ 70 | _sw(_lw(_func_), (u32)patch_buffer); \ 71 | _sw(_lw(_func_ + 4), (u32)patch_buffer + 8); \ 72 | MAKE_JUMP((u32)patch_buffer + 4, _func_ + 8); \ 73 | } \ 74 | _sw(0x08000000 | (((u32)(_ff) >> 2) & 0x03FFFFFF), _func_); \ 75 | _sw(0, _func_ + 4); \ 76 | ptr = (void *)patch_buffer; \ 77 | sceKernelDcacheWritebackInvalidateAll(); \ 78 | sceKernelIcacheClearAll(); \ 79 | pspSdkEnableInterrupts(_interrupts); \ 80 | if(!is_emulator){ \ 81 | LOG("real hardware mode, retargetting function 0x%lx", _func_); \ 82 | } \ 83 | LOG("original instructions: 0x%lx 0x%lx", _lw((u32)_pattern), _lw((u32)_pattern + 4)); \ 84 | if(is_emulator){ \ 85 | SceUID _modules[32]; \ 86 | static u32 _scan_cache[32] = {0}; \ 87 | SceKernelModuleInfo _info; \ 88 | int _i, _count = 0; \ 89 | if (sceKernelGetModuleIdList(_modules, sizeof(_modules), &_count) >= 0) { \ 90 | for (_i = 0; _i < _count; _i++) { \ 91 | if(_scan_cache[_i] != 0){ \ 92 | continue; \ 93 | } \ 94 | _info.size = sizeof(SceKernelModuleInfo); \ 95 | if (sceKernelQueryModuleInfo(_modules[_i], &_info) < 0) { \ 96 | continue; \ 97 | } \ 98 | if (strcmp(_info.name, MODULE_NAME) == 0) { \ 99 | continue; \ 100 | } \ 101 | LOG("scanning module %s in ppsspp mode", _info.name); \ 102 | LOG("info.text_addr: 0x%x info.text_size: 0x%x info.nsegment: 0x%x", _info.text_addr, _info.text_size, (int)_info.nsegment); \ 103 | u32 _j; \ 104 | for(_j = 0;_j < _info.nsegment; _j++){ \ 105 | LOG("info.segmentaddr[%ld]: 0x%x info.segmentsize[%ld]: 0x%x", _j, _info.segmentaddr[_j], _j, _info.segmentsize[_j]); \ 106 | } \ 107 | if(_info.text_size == 0){ \ 108 | if(_info.nsegment >= 1 && _info.segmentaddr[0] == _info.text_addr){ \ 109 | _info.text_size = _info.segmentsize[0]; \ 110 | } \ 111 | } \ 112 | for(_j = 0; _j < _info.text_size; _j+=4){ \ 113 | u32 _addr = _j + _info.text_addr; \ 114 | int _found = 0; \ 115 | _interrupts = pspSdkDisableInterrupts(); \ 116 | if(_lw((u32)_pattern) == _lw(_addr + 0) && _lw((u32)_pattern + 4) == _lw(_addr + 4)){ \ 117 | _scan_cache[_i] = _addr; \ 118 | _found = 1; \ 119 | } \ 120 | pspSdkEnableInterrupts(_interrupts); \ 121 | if(_found){ \ 122 | continue; \ 123 | } \ 124 | } \ 125 | } \ 126 | for(_i = 0; _i < _count; _i++){ \ 127 | u32 _addr = _scan_cache[_i]; \ 128 | if(_addr != 0){ \ 129 | int _patched = 0; \ 130 | _interrupts = pspSdkDisableInterrupts(); \ 131 | if(_lw((u32)_pattern) == _lw(_addr + 0) && _lw((u32)_pattern + 4) == _lw(_addr + 4)){ \ 132 | _sw(0x08000000 | (((u32)(_ff) >> 2) & 0x03FFFFFF), _addr); \ 133 | _sw(0, _addr + 4); \ 134 | _patched = 1; \ 135 | sceKernelIcacheClearAll(); \ 136 | } \ 137 | pspSdkEnableInterrupts(_interrupts); \ 138 | if(_patched){ \ 139 | LOG("found instruction pattern 0x%lx 0x%lx at 0x%lx, patching", _pattern[0], _pattern[1], _addr); \ 140 | } \ 141 | } \ 142 | } \ 143 | } \ 144 | } \ 145 | } 146 | 147 | #endif 148 | -------------------------------------------------------------------------------- /logging.h: -------------------------------------------------------------------------------- 1 | #ifndef _LOGGING_ 2 | #define _LOGGING_ 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include "common.h" 9 | 10 | // is there a flush..? or the non async version always syncs? 11 | #if DEBUG_LOG 12 | static int logfd = -1; 13 | #define LOG(...) {\ 14 | if(logfd < 0){ \ 15 | logfd = sceIoOpen("ms0:/PSP/" MODULE_NAME ".log", PSP_O_WRONLY|PSP_O_CREAT|PSP_O_APPEND, 0777); \ 16 | if(logfd < 0){ \ 17 | logfd = sceIoOpen("ef0:/PSP/" MODULE_NAME ".log", PSP_O_WRONLY|PSP_O_CREAT|PSP_O_APPEND, 0777); \ 18 | } \ 19 | } \ 20 | char _log_buf[128]; \ 21 | int _log_len = sprintf(_log_buf, __VA_ARGS__); \ 22 | _log_buf[_log_len] = '\n'; \ 23 | _log_len++; \ 24 | if(logfd >= 0){ \ 25 | if(_log_len != 0){ \ 26 | sceIoWrite(logfd, _log_buf, _log_len); \ 27 | } \ 28 | sceIoClose(logfd); \ 29 | logfd = -1; \ 30 | }else{ \ 31 | sceIoWrite(2, _log_buf, _log_len); \ 32 | } \ 33 | } 34 | #else // DEBUG_LOG 35 | #define LOG(...) 36 | #endif // DEBUG_LOG 37 | #if VERBOSE 38 | #define LOG_VERBOSE(...) LOG(__VA_ARGS__) 39 | #else // VERBOSE 40 | #define LOG_VERBOSE(...) 41 | #endif // VERBOSE 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /m33_sdk_prebuilt/README.txt: -------------------------------------------------------------------------------- 1 | obtained from https://gbatemp.net/download/custom-firmware-cfw-4-01-m33.37679/ 2 | -------------------------------------------------------------------------------- /m33_sdk_prebuilt/include/kubridge.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/m33_sdk_prebuilt/include/kubridge.h -------------------------------------------------------------------------------- /m33_sdk_prebuilt/include/pspinit.h: -------------------------------------------------------------------------------- 1 | #ifndef __PSPINIT_H__ 2 | 3 | #define __PSPINIT_H__ 4 | 5 | enum PSPBootFrom 6 | { 7 | PSP_BOOT_FLASH = 0, /* ? */ 8 | PSP_BOOT_DISC = 0x20, 9 | PSP_BOOT_MS = 0x40, 10 | }; 11 | 12 | enum PSPInitApitype 13 | { 14 | PSP_INIT_APITYPE_DISC = 0x120, 15 | PSP_INIT_APITYPE_DISC_UPDATER = 0x121, 16 | PSP_INIT_APITYPE_MS1 = 0x140, 17 | PSP_INIT_APITYPE_MS2 = 0x141, 18 | PSP_INIT_APITYPE_MS3 = 0x142, 19 | PSP_INIT_APITYPE_MS4 = 0x143, 20 | PSP_INIT_APITYPE_MS5 = 0x144, 21 | PSP_INIT_APITYPE_VSH1 = 0x210, /* ExitGame */ 22 | PSP_INIT_APITYPE_VSH2 = 0x220, /* ExitVSH */ 23 | }; 24 | 25 | enum PSPKeyConfig 26 | { 27 | PSP_INIT_KEYCONFIG_VSH = 0x100, 28 | PSP_INIT_KEYCONFIG_GAME = 0x200, 29 | PSP_INIT_KEYCONFIG_POPS = 0x300, 30 | }; 31 | 32 | /** 33 | * Gets the api type 34 | * 35 | * @returns the api type in which the system has booted 36 | */ 37 | int sceKernelInitApitype(); 38 | 39 | /** 40 | * Gets the filename of the executable to be launched after all modules of the api. 41 | * 42 | * @returns filename of executable or NULL if no executable found. 43 | */ 44 | char *sceKernelInitFileName(); 45 | 46 | /** 47 | * 48 | * Gets the device in which the application was launched. 49 | * 50 | * @returns the device code, one of PSPBootFrom values. 51 | */ 52 | int sceKernelBootFrom(); 53 | 54 | /** 55 | * Get the key configuration in which the system has booted. 56 | * 57 | * @returns the key configuration code, one of PSPKeyConfig values 58 | */ 59 | int InitForKernel_7233B5BC(); 60 | 61 | #define sceKernelInitKeyConfig InitForKernel_7233B5BC 62 | 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /m33_sdk_prebuilt/include/psploadcore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PSP Software Development Kit - http://www.pspdev.org 3 | * ----------------------------------------------------------------------- 4 | * Licensed under the BSD license, see LICENSE in PSPSDK root for details. 5 | * 6 | * psploadcore.h - Interface to LoadCoreForKernel. 7 | * 8 | * Copyright (c) 2005 Marcus R. Brown 9 | * Copyright (c) 2005 James Forshaw 10 | * Copyright (c) 2005 John Kelley 11 | * 12 | * $Id: psploadcore.h 1095 2005-09-27 21:02:16Z jim $ 13 | */ 14 | 15 | #ifndef PSPLOADCORE_H 16 | #define PSPLOADCORE_H 17 | 18 | #include 19 | 20 | /** @defgroup LoadCore Interface to the LoadCoreForKernel library. 21 | */ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** @addtogroup LoadCore Interface to the LoadCoreForKernel library. */ 28 | /*@{*/ 29 | 30 | /** Describes a module. This structure could change in future firmware revisions. */ 31 | typedef struct SceModule { 32 | struct SceModule *next; 33 | unsigned short attribute; 34 | unsigned char version[2]; 35 | char modname[27]; 36 | char terminal; 37 | unsigned int unknown1; 38 | unsigned int unknown2; 39 | SceUID modid; 40 | unsigned int unknown3[4]; 41 | void * ent_top; 42 | unsigned int ent_size; 43 | void * stub_top; 44 | unsigned int stub_size; 45 | unsigned int unknown4[4]; 46 | unsigned int entry_addr; 47 | unsigned int gp_value; 48 | unsigned int text_addr; 49 | unsigned int text_size; 50 | unsigned int data_size; 51 | unsigned int bss_size; 52 | unsigned int nsegment; 53 | unsigned int segmentaddr[4]; 54 | unsigned int segmentsize[4]; 55 | } SceModule; 56 | 57 | // For 1.50+ 58 | 59 | typedef struct SceModule2 60 | { 61 | struct SceModule *next; // 0 62 | u16 attribute; // 4 63 | u8 version[2]; // 6 64 | char modname[27]; // 8 65 | char terminal; // 0x23 66 | char mod_state; // 0x24 67 | char unk1; // 0x25 68 | char unk2[2]; // 0x26 69 | u32 unk3; // 0x28 70 | SceUID modid; // 0x2C 71 | u32 unk4; // 0x30 72 | SceUID mem_id; // 0x34 73 | u32 mpid_text; // 0x38 74 | u32 mpid_data; // 0x3C 75 | void * ent_top; // 0x40 76 | unsigned int ent_size; // 0x44 77 | void * stub_top; // 0x48 78 | u32 stub_size; // 0x4C 79 | u32 entry_addr_; // 0x50 80 | u32 unk5[4]; // 0x54 81 | u32 entry_addr; // 0x64 82 | u32 gp_value; // 0x68 83 | u32 text_addr; // 0x6C 84 | u32 text_size; // 0x70 85 | u32 data_size; // 0x74 86 | u32 bss_size; // 0x78 87 | u32 nsegment; // 0x7C 88 | u32 segmentaddr[4]; // 0x80 89 | u32 segmentsize[4]; // 0x90 90 | } SceModule2; 91 | 92 | /** Defines a library and its exported functions and variables. Use the len 93 | member to determine the real size of the table (size = len * 4). */ 94 | typedef struct SceLibraryEntryTable { 95 | /**The library's name. */ 96 | const char * libname; 97 | /** Library version. */ 98 | unsigned char version[2]; 99 | /** Library attributes. */ 100 | unsigned short attribute; 101 | /** Length of this entry table in 32-bit WORDs. */ 102 | unsigned char len; 103 | /** The number of variables exported by the library. */ 104 | unsigned char vstubcount; 105 | /** The number of functions exported by the library. */ 106 | unsigned short stubcount; 107 | /** Pointer to the entry table; an array of NIDs followed by 108 | pointers to functions and variables. */ 109 | void * entrytable; 110 | } SceLibraryEntryTable; 111 | 112 | /** Specifies a library and a set of imports from that library. Use the len 113 | member to determine the real size of the table (size = len * 4). */ 114 | typedef struct SceLibraryStubTable { 115 | /* The name of the library we're importing from. */ 116 | const char * libname; 117 | /** Minimum required version of the library we want to import. */ 118 | unsigned char version[2]; 119 | /* Import attributes. */ 120 | unsigned short attribute; 121 | /** Length of this stub table in 32-bit WORDs. */ 122 | unsigned char len; 123 | /** The number of variables imported from the library. */ 124 | unsigned char vstubcount; 125 | /** The number of functions imported from the library. */ 126 | unsigned short stubcount; 127 | /** Pointer to an array of NIDs. */ 128 | unsigned int * nidtable; 129 | /** Pointer to the imported function stubs. */ 130 | void * stubtable; 131 | /** Pointer to the imported variable stubs. */ 132 | void * vstubtable; 133 | } SceLibraryStubTable; 134 | 135 | 136 | /** 137 | * Find a module by it's name. 138 | * 139 | * @param modname - The name of the module. 140 | * 141 | * @returns Pointer to the ::SceModule structure if found, otherwise NULL. 142 | */ 143 | //SceModule * sceKernelFindModuleByName(const char *modname); 144 | SceModule2 *sceKernelFindModuleByName(const char *modname); 145 | 146 | /** 147 | * Find a module from an address. 148 | * 149 | * @param addr - Address somewhere within the module. 150 | * 151 | * @returns Pointer to the ::SceModule structure if found, otherwise NULL. 152 | */ 153 | //SceModule * sceKernelFindModuleByAddress(unsigned int addr); 154 | SceModule2 *sceKernelFindModuleByAddress(unsigned int addr); 155 | 156 | /** 157 | * Find a module by it's UID. 158 | * 159 | * @param modid - The UID of the module. 160 | * 161 | * @returns Pointer to the ::SceModule structure if found, otherwise NULL. 162 | */ 163 | //SceModule * sceKernelFindModuleByUID(SceUID modid); 164 | SceModule2 *sceKernelFindModuleByUID(SceUID modid); 165 | 166 | 167 | /** 168 | * Return the count of loaded modules. 169 | * 170 | * @returns The count of loaded modules. 171 | */ 172 | int sceKernelModuleCount(void); 173 | 174 | /** 175 | * Invalidate the CPU's instruction cache. 176 | */ 177 | void sceKernelIcacheClearAll(void); 178 | 179 | /*@}*/ 180 | 181 | #ifdef __cplusplus 182 | } 183 | #endif 184 | 185 | #endif /* PSPLOADCORE_H */ 186 | -------------------------------------------------------------------------------- /m33_sdk_prebuilt/include/psploadexec_kernel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File for the kernel exports of LoadExec 3 | */ 4 | 5 | #ifndef __LOADEXEC_KERNEL__ 6 | #define __LOADEXEC_KERNEL__ 7 | 8 | #include 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /** Structure for LoadExecVSH* functions */ 15 | struct SceKernelLoadExecVSHParam { 16 | /** Size of the structure in bytes */ 17 | SceSize size; 18 | /** Size of the arguments string */ 19 | SceSize args; 20 | /** Pointer to the arguments strings */ 21 | void * argp; 22 | /** The key, usually "game", "updater" or "vsh" */ 23 | const char * key; 24 | /** The size of the vshmain arguments */ 25 | u32 vshmain_args_size; 26 | /** vshmain arguments that will be passed to vshmain after the program has exited */ 27 | void *vshmain_args; 28 | /** "/kd/pspbtcnf_game.txt" or "/kd/pspbtcnf.txt" if not supplied (max. 256 chars) */ 29 | char *configfile; 30 | /** An unknown string (max. 256 chars) probably used in 2nd stage of loadexec */ 31 | u32 unk4; 32 | /** unknown flag default value = 0x10000 */ 33 | u32 unk5; 34 | }; 35 | 36 | /** 37 | * Executes a new executable from a buffer. 38 | * 39 | * @param bufsize - Size in bytes of the buffer pointed by buf. 40 | * @param buf - Pointer to a buffer containing the module to execute. 41 | * @param param - Pointer to a ::SceKernelLoadExecParam structure, or NULL. 42 | * 43 | * @returns < 0 on some errors. 44 | */ 45 | int sceKernelLoadExecBufferPlain(SceSize bufsize, void *buf, struct SceKernelLoadExecParam *param); 46 | 47 | /** 48 | * Restart the vsh. 49 | * 50 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL 51 | * 52 | * @returns < 0 on some errors. 53 | * 54 | * @note - when called in game mode it will have the same effect that sceKernelExitGame 55 | * 56 | */ 57 | int sceKernelExitVSHVSH(struct SceKernelLoadExecVSHParam *param); 58 | 59 | /** 60 | * Restart the vsh (to be used by a kernel module) 61 | * 62 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL 63 | * 64 | * @returns < 0 on some errors. 65 | * 66 | * @note - when called in game mode it will have the same effect that sceKernelExitGame 67 | * @note2: available since firmware 2.00. 68 | */ 69 | int sceKernelExitVSHKernel(struct SceKernelLoadExecVSHParam *param); 70 | 71 | /** 72 | * Executes a new executable from a disc. 73 | * It is the function used by the firmware to execute the EBOOT.BIN from a disc. 74 | * 75 | * @param file - The file to execute. 76 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 77 | * 78 | * @returns < 0 on some errors. 79 | */ 80 | int sceKernelLoadExecVSHDisc(const char *file, struct SceKernelLoadExecVSHParam *param); 81 | 82 | /** 83 | * Executes a new executable from a disc. 84 | * It is the function used by the firmware to execute an updater from a disc. 85 | * 86 | * @param file - The file to execute. 87 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 88 | * 89 | * @returns < 0 on some errors. 90 | */ 91 | int sceKernelLoadExecVSHDiscUpdater(const char *file, struct SceKernelLoadExecVSHParam *param); 92 | 93 | /** 94 | * Executes a new executable from a memory stick. 95 | * It is the function used by the firmware to execute an updater from a memory stick. 96 | * 97 | * @param file - The file to execute. 98 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 99 | * 100 | * @returns < 0 on some errors. 101 | */ 102 | int sceKernelLoadExecVSHMs1(const char *file, struct SceKernelLoadExecVSHParam *param); 103 | 104 | /** 105 | * Executes a new executable from a memory stick. 106 | * It is the function used by the firmware to execute games (and homebrew :P) from a memory stick. 107 | * 108 | * @param file - The file to execute. 109 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 110 | * 111 | * @returns < 0 on some errors. 112 | */ 113 | int sceKernelLoadExecVSHMs2(const char *file, struct SceKernelLoadExecVSHParam *param); 114 | 115 | /** 116 | * Executes a new executable from a memory stick. 117 | * It is the function used by the firmware to execute ... ? 118 | * 119 | * @param file - The file to execute. 120 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 121 | * 122 | * @returns < 0 on some errors. 123 | */ 124 | int sceKernelLoadExecVSHMs3(const char *file, struct SceKernelLoadExecVSHParam *param); 125 | 126 | /*** 127 | * Executes a new executable from a memory stick. 128 | * It is the function used by the firmware to execute psx games 129 | * 130 | * @param file - The file to execute. 131 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 132 | * 133 | * @returns < 0 on some errors. 134 | * @note - Available since firmware 3.00 135 | */ 136 | int sceKernelLoadExecVSHMs4(const char *file, struct SceKernelLoadExecVSHParam *param); 137 | 138 | #ifdef __cplusplus 139 | } 140 | #endif 141 | 142 | #endif 143 | -------------------------------------------------------------------------------- /m33_sdk_prebuilt/include/pspmodulemgr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PSP Software Development Kit - http://www.pspdev.org 3 | * ----------------------------------------------------------------------- 4 | * Licensed under the BSD license, see LICENSE in PSPSDK root for details. 5 | * 6 | * pspmodulemgr.h - Prototypes to manage modules. 7 | * 8 | * Copyright (c) 2005 Marcus R. Brown 9 | * Copyright (c) 2005 James Forshaw 10 | * Copyright (c) 2005 John Kelley 11 | * 12 | * $Id: pspmodulemgr.h 1148 2005-10-12 19:08:27Z tyranid $ 13 | */ 14 | 15 | /* Note: Some of the structures, types, and definitions in this file were 16 | extrapolated from symbolic debugging information found in the Japanese 17 | version of Puzzle Bobble. */ 18 | 19 | #ifndef __MODLOAD_H__ 20 | #define __MODLOAD_H__ 21 | 22 | #include 23 | 24 | /** @defgroup ModuleMgr Module Manager Library 25 | * This module contains the imports for the kernel's module management routines. 26 | */ 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | /** @addtogroup ModuleMgr Module Manager Library */ 33 | /*@{*/ 34 | 35 | #define PSP_MEMORY_PARTITION_KERNEL 1 36 | #define PSP_MEMORY_PARTITION_USER 2 37 | 38 | typedef struct SceKernelLMOption { 39 | SceSize size; 40 | SceUID mpidtext; 41 | SceUID mpiddata; 42 | unsigned int flags; 43 | char position; 44 | char access; 45 | char creserved[2]; 46 | } SceKernelLMOption; 47 | 48 | typedef struct SceKernelSMOption { 49 | SceSize size; 50 | SceUID mpidstack; 51 | SceSize stacksize; 52 | int priority; 53 | unsigned int attribute; 54 | } SceKernelSMOption; 55 | 56 | 57 | /** 58 | * Load a module. 59 | * @note This function restricts where it can load from (such as from flash0) 60 | * unless you call it in kernel mode. It also must be called from a thread. 61 | * 62 | * @param path - The path to the module to load. 63 | * @param flags - Unused, always 0 . 64 | * @param option - Pointer to a mod_param_t structure. Can be NULL. 65 | * 66 | * @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes. 67 | */ 68 | SceUID sceKernelLoadModule(const char *path, int flags, SceKernelLMOption *option); 69 | 70 | /** 71 | * Load a module from MS. 72 | * @note This function restricts what it can load, e.g. it wont load plain executables. 73 | * 74 | * @param path - The path to the module to load. 75 | * @param flags - Unused, set to 0. 76 | * @param option - Pointer to a mod_param_t structure. Can be NULL. 77 | * 78 | * @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes. 79 | */ 80 | SceUID sceKernelLoadModuleMs(const char *path, int flags, SceKernelLMOption *option); 81 | 82 | /** 83 | * Load a module from the given file UID. 84 | * 85 | * @param fid - The module's file UID. 86 | * @param flags - Unused, always 0. 87 | * @param option - Pointer to an optional ::SceKernelLMOption structure. 88 | * 89 | * @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes. 90 | */ 91 | SceUID sceKernelLoadModuleByID(SceUID fid, int flags, SceKernelLMOption *option); 92 | 93 | /** 94 | * Load a module from a buffer using the USB/WLAN API. 95 | * 96 | * Can only be called from kernel mode, or from a thread that has attributes of 0xa0000000. 97 | * 98 | * @param bufsize - Size (in bytes) of the buffer pointed to by buf. 99 | * @param buf - Pointer to a buffer containing the module to load. The buffer must reside at an 100 | * address that is a multiple to 64 bytes. 101 | * @param flags - Unused, always 0. 102 | * @param option - Pointer to an optional ::SceKernelLMOption structure. 103 | * 104 | * @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes. 105 | */ 106 | SceUID sceKernelLoadModuleBufferUsbWlan(SceSize bufsize, void *buf, int flags, SceKernelLMOption *option); 107 | 108 | /** 109 | * Start a loaded module. 110 | * 111 | * @param modid - The ID of the module returned from LoadModule. 112 | * @param argsize - Length of the args. 113 | * @param argp - A pointer to the arguments to the module. 114 | * @param status - Returns the status of the start. 115 | * @param option - Pointer to an optional ::SceKernelSMOption structure. 116 | * 117 | * @return ??? on success, otherwise one of ::PspKernelErrorCodes. 118 | */ 119 | int sceKernelStartModule(SceUID modid, SceSize argsize, void *argp, int *status, SceKernelSMOption *option); 120 | 121 | /** 122 | * Stop a running module. 123 | * 124 | * @param modid - The UID of the module to stop. 125 | * @param argsize - The length of the arguments pointed to by argp. 126 | * @param argp - Pointer to arguments to pass to the module's module_stop() routine. 127 | * @param status - Return value of the module's module_stop() routine. 128 | * @param option - Pointer to an optional ::SceKernelSMOption structure. 129 | * 130 | * @returns ??? on success, otherwise one of ::PspKernelErrorCodes. 131 | */ 132 | int sceKernelStopModule(SceUID modid, SceSize argsize, void *argp, int *status, SceKernelSMOption *option); 133 | 134 | /** 135 | * Unload a stopped module. 136 | * 137 | * @param modid - The UID of the module to unload. 138 | * 139 | * @returns ??? on success, otherwise one of ::PspKernelErrorCodes. 140 | */ 141 | int sceKernelUnloadModule(SceUID modid); 142 | 143 | /** 144 | * Stop and unload the current module. 145 | * 146 | * @param unknown - Unknown (I've seen 1 passed). 147 | * @param argsize - Size (in bytes) of the arguments that will be passed to module_stop(). 148 | * @param argp - Pointer to arguments that will be passed to module_stop(). 149 | * 150 | * @return ??? on success, otherwise one of ::PspKernelErrorCodes. 151 | */ 152 | int sceKernelSelfStopUnloadModule(int unknown, SceSize argsize, void *argp); 153 | 154 | /** 155 | * Stop and unload the current module. 156 | * 157 | * @param argsize - Size (in bytes) of the arguments that will be passed to module_stop(). 158 | * @param argp - Poitner to arguments that will be passed to module_stop(). 159 | * @param status - Return value from module_stop(). 160 | * @param option - Pointer to an optional ::SceKernelSMOption structure. 161 | * 162 | * @returns ??? on success, otherwise one of ::PspKernelErrorCodes. 163 | */ 164 | int sceKernelStopUnloadSelfModule(SceSize argsize, void *argp, int *status, SceKernelSMOption *option); 165 | 166 | 167 | typedef struct SceKernelModuleInfo { 168 | SceSize size; 169 | char nsegment; 170 | char reserved[3]; 171 | int segmentaddr[4]; 172 | int segmentsize[4]; 173 | unsigned int entry_addr; 174 | unsigned int gp_value; 175 | unsigned int text_addr; 176 | unsigned int text_size; 177 | unsigned int data_size; 178 | unsigned int bss_size; 179 | /* The following is only available in the v1.5 firmware and above, 180 | but as sceKernelQueryModuleInfo is broken in v1.0 is doesn't matter ;) */ 181 | unsigned short attribute; 182 | unsigned char version[2]; 183 | char name[28]; 184 | } SceKernelModuleInfo; 185 | 186 | /** 187 | * Query the information about a loaded module from its UID. 188 | * @note This fails on v1.0 firmware (and even it worked has a limited structure) 189 | * so if you want to be compatible with both 1.5 and 1.0 (and you are running in 190 | * kernel mode) then call this function first then ::pspSdkQueryModuleInfoV1 191 | * if it fails, or make separate v1 and v1.5+ builds. 192 | * 193 | * @param modid - The UID of the loaded module. 194 | * @param info - Pointer to a ::SceKernelModuleInfo structure. 195 | * 196 | * @return 0 on success, otherwise one of ::PspKernelErrorCodes. 197 | */ 198 | int sceKernelQueryModuleInfo(SceUID modid, SceKernelModuleInfo *info); 199 | 200 | /** 201 | * Get a list of module IDs. NOTE: This is only available on 1.5 firmware 202 | * and above. For V1 use ::pspSdkGetModuleIdList. 203 | * 204 | * @param readbuf - Buffer to store the module list. 205 | * @param readbufsize - Number of elements in the readbuffer. 206 | * @param idcount - Returns the number of module ids 207 | * 208 | * @return >= 0 on success 209 | */ 210 | int sceKernelGetModuleIdList(SceUID *readbuf, int readbufsize, int *idcount); 211 | 212 | /** 213 | * Load a module protected by DRM... 214 | * 215 | * @param path - The path to the module to load. 216 | * @param flags - Unused, always 0 . 217 | * @param option - Pointer to a mod_param_t structure. Can be NULL. 218 | * 219 | * @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes. 220 | */ 221 | SceUID ModuleMgrForUser_FEF27DC1(const char *path, int flags, SceKernelLMOption *option); 222 | 223 | #define sceKernelLoadModuleDNAS ModuleMgrForUser_FEF27DC1 224 | 225 | /** 226 | * Stop and unload the current module with the specified exit status code 227 | * 228 | * @param exitcode - The exitcode for the module 229 | * @param argsize - Size (in bytes) of the arguments that will be passed to module_stop(). 230 | * @param argp - Poitner to arguments that will be passed to module_stop(). 231 | * @param status - Return value from module_stop(). 232 | * @param option - Pointer to an optional ::SceKernelSMOption structure. 233 | * 234 | * @returns ??? on success, otherwise one of ::PspKernelErrorCodes. 235 | */ 236 | int ModuleMgrForUser_8F2DF740(int exitcode, SceSize argsize, void *argp, int *status, SceKernelSMOption *option); 237 | 238 | #define sceKernelStopUnloadSelfModuleWithStatus ModuleMgrForUser_8F2DF740 239 | 240 | /*@}*/ 241 | 242 | #ifdef __cplusplus 243 | } 244 | #endif 245 | 246 | #endif 247 | -------------------------------------------------------------------------------- /m33_sdk_prebuilt/include/pspmodulemgr_kernel.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/m33_sdk_prebuilt/include/pspmodulemgr_kernel.h -------------------------------------------------------------------------------- /m33_sdk_prebuilt/include/pspsysmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PSP Software Development Kit - http://www.pspdev.org 3 | * ----------------------------------------------------------------------- 4 | * Licensed under the BSD license, see LICENSE in PSPSDK root for details. 5 | * 6 | * pspsysmem.h - Interface to the system memory manager. 7 | * 8 | * Copyright (c) 2005 Marcus R. Brown 9 | * 10 | * $Id: pspsysmem.h 1961 2006-07-04 04:14:56Z jim $ 11 | */ 12 | 13 | /* Note: Some of the structures, types, and definitions in this file were 14 | extrapolated from symbolic debugging information found in the Japanese 15 | version of Puzzle Bobble. */ 16 | 17 | #ifndef PSPSYSMEM_H 18 | #define PSPSYSMEM_H 19 | 20 | #include 21 | 22 | /** @defgroup SysMem System Memory Manager 23 | * This module contains routines to manage heaps of memory. 24 | */ 25 | 26 | /** @addtogroup SysMem System Memory Manager */ 27 | /*@{*/ 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /** Specifies the type of allocation used for memory blocks. */ 34 | enum PspSysMemBlockTypes { 35 | /** Allocate from the lowest available address. */ 36 | PSP_SMEM_Low = 0, 37 | /** Allocate from the highest available address. */ 38 | PSP_SMEM_High, 39 | /** Allocate from the specified address. */ 40 | PSP_SMEM_Addr 41 | }; 42 | 43 | typedef int SceKernelSysMemAlloc_t; 44 | 45 | /** 46 | * Allocate a memory block from a memory partition. 47 | * 48 | * @param partitionid - The UID of the partition to allocate from. 49 | * @param name - Name assigned to the new block. 50 | * @param type - Specifies how the block is allocated within the partition. One of ::PspSysMemBlockTypes. 51 | * @param size - Size of the memory block, in bytes. 52 | * @param addr - If type is PSP_SMEM_Addr, then addr specifies the lowest address allocate the block from. 53 | * 54 | * @returns The UID of the new block, or if less than 0 an error. 55 | */ 56 | SceUID sceKernelAllocPartitionMemory(SceUID partitionid, const char *name, int type, SceSize size, void *addr); 57 | 58 | /** 59 | * Free a memory block allocated with ::sceKernelAllocPartitionMemory. 60 | * 61 | * @param blockid - UID of the block to free. 62 | * 63 | * @returns ? on success, less than 0 on error. 64 | */ 65 | int sceKernelFreePartitionMemory(SceUID blockid); 66 | 67 | /** 68 | * Get the address of a memory block. 69 | * 70 | * @param blockid - UID of the memory block. 71 | * 72 | * @returns The lowest address belonging to the memory block. 73 | */ 74 | void * sceKernelGetBlockHeadAddr(SceUID blockid); 75 | 76 | /** 77 | * Get the total amount of free memory. 78 | * 79 | * @returns The total amount of free memory, in bytes. 80 | */ 81 | SceSize sceKernelTotalFreeMemSize(void); 82 | 83 | /** 84 | * Get the size of the largest free memory block. 85 | * 86 | * @returns The size of the largest free memory block, in bytes. 87 | */ 88 | SceSize sceKernelMaxFreeMemSize(void); 89 | 90 | /** 91 | * Get the firmware version. 92 | * 93 | * @returns The firmware version. 94 | * 0x01000300 on v1.00 unit, 95 | * 0x01050001 on v1.50 unit, 96 | * 0x01050100 on v1.51 unit, 97 | * 0x01050200 on v1.52 unit, 98 | * 0x02000010 on v2.00/v2.01 unit, 99 | * 0x02050010 on v2.50 unit, 100 | * 0x02060010 on v2.60 unit, 101 | * 0x02070010 on v2.70 unit, 102 | * 0x02070110 on v2.71 unit. 103 | */ 104 | int sceKernelDevkitVersion(void); 105 | 106 | /** 107 | * 108 | * Set the SDK version of the current application. 109 | * All licensed games seem to set this value in the crt0 110 | * 111 | * @param sdkversion - The sdkversion to set (e.g.: 0x02070110 in applicationc compiled for firmware 2.71) 112 | * 113 | * @returns 0 114 | */ 115 | int sceKernelSetCompiledSdkVersion(int sdkversion); 116 | 117 | /** 118 | * 119 | * Get the SDK version of the current application, previously set with sceKernelSetCompiledSdkVersion 120 | * 121 | * @returns The sdk version 122 | */ 123 | int sceKernelGetCompiledSdkVersion(void); 124 | 125 | /** 126 | * 127 | * Set the compiler version of the current application. 128 | * All licensed games seem to set this value in the crt0 129 | * 130 | * @param version - The compiler version to set 131 | * 132 | * @returns 0 133 | */ 134 | int sceKernelSetCompilerVersion(int version); 135 | 136 | /** 137 | * 138 | * Get the compiler version of the current application, previously set with sceKernelSetCompilerVersion 139 | * 140 | * @returns The compiler version 141 | */ 142 | int sceKernelGetCompilerVersion(void); 143 | 144 | 145 | #ifdef __cplusplus 146 | } 147 | #endif 148 | 149 | /*@}*/ 150 | 151 | #endif /* PSPSYSMEM_H */ 152 | -------------------------------------------------------------------------------- /m33_sdk_prebuilt/include/pspsysmem_kernel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PSP Software Development Kit - http://www.pspdev.org 3 | * ----------------------------------------------------------------------- 4 | * Licensed under the BSD license, see LICENSE in PSPSDK root for details. 5 | * 6 | * pspsysmem_kernel.h - Interface to the system memory manager (kernel). 7 | * 8 | * Copyright (c) 2005 James F. 9 | * 10 | * $Id: pspsysmem.h 1095 2005-09-27 21:02:16Z jim $ 11 | */ 12 | 13 | /* Note: Some of the structures, types, and definitions in this file were 14 | extrapolated from symbolic debugging information found in the Japanese 15 | version of Puzzle Bobble. */ 16 | 17 | #ifndef PSPSYSMEMKERNEL_H 18 | #define PSPSYSMEMKERNEL_H 19 | 20 | #include 21 | #include 22 | 23 | /** @defgroup SysMemKern System Memory Manager Kernel 24 | * This module contains routines to manage heaps of memory. 25 | */ 26 | 27 | /** @addtogroup SysMemKern System Memory Manager Kernel */ 28 | /*@{*/ 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | typedef struct _PspSysmemPartitionInfo 35 | { 36 | SceSize size; 37 | unsigned int startaddr; 38 | unsigned int memsize; 39 | unsigned int attr; 40 | } PspSysmemPartitionInfo; 41 | 42 | enum PspModel 43 | { 44 | PSP_MODEL_STANDARD = 0, 45 | PSP_MODEL_SLIM_AND_LITE = 1 46 | }; 47 | 48 | /** 49 | * Query the parition information 50 | * 51 | * @param pid - The partition id 52 | * @param info - Pointer to the ::PspSysmemPartitionInfo structure 53 | * 54 | * @returns 0 on success. 55 | */ 56 | int sceKernelQueryMemoryPartitionInfo(int pid, PspSysmemPartitionInfo *info); 57 | 58 | /** 59 | * Get the total amount of free memory. 60 | * 61 | * @param pid - The partition id 62 | * 63 | * @returns The total amount of free memory, in bytes. 64 | */ 65 | SceSize sceKernelPartitionTotalFreeMemSize(int pid); 66 | 67 | /** 68 | * Get the size of the largest free memory block. 69 | * 70 | * @param pid - The partition id 71 | * 72 | * @returns The size of the largest free memory block, in bytes. 73 | */ 74 | SceSize sceKernelPartitionMaxFreeMemSize(int pid); 75 | 76 | /** 77 | * Get the kernel to dump the internal memory table to Kprintf 78 | */ 79 | void sceKernelSysMemDump(void); 80 | 81 | /** 82 | * Dump the list of memory blocks 83 | */ 84 | void sceKernelSysMemDumpBlock(void); 85 | 86 | /** 87 | * Dump the tail blocks 88 | */ 89 | void sceKernelSysMemDumpTail(void); 90 | 91 | /** 92 | * Set the protection of a block of ddr memory 93 | * 94 | * @param addr - Address to set protection on 95 | * @param size - Size of block 96 | * @param prot - Protection bitmask 97 | * 98 | * @return < 0 on error 99 | */ 100 | int sceKernelSetDdrMemoryProtection(void *addr, int size, int prot); 101 | 102 | /** 103 | * Create a heap. 104 | * 105 | * @param partitionid - The UID of the partition where allocate the heap. 106 | * @param size - The size in bytes of the heap. 107 | * @param unk - Unknown, probably some flag or type, pass 1. 108 | * @param name - Name assigned to the new heap. 109 | * 110 | * @returns The UID of the new heap, or if less than 0 an error. 111 | */ 112 | SceUID sceKernelCreateHeap(SceUID partitionid, SceSize size, int unk, const char *name); 113 | 114 | /** 115 | * Allocate a memory block from a heap. 116 | * 117 | * @param heapid - The UID of the heap to allocate from. 118 | * @param size - The number of bytes to allocate. 119 | * 120 | * @returns The address of the allocated memory block, or NULL on error. 121 | */ 122 | void *sceKernelAllocHeapMemory(SceUID heapid, SceSize size); 123 | 124 | /** 125 | * Free a memory block allocated from a heap. 126 | * 127 | * @param heapid - The UID of the heap where block belongs. 128 | * @param block - The block of memory to free from the heap. 129 | * 130 | * @returns 0 on success, < 0 on error. 131 | */ 132 | int sceKernelFreeHeapMemory(SceUID heapid, void *block); 133 | 134 | /** 135 | * Delete a heap. 136 | * 137 | * @param heapid - The UID of the heap to delete. 138 | * 139 | * @returns 0 on success, < 0 on error. 140 | */ 141 | int sceKernelDeleteHeap(SceUID heapid); 142 | 143 | /** 144 | * Get the amount of free size of a heap, in bytes. 145 | * 146 | * @param heapid - The UID of the heap 147 | * 148 | * @returns the free size of the heap, in bytes. < 0 on error. 149 | */ 150 | SceSize sceKernelHeapTotalFreeSize(SceUID heapid); 151 | 152 | /** Structure of a UID control block */ 153 | struct _uidControlBlock { 154 | struct _uidControlBlock *parent; 155 | struct _uidControlBlock *nextChild; 156 | struct _uidControlBlock *type; //(0x8) 157 | u32 UID; //(0xC) 158 | char *name; //(0x10) 159 | unsigned char unk; 160 | unsigned char size; // Size in words 161 | short attribute; 162 | struct _uidControlBlock *nextEntry; 163 | } __attribute__((packed)); 164 | typedef struct _uidControlBlock uidControlBlock; 165 | 166 | /** 167 | * Get a UID control block 168 | * 169 | * @param uid - The UID to find 170 | * @param block - Pointer to hold the pointer to the block 171 | * 172 | * @return 0 on success 173 | */ 174 | int sceKernelGetUIDcontrolBlock(SceUID uid, uidControlBlock** block); 175 | 176 | /** 177 | * Get a UID control block on a particular type 178 | * 179 | * @param uid - The UID to find 180 | * @param type - Pointer to the type UID block 181 | * @param block - Pointer to hold the pointer to the block 182 | * 183 | * @return 0 on success 184 | */ 185 | int sceKernelGetUIDcontrolBlockWithType(SceUID uid, uidControlBlock* type, uidControlBlock** block); 186 | 187 | /** 188 | * Get the root of the UID tree (1.5+ only) 189 | * 190 | * @return Pointer to the UID tree root 191 | */ 192 | uidControlBlock* SysMemForKernel_536AD5E1(void); 193 | 194 | /** 195 | * Delete a UID 196 | * 197 | * @param uid - The UID to delete 198 | * 199 | * @return 0 on success 200 | */ 201 | int sceKernelDeleteUID(SceUID uid); 202 | 203 | /** 204 | * Gets the model of the PSP. 205 | * 206 | * @returns one of PspModel values. 207 | */ 208 | int sceKernelGetModel(void); 209 | 210 | #ifdef __cplusplus 211 | } 212 | #endif 213 | 214 | /*@}*/ 215 | 216 | #endif /* PSPSYSMEMKERNEL_H */ 217 | -------------------------------------------------------------------------------- /m33_sdk_prebuilt/include/pspusbdevice.h: -------------------------------------------------------------------------------- 1 | #ifndef __PSPUSBDEVICE_H__ 2 | #define __PSPUSBDEVICE_H__ 3 | 4 | /** 5 | * This functions require flash0:/kd/usbdevice.prx to be loaded/started first. 6 | 7 | * Link with pspusbdevice for user mode access or with pspusbdevice_driver for kernel access 8 | */ 9 | 10 | #define PSP_USBDEVICE_FLASH0 0 11 | #define PSP_USBDEVICE_FLASH1 1 12 | #define PSP_USBDEVICE_FLASH2 2 13 | #define PSP_USBDEVICE_FLASH3 3 14 | #define PSP_USBDEVICE_UMD9660 4 15 | 16 | #define UNASSIGN_MASK_FLASH0 1 17 | #define UNASSIGN_MASK_FLASH1 2 18 | #define UNASSIGN_MASK_FLASH2 3 19 | #define UNASSIGN_MASK_FLASH3 4 20 | 21 | /** 22 | * Sets the usb device. Call this function when you are about to do the sceUsbStart and sceUsbActivate stuff 23 | * 24 | * @param device - The usb device, one of listed above. 25 | * @param ronly - If non-zero indicates read only access. This parameters is ignored for PSP_USBDEVICE_UMD9660 26 | * @param unassign_mask - It unassigns automatically the flashes indicated by the mask. 27 | * The flashes will be reassigned automatically after calling pspUsbDeviceFinishDevice 28 | * 29 | * Set this param to 0 if you don't need it (vshctrl doesn't use it). 30 | * 31 | * @returns 0 on success, < 0 on error. 32 | */ 33 | int pspUsbDeviceSetDevice(u32 device, int ronly, int unassign_mask); 34 | 35 | /** 36 | * Finishes the usb device. Call this function after stoping usbstor driver 37 | * 38 | * @returns 0 in success, < 0 on error 39 | */ 40 | int pspUsbDeviceFinishDevice(); 41 | 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /m33_sdk_prebuilt/include/systemctrl.h: -------------------------------------------------------------------------------- 1 | #ifndef __SCTRLLIBRARY_H__ 2 | #define __SCTRLLIBRARY_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | enum BootLoadFlags 11 | { 12 | BOOTLOAD_VSH = 1, 13 | BOOTLOAD_GAME = 2, 14 | BOOTLOAD_UPDATER = 4, 15 | BOOTLOAD_POPS = 8, 16 | BOOTLOAD_UMDEMU = 64, /* for original NP9660 */ 17 | }; 18 | 19 | /** 20 | * Restart the vsh. 21 | * 22 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL 23 | * 24 | * @returns < 0 on some errors. 25 | * 26 | */ 27 | int sctrlKernelExitVSH(struct SceKernelLoadExecVSHParam *param); 28 | 29 | /** 30 | * Executes a new executable from a disc. 31 | * It is the function used by the firmware to execute the EBOOT.BIN from a disc. 32 | * 33 | * @param file - The file to execute. 34 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 35 | * 36 | * @returns < 0 on some errors. 37 | */ 38 | int sctrlKernelLoadExecVSHDisc(const char *file, struct SceKernelLoadExecVSHParam *param); 39 | 40 | /** 41 | * Executes a new executable from a disc. 42 | * It is the function used by the firmware to execute an updater from a disc. 43 | * 44 | * @param file - The file to execute. 45 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 46 | * 47 | * @returns < 0 on some errors. 48 | */ 49 | int sctrlKernelLoadExecVSHDiscUpdater(const char *file, struct SceKernelLoadExecVSHParam *param); 50 | 51 | /** 52 | * Executes a new executable from a memory stick. 53 | * It is the function used by the firmware to execute an updater from a memory stick. 54 | * 55 | * @param file - The file to execute. 56 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 57 | * 58 | * @returns < 0 on some errors. 59 | */ 60 | int sctrlKernelLoadExecVSHMs1(const char *file, struct SceKernelLoadExecVSHParam *param); 61 | 62 | /** 63 | * Executes a new executable from a memory stick. 64 | * It is the function used by the firmware to execute games (and homebrew :P) from a memory stick. 65 | * 66 | * @param file - The file to execute. 67 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 68 | * 69 | * @returns < 0 on some errors. 70 | */ 71 | int sctrlKernelLoadExecVSHMs2(const char *file, struct SceKernelLoadExecVSHParam *param); 72 | 73 | /** 74 | * Executes a new executable from a memory stick. 75 | * It is the function used by the firmware to execute ... ? 76 | * 77 | * @param file - The file to execute. 78 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 79 | * 80 | * @returns < 0 on some errors. 81 | */ 82 | int sctrlKernelLoadExecVSHMs3(const char *file, struct SceKernelLoadExecVSHParam *param); 83 | 84 | /** 85 | * Executes a new executable from a memory stick. 86 | * It is the function used by the firmware to execute psx games 87 | * 88 | * @param file - The file to execute. 89 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 90 | * 91 | * @returns < 0 on some errors. 92 | */ 93 | int sctrlKernelLoadExecVSHMs4(const char *file, struct SceKernelLoadExecVSHParam *param); 94 | 95 | 96 | /** 97 | * Executes a new executable with the specified apitype 98 | * 99 | * @param apitype - The apitype 100 | * @param file - The file to execute. 101 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 102 | * 103 | * @returns < 0 on some errors. 104 | */ 105 | int sctrlKernelLoadExecVSHWithApitype(int apitype, const char *file, struct SceKernelLoadExecVSHParam *param); 106 | 107 | /** 108 | * Sets the api type 109 | * 110 | * @param apitype - The apitype to set 111 | * @returns the previous apitype 112 | * 113 | * @Note - this will modify also the value of sceKernelBootFrom, since the value of 114 | * bootfrom is calculated from the apitype 115 | */ 116 | int sctrlKernelSetInitApitype(int apitype); 117 | 118 | /** 119 | * Sets the filename of the launched executable. 120 | * 121 | * @param filename - The filename to set 122 | * @returns 0 on success 123 | */ 124 | int sctrlKernelSetInitFileName(char *filename); 125 | 126 | /** 127 | * Sets the init key config 128 | * 129 | * @param key - The key code 130 | * @returns the previous key config 131 | */ 132 | int sctrlKernelSetInitKeyConfig(int key); 133 | 134 | /** 135 | * Sets the user level of the current thread 136 | * 137 | * @param level - The user level 138 | * @return the previous user level on success 139 | */ 140 | int sctrlKernelSetUserLevel(int level); 141 | 142 | /** 143 | * Sets the devkit version 144 | * 145 | * @param version - The devkit version to set 146 | * @return the previous devkit version 147 | * 148 | */ 149 | int sctrlKernelSetDevkitVersion(int version); 150 | 151 | /** 152 | * Checks if we are in SE. 153 | * 154 | * @returns 1 if we are in SE-C or later, 0 if we are in HEN-D or later, 155 | * and < 0 (a kernel error code) in any other case 156 | */ 157 | int sctrlHENIsSE(); 158 | 159 | /** 160 | * Checks if we are in Devhook. 161 | * 162 | * @returns 1 if we are in SE-C/HEN-D for devhook or later, 0 if we are in normal SE-C/HEN-D or later, 163 | * and < 0 (a kernel error code) in any other case 164 | */ 165 | int sctrlHENIsDevhook(); 166 | 167 | /** 168 | * Gets the HEN version 169 | * 170 | * @returns - The HEN version 171 | * 172 | * HEN D / SE-C : 0x00000400 173 | */ 174 | int sctrlHENGetVersion(); 175 | 176 | /** 177 | * Finds a driver 178 | * 179 | * @param drvname - The name of the driver (without ":" or numbers) 180 | * 181 | * @returns the driver if found, NULL otherwise 182 | * 183 | */ 184 | PspIoDrv *sctrlHENFindDriver(char *drvname); 185 | 186 | /** 187 | * Finds a function. 188 | * 189 | * @param szMod - The module where to search the function 190 | * @param szLib - The library name 191 | * @param nid - The nid of the function 192 | * 193 | * @returns - The function address or 0 if not found 194 | * 195 | */ 196 | u32 sctrlHENFindFunction(const char* szMod, const char* szLib, u32 nid); 197 | 198 | #define FindProc sctrlHENFindFunction 199 | 200 | typedef int (* STMOD_HANDLER)(SceModule2 *); 201 | 202 | /** 203 | * Sets a function to be called just before module_start of a module is gonna be called (useful for patching purposes) 204 | * 205 | * @param handler - The function, that will receive the module structure before the module is started. 206 | * 207 | * @returns - The previous set function (NULL if none); 208 | * @Note: because only one handler function is handled by HEN, you should 209 | * call the previous function in your code. 210 | * 211 | * @Example: 212 | * 213 | * STMOD_HANDLER previous = NULL; 214 | * 215 | * int OnModuleStart(SceModule2 *mod); 216 | * 217 | * void somepointofmycode() 218 | * { 219 | * previous = sctrlHENSetStartModuleHandler(OnModuleStart); 220 | * } 221 | * 222 | * int OnModuleStart(SceModule2 *mod) 223 | * { 224 | * if (strcmp(mod->modname, "vsh_module") == 0) 225 | * { 226 | * // Do something with vsh module here 227 | * } 228 | * 229 | * if (!previous) 230 | * return 0; 231 | * 232 | * // Call previous handler 233 | * 234 | * return previous(mod); 235 | * } 236 | * 237 | * @Note2: The above example should be compiled with the flag -fno-pic 238 | * in order to avoid problems with gp register that may lead to a crash. 239 | * 240 | */ 241 | STMOD_HANDLER sctrlHENSetStartModuleHandler(STMOD_HANDLER handler); 242 | 243 | /** 244 | * Sets the partition 2 and 8 memory for next loadexec. 245 | * 246 | * @param p2 - The size in MB for the user partition. Must be > 0 247 | * @param p8 - The size in MB for partition 8. Can be 0. 248 | * 249 | * @returns 0 on success, < 0 on error. 250 | * This function is only available in the slim. The function will fail 251 | * if p2+p8 > 52 or p2 == 0 252 | */ 253 | int sctrlHENSetMemory(u32 p2, u32 p8); 254 | 255 | /** 256 | * Loads a module on next reboot. Only kernel mode. 257 | * 258 | * @param module_after - The path of the module which is loaded after the module to be loaded. 259 | The module passed to this function will be loaded just before that module. 260 | * @param buf - The buffer containing the module - Don't deallocate this one. It has to reside in kernel memory. 261 | * @param size - The size of the module 262 | * @param flags - The modes in which the module should be loaded, one of BootLoadFlags 263 | * 264 | * @Example: 265 | * sctrlHENLoadModuleOnReboot("/kd/usersystemlib.prx", module_buffer, module_size, BOOTLOAD_GAME | BOOTLOAD_POPS | BOOTLOAD_UMDEMU); 266 | * 267 | * This will load the module contained in module_buffer just before /kd/usersystemlib.prx in the next reboot, if the mode of next reboot is game, pops or umdemu 268 | * 269 | * @Remarks: Don't use too early modules in first param like "/kd/init.prx" or "/kd/systemctrl.prx", or your module may not load properly 270 | * Only one module will be loaded on reboot with this function. 271 | * If this function is called many times, only the last one will be considered. 272 | * By making a module to load itself using this function, and calling 273 | * sctrlHENLoadModuleOnReboot on module_start, a prx can cause itself to be resident in the modes choosen by flags. 274 | * If all flags are selected, the module will stay resident until a psp shutdown, or until sctrlHENLoadModuleOnReboot is not called. 275 | */ 276 | 277 | void sctrlHENLoadModuleOnReboot(char *module_after, void *buf, int size, int flags); 278 | 279 | /** Changes a syscall to another function 280 | * 281 | * @param addr - the address of the original function 282 | * @param newaddr - the address of the new function 283 | */ 284 | void sctrlHENPatchSyscall(u32 addr, void *newaddr); 285 | 286 | #endif 287 | 288 | 289 | 290 | -------------------------------------------------------------------------------- /m33_sdk_prebuilt/include/systemctrl_se.h: -------------------------------------------------------------------------------- 1 | #ifndef __SCTRLLIBRARY_SE_H__ 2 | #define __SCTRLLIBRARY_SE_H__ 3 | 4 | /** 5 | * These functions are only available in SE-C and later, 6 | * and they are not in HEN 7 | */ 8 | 9 | enum 10 | { 11 | FAKE_REGION_DISABLED = 0, 12 | FAKE_REGION_JAPAN = 1, 13 | FAKE_REGION_AMERICA = 2, 14 | FAKE_REGION_EUROPE = 3, 15 | FAKE_REGION_KOREA = 4, /* do not use, may cause brick on restore default settings */ 16 | FAKE_REGION_UNK = 5, 17 | FAKE_REGION_UNK2 = 6, 18 | FAKE_REGION_AUSTRALIA = 7, 19 | FAKE_REGION_HONGKONG = 8, /* do not use, may cause brick on restore default settings */ 20 | FAKE_REGION_TAIWAN = 9, /* do not use, may cause brick on restore default settings */ 21 | FAKE_REGION_RUSSIA = 10, 22 | FAKE_REGION_CHINA = 11, /* do not use, may cause brick on restore default settings */ 23 | }; 24 | 25 | 26 | enum SEUmdModes 27 | { 28 | MODE_UMD = 0, 29 | MODE_OE_LEGACY = 1, 30 | MODE_MARCH33 = 2, 31 | MODE_NP9660 = 3, 32 | }; 33 | 34 | typedef struct 35 | { 36 | int magic; /* 0x47434553 */ 37 | int hidecorrupt; 38 | int skiplogo; 39 | int umdactivatedplaincheck; 40 | int gamekernel150; 41 | int executebootbin; 42 | int startupprog; 43 | int umdmode; 44 | int useisofsonumdinserted; 45 | int vshcpuspeed; 46 | int vshbusspeed; 47 | int umdisocpuspeed; 48 | int umdisobusspeed; 49 | int fakeregion; 50 | int freeumdregion; 51 | int hardresetHB; 52 | int usbdevice; 53 | int novshmenu; 54 | int usbcharge; 55 | int notusedaxupd; 56 | int reserved[2]; 57 | } SEConfig; 58 | 59 | 60 | /** 61 | * Gets the SE/OE version 62 | * 63 | * @returns the SE version 64 | * 65 | * 3.03 OE-A: 0x00000500 66 | */ 67 | int sctrlSEGetVersion(); 68 | 69 | /** 70 | * Gets the SE configuration. 71 | * Avoid using this function, it may corrupt your program. 72 | * Use sctrlSEGetCongiEx function instead. 73 | * 74 | * @param config - pointer to a SEConfig structure that receives the SE configuration 75 | * @returns 0 on success 76 | */ 77 | int sctrlSEGetConfig(SEConfig *config); 78 | 79 | /** 80 | * Gets the SE configuration 81 | * 82 | * @param config - pointer to a SEConfig structure that receives the SE configuration 83 | * @param size - The size of the structure 84 | * @returns 0 on success 85 | */ 86 | int sctrlSEGetConfigEx(SEConfig *config, int size); 87 | 88 | /** 89 | * Sets the SE configuration 90 | * This function can corrupt the configuration in flash, use 91 | * sctrlSESetConfigEx instead. 92 | * 93 | * @param config - pointer to a SEConfig structure that has the SE configuration to set 94 | * @returns 0 on success 95 | */ 96 | int sctrlSESetConfig(SEConfig *config); 97 | 98 | /** 99 | * Sets the SE configuration 100 | * 101 | * @param config - pointer to a SEConfig structure that has the SE configuration to set 102 | * @param size - the size of the structure 103 | * @returns 0 on success 104 | */ 105 | int sctrlSESetConfigEx(SEConfig *config, int size); 106 | 107 | /** 108 | * Initiates the emulation of a disc from an ISO9660/CSO file. 109 | * 110 | * @param file - The path of the 111 | * @param noumd - Wether use noumd or not 112 | * @param isofs - Wether use the custom SE isofs driver or not 113 | * 114 | * @returns 0 on success 115 | * 116 | * @Note - When setting noumd to 1, isofs should also be set to 1, 117 | * otherwise the umd would be still required. 118 | * 119 | * @Note 2 - The function doesn't check if the file is valid or even if it exists 120 | * and it may return success on those cases 121 | * 122 | * @Note 3 - This function is not available in SE for devhook 123 | * @Example: 124 | * 125 | * SEConfig config; 126 | * 127 | * sctrlSEGetConfig(&config); 128 | * 129 | * if (config.usenoumd) 130 | * { 131 | * sctrlSEMountUmdFromFile("ms0:/ISO/mydisc.iso", 1, 1); 132 | * } 133 | * else 134 | * { 135 | * sctrlSEMountUmdFromFile("ms0:/ISO/mydisc.iso", 0, config.useisofsonumdinserted); 136 | * } 137 | */ 138 | int sctrlSEMountUmdFromFile(char *file, int noumd, int isofs); 139 | 140 | /** 141 | * Umounts an iso. 142 | * 143 | * @returns 0 on success 144 | */ 145 | int sctrlSEUmountUmd(void); 146 | 147 | /** 148 | * Forces the umd disc out state 149 | * 150 | * @param out - non-zero for disc out, 0 otherwise 151 | * 152 | */ 153 | void sctrlSESetDiscOut(int out); 154 | 155 | /** 156 | * Sets the disctype. 157 | * 158 | * @param type - the disctype (0x10=game, 0x20=video, 0x40=audio) 159 | */ 160 | void sctrlSESetDiscType(int type); 161 | 162 | /** 163 | * Sets the current umd file (kernel only) 164 | */ 165 | char *sctrlSEGetUmdFile(); 166 | 167 | /** 168 | * Gets the current umd file (kernel only) 169 | */ 170 | char *sctrlSEGetUmdFile(); 171 | 172 | /** 173 | * Sets the current umd file (kernel only) 174 | * 175 | * @param file - The umd file 176 | */ 177 | void sctrlSESetUmdFile(char *file); 178 | 179 | /** 180 | * Sets the boot config file for next reboot (kernel only) 181 | * 182 | * @param index - The index identifying the file (0 -> normal bootconf, 1 -> march33 driver bootconf, 2 -> np9660 bootcnf) 183 | */ 184 | void sctrlSESetBootConfFileIndex(int index); 185 | 186 | #endif 187 | -------------------------------------------------------------------------------- /m33_sdk_prebuilt/include/vshctrl.h: -------------------------------------------------------------------------------- 1 | #ifndef __VSHCTRL_H__ 2 | #define __VSHCTRL_H__ 3 | 4 | /** 5 | * This api is for vsh menu. (flash0:/vsh/module/satelite.prx) 6 | * 7 | * The vsh menu is an user mode module, and because of this, these functions are 8 | * only available to user mode. 9 | */ 10 | 11 | /** 12 | * Registers the vsh menu. 13 | * When HOME is pressed, vshctrl will load the satelite module. 14 | * In module_start, call this function to register the vsh menu. 15 | * 16 | * @param ctrl - The function that will be executed each time 17 | * the system calls ReadBufferPositive. Despite satelite.prx being 18 | * an user module, this function will be executed in kernel mode. 19 | * 20 | * @returns 0 on success, < 0 on error. 21 | */ 22 | int vctrlVSHRegisterVshMenu(int (* ctrl)(SceCtrlData *, int)); 23 | 24 | /** 25 | * Exits the vsh menu. 26 | * vshmenu module must call this module after destroying vsh menu display and 27 | * freeing resources. 28 | * 29 | * vshmenu module doesn't need to stop-unload itself, as that is vshctrl job. 30 | * 31 | * @param conf - Indicates the new config. vshctrl will update the internal 32 | * vshctrl and systemctrl variables with the new configuration given by this param. 33 | * However is job of satelite.prx to save those settings to the configuration file. 34 | * using sctrlSESetConfig. 35 | * 36 | * @param videoiso - Indicates the videoiso to mount, or NULL if none. 37 | * @param disctype - The disctype of the videoiso (0x20=video, 0x40=audio) 38 | * 39 | * @returns 0 on success, < 0 on error. 40 | */ 41 | int vctrlVSHExitVSHMenu(SEConfig *conf, char *videoiso, int disctype); 42 | 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /m33_sdk_prebuilt/lib/libpspinit.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/m33_sdk_prebuilt/lib/libpspinit.a -------------------------------------------------------------------------------- /m33_sdk_prebuilt/lib/libpspkdebug.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/m33_sdk_prebuilt/lib/libpspkdebug.a -------------------------------------------------------------------------------- /m33_sdk_prebuilt/lib/libpspkubridge.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/m33_sdk_prebuilt/lib/libpspkubridge.a -------------------------------------------------------------------------------- /m33_sdk_prebuilt/lib/libpsploadexec_kernel.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/m33_sdk_prebuilt/lib/libpsploadexec_kernel.a -------------------------------------------------------------------------------- /m33_sdk_prebuilt/lib/libpspmodulemgr_kernel.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/m33_sdk_prebuilt/lib/libpspmodulemgr_kernel.a -------------------------------------------------------------------------------- /m33_sdk_prebuilt/lib/libpspmodulemgr_user.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/m33_sdk_prebuilt/lib/libpspmodulemgr_user.a -------------------------------------------------------------------------------- /m33_sdk_prebuilt/lib/libpspsysmem_kernel.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/m33_sdk_prebuilt/lib/libpspsysmem_kernel.a -------------------------------------------------------------------------------- /m33_sdk_prebuilt/lib/libpspsysmem_user.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/m33_sdk_prebuilt/lib/libpspsysmem_user.a -------------------------------------------------------------------------------- /m33_sdk_prebuilt/lib/libpspsystemctrl_kernel.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/m33_sdk_prebuilt/lib/libpspsystemctrl_kernel.a -------------------------------------------------------------------------------- /m33_sdk_prebuilt/lib/libpspsystemctrl_user.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/m33_sdk_prebuilt/lib/libpspsystemctrl_user.a -------------------------------------------------------------------------------- /m33_sdk_prebuilt/lib/libpspumd_kernel.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/m33_sdk_prebuilt/lib/libpspumd_kernel.a -------------------------------------------------------------------------------- /m33_sdk_prebuilt/lib/libpspusbdevice.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/m33_sdk_prebuilt/lib/libpspusbdevice.a -------------------------------------------------------------------------------- /m33_sdk_prebuilt/lib/libpspusbdevice_driver.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/m33_sdk_prebuilt/lib/libpspusbdevice_driver.a -------------------------------------------------------------------------------- /m33_sdk_prebuilt/lib/libpspvshctrl.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/m33_sdk_prebuilt/lib/libpspvshctrl.a -------------------------------------------------------------------------------- /main.c: -------------------------------------------------------------------------------- 1 | /* 2 | Remastered Controls: RemasteredControls_GTpsp 3 | Copyright (C) 2018, TheFloW 4 | Copyright (C) 2023, Katharine Chui 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #include 21 | 22 | #include 23 | 24 | #include "hooking.h" 25 | #include "disc_ident.h" 26 | 27 | #include "logging.h" 28 | 29 | #include 30 | 31 | #include "common.h" 32 | #define GAME_MODULE_NAME "PDIAPP" 33 | 34 | PSP_MODULE_INFO(MODULE_NAME, PSP_MODULE_KERNEL, 1, 0); 35 | 36 | #define EMULATOR_DEVCTL__IS_EMULATOR 0x00000003 37 | 38 | #ifndef IRSHELL 39 | static STMOD_HANDLER previous; 40 | #endif 41 | 42 | static int is_emulator; 43 | static u32 game_base_addr = 0; 44 | 45 | static int override_accel = 0; 46 | static int accel_override = 0; 47 | static int override_brake = 0; 48 | static int brake_override = 0; 49 | static int override_steering = 0; 50 | static short int steering_override = 0; 51 | static int override_camera = 0; 52 | static float camera_override = 0; 53 | 54 | static unsigned char outer_deadzone = 114; 55 | static unsigned char inner_deadzone = 10; 56 | 57 | static int camera_controls = 0; 58 | static int adjacent_axes = 0; 59 | 60 | static int apply_deadzone(int val){ 61 | if(val < inner_deadzone){ 62 | return 0; 63 | } 64 | int range = outer_deadzone - inner_deadzone; 65 | val = val - inner_deadzone; 66 | if(val > range){ 67 | val = range; 68 | } 69 | return val * 127 / range; 70 | } 71 | 72 | static void sample_input(SceCtrlData *pad_data, int count, int negative){ 73 | if(count < 1){ 74 | LOG("count is %d, processing skipped", count); 75 | return; 76 | } 77 | 78 | LOG_VERBOSE("processing %d buffers in %s mode", count, negative? "negative" : "positive"); 79 | 80 | // for this game, it probably makes sense to just process the last buffer 81 | int rx = pad_data[count - 1].Rsrv[0]; 82 | int ry = pad_data[count - 1].Rsrv[1]; 83 | int lx = pad_data[count - 1].Lx; 84 | int ly = pad_data[count - 1].Ly; 85 | 86 | #if VERBOSE 87 | u32 timestamp = pad_data[count - 1].TimeStamp; 88 | #endif // VERBOSE 89 | 90 | // right, left, down, up 91 | 92 | int lxp = 0; 93 | int lxn = 0; 94 | int lyp = 0; 95 | int lyn = 0; 96 | //int rxp = 0; 97 | int rxn = 0; 98 | int ryp = 0; 99 | int ryn = 0; 100 | 101 | static int right_stick_looks_dead = 1; 102 | if(right_stick_looks_dead && (rx != 0 || ry != 0)){ 103 | right_stick_looks_dead = 0; 104 | } 105 | 106 | if(lx < 128){ 107 | lxn = apply_deadzone(128 - lx); 108 | } 109 | if(lx > 128){ 110 | lxp = apply_deadzone(lx - 128); 111 | } 112 | if(ly < 128){ 113 | lyn = apply_deadzone(128 - ly); 114 | } 115 | if(ly > 128){ 116 | lyp = apply_deadzone(ly - 128); 117 | } 118 | if(rx < 128){ 119 | rxn = apply_deadzone(128 - rx); 120 | } 121 | /* 122 | if(rx > 128){ 123 | rxp = apply_deadzone(rx - 128); 124 | } 125 | */ 126 | if(ry < 128){ 127 | ryn = apply_deadzone(128 - ry); 128 | } 129 | if(ry > 128){ 130 | ryp = apply_deadzone(ry - 128); 131 | } 132 | 133 | if(adjacent_axes){ 134 | int tmp = ryn; 135 | ryn = rxn; 136 | rxn = tmp; 137 | } 138 | 139 | override_brake = 0; 140 | override_accel = 0; 141 | override_steering = 0; 142 | override_camera = 0; 143 | 144 | if(lxp > 0){ 145 | override_steering = 1; 146 | steering_override = lxp * (-1); 147 | } 148 | 149 | if(lxn > 0){ 150 | override_steering = 1; 151 | steering_override = lxn; 152 | } 153 | 154 | if(!right_stick_looks_dead){ 155 | if(ryp > 0){ 156 | override_brake = 1; 157 | brake_override = ryp; 158 | } 159 | 160 | if(ryn > 0){ 161 | override_accel = 1; 162 | accel_override = ryn; 163 | } 164 | } 165 | 166 | if(camera_controls){ 167 | if(lyn > 0){ 168 | override_camera = 1; 169 | camera_override = (float)(lyn * -1.5f) / 127.0f; 170 | } 171 | 172 | if(lyp > 0){ 173 | override_camera = 1; 174 | camera_override = (float)(lyp * 1.5f) / 127.0f; 175 | } 176 | } 177 | 178 | LOG_VERBOSE("timestamp: %lu lx: %d ly: %d rx: %d ry: %d", timestamp, lx, ly, rx, ry); 179 | } 180 | 181 | static int (*sceCtrlReadBufferPositiveOrig)(SceCtrlData *pad_data, int count); 182 | int sceCtrlReadBufferPositivePatched(SceCtrlData *pad_data, int count){ 183 | int k1 = pspSdkSetK1(0); 184 | int res = sceCtrlReadBufferPositiveOrig(pad_data, count); 185 | 186 | sample_input(pad_data, res, 0); 187 | 188 | pspSdkSetK1(k1); 189 | return res; 190 | } 191 | 192 | int set_offsets(char *disc_id, char *disc_version){ 193 | LOG("game_base_addr: 0x%lx", game_base_addr); 194 | // EU and US v2.00 195 | if(strcmp("2.00", disc_version) == 0 && (strcmp("UCES01245", disc_id) == 0 || strcmp("UCUS98632", disc_id) == 0)){ 196 | offset_digital_to_analog = game_base_addr + 0x14eb40; 197 | offset_populate_car_digital_control = game_base_addr + 0x126b50; 198 | offset_populate_car_analog_control = game_base_addr + 0x126dec; 199 | return 0; 200 | } 201 | 202 | // ASIA v1.00 203 | if(strcmp("1.00", disc_version) == 0 && strcmp("UCAS40265", disc_id) == 0){ 204 | offset_populate_car_analog_control = game_base_addr + 0x126dec; 205 | return 0; 206 | } 207 | 208 | // JP v1.01 209 | if(strcmp("1.01", disc_version) == 0 && strcmp("UCJS10100", disc_id) == 0){ 210 | offset_populate_car_analog_control = game_base_addr + 0x126dd0; 211 | return 0; 212 | } 213 | 214 | LOG("unknown dics id %s with version %s", disc_id, disc_version); 215 | return -1; 216 | } 217 | 218 | // this maps way smoother than trying to go through the ps3 path, but then it breaks replay and ghost 219 | static void (*digital_to_analog_orig)(u32 *param_1, u32 *param_2); 220 | void digital_to_analog_patched(u32 *param_1, u32 *param_2){ 221 | float *accel = (float *)((u32)(param_1[2]) + 0x530); 222 | u32 *accel_as_int = (u32 *)accel; 223 | float *brake = (float *)((u32)(param_1[2]) + 0x538); 224 | u32 *brake_as_int = (u32 *)brake; 225 | 226 | //LOG("accel at 0x%lx is %f, brake at 0x%lx is %f", (u32)accel, *accel, (u32)brake, *brake); 227 | 228 | digital_to_analog_orig(param_1, param_2); 229 | if(*accel_as_int != 0 && override_accel){ 230 | *accel = (float)accel_override / 127.0f; 231 | if(*accel > 1.0){ 232 | *accel = 1.0; 233 | } 234 | } 235 | 236 | if(*brake_as_int != 0 && override_brake){ 237 | *brake = (float)brake_override / 127.0f; 238 | if(*brake > 1.0){ 239 | *brake = 1.0; 240 | } 241 | } 242 | } 243 | 244 | static void (*populate_car_digital_control_orig)(unsigned char *param_1, u32 param_2, u32 param_3); 245 | void populate_car_digital_control_patched(unsigned char *param_1, u32 param_2, u32 param_3){ 246 | unsigned short int *accel_control = (unsigned short int *)¶m_1[8]; 247 | unsigned short int *brake_control = (unsigned short int *)¶m_1[10]; 248 | 249 | populate_car_digital_control_orig(param_1, param_2, param_3); 250 | 251 | if(override_accel){ 252 | *accel_control = 1; 253 | param_1[0] &= 0x9d; 254 | } 255 | if(override_brake){ 256 | *brake_control = 1; 257 | param_1[0] &= 0xfb; 258 | } 259 | } 260 | 261 | // this is naturally invoked when button bound for steering is not pressed, so likely invoked for converting analog stick value to steering 262 | static void (*populate_car_analog_control_orig)(u32 param_1, int *param_2, unsigned char *param_3, u32 param_4, u32 param_5, unsigned char param_6); 263 | void populate_car_analog_control_patched(u32 param_1, int *param_2, unsigned char *param_3, u32 param_4, u32 param_5, unsigned char param_6){ 264 | short *steering = (short *)(¶m_3[4]); // +- 0x2000 int 265 | float *camera_rotation = (float *)(¶m_3[0x2c]); // +-1.0 float 266 | short *throttle = (short *)(¶m_3[0x8]); 267 | short *brake = (short *)(¶m_3[0xA]); 268 | // an analog handbrake 269 | //short *handbrake = (short *)(¶m_3[0xe]); 270 | //param_3[0] = param_3[0] | 0x10; 271 | // analog reverse, also has the weird response curve 272 | //short *reverse = (short *)(¶m_3[0xc]); 273 | //param_3[0] = param_3[0] | 8; 274 | 275 | // no clutch..? 276 | 277 | // populate_car_analog_control_orig(param_1, param_2, param_3, param_4, param_5, param_6); 278 | param_3[0] = 0; 279 | param_3[1] = 0; 280 | 281 | int k1 = pspSdkSetK1(0); 282 | 283 | static void *logged_location = NULL; 284 | if(param_3 != logged_location){ 285 | logged_location = param_3; 286 | LOG("car control struct is now at 0x%lx", (uint32_t)param_3); 287 | } 288 | 289 | int mode; 290 | sceCtrlGetSamplingMode(&mode); 291 | if(mode != PSP_CTRL_MODE_ANALOG){ 292 | // the mode might be per thread 293 | LOG_VERBOSE("sceCtrlGetSamplingMode is not analog..? setting it to analog now"); 294 | sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG); 295 | return; 296 | } 297 | 298 | #if 0 299 | if(is_emulator){ 300 | #else 301 | { 302 | #endif 303 | SceCtrlData pad_data; 304 | int res = sceCtrlPeekBufferPositive(&pad_data, 1); 305 | sample_input(&pad_data, res, 0); 306 | } 307 | 308 | if(override_steering){ 309 | param_3[0] = param_3[0] | 1; 310 | param_3[1] = param_3[1] | 2; 311 | *steering = steering_override * 0x2000 / 127; 312 | LOG_VERBOSE("applying steering override, val is %d, steering is %d", steering_override, *steering); 313 | }else{ 314 | *steering = 0; 315 | } 316 | 317 | if(override_accel){ 318 | // weird curve, 0-0.71 is roughly nothing, 0.81 is roughly 0.25 throttle, 0.91 is roughly 0.5 throttle, 0.96 is roughly 0.75 throttle 319 | param_3[0] = param_3[0] | 2; 320 | if(accel_override >= 95){ 321 | static short base = (0x1000 * 0.96f); 322 | static short offset_throttle = (0x1000 * (1.0f - 0.96f) + 1); 323 | int throttle_segment = accel_override - 95; 324 | static int range = 127 - 95; 325 | *throttle = base + throttle_segment * offset_throttle / range; 326 | if(*throttle > 4096){ 327 | *throttle = 4096; 328 | } 329 | }else if(accel_override >= 64){ 330 | static short base = (0x1000 * 0.91f); 331 | static short offset_throttle = (0x1000 * (0.96f - 0.91f)); 332 | int throttle_segment = accel_override - 64; 333 | static int range = 94 - 64; 334 | *throttle = base + throttle_segment * offset_throttle / range; 335 | }else if(accel_override >= 32){ 336 | static short base = (0x1000 * 0.81f); 337 | static short offset_throttle = (0x1000 * (0.91f - 0.81f)); 338 | int throttle_segment = accel_override - 32; 339 | static int range = 63 - 32; 340 | *throttle = base + throttle_segment * offset_throttle / range; 341 | }else{ 342 | static short base = (0x1000 * 0.71f); 343 | static short offset_throttle = (0x1000 * (0.81f - 0.71f)); 344 | int throttle_segment = accel_override; 345 | static int range = 31; 346 | *throttle = base + throttle_segment * offset_throttle / range; 347 | } 348 | // *throttle = accel_override * 0x1000 / 127; 349 | LOG_VERBOSE("applying accel override, val is %d, throttle is %d", accel_override, *throttle); 350 | } 351 | 352 | if(override_brake){ 353 | param_3[0] = param_3[0] | 4; 354 | *brake = brake_override * 0x1000 / 127; 355 | LOG_VERBOSE("applying brake override, val is %d, brake is %d", brake_override, *brake); 356 | } 357 | 358 | if(override_camera){ 359 | *camera_rotation = camera_override; 360 | } 361 | 362 | pspSdkSetK1(k1); 363 | } 364 | 365 | int _atoi(char *buf){ 366 | int i = 0; 367 | int val = 0; 368 | int negative = 0; 369 | 370 | if(buf[0] == '-'){ 371 | negative = 1; 372 | i = 1; 373 | } 374 | 375 | while(1){ 376 | if(buf[i] == '\0'){ 377 | break; 378 | } 379 | val = val * 10; 380 | val = val + (int)(buf[i] - '0'); 381 | i++; 382 | } 383 | 384 | if(negative){ 385 | val = val * (-1); 386 | } 387 | 388 | return val; 389 | } 390 | 391 | void parse_config(){ 392 | char *path = "ms0:/PSP/"MODULE_NAME"_settings.txt"; 393 | int fd = sceIoOpen(path, PSP_O_RDONLY, 0); 394 | if(fd < 0){ 395 | LOG("cannot open %s for reading, trying ef0:/", path); 396 | path = "ef0:/PSP/"MODULE_NAME"_settings.txt"; 397 | fd = sceIoOpen(path, PSP_O_RDONLY, 0); 398 | if(fd < 0){ 399 | LOG("cannot open %s for reading either", path); 400 | return; 401 | } 402 | } 403 | 404 | char buf[128] = {0}; 405 | u32 len = sceIoRead(fd, buf, sizeof(buf)); 406 | if(len < 0){ 407 | LOG("failed reading %s after opening", path); 408 | return; 409 | } 410 | 411 | int arg_idx = 0; 412 | char arg_buf[128] = {0}; 413 | u32 arg_buf_write_head = 0; 414 | for(u32 i = 0;i <= len; i++){ 415 | if(i < len && buf[i] != ' ' && buf[i] != '\n'){ 416 | arg_buf[arg_buf_write_head] = buf[i]; 417 | arg_buf_write_head++; 418 | }else{ 419 | if(arg_buf_write_head == 0){ 420 | continue; 421 | } 422 | arg_buf[arg_buf_write_head] = '\0'; 423 | if(arg_idx == 0){ 424 | int num = _atoi(arg_buf); 425 | camera_controls = num && is_emulator; 426 | if(camera_controls){ 427 | LOG("enabling camera controls"); 428 | }else{ 429 | LOG("not enabling camera controls"); 430 | } 431 | }else if(arg_idx == 1){ 432 | int num = _atoi(arg_buf); 433 | if(num > 127){ 434 | num = 127; 435 | } 436 | if(num < 0){ 437 | num = 0; 438 | } 439 | LOG("overriding inner deadzone %d with %d", inner_deadzone, num); 440 | inner_deadzone = num; 441 | }else if(arg_idx == 2){ 442 | int num = _atoi(arg_buf); 443 | if(num > 127){ 444 | num = 127; 445 | } 446 | if(num < 0){ 447 | num = 0; 448 | } 449 | LOG("overriding outer deadzone %d with %d", outer_deadzone, num); 450 | outer_deadzone = num; 451 | } 452 | 453 | arg_buf_write_head = 0; 454 | arg_idx++; 455 | } 456 | } 457 | } 458 | 459 | int init(){ 460 | char disc_id[50]; 461 | char disc_version[50]; 462 | int disc_id_valid = get_disc_id_version(disc_id, disc_version) == 0; 463 | if(disc_id_valid){ 464 | LOG("disc id is %s", disc_id); 465 | LOG("disc version is %s", disc_version); 466 | }else{ 467 | LOG("cannot find disc id from sfo, aborting"); 468 | return -1; 469 | } 470 | 471 | if(set_offsets(disc_id, disc_version) != 0){ 472 | LOG("cannot lookup function offsets with disc id and version, aborting"); 473 | return -1; 474 | } 475 | 476 | if(is_emulator){ 477 | adjacent_axes = 1; 478 | outer_deadzone = 124; 479 | inner_deadzone = 3; 480 | } 481 | parse_config(); 482 | 483 | //HIJACK_FUNCTION(offset_digital_to_analog, digital_to_analog_patched, digital_to_analog_orig); 484 | //HIJACK_FUNCTION(offset_populate_car_digital_control, populate_car_digital_control_patched, populate_car_digital_control_orig); 485 | HIJACK_FUNCTION(offset_populate_car_analog_control, populate_car_analog_control_patched, populate_car_analog_control_orig); 486 | 487 | #if 0 488 | if(!is_emulator){ 489 | HIJACK_SYSCALL_STUB((u32)sceCtrlReadBufferPositive, sceCtrlReadBufferPositivePatched, sceCtrlReadBufferPositiveOrig); 490 | } 491 | #endif 492 | 493 | if(is_emulator){ 494 | sceKernelDelayThread(1000 * 1000 * 5); 495 | LOG("boosting input sampling on ppsspp"); 496 | sceCtrlSetSamplingCycle(5555); 497 | } 498 | 499 | LOG("main thread finishes"); 500 | return 0; 501 | } 502 | 503 | #ifndef IRSHELL 504 | int StartPSP(SceModule2 *mod) { 505 | char namebuf[sizeof(mod->modname) + 1] = {0}; 506 | memcpy(namebuf, mod->modname, sizeof(mod->modname)); 507 | LOG("PSP module %s", namebuf); 508 | if(strcmp(namebuf, GAME_MODULE_NAME) == 0){ 509 | game_base_addr = mod->text_addr; 510 | // XXX oh no 511 | game_base_addr = game_base_addr + 0x28; 512 | LOG("GTPSP module %s found, setting base address to 0x%08lx", namebuf, game_base_addr); 513 | init(); 514 | } 515 | 516 | if (!previous){ 517 | return 0; 518 | } 519 | 520 | return previous(mod); 521 | } 522 | #else 523 | int irshell_find_module(SceSize args, void *argp){ 524 | int cycles = 0; 525 | while(cycles < 60){ 526 | SceUID modules[256] = {0}; 527 | SceKernelModuleInfo info = {0}; 528 | int count = 0; 529 | LOG("%s: scanning through module list", __func__); 530 | if(sceKernelGetModuleIdList(modules, sizeof(modules), &count) >= 0){ 531 | for(int i = 0;i < count;i++){ 532 | info.size = sizeof(SceKernelModuleInfo); 533 | if(sceKernelQueryModuleInfo(modules[i], &info) < 0){ 534 | LOG("failed fetching module info for id 0x%08x", modules[i]); 535 | continue; 536 | } 537 | char namebuf[sizeof(info.name) + 1] = {0}; 538 | memcpy(namebuf, info.name, sizeof(info.name)); 539 | if(strcmp(namebuf, GAME_MODULE_NAME) == 0){ 540 | LOG("GTPSP module %s found with text_addr 0x%08x", namebuf, info.text_addr); 541 | // XXX I guess ppsspp's value is off 542 | game_base_addr = info.text_addr + 0x28; 543 | }else{ 544 | LOG("ignoring module %s", namebuf); 545 | } 546 | } 547 | if(game_base_addr != 0){ 548 | init(); 549 | sceKernelExitDeleteThread(0); 550 | return 0; 551 | } 552 | }else{ 553 | LOG("failed fetching module id list"); 554 | } 555 | LOG("%s: didn't find GTPSP module, trying again in a second", __func__); 556 | sceKernelDelayThread(1000 * 1000); 557 | cycles++; 558 | } 559 | LOG("%s: giving up, it has been a whole minute", __func__); 560 | sceKernelExitDeleteThread(0); 561 | return 0; 562 | } 563 | #endif 564 | 565 | static void StartPPSSPP() { 566 | SceUID modules[256]; 567 | SceKernelModuleInfo info; 568 | int i, count = 0; 569 | 570 | if (sceKernelGetModuleIdList(modules, sizeof(modules), &count) >= 0) { 571 | for (i = 0; i < count; ++i) { 572 | info.size = sizeof(SceKernelModuleInfo); 573 | if (sceKernelQueryModuleInfo(modules[i], &info) < 0) { 574 | continue; 575 | } 576 | char namebuf[sizeof(info.name) + 1] = {0}; 577 | memcpy(namebuf, info.name, sizeof(info.name)); 578 | LOG("PPSSPP module %s", namebuf); 579 | if(strcmp(namebuf, GAME_MODULE_NAME) == 0){ 580 | LOG("GTPSP module %s found", namebuf); 581 | game_base_addr = info.text_addr; 582 | } 583 | } 584 | if(game_base_addr != 0){ 585 | init(); 586 | } 587 | } 588 | } 589 | 590 | int module_start(SceSize args, void *argp){ 591 | #if DEBUG_LOG 592 | sceIoRemove("ms0:/PSP/"MODULE_NAME".log"); 593 | sceIoRemove("ef0:/PSP/"MODULE_NAME".log"); 594 | #endif 595 | LOG("module started"); 596 | 597 | is_emulator = sceIoDevctl("kemulator:", EMULATOR_DEVCTL__IS_EMULATOR, NULL, 0, NULL, 0) == 0; 598 | 599 | if (is_emulator) { 600 | // Just scan the modules using normal/official syscalls. 601 | LOG("starting in ppsspp mode"); 602 | StartPPSSPP(); 603 | }else{ 604 | #ifndef IRSHELL 605 | LOG("starting in psp hen mode"); 606 | previous = sctrlHENSetStartModuleHandler(StartPSP); 607 | #else 608 | LOG("starting in psp irshell mode"); 609 | SceUID thid = sceKernelCreateThread("irshell_find_module", irshell_find_module, 0x18, 0x10000, 0, NULL); 610 | if(thid < 0){ 611 | LOG("failed creating irshell module searching thread"); 612 | return 0; 613 | } 614 | sceKernelStartThread(thid, 0, NULL); 615 | #endif 616 | } 617 | return 0; 618 | } 619 | 620 | int module_stop(SceSize args, void *argp){ 621 | LOG("attempting to stop this module, but unload is not really implemented..."); 622 | return 0; 623 | } 624 | -------------------------------------------------------------------------------- /plugin.ini: -------------------------------------------------------------------------------- 1 | [options] 2 | type = prx 3 | version = 1 4 | filename = GTRemastered.prx 5 | 6 | [games] 7 | UCUS98632 = true 8 | UCES01245 = true 9 | UCAS40265 = true 10 | UCJS10100 = true 11 | -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/README.txt: -------------------------------------------------------------------------------- 1 | built from https://github.com/MrColdbird/procfw 2 | -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/include/kubridge.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/procfw_sdk_prebuilt/include/kubridge.h -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/include/pspcrypt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * File for native encrypt/decrypt functions 3 | */ 4 | 5 | #include 6 | 7 | /** 8 | * Sends a command to the KIRK encryption/decryption engine. 9 | * 10 | * @param inbuf - The input buffer 11 | * @param insize - The size of input buffer 12 | * @param outbuf - The output buffer 13 | * @param outsize - The size of output buffer 14 | * @param cmd - The commands to send to KIRK engine. 15 | * 16 | * @returns < 0 on error 17 | */ 18 | int sceUtilsBufferCopyWithRange(void *inbuf, SceSize insize, void *outbuf, int outsize, int cmd); 19 | 20 | /** 21 | * Sends a command to the KIRK encryption/decryption engine, by polling 22 | * 23 | * @param inbuf - The input buffer 24 | * @param insize - The size of input buffer 25 | * @param outbuf - The output buffer 26 | * @param outsize - The size of output buffer 27 | * @param cmd - The commands to send to KIRK engine. 28 | * 29 | * @returns < 0 on error 30 | */ 31 | int sceUtilsBufferCopyByPollingWithRange(void *inbuf, SceSize insize, void *outbuf, int outsize, int cmd); 32 | 33 | /** 34 | * Used for PSAR decoding (1.00 bogus) 35 | * 36 | * @param buf - The in/out buffer to decode. 37 | * @param bufsize - The size of the buffer pointed by buf 38 | * @param retSize - Pointer to an integer that receives the size of 39 | * the decoded data. 40 | * 41 | * @returns < 0 on error 42 | */ 43 | int sceNwman_driver_9555D68D(void* buf, SceSize bufsize, int* retSize); 44 | 45 | /** 46 | * Used for PSAR decoding 47 | * 48 | * @param buf - The in/out buffer to decode. 49 | * @param bufsize - The size of the buffer pointed by buf 50 | * @param retSize - Pointer to an integer that receives the size of 51 | * the decoded data. 52 | * 53 | * @returns < 0 on error 54 | */ 55 | int sceMesgd_driver_102DC8AF(void* buf, SceSize bufsize, int* retSize); 56 | -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/include/pspmodulemgr_kernel.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/procfw_sdk_prebuilt/include/pspmodulemgr_kernel.h -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/include/pspusbdevice.h: -------------------------------------------------------------------------------- 1 | #ifndef __PSPUSBDEVICE_H__ 2 | #define __PSPUSBDEVICE_H__ 3 | 4 | /** 5 | * This functions require flash0:/kd/_usbdevice.prx to be loaded/started first. 6 | 7 | * Link with pspusbdevice for user mode access or with pspusbdevice_driver for kernel access 8 | */ 9 | 10 | #define PSP_USBDEVICE_FLASH0 0 11 | #define PSP_USBDEVICE_FLASH1 1 12 | #define PSP_USBDEVICE_FLASH2 2 13 | #define PSP_USBDEVICE_FLASH3 3 14 | #define PSP_USBDEVICE_UMD9660 4 15 | 16 | #define UNASSIGN_MASK_FLASH0 1 17 | #define UNASSIGN_MASK_FLASH1 2 18 | #define UNASSIGN_MASK_FLASH2 3 19 | #define UNASSIGN_MASK_FLASH3 4 20 | 21 | /** 22 | * Sets the usb device. Call this function when you are about to do the sceUsbStart and sceUsbActivate stuff 23 | * 24 | * @param device - The usb device, one of listed above. 25 | * @param ronly - If non-zero indicates read only access. This parameters is ignored for PSP_USBDEVICE_UMD9660 26 | * @param unassign_mask - It unassigns automatically the flashes indicated by the mask. 27 | * The flashes will be reassigned automatically after calling pspUsbDeviceFinishDevice 28 | * 29 | * Set this param to 0 if you don't need it (vshctrl doesn't use it). 30 | * 31 | * @returns 0 on success, < 0 on error. 32 | */ 33 | int pspUsbDeviceSetDevice(u32 device, int ronly, int unassign_mask); 34 | 35 | /** 36 | * Finishes the usb device. Call this function after stoping usbstor driver 37 | * 38 | * @returns 0 in success, < 0 on error 39 | */ 40 | int pspUsbDeviceFinishDevice(); 41 | 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/include/pspvshbridge.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File for sceVshBridge functions 3 | * Note: vshbridge lets vsh threads to call to some functions that 4 | * are kernel-exports only. 5 | */ 6 | 7 | #ifndef __VSHBRIDGE__ 8 | #define __VSHBRIDGE__ 9 | 10 | #include "psploadexec_kernel.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /** 17 | * Executes a new executable from a buffer. 18 | * 19 | * @param bufsize - Size in bytes of the buffer pointed by buf. 20 | * @param buf - Pointer to a buffer containing the module to execute. 21 | * @param param - Pointer to a ::SceKernelLoadExecParam structure, or NULL. 22 | * 23 | * @returns < 0 on some errors. 24 | */ 25 | int vshKernelLoadExecBufferPlain(SceSize bufsize, void *buf, struct SceKernelLoadExecParam *param); 26 | 27 | /** 28 | * Restart the vsh. 29 | * 30 | * @param unk - Unknown, I haven't checked it. Set it to NULL 31 | * 32 | * @returns < 0 on some errors. 33 | * 34 | * @note - when called in game mode it will have the same effect that sceKernelExitGame 35 | * 36 | */ 37 | int vshKernelExitVSHVSH(void *unk); 38 | 39 | /** 40 | * Executes a new executable from a disc. 41 | * It is the function used by the firmware to execute the EBOOT.BIN from a disc. 42 | * 43 | * @param file - The file to execute. 44 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 45 | * 46 | * @returns < 0 on some errors. 47 | */ 48 | int sceVshBridge_F4873F4D(const char *file, struct SceKernelLoadExecVSHParam *param); 49 | 50 | /** 51 | * Executes a new executable from a disc. 52 | * It is the function used by the firmware to execute an updater from a disc. 53 | * 54 | * @param file - The file to execute. 55 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 56 | * 57 | * @returns < 0 on some errors. 58 | */ 59 | int vshKernelLoadExecVSHDiscUpdater(const char *file, struct SceKernelLoadExecVSHParam *param); 60 | 61 | /** 62 | * Executes a new executable from a memory stick. 63 | * It is the function used by the firmware to execute an updater from a memory stick. 64 | * 65 | * @param file - The file to execute. 66 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 67 | * 68 | * @returns < 0 on some errors. 69 | */ 70 | int vshKernelLoadExecVSHMs1(const char *file, struct SceKernelLoadExecVSHParam *param); 71 | 72 | /** 73 | * Executes a new executable from a memory stick. 74 | * It is the function used by the firmware to execute games (and homebrew :P) from a memory stick. 75 | * 76 | * @param file - The file to execute. 77 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 78 | * 79 | * @returns < 0 on some errors. 80 | */ 81 | int vshKernelLoadExecVSHMs2(const char *file, struct SceKernelLoadExecVSHParam *param); 82 | 83 | /** 84 | * Executes a new executable from a memory stick. 85 | * It is the function used by the firmware to execute ... ? 86 | * 87 | * @param file - The file to execute. 88 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 89 | * 90 | * @returns < 0 on some errors. 91 | */ 92 | int vshKernelLoadExecVSHMs3(const char *file, struct SceKernelLoadExecVSHParam *param); 93 | 94 | 95 | /** 96 | * Performs a logical format in a flash partition. 97 | * 98 | * @param argc - The number of parameters 99 | * @param argv - The parameters 100 | * @return < 0 on error 101 | */ 102 | int vshLflashFatfmtStartFatfmt(int argc, char *argv[]); 103 | 104 | /** 105 | * Load a module. 106 | * 107 | * @param path - The path to the module to load. 108 | * @param flags - Unused, always 0 . 109 | * @param option - Pointer to a mod_param_t structure. Can be NULL. 110 | * 111 | * @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes. 112 | */ 113 | SceUID vshKernelLoadModuleVSH(const char *path, int flags, SceKernelLMOption *option); 114 | 115 | SceUID vshKernelLoadModuleBufferVSH(SceSize bufsize, void *buf, int flags, SceKernelLMOption *option); 116 | 117 | #ifdef __cplusplus 118 | } 119 | #endif 120 | 121 | #endif 122 | -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/include/systemctrl.h: -------------------------------------------------------------------------------- 1 | #ifndef __SCTRLLIBRARY_H__ 2 | #define __SCTRLLIBRARY_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | enum BootLoadFlags 10 | { 11 | BOOTLOAD_VSH = 1, 12 | BOOTLOAD_GAME = 2, 13 | BOOTLOAD_UPDATER = 4, 14 | BOOTLOAD_POPS = 8, 15 | BOOTLOAD_UMDEMU = 64, /* for original NP9660 */ 16 | }; 17 | 18 | /** 19 | * Restart the vsh. 20 | * 21 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL 22 | * 23 | * @returns < 0 on some errors. 24 | * 25 | */ 26 | int sctrlKernelExitVSH(struct SceKernelLoadExecVSHParam *param); 27 | 28 | /** 29 | * Executes a new executable from a disc. 30 | * It is the function used by the firmware to execute the EBOOT.BIN from a disc. 31 | * 32 | * @param file - The file to execute. 33 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 34 | * 35 | * @returns < 0 on some errors. 36 | */ 37 | int sctrlKernelLoadExecVSHDisc(const char *file, struct SceKernelLoadExecVSHParam *param); 38 | 39 | /** 40 | * Executes a new executable from a disc. 41 | * It is the function used by the firmware to execute an updater from a disc. 42 | * 43 | * @param file - The file to execute. 44 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 45 | * 46 | * @returns < 0 on some errors. 47 | */ 48 | int sctrlKernelLoadExecVSHDiscUpdater(const char *file, struct SceKernelLoadExecVSHParam *param); 49 | 50 | /** 51 | * Executes a new executable from a memory stick. 52 | * It is the function used by the firmware to execute an updater from a memory stick. 53 | * 54 | * @param file - The file to execute. 55 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 56 | * 57 | * @returns < 0 on some errors. 58 | */ 59 | int sctrlKernelLoadExecVSHMs1(const char *file, struct SceKernelLoadExecVSHParam *param); 60 | 61 | /** 62 | * Executes a new executable from a memory stick. 63 | * It is the function used by the firmware to execute games (and homebrew :P) from a memory stick. 64 | * 65 | * @param file - The file to execute. 66 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 67 | * 68 | * @returns < 0 on some errors. 69 | */ 70 | int sctrlKernelLoadExecVSHMs2(const char *file, struct SceKernelLoadExecVSHParam *param); 71 | int sctrlKernelLoadExecVSHEf2(const char *file, struct SceKernelLoadExecVSHParam *param); 72 | 73 | /** 74 | * Executes a new executable from a memory stick. 75 | * It is the function used by the firmware to execute ... ? 76 | * 77 | * @param file - The file to execute. 78 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 79 | * 80 | * @returns < 0 on some errors. 81 | */ 82 | int sctrlKernelLoadExecVSHMs3(const char *file, struct SceKernelLoadExecVSHParam *param); 83 | 84 | /** 85 | * Executes a new executable from a memory stick. 86 | * It is the function used by the firmware to execute psx games 87 | * 88 | * @param file - The file to execute. 89 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 90 | * 91 | * @returns < 0 on some errors. 92 | */ 93 | int sctrlKernelLoadExecVSHMs4(const char *file, struct SceKernelLoadExecVSHParam *param); 94 | 95 | 96 | /** 97 | * Executes a new executable with the specified apitype 98 | * 99 | * @param apitype - The apitype 100 | * @param file - The file to execute. 101 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 102 | * 103 | * @returns < 0 on some errors. 104 | */ 105 | int sctrlKernelLoadExecVSHWithApitype(int apitype, const char *file, struct SceKernelLoadExecVSHParam *param); 106 | 107 | /** 108 | * Sets the api type 109 | * 110 | * @param apitype - The apitype to set 111 | * @returns the previous apitype 112 | * 113 | * @Note - this will modify also the value of sceKernelBootFrom, since the value of 114 | * bootfrom is calculated from the apitype 115 | */ 116 | int sctrlKernelSetInitApitype(int apitype); 117 | 118 | /** 119 | * Sets the filename of the launched executable. 120 | * 121 | * @param filename - The filename to set 122 | * @returns 0 on success 123 | */ 124 | int sctrlKernelSetInitFileName(char *filename); 125 | 126 | /** 127 | * Sets the init key config 128 | * 129 | * @param key - The key code 130 | * @returns the previous key config 131 | */ 132 | int sctrlKernelSetInitKeyConfig(int key); 133 | 134 | /** 135 | * Sets the user level of the current thread 136 | * 137 | * @param level - The user level 138 | * @return the previous user level on success 139 | */ 140 | int sctrlKernelSetUserLevel(int level); 141 | 142 | /** 143 | * Sets the devkit version 144 | * 145 | * @param version - The devkit version to set 146 | * @return the previous devkit version 147 | * 148 | */ 149 | int sctrlKernelSetDevkitVersion(int version); 150 | 151 | /** 152 | * Checks if we are in SE. 153 | * 154 | * @returns 1 if we are in SE-C or later, 0 if we are in HEN-D or later, 155 | * and < 0 (a kernel error code) in any other case 156 | */ 157 | int sctrlHENIsSE(); 158 | 159 | /** 160 | * Checks if we are in Devhook. 161 | * 162 | * @returns 1 if we are in SE-C/HEN-D for devhook or later, 0 if we are in normal SE-C/HEN-D or later, 163 | * and < 0 (a kernel error code) in any other case 164 | */ 165 | int sctrlHENIsDevhook(); 166 | 167 | /** 168 | * Gets the HEN version 169 | * 170 | * @returns - The HEN version 171 | * 172 | * HEN D / SE-C : 0x00000400 173 | */ 174 | int sctrlHENGetVersion(); 175 | 176 | /** 177 | * Gets the HEN minor version 178 | * 179 | * @returns - The HEN minor version 180 | */ 181 | int sctrlHENGetMinorVersion(); 182 | 183 | /** 184 | * Finds a driver 185 | * 186 | * @param drvname - The name of the driver (without ":" or numbers) 187 | * 188 | * @returns the driver if found, NULL otherwise 189 | * 190 | */ 191 | PspIoDrv *sctrlHENFindDriver(char *drvname); 192 | 193 | /** 194 | * Finds a function. 195 | * 196 | * @param modname - The module where to search the function 197 | * @param libname - The library name 198 | * @nid - The nid of the function 199 | * 200 | * @returns - The function address or 0 if not found 201 | * 202 | */ 203 | u32 sctrlHENFindFunction(char *modname, char *libname, u32 nid); 204 | 205 | typedef struct SceModule2 { 206 | struct SceModule2 *next; 207 | unsigned short attribute; 208 | unsigned char version[2]; 209 | char modname[27]; 210 | char terminal; 211 | unsigned int unknown1; 212 | unsigned int unknown2; 213 | SceUID modid; 214 | unsigned int unknown3[2]; 215 | u32 mpid_text; // 0x38 216 | u32 mpid_data; // 0x3C 217 | void * ent_top; 218 | unsigned int ent_size; 219 | void * stub_top; 220 | unsigned int stub_size; 221 | unsigned int unknown4[5]; 222 | unsigned int entry_addr; 223 | unsigned int gp_value; 224 | unsigned int text_addr; 225 | unsigned int text_size; 226 | unsigned int data_size; 227 | unsigned int bss_size; 228 | unsigned int nsegment; 229 | unsigned int segmentaddr[4]; 230 | unsigned int segmentsize[4]; 231 | } SceModule2; 232 | 233 | typedef int (* STMOD_HANDLER)(SceModule2 *); 234 | 235 | /** 236 | * Sets a function to be called just before module_start of a module is gonna be called (useful for patching purposes) 237 | * 238 | * @param handler - The function, that will receive the module structure before the module is started. 239 | * 240 | * @returns - The previous set function (NULL if none); 241 | * @Note: because only one handler function is handled by HEN, you should 242 | * call the previous function in your code. 243 | * 244 | * @Example: 245 | * 246 | * STMOD_HANDLER previous = NULL; 247 | * 248 | * int OnModuleStart(SceModule2 *mod); 249 | * 250 | * void somepointofmycode() 251 | * { 252 | * previous = sctrlHENSetStartModuleHandler(OnModuleStart); 253 | * } 254 | * 255 | * int OnModuleStart(SceModule2 *mod) 256 | * { 257 | * if (strcmp(mod->modname, "vsh_module") == 0) 258 | * { 259 | * // Do something with vsh module here 260 | * } 261 | * 262 | * if (!previous) 263 | * return 0; 264 | * 265 | * // Call previous handler 266 | * 267 | * return previous(mod); 268 | * } 269 | * 270 | * @Note2: The above example should be compiled with the flag -fno-pic 271 | * in order to avoid problems with gp register that may lead to a crash. 272 | * 273 | */ 274 | STMOD_HANDLER sctrlHENSetStartModuleHandler(STMOD_HANDLER handler); 275 | 276 | typedef int (* KDEC_HANDLER)(u32 *buf, int size, int *retSize, int m); 277 | typedef int (* MDEC_HANDLER)(u32 *tag, u8 *keys, u32 code, u32 *buf, int size, int *retSize, int m, void *unk0, int unk1, int unk2, int unk3, int unk4); 278 | 279 | /** 280 | * Sets the speed (only for kernel usage) 281 | * 282 | * @param cpu - The cpu speed 283 | * @param bus - The bus speed 284 | */ 285 | void sctrlHENSetSpeed(int cpu, int bus); 286 | 287 | /** 288 | * Sets the partition 2 and 8 memory for next loadexec. 289 | * 290 | * @param p2 - The size in MB for the user partition. Must be > 0 291 | * @param p8 - The size in MB for partition 8. Can be 0. 292 | * 293 | * @returns 0 on success, < 0 on error. 294 | * This function is only available in the slim. The function will fail 295 | * if p2+p8 > 52 or p2 == 0 296 | */ 297 | int sctrlHENSetMemory(u32 p2, u32 p8); 298 | 299 | void sctrlHENPatchSyscall(void *addr, void *newaddr); 300 | 301 | int sctrlKernelQuerySystemCall(void *func_addr); 302 | 303 | int sctrlKernelBootFrom(void); 304 | 305 | /** 306 | * Patch module by offset 307 | * 308 | * @param modname - module name 309 | * @param inst - instruction 310 | * @param offset - module patch offset 311 | * 312 | * @return < 0 on error 313 | */ 314 | int sctrlPatchModule(char *modname, u32 inst, u32 offset); 315 | 316 | /** 317 | * Get module text address 318 | * 319 | * @param modname - module name 320 | * 321 | * @return text address, or 0 if not found 322 | */ 323 | u32 sctrlModuleTextAddr(char *modname); 324 | 325 | /** 326 | * Get sceInit module text address 327 | * 328 | * @note Only useful before sceInit exits 329 | * 330 | * @return text address, or 0 if not found 331 | */ 332 | u32 sctrlGetInitTextAddr(void); 333 | 334 | /** 335 | * Set custom start module handler 336 | * It can be used to replace a system module 337 | * 338 | * @note: func returns -1 to ignore the module and load the original module. Or new modid if replace is done. 339 | */ 340 | void sctrlSetCustomStartModule(int (*func)(int modid, SceSize argsize, void *argp, int *modstatus, SceKernelSMOption *opt)); 341 | 342 | /** 343 | * Loads a module on next reboot. Only kernel mode. 344 | * 345 | * @param module_after - The path of the module which is loaded after the module to be loaded. 346 | The module passed to this function will be loaded just before that module. 347 | * @param buf - The buffer containing the module - Don't deallocate this one. It has to reside in kernel memory. 348 | * @param size - The size of the module 349 | * @param flags - The modes in which the module should be loaded, one of BootLoadFlags 350 | * 351 | * @Example: 352 | * sctrlHENLoadModuleOnReboot("/kd/usersystemlib.prx", module_buffer, module_size, BOOTLOAD_GAME | BOOTLOAD_POPS | BOOTLOAD_UMDEMU); 353 | * 354 | * This will load the module contained in module_buffer just before /kd/usersystemlib.prx in the next reboot, if the mode of next reboot is game, pops or umdemu 355 | * 356 | * @Remarks: Don't use too early modules in first param like "/kd/init.prx" or "/kd/systemctrl.prx", or your module may not load properly 357 | * Only one module will be loaded on reboot with this function. 358 | * If this function is called many times, only the last one will be considered. 359 | * By making a module to load itself using this function, and calling 360 | * sctrlHENLoadModuleOnReboot on module_start, a prx can cause itself to be resident in the modes choosen by flags. 361 | * If all flags are selected, the module will stay resident until a psp shutdown, or until sctrlHENLoadModuleOnReboot is not called. 362 | */ 363 | 364 | void sctrlHENLoadModuleOnReboot(char *module_after, void *buf, int size, int flags); 365 | 366 | /** 367 | * Enable/disable NID Resolver on particular library 368 | * 369 | * @param libname the name of the library to be enabled/disabled 370 | * @param enabled 0 - disabled, != 0 - enabled 371 | * 372 | * @Example: 373 | * sctrlKernelSetNidResolver("sceImpose_driver", 0); // disable sceImpose_driver resolving 374 | * 375 | * @return previous value if set, < 0 on error 376 | */ 377 | int sctrlKernelSetNidResolver(char *libname, u32 enabled); 378 | 379 | /** 380 | * Get a random u32 key from PSP Kirk PRNG 381 | */ 382 | u32 sctrlKernelRand(void); 383 | 384 | /** 385 | * Get the real unspoofed Ethernet (MAC) Address of the systems WLAN chip 386 | * 387 | * @param mac Out-Buffer (6B) for real MAC Address 388 | * 389 | * @return 0 on success, < 0 on error 390 | */ 391 | int sctrlGetRealEthernetAddress(uint8_t * mac); 392 | 393 | #endif 394 | -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/include/systemctrl_se.h: -------------------------------------------------------------------------------- 1 | #ifndef __SCTRLLIBRARY_SE_H__ 2 | #define __SCTRLLIBRARY_SE_H__ 3 | 4 | /** 5 | * These functions are only available in SE-C and later, 6 | * and they are not in HEN 7 | */ 8 | 9 | enum 10 | { 11 | FAKE_REGION_DISABLED = 0, 12 | FAKE_REGION_JAPAN = 1, 13 | FAKE_REGION_AMERICA = 2, 14 | FAKE_REGION_EUROPE = 3, 15 | FAKE_REGION_KOREA = 4, 16 | FAKE_REGION_UNK = 5, 17 | FAKE_REGION_UNK2 = 6, 18 | FAKE_REGION_AUSTRALIA = 7, 19 | FAKE_REGION_HONGKONG = 8, 20 | FAKE_REGION_TAIWAN = 9, 21 | FAKE_REGION_RUSSIA = 10, 22 | FAKE_REGION_CHINA = 11, 23 | FAKE_REGION_DEBUG_TYPE_I = 12, 24 | FAKE_REGION_DEBUG_TYPE_II = 13, 25 | }; 26 | 27 | // No MODE_OE_LEGACY any more 28 | enum SEUmdModes 29 | { 30 | MODE_UMD = 0, 31 | MODE_MARCH33 = 1, 32 | MODE_NP9660 = 2, 33 | MODE_INFERNO = 3, 34 | MODE_VSHUMD = 4, 35 | MODE_UPDATERUMD = 5, 36 | }; 37 | 38 | enum MsSpeedFlag 39 | { 40 | MSSPEED_NONE = 0, 41 | MSSPEED_POP = 1, 42 | MSSPEED_GAME = 2, 43 | MSSPEED_VSH = 3, 44 | MSSPEED_POP_GAME = 4, 45 | MSSPEED_GAME_VSH = 5, 46 | MSSPEED_VSH_POP = 6, 47 | MSSPEED_ALWAYS = 7, 48 | }; 49 | 50 | enum InfernoCachePolicy 51 | { 52 | CACHE_POLICY_LRU = 0, 53 | CACHE_POLICY_RR = 1, 54 | }; 55 | 56 | typedef struct _SEConfig 57 | { 58 | int magic; 59 | s16 umdmode; 60 | s16 vshcpuspeed; 61 | s16 vshbusspeed; 62 | s16 umdisocpuspeed; 63 | s16 umdisobusspeed; 64 | s16 fakeregion; 65 | s16 usbdevice; 66 | s16 usbcharge; 67 | s16 machidden; 68 | s16 skipgameboot; 69 | s16 hidepic; 70 | s16 plugvsh; 71 | s16 pluggame; 72 | s16 plugpop; 73 | s16 flashprot; 74 | s16 skiplogo; 75 | s16 useversion; 76 | s16 useownupdate; 77 | s16 usenodrm; 78 | s16 hibblock; 79 | s16 noanalog; 80 | s16 oldplugin; 81 | s16 htmlviewer_custom_save_location; 82 | s16 hide_cfw_dirs; 83 | s16 chn_iso; 84 | s16 msspeed; 85 | s16 slimcolor; 86 | s16 iso_cache; 87 | s16 iso_cache_total_size; // in MB 88 | s16 iso_cache_num; 89 | s16 iso_cache_policy; 90 | s16 usbversion; 91 | s16 language; /* -1 as autodetect */ 92 | s16 retail_high_memory; 93 | s16 macspoofer; 94 | } SEConfig; 95 | 96 | /** 97 | * Gets the SE/OE version 98 | * 99 | * @returns the SE version 100 | * 101 | * 3.03 OE-A: 0x00000500 102 | */ 103 | int sctrlSEGetVersion(); 104 | 105 | /** 106 | * Gets the SE configuration. 107 | * Avoid using this function, it may corrupt your program. 108 | * Use sctrlSEGetCongiEx function instead. 109 | * 110 | * @param config - pointer to a SEConfig structure that receives the SE configuration 111 | * @returns 0 on success 112 | */ 113 | int sctrlSEGetConfig(SEConfig *config); 114 | 115 | /** 116 | * Gets the SE configuration 117 | * 118 | * @param config - pointer to a SEConfig structure that receives the SE configuration 119 | * @param size - The size of the structure 120 | * @returns 0 on success 121 | */ 122 | int sctrlSEGetConfigEx(SEConfig *config, int size); 123 | 124 | /** 125 | * Sets the SE configuration 126 | * This function can corrupt the configuration in flash, use 127 | * sctrlSESetConfigEx instead. 128 | * 129 | * @param config - pointer to a SEConfig structure that has the SE configuration to set 130 | * @returns 0 on success 131 | */ 132 | int sctrlSESetConfig(SEConfig *config); 133 | 134 | /** 135 | * Sets the SE configuration 136 | * 137 | * @param config - pointer to a SEConfig structure that has the SE configuration to set 138 | * @param size - the size of the structure 139 | * @returns 0 on success 140 | */ 141 | int sctrlSESetConfigEx(SEConfig *config, int size); 142 | 143 | /** 144 | * Initiates the emulation of a disc from an ISO9660/CSO file. 145 | * 146 | * @param file - The path of the 147 | * @param noumd - Wether use noumd or not 148 | * @param isofs - Wether use the custom SE isofs driver or not 149 | * 150 | * @returns 0 on success 151 | * 152 | * @Note - When setting noumd to 1, isofs should also be set to 1, 153 | * otherwise the umd would be still required. 154 | * 155 | * @Note 2 - The function doesn't check if the file is valid or even if it exists 156 | * and it may return success on those cases 157 | * 158 | * @Note 3 - This function is not available in SE for devhook 159 | * @Example: 160 | * 161 | * SEConfig config; 162 | * 163 | * sctrlSEGetConfig(&config); 164 | * 165 | * if (config.usenoumd) 166 | * { 167 | * sctrlSEMountUmdFromFile("ms0:/ISO/mydisc.iso", 1, 1); 168 | * } 169 | * else 170 | * { 171 | * sctrlSEMountUmdFromFile("ms0:/ISO/mydisc.iso", 0, config.useisofsonumdinserted); 172 | * } 173 | */ 174 | int sctrlSEMountUmdFromFile(char *file, int noumd, int isofs); 175 | 176 | /** 177 | * Umounts an iso. 178 | * 179 | * @returns 0 on success 180 | */ 181 | int sctrlSEUmountUmd(void); 182 | 183 | /** 184 | * Forces the umd disc out state 185 | * 186 | * @param out - non-zero for disc out, 0 otherwise 187 | * 188 | */ 189 | void sctrlSESetDiscOut(int out); 190 | 191 | /** 192 | * Sets the disctype. 193 | * 194 | * @param type - the disctype (0x10=game, 0x20=video, 0x40=audio) 195 | * @note: Currently only inferno available, needs reset to take effect 196 | */ 197 | void sctrlSESetDiscType(int type); 198 | 199 | /** 200 | * Get the disctype. 201 | */ 202 | int sctrlSEGetDiscType(void); 203 | 204 | /** 205 | * Sets the current umd file (kernel only) 206 | */ 207 | char *sctrlSEGetUmdFile(); 208 | 209 | /** 210 | * Gets the current umd file (kernel only) 211 | */ 212 | char *sctrlSEGetUmdFile(); 213 | 214 | /** 215 | * Sets the current umd file (kernel only) 216 | * 217 | * @param file - The umd file 218 | */ 219 | void sctrlSESetUmdFile(char *file); 220 | 221 | /** 222 | * Sets the boot config file for next reboot 223 | * 224 | * @param index - The index identifying the file (0 -> normal bootconf, 1 -> march33 driver bootconf, 2 -> np9660 bootcnf, 3 -> inferno bootconf), 4 -> inferno vsh mount 225 | */ 226 | void sctrlSESetBootConfFileIndex(int index); 227 | 228 | /** 229 | * Get the boot config index 230 | */ 231 | u32 sctrlSEGetBootConfFileIndex(void); 232 | 233 | #endif 234 | -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/include/vshctrl.h: -------------------------------------------------------------------------------- 1 | #ifndef __VSHCTRL_H__ 2 | #define __VSHCTRL_H__ 3 | 4 | /** 5 | * This api is for vsh menu. (flash0:/vsh/module/_satelite.prx) 6 | * 7 | * The vsh menu is an user mode module, and because of this, these functions are 8 | * only available to user mode. 9 | */ 10 | 11 | /** 12 | * Registers the vsh menu. 13 | * When HOME is pressed, vshctrl will load the satelite module. 14 | * In module_start, call this function to register the vsh menu. 15 | * 16 | * @param ctrl - The function that will be executed each time 17 | * the system calls ReadBufferPositive. Despite satelite.prx being 18 | * an user module, this function will be executed in kernel mode. 19 | * 20 | * @returns 0 on success, < 0 on error. 21 | */ 22 | int vctrlVSHRegisterVshMenu(int (* ctrl)(SceCtrlData *, int)); 23 | 24 | /** 25 | * Exits the vsh menu. 26 | * vshmenu module must call this module after destroying vsh menu display and 27 | * freeing resources. 28 | * 29 | * vshmenu module doesn't need to stop-unload itself, as that is vshctrl job. 30 | * 31 | * @param conf - Indicates the new config. vshctrl will update the internal 32 | * vshctrl and systemctrl variables with the new configuration given by this param. 33 | * However is job of satelite.prx to save those settings to the configuration file. 34 | * using sctrlSESetConfig. 35 | * 36 | * @param videoiso - Indicates the videoiso to mount, or NULL if none. 37 | * @param disctype - The disctype of the videoiso (0x20=video, 0x40=audio) 38 | * 39 | * @returns 0 on success, < 0 on error. 40 | */ 41 | int vctrlVSHExitVSHMenu(SEConfig *conf, char *videoiso, int disctype); 42 | 43 | int vctrlVSHUpdateConfig(SEConfig *config); 44 | 45 | int vshDetectDiscType(const char *path); 46 | 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/include/zconf.h: -------------------------------------------------------------------------------- 1 | /* zconf.h -- configuration of the zlib compression library 2 | * Copyright (C) 1995-2004 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #ifndef ZCONF_H 9 | #define ZCONF_H 10 | 11 | /* 12 | * If you *really* need a unique prefix for all types and library functions, 13 | * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. 14 | */ 15 | #ifdef Z_PREFIX 16 | # define deflateInit_ z_deflateInit_ 17 | # define deflate z_deflate 18 | # define deflateEnd z_deflateEnd 19 | # define inflateInit_ z_inflateInit_ 20 | # define inflate z_inflate 21 | # define inflateEnd z_inflateEnd 22 | # define deflateInit2_ z_deflateInit2_ 23 | # define deflateSetDictionary z_deflateSetDictionary 24 | # define deflateCopy z_deflateCopy 25 | # define deflateReset z_deflateReset 26 | # define deflateParams z_deflateParams 27 | # define deflateBound z_deflateBound 28 | # define deflatePrime z_deflatePrime 29 | # define inflateInit2_ z_inflateInit2_ 30 | # define inflateSetDictionary z_inflateSetDictionary 31 | # define inflateSync z_inflateSync 32 | # define inflateSyncPoint z_inflateSyncPoint 33 | # define inflateCopy z_inflateCopy 34 | # define inflateReset z_inflateReset 35 | # define inflateBack z_inflateBack 36 | # define inflateBackEnd z_inflateBackEnd 37 | # define compress z_compress 38 | # define compress2 z_compress2 39 | # define compressBound z_compressBound 40 | # define uncompress z_uncompress 41 | # define adler32 z_adler32 42 | # define crc32 z_crc32 43 | # define get_crc_table z_get_crc_table 44 | # define zError z_zError 45 | 46 | # define Byte z_Byte 47 | # define uInt z_uInt 48 | # define uLong z_uLong 49 | # define Bytef z_Bytef 50 | # define charf z_charf 51 | # define intf z_intf 52 | # define uIntf z_uIntf 53 | # define uLongf z_uLongf 54 | # define voidpf z_voidpf 55 | # define voidp z_voidp 56 | #endif 57 | 58 | #if defined(__MSDOS__) && !defined(MSDOS) 59 | # define MSDOS 60 | #endif 61 | #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) 62 | # define OS2 63 | #endif 64 | #if defined(_WINDOWS) && !defined(WINDOWS) 65 | # define WINDOWS 66 | #endif 67 | #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) 68 | # define WIN32 69 | #endif 70 | #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) 71 | # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) 72 | # ifndef SYS16BIT 73 | # define SYS16BIT 74 | # endif 75 | # endif 76 | #endif 77 | 78 | /* 79 | * Compile with -DMAXSEG_64K if the alloc function cannot allocate more 80 | * than 64k bytes at a time (needed on systems with 16-bit int). 81 | */ 82 | #ifdef SYS16BIT 83 | # define MAXSEG_64K 84 | #endif 85 | #ifdef MSDOS 86 | # define UNALIGNED_OK 87 | #endif 88 | 89 | #ifdef __STDC_VERSION__ 90 | # ifndef STDC 91 | # define STDC 92 | # endif 93 | # if __STDC_VERSION__ >= 199901L 94 | # ifndef STDC99 95 | # define STDC99 96 | # endif 97 | # endif 98 | #endif 99 | #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) 100 | # define STDC 101 | #endif 102 | #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) 103 | # define STDC 104 | #endif 105 | #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) 106 | # define STDC 107 | #endif 108 | #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) 109 | # define STDC 110 | #endif 111 | 112 | #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ 113 | # define STDC 114 | #endif 115 | 116 | #ifndef STDC 117 | # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ 118 | # define const /* note: need a more gentle solution here */ 119 | # endif 120 | #endif 121 | 122 | /* Some Mac compilers merge all .h files incorrectly: */ 123 | #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) 124 | # define NO_DUMMY_DECL 125 | #endif 126 | 127 | /* Maximum value for memLevel in deflateInit2 */ 128 | #ifndef MAX_MEM_LEVEL 129 | # ifdef MAXSEG_64K 130 | # define MAX_MEM_LEVEL 8 131 | # else 132 | # define MAX_MEM_LEVEL 9 133 | # endif 134 | #endif 135 | 136 | /* Maximum value for windowBits in deflateInit2 and inflateInit2. 137 | * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files 138 | * created by gzip. (Files created by minigzip can still be extracted by 139 | * gzip.) 140 | */ 141 | #ifndef MAX_WBITS 142 | # define MAX_WBITS 15 /* 32K LZ77 window */ 143 | #endif 144 | 145 | /* The memory requirements for deflate are (in bytes): 146 | (1 << (windowBits+2)) + (1 << (memLevel+9)) 147 | that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) 148 | plus a few kilobytes for small objects. For example, if you want to reduce 149 | the default memory requirements from 256K to 128K, compile with 150 | make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" 151 | Of course this will generally degrade compression (there's no free lunch). 152 | 153 | The memory requirements for inflate are (in bytes) 1 << windowBits 154 | that is, 32K for windowBits=15 (default value) plus a few kilobytes 155 | for small objects. 156 | */ 157 | 158 | /* Type declarations */ 159 | 160 | #ifndef OF /* function prototypes */ 161 | # ifdef STDC 162 | # define OF(args) args 163 | # else 164 | # define OF(args) () 165 | # endif 166 | #endif 167 | 168 | /* The following definitions for FAR are needed only for MSDOS mixed 169 | * model programming (small or medium model with some far allocations). 170 | * This was tested only with MSC; for other MSDOS compilers you may have 171 | * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, 172 | * just define FAR to be empty. 173 | */ 174 | #ifdef SYS16BIT 175 | # if defined(M_I86SM) || defined(M_I86MM) 176 | /* MSC small or medium model */ 177 | # define SMALL_MEDIUM 178 | # ifdef _MSC_VER 179 | # define FAR _far 180 | # else 181 | # define FAR far 182 | # endif 183 | # endif 184 | # if (defined(__SMALL__) || defined(__MEDIUM__)) 185 | /* Turbo C small or medium model */ 186 | # define SMALL_MEDIUM 187 | # ifdef __BORLANDC__ 188 | # define FAR _far 189 | # else 190 | # define FAR far 191 | # endif 192 | # endif 193 | #endif 194 | 195 | #if defined(WINDOWS) || defined(WIN32) 196 | /* If building or using zlib as a DLL, define ZLIB_DLL. 197 | * This is not mandatory, but it offers a little performance increase. 198 | */ 199 | # ifdef ZLIB_DLL 200 | # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) 201 | # ifdef ZLIB_INTERNAL 202 | # define ZEXTERN extern __declspec(dllexport) 203 | # else 204 | # define ZEXTERN extern __declspec(dllimport) 205 | # endif 206 | # endif 207 | # endif /* ZLIB_DLL */ 208 | /* If building or using zlib with the WINAPI/WINAPIV calling convention, 209 | * define ZLIB_WINAPI. 210 | * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. 211 | */ 212 | # ifdef ZLIB_WINAPI 213 | # ifdef FAR 214 | # undef FAR 215 | # endif 216 | # include 217 | /* No need for _export, use ZLIB.DEF instead. */ 218 | /* For complete Windows compatibility, use WINAPI, not __stdcall. */ 219 | # define ZEXPORT WINAPI 220 | # ifdef WIN32 221 | # define ZEXPORTVA WINAPIV 222 | # else 223 | # define ZEXPORTVA FAR CDECL 224 | # endif 225 | # endif 226 | #endif 227 | 228 | #if defined (__BEOS__) 229 | # ifdef ZLIB_DLL 230 | # ifdef ZLIB_INTERNAL 231 | # define ZEXPORT __declspec(dllexport) 232 | # define ZEXPORTVA __declspec(dllexport) 233 | # else 234 | # define ZEXPORT __declspec(dllimport) 235 | # define ZEXPORTVA __declspec(dllimport) 236 | # endif 237 | # endif 238 | #endif 239 | 240 | #ifndef ZEXTERN 241 | # define ZEXTERN extern 242 | #endif 243 | #ifndef ZEXPORT 244 | # define ZEXPORT 245 | #endif 246 | #ifndef ZEXPORTVA 247 | # define ZEXPORTVA 248 | #endif 249 | 250 | #ifndef FAR 251 | # define FAR 252 | #endif 253 | 254 | #if !defined(__MACTYPES__) 255 | typedef unsigned char Byte; /* 8 bits */ 256 | #endif 257 | typedef unsigned int uInt; /* 16 bits or more */ 258 | typedef unsigned long uLong; /* 32 bits or more */ 259 | 260 | #ifdef SMALL_MEDIUM 261 | /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ 262 | # define Bytef Byte FAR 263 | #else 264 | typedef Byte FAR Bytef; 265 | #endif 266 | typedef char FAR charf; 267 | typedef int FAR intf; 268 | typedef uInt FAR uIntf; 269 | typedef uLong FAR uLongf; 270 | 271 | #ifdef STDC 272 | typedef void const *voidpc; 273 | typedef void FAR *voidpf; 274 | typedef void *voidp; 275 | #else 276 | typedef Byte const *voidpc; 277 | typedef Byte FAR *voidpf; 278 | typedef Byte *voidp; 279 | #endif 280 | 281 | #if 1 /* HAVE_UNISTD_H -- this line is updated by ./configure */ 282 | # include /* for off_t */ 283 | # include /* for SEEK_* and off_t */ 284 | # ifdef VMS 285 | # include /* for off_t */ 286 | # endif 287 | # define z_off_t off_t 288 | #endif 289 | #ifndef SEEK_SET 290 | # define SEEK_SET 0 /* Seek from beginning of file. */ 291 | # define SEEK_CUR 1 /* Seek from current position. */ 292 | # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ 293 | #endif 294 | #ifndef z_off_t 295 | # define z_off_t long 296 | #endif 297 | 298 | #if defined(__OS400__) 299 | # define NO_vsnprintf 300 | #endif 301 | 302 | #if defined(__MVS__) 303 | # define NO_vsnprintf 304 | # ifdef FAR 305 | # undef FAR 306 | # endif 307 | #endif 308 | 309 | /* MVS linker does not support external names larger than 8 bytes */ 310 | #if defined(__MVS__) 311 | # pragma map(deflateInit_,"DEIN") 312 | # pragma map(deflateInit2_,"DEIN2") 313 | # pragma map(deflateEnd,"DEEND") 314 | # pragma map(deflateBound,"DEBND") 315 | # pragma map(inflateInit_,"ININ") 316 | # pragma map(inflateInit2_,"ININ2") 317 | # pragma map(inflateEnd,"INEND") 318 | # pragma map(inflateSync,"INSY") 319 | # pragma map(inflateSetDictionary,"INSEDI") 320 | # pragma map(compressBound,"CMBND") 321 | # pragma map(inflate_table,"INTABL") 322 | # pragma map(inflate_fast,"INFA") 323 | # pragma map(inflate_copyright,"INCOPY") 324 | #endif 325 | 326 | #endif /* ZCONF_H */ 327 | -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/include/zlib.h: -------------------------------------------------------------------------------- 1 | /* zlib.h -- interface of the 'zlib' general purpose compression library 2 | version 1.2.2, October 3rd, 2004 3 | 4 | Copyright (C) 1995-2004 Jean-loup Gailly and Mark Adler 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | 10 | Permission is granted to anyone to use this software for any purpose, 11 | including commercial applications, and to alter it and redistribute it 12 | freely, subject to the following restrictions: 13 | 14 | 1. The origin of this software must not be misrepresented; you must not 15 | claim that you wrote the original software. If you use this software 16 | in a product, an acknowledgment in the product documentation would be 17 | appreciated but is not required. 18 | 2. Altered source versions must be plainly marked as such, and must not be 19 | misrepresented as being the original software. 20 | 3. This notice may not be removed or altered from any source distribution. 21 | 22 | Jean-loup Gailly Mark Adler 23 | jloup@gzip.org madler@alumni.caltech.edu 24 | 25 | 26 | The data format used by the zlib library is described by RFCs (Request for 27 | Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt 28 | (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). 29 | */ 30 | 31 | #ifndef ZLIB_H 32 | #define ZLIB_H 33 | 34 | #include "zconf.h" 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | #define ZLIB_VERSION "1.2.2" 41 | #define ZLIB_VERNUM 0x1220 42 | 43 | /* 44 | The 'zlib' compression library provides in-memory compression and 45 | decompression functions, including integrity checks of the uncompressed 46 | data. This version of the library supports only one compression method 47 | (deflation) but other algorithms will be added later and will have the same 48 | stream interface. 49 | 50 | Compression can be done in a single step if the buffers are large 51 | enough (for example if an input file is mmap'ed), or can be done by 52 | repeated calls of the compression function. In the latter case, the 53 | application must provide more input and/or consume the output 54 | (providing more output space) before each call. 55 | 56 | The compressed data format used by default by the in-memory functions is 57 | the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped 58 | around a deflate stream, which is itself documented in RFC 1951. 59 | 60 | The library also supports reading and writing files in gzip (.gz) format 61 | with an interface similar to that of stdio using the functions that start 62 | with "gz". The gzip format is different from the zlib format. gzip is a 63 | gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. 64 | 65 | This library can optionally read and write gzip streams in memory as well. 66 | 67 | The zlib format was designed to be compact and fast for use in memory 68 | and on communications channels. The gzip format was designed for single- 69 | file compression on file systems, has a larger header than zlib to maintain 70 | directory information, and uses a different, slower check method than zlib. 71 | 72 | The library does not install any signal handler. The decoder checks 73 | the consistency of the compressed data, so the library should never 74 | crash even in case of corrupted input. 75 | */ 76 | 77 | typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); 78 | typedef void (*free_func) OF((voidpf opaque, voidpf address)); 79 | 80 | struct internal_state; 81 | 82 | typedef struct z_stream_s { 83 | Bytef *next_in; /* next input byte */ 84 | uInt avail_in; /* number of bytes available at next_in */ 85 | uLong total_in; /* total nb of input bytes read so far */ 86 | 87 | Bytef *next_out; /* next output byte should be put there */ 88 | uInt avail_out; /* remaining free space at next_out */ 89 | uLong total_out; /* total nb of bytes output so far */ 90 | 91 | char *msg; /* last error message, NULL if no error */ 92 | struct internal_state FAR *state; /* not visible by applications */ 93 | 94 | alloc_func zalloc; /* used to allocate the internal state */ 95 | free_func zfree; /* used to free the internal state */ 96 | voidpf opaque; /* private data object passed to zalloc and zfree */ 97 | 98 | int data_type; /* best guess about the data type: ascii or binary */ 99 | uLong adler; /* adler32 value of the uncompressed data */ 100 | uLong reserved; /* reserved for future use */ 101 | } z_stream; 102 | 103 | typedef z_stream FAR *z_streamp; 104 | 105 | /* 106 | The application must update next_in and avail_in when avail_in has 107 | dropped to zero. It must update next_out and avail_out when avail_out 108 | has dropped to zero. The application must initialize zalloc, zfree and 109 | opaque before calling the init function. All other fields are set by the 110 | compression library and must not be updated by the application. 111 | 112 | The opaque value provided by the application will be passed as the first 113 | parameter for calls of zalloc and zfree. This can be useful for custom 114 | memory management. The compression library attaches no meaning to the 115 | opaque value. 116 | 117 | zalloc must return Z_NULL if there is not enough memory for the object. 118 | If zlib is used in a multi-threaded application, zalloc and zfree must be 119 | thread safe. 120 | 121 | On 16-bit systems, the functions zalloc and zfree must be able to allocate 122 | exactly 65536 bytes, but will not be required to allocate more than this 123 | if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, 124 | pointers returned by zalloc for objects of exactly 65536 bytes *must* 125 | have their offset normalized to zero. The default allocation function 126 | provided by this library ensures this (see zutil.c). To reduce memory 127 | requirements and avoid any allocation of 64K objects, at the expense of 128 | compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). 129 | 130 | The fields total_in and total_out can be used for statistics or 131 | progress reports. After compression, total_in holds the total size of 132 | the uncompressed data and may be saved for use in the decompressor 133 | (particularly if the decompressor wants to decompress everything in 134 | a single step). 135 | */ 136 | 137 | /* constants */ 138 | 139 | #define Z_NO_FLUSH 0 140 | #define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ 141 | #define Z_SYNC_FLUSH 2 142 | #define Z_FULL_FLUSH 3 143 | #define Z_FINISH 4 144 | #define Z_BLOCK 5 145 | /* Allowed flush values; see deflate() and inflate() below for details */ 146 | 147 | #define Z_OK 0 148 | #define Z_STREAM_END 1 149 | #define Z_NEED_DICT 2 150 | #define Z_ERRNO (-1) 151 | #define Z_STREAM_ERROR (-2) 152 | #define Z_DATA_ERROR (-3) 153 | #define Z_MEM_ERROR (-4) 154 | #define Z_BUF_ERROR (-5) 155 | #define Z_VERSION_ERROR (-6) 156 | /* Return codes for the compression/decompression functions. Negative 157 | * values are errors, positive values are used for special but normal events. 158 | */ 159 | 160 | #define Z_NO_COMPRESSION 0 161 | #define Z_BEST_SPEED 1 162 | #define Z_BEST_COMPRESSION 9 163 | #define Z_DEFAULT_COMPRESSION (-1) 164 | /* compression levels */ 165 | 166 | #define Z_FILTERED 1 167 | #define Z_HUFFMAN_ONLY 2 168 | #define Z_RLE 3 169 | #define Z_DEFAULT_STRATEGY 0 170 | /* compression strategy; see deflateInit2() below for details */ 171 | 172 | #define Z_BINARY 0 173 | #define Z_ASCII 1 174 | #define Z_UNKNOWN 2 175 | /* Possible values of the data_type field (though see inflate()) */ 176 | 177 | #define Z_DEFLATED 8 178 | /* The deflate compression method (the only one supported in this version) */ 179 | 180 | #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ 181 | 182 | #define zlib_version zlibVersion() 183 | /* for compatibility with versions < 1.0.2 */ 184 | 185 | /* basic functions */ 186 | 187 | ZEXTERN const char * ZEXPORT zlibVersion OF((void)); 188 | /* The application can compare zlibVersion and ZLIB_VERSION for consistency. 189 | If the first character differs, the library code actually used is 190 | not compatible with the zlib.h header file used by the application. 191 | This check is automatically made by deflateInit and inflateInit. 192 | */ 193 | 194 | /* 195 | ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); 196 | 197 | Initializes the internal stream state for compression. The fields 198 | zalloc, zfree and opaque must be initialized before by the caller. 199 | If zalloc and zfree are set to Z_NULL, deflateInit updates them to 200 | use default allocation functions. 201 | 202 | The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: 203 | 1 gives best speed, 9 gives best compression, 0 gives no compression at 204 | all (the input data is simply copied a block at a time). 205 | Z_DEFAULT_COMPRESSION requests a default compromise between speed and 206 | compression (currently equivalent to level 6). 207 | 208 | deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not 209 | enough memory, Z_STREAM_ERROR if level is not a valid compression level, 210 | Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible 211 | with the version assumed by the caller (ZLIB_VERSION). 212 | msg is set to null if there is no error message. deflateInit does not 213 | perform any compression: this will be done by deflate(). 214 | */ 215 | 216 | 217 | ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); 218 | /* 219 | deflate compresses as much data as possible, and stops when the input 220 | buffer becomes empty or the output buffer becomes full. It may introduce some 221 | output latency (reading input without producing any output) except when 222 | forced to flush. 223 | 224 | The detailed semantics are as follows. deflate performs one or both of the 225 | following actions: 226 | 227 | - Compress more input starting at next_in and update next_in and avail_in 228 | accordingly. If not all input can be processed (because there is not 229 | enough room in the output buffer), next_in and avail_in are updated and 230 | processing will resume at this point for the next call of deflate(). 231 | 232 | - Provide more output starting at next_out and update next_out and avail_out 233 | accordingly. This action is forced if the parameter flush is non zero. 234 | Forcing flush frequently degrades the compression ratio, so this parameter 235 | should be set only when necessary (in interactive applications). 236 | Some output may be provided even if flush is not set. 237 | 238 | Before the call of deflate(), the application should ensure that at least 239 | one of the actions is possible, by providing more input and/or consuming 240 | more output, and updating avail_in or avail_out accordingly; avail_out 241 | should never be zero before the call. The application can consume the 242 | compressed output when it wants, for example when the output buffer is full 243 | (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK 244 | and with zero avail_out, it must be called again after making room in the 245 | output buffer because there might be more output pending. 246 | 247 | If the parameter flush is set to Z_SYNC_FLUSH, all pending output is 248 | flushed to the output buffer and the output is aligned on a byte boundary, so 249 | that the decompressor can get all input data available so far. (In particular 250 | avail_in is zero after the call if enough output space has been provided 251 | before the call.) Flushing may degrade compression for some compression 252 | algorithms and so it should be used only when necessary. 253 | 254 | If flush is set to Z_FULL_FLUSH, all output is flushed as with 255 | Z_SYNC_FLUSH, and the compression state is reset so that decompression can 256 | restart from this point if previous compressed data has been damaged or if 257 | random access is desired. Using Z_FULL_FLUSH too often can seriously degrade 258 | the compression. 259 | 260 | If deflate returns with avail_out == 0, this function must be called again 261 | with the same value of the flush parameter and more output space (updated 262 | avail_out), until the flush is complete (deflate returns with non-zero 263 | avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that 264 | avail_out is greater than six to avoid repeated flush markers due to 265 | avail_out == 0 on return. 266 | 267 | If the parameter flush is set to Z_FINISH, pending input is processed, 268 | pending output is flushed and deflate returns with Z_STREAM_END if there 269 | was enough output space; if deflate returns with Z_OK, this function must be 270 | called again with Z_FINISH and more output space (updated avail_out) but no 271 | more input data, until it returns with Z_STREAM_END or an error. After 272 | deflate has returned Z_STREAM_END, the only possible operations on the 273 | stream are deflateReset or deflateEnd. 274 | 275 | Z_FINISH can be used immediately after deflateInit if all the compression 276 | is to be done in a single step. In this case, avail_out must be at least 277 | the value returned by deflateBound (see below). If deflate does not return 278 | Z_STREAM_END, then it must be called again as described above. 279 | 280 | deflate() sets strm->adler to the adler32 checksum of all input read 281 | so far (that is, total_in bytes). 282 | 283 | deflate() may update data_type if it can make a good guess about 284 | the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered 285 | binary. This field is only for information purposes and does not affect 286 | the compression algorithm in any manner. 287 | 288 | deflate() returns Z_OK if some progress has been made (more input 289 | processed or more output produced), Z_STREAM_END if all input has been 290 | consumed and all output has been produced (only when flush is set to 291 | Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example 292 | if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible 293 | (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not 294 | fatal, and deflate() can be called again with more input and more output 295 | space to continue compressing. 296 | */ 297 | 298 | 299 | ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); 300 | /* 301 | All dynamically allocated data structures for this stream are freed. 302 | This function discards any unprocessed input and does not flush any 303 | pending output. 304 | 305 | deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the 306 | stream state was inconsistent, Z_DATA_ERROR if the stream was freed 307 | prematurely (some input or output was discarded). In the error case, 308 | msg may be set but then points to a static string (which must not be 309 | deallocated). 310 | */ 311 | 312 | 313 | /* 314 | ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); 315 | 316 | Initializes the internal stream state for decompression. The fields 317 | next_in, avail_in, zalloc, zfree and opaque must be initialized before by 318 | the caller. If next_in is not Z_NULL and avail_in is large enough (the exact 319 | value depends on the compression method), inflateInit determines the 320 | compression method from the zlib header and allocates all data structures 321 | accordingly; otherwise the allocation will be deferred to the first call of 322 | inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to 323 | use default allocation functions. 324 | 325 | inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough 326 | memory, Z_VERSION_ERROR if the zlib library version is incompatible with the 327 | version assumed by the caller. msg is set to null if there is no error 328 | message. inflateInit does not perform any decompression apart from reading 329 | the zlib header if present: this will be done by inflate(). (So next_in and 330 | avail_in may be modified, but next_out and avail_out are unchanged.) 331 | */ 332 | 333 | 334 | ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); 335 | /* 336 | inflate decompresses as much data as possible, and stops when the input 337 | buffer becomes empty or the output buffer becomes full. It may introduce 338 | some output latency (reading input without producing any output) except when 339 | forced to flush. 340 | 341 | The detailed semantics are as follows. inflate performs one or both of the 342 | following actions: 343 | 344 | - Decompress more input starting at next_in and update next_in and avail_in 345 | accordingly. If not all input can be processed (because there is not 346 | enough room in the output buffer), next_in is updated and processing 347 | will resume at this point for the next call of inflate(). 348 | 349 | - Provide more output starting at next_out and update next_out and avail_out 350 | accordingly. inflate() provides as much output as possible, until there 351 | is no more input data or no more space in the output buffer (see below 352 | about the flush parameter). 353 | 354 | Before the call of inflate(), the application should ensure that at least 355 | one of the actions is possible, by providing more input and/or consuming 356 | more output, and updating the next_* and avail_* values accordingly. 357 | The application can consume the uncompressed output when it wants, for 358 | example when the output buffer is full (avail_out == 0), or after each 359 | call of inflate(). If inflate returns Z_OK and with zero avail_out, it 360 | must be called again after making room in the output buffer because there 361 | might be more output pending. 362 | 363 | The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, 364 | Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much 365 | output as possible to the output buffer. Z_BLOCK requests that inflate() stop 366 | if and when it get to the next deflate block boundary. When decoding the zlib 367 | or gzip format, this will cause inflate() to return immediately after the 368 | header and before the first block. When doing a raw inflate, inflate() will 369 | go ahead and process the first block, and will return when it gets to the end 370 | of that block, or when it runs out of data. 371 | 372 | The Z_BLOCK option assists in appending to or combining deflate streams. 373 | Also to assist in this, on return inflate() will set strm->data_type to the 374 | number of unused bits in the last byte taken from strm->next_in, plus 64 375 | if inflate() is currently decoding the last block in the deflate stream, 376 | plus 128 if inflate() returned immediately after decoding an end-of-block 377 | code or decoding the complete header up to just before the first byte of the 378 | deflate stream. The end-of-block will not be indicated until all of the 379 | uncompressed data from that block has been written to strm->next_out. The 380 | number of unused bits may in general be greater than seven, except when 381 | bit 7 of data_type is set, in which case the number of unused bits will be 382 | less than eight. 383 | 384 | inflate() should normally be called until it returns Z_STREAM_END or an 385 | error. However if all decompression is to be performed in a single step 386 | (a single call of inflate), the parameter flush should be set to 387 | Z_FINISH. In this case all pending input is processed and all pending 388 | output is flushed; avail_out must be large enough to hold all the 389 | uncompressed data. (The size of the uncompressed data may have been saved 390 | by the compressor for this purpose.) The next operation on this stream must 391 | be inflateEnd to deallocate the decompression state. The use of Z_FINISH 392 | is never required, but can be used to inform inflate that a faster approach 393 | may be used for the single inflate() call. 394 | 395 | In this implementation, inflate() always flushes as much output as 396 | possible to the output buffer, and always uses the faster approach on the 397 | first call. So the only effect of the flush parameter in this implementation 398 | is on the return value of inflate(), as noted below, or when it returns early 399 | because Z_BLOCK is used. 400 | 401 | If a preset dictionary is needed after this call (see inflateSetDictionary 402 | below), inflate sets strm->adler to the adler32 checksum of the dictionary 403 | chosen by the compressor and returns Z_NEED_DICT; otherwise it sets 404 | strm->adler to the adler32 checksum of all output produced so far (that is, 405 | total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described 406 | below. At the end of the stream, inflate() checks that its computed adler32 407 | checksum is equal to that saved by the compressor and returns Z_STREAM_END 408 | only if the checksum is correct. 409 | 410 | inflate() will decompress and check either zlib-wrapped or gzip-wrapped 411 | deflate data. The header type is detected automatically. Any information 412 | contained in the gzip header is not retained, so applications that need that 413 | information should instead use raw inflate, see inflateInit2() below, or 414 | inflateBack() and perform their own processing of the gzip header and 415 | trailer. 416 | 417 | inflate() returns Z_OK if some progress has been made (more input processed 418 | or more output produced), Z_STREAM_END if the end of the compressed data has 419 | been reached and all uncompressed output has been produced, Z_NEED_DICT if a 420 | preset dictionary is needed at this point, Z_DATA_ERROR if the input data was 421 | corrupted (input stream not conforming to the zlib format or incorrect check 422 | value), Z_STREAM_ERROR if the stream structure was inconsistent (for example 423 | if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, 424 | Z_BUF_ERROR if no progress is possible or if there was not enough room in the 425 | output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and 426 | inflate() can be called again with more input and more output space to 427 | continue decompressing. If Z_DATA_ERROR is returned, the application may then 428 | call inflateSync() to look for a good compression block if a partial recovery 429 | of the data is desired. 430 | */ 431 | 432 | 433 | ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); 434 | /* 435 | All dynamically allocated data structures for this stream are freed. 436 | This function discards any unprocessed input and does not flush any 437 | pending output. 438 | 439 | inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state 440 | was inconsistent. In the error case, msg may be set but then points to a 441 | static string (which must not be deallocated). 442 | */ 443 | 444 | /* Advanced functions */ 445 | 446 | /* 447 | The following functions are needed only in some special applications. 448 | */ 449 | 450 | /* 451 | ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, 452 | int level, 453 | int method, 454 | int windowBits, 455 | int memLevel, 456 | int strategy)); 457 | 458 | This is another version of deflateInit with more compression options. The 459 | fields next_in, zalloc, zfree and opaque must be initialized before by 460 | the caller. 461 | 462 | The method parameter is the compression method. It must be Z_DEFLATED in 463 | this version of the library. 464 | 465 | The windowBits parameter is the base two logarithm of the window size 466 | (the size of the history buffer). It should be in the range 8..15 for this 467 | version of the library. Larger values of this parameter result in better 468 | compression at the expense of memory usage. The default value is 15 if 469 | deflateInit is used instead. 470 | 471 | windowBits can also be -8..-15 for raw deflate. In this case, -windowBits 472 | determines the window size. deflate() will then generate raw deflate data 473 | with no zlib header or trailer, and will not compute an adler32 check value. 474 | 475 | windowBits can also be greater than 15 for optional gzip encoding. Add 476 | 16 to windowBits to write a simple gzip header and trailer around the 477 | compressed data instead of a zlib wrapper. The gzip header will have no 478 | file name, no extra data, no comment, no modification time (set to zero), 479 | no header crc, and the operating system will be set to 255 (unknown). If a 480 | gzip stream is being written, strm->adler is a crc32 instead of an adler32. 481 | 482 | The memLevel parameter specifies how much memory should be allocated 483 | for the internal compression state. memLevel=1 uses minimum memory but 484 | is slow and reduces compression ratio; memLevel=9 uses maximum memory 485 | for optimal speed. The default value is 8. See zconf.h for total memory 486 | usage as a function of windowBits and memLevel. 487 | 488 | The strategy parameter is used to tune the compression algorithm. Use the 489 | value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a 490 | filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no 491 | string match), or Z_RLE to limit match distances to one (run-length 492 | encoding). Filtered data consists mostly of small values with a somewhat 493 | random distribution. In this case, the compression algorithm is tuned to 494 | compress them better. The effect of Z_FILTERED is to force more Huffman 495 | coding and less string matching; it is somewhat intermediate between 496 | Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as 497 | Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy 498 | parameter only affects the compression ratio but not the correctness of the 499 | compressed output even if it is not set appropriately. 500 | 501 | deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 502 | memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid 503 | method). msg is set to null if there is no error message. deflateInit2 does 504 | not perform any compression: this will be done by deflate(). 505 | */ 506 | 507 | ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, 508 | const Bytef *dictionary, 509 | uInt dictLength)); 510 | /* 511 | Initializes the compression dictionary from the given byte sequence 512 | without producing any compressed output. This function must be called 513 | immediately after deflateInit, deflateInit2 or deflateReset, before any 514 | call of deflate. The compressor and decompressor must use exactly the same 515 | dictionary (see inflateSetDictionary). 516 | 517 | The dictionary should consist of strings (byte sequences) that are likely 518 | to be encountered later in the data to be compressed, with the most commonly 519 | used strings preferably put towards the end of the dictionary. Using a 520 | dictionary is most useful when the data to be compressed is short and can be 521 | predicted with good accuracy; the data can then be compressed better than 522 | with the default empty dictionary. 523 | 524 | Depending on the size of the compression data structures selected by 525 | deflateInit or deflateInit2, a part of the dictionary may in effect be 526 | discarded, for example if the dictionary is larger than the window size in 527 | deflate or deflate2. Thus the strings most likely to be useful should be 528 | put at the end of the dictionary, not at the front. 529 | 530 | Upon return of this function, strm->adler is set to the adler32 value 531 | of the dictionary; the decompressor may later use this value to determine 532 | which dictionary has been used by the compressor. (The adler32 value 533 | applies to the whole dictionary even if only a subset of the dictionary is 534 | actually used by the compressor.) If a raw deflate was requested, then the 535 | adler32 value is not computed and strm->adler is not set. 536 | 537 | deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a 538 | parameter is invalid (such as NULL dictionary) or the stream state is 539 | inconsistent (for example if deflate has already been called for this stream 540 | or if the compression method is bsort). deflateSetDictionary does not 541 | perform any compression: this will be done by deflate(). 542 | */ 543 | 544 | ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, 545 | z_streamp source)); 546 | /* 547 | Sets the destination stream as a complete copy of the source stream. 548 | 549 | This function can be useful when several compression strategies will be 550 | tried, for example when there are several ways of pre-processing the input 551 | data with a filter. The streams that will be discarded should then be freed 552 | by calling deflateEnd. Note that deflateCopy duplicates the internal 553 | compression state which can be quite large, so this strategy is slow and 554 | can consume lots of memory. 555 | 556 | deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not 557 | enough memory, Z_STREAM_ERROR if the source stream state was inconsistent 558 | (such as zalloc being NULL). msg is left unchanged in both source and 559 | destination. 560 | */ 561 | 562 | ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); 563 | /* 564 | This function is equivalent to deflateEnd followed by deflateInit, 565 | but does not free and reallocate all the internal compression state. 566 | The stream will keep the same compression level and any other attributes 567 | that may have been set by deflateInit2. 568 | 569 | deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source 570 | stream state was inconsistent (such as zalloc or state being NULL). 571 | */ 572 | 573 | ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, 574 | int level, 575 | int strategy)); 576 | /* 577 | Dynamically update the compression level and compression strategy. The 578 | interpretation of level and strategy is as in deflateInit2. This can be 579 | used to switch between compression and straight copy of the input data, or 580 | to switch to a different kind of input data requiring a different 581 | strategy. If the compression level is changed, the input available so far 582 | is compressed with the old level (and may be flushed); the new level will 583 | take effect only at the next call of deflate(). 584 | 585 | Before the call of deflateParams, the stream state must be set as for 586 | a call of deflate(), since the currently available input may have to 587 | be compressed and flushed. In particular, strm->avail_out must be non-zero. 588 | 589 | deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source 590 | stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR 591 | if strm->avail_out was zero. 592 | */ 593 | 594 | ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, 595 | uLong sourceLen)); 596 | /* 597 | deflateBound() returns an upper bound on the compressed size after 598 | deflation of sourceLen bytes. It must be called after deflateInit() 599 | or deflateInit2(). This would be used to allocate an output buffer 600 | for deflation in a single pass, and so would be called before deflate(). 601 | */ 602 | 603 | ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, 604 | int bits, 605 | int value)); 606 | /* 607 | deflatePrime() inserts bits in the deflate output stream. The intent 608 | is that this function is used to start off the deflate output with the 609 | bits leftover from a previous deflate stream when appending to it. As such, 610 | this function can only be used for raw deflate, and must be used before the 611 | first deflate() call after a deflateInit2() or deflateReset(). bits must be 612 | less than or equal to 16, and that many of the least significant bits of 613 | value will be inserted in the output. 614 | 615 | deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source 616 | stream state was inconsistent. 617 | */ 618 | 619 | /* 620 | ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, 621 | int windowBits)); 622 | 623 | This is another version of inflateInit with an extra parameter. The 624 | fields next_in, avail_in, zalloc, zfree and opaque must be initialized 625 | before by the caller. 626 | 627 | The windowBits parameter is the base two logarithm of the maximum window 628 | size (the size of the history buffer). It should be in the range 8..15 for 629 | this version of the library. The default value is 15 if inflateInit is used 630 | instead. windowBits must be greater than or equal to the windowBits value 631 | provided to deflateInit2() while compressing, or it must be equal to 15 if 632 | deflateInit2() was not used. If a compressed stream with a larger window 633 | size is given as input, inflate() will return with the error code 634 | Z_DATA_ERROR instead of trying to allocate a larger window. 635 | 636 | windowBits can also be -8..-15 for raw inflate. In this case, -windowBits 637 | determines the window size. inflate() will then process raw deflate data, 638 | not looking for a zlib or gzip header, not generating a check value, and not 639 | looking for any check values for comparison at the end of the stream. This 640 | is for use with other formats that use the deflate compressed data format 641 | such as zip. Those formats provide their own check values. If a custom 642 | format is developed using the raw deflate format for compressed data, it is 643 | recommended that a check value such as an adler32 or a crc32 be applied to 644 | the uncompressed data as is done in the zlib, gzip, and zip formats. For 645 | most applications, the zlib format should be used as is. Note that comments 646 | above on the use in deflateInit2() applies to the magnitude of windowBits. 647 | 648 | windowBits can also be greater than 15 for optional gzip decoding. Add 649 | 32 to windowBits to enable zlib and gzip decoding with automatic header 650 | detection, or add 16 to decode only the gzip format (the zlib format will 651 | return a Z_DATA_ERROR. If a gzip stream is being decoded, strm->adler is 652 | a crc32 instead of an adler32. 653 | 654 | inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 655 | memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative 656 | memLevel). msg is set to null if there is no error message. inflateInit2 657 | does not perform any decompression apart from reading the zlib header if 658 | present: this will be done by inflate(). (So next_in and avail_in may be 659 | modified, but next_out and avail_out are unchanged.) 660 | */ 661 | 662 | ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, 663 | const Bytef *dictionary, 664 | uInt dictLength)); 665 | /* 666 | Initializes the decompression dictionary from the given uncompressed byte 667 | sequence. This function must be called immediately after a call of inflate 668 | if this call returned Z_NEED_DICT. The dictionary chosen by the compressor 669 | can be determined from the adler32 value returned by this call of 670 | inflate. The compressor and decompressor must use exactly the same 671 | dictionary (see deflateSetDictionary). 672 | 673 | inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a 674 | parameter is invalid (such as NULL dictionary) or the stream state is 675 | inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the 676 | expected one (incorrect adler32 value). inflateSetDictionary does not 677 | perform any decompression: this will be done by subsequent calls of 678 | inflate(). 679 | */ 680 | 681 | ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); 682 | /* 683 | Skips invalid compressed data until a full flush point (see above the 684 | description of deflate with Z_FULL_FLUSH) can be found, or until all 685 | available input is skipped. No output is provided. 686 | 687 | inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR 688 | if no more input was provided, Z_DATA_ERROR if no flush point has been found, 689 | or Z_STREAM_ERROR if the stream structure was inconsistent. In the success 690 | case, the application may save the current current value of total_in which 691 | indicates where valid compressed data was found. In the error case, the 692 | application may repeatedly call inflateSync, providing more input each time, 693 | until success or end of the input data. 694 | */ 695 | 696 | ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, 697 | z_streamp source)); 698 | /* 699 | Sets the destination stream as a complete copy of the source stream. 700 | 701 | This function can be useful when randomly accessing a large stream. The 702 | first pass through the stream can periodically record the inflate state, 703 | allowing restarting inflate at those points when randomly accessing the 704 | stream. 705 | 706 | inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not 707 | enough memory, Z_STREAM_ERROR if the source stream state was inconsistent 708 | (such as zalloc being NULL). msg is left unchanged in both source and 709 | destination. 710 | */ 711 | 712 | ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); 713 | /* 714 | This function is equivalent to inflateEnd followed by inflateInit, 715 | but does not free and reallocate all the internal decompression state. 716 | The stream will keep attributes that may have been set by inflateInit2. 717 | 718 | inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source 719 | stream state was inconsistent (such as zalloc or state being NULL). 720 | */ 721 | 722 | /* 723 | ZEXTERN int ZEXPORT inflateBackInit OF((z_stream FAR *strm, int windowBits, 724 | unsigned char FAR *window)); 725 | 726 | Initialize the internal stream state for decompression using inflateBack() 727 | calls. The fields zalloc, zfree and opaque in strm must be initialized 728 | before the call. If zalloc and zfree are Z_NULL, then the default library- 729 | derived memory allocation routines are used. windowBits is the base two 730 | logarithm of the window size, in the range 8..15. window is a caller 731 | supplied buffer of that size. Except for special applications where it is 732 | assured that deflate was used with small window sizes, windowBits must be 15 733 | and a 32K byte window must be supplied to be able to decompress general 734 | deflate streams. 735 | 736 | See inflateBack() for the usage of these routines. 737 | 738 | inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of 739 | the paramaters are invalid, Z_MEM_ERROR if the internal state could not 740 | be allocated, or Z_VERSION_ERROR if the version of the library does not 741 | match the version of the header file. 742 | */ 743 | 744 | typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); 745 | typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); 746 | 747 | ZEXTERN int ZEXPORT inflateBack OF((z_stream FAR *strm, 748 | in_func in, void FAR *in_desc, 749 | out_func out, void FAR *out_desc)); 750 | /* 751 | inflateBack() does a raw inflate with a single call using a call-back 752 | interface for input and output. This is more efficient than inflate() for 753 | file i/o applications in that it avoids copying between the output and the 754 | sliding window by simply making the window itself the output buffer. This 755 | function trusts the application to not change the output buffer passed by 756 | the output function, at least until inflateBack() returns. 757 | 758 | inflateBackInit() must be called first to allocate the internal state 759 | and to initialize the state with the user-provided window buffer. 760 | inflateBack() may then be used multiple times to inflate a complete, raw 761 | deflate stream with each call. inflateBackEnd() is then called to free 762 | the allocated state. 763 | 764 | A raw deflate stream is one with no zlib or gzip header or trailer. 765 | This routine would normally be used in a utility that reads zip or gzip 766 | files and writes out uncompressed files. The utility would decode the 767 | header and process the trailer on its own, hence this routine expects 768 | only the raw deflate stream to decompress. This is different from the 769 | normal behavior of inflate(), which expects either a zlib or gzip header and 770 | trailer around the deflate stream. 771 | 772 | inflateBack() uses two subroutines supplied by the caller that are then 773 | called by inflateBack() for input and output. inflateBack() calls those 774 | routines until it reads a complete deflate stream and writes out all of the 775 | uncompressed data, or until it encounters an error. The function's 776 | parameters and return types are defined above in the in_func and out_func 777 | typedefs. inflateBack() will call in(in_desc, &buf) which should return the 778 | number of bytes of provided input, and a pointer to that input in buf. If 779 | there is no input available, in() must return zero--buf is ignored in that 780 | case--and inflateBack() will return a buffer error. inflateBack() will call 781 | out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() 782 | should return zero on success, or non-zero on failure. If out() returns 783 | non-zero, inflateBack() will return with an error. Neither in() nor out() 784 | are permitted to change the contents of the window provided to 785 | inflateBackInit(), which is also the buffer that out() uses to write from. 786 | The length written by out() will be at most the window size. Any non-zero 787 | amount of input may be provided by in(). 788 | 789 | For convenience, inflateBack() can be provided input on the first call by 790 | setting strm->next_in and strm->avail_in. If that input is exhausted, then 791 | in() will be called. Therefore strm->next_in must be initialized before 792 | calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called 793 | immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in 794 | must also be initialized, and then if strm->avail_in is not zero, input will 795 | initially be taken from strm->next_in[0 .. strm->avail_in - 1]. 796 | 797 | The in_desc and out_desc parameters of inflateBack() is passed as the 798 | first parameter of in() and out() respectively when they are called. These 799 | descriptors can be optionally used to pass any information that the caller- 800 | supplied in() and out() functions need to do their job. 801 | 802 | On return, inflateBack() will set strm->next_in and strm->avail_in to 803 | pass back any unused input that was provided by the last in() call. The 804 | return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR 805 | if in() or out() returned an error, Z_DATA_ERROR if there was a format 806 | error in the deflate stream (in which case strm->msg is set to indicate the 807 | nature of the error), or Z_STREAM_ERROR if the stream was not properly 808 | initialized. In the case of Z_BUF_ERROR, an input or output error can be 809 | distinguished using strm->next_in which will be Z_NULL only if in() returned 810 | an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to 811 | out() returning non-zero. (in() will always be called before out(), so 812 | strm->next_in is assured to be defined if out() returns non-zero.) Note 813 | that inflateBack() cannot return Z_OK. 814 | */ 815 | 816 | ZEXTERN int ZEXPORT inflateBackEnd OF((z_stream FAR *strm)); 817 | /* 818 | All memory allocated by inflateBackInit() is freed. 819 | 820 | inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream 821 | state was inconsistent. 822 | */ 823 | 824 | ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); 825 | /* Return flags indicating compile-time options. 826 | 827 | Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: 828 | 1.0: size of uInt 829 | 3.2: size of uLong 830 | 5.4: size of voidpf (pointer) 831 | 7.6: size of z_off_t 832 | 833 | Compiler, assembler, and debug options: 834 | 8: DEBUG 835 | 9: ASMV or ASMINF -- use ASM code 836 | 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention 837 | 11: 0 (reserved) 838 | 839 | One-time table building (smaller code, but not thread-safe if true): 840 | 12: BUILDFIXED -- build static block decoding tables when needed 841 | 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed 842 | 14,15: 0 (reserved) 843 | 844 | Library content (indicates missing functionality): 845 | 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking 846 | deflate code when not needed) 847 | 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect 848 | and decode gzip streams (to avoid linking crc code) 849 | 18-19: 0 (reserved) 850 | 851 | Operation variations (changes in library functionality): 852 | 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate 853 | 21: FASTEST -- deflate algorithm with only one, lowest compression level 854 | 22,23: 0 (reserved) 855 | 856 | The sprintf variant used by gzprintf (zero is best): 857 | 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format 858 | 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! 859 | 26: 0 = returns value, 1 = void -- 1 means inferred string length returned 860 | 861 | Remainder: 862 | 27-31: 0 (reserved) 863 | */ 864 | 865 | 866 | /* utility functions */ 867 | 868 | /* 869 | The following utility functions are implemented on top of the 870 | basic stream-oriented functions. To simplify the interface, some 871 | default options are assumed (compression level and memory usage, 872 | standard memory allocation functions). The source code of these 873 | utility functions can easily be modified if you need special options. 874 | */ 875 | 876 | ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, 877 | const Bytef *source, uLong sourceLen)); 878 | /* 879 | Compresses the source buffer into the destination buffer. sourceLen is 880 | the byte length of the source buffer. Upon entry, destLen is the total 881 | size of the destination buffer, which must be at least the value returned 882 | by compressBound(sourceLen). Upon exit, destLen is the actual size of the 883 | compressed buffer. 884 | This function can be used to compress a whole file at once if the 885 | input file is mmap'ed. 886 | compress returns Z_OK if success, Z_MEM_ERROR if there was not 887 | enough memory, Z_BUF_ERROR if there was not enough room in the output 888 | buffer. 889 | */ 890 | 891 | ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, 892 | const Bytef *source, uLong sourceLen, 893 | int level)); 894 | /* 895 | Compresses the source buffer into the destination buffer. The level 896 | parameter has the same meaning as in deflateInit. sourceLen is the byte 897 | length of the source buffer. Upon entry, destLen is the total size of the 898 | destination buffer, which must be at least the value returned by 899 | compressBound(sourceLen). Upon exit, destLen is the actual size of the 900 | compressed buffer. 901 | 902 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 903 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, 904 | Z_STREAM_ERROR if the level parameter is invalid. 905 | */ 906 | 907 | ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); 908 | /* 909 | compressBound() returns an upper bound on the compressed size after 910 | compress() or compress2() on sourceLen bytes. It would be used before 911 | a compress() or compress2() call to allocate the destination buffer. 912 | */ 913 | 914 | ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, 915 | const Bytef *source, uLong sourceLen)); 916 | /* 917 | Decompresses the source buffer into the destination buffer. sourceLen is 918 | the byte length of the source buffer. Upon entry, destLen is the total 919 | size of the destination buffer, which must be large enough to hold the 920 | entire uncompressed data. (The size of the uncompressed data must have 921 | been saved previously by the compressor and transmitted to the decompressor 922 | by some mechanism outside the scope of this compression library.) 923 | Upon exit, destLen is the actual size of the compressed buffer. 924 | This function can be used to decompress a whole file at once if the 925 | input file is mmap'ed. 926 | 927 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not 928 | enough memory, Z_BUF_ERROR if there was not enough room in the output 929 | buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. 930 | */ 931 | 932 | 933 | typedef voidp gzFile; 934 | 935 | ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); 936 | /* 937 | Opens a gzip (.gz) file for reading or writing. The mode parameter 938 | is as in fopen ("rb" or "wb") but can also include a compression level 939 | ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for 940 | Huffman only compression as in "wb1h", or 'R' for run-length encoding 941 | as in "wb1R". (See the description of deflateInit2 for more information 942 | about the strategy parameter.) 943 | 944 | gzopen can be used to read a file which is not in gzip format; in this 945 | case gzread will directly read from the file without decompression. 946 | 947 | gzopen returns NULL if the file could not be opened or if there was 948 | insufficient memory to allocate the (de)compression state; errno 949 | can be checked to distinguish the two cases (if errno is zero, the 950 | zlib error is Z_MEM_ERROR). */ 951 | 952 | ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); 953 | /* 954 | gzdopen() associates a gzFile with the file descriptor fd. File 955 | descriptors are obtained from calls like open, dup, creat, pipe or 956 | fileno (in the file has been previously opened with fopen). 957 | The mode parameter is as in gzopen. 958 | The next call of gzclose on the returned gzFile will also close the 959 | file descriptor fd, just like fclose(fdopen(fd), mode) closes the file 960 | descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). 961 | gzdopen returns NULL if there was insufficient memory to allocate 962 | the (de)compression state. 963 | */ 964 | 965 | ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); 966 | /* 967 | Dynamically update the compression level or strategy. See the description 968 | of deflateInit2 for the meaning of these parameters. 969 | gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not 970 | opened for writing. 971 | */ 972 | 973 | ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); 974 | /* 975 | Reads the given number of uncompressed bytes from the compressed file. 976 | If the input file was not in gzip format, gzread copies the given number 977 | of bytes into the buffer. 978 | gzread returns the number of uncompressed bytes actually read (0 for 979 | end of file, -1 for error). */ 980 | 981 | ZEXTERN int ZEXPORT gzwrite OF((gzFile file, 982 | voidpc buf, unsigned len)); 983 | /* 984 | Writes the given number of uncompressed bytes into the compressed file. 985 | gzwrite returns the number of uncompressed bytes actually written 986 | (0 in case of error). 987 | */ 988 | 989 | ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); 990 | /* 991 | Converts, formats, and writes the args to the compressed file under 992 | control of the format string, as in fprintf. gzprintf returns the number of 993 | uncompressed bytes actually written (0 in case of error). The number of 994 | uncompressed bytes written is limited to 4095. The caller should assure that 995 | this limit is not exceeded. If it is exceeded, then gzprintf() will return 996 | return an error (0) with nothing written. In this case, there may also be a 997 | buffer overflow with unpredictable consequences, which is possible only if 998 | zlib was compiled with the insecure functions sprintf() or vsprintf() 999 | because the secure snprintf() or vsnprintf() functions were not available. 1000 | */ 1001 | 1002 | ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); 1003 | /* 1004 | Writes the given null-terminated string to the compressed file, excluding 1005 | the terminating null character. 1006 | gzputs returns the number of characters written, or -1 in case of error. 1007 | */ 1008 | 1009 | ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); 1010 | /* 1011 | Reads bytes from the compressed file until len-1 characters are read, or 1012 | a newline character is read and transferred to buf, or an end-of-file 1013 | condition is encountered. The string is then terminated with a null 1014 | character. 1015 | gzgets returns buf, or Z_NULL in case of error. 1016 | */ 1017 | 1018 | ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); 1019 | /* 1020 | Writes c, converted to an unsigned char, into the compressed file. 1021 | gzputc returns the value that was written, or -1 in case of error. 1022 | */ 1023 | 1024 | ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); 1025 | /* 1026 | Reads one byte from the compressed file. gzgetc returns this byte 1027 | or -1 in case of end of file or error. 1028 | */ 1029 | 1030 | ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); 1031 | /* 1032 | Push one character back onto the stream to be read again later. 1033 | Only one character of push-back is allowed. gzungetc() returns the 1034 | character pushed, or -1 on failure. gzungetc() will fail if a 1035 | character has been pushed but not read yet, or if c is -1. The pushed 1036 | character will be discarded if the stream is repositioned with gzseek() 1037 | or gzrewind(). 1038 | */ 1039 | 1040 | ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); 1041 | /* 1042 | Flushes all pending output into the compressed file. The parameter 1043 | flush is as in the deflate() function. The return value is the zlib 1044 | error number (see function gzerror below). gzflush returns Z_OK if 1045 | the flush parameter is Z_FINISH and all output could be flushed. 1046 | gzflush should be called only when strictly necessary because it can 1047 | degrade compression. 1048 | */ 1049 | 1050 | ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, 1051 | z_off_t offset, int whence)); 1052 | /* 1053 | Sets the starting position for the next gzread or gzwrite on the 1054 | given compressed file. The offset represents a number of bytes in the 1055 | uncompressed data stream. The whence parameter is defined as in lseek(2); 1056 | the value SEEK_END is not supported. 1057 | If the file is opened for reading, this function is emulated but can be 1058 | extremely slow. If the file is opened for writing, only forward seeks are 1059 | supported; gzseek then compresses a sequence of zeroes up to the new 1060 | starting position. 1061 | 1062 | gzseek returns the resulting offset location as measured in bytes from 1063 | the beginning of the uncompressed stream, or -1 in case of error, in 1064 | particular if the file is opened for writing and the new starting position 1065 | would be before the current position. 1066 | */ 1067 | 1068 | ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); 1069 | /* 1070 | Rewinds the given file. This function is supported only for reading. 1071 | 1072 | gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) 1073 | */ 1074 | 1075 | ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); 1076 | /* 1077 | Returns the starting position for the next gzread or gzwrite on the 1078 | given compressed file. This position represents a number of bytes in the 1079 | uncompressed data stream. 1080 | 1081 | gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) 1082 | */ 1083 | 1084 | ZEXTERN int ZEXPORT gzeof OF((gzFile file)); 1085 | /* 1086 | Returns 1 when EOF has previously been detected reading the given 1087 | input stream, otherwise zero. 1088 | */ 1089 | 1090 | ZEXTERN int ZEXPORT gzclose OF((gzFile file)); 1091 | /* 1092 | Flushes all pending output if necessary, closes the compressed file 1093 | and deallocates all the (de)compression state. The return value is the zlib 1094 | error number (see function gzerror below). 1095 | */ 1096 | 1097 | ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); 1098 | /* 1099 | Returns the error message for the last error which occurred on the 1100 | given compressed file. errnum is set to zlib error number. If an 1101 | error occurred in the file system and not in the compression library, 1102 | errnum is set to Z_ERRNO and the application may consult errno 1103 | to get the exact error code. 1104 | */ 1105 | 1106 | ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); 1107 | /* 1108 | Clears the error and end-of-file flags for file. This is analogous to the 1109 | clearerr() function in stdio. This is useful for continuing to read a gzip 1110 | file that is being written concurrently. 1111 | */ 1112 | 1113 | /* checksum functions */ 1114 | 1115 | /* 1116 | These functions are not related to compression but are exported 1117 | anyway because they might be useful in applications using the 1118 | compression library. 1119 | */ 1120 | 1121 | ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); 1122 | 1123 | /* 1124 | Update a running Adler-32 checksum with the bytes buf[0..len-1] and 1125 | return the updated checksum. If buf is NULL, this function returns 1126 | the required initial value for the checksum. 1127 | An Adler-32 checksum is almost as reliable as a CRC32 but can be computed 1128 | much faster. Usage example: 1129 | 1130 | uLong adler = adler32(0L, Z_NULL, 0); 1131 | 1132 | while (read_buffer(buffer, length) != EOF) { 1133 | adler = adler32(adler, buffer, length); 1134 | } 1135 | if (adler != original_adler) error(); 1136 | */ 1137 | 1138 | ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); 1139 | /* 1140 | Update a running crc with the bytes buf[0..len-1] and return the updated 1141 | crc. If buf is NULL, this function returns the required initial value 1142 | for the crc. Pre- and post-conditioning (one's complement) is performed 1143 | within this function so it shouldn't be done by the application. 1144 | Usage example: 1145 | 1146 | uLong crc = crc32(0L, Z_NULL, 0); 1147 | 1148 | while (read_buffer(buffer, length) != EOF) { 1149 | crc = crc32(crc, buffer, length); 1150 | } 1151 | if (crc != original_crc) error(); 1152 | */ 1153 | 1154 | 1155 | /* various hacks, don't look :) */ 1156 | 1157 | /* deflateInit and inflateInit are macros to allow checking the zlib version 1158 | * and the compiler's view of z_stream: 1159 | */ 1160 | ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, 1161 | const char *version, int stream_size)); 1162 | ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, 1163 | const char *version, int stream_size)); 1164 | ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, 1165 | int windowBits, int memLevel, 1166 | int strategy, const char *version, 1167 | int stream_size)); 1168 | ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, 1169 | const char *version, int stream_size)); 1170 | ZEXTERN int ZEXPORT inflateBackInit_ OF((z_stream FAR *strm, int windowBits, 1171 | unsigned char FAR *window, 1172 | const char *version, 1173 | int stream_size)); 1174 | #define deflateInit(strm, level) \ 1175 | deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) 1176 | #define inflateInit(strm) \ 1177 | inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) 1178 | #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ 1179 | deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ 1180 | (strategy), ZLIB_VERSION, sizeof(z_stream)) 1181 | #define inflateInit2(strm, windowBits) \ 1182 | inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) 1183 | #define inflateBackInit(strm, windowBits, window) \ 1184 | inflateBackInit_((strm), (windowBits), (window), \ 1185 | ZLIB_VERSION, sizeof(z_stream)) 1186 | 1187 | 1188 | #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) 1189 | struct internal_state {int dummy;}; /* hack for buggy compilers */ 1190 | #endif 1191 | 1192 | ZEXTERN const char * ZEXPORT zError OF((int)); 1193 | ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); 1194 | ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); 1195 | 1196 | #ifdef __cplusplus 1197 | } 1198 | #endif 1199 | 1200 | #endif /* ZLIB_H */ 1201 | -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/lib/libpspkubridge.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/procfw_sdk_prebuilt/lib/libpspkubridge.a -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/lib/libpspmodulemgr_kernel.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/procfw_sdk_prebuilt/lib/libpspmodulemgr_kernel.a -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/lib/libpspsemaphore.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/procfw_sdk_prebuilt/lib/libpspsemaphore.a -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/lib/libpspsystemctrl_kernel.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/procfw_sdk_prebuilt/lib/libpspsystemctrl_kernel.a -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/lib/libpspsystemctrl_user.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/procfw_sdk_prebuilt/lib/libpspsystemctrl_user.a -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/lib/libpspumd_kernel.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/procfw_sdk_prebuilt/lib/libpspumd_kernel.a -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/lib/libpspusbdevice.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/procfw_sdk_prebuilt/lib/libpspusbdevice.a -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/lib/libpspusbdevice_driver.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/procfw_sdk_prebuilt/lib/libpspusbdevice_driver.a -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/lib/libpspvshbridge.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/procfw_sdk_prebuilt/lib/libpspvshbridge.a -------------------------------------------------------------------------------- /procfw_sdk_prebuilt/lib/libz.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kethen/RemasteredControls_GTpsp/d689806b845b4da2a10d511297381b76dac2755b/procfw_sdk_prebuilt/lib/libz.a -------------------------------------------------------------------------------- /script: -------------------------------------------------------------------------------- 1 | cp procfw_sdk_prebuilt/include/* /usr/local/pspdev/psp/sdk/include/ 2 | cp procfw_sdk_prebuilt/lib/* /usr/local/pspdev/psp/sdk/lib/ 3 | make clean 4 | make 5 | -------------------------------------------------------------------------------- /start_shell_podman.sh: -------------------------------------------------------------------------------- 1 | IMAGE_NAME="pspsdk" 2 | 3 | set -xe 4 | 5 | if [ "$REBUILD_IMAGE" == "true" ] && podman image exists $IMAGE_NAME 6 | then 7 | podman image rm -f $IMAGE_NAME 8 | fi 9 | 10 | if ! podman image exists $IMAGE_NAME 11 | then 12 | podman image build -f Dockerfile -t $IMAGE_NAME 13 | fi 14 | 15 | mkdir -p workdir 16 | 17 | podman run \ 18 | --rm -it \ 19 | -v /dev/bus/usb:/dev/bus/usb \ 20 | -v ./:/workdir \ 21 | -w /workdir \ 22 | $IMAGE_NAME 23 | --------------------------------------------------------------------------------