├── .gitattributes ├── .github └── workflows │ ├── main.yml │ └── pr.yml ├── .gitignore ├── LICENSE ├── README.md ├── as_only.cmd ├── as_shader_dump.cmd ├── chip ├── pm4defs.pas ├── ps4_gpu_regs.pas ├── ps4_pssl.pas ├── ps4_shader.pas ├── ps4_tiling.pas ├── ps4_videodrv.pas ├── shader_dump.pas ├── si_ci_vi_merged_enum.pas ├── si_ci_vi_merged_offset.pas └── si_ci_vi_merged_registers.pas ├── ffmpeg ├── ffmpeg.inc ├── ffmpeg_types.pas ├── libavcodec.pas ├── libavdevice.pas ├── libavfilter.pas ├── libavformat.pas ├── libavutil.pas ├── libpostproc.pas ├── libswresample.pas └── libswscale.pas ├── fpPS4.ico ├── fpPS4.lpi ├── fpPS4.lpr ├── fpPS4.res ├── icons ├── Readme.txt ├── SuriK │ ├── Readme.txt │ ├── fpPS4.ico │ └── logo.png ├── boosty.svg ├── fpPS4.ico └── logo.png ├── kernel ├── StopNotificationReason.inc ├── libsysmodule.inc ├── mm_adr_direct.pas ├── mm_adr_name.pas ├── mm_adr_virtual.pas ├── ps4_barrier.pas ├── ps4_cond.pas ├── ps4_event_flag.pas ├── ps4_kernel_file.pas ├── ps4_libkernel.pas ├── ps4_map_mm.pas ├── ps4_mutex.pas ├── ps4_pthread.pas ├── ps4_pthread_attr.pas ├── ps4_pthread_key.pas ├── ps4_queue.pas ├── ps4_rwlock.pas ├── ps4_scesocket.pas ├── ps4_sema.pas ├── ps4_signal.pas └── ps4_time.pas ├── ps4_elf.pas ├── ps4_program.pas ├── ps4libdoc.pas ├── rtl ├── LFQueue.pas ├── RWLock.pas ├── atomic.pas ├── bittype.pas ├── g23tree.pas ├── hamt.pas ├── mmap.pas ├── mpmc_queue.pas ├── ntapi.pas ├── ps4_elf_tls.pas ├── ps4_handles.pas ├── seh64.pas ├── stub_manager.pas └── trace_manager.pas ├── shaders ├── FLIP_CURSOR.comp ├── FLIP_LINE_A8R8G8B8_SRGB.comp ├── FLIP_TILE_A8B8G8R8_SRGB.comp ├── FLIP_TILE_A8R8G8B8_SRGB.comp ├── FLIP_TILE_A8R8G8B8_SRGB_NEO.comp ├── compile.cmd ├── shaders.lrs └── shaders.pas ├── spirv ├── Half16.pas ├── SprvEmit.pas ├── emit_alloc.pas ├── emit_bin.pas ├── emit_exp.pas ├── emit_fetch.pas ├── emit_mimg.pas ├── emit_mtbuf.pas ├── emit_mubuf.pas ├── emit_op.pas ├── emit_post.pas ├── emit_post_op.pas ├── emit_print.pas ├── emit_smrd.pas ├── emit_sop1.pas ├── emit_sop2.pas ├── emit_sopc.pas ├── emit_sopk.pas ├── emit_sopp.pas ├── emit_vbuf_chain.pas ├── emit_vbuf_load.pas ├── emit_vbuf_store.pas ├── emit_vintrp.pas ├── emit_vop1.pas ├── emit_vop2.pas ├── emit_vop3.pas ├── emit_vopc.pas ├── ginodes.pas ├── pssl-spirv.lpi ├── pssl-spirv.lpr ├── spirv.pas ├── srAllocator.pas ├── srBitcast.pas ├── srBuffer.pas ├── srCFGCursor.pas ├── srCFGLabel.pas ├── srCFGParser.pas ├── srCacheOp.pas ├── srCapability.pas ├── srConfig.pas ├── srConst.pas ├── srDecorate.pas ├── srFlow.pas ├── srFragLayout.pas ├── srInput.pas ├── srInterface.pas ├── srLayout.pas ├── srLiteral.pas ├── srNode.pas ├── srOp.pas ├── srOpUtils.pas ├── srOutput.pas ├── srPrivate.pas ├── srRefId.pas ├── srReg.pas ├── srType.pas ├── srTypes.pas ├── srUniform.pas ├── srVBufInfo.pas ├── srVariable.pas └── srVertLayout.pas ├── src ├── ajm │ ├── ajm_error.inc │ └── ps4_libsceajm.pas ├── audio │ ├── libportaudio.pas │ ├── ps4_libsceaudio3d.pas │ └── ps4_libsceaudioout.pas ├── audiodec │ ├── ps4_libsceaudiodec.pas │ └── ps4_libsceaudiodeccpu.pas ├── inputs │ ├── formbindbutton.lfm │ ├── formbindbutton.pas │ ├── formcontroller.lfm │ ├── formcontroller.pas │ ├── kbm_pad_interface.pas │ ├── sce_pad_interface.pas │ ├── sce_pad_types.pas │ ├── sdl2.pas │ ├── sdl2_pad_interface.pas │ ├── umappableinputs.pas │ ├── xinput.pas │ └── xinput_pad_interface.pas ├── libcinternal │ ├── ps4_atexit_internal.pas │ ├── ps4_guard_internal.pas │ ├── ps4_libscelibcinternal.pas │ ├── ps4_mspace_internal.pas │ └── ps4_mtx_internal.pas ├── np │ ├── np_error.pas │ ├── ps4_libscenpauth.pas │ ├── ps4_libscenpcommon.pas │ ├── ps4_libscenpgameintent.pas │ ├── ps4_libscenpmanager.pas │ ├── ps4_libscenpmatching2.pas │ ├── ps4_libscenpparty.pas │ ├── ps4_libscenpscore.pas │ ├── ps4_libscenpsessionsignaling.pas │ ├── ps4_libscenpsignaling.pas │ ├── ps4_libscenptrophy.pas │ ├── ps4_libscenptus.pas │ ├── ps4_libscenputility.pas │ └── ps4_libscenpwebapi.pas ├── param_sfo.pas ├── playgo │ ├── playgo_chunk_loader.pas │ └── ps4_libsceplaygo.pas ├── ps4_libSceSsl.pas ├── ps4_libsceappcontent.pas ├── ps4_libsceavplayer.pas ├── ps4_libscecamera.pas ├── ps4_libscecompanionhttpd.pas ├── ps4_libscecompanionutil.pas ├── ps4_libscecomposite.pas ├── ps4_libscecontentexport.pas ├── ps4_libsceconvertkeycode.pas ├── ps4_libscedepth.pas ├── ps4_libscedialogs.pas ├── ps4_libscediscmap.pas ├── ps4_libscefiber.pas ├── ps4_libscegamelivestreaming.pas ├── ps4_libscegnmdriver.pas ├── ps4_libscehmd.pas ├── ps4_libscehttp.pas ├── ps4_libsceime.pas ├── ps4_libscelncutil.pas ├── ps4_libsceloginservice.pas ├── ps4_libscemouse.pas ├── ps4_libscemove.pas ├── ps4_libscemovetracker.pas ├── ps4_libscenet.pas ├── ps4_libscepad.pas ├── ps4_libscerandom.pas ├── ps4_libsceremoteplay.pas ├── ps4_libscertc.pas ├── ps4_libscerudp.pas ├── ps4_libscesavedata.pas ├── ps4_libscescreenshot.pas ├── ps4_libsceshareplay.pas ├── ps4_libsceshareutility.pas ├── ps4_libscesocialscreen.pas ├── ps4_libscesyscore.pas ├── ps4_libscesystemgesture.pas ├── ps4_libscesystemservice.pas ├── ps4_libsceult.pas ├── ps4_libsceusbd.pas ├── ps4_libsceusbstorage.pas ├── ps4_libsceuserservice.pas ├── ps4_libscevideoout.pas ├── ps4_libscevideorecording.pas ├── ps4_libscevoice.pas └── ps4_libscevrtracker.pas ├── static ├── libkernel32.a ├── libmingwex.a ├── libmsvcrt.a ├── libportaudio.a └── libwinmm.a ├── sys ├── errno.inc ├── sce_errno.inc ├── signal.inc ├── spinlock.pas ├── sys_context.pas ├── sys_crt.pas ├── sys_dev.pas ├── sys_dir.pas ├── sys_fd.pas ├── sys_file.pas ├── sys_kernel.pas ├── sys_path.pas ├── sys_pthread.pas ├── sys_signal.pas ├── sys_time.pas └── sys_types.pas ├── tag.inc ├── third_party_gui ├── GUI │ ├── main.py │ └── readme.txt ├── README.md ├── fpPS4Fro │ ├── AboutBox1.Designer.cs │ ├── AboutBox1.cs │ ├── AboutBox1.resx │ ├── Form1.Designer.cs │ ├── Form1.cs │ ├── Form1.resx │ ├── Form2.Designer.cs │ ├── Form2.cs │ ├── Form2.resx │ ├── Ini.cs │ ├── Program.cs │ ├── fpPS4Fro.csproj │ ├── fpPS4Fro.csproj.user │ └── readme.txt └── frofpp4 │ ├── project1.ico │ ├── project1.lpi │ ├── project1.lpr │ ├── project1.res │ ├── readme.txt │ ├── unit1.lfm │ ├── unit1.pas │ ├── unit2.lfm │ ├── unit2.pas │ ├── unit3.lfm │ └── unit3.pas ├── tools ├── dump_sym │ ├── dump_sym.lpi │ └── dump_sym.lpr ├── elf_sym │ ├── elf_sym.lpi │ ├── elf_sym.lpr │ ├── run.cmd │ └── uarch.pas ├── gfx6_chip │ ├── chip.lpi │ ├── chip.lpr │ ├── si_ci_vi_merged_enum.h │ ├── si_ci_vi_merged_offset.h │ ├── si_ci_vi_merged_pm4_it_opcodes.h │ ├── si_ci_vi_merged_pm4defs.h │ └── si_ci_vi_merged_registers.h ├── nid_gui_test │ ├── main.lfm │ ├── main.pas │ ├── nid_gui_test.ico │ ├── nid_gui_test.lpi │ ├── nid_gui_test.lpr │ └── nid_gui_test.res ├── param_sfo │ ├── param_sfo_info.lpi │ └── param_sfo_info.lpr ├── playgo │ ├── playgo_info.lpi │ └── playgo_info.lpr ├── ps4libdoc │ ├── funct_helper2.lpi │ ├── funct_helper2.lpr │ ├── known_names.txt │ ├── list_from_sdk.txt │ ├── ps4_names.txt │ └── sceKernelDlsym.txt └── spirv │ ├── extinst.glsl.std.450.grammar.json │ ├── spirv.core.grammar.json │ ├── spirv.json │ ├── spirv_helper.lpi │ ├── spirv_helper.lpr │ └── xpath │ ├── UJson.pas │ ├── Ufpjson.pp │ ├── Ujsonreader.pas │ └── Ujsonscanner.pas └── vulkan ├── Vulkan.pas ├── vBuffer.pas ├── vCmdBuffer.pas ├── vDevice.pas ├── vFlip.pas ├── vHostBufferManager.pas ├── vImage.pas ├── vImageManager.pas ├── vImageTiling.pas ├── vMemory.pas ├── vPipeline.pas ├── vPipelineLayoutManager.pas ├── vRender.pas ├── vRenderPassManager.pas ├── vSampler.pas ├── vSamplerManager.pas ├── vSetLayoutManager.pas ├── vSetsPoolManager.pas ├── vShader.pas ├── vShaderExt.pas └── vShaderManager.pas /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | 2 | name: Main CI 3 | 4 | on: 5 | push: 6 | branches: 7 | - '*' 8 | tags: 9 | - '*' 10 | 11 | workflow_dispatch: 12 | 13 | jobs: 14 | build_windows: 15 | runs-on: windows-latest 16 | 17 | steps: 18 | - name: Checkout source code 19 | uses: actions/checkout@v4 20 | 21 | - name: Install Lazarus 22 | uses: red-prig/setup-lazarus@v3 23 | with: 24 | lazarus-version: "3.6" 25 | with-cache: true 26 | 27 | - name: Hash 28 | shell: cmd 29 | working-directory: ./ 30 | run: echo '%GITHUB_SHA:~0,7%' > tag.inc 31 | 32 | - name: Tag 33 | shell: cmd 34 | working-directory: ./ 35 | if: startsWith(github.ref, 'refs/tags/') 36 | run: echo '%GITHUB_REF_NAME%' > tag.inc 37 | 38 | - name: Compile 39 | shell: cmd 40 | working-directory: ./ 41 | run: | 42 | lazbuild -B fpPS4.lpi > nul 43 | strip fpPS4.exe 44 | 45 | - name: Download 46 | shell: cmd 47 | working-directory: ./ 48 | run: | 49 | curl -k -L -s https://github.com/red-prig/fpps4-bin/raw/main/ffmpeg.zip -o ffmpeg.zip 50 | unzip ffmpeg.zip 51 | 52 | - name: Upload artifacts 53 | uses: actions/upload-artifact@v4 54 | if: ${{ !startsWith(github.ref, 'refs/tags/') }} 55 | with: 56 | name: fpPS4 57 | path: | 58 | fpPS4.exe 59 | *.dll 60 | if-no-files-found: warn 61 | 62 | - name: Pack 63 | shell: cmd 64 | working-directory: ./ 65 | if: startsWith(github.ref, 'refs/tags/') 66 | run: | 67 | mkdir sce_module 68 | echo "Put libSceNgs2.prx and etc. here" > sce_module/info.txt 69 | zip -9 -qq -r "fpPS4_%GITHUB_REF_NAME%.zip" "fpPS4.exe" "*.dll" "sce_module/info.txt" 70 | 71 | - name: Release 72 | uses: softprops/action-gh-release@v2 73 | if: startsWith(github.ref, 'refs/tags/') 74 | with: 75 | files: ./fpPS4_${{ github.ref_name }}.zip 76 | -------------------------------------------------------------------------------- /.github/workflows/pr.yml: -------------------------------------------------------------------------------- 1 | 2 | name: PR CI 3 | 4 | on: 5 | pull_request: 6 | branches: 7 | - '*' 8 | 9 | workflow_dispatch: 10 | 11 | jobs: 12 | build_windows: 13 | runs-on: windows-latest 14 | 15 | steps: 16 | - name: Checkout source code 17 | uses: actions/checkout@v4 18 | 19 | - name: Install Lazarus 20 | uses: red-prig/setup-lazarus@v3 21 | with: 22 | lazarus-version: "3.6" 23 | with-cache: true 24 | 25 | - name: Hash 26 | shell: cmd 27 | working-directory: ./ 28 | run: echo '%GITHUB_SHA:~0,7%' > tag.inc 29 | 30 | - name: Compile 31 | shell: cmd 32 | working-directory: ./ 33 | run: | 34 | lazbuild -B fpPS4.lpi > nul 35 | strip fpPS4.exe 36 | 37 | - name: Upload artifacts 38 | uses: actions/upload-artifact@v4 39 | with: 40 | name: fpPS4 41 | path: fpPS4.exe 42 | if-no-files-found: warn 43 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | *.dll 3 | *.lps 4 | *.ppu 5 | *.bak 6 | *.o 7 | *.ini 8 | *.db 9 | *.rar 10 | *.tga 11 | *.bat 12 | *.prx 13 | *.sprx 14 | *.dump 15 | link.res 16 | lib/ 17 | backup/ 18 | shader_dump/* 19 | avplayer_dump/* 20 | savedata/* 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # fpPS4 [![CI](https://github.com/red-prig/fpPS4/actions/workflows/main.yml/badge.svg)](https://github.com/red-prig/fpPS4/actions) [](https://discord.gg/up9qatpX7M) 3 | 4 | This emulator is still in the early stages of development and big games like the tripple A game still don't work, see the compatibility list for more details: https://github.com/red-prig/fpps4-game-compatibility/issues 5 | 6 | If your game doesn't work don't create a new issue, check the compatibility list first. 7 | 8 | If you want to know the details or just chat, welcome to the discord: https://discord.gg/up9qatpX7M 9 | 10 | I am currently rewriting the emulator core in the [kern](https://github.com/red-prig/fpPS4/tree/kern) branch and until the work is completed, there will be no support for specific games. 11 | 12 | # Donate: [](https://boosty.to/fpps4) 13 | 14 | ![Book logo](/icons/logo.png) 15 | 16 | # 17 | 18 | PS4 compatibility layer (emulator) written with Free Pascal 19 | 20 | This project is currently at the beginning and started for fun. 21 | 22 | ### Building 23 | - Free Pascal compiler: 3.3.1 (use fpcupdeluxe with trunk), x86_64 only. 24 | - Lazarus: 2.0.0 and higher, x86_64 only. 25 | 26 | ### Minimum system requirements 27 | 28 | - OS: Windows 7 SP1 x64 and higher 29 | - CPU: x64, AVX2 support 30 | - GPU: Vulkan API support 31 | 32 | ### Game compatibility tracker 33 | https://github.com/red-prig/fpps4-game-compatibility/issues 34 | 35 | ### Control layout 36 | To switch to borderless full screen mode, press Alt-Enter. 37 | 38 | fpPS4 supports XInput-compatible gamepads natively. You can remap buttons by pressing Esc on the keyboard during emulation. 39 | Regardless, you can use a keyboard as a input. 40 | A DualShock4 touchpad is emulated by the mouse. 41 | 42 | # Keyboard layout: 43 | PS4 Gamepad button | Keyboard button 44 | :------------ | :------------ 45 | Left Stick Up |W 46 | Left Stick Left |A 47 | Left Stick Down |S 48 | Left Stick Right |D 49 | Right Stick Up |I 50 | Right Stick Left |J 51 | Right Stick Down |K 52 | Right Stick Right |L 53 | OPTIONS |Enter 54 | Dpad Up |Arrow Up 55 | Dpad Left |Arrow Left 56 | Dpad Down |Arrow Down 57 | Dpad Right |Arrow Right 58 | Triangle |Numpad 8 59 | Square |Numpad 4 60 | Cross |Numpad 2 61 | Circle |Numpad 6 62 | L1 |Q 63 | L2 |1 64 | L3 |Z 65 | R1 |E 66 | R2 |4 67 | R3 |C 68 | -------------------------------------------------------------------------------- /as_only.cmd: -------------------------------------------------------------------------------- 1 | 2 | @echo off 3 | cd /D "%~dp0" 4 | 5 | Set opt=spirv-opt --eliminate-dead-branches --eliminate-local-multi-store --eliminate-dead-code-aggressive --scalar-replacement --simplify-instructions 6 | 7 | call :folder shader_dump 8 | 9 | pause 10 | exit 11 | 12 | :folder 13 | For /F %%a in ('dir /B %1') do if "%%~xa"==".txt" (call :compil %1\%%~na) 14 | exit /b 15 | 16 | :compil 17 | echo %~n1 18 | del %1.spv >nul 2>&1 19 | spirv-as --target-env vulkan1.1 %1.txt -o %1.spv 20 | spirv-val --scalar-block-layout --target-env vulkan1.1 %1.spv 21 | rem %opt% %1.spv -o %1.spv 22 | exit /b 23 | -------------------------------------------------------------------------------- /as_shader_dump.cmd: -------------------------------------------------------------------------------- 1 | 2 | @echo off 3 | cd /D "%~dp0" 4 | 5 | Set opt=spirv-opt --eliminate-dead-branches --eliminate-local-multi-store --eliminate-dead-code-aggressive --scalar-replacement --simplify-instructions 6 | 7 | call :folder shader_dump 8 | 9 | pause 10 | exit 11 | 12 | :folder 13 | For /F %%a in ('dir /B %1') do if "%%~xa"==".dump" (call :compil %1\%%~na) 14 | exit /b 15 | 16 | :compil 17 | echo %~n1 18 | del %1.txt >nul 2>&1 19 | del %1.spv >nul 2>&1 20 | spirv\pssl-spirv %1.dump -p > %1.txt 21 | spirv\pssl-spirv %1.dump -b %1.spv 22 | spirv-val --target-env vulkan1.1 --scalar-block-layout %1.spv 23 | rem %opt% %1.spv -o %1.spv 24 | exit /b 25 | -------------------------------------------------------------------------------- /ffmpeg/ffmpeg_types.pas: -------------------------------------------------------------------------------- 1 | unit ffmpeg_types; 2 | 3 | {$IFDEF FPC} 4 | {$MODE Delphi} 5 | {$ENDIF} 6 | 7 | interface 8 | 9 | Type 10 | Bool = WordBool; 11 | float = Single; 12 | ppDouble = ^pDouble; 13 | 14 | size_t = NativeUInt; 15 | psize_t = ^size_t; 16 | ptrdiff_t = UInt32; 17 | uint32_t = Cardinal; 18 | unsigned = uint32_t; 19 | unsignedint = UInt32; 20 | UINT = unsigned; 21 | unsigned_int = UInt32; 22 | punsigned_int = ^unsigned_int; 23 | unsigned_long = Cardinal; 24 | 25 | unsignedchar = Byte; 26 | unsigned_char = unsignedchar; 27 | punsignedchar = PByte; // ^unsignedchar; 28 | punsigned_char = punsignedchar; 29 | 30 | Int = Integer; 31 | pint = ^Int; 32 | ppint = ^pint; 33 | 34 | int8_t = Int8; 35 | pint8_t = ^int8_t; 36 | 37 | uint8_t = Byte; 38 | puint8_t = PByte; // ^uint8_t; 39 | ppuint8_t = ^puint8_t; 40 | PPByte = ppuint8_t; 41 | 42 | int16_t = int16; 43 | pint16_t = ^int16_t; 44 | uint16_t = UInt16; 45 | puint16_t = ^uint16_t; 46 | 47 | int32_t = Int32; 48 | pint32_t = ^int32_t; 49 | ppint32_t = ^pint32_t; 50 | 51 | int64_t = Int64; 52 | pint64_t = ^int64_t; 53 | uint64_t = UInt64; 54 | puint64_t = ^uint64_t; 55 | 56 | array_uint8_t = array [0 .. 0] of uint8_t; 57 | parray_uint8_t = ^array_uint8_t; 58 | 59 | array_int = array [0 .. 0] of Int; 60 | parray_int = ^array_int; 61 | 62 | array4_int = array [0 .. 3] of Int; 63 | parray4_int = ^array4_int; 64 | 65 | array4_puint8_t = array [0 .. 3] of puint8_t; 66 | parray4_puint8_t = ^array4_puint8_t; 67 | 68 | array4_ptrdiff_t = array [0 .. 3] of ptrdiff_t; 69 | parray4_ptrdiff_t = ^array4_ptrdiff_t; 70 | 71 | time_t = LongInt; 72 | 73 | AnsiCharArray = array [0 .. 0] of pAnsiChar; 74 | pAnsiCharArray = ^AnsiCharArray; 75 | 76 | (* MICROSOFT VC++ STDIO'S FILE DEFINITION *) 77 | _iobuf = record 78 | _ptr: pAnsiChar; 79 | _cnt: Integer; 80 | _base: pAnsiChar; 81 | _flag: Integer; 82 | _file: Integer; 83 | _charbuf: Integer; 84 | _bufsiz: Integer; 85 | _tmpfname: pAnsiChar; 86 | end; 87 | 88 | PFile = ^TFile; 89 | TFile = _iobuf; 90 | 91 | pAVHWAccel = Pointer; 92 | ppAVCodecHWConfigInternal = Pointer; 93 | 94 | const 95 | max_unsigned = $FFFF; 96 | 97 | implementation 98 | 99 | end. 100 | -------------------------------------------------------------------------------- /ffmpeg/libpostproc.pas: -------------------------------------------------------------------------------- 1 | unit libpostproc; 2 | 3 | {$IFDEF FPC} 4 | {$MODE Delphi} 5 | {$ENDIF} 6 | 7 | interface 8 | 9 | Uses 10 | ffmpeg_types; 11 | 12 | {$I ffmpeg.inc} 13 | 14 | (* * 15 | * Return the LIBPOSTPROC_VERSION_INT constant. 16 | *) 17 | // unsigned postproc_version(void); 18 | function postproc_version(): unsigned; cdecl; external postproc_dll; 19 | 20 | (* * 21 | * Return the libpostproc build-time configuration. 22 | *) 23 | // const char *postproc_configuration(void); 24 | function postproc_configuration(): pAnsiChar; cdecl; external postproc_dll; 25 | (* * 26 | * Return the libpostproc license. 27 | *) 28 | // const char *postproc_license(void); 29 | function postproc_license(): pAnsiChar; cdecl; external postproc_dll; 30 | 31 | const 32 | PP_QUALITY_MAX = 6; 33 | 34 | // #include 35 | 36 | type 37 | ppp_context = ^pp_context; 38 | 39 | pp_context = record 40 | end; 41 | 42 | ppp_mode = ^pp_mode; 43 | 44 | pp_mode = record 45 | end; 46 | 47 | Tpp_src_puint8_t = array [0 .. 2] of puint8_t; 48 | Tpp_dst_puint8_t = Tpp_src_puint8_t; 49 | Tpp_srcStride_int = array [0 .. 2] of int; 50 | Tpp_dstStride_int = Tpp_srcStride_int; 51 | 52 | (* 53 | #if LIBPOSTPROC_VERSION_INT < (52<<16) 54 | typedef pp_context pp_context_t; 55 | typedef pp_mode pp_mode_t; 56 | extern const char *const pp_help; ///< a simple help text 57 | #else 58 | extern const char pp_help[]; ///< a simple help text 59 | #endif 60 | *) 61 | 62 | // void pp_postprocess(const uint8_t * src[3], const int srcStride[3], 63 | // uint8_t * dst[3], const int dstStride[3], 64 | // int horizontalSize, int verticalSize, 65 | // const int8_t *QP_store, int QP_stride, 66 | // pp_mode *mode, pp_context *ppContext, int pict_type); 67 | 68 | procedure pp_postprocess(const src: Tpp_src_puint8_t; const srcStride: Tpp_srcStride_int; dst: Tpp_dst_puint8_t; 69 | const dstStride: Tpp_dstStride_int; horizontalSize: int; verticalSize: int; const QP_store: pint8_t; QP_stride: int; mode: ppp_mode; 70 | ppContext: ppp_context; pict_type: int); cdecl; external postproc_dll; 71 | (* * 72 | * Return a pp_mode or NULL if an error occurred. 73 | * 74 | * @param name the string after "-pp" on the command line 75 | * @param quality a number from 0 to PP_QUALITY_MAX 76 | *) 77 | // pp_mode *pp_get_mode_by_name_and_quality(const char *name, int quality); 78 | function pp_get_mode_by_name_and_quality(const name: pAnsiChar; quality: int): ppp_mode; cdecl; external postproc_dll; 79 | 80 | // void pp_free_mode(pp_mode *mode); 81 | procedure pp_free_mode(mode: ppp_mode); cdecl; external postproc_dll; 82 | 83 | // pp_context *pp_get_context(int width, int height, int flags); 84 | function pp_get_context(width: int; height: int; flags: int): ppp_context; cdecl; external postproc_dll; 85 | 86 | // void pp_free_context(pp_context *ppContext); 87 | procedure pp_free_context(ppContext: ppp_context); cdecl; external postproc_dll; 88 | 89 | const 90 | PP_CPU_CAPS_MMX = $80000000; 91 | PP_CPU_CAPS_MMX2 = $20000000; 92 | PP_CPU_CAPS_3DNOW = $40000000; 93 | PP_CPU_CAPS_ALTIVEC = $10000000; 94 | PP_CPU_CAPS_AUTO = $00080000; 95 | 96 | PP_FORMAT = $00000008; 97 | PP_FORMAT_420 = ($00000011 or PP_FORMAT); 98 | PP_FORMAT_422 = ($00000001 or PP_FORMAT); 99 | PP_FORMAT_411 = ($00000002 or PP_FORMAT); 100 | PP_FORMAT_444 = ($00000000 or PP_FORMAT); 101 | PP_FORMAT_440 = ($00000010 or PP_FORMAT); 102 | 103 | PP_PICT_TYPE_QP2 = $00000010; 104 | /// < MPEG2 style QScale 105 | 106 | implementation 107 | 108 | end. 109 | -------------------------------------------------------------------------------- /fpPS4.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red-prig/fpPS4/04cefd43e6fddd1ab033e7980cd356d14c964905/fpPS4.ico -------------------------------------------------------------------------------- /fpPS4.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red-prig/fpPS4/04cefd43e6fddd1ab033e7980cd356d14c964905/fpPS4.res -------------------------------------------------------------------------------- /icons/Readme.txt: -------------------------------------------------------------------------------- 1 | 2 | /---------\ 3 | |logo.png | 4 | |fpPS4.ico| 5 | \---------/ 6 | 7 | Basic icon theme: 8 | Author: https://github.com/Mou-Ikkai 9 | 10 | -------------------------------------------------------------------------------- /icons/SuriK/Readme.txt: -------------------------------------------------------------------------------- 1 | 2 | /---------\ 3 | |logo.png | 4 | |fpPS4.ico| 5 | \---------/ 6 | 7 | Basic icon theme: 8 | Author: SuriK#7587 9 | 10 | -------------------------------------------------------------------------------- /icons/SuriK/fpPS4.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red-prig/fpPS4/04cefd43e6fddd1ab033e7980cd356d14c964905/icons/SuriK/fpPS4.ico -------------------------------------------------------------------------------- /icons/SuriK/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red-prig/fpPS4/04cefd43e6fddd1ab033e7980cd356d14c964905/icons/SuriK/logo.png -------------------------------------------------------------------------------- /icons/boosty.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/fpPS4.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red-prig/fpPS4/04cefd43e6fddd1ab033e7980cd356d14c964905/icons/fpPS4.ico -------------------------------------------------------------------------------- /icons/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red-prig/fpPS4/04cefd43e6fddd1ab033e7980cd356d14c964905/icons/logo.png -------------------------------------------------------------------------------- /rtl/bittype.pas: -------------------------------------------------------------------------------- 1 | unit bittype; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | type 8 | bit1=0..1; 9 | bit2=0..3; 10 | bit3=0..7; 11 | bit4=0..15; 12 | bit5=0..31; 13 | bit6=0..63; 14 | bit7=0..127; 15 | bit8=Byte; 16 | bit9=0..511; 17 | bit10=0..1023; 18 | bit11=0..2047; 19 | bit12=0..4095; 20 | bit13=0..8191; 21 | bit14=0..16383; 22 | bit15=0..32767; 23 | bit16=Word; 24 | bit17=0..131071; 25 | bit18=0..262143; 26 | bit19=0..524287; 27 | bit20=0..1048575; 28 | bit21=0..2097151; 29 | bit22=0..4194303; 30 | bit23=0..8388607; 31 | bit24=0..16777215; 32 | bit25=0..33554431; 33 | bit26=0..67108863; 34 | bit27=0..134217727; 35 | bit28=0..268435455; 36 | bit29=0..536870911; 37 | bit30=0..1073741823; 38 | bit31=0..2147483647; 39 | bit32=DWORD; 40 | bit38=0..274877906943; 41 | bit43=0..8796093022207; 42 | bit44=0..17592186044415; 43 | bit48=0..281474976710655; 44 | bit64=QWORD; 45 | 46 | implementation 47 | 48 | end. 49 | 50 | -------------------------------------------------------------------------------- /rtl/ps4_elf_tls.pas: -------------------------------------------------------------------------------- 1 | unit ps4_elf_tls; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, 9 | SysUtils, 10 | Hamt; 11 | 12 | type 13 | Pdtv=^Tdtv; 14 | Tdtv=packed record 15 | value:Pointer; 16 | is_static:QWORD; 17 | gen:QWORD; 18 | end; 19 | Ptls_tcb=^Ttls_tcb; 20 | Ttls_tcb=packed record 21 | seg_adr:Pointer; 22 | dtv:Pdtv; 23 | _dtv:Tdtv; 24 | base:Pointer; 25 | end; 26 | 27 | function _init_tls_tcb(Size,_align,is_static,gen:QWORD):Ptls_tcb; 28 | function _get_tls_tcb(gen:QWORD):Ptls_tcb; 29 | procedure _free_tls_tcb_all; 30 | 31 | implementation 32 | 33 | threadvar 34 | tls_local:THAMT; 35 | 36 | function _init_tls_tcb(Size,_align,is_static,gen:QWORD):Ptls_tcb; 37 | var 38 | full_size:QWORD; 39 | base:Pointer; 40 | dtv :Pointer; 41 | tcb :Ptls_tcb; 42 | PP :PPointer; 43 | begin 44 | if (_align=0) then _align:=1; 45 | 46 | full_size:=Size+(_align-1)+SizeOf(Ttls_tcb); 47 | base:=AllocMem(full_size); 48 | dtv :=Align(base,_align); 49 | 50 | tcb:=Pointer(dtv+Size); 51 | tcb^.base:=base; 52 | 53 | tcb^.seg_adr:=tcb; 54 | tcb^.dtv:=@tcb^._dtv; 55 | tcb^._dtv.value:=dtv; 56 | tcb^._dtv.is_static:=is_static; 57 | tcb^._dtv.gen:=gen; 58 | 59 | if (tls_local=nil) then tls_local:=HAMT_create64; 60 | PP:=HAMT_insert64(tls_local,gen,tcb); 61 | Assert(PP<>nil); 62 | Assert(PP^=tcb); 63 | Result:=tcb; 64 | end; 65 | 66 | function _get_tls_tcb(gen:QWORD):Ptls_tcb; 67 | var 68 | PP:PPointer; 69 | begin 70 | Result:=nil; 71 | PP:=HAMT_search64(tls_local,gen); 72 | if (PP<>nil) then Result:=PP^; 73 | end; 74 | 75 | procedure _free_tls_tcb(data,userdata:Pointer); 76 | Var 77 | tcb:Ptls_tcb; 78 | base:Pointer; 79 | begin 80 | tcb:=data; 81 | if (tcb=nil) then Exit; 82 | base:=tcb^.base; 83 | FreeMem(base); 84 | end; 85 | 86 | procedure _free_tls_tcb_all; 87 | begin 88 | HAMT_destroy64(tls_local,@_free_tls_tcb,nil); 89 | tls_local:=nil; 90 | end; 91 | 92 | end. 93 | 94 | -------------------------------------------------------------------------------- /rtl/ps4_handles.pas: -------------------------------------------------------------------------------- 1 | unit ps4_handles; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | hamt, 9 | RWLock, 10 | Classes, SysUtils; 11 | 12 | type 13 | TClassHandle=class 14 | private 15 | FRef:Pointer; 16 | public 17 | Procedure Acqure; 18 | Procedure Release; 19 | end; 20 | AClassHandle=Array of TClassHandle; 21 | 22 | TClassHandleLock=class(TClassHandle) 23 | private 24 | FLock:TRWLock; 25 | public 26 | constructor Create; 27 | destructor Destroy; override; 28 | Procedure Lock; 29 | Procedure UnLock; 30 | end; 31 | 32 | TIntegerHandles=class 33 | private 34 | Const 35 | def_max_key=$7FFFFFFF; 36 | var 37 | FStub:TSTUB_HAMT32; 38 | FHAMT:THAMT; 39 | FCount,FPos:Integer; 40 | FLock:TRWLock; 41 | public 42 | min_key,max_key:Integer; 43 | constructor Create(min:Integer); 44 | destructor Destroy; override; 45 | function New(H:TClassHandle;var OutKey:Integer):Boolean; 46 | function Acqure(const Key:Integer):TClassHandle; 47 | function Delete(const Key:Integer):Boolean; 48 | end; 49 | 50 | implementation 51 | 52 | Procedure TClassHandle.Acqure; 53 | begin 54 | System.InterlockedIncrement(FRef); 55 | end; 56 | 57 | Procedure TClassHandle.Release; 58 | begin 59 | if System.InterlockedDecrement(FRef)=nil then 60 | begin 61 | Free; 62 | end; 63 | end; 64 | 65 | constructor TClassHandleLock.Create; 66 | begin 67 | inherited; 68 | rwlock_init(FLock); 69 | end; 70 | 71 | destructor TClassHandleLock.Destroy; 72 | begin 73 | rwlock_destroy(FLock); 74 | inherited; 75 | end; 76 | 77 | Procedure TClassHandleLock.Lock; 78 | begin 79 | rwlock_wrlock(FLock); 80 | end; 81 | 82 | Procedure TClassHandleLock.UnLock; 83 | begin 84 | rwlock_unlock(FLock); 85 | end; 86 | 87 | constructor TIntegerHandles.Create(min:Integer); 88 | begin 89 | min_key:=min; 90 | max_key:=def_max_key; 91 | FPos:=min; 92 | FHAMT:=@FStub; 93 | rwlock_init(FLock); 94 | end; 95 | 96 | procedure _free_data_cb(data,userdata:Pointer); 97 | begin 98 | if (data<>nil) then 99 | TClassHandle(data).Release; 100 | end; 101 | 102 | destructor TIntegerHandles.Destroy; 103 | begin 104 | HAMT_clear32(FHAMT,@_free_data_cb,nil); 105 | rwlock_destroy(FLock); 106 | inherited; 107 | end; 108 | 109 | function TIntegerHandles.New(H:TClassHandle;var OutKey:Integer):Boolean; 110 | Var 111 | i,m:Integer; 112 | data:PPointer; 113 | Label 114 | _data,_exit; 115 | begin 116 | Result:=False; 117 | if (H=nil) then Exit; 118 | rwlock_wrlock(FLock); 119 | m:=(max_key-min_key); 120 | if (FCount>=m+1) then Goto _exit; 121 | if (FPosmax_key) then FPos:=min_key; 122 | if (FCount=0) then 123 | begin 124 | OutKey:=FPos; 125 | Inc(FPos); 126 | data:=HAMT_insert32(FHAMT,OutKey,Pointer(H)); 127 | if (data=nil) then Goto _exit; 128 | if (data^<>Pointer(H)) then Goto _exit; 129 | end else 130 | begin 131 | For i:=0 to m do 132 | begin 133 | OutKey:=FPos; 134 | Inc(FPos); 135 | if (FPos>max_key) then FPos:=min_key; 136 | data:=HAMT_insert32(FHAMT,OutKey,Pointer(H)); 137 | if (data=nil) then Goto _exit; 138 | if (data^=Pointer(H)) then Goto _data; 139 | end; 140 | Goto _exit; 141 | end; 142 | _data: 143 | Inc(FCount); 144 | H.Acqure; 145 | H.Acqure; 146 | Result:=True; 147 | _exit: 148 | rwlock_unlock(FLock); 149 | end; 150 | 151 | function TIntegerHandles.Acqure(const Key:Integer):TClassHandle; 152 | Var 153 | data:PPointer; 154 | Label 155 | _exit; 156 | begin 157 | Result:=nil; 158 | if (Keymax_key) then Exit; 159 | rwlock_rdlock(FLock); 160 | data:=HAMT_search32(FHAMT,Key); 161 | if (data=nil) then Goto _exit; 162 | Pointer(Result):=data^; 163 | if Assigned(Result) then 164 | begin 165 | Result.Acqure; 166 | end; 167 | _exit: 168 | rwlock_unlock(FLock); 169 | end; 170 | 171 | function TIntegerHandles.Delete(const Key:Integer):Boolean; 172 | Var 173 | data:TClassHandle; 174 | begin 175 | Result:=False; 176 | if (Keymax_key) then Exit; 177 | rwlock_wrlock(FLock); 178 | HAMT_delete32(FHAMT,Key,@data); 179 | if Assigned(data) then 180 | begin 181 | data.Release; 182 | Dec(FCount); 183 | Result:=True; 184 | end; 185 | rwlock_unlock(FLock); 186 | end; 187 | 188 | end. 189 | 190 | -------------------------------------------------------------------------------- /rtl/stub_manager.pas: -------------------------------------------------------------------------------- 1 | unit stub_manager; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Windows; 9 | 10 | type 11 | TStubMemory=object 12 | protected 13 | type 14 | PNode=^TNode; 15 | TNode=record 16 | pNext:PNode; 17 | Stub_va:Pointer; 18 | end; 19 | Const 20 | VA_SIZE=16*1024; 21 | var 22 | pHead:PNode; 23 | Stub_va:Pointer; 24 | Stub_pos:Word; 25 | procedure Push(P:Pointer); 26 | function Pop:Pointer; 27 | public 28 | Procedure Clear; 29 | procedure FinStub; 30 | function NewStub(data:Pointer;size:Word):Pointer; 31 | end; 32 | 33 | TStubMemoryProc=object(TStubMemory) 34 | function NewNopStub(nid:QWORD;lib,proc:Pointer):Pointer; 35 | end; 36 | 37 | implementation 38 | 39 | procedure TStubMemory.Push(P:Pointer); 40 | var 41 | Node:PNode; 42 | begin 43 | Node:=AllocMem(SizeOf(TNode)); 44 | Node^.Stub_va:=P; 45 | if (pHead=nil) then 46 | begin 47 | node^.pNext:=nil; 48 | end else 49 | begin 50 | node^.pNext:=pHead; 51 | end; 52 | pHead:=node; 53 | end; 54 | 55 | function TStubMemory.Pop:Pointer; 56 | var 57 | Node:PNode; 58 | begin 59 | Result:=nil; 60 | Node:=pHead; 61 | if (pHead<>nil) then 62 | begin 63 | pHead:=pHead^.pNext; 64 | end; 65 | if (Node<>nil) then 66 | begin 67 | Node^.pNext:=nil; 68 | end; 69 | if (Node<>nil) then 70 | begin 71 | Result:=Node^.Stub_va; 72 | FreeMem(Node); 73 | end; 74 | end; 75 | 76 | Procedure TStubMemory.Clear; 77 | var 78 | P:Pointer; 79 | begin 80 | P:=Pop; 81 | While (P<>nil) do 82 | begin 83 | VirtualFree(P,0,MEM_RELEASE); 84 | P:=Pop; 85 | end; 86 | if (Stub_va<>nil) then 87 | begin 88 | VirtualFree(Stub_va,0,MEM_RELEASE); 89 | end; 90 | Stub_va:=nil; 91 | Stub_pos:=0; 92 | end; 93 | 94 | procedure TStubMemory.FinStub; 95 | var 96 | dummy:DWORD; 97 | begin 98 | if (Stub_va<>nil) then 99 | begin 100 | Push(Stub_va); 101 | //VirtualProtect(Stub_va,VA_SIZE,PAGE_EXECUTE_READ,@dummy); 102 | FlushInstructionCache(GetCurrentProcess,Stub_va,VA_SIZE); 103 | Stub_va:=nil; 104 | Stub_pos:=0; 105 | end; 106 | end; 107 | 108 | function TStubMemory.NewStub(data:Pointer;size:Word):Pointer; 109 | begin 110 | if ((Stub_pos+size)>VA_SIZE) then 111 | FinStub; 112 | 113 | if (Stub_va=nil) then 114 | begin 115 | Stub_va:=VirtualAlloc(nil,VA_SIZE,MEM_COMMIT or MEM_RESERVE,{PAGE_READWRITE}PAGE_EXECUTE_READWRITE); 116 | end; 117 | 118 | Result:=Stub_va+Stub_pos; 119 | Move(data^,Result^,size); 120 | Stub_pos:=Stub_pos+size; 121 | end; 122 | 123 | // 124 | 125 | 126 | //52 push %rdx 127 | //51 push %rcx 128 | //48ba0100000000000000 movabs $0x1,%rdx 129 | //48b90200000000000000 movabs $0x2,%rcx 130 | //48b80300000000000000 movabs $0x3,%rax 131 | //ffd0 callq *%rax 132 | //4831c0 xor %rax,%rax 133 | //59 pop %rcx 134 | //5a pop %rdx 135 | //c3 retq 136 | 137 | 138 | Type 139 | Pnopstub=^Tnopstub; 140 | Tnopstub=packed record 141 | _push_rdx:Byte; // $52 142 | _push_rcx:Byte; // $51 143 | _movabs_rdx:array[0..1] of Byte; // $48 $ba 144 | _lib:Pointer; 145 | _movabs_rcx:array[0..1] of Byte; // $48 $B9 146 | _nid:QWord; 147 | _movabs_rax:array[0..1] of Byte; // $48 $B8 148 | _addr:Pointer; 149 | _call_rax:array[0..1] of Byte; // $FF $D0 150 | _pop_rcx:Byte; // $59 151 | _pop_rdx:Byte; // $5A 152 | _ret:Byte; // $C3 153 | end; 154 | 155 | const 156 | _nopstub:Tnopstub=( 157 | _push_rdx:$52; 158 | _push_rcx:$51; 159 | _movabs_rdx:($48,$BA); 160 | _lib:nil; 161 | _movabs_rcx:($48,$B9); 162 | _nid:0; 163 | _movabs_rax:($48,$B8); 164 | _addr:nil; 165 | _call_rax:($FF,$D0); 166 | _pop_rcx:$59; 167 | _pop_rdx:$5A; 168 | _ret:$C3 169 | ); 170 | 171 | function TStubMemoryProc.NewNopStub(nid:QWORD;lib,proc:Pointer):Pointer; 172 | var 173 | nopstub:Tnopstub; 174 | begin 175 | nopstub:=_nopstub; 176 | nopstub._lib:=lib; 177 | nopstub._nid:=nid; 178 | nopstub._addr:=proc; 179 | Result:=NewStub(@nopstub,SizeOf(Tnopstub)); 180 | end; 181 | 182 | end. 183 | 184 | -------------------------------------------------------------------------------- /shaders/FLIP_CURSOR.comp: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout (local_size_x = 16, local_size_y = 16) in; 4 | 5 | layout (binding = 0) readonly buffer Host 6 | { 7 | uint data[]; 8 | } host; 9 | 10 | layout (binding = 1, rgba8) uniform image2D resultImage; 11 | 12 | layout (push_constant) uniform constants 13 | { 14 | vec4 gamma; 15 | ivec2 pos; 16 | } cfg; 17 | 18 | 19 | void main() 20 | { 21 | ivec2 pixelCoords = ivec2(gl_GlobalInvocationID.xy); 22 | 23 | int offset = (pixelCoords.y*64)+pixelCoords.x; 24 | 25 | uint pack=host.data[offset]; 26 | 27 | ////const uvec4 shift = uvec4(16,8,0,24); 28 | ////const uvec4 mask4 = uvec4(255,255,255,255); 29 | 30 | ////uvec4 pix_int=(uvec4(pack,pack,pack,pack) >> shift) & mask4; 31 | 32 | //24,16, 8, 0 33 | //AA,RR,GG,BB 34 | 35 | //0,8,16,24 36 | //R,G, B,A 37 | 38 | //16,8,0,24 39 | //BGRA 40 | 41 | //24,0,8,16 42 | //ARGB 43 | 44 | ////vec4 pixel = vec4(pix_int) / mask4; 45 | 46 | vec4 pixel=unpackUnorm4x8(pack); 47 | 48 | pixel=pixel.bgra; 49 | 50 | pixel = pow(pixel, cfg.gamma); 51 | 52 | pixelCoords = pixelCoords + cfg.pos; 53 | 54 | vec4 prev = imageLoad(resultImage, pixelCoords); 55 | 56 | pixel.rgb = mix(prev.rgb,pixel.rgb,pixel.a); 57 | 58 | imageStore(resultImage, pixelCoords, pixel); 59 | } 60 | 61 | -------------------------------------------------------------------------------- /shaders/FLIP_LINE_A8R8G8B8_SRGB.comp: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout (local_size_x = 16, local_size_y = 16) in; 4 | 5 | layout (binding = 0) readonly buffer Host 6 | { 7 | uint data[]; 8 | } host; 9 | 10 | layout (binding = 1, rgba8) writeonly uniform image2D resultImage; 11 | 12 | layout (push_constant) uniform constants 13 | { 14 | vec4 gamma; 15 | ivec2 Width; 16 | } cfg; 17 | 18 | 19 | void main() 20 | { 21 | ivec2 pixelCoords = ivec2(gl_GlobalInvocationID.xy); 22 | 23 | 24 | int offset = (pixelCoords.y*cfg.Width.y)+pixelCoords.x; 25 | 26 | uint pack=host.data[offset]; 27 | 28 | //const uvec4 shift = uvec4(16,8,0,24); 29 | //const uvec4 mask4 = uvec4(255,255,255,255); 30 | 31 | //uvec4 pix_int=(uvec4(pack,pack,pack,pack) >> shift) & mask4; 32 | 33 | //0,8,16,24 34 | //R,G, B,A 35 | 36 | //16,8,0,24 37 | //BGRA 38 | 39 | //vec4 pixel = vec4(pix_int) / mask4; 40 | 41 | vec4 pixel=unpackUnorm4x8(pack); 42 | 43 | pixel=pixel.bgra; 44 | 45 | pixel = pow(pixel, cfg.gamma); 46 | 47 | imageStore(resultImage, pixelCoords, pixel); 48 | } 49 | -------------------------------------------------------------------------------- /shaders/FLIP_TILE_A8B8G8R8_SRGB.comp: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout (local_size_x = 16, local_size_y = 16) in; 4 | 5 | layout (binding = 0) readonly buffer Host 6 | { 7 | uint data[]; 8 | } host; 9 | 10 | layout (binding = 1, rgba8) writeonly uniform image2D resultImage; 11 | 12 | layout (push_constant) uniform constants 13 | { 14 | vec4 gamma; 15 | ivec2 pitch; 16 | } cfg; 17 | 18 | const ivec2 sh02 = ivec2(0,2); 19 | const ivec4 sh1212 = ivec4(1,2,1,2); 20 | const ivec4 sh1345 = ivec4(1,3,4,5); 21 | 22 | const ivec3 sh345 = ivec3(3,4,5); 23 | const ivec3 sh678 = ivec3(6,7,8); 24 | 25 | const ivec4 sh6789 = ivec4(6,7,8,9); 26 | const ivec4 sh6543 = ivec4(6,5,4,3); 27 | const ivec4 sh9101112 = ivec4(9,10,11,12); 28 | 29 | const ivec2 i2_1 = ivec2(1,1); 30 | const ivec3 i3_1 = ivec3(1,1,1); 31 | const ivec4 i4_1 = ivec4(1,1,1,1); 32 | 33 | int getElementIndex(ivec2 p) //[0..5] 34 | { 35 | ivec2 t1=(p.xy & i2_1) << sh02; 36 | ivec4 t2=((p.xxyy >> sh1212) & i4_1) << sh1345; 37 | 38 | t1=t1 | t2.xy | t2.zw; 39 | return t1.x | t1.y; 40 | } 41 | 42 | int getPipeIndex(ivec2 p) //[6..8] 43 | { 44 | ivec3 t=(((p.xxx >> sh345) ^ (p.yyy >> sh345) ^ ivec3(p.x>>4,0,0)) & i3_1) << sh678; 45 | 46 | return t.x | t.y | t.z; 47 | } 48 | 49 | int getBankIndex(ivec2 p) //[9..12] 50 | { 51 | ivec4 bank=(((p.xxxx >> sh6789) ^ (p.yyyy >> sh6543) ^ ivec4(0,p.y>>6,0,0)) & i4_1) << sh9101112; 52 | 53 | ivec2 t=bank.xy | bank.zw; 54 | return t.x | t.y; 55 | } 56 | 57 | void main() 58 | { 59 | ivec2 pixelCoords = ivec2(gl_GlobalInvocationID.xy); 60 | 61 | int element_index=getElementIndex(pixelCoords); 62 | int pipe=getPipeIndex(pixelCoords); 63 | int bank=getBankIndex(pixelCoords); 64 | 65 | //const ivec4 shmt = ivec4(7,6,6,3); 66 | const ivec2 shmt = ivec2(7,6); 67 | //const ivec2 bmod = ivec2(1,1); 68 | 69 | //ivec4 mt=(pixelCoords.xyxy >> shmt); 70 | ivec2 mt=(pixelCoords.xy >> shmt); 71 | ivec2 total_offset=(mt.xy*cfg.pitch); 72 | //+(mt.zw % bmod); 73 | 74 | int offset = element_index | pipe | bank | ((total_offset.x+total_offset.y) << 13); 75 | 76 | uint pack=host.data[offset]; 77 | 78 | ////const uvec4 shift = uvec4(0,8,16,24); 79 | ////const uvec4 mask4 = uvec4(255,255,255,255); 80 | 81 | ////uvec4 pix_int=(uvec4(pack,pack,pack,pack) >> shift) & mask4; 82 | 83 | //0,8,16,24 84 | //RGBA 85 | 86 | ////vec4 pixel = vec4(pix_int) / mask4; 87 | 88 | vec4 pixel=unpackUnorm4x8(pack); 89 | 90 | pixel=pixel.rgba; 91 | 92 | pixel = pow(pixel, cfg.gamma); 93 | 94 | imageStore(resultImage, pixelCoords, pixel); 95 | } 96 | -------------------------------------------------------------------------------- /shaders/FLIP_TILE_A8R8G8B8_SRGB.comp: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout (local_size_x = 16, local_size_y = 16) in; 4 | 5 | layout (binding = 0) readonly buffer Host 6 | { 7 | uint data[]; 8 | } host; 9 | 10 | layout (binding = 1, rgba8) writeonly uniform image2D resultImage; 11 | 12 | layout (push_constant) uniform constants 13 | { 14 | vec4 gamma; 15 | ivec2 pitch; 16 | } cfg; 17 | 18 | const ivec2 sh02 = ivec2(0,2); 19 | const ivec4 sh1212 = ivec4(1,2,1,2); 20 | const ivec4 sh1345 = ivec4(1,3,4,5); 21 | 22 | const ivec3 sh345 = ivec3(3,4,5); 23 | const ivec3 sh678 = ivec3(6,7,8); 24 | 25 | const ivec4 sh6789 = ivec4(6,7,8,9); 26 | const ivec4 sh6543 = ivec4(6,5,4,3); 27 | const ivec4 sh9101112 = ivec4(9,10,11,12); 28 | 29 | const ivec2 i2_1 = ivec2(1,1); 30 | const ivec3 i3_1 = ivec3(1,1,1); 31 | const ivec4 i4_1 = ivec4(1,1,1,1); 32 | 33 | int getElementIndex(ivec2 p) //[0..5] 34 | { 35 | ivec2 t1=(p.xy & i2_1) << sh02; 36 | ivec4 t2=((p.xxyy >> sh1212) & i4_1) << sh1345; 37 | 38 | t1=t1 | t2.xy | t2.zw; 39 | return t1.x | t1.y; 40 | } 41 | 42 | int getPipeIndex(ivec2 p) //[6..8] 43 | { 44 | ivec3 t=(((p.xxx >> sh345) ^ (p.yyy >> sh345) ^ ivec3(p.x>>4,0,0)) & i3_1) << sh678; 45 | 46 | return t.x | t.y | t.z; 47 | } 48 | 49 | int getBankIndex(ivec2 p) //[9..12] 50 | { 51 | ivec4 bank=(((p.xxxx >> sh6789) ^ (p.yyyy >> sh6543) ^ ivec4(0,p.y>>6,0,0)) & i4_1) << sh9101112; 52 | 53 | ivec2 t=bank.xy | bank.zw; 54 | return t.x | t.y; 55 | } 56 | 57 | void main() 58 | { 59 | ivec2 pixelCoords = ivec2(gl_GlobalInvocationID.xy); 60 | 61 | int element_index=getElementIndex(pixelCoords); 62 | int pipe=getPipeIndex(pixelCoords); 63 | int bank=getBankIndex(pixelCoords); 64 | 65 | //const ivec4 shmt = ivec4(7,6,6,3); 66 | const ivec2 shmt = ivec2(7,6); 67 | //const ivec2 bmod = ivec2(1,1); 68 | 69 | //ivec4 mt=(pixelCoords.xyxy >> shmt); 70 | ivec2 mt=(pixelCoords.xy >> shmt); 71 | ivec2 total_offset=(mt.xy*cfg.pitch); 72 | //+(mt.zw % bmod); 73 | 74 | int offset = element_index | pipe | bank | ((total_offset.x+total_offset.y) << 13); 75 | 76 | uint pack=host.data[offset]; 77 | 78 | ////const uvec4 shift = uvec4(16,8,0,24); 79 | ////const uvec4 mask4 = uvec4(255,255,255,255); 80 | 81 | ////uvec4 pix_int=(uvec4(pack,pack,pack,pack) >> shift) & mask4; 82 | 83 | //0,8,16,24 84 | //R,G, B,A 85 | 86 | //16,8,0,24 87 | //BGRA 88 | 89 | ////vec4 pixel = vec4(pix_int) / mask4; 90 | 91 | vec4 pixel=unpackUnorm4x8(pack); 92 | 93 | pixel=pixel.bgra; 94 | 95 | pixel = pow(pixel, cfg.gamma); 96 | 97 | imageStore(resultImage, pixelCoords, pixel); 98 | } 99 | -------------------------------------------------------------------------------- /shaders/FLIP_TILE_A8R8G8B8_SRGB_NEO.comp: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout (local_size_x = 16, local_size_y = 16) in; 4 | 5 | layout (binding = 0) readonly buffer Host 6 | { 7 | uint data[]; 8 | } host; 9 | 10 | layout (binding = 1, rgba8) writeonly uniform image2D resultImage; 11 | 12 | layout (push_constant) uniform constants 13 | { 14 | vec4 gamma; 15 | ivec2 pitch; 16 | } cfg; 17 | 18 | const ivec2 sh02 = ivec2(0,2); 19 | const ivec4 sh1212 = ivec4(1,2,1,2); 20 | const ivec4 sh1345 = ivec4(1,3,4,5); 21 | 22 | const ivec4 sh3456 = ivec4(3,4,5,6); 23 | const ivec4 sh3455 = ivec4(3,4,5,5); 24 | const ivec4 sh6789 = ivec4(6,7,8,9); 25 | 26 | const ivec3 sh789 = ivec3(7,8,9); 27 | const ivec3 sh654 = ivec3(6,5,4); 28 | const ivec3 sh101112 = ivec3(10,11,12); 29 | 30 | const ivec2 i2_1 = ivec2(1,1); 31 | const ivec3 i3_1 = ivec3(1,1,1); 32 | const ivec4 i4_1 = ivec4(1,1,1,1); 33 | 34 | int getElementIndex(ivec2 p) //[0..5] 35 | { 36 | ivec2 t1=(p.xy & i2_1) << sh02; 37 | ivec4 t2=((p.xxyy >> sh1212) & i4_1) << sh1345; 38 | 39 | t1=t1 | t2.xy | t2.zw; 40 | return t1.x | t1.y; 41 | } 42 | 43 | int getPipeIndex(ivec2 p) //[6..9] 44 | { 45 | ivec4 t=(((p.xxxx >> sh3456) ^ (p.yyyy >> sh3455) ^ ivec4(p.x>>4,0,0,0)) & i4_1) << sh6789; 46 | 47 | ivec2 t2=t.xy | t.zw; 48 | return t2.x | t2.y; 49 | } 50 | 51 | int getBankIndex(ivec2 p) //[10..12] 52 | { 53 | ivec3 bank=(((p.xxx >> sh789) ^ (p.yyy >> sh654) ^ ivec3(0,p.y>>6,0)) & i3_1) << sh101112; 54 | 55 | return bank.x | bank.y | bank.z; 56 | } 57 | 58 | void main() 59 | { 60 | ivec2 pixelCoords = ivec2(gl_GlobalInvocationID.xy); 61 | 62 | int element_index=getElementIndex(pixelCoords); 63 | int pipe=getPipeIndex(pixelCoords); 64 | int bank=getBankIndex(pixelCoords); 65 | 66 | const ivec4 shmt = ivec4(7,7,7,3); 67 | const ivec2 bmod = ivec2(1,2); 68 | 69 | ivec4 mt=(pixelCoords.xyxy >> shmt); 70 | 71 | ivec2 total_offset=((mt.xy*cfg.pitch) << i2_1)+(mt.zw % bmod); 72 | 73 | int offset = element_index | pipe | bank | ((total_offset.x+total_offset.y) << 13); 74 | 75 | uint pack=host.data[offset]; 76 | 77 | ////const uvec4 shift = uvec4(16,8,0,24); 78 | ////const uvec4 mask4 = uvec4(255,255,255,255); 79 | 80 | ////uvec4 pix_int=(uvec4(pack,pack,pack,pack) >> shift) & mask4; 81 | 82 | //0,8,16,24 83 | //R,G, B,A 84 | 85 | //16,8,0,24 86 | //BGRA 87 | 88 | ////vec4 pixel = vec4(pix_int) / mask4; 89 | 90 | vec4 pixel=unpackUnorm4x8(pack); 91 | 92 | pixel=pixel.bgra; 93 | 94 | pixel = pow(pixel, cfg.gamma); 95 | 96 | imageStore(resultImage, pixelCoords, pixel); 97 | } 98 | -------------------------------------------------------------------------------- /shaders/compile.cmd: -------------------------------------------------------------------------------- 1 | 2 | @echo off 3 | 4 | Rem The source of "glslangValidator" and "spirv-opt" is Vulkan SDK 5 | Rem The source of "lazres" is Lazarus IDE 6 | 7 | Set spirvgls=glslangValidator -g0 -V --target-env vulkan1.0 8 | 9 | Set spirvopt=spirv-opt --eliminate-dead-branches --eliminate-local-multi-store --inline-entry-points-exhaustive --eliminate-dead-code-aggressive --scalar-replacement --simplify-instructions 10 | 11 | Set lrs=shaders.lrs 12 | 13 | echo [build comp] 14 | For /F %%a in ('dir /B') do if "%%~xa"==".comp" (call :build %%a %%~na) 15 | 16 | echo [build vert] 17 | For /F %%a in ('dir /B') do if "%%~xa"==".vert" (call :build %%a %%~na) 18 | 19 | echo [build lrs] 20 | lazres %lrs% 21 | 22 | echo [clean] 23 | For /F %%a in ('dir /B') do if "%%~xa"==".spv" (call del /Q %%a) 24 | 25 | pause 26 | exit 27 | 28 | :build 29 | Set lrs=%lrs% %2.spv 30 | %spirvgls% %1 -o %2.spv 31 | %spirvopt% %2.spv -o %2.spv 32 | exit /b 33 | -------------------------------------------------------------------------------- /shaders/shaders.pas: -------------------------------------------------------------------------------- 1 | unit shaders; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | LResources, 9 | Classes, 10 | SysUtils; 11 | 12 | function GetResourceStream(const ResName:string;ResType:PChar=nil):TStream; 13 | 14 | implementation 15 | 16 | function GetResourceStream(const ResName:string;ResType:PChar=nil):TStream; 17 | begin 18 | Result:=TLazarusResourceStream.Create(ResName,ResType); 19 | end; 20 | 21 | initialization 22 | {$I shaders.lrs} 23 | 24 | end. 25 | 26 | -------------------------------------------------------------------------------- /spirv/Half16.pas: -------------------------------------------------------------------------------- 1 | unit Half16; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | type 8 | PHalf16=^THalf16; 9 | THalf16=bitpacked record 10 | man:0..1023; 11 | exp:0..31; 12 | sgn:0..1; 13 | end; 14 | 15 | operator := (i:THalf16):Single; 16 | operator := (i:Single):THalf16; 17 | 18 | implementation 19 | 20 | operator := (i:THalf16):Single; 21 | var 22 | t1,t2,t3:DWORD; 23 | begin 24 | t1:=Word(i) and $7fff; // Non-sign bits 25 | t2:=Word(i) and $8000; // Sign bit 26 | t3:=Word(i) and $7c00; // Exponent 27 | 28 | t1:=t1 shl 13; // Align mantissa on MSB 29 | t2:=t2 shl 16; // Shift sign bit into position 30 | 31 | t1:=t1+$38000000; // Adjust bias 32 | 33 | if (t3=0) then t1:=0; // Denormals-as-zero 34 | 35 | t1:=t1 or t2; // Re-insert sign bit 36 | 37 | PDWORD(@Result)^:=t1; 38 | end; 39 | 40 | operator := (i:Single):THalf16; 41 | var 42 | t1,t2,t3:DWORD; 43 | begin 44 | t1:=PDWORD(@i)^ and $7fffffff; // Non-sign bits 45 | t2:=PDWORD(@i)^ and $80000000; // Sign bit 46 | t3:=PDWORD(@i)^ and $7f800000; // Exponent 47 | 48 | t1:=t1 shr 13; // Align mantissa on MSB 49 | t2:=t2 shr 16; // Shift sign bit into position 50 | 51 | t1:=t1-$1c000; // Adjust bias 52 | 53 | if (t3<$38800000) then t1:=0; // Flush-to-zero 54 | if (t3>$47000000) then t1:=$7bff; // Clamp-to-max 55 | 56 | t1:=t1 or t2; // Re-insert sign bit 57 | 58 | Word(Result):=Word(t1); 59 | end; 60 | 61 | end. 62 | 63 | -------------------------------------------------------------------------------- /spirv/emit_mtbuf.pas: -------------------------------------------------------------------------------- 1 | unit emit_MTBUF; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | sysutils, 9 | ps4_pssl, 10 | srReg, 11 | srLayout, 12 | emit_fetch, 13 | srVBufInfo, 14 | emit_vbuf_load, 15 | emit_vbuf_store; 16 | 17 | type 18 | TEmit_MTBUF=class(TEmitFetch) 19 | procedure emit_MTBUF; 20 | procedure emit_TBUFFER_LOAD_FORMAT(count:Byte); 21 | procedure emit_TBUFFER_STORE_FORMAT(count:Byte); 22 | end; 23 | 24 | implementation 25 | 26 | procedure TEmit_MTBUF.emit_TBUFFER_LOAD_FORMAT(count:Byte); 27 | var 28 | src:array[0..3] of PsrRegSlot; 29 | 30 | grp:PsrDataLayout; 31 | 32 | begin 33 | if not get_srsrc(FSPI.MTBUF.SRSRC,4,@src) then Assert(false); 34 | 35 | grp:=GroupingSharp(@src,rtVSharp4); 36 | 37 | TEmit_vbuf_load(TObject(Self)).buf_load( 38 | Buf_info(grp, 39 | dst_sel_identity, 40 | FSPI.MTBUF.DFMT, 41 | FSPI.MTBUF.NFMT, 42 | count) 43 | ); 44 | 45 | end; 46 | 47 | procedure TEmit_MTBUF.emit_TBUFFER_STORE_FORMAT(count:Byte); 48 | var 49 | src:array[0..3] of PsrRegSlot; 50 | 51 | grp:PsrDataLayout; 52 | 53 | begin 54 | if not get_srsrc(FSPI.MTBUF.SRSRC,4,@src) then Assert(false); 55 | 56 | grp:=GroupingSharp(@src,rtVSharp4); 57 | 58 | TEmit_vbuf_store(TObject(Self)).buf_store( 59 | Buf_info(grp, 60 | dst_sel_identity, 61 | FSPI.MTBUF.DFMT, 62 | FSPI.MTBUF.NFMT, 63 | count) 64 | ); 65 | 66 | end; 67 | 68 | procedure TEmit_MTBUF.emit_MTBUF; 69 | begin 70 | 71 | case FSPI.MTBUF.OP of 72 | TBUFFER_LOAD_FORMAT_X :emit_TBUFFER_LOAD_FORMAT(1); 73 | TBUFFER_LOAD_FORMAT_XY :emit_TBUFFER_LOAD_FORMAT(2); 74 | TBUFFER_LOAD_FORMAT_XYZ :emit_TBUFFER_LOAD_FORMAT(3); 75 | TBUFFER_LOAD_FORMAT_XYZW :emit_TBUFFER_LOAD_FORMAT(4); 76 | 77 | TBUFFER_STORE_FORMAT_X :emit_TBUFFER_STORE_FORMAT(1); 78 | TBUFFER_STORE_FORMAT_XY :emit_TBUFFER_STORE_FORMAT(2); 79 | TBUFFER_STORE_FORMAT_XYZ :emit_TBUFFER_STORE_FORMAT(3); 80 | TBUFFER_STORE_FORMAT_XYZW:emit_TBUFFER_STORE_FORMAT(4); 81 | end; 82 | 83 | //OFFSET:bit12; //Unsigned byte offset. 84 | //OFFEN:bit1; //enable offset in VADDR 85 | //IDXEN:bit1; //enable index in VADDR 86 | //GLC:bit1; //globally coherent. 87 | // 88 | //VADDR:Byte; //VGPR address source. 89 | //VDATA:Byte; //Vector GPR to read/write result to. 90 | //SRSRC:bit5; //Scalar GPR that specifies the resource constant, in units of four SGPRs 91 | //SLC:bit1; //System Level Coherent. 92 | //TFE:bit1; //Texture Fail Enable 93 | //SOFFSET:Byte; 94 | 95 | end; 96 | 97 | end. 98 | 99 | -------------------------------------------------------------------------------- /spirv/emit_smrd.pas: -------------------------------------------------------------------------------- 1 | unit emit_SMRD; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | sysutils, 9 | ps4_pssl, 10 | srType, 11 | srReg, 12 | srLayout, 13 | emit_fetch; 14 | 15 | type 16 | TEmit_SMRD=class(TEmitFetch) 17 | procedure emit_SMRD; 18 | procedure emit_LOAD_DWORDX(grp:PsrDataLayout;count:Byte); 19 | procedure emit_LOAD_DWORDX(count:Byte); 20 | procedure emit_BUFFER_LOAD_DWORDX(count:Byte); 21 | end; 22 | 23 | implementation 24 | 25 | procedure TEmit_SMRD.emit_LOAD_DWORDX(grp:PsrDataLayout;count:Byte); 26 | var 27 | dst:PsrRegSlot; 28 | 29 | ofs_r,idx_r:PsrRegNode; 30 | 31 | lvl_0:TsrChainLvl_0; 32 | lvl_1:TsrChainLvl_1; 33 | 34 | i:Byte; 35 | 36 | begin 37 | 38 | if (FSPI.SMRD.IMM<>0) then 39 | begin 40 | For i:=0 to count-1 do 41 | begin 42 | dst:=get_sdst7(FSPI.SMRD.SDST+i); 43 | Assert(dst<>nil); 44 | 45 | lvl_0.offset:=(FSPI.SMRD.OFFSET+i)*4; 46 | lvl_0.size :=4; 47 | 48 | MakeChain(dst,grp,@lvl_0,nil); 49 | end; 50 | end else 51 | begin 52 | ofs_r:=fetch_ssrc9(FSPI.SMRD.OFFSET,dtUint32); 53 | 54 | idx_r:=OpShrTo(ofs_r,2); 55 | 56 | For i:=0 to count-1 do 57 | begin 58 | dst:=get_sdst7(FSPI.SMRD.SDST+i); 59 | Assert(dst<>nil); 60 | 61 | if (i=0) then 62 | begin 63 | ofs_r:=idx_r; 64 | end else 65 | begin 66 | ofs_r:=OpIAddTo(idx_r,i); 67 | end; 68 | 69 | lvl_0.offset:=0; 70 | lvl_0.size :=4; 71 | 72 | lvl_1.pIndex:=ofs_r; 73 | lvl_1.stride:=4; 74 | 75 | MakeChain(dst,grp,@lvl_0,@lvl_1); 76 | end; 77 | end; 78 | 79 | end; 80 | 81 | procedure TEmit_SMRD.emit_LOAD_DWORDX(count:Byte); 82 | var 83 | src:array[0..3] of PsrRegSlot; 84 | grp:PsrDataLayout; 85 | begin 86 | if not get_sbase(FSPI.SMRD.SBASE,2,@src) then Assert(false); 87 | grp:=GroupingSharp(@src,rtBufPtr2); 88 | emit_LOAD_DWORDX(grp,count); 89 | end; 90 | 91 | procedure TEmit_SMRD.emit_BUFFER_LOAD_DWORDX(count:Byte); 92 | var 93 | src:array[0..3] of PsrRegSlot; 94 | grp:PsrDataLayout; 95 | begin 96 | if not get_sbase(FSPI.SMRD.SBASE,4,@src) then Assert(false); 97 | grp:=GroupingSharp(@src,rtVSharp4); 98 | emit_LOAD_DWORDX(grp,count); 99 | end; 100 | 101 | procedure TEmit_SMRD.emit_SMRD; 102 | begin 103 | 104 | Case FSPI.SMRD.OP of 105 | S_BUFFER_LOAD_DWORD : emit_BUFFER_LOAD_DWORDX(1); 106 | S_BUFFER_LOAD_DWORDX2 : emit_BUFFER_LOAD_DWORDX(2); 107 | S_BUFFER_LOAD_DWORDX4 : emit_BUFFER_LOAD_DWORDX(4); 108 | S_BUFFER_LOAD_DWORDX8 : emit_BUFFER_LOAD_DWORDX(8); 109 | S_BUFFER_LOAD_DWORDX16: emit_BUFFER_LOAD_DWORDX(16); 110 | 111 | S_LOAD_DWORD : emit_LOAD_DWORDX(1); 112 | S_LOAD_DWORDX2 : emit_LOAD_DWORDX(2); 113 | S_LOAD_DWORDX4 : emit_LOAD_DWORDX(4); 114 | S_LOAD_DWORDX8 : emit_LOAD_DWORDX(8); 115 | S_LOAD_DWORDX16: emit_LOAD_DWORDX(16); 116 | 117 | else 118 | Assert(false,'SMRD?'+IntToStr(FSPI.SMRD.OP)); 119 | end; 120 | 121 | end; 122 | 123 | end. 124 | 125 | -------------------------------------------------------------------------------- /spirv/emit_sopc.pas: -------------------------------------------------------------------------------- 1 | unit emit_SOPC; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | sysutils, 9 | spirv, 10 | ps4_pssl, 11 | srType, 12 | srReg, 13 | emit_fetch; 14 | 15 | type 16 | TEmit_SOPC=class(TEmitFetch) 17 | procedure emit_SOPC; 18 | procedure emit_S_CMP_32(OpId:DWORD;rtype:TsrDataType); 19 | end; 20 | 21 | implementation 22 | 23 | procedure TEmit_SOPC.emit_S_CMP_32(OpId:DWORD;rtype:TsrDataType); 24 | Var 25 | dst:PsrRegSlot; 26 | src:array[0..1] of PsrRegNode; 27 | begin 28 | dst:=get_scc; 29 | 30 | src[0]:=fetch_ssrc9(FSPI.SOPC.SSRC0,rtype); 31 | src[1]:=fetch_ssrc9(FSPI.SOPC.SSRC1,rtype); 32 | 33 | OpCmpS(OpId,dst,src[0],src[1]); 34 | end; 35 | 36 | procedure TEmit_SOPC.emit_SOPC; 37 | begin 38 | Case FSPI.SOPC.OP of 39 | S_CMP_EQ_I32 :emit_S_CMP_32(Op.OpIEqual ,dtInt32); 40 | S_CMP_LG_I32 :emit_S_CMP_32(Op.OpINotEqual ,dtInt32); 41 | S_CMP_GT_I32 :emit_S_CMP_32(Op.OpSGreaterThan ,dtInt32); 42 | S_CMP_GE_I32 :emit_S_CMP_32(Op.OpSGreaterThanEqual,dtInt32); 43 | S_CMP_LT_I32 :emit_S_CMP_32(Op.OpSLessThan ,dtInt32); 44 | S_CMP_LE_I32 :emit_S_CMP_32(Op.OpSLessThanEqual ,dtInt32); 45 | 46 | S_CMP_EQ_U32 :emit_S_CMP_32(Op.OpIEqual ,dtUint32); 47 | S_CMP_LG_U32 :emit_S_CMP_32(Op.OpINotEqual ,dtUint32); 48 | S_CMP_GT_U32 :emit_S_CMP_32(Op.OpUGreaterThan ,dtUint32); 49 | S_CMP_GE_U32 :emit_S_CMP_32(Op.OpUGreaterThanEqual,dtUint32); 50 | S_CMP_LT_U32 :emit_S_CMP_32(Op.OpULessThan ,dtUint32); 51 | S_CMP_LE_U32 :emit_S_CMP_32(Op.OpULessThanEqual ,dtUint32); 52 | 53 | //S_BITCMP0_B32:; 54 | //S_BITCMP1_B32:; 55 | //S_BITCMP0_B64:; 56 | //S_BITCMP1_B64:; 57 | //S_SETVSKIP :; 58 | else 59 | Assert(false,'SOPC?'+IntToStr(FSPI.SOPC.OP)); 60 | end; 61 | 62 | end; 63 | 64 | end. 65 | 66 | -------------------------------------------------------------------------------- /spirv/emit_sopk.pas: -------------------------------------------------------------------------------- 1 | unit emit_SOPK; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | sysutils, 9 | spirv, 10 | ps4_pssl, 11 | srType, 12 | srReg, 13 | emit_fetch; 14 | 15 | type 16 | TEmit_SOPK=class(TEmitFetch) 17 | procedure emit_SOPK; 18 | procedure emit_S_MOVK_I32; 19 | procedure emit_S_ADDK_I32; 20 | procedure emit_S_CMPK_I32(OpId:DWORD); 21 | procedure emit_S_CMPK_U32(OpId:DWORD); 22 | end; 23 | 24 | implementation 25 | 26 | function SignExtend16(W:Word):Integer; inline; 27 | const 28 | shift=BitSizeOf(Integer)-BitSizeOf(Word); 29 | begin 30 | Result:=SarLongint((Integer(W) shl shift),shift); 31 | end; 32 | 33 | procedure TEmit_SOPK.emit_S_MOVK_I32; //sdst.s = signExtend(imm16) 34 | Var 35 | dst:PsrRegSlot; 36 | begin 37 | dst:=get_sdst7(FSPI.SOPK.SDST); 38 | SetConst_i(dst,dtInt32,SignExtend16(FSPI.SOPK.SIMM)); 39 | end; 40 | 41 | procedure TEmit_SOPK.emit_S_ADDK_I32; //sdst.s = (sdst.s + signExtend(imm16)); SCC = overflow 42 | Var 43 | dst:PsrRegSlot; 44 | car:PsrRegSlot; 45 | src:PsrRegNode; 46 | imm:PsrRegNode; 47 | begin 48 | dst:=get_sdst7(FSPI.SOPK.SDST); 49 | car:=get_scc; 50 | 51 | src:=fetch_ssrc8(FSPI.SOPK.SDST,dtInt32); 52 | imm:=NewReg_i(dtInt32,SignExtend16(FSPI.SOPK.SIMM)); 53 | 54 | OpIAddExt(dst,car,src,imm); 55 | end; 56 | 57 | procedure TEmit_SOPK.emit_S_CMPK_I32(OpId:DWORD); //SCC = compareOp(sdst.s, signExtend(imm16.s)) 58 | Var 59 | dst:PsrRegSlot; 60 | src:PsrRegNode; 61 | imm:PsrRegNode; 62 | begin 63 | dst:=get_scc; 64 | 65 | src:=fetch_ssrc8(FSPI.SOPK.SDST,dtInt32); 66 | imm:=NewReg_i(dtInt32,SignExtend16(FSPI.SOPK.SIMM)); 67 | 68 | OpCmpS(OpId,dst,src,imm); 69 | end; 70 | 71 | procedure TEmit_SOPK.emit_S_CMPK_U32(OpId:DWORD); //SCC = compareOp(sdst.u, imm16.u) 72 | Var 73 | dst:PsrRegSlot; 74 | src:PsrRegNode; 75 | imm:PsrRegNode; 76 | begin 77 | dst:=get_scc; 78 | 79 | src:=fetch_ssrc8(FSPI.SOPK.SDST,dtUint32); 80 | imm:=NewReg_i(dtUint32,FSPI.SOPK.SIMM); 81 | 82 | OpCmpS(OpId,dst,src,imm); 83 | end; 84 | 85 | procedure TEmit_SOPK.emit_SOPK; 86 | begin 87 | 88 | Case FSPI.SOPK.OP of 89 | 90 | S_CMPK_EQ_I32:emit_S_CMPK_I32(Op.OpIEqual); 91 | S_CMPK_LG_I32:emit_S_CMPK_I32(Op.OpINotEqual); 92 | S_CMPK_GT_I32:emit_S_CMPK_I32(Op.OpSGreaterThan); 93 | S_CMPK_GE_I32:emit_S_CMPK_I32(Op.OpSGreaterThanEqual); 94 | S_CMPK_LT_I32:emit_S_CMPK_I32(Op.OpSLessThan); 95 | S_CMPK_LE_I32:emit_S_CMPK_I32(Op.OpSLessThanEqual); 96 | 97 | S_CMPK_EQ_U32:emit_S_CMPK_U32(Op.OpIEqual); 98 | S_CMPK_LG_U32:emit_S_CMPK_U32(Op.OpINotEqual); 99 | S_CMPK_GT_U32:emit_S_CMPK_U32(Op.OpSGreaterThan); 100 | S_CMPK_GE_U32:emit_S_CMPK_U32(Op.OpSGreaterThanEqual); 101 | S_CMPK_LT_U32:emit_S_CMPK_U32(Op.OpSLessThan); 102 | S_CMPK_LE_U32:emit_S_CMPK_U32(Op.OpSLessThanEqual); 103 | 104 | S_MOVK_I32: emit_S_MOVK_I32; 105 | 106 | S_ADDK_I32: emit_S_ADDK_I32; 107 | 108 | else 109 | Assert(false,'SOPK?'+IntToStr(FSPI.SOPK.OP)); 110 | end; 111 | 112 | end; 113 | 114 | 115 | end. 116 | 117 | 118 | -------------------------------------------------------------------------------- /spirv/emit_vintrp.pas: -------------------------------------------------------------------------------- 1 | unit emit_VINTRP; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | sysutils, 9 | spirv, 10 | ps4_pssl, 11 | srType, 12 | srInput, 13 | srReg, 14 | emit_fetch; 15 | 16 | type 17 | TEmit_VINTRP=class(TEmitFetch) 18 | procedure emit_VINTRP; 19 | end; 20 | 21 | implementation 22 | 23 | procedure TEmit_VINTRP.emit_VINTRP; 24 | var 25 | inp_M0:PsrInput; 26 | 27 | src:PsrRegSlot; 28 | dst:PsrRegSlot; 29 | 30 | inp_SRC:PsrInput; 31 | 32 | rsl,elm:PsrRegNode; 33 | 34 | begin 35 | Assert(FExecutionModel=ExecutionModel.Fragment); //only pixel shader 36 | 37 | dst:=get_vdst8(FSPI.VINTRP.VDST); 38 | 39 | inp_M0:=GetInputRegNode(get_m0^.current); 40 | 41 | //Assert(inp_M0<>nil); 42 | //Assert(inp_M0^.itype=itPsState); 43 | 44 | Case FSPI.VINTRP.OP of 45 | V_INTERP_P1_F32: 46 | begin 47 | src:=get_vsrc8(FSPI.VINTRP.VSRC); 48 | 49 | inp_SRC:=GetInputRegNode(src^.current); 50 | 51 | Assert(inp_SRC<>nil); 52 | 53 | Case inp_SRC^.itype of 54 | itPerspSample, 55 | itPerspCenter, //barycentrics with perspective interpolation 56 | itPerspCentroid, 57 | itLinearSample, 58 | itLinearCenter, 59 | itLinearCentroid:; 60 | else 61 | Assert(false); 62 | end; 63 | 64 | Assert(inp_SRC^.typeid=0); //I 65 | 66 | rsl:=AddFragLayout(inp_SRC^.itype,dtVec4f,FSPI.VINTRP.ATTR); 67 | 68 | elm:=dst^.New(line,dtFloat32); 69 | 70 | OpExtract(line,elm,rsl,FSPI.VINTRP.ATTRCHAN); 71 | end; 72 | 73 | V_INTERP_P2_F32: 74 | begin 75 | src:=get_vsrc8(FSPI.VINTRP.VSRC); 76 | 77 | inp_SRC:=GetInputRegNode(src^.current); 78 | 79 | Assert(inp_SRC<>nil); 80 | 81 | Case inp_SRC^.itype of 82 | itPerspSample, 83 | itPerspCenter, //barycentrics with perspective interpolation 84 | itPerspCentroid, 85 | itLinearSample, 86 | itLinearCenter, 87 | itLinearCentroid:; 88 | else 89 | Assert(false); 90 | end; 91 | 92 | Assert(inp_SRC^.typeid=1); //J 93 | 94 | rsl:=AddFragLayout(inp_SRC^.itype,dtVec4f,FSPI.VINTRP.ATTR); 95 | 96 | elm:=dst^.New(line,dtFloat32); 97 | 98 | OpExtract(line,elm,rsl,FSPI.VINTRP.ATTRCHAN); 99 | end; 100 | 101 | V_INTERP_MOV_F32: 102 | begin 103 | //src ignore 104 | 105 | //just use nointerpolation 106 | inp_SRC:=InputList.Fetch(dtVec4f,itFlat,0); 107 | 108 | rsl:=AddFragLayout(inp_SRC^.itype,dtVec4f,FSPI.VINTRP.ATTR); 109 | 110 | elm:=dst^.New(line,dtFloat32); 111 | 112 | OpExtract(line,elm,rsl,FSPI.VINTRP.ATTRCHAN); 113 | end; 114 | 115 | 116 | else 117 | Assert(False,'VINTRP?'+IntToStr(FSPI.VINTRP.OP)); 118 | end; 119 | 120 | end; 121 | 122 | end. 123 | 124 | -------------------------------------------------------------------------------- /spirv/srAllocator.pas: -------------------------------------------------------------------------------- 1 | unit srAllocator; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ginodes; 9 | 10 | type 11 | PsrAllocNode=^TsrAllocNode; 12 | TsrAllocNode=packed record 13 | pNext:PsrAllocNode; 14 | data:record end; 15 | end; 16 | 17 | _TsrAllocator=specialize TNodeStack; 18 | TsrAllocator=object(_TsrAllocator) 19 | curr_apos:ptruint; //alloc pos in current node 20 | curr_size:ptruint; //useable size of current node 21 | used_size:ptruint; //full usable size 22 | full_size:ptruint; //full alloc size 23 | Function Alloc(Size:ptruint):Pointer; 24 | Procedure Free; 25 | end; 26 | 27 | implementation 28 | 29 | Function TsrAllocator.Alloc(Size:ptruint):Pointer; 30 | const 31 | asize=$FFFF-SizeOf(ptruint)*3; 32 | var 33 | mem_size:ptruint; 34 | 35 | function _alloc:Pointer; 36 | begin 37 | if (Size>asize-SizeOf(Pointer)) then 38 | begin 39 | Result:=AllocMem(Size+SizeOf(Pointer)); 40 | end else 41 | begin 42 | Result:=AllocMem(asize); 43 | end; 44 | end; 45 | 46 | begin 47 | if (pHead=nil) or (Size>curr_size) then 48 | begin 49 | Push_head(_alloc); 50 | mem_size:=MemSize(pHead); 51 | curr_apos:=0; 52 | curr_size:=mem_size-SizeOf(Pointer); 53 | Inc(full_size,mem_size); 54 | end; 55 | 56 | Result:=@PByte(@pHead^.data)[curr_apos]; 57 | 58 | Inc(used_size,Size); 59 | Size:=Align(Size,SizeOf(ptruint)); 60 | Inc(curr_apos,Size); 61 | Dec(curr_size,Size); 62 | end; 63 | 64 | Procedure TsrAllocator.Free; 65 | var 66 | node:PsrAllocNode; 67 | begin 68 | node:=Pop_head; 69 | While (node<>nil) do 70 | begin 71 | FreeMem(node); 72 | node:=Pop_head; 73 | end; 74 | curr_apos:=0; 75 | curr_size:=0; 76 | used_size:=0; 77 | full_size:=0; 78 | end; 79 | 80 | end. 81 | 82 | -------------------------------------------------------------------------------- /spirv/srCFGCursor.pas: -------------------------------------------------------------------------------- 1 | unit srCFGCursor; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | srCFGLabel, 9 | srCFGParser, 10 | ginodes, 11 | srNode; 12 | 13 | type 14 | PsrCursor=^TsrCursor; 15 | TsrCursor=object(TsrLCursor) 16 | pCode:PsrCodeBlock; 17 | pBlock:PsrCFGBlock; 18 | function PopBlock:Boolean; 19 | end; 20 | 21 | TsrCodeList=specialize TNodeQueue; 22 | 23 | PsrCodeHeap=^TsrCodeHeap; 24 | TsrCodeHeap=object(TsrCodeList) 25 | FEmit:TCustomEmit; 26 | Procedure Init(Emit:TCustomEmit); 27 | function FindByPtr(base:Pointer):PsrCodeBlock; 28 | function FetchByPtr(base:Pointer;bType:TsrBlockType):TsrCursor; 29 | end; 30 | 31 | implementation 32 | 33 | // 34 | 35 | Procedure TsrCodeHeap.Init(Emit:TCustomEmit); 36 | begin 37 | FEmit:=Emit; 38 | end; 39 | 40 | function TsrCodeHeap.FindByPtr(base:Pointer):PsrCodeBlock; 41 | var 42 | node:PsrCodeBlock; 43 | begin 44 | Result:=nil; 45 | node:=pHead; 46 | While (node<>nil) do 47 | begin 48 | if node^.IsContain(base) then 49 | begin 50 | Exit(node); 51 | end; 52 | node:=node^.pNext; 53 | end; 54 | end; 55 | 56 | function TsrCodeHeap.FetchByPtr(base:Pointer;bType:TsrBlockType):TsrCursor; 57 | var 58 | node:PsrCodeBlock; 59 | adr:TSrcAdr; 60 | begin 61 | node:=FindByPtr(base); 62 | if (node=nil) then 63 | begin 64 | node:=FEmit.Alloc(SizeOf(TsrCodeBlock)); 65 | node^.FEmit:=FEmit; 66 | if parse_code_cfg(bType,base,node)>1 then Assert(False); 67 | Push_tail(node); 68 | end; 69 | 70 | Result:=Default(TsrCursor); 71 | Result.Init(node^.Body); 72 | Result.pCode :=node; 73 | Result.pBlock:=@node^.FTop; 74 | 75 | adr:=Default(TSrcAdr); 76 | adr.pBody:=node^.Body; 77 | adr.Offdw:=(Pointer(base)-Pointer(adr.pBody)) div 4; 78 | Result.Adr:=adr; 79 | 80 | Result.pBlock:=Result.pBlock^.DownBlock(adr); 81 | end; 82 | 83 | function TsrCursor.PopBlock:Boolean; 84 | begin 85 | Result:=False; 86 | if (pBlock=nil) then Exit; 87 | if (pBlock^.pParent=nil) then Exit; 88 | pBlock:=pBlock^.pParent; 89 | Result:=True; 90 | end; 91 | 92 | end. 93 | 94 | -------------------------------------------------------------------------------- /spirv/srCFGLabel.pas: -------------------------------------------------------------------------------- 1 | unit srCFGLabel; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_pssl, 9 | ginodes; 10 | 11 | type 12 | TSrcAdr=object 13 | pBody:PDWORD; 14 | Offdw:ptrint; 15 | function get_pc:PDWORD; 16 | end; 17 | 18 | TsrLCursor=object(TShaderParser) 19 | private 20 | function get_src_adr:TSrcAdr; 21 | Procedure set_src_adr(src:TSrcAdr); 22 | public 23 | procedure Init(base:Pointer); 24 | property Adr:TSrcAdr read get_src_adr write set_src_adr; 25 | end; 26 | 27 | TsrLabelType=(ltBranch,ltUnknow,ltBegAdr,ltEndAdr,ltBegCond,ltEndCond,ltBegLoop,ltEndLoop); 28 | 29 | TsrSetLabelType=Set of TsrLabelType; 30 | 31 | TsrBlockType=(btMain,btAdr,btAdrBranch,btSetpc,btCond,btLoop,btOther); 32 | 33 | PsrLabel=^TsrLabel; 34 | TsrLabel=object 35 | pLeft,pRight:PsrLabel; 36 | //---- 37 | Adr:TSrcAdr; 38 | lType:TsrSetLabelType; 39 | function c(n1,n2:PsrLabel):Integer; static; 40 | Procedure AddType(t:TsrLabelType); 41 | Procedure RemType(t:TsrLabelType); 42 | function IsType(t:TsrLabelType):Boolean; 43 | end; 44 | 45 | TsrLabels=object 46 | type 47 | TNodeFetch=specialize TNodeFetch; 48 | var 49 | FNTree:TNodeFetch; 50 | end; 51 | 52 | function get_branch_offset(var FSPI:TSPI):ptrint; 53 | 54 | implementation 55 | 56 | function TSrcAdr.get_pc:PDWORD; 57 | begin 58 | Result:=pBody+Offdw; 59 | end; 60 | 61 | procedure TsrLCursor.Init(base:Pointer); 62 | begin 63 | Body :=base; 64 | OFFSET_DW:=0; 65 | end; 66 | 67 | function TsrLCursor.get_src_adr:TSrcAdr; 68 | begin 69 | Result:=Default(TSrcAdr); 70 | Result.pBody:=Body; 71 | Result.Offdw:=OFFSET_DW; 72 | end; 73 | 74 | Procedure TsrLCursor.set_src_adr(src:TSrcAdr); 75 | begin 76 | Body :=src.pBody; 77 | OFFSET_DW:=src.Offdw; 78 | end; 79 | 80 | function TsrLabel.c(n1,n2:PsrLabel):Integer; 81 | var 82 | p1,p2:Pointer; 83 | begin 84 | p1:=n1^.Adr.get_pc; 85 | p2:=n2^.Adr.get_pc; 86 | Result:=Integer(p1>p2)-Integer(p1; 37 | var 38 | FEmit:TCustomEmit; 39 | FNTree:TNodeFetch; 40 | Procedure Init(Emit:TCustomEmit); inline; 41 | function Fetch(place:PsrOpBlock;OpId:DWORD;rtype:TsrDataType;count:Byte;src:PPsrRegNode):PsrCacheOp; 42 | end; 43 | 44 | function _up_to_real(t:PsrOpBlock):PsrOpBlock; 45 | 46 | implementation 47 | 48 | function _up_to_real(t:PsrOpBlock):PsrOpBlock; 49 | begin 50 | repeat 51 | if not t^.IsType(ntOpBlock) then Break; 52 | Case t^.Block.bType of 53 | btMain, 54 | btCond, 55 | btLoop:Break; 56 | else; 57 | end; 58 | t:=t^.Parent; 59 | until false; 60 | Result:=t; 61 | end; 62 | 63 | //-- 64 | 65 | function TsrCacheOp.c(n1,n2:PsrCacheOp):Integer; 66 | var 67 | count:DWORD; 68 | begin 69 | Result:=CompareByte(n1^.key,n2^.key,SizeOf(TsrCacheOp.key)); 70 | if (Result=0) then 71 | begin 72 | count:=n1^.key.count; 73 | if (count<>0) then 74 | begin 75 | Result:=CompareByte(n1^.pData^,n2^.pData^,count*SizeOf(Pointer)); 76 | end; 77 | end; 78 | end; 79 | 80 | Procedure TsrCacheOpList.Init(Emit:TCustomEmit); inline; 81 | begin 82 | FEmit:=Emit; 83 | end; 84 | 85 | function TsrCacheOpList.Fetch(place:PsrOpBlock;OpId:DWORD;rtype:TsrDataType;count:Byte;src:PPsrRegNode):PsrCacheOp; 86 | var 87 | size:ptruint; 88 | node:TsrCacheOp; 89 | begin 90 | Assert(place<>nil); 91 | place:=_up_to_real(place); 92 | Result:=nil; 93 | node:=Default(TsrCacheOp); 94 | node.key.place:=place; 95 | node.key.OpId :=OpId; 96 | node.key.dtype:=rtype; 97 | node.key.count:=count; 98 | node.pData:=src; 99 | Result:=FNTree.Find(@node); 100 | if (Result=nil) then 101 | begin 102 | Result:=FEmit.Alloc(SizeOf(TsrCacheOp)); 103 | Move(node,Result^,SizeOf(TsrCacheOp)); 104 | 105 | size:=count*SizeOf(Pointer); 106 | Result^.pData:=FEmit.Alloc(size); 107 | Move(src^,Result^.pData^,size); 108 | 109 | FNTree.Insert(Result); 110 | end; 111 | end; 112 | 113 | end. 114 | 115 | -------------------------------------------------------------------------------- /spirv/srCapability.pas: -------------------------------------------------------------------------------- 1 | unit srCapability; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ginodes, 9 | srNode; 10 | 11 | type 12 | PsrCapability=^TsrCapability; 13 | TsrCapability=object 14 | pLeft,pRight:PsrCapability; 15 | //---- 16 | ID:DWORD; 17 | function c(n1,n2:PsrCapability):Integer; static; 18 | end; 19 | 20 | PsrCapabilityList=^TsrCapabilityList; 21 | TsrCapabilityList=object 22 | type 23 | TNodeFetch=specialize TNodeFetch; 24 | var 25 | FEmit:TCustomEmit; 26 | FNTree:TNodeFetch; 27 | Procedure Init(Emit:TCustomEmit); 28 | procedure Add(ID:DWORD); 29 | Function First:PsrCapability; 30 | Function Next(node:PsrCapability):PsrCapability; 31 | end; 32 | 33 | implementation 34 | 35 | function TsrCapability.c(n1,n2:PsrCapability):Integer; 36 | begin 37 | Result:=Integer(n1^.ID>n2^.ID)-Integer(n1^.IDnil) then Exit; 53 | pnode:=FEmit.Alloc(SizeOf(TsrCapability)); 54 | Move(fnode,pnode^,SizeOf(TsrCapability)); 55 | FNTree.Insert(pnode); 56 | end; 57 | 58 | Function TsrCapabilityList.First:PsrCapability; 59 | begin 60 | Result:=FNTree.Min; 61 | end; 62 | 63 | Function TsrCapabilityList.Next(node:PsrCapability):PsrCapability; 64 | begin 65 | Result:=FNTree.Next(node); 66 | end; 67 | 68 | end. 69 | 70 | -------------------------------------------------------------------------------- /spirv/srConfig.pas: -------------------------------------------------------------------------------- 1 | unit srConfig; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | type 8 | PsrConfig=^TsrConfig; 9 | TsrConfig=packed object 10 | PrintAsm:Boolean; 11 | UseVertexInput:Boolean; //True 12 | UseTexelBuffer:Boolean; 13 | UseOutput16:Boolean; 14 | // 15 | DescriptorSet:DWORD; //0 16 | // 17 | SpvVersion:PtrUint; // $10100 18 | maxUniformBufferRange:PtrUint; // $FFFF 19 | PushConstantsOffset:PtrUint; // 0 20 | maxPushConstantsSize:PtrUint; // 128 21 | minStorageBufferOffsetAlignment:PtrUint; // $10 22 | minUniformBufferOffsetAlignment:PtrUint; // $100 23 | // 24 | Procedure Init; 25 | Function CanUseStorageBufferClass:Boolean; 26 | end; 27 | 28 | implementation 29 | 30 | Procedure TsrConfig.Init; 31 | begin 32 | UseVertexInput:=True; 33 | // 34 | SpvVersion:=$10100; 35 | maxUniformBufferRange:=$FFFF; 36 | maxPushConstantsSize:=128; 37 | minStorageBufferOffsetAlignment:=0; 38 | minUniformBufferOffsetAlignment:=0; 39 | end; 40 | 41 | Function TsrConfig.CanUseStorageBufferClass:Boolean; 42 | begin 43 | Result:=(SpvVersion>=$10300); 44 | end; 45 | 46 | end. 47 | 48 | -------------------------------------------------------------------------------- /spirv/srRefId.pas: -------------------------------------------------------------------------------- 1 | unit srRefId; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | sysutils, 9 | srNode; 10 | 11 | type 12 | ntRefId=class(TsrNodeVmt) 13 | class function GetPrintName(node:PsrNode):RawByteString; override; 14 | class function GetRef(node:PsrNode):Pointer; override; 15 | end; 16 | 17 | PsrRefId=^TsrRefId; 18 | TsrRefId=object 19 | ID:DWORD; 20 | function Alloc:Boolean; inline; 21 | end; 22 | 23 | PsrRefNode=^TsrRefNode; 24 | TsrRefNode=object(TsrNode) 25 | ID:TsrRefId; 26 | Procedure Init; inline; 27 | function GetPrintName:RawByteString; 28 | end; 29 | 30 | PsrRefIdAlloc=^TsrRefIdAlloc; 31 | TsrRefIdAlloc=object 32 | FSpirvID:DWORD; 33 | function FetchSpirvID:DWORD; inline; 34 | procedure FetchSpirvID(P:PsrRefId); 35 | function GetSpirvIDBound:DWORD; inline; 36 | end; 37 | 38 | implementation 39 | 40 | class function ntRefId.GetPrintName(node:PsrNode):RawByteString; 41 | begin 42 | Result:=PsrRefNode(node)^.GetPrintName; 43 | end; 44 | 45 | class function ntRefId.GetRef(node:PsrNode):Pointer; 46 | begin 47 | Result:=@PsrRefNode(node)^.ID; 48 | end; 49 | 50 | Procedure TsrRefNode.Init; inline; 51 | begin 52 | fntype:=ntRefId; 53 | end; 54 | 55 | function TsrRefNode.GetPrintName:RawByteString; 56 | begin 57 | Assert(ID.ID<>0); 58 | Result:=IntToStr(ID.ID); 59 | end; 60 | 61 | function TsrRefId.Alloc:Boolean; inline; 62 | begin 63 | Result:=(ID<>0); 64 | end; 65 | 66 | function TsrRefIdAlloc.FetchSpirvID:DWORD; inline; 67 | begin 68 | Inc(FSpirvID); 69 | Result:=FSpirvID; 70 | end; 71 | 72 | procedure TsrRefIdAlloc.FetchSpirvID(P:PsrRefId); 73 | begin 74 | if (P<>nil) and (not P^.Alloc) then 75 | begin 76 | P^.ID:=FetchSpirvID; 77 | end; 78 | end; 79 | 80 | function TsrRefIdAlloc.GetSpirvIDBound:DWORD; inline; 81 | begin 82 | Result:=FSpirvID+1; 83 | end; 84 | 85 | end. 86 | 87 | -------------------------------------------------------------------------------- /src/ajm/ajm_error.inc: -------------------------------------------------------------------------------- 1 | 2 | const 3 | SCE_AJM_ERROR_UNKNOWN =-2137849855; // 0x80930001 4 | SCE_AJM_ERROR_INVALID_CONTEXT =-2137849854; // 0x80930002 5 | SCE_AJM_ERROR_INVALID_INSTANCE =-2137849853; // 0x80930003 6 | SCE_AJM_ERROR_INVALID_BATCH =-2137849852; // 0x80930004 7 | SCE_AJM_ERROR_INVALID_PARAMETER =-2137849851; // 0x80930005 8 | SCE_AJM_ERROR_OUT_OF_MEMORY =-2137849850; // 0x80930006 9 | SCE_AJM_ERROR_OUT_OF_RESOURCES =-2137849849; // 0x80930007 10 | SCE_AJM_ERROR_CODEC_NOT_SUPPORTED =-2137849848; // 0x80930008 11 | SCE_AJM_ERROR_CODEC_ALREADY_REGISTERED =-2137849847; // 0x80930009 12 | SCE_AJM_ERROR_CODEC_NOT_REGISTERED =-2137849846; // 0x8093000A 13 | SCE_AJM_ERROR_WRONG_REVISION_FLAG =-2137849845; // 0x8093000B 14 | SCE_AJM_ERROR_FLAG_NOT_SUPPORTED =-2137849844; // 0x8093000C 15 | SCE_AJM_ERROR_BUSY =-2137849843; // 0x8093000D 16 | SCE_AJM_ERROR_BAD_PRIORITY =-2137849842; // 0x8093000E 17 | SCE_AJM_ERROR_IN_PROGRESS =-2137849841; // 0x8093000F 18 | SCE_AJM_ERROR_RETRY =-2137849840; // 0x80930010 19 | SCE_AJM_ERROR_MALFORMED_BATCH =-2137849839; // 0x80930011 20 | SCE_AJM_ERROR_JOB_CREATION =-2137849838; // 0x80930012 21 | SCE_AJM_ERROR_INVALID_OPCODE =-2137849837; // 0x80930013 22 | SCE_AJM_ERROR_PRIORITY_VIOLATION =-2137849836; // 0x80930014 23 | SCE_AJM_ERROR_BUFFER_TOO_BIG =-2137849835; // 0x80930015 24 | SCE_AJM_ERROR_INVALID_ADDRESS =-2137849834; // 0x80930016 25 | SCE_AJM_ERROR_CANCELLED =-2137849833; // 0x80930017 26 | 27 | 28 | SCE_AJM_RESULT_NOT_INITIALIZED =$00000001; 29 | SCE_AJM_RESULT_INVALID_DATA =$00000002; 30 | SCE_AJM_RESULT_INVALID_PARAMETER =$00000004; 31 | SCE_AJM_RESULT_PARTIAL_INPUT =$00000008; 32 | SCE_AJM_RESULT_NOT_ENOUGH_ROOM =$00000010; 33 | SCE_AJM_RESULT_STREAM_CHANGE =$00000020; 34 | SCE_AJM_RESULT_TOO_MANY_CHANNELS =$00000040; 35 | SCE_AJM_RESULT_UNSUPPORTED_FLAG =$00000080; 36 | SCE_AJM_RESULT_SIDEBAND_TRUNCATED =$00000100; 37 | SCE_AJM_RESULT_PRIORITY_PASSED =$00000200; 38 | SCE_AJM_RESULT_FATAL =$80000000; 39 | SCE_AJM_RESULT_CODEC_ERROR =$40000000; 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/audiodec/ps4_libsceaudiodeccpu.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceAudiodecCpu; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program; 9 | 10 | implementation 11 | 12 | type 13 | PSceAudiodecCpuCtrl=Pointer; 14 | PSceAudiodecCpuResource=Pointer; 15 | 16 | function ps4_sceAudiodecCpuQueryMemSize(pCtrl :PSceAudiodecCpuCtrl; 17 | pRes :PSceAudiodecCpuResource; 18 | uiCodecType:DWord):Integer; SysV_ABI_CDecl; 19 | begin 20 | Writeln('sceAudiodecCpuQueryMemSize,uiCodecType=',uiCodecType); 21 | Result:=0; 22 | end; 23 | 24 | function ps4_sceAudiodecCpuInitDecoder(pCtrl :PSceAudiodecCpuCtrl; 25 | pRes :PSceAudiodecCpuResource; 26 | uiCodecType:DWord):Integer; SysV_ABI_CDecl; 27 | begin 28 | Writeln('sceAudiodecCpuInitDecoder,uiCodecType=',uiCodecType); 29 | Result:=0; 30 | end; 31 | 32 | function ps4_sceAudiodecCpuDecode(pCtrl :PSceAudiodecCpuCtrl; 33 | pRes :PSceAudiodecCpuResource; 34 | uiCodecType:DWord):Integer; SysV_ABI_CDecl; 35 | begin 36 | // Writeln('sceAudiodecCpuDecode,uiCodecType=',uiCodecType); 37 | Result:=0; 38 | end; 39 | 40 | function Load_libSceAudiodecCpu(Const name:RawByteString):TElf_node; 41 | var 42 | lib:PLIBRARY; 43 | begin 44 | Result:=TElf_node.Create; 45 | Result.pFileName:=name; 46 | 47 | lib:=Result._add_lib('libSceAudiodecCpu'); 48 | 49 | lib^.set_proc($92D0F6C370F81B65,@ps4_sceAudiodecCpuQueryMemSize); 50 | lib^.set_proc($85D16CC68DCC16EF,@ps4_sceAudiodecCpuInitDecoder); 51 | lib^.set_proc($952553896579C0B7,@ps4_sceAudiodecCpuDecode); 52 | end; 53 | 54 | initialization 55 | ps4_app.RegistredPreLoad('libSceAudiodecCpu.prx',@Load_libSceAudiodecCpu); 56 | 57 | end. 58 | 59 | -------------------------------------------------------------------------------- /src/inputs/formbindbutton.lfm: -------------------------------------------------------------------------------- 1 | object FormBindButtons: TFormBindButtons 2 | Left = 701 3 | Height = 401 4 | Top = 433 5 | Width = 929 6 | Caption = 'Button Binding' 7 | ClientHeight = 401 8 | ClientWidth = 929 9 | DesignTimePPI = 192 10 | OnShow = FormShow 11 | LCLVersion = '2.3.0.0' 12 | object BitBtn1: TBitBtn 13 | Left = 388 14 | Height = 60 15 | Top = 272 16 | Width = 150 17 | Caption = 'Cancel' 18 | OnClick = BitBtn1Click 19 | TabOrder = 0 20 | end 21 | object BitBtn2: TBitBtn 22 | Left = 328 23 | Height = 60 24 | Top = 176 25 | Width = 272 26 | Caption = 'Unbind this button' 27 | OnClick = BitBtn2Click 28 | TabOrder = 1 29 | end 30 | object Label1: TLabel 31 | Left = 208 32 | Height = 32 33 | Top = 72 34 | Width = 526 35 | Caption = 'Press a button or move a joystick / analog trigger' 36 | end 37 | object CheckInput: TTimer 38 | Interval = 100 39 | OnTimer = CheckInputTimer 40 | Left = 736 41 | Top = 216 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /src/inputs/formbindbutton.pas: -------------------------------------------------------------------------------- 1 | unit formBindButton; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Buttons, StdCtrls, 9 | ExtCtrls, uMappableInputs, Windows; 10 | 11 | type 12 | 13 | { TFormBindButtons } 14 | 15 | TFormBindButtons = class(TForm) 16 | BitBtn1: TBitBtn; 17 | BitBtn2: TBitBtn; 18 | CheckInput: TTimer; 19 | Label1: TLabel; 20 | procedure BitBtn1Click(Sender: TObject); 21 | procedure BitBtn2Click(Sender: TObject); 22 | procedure CheckInputTimer(Sender: TObject); 23 | procedure FormShow(Sender: TObject); 24 | private 25 | 26 | public 27 | XInputKey: EnumXInputButtons; 28 | ResetToDefault: boolean; 29 | end; 30 | 31 | var 32 | FormBindButtons: TFormBindButtons; 33 | 34 | implementation 35 | 36 | uses XInput; 37 | 38 | {$R *.lfm} 39 | 40 | { TFormBindButtons } 41 | 42 | procedure TFormBindButtons.CheckInputTimer(Sender: TObject); 43 | var 44 | i: integer; 45 | state: TXInputState; 46 | key: EnumXInputButtons; 47 | begin 48 | ZeroMemory(@state, SizeOf(TXInputState)); 49 | if XInputGetState(0, state) = ERROR_SUCCESS then 50 | begin 51 | key := MappableInputs.XInputStateToKey(state); 52 | if key <> EnumXInputButtons.xiUnbound then 53 | begin 54 | XInputKey := key; 55 | ModalResult := mrOk; 56 | end; 57 | end; 58 | end; 59 | 60 | procedure TFormBindButtons.BitBtn2Click(Sender: TObject); 61 | begin 62 | XInputKey := xiUnbound; 63 | ModalResult := mrOk; 64 | end; 65 | 66 | procedure TFormBindButtons.BitBtn1Click(Sender: TObject); 67 | begin 68 | ModalResult := mrCancel; 69 | end; 70 | 71 | procedure TFormBindButtons.FormShow(Sender: TObject); 72 | begin 73 | XInputKey := xiUnbound; 74 | end; 75 | 76 | end. 77 | -------------------------------------------------------------------------------- /src/inputs/sce_pad_interface.pas: -------------------------------------------------------------------------------- 1 | unit sce_pad_interface; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | sce_pad_types, 9 | ps4_handles, 10 | spinlock; 11 | 12 | type 13 | TScePadHandle=class(TClassHandle) 14 | var 15 | userID:Integer; 16 | _type :Integer; 17 | index :Integer; 18 | handle:Integer; 19 | function ReadState(data:PScePadData):Integer; virtual; 20 | function SetLightBar(data:pScePadLightBarParam):Integer; virtual; 21 | function ResetLightBar():Integer; virtual; 22 | destructor Destroy; override; 23 | end; 24 | 25 | TScePadInterface=class 26 | class function Load:Boolean; virtual; 27 | class procedure Unload; virtual; 28 | class function Init:Integer; virtual; 29 | class function Done:Integer; virtual; 30 | class function Open(var handle:TScePadHandle):Integer; virtual; 31 | end; 32 | 33 | TAbstractScePadInterface=class of TScePadInterface; 34 | 35 | var 36 | pad_handles:TIntegerHandles; 37 | pad_opened :array[0..15] of TScePadHandle; 38 | pad_lock :Pointer; 39 | 40 | function FindPadByParam(userID,_type,index:Integer):TScePadHandle; 41 | Procedure SavePadHandle(handle:TScePadHandle); 42 | Procedure ClearPadHandle(handle:TScePadHandle); 43 | 44 | implementation 45 | 46 | function FindPadByParam(userID,_type,index:Integer):TScePadHandle; 47 | var 48 | i:Integer; 49 | begin 50 | Result:=nil; 51 | spin_lock(pad_lock); 52 | For i:=Low(pad_opened) to High(pad_opened) do 53 | if (pad_opened[i]<>nil) then 54 | if (pad_opened[i].userID=userID) and 55 | (pad_opened[i]._type =_type ) and 56 | (pad_opened[i].index =index ) then 57 | begin 58 | Result:=pad_opened[i]; 59 | Result.Acqure; 60 | Break; 61 | end; 62 | spin_unlock(pad_lock); 63 | end; 64 | 65 | Procedure SavePadHandle(handle:TScePadHandle); 66 | var 67 | i:Integer; 68 | begin 69 | spin_lock(pad_lock); 70 | For i:=Low(pad_opened) to High(pad_opened) do 71 | if (pad_opened[i]=nil) then 72 | begin 73 | pad_opened[i]:=handle; 74 | Break; 75 | end; 76 | spin_unlock(pad_lock); 77 | end; 78 | 79 | Procedure ClearPadHandle(handle:TScePadHandle); 80 | var 81 | i:Integer; 82 | begin 83 | spin_lock(pad_lock); 84 | For i:=Low(pad_opened) to High(pad_opened) do 85 | if (pad_opened[i]=handle) then 86 | begin 87 | pad_opened[i]:=nil; 88 | Break; 89 | end; 90 | spin_unlock(pad_lock); 91 | end; 92 | 93 | function TScePadHandle.ReadState(data:PScePadData):Integer; 94 | begin 95 | Result:=SCE_PAD_ERROR_INVALID_HANDLE; 96 | end; 97 | 98 | function TScePadHandle.SetLightBar(data:pScePadLightBarParam):Integer; 99 | begin 100 | Result:=0; 101 | end; 102 | 103 | function TScePadHandle.ResetLightBar():Integer; 104 | begin 105 | Result:=0; 106 | end; 107 | 108 | destructor TScePadHandle.Destroy; 109 | begin 110 | ClearPadHandle(Self); 111 | // 112 | inherited; 113 | end; 114 | 115 | class function TScePadInterface.Load:Boolean; 116 | begin 117 | Result:=True; 118 | end; 119 | 120 | class procedure TScePadInterface.Unload; 121 | begin 122 | // 123 | end; 124 | 125 | 126 | class function TScePadInterface.Init:Integer; 127 | begin 128 | Result:=0; 129 | end; 130 | 131 | class function TScePadInterface.Done:Integer; 132 | begin 133 | Result:=0; 134 | end; 135 | 136 | class function TScePadInterface.Open(var handle:TScePadHandle):Integer; 137 | begin 138 | handle:=nil; 139 | Result:=SCE_PAD_ERROR_NOT_INITIALIZED; 140 | end; 141 | 142 | initialization 143 | pad_handles:=TIntegerHandles.Create(1); 144 | pad_handles.max_key:=16; 145 | 146 | end. 147 | 148 | 149 | -------------------------------------------------------------------------------- /src/libcinternal/ps4_guard_internal.pas: -------------------------------------------------------------------------------- 1 | unit ps4_guard_internal; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | type 8 | p_guard_t=^guard_t; 9 | guard_t=packed record 10 | init_half:DWORD; 11 | lock_half:DWORD; 12 | end; 13 | guard_lock_t=DWORD; 14 | 15 | function ps4___cxa_guard_acquire(guard_object:p_guard_t):Integer; SysV_ABI_CDecl; 16 | procedure ps4___cxa_guard_abort(guard_object:p_guard_t); SysV_ABI_CDecl; 17 | procedure ps4___cxa_guard_release(guard_object:p_guard_t); SysV_ABI_CDecl; 18 | 19 | implementation 20 | 21 | const 22 | LOCKED =1; 23 | INITIALISED=1; 24 | INITIAL =0; 25 | 26 | function INIT_PART(guard:p_guard_t):PDWORD; inline; 27 | begin 28 | Result:=@guard^.init_half; 29 | end; 30 | 31 | function LOCK_PART(guard:p_guard_t):PDWORD; inline; 32 | begin 33 | Result:=@guard^.lock_half; 34 | end; 35 | 36 | { 37 | * Acquires a lock on a guard, returning 0 if the object has already been 38 | * initialised, and 1 if it has not. If the object is already constructed then 39 | * this function just needs to read a byte from memory and return. 40 | } 41 | function ps4___cxa_guard_acquire(guard_object:p_guard_t):Integer; SysV_ABI_CDecl; 42 | var 43 | old:guard_lock_t; 44 | begin 45 | // Not an atomic read, doesn't establish a happens-before relationship, but 46 | // if one is already established and we end up seeing an initialised state 47 | // then it's a fast path, otherwise we'll do something more expensive than 48 | // this test anyway... 49 | if (INITIALISED = INIT_PART(guard_object)^) then 50 | Exit(0); 51 | // Spin trying to do the initialisation 52 | repeat 53 | // Loop trying to move the value of the guard from 0 (not 54 | // locked, not initialised) to the locked-uninitialised 55 | // position. 56 | 57 | old:=InterlockedCompareExchange(LOCK_PART(guard_object)^,LOCKED,INITIAL); 58 | if (old = INITIAL) then 59 | begin 60 | if (INITIALISED <> INIT_PART(guard_object)^) then 61 | Exit(1); 62 | 63 | // No need for a memory barrier here, 64 | // see first comment. 65 | LOCK_PART(guard_object)^ := INITIAL; 66 | Exit(0); 67 | end; 68 | 69 | assert(old = LOCKED); 70 | // Another thread holds the lock. 71 | ThreadSwitch; 72 | until false; 73 | end; 74 | 75 | { 76 | * Releases the lock without marking the object as initialised. This function 77 | * is called if initialising a static causes an exception to be thrown. 78 | } 79 | procedure ps4___cxa_guard_abort(guard_object:p_guard_t); SysV_ABI_CDecl; 80 | var 81 | reset:Boolean; 82 | begin 83 | reset:=InterlockedCompareExchange(LOCK_PART(guard_object)^,INITIAL,LOCKED)=LOCKED; 84 | assert(reset); 85 | end; 86 | 87 | { 88 | * Releases the guard and marks the object as initialised. This function is 89 | * called after successful initialisation of a static. 90 | } 91 | procedure ps4___cxa_guard_release(guard_object:p_guard_t); SysV_ABI_CDecl; 92 | var 93 | reset:Boolean; 94 | begin 95 | reset:=InterlockedCompareExchange(INIT_PART(guard_object)^,INITIALISED,INITIAL)=INITIAL; 96 | assert(reset); 97 | LOCK_PART(guard_object)^ := INITIAL; 98 | end; 99 | 100 | end. 101 | 102 | -------------------------------------------------------------------------------- /src/np/ps4_libscenpauth.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceNpAuth; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program, 9 | np_error, 10 | ps4_libSceNpCommon, 11 | sys_kernel; 12 | 13 | const 14 | SCE_NP_CLIENT_ID_MAX_LEN=128; 15 | SCE_NP_CLIENT_SECRET_MAX_LEN=256; 16 | SCE_NP_AUTHORIZATION_CODE_MAX_LEN=128; 17 | SCE_NP_ID_TOKEN_MAX_LEN=4096; 18 | 19 | type 20 | pSceNpClientId=^SceNpClientId; 21 | SceNpClientId=packed record 22 | id:array[0..SCE_NP_CLIENT_ID_MAX_LEN] of char; 23 | padding:array[0..6] of Byte; 24 | end; 25 | 26 | pSceNpClientSecret=^SceNpClientSecret; 27 | SceNpClientSecret=packed record 28 | secret:array[0..SCE_NP_CLIENT_SECRET_MAX_LEN] of char; 29 | padding:array[0..6] of Byte; 30 | end; 31 | 32 | pSceNpAuthCreateAsyncRequestParameter=^SceNpAuthCreateAsyncRequestParameter; 33 | SceNpAuthCreateAsyncRequestParameter=packed record 34 | size:QWORD; 35 | cpuAffinityMask:QWORD; 36 | threadPriority:Integer; 37 | padding:array[0..3] of Byte; 38 | end; 39 | 40 | pSceNpAuthGetAuthorizationCodeParameter=^SceNpAuthGetAuthorizationCodeParameter; 41 | SceNpAuthGetAuthorizationCodeParameter=packed record 42 | size:QWORD; 43 | pOnlineId:pSceNpOnlineId; 44 | pClientId:pSceNpClientId; 45 | scope:PChar; 46 | end; 47 | 48 | pSceNpAuthorizationCode=^SceNpAuthorizationCode; 49 | SceNpAuthorizationCode=packed record 50 | code:array[0..SCE_NP_AUTHORIZATION_CODE_MAX_LEN] of char; 51 | padding:array[0..6] of Byte; 52 | end; 53 | 54 | pSceNpAuthGetIdTokenParameterA=^SceNpAuthGetIdTokenParameterA; 55 | SceNpAuthGetIdTokenParameterA=packed record 56 | size:QWORD; 57 | userId:Integer; 58 | padding:array[0..3] of Byte; 59 | clientId:pSceNpClientId; 60 | clientSecret:pSceNpClientSecret; 61 | scope:PChar; 62 | end; 63 | 64 | pSceNpIdToken=^SceNpIdToken; 65 | SceNpIdToken=packed record 66 | token:array[0..SCE_NP_ID_TOKEN_MAX_LEN] of char; 67 | padding:array[0..6] of Byte; 68 | end; 69 | 70 | implementation 71 | 72 | function ps4_sceNpAuthCreateRequest():Integer; SysV_ABI_CDecl; 73 | begin 74 | Writeln(SysLogPrefix,'sceNpAuthCreateRequest'); 75 | Result:=-1; 76 | end; 77 | 78 | function ps4_sceNpAuthCreateAsyncRequest(const pParam:pSceNpAuthCreateAsyncRequestParameter):Integer; SysV_ABI_CDecl; 79 | begin 80 | Result:=0; 81 | end; 82 | 83 | function ps4_sceNpAuthGetAuthorizationCode(reqId:Integer; 84 | const param:pSceNpAuthGetAuthorizationCodeParameter; 85 | authCode:pSceNpAuthorizationCode; 86 | issuerId:PInteger):Integer; SysV_ABI_CDecl; 87 | begin 88 | Result:=0; 89 | end; 90 | 91 | function ps4_sceNpAuthPollAsync(reqId:Integer;pResult:PInteger):Integer; SysV_ABI_CDecl; 92 | begin 93 | Result:=0; 94 | end; 95 | 96 | function ps4_sceNpAuthDeleteRequest(reqId:Integer):Integer; SysV_ABI_CDecl; 97 | begin 98 | Result:=0; 99 | end; 100 | 101 | function ps4_sceNpAuthGetIdTokenA(reqId:Integer; 102 | const param:pSceNpAuthGetIdTokenParameterA; 103 | idToken:pSceNpIdToken):Integer; SysV_ABI_CDecl; 104 | begin 105 | Writeln(SysLogPrefix,'sceNpAuthGetIdTokenA'); 106 | FillChar(idToken^, SizeOf(SceNpIdToken), 0); 107 | Result:=0; 108 | end; 109 | 110 | function Load_libSceNpAuth(Const name:RawByteString):TElf_node; 111 | var 112 | lib:PLIBRARY; 113 | begin 114 | Result:=TElf_node.Create; 115 | Result.pFileName:=name; 116 | 117 | lib:=Result._add_lib('libSceNpAuth'); 118 | lib^.set_proc($E9BC05928B184508,@ps4_sceNpAuthCreateRequest); 119 | lib^.set_proc($37E9ABEC68D3BEBF,@ps4_sceNpAuthCreateAsyncRequest); 120 | lib^.set_proc($2B11A43AB4094EA6,@ps4_sceNpAuthGetAuthorizationCode); 121 | lib^.set_proc($8234B27F34AC0DC1,@ps4_sceNpAuthPollAsync); 122 | lib^.set_proc($1FCC06F4193F9CF7,@ps4_sceNpAuthDeleteRequest); 123 | lib^.set_proc($0A871B1D520A3C4F,@ps4_sceNpAuthGetIdTokenA); 124 | end; 125 | 126 | initialization 127 | ps4_app.RegistredPreLoad('libSceNpAuth.prx' ,@Load_libSceNpAuth); 128 | 129 | end. 130 | 131 | -------------------------------------------------------------------------------- /src/np/ps4_libscenpgameintent.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceNpGameIntent; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program; 9 | 10 | implementation 11 | 12 | const 13 | SCE_NP_GAME_INTENT_TYPE_MAX_SIZE=(32+1); 14 | SCE_NP_GAME_INTENT_DATA_MAX_SIZE=(16*1024+1); 15 | 16 | type 17 | pSceNpGameIntentInitParam=^SceNpGameIntentInitParam; 18 | SceNpGameIntentInitParam=packed record 19 | size:QWORD; 20 | reserved:array[0..31] of Byte; 21 | end; 22 | 23 | pSceNpGameIntentData=^SceNpGameIntentData; 24 | SceNpGameIntentData=packed record 25 | data:array[0..SCE_NP_GAME_INTENT_DATA_MAX_SIZE-1] of Byte; 26 | padding:array[0..6] of Byte; 27 | end; 28 | 29 | pSceNpGameIntentInfo=^SceNpGameIntentInfo; 30 | SceNpGameIntentInfo=packed record 31 | size:QWORD; 32 | userId:Integer; 33 | intentType:array[0..SCE_NP_GAME_INTENT_TYPE_MAX_SIZE-1] of AnsiChar; 34 | padding:array[0..6] of Byte; 35 | reserved:array[0..255] of Byte; 36 | intentData:SceNpGameIntentData; 37 | end; 38 | 39 | function ps4_sceNpGameIntentInitialize(initParam:pSceNpGameIntentInitParam):Integer; SysV_ABI_CDecl; 40 | begin 41 | Result:=6; 42 | end; 43 | 44 | function ps4_sceNpGameIntentReceiveIntent(intentInfo:pSceNpGameIntentInfo):Integer; SysV_ABI_CDecl; 45 | begin 46 | Result:=0; 47 | end; 48 | 49 | function ps4_sceNpGameIntentGetPropertyValueString(intentData:pSceNpGameIntentData; 50 | key:Pchar; 51 | valueBuf:Pchar; 52 | bufSize:QWORD):Integer; SysV_ABI_CDecl; 53 | begin 54 | if (valueBuf<>nil) then 55 | begin 56 | FillChar(valueBuf^,bufSize,0); 57 | end; 58 | Result:=0; 59 | end; 60 | 61 | 62 | function Load_libSceNpGameIntent(Const name:RawByteString):TElf_node; 63 | var 64 | lib:PLIBRARY; 65 | begin 66 | Result:=TElf_node.Create; 67 | Result.pFileName:=name; 68 | lib:=Result._add_lib('libSceNpGameIntent'); 69 | lib^.set_proc($9BCEC11F1B7F1FAD,@ps4_sceNpGameIntentInitialize); 70 | lib^.set_proc($8C4217500AFD5C4F,@ps4_sceNpGameIntentReceiveIntent); 71 | lib^.set_proc($ACF97420D35CFCCF,@ps4_sceNpGameIntentGetPropertyValueString); 72 | end; 73 | 74 | initialization 75 | ps4_app.RegistredPreLoad('libSceNpGameIntent.prx',@Load_libSceNpGameIntent); 76 | 77 | end. 78 | 79 | -------------------------------------------------------------------------------- /src/np/ps4_libscenpsessionsignaling.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceNpSessionSignaling; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program, 9 | Classes, 10 | SysUtils; 11 | 12 | implementation 13 | 14 | function ps4_sceNpSessionSignalingInitialize():Integer; SysV_ABI_CDecl; 15 | begin 16 | Result:=0; 17 | end; 18 | 19 | function Load_libSceNpSessionSignaling(Const name:RawByteString):TElf_node; 20 | var 21 | lib:PLIBRARY; 22 | begin 23 | Result:=TElf_node.Create; 24 | Result.pFileName:=name; 25 | lib:=Result._add_lib('libSceNpSessionSignaling'); 26 | lib^.set_proc($CAC9B0E89FCFF009,@ps4_sceNpSessionSignalingInitialize); 27 | end; 28 | 29 | initialization 30 | ps4_app.RegistredPreLoad('libSceNpSessionSignaling.prx',@Load_libSceNpSessionSignaling); 31 | 32 | end. 33 | 34 | -------------------------------------------------------------------------------- /src/np/ps4_libscenpsignaling.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceNpSignaling; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program, 9 | ps4_libSceNet, 10 | ps4_libSceNpCommon; 11 | 12 | const 13 | SCE_NP_SIGNALING_CONTEXT_MAX=8; 14 | 15 | type 16 | SceNpSignalingHandler=procedure( 17 | ctxId :DWORD; 18 | subjectId:DWORD; 19 | event :Integer; 20 | errorCode:Integer; 21 | arg :Pointer 22 | ); SysV_ABI_CDecl; 23 | 24 | pSceNpSignalingNetInfo=^SceNpSignalingNetInfo; 25 | SceNpSignalingNetInfo=packed record 26 | size :QWORD; 27 | local_addr :SceNetInAddr; 28 | mapped_addr:SceNetInAddr; 29 | nat_status :Integer; 30 | end; 31 | 32 | implementation 33 | 34 | function ps4_sceNpSignalingInitialize(poolSize:QWORD; 35 | threadPriority:Integer; 36 | cpuAffinityMask:Integer; 37 | threadStackSize:QWORD):Integer; SysV_ABI_CDecl; 38 | begin 39 | Result:=0; 40 | end; 41 | 42 | function ps4_sceNpSignalingCreateContext(npId:pSceNpId; 43 | handler:SceNpSignalingHandler; 44 | arg:Pointer; 45 | ctxId:PDWORD):Integer; SysV_ABI_CDecl; 46 | begin 47 | Result:=0; 48 | end; 49 | 50 | function ps4_sceNpSignalingCreateContextA(npId:pSceNpId; 51 | handler:SceNpSignalingHandler; 52 | arg:Pointer; 53 | ctxId:PDWORD):Integer; SysV_ABI_CDecl; 54 | begin 55 | Result:=0; 56 | end; 57 | 58 | function ps4_sceNpSignalingGetLocalNetInfo(ctxId:DWORD; 59 | info:pSceNpSignalingNetInfo):Integer; SysV_ABI_CDecl; 60 | begin 61 | Result:=0; 62 | end; 63 | 64 | function ps4_sceNpSignalingSetContextOption(ctxId:DWORD; 65 | optname:Integer; 66 | optval:Integer):Integer; SysV_ABI_CDecl; 67 | begin 68 | Result:=0; 69 | end; 70 | 71 | function Load_libSceNpSignaling(Const name:RawByteString):TElf_node; 72 | var 73 | lib:PLIBRARY; 74 | begin 75 | Result:=TElf_node.Create; 76 | Result.pFileName:=name; 77 | 78 | lib:=Result._add_lib('libSceNpSignaling'); 79 | lib^.set_proc($DCA3AE0B84666595,@ps4_sceNpSignalingInitialize); 80 | lib^.set_proc($E7262311D778B7C6,@ps4_sceNpSignalingCreateContext); 81 | lib^.set_proc($7432CD15D63C770B,@ps4_sceNpSignalingCreateContextA); 82 | lib^.set_proc($53C01032538505CF,@ps4_sceNpSignalingGetLocalNetInfo); 83 | lib^.set_proc($207443BD9A1D3D86,@ps4_sceNpSignalingSetContextOption); 84 | end; 85 | 86 | initialization 87 | ps4_app.RegistredPreLoad('libSceNpSignaling.prx',@Load_libSceNpSignaling); 88 | 89 | end. 90 | 91 | -------------------------------------------------------------------------------- /src/np/ps4_libscenputility.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceNpUtility; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program, 9 | ps4_libSceNpCommon; 10 | 11 | const 12 | SCE_NP_LOOKUP_MAX_CTX_NUM=32; 13 | 14 | type 15 | pSceNpBandwidthTestInitParam=^SceNpBandwidthTestInitParam; 16 | SceNpBandwidthTestInitParam=packed record 17 | size :QWORD; 18 | threadPriority :Integer; 19 | padding :Integer; 20 | cpuAffinityMask:QWORD; 21 | reserved :array[0..7] of DWORD; 22 | end; 23 | 24 | implementation 25 | 26 | function ps4_sceNpLookupCreateTitleCtx(selfNpId:PSceNpId):Integer; SysV_ABI_CDecl; 27 | begin 28 | Result:=1; 29 | end; 30 | 31 | function ps4_sceNpLookupCreateTitleCtxA(selfNpId:Integer):Integer; SysV_ABI_CDecl; 32 | begin 33 | Result:=1; 34 | end; 35 | 36 | function ps4_sceNpBandwidthTestInitStart(const param:pSceNpBandwidthTestInitParam):Integer; SysV_ABI_CDecl; 37 | begin 38 | Result:=0; 39 | end; 40 | 41 | function ps4_sceNpBandwidthTestGetStatus(contextId:Integer;status:PInteger):Integer; SysV_ABI_CDecl; 42 | begin 43 | Result:=0; 44 | end; 45 | 46 | function Load_libSceNpUtility(Const name:RawByteString):TElf_node; 47 | var 48 | lib:PLIBRARY; 49 | begin 50 | Result:=TElf_node.Create; 51 | Result.pFileName:=name; 52 | 53 | lib:=Result._add_lib('libSceNpUtility'); 54 | lib^.set_proc($F39DF743E2D4EC44,@ps4_sceNpLookupCreateTitleCtx); 55 | lib^.set_proc($BD3F7186A3CEEBED,@ps4_sceNpLookupCreateTitleCtxA); 56 | lib^.set_proc($8E4B70C37C895E77,@ps4_sceNpBandwidthTestInitStart); 57 | lib^.set_proc($05821918A9BA6CEE,@ps4_sceNpBandwidthTestGetStatus); 58 | ///lib^.set_proc($E7262311D778B7C6,@ps4_sceNpSignalingCreateContext); 59 | end; 60 | 61 | initialization 62 | ps4_app.RegistredPreLoad('libSceNpUtility.prx',@Load_libSceNpUtility); 63 | 64 | end. 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/ps4_libSceSsl.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceSsl; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program; 9 | 10 | type 11 | pSceSslData=^SceSslData; 12 | SceSslData=packed record 13 | ptr :PChar; 14 | size:QWORD; 15 | end; 16 | 17 | pSceSslCaCerts=^SceSslCaCerts; 18 | SceSslCaCerts=packed record 19 | certData :pSceSslData; 20 | certDataNum:QWORD; 21 | pool :Pointer; 22 | end; 23 | 24 | implementation 25 | 26 | function ps4_sceSslInit(poolSize:size_t):Integer; SysV_ABI_CDecl; 27 | begin 28 | Writeln('sceSslInit:',poolSize); 29 | Result:=3; 30 | end; 31 | 32 | function ps4_sceSslTerm(ctxId:Integer):Integer; SysV_ABI_CDecl; 33 | begin 34 | Writeln('sceSslTerm:ctxId=',ctxId); 35 | Result:=0; 36 | end; 37 | 38 | function ps4_sceSslGetCaCerts(libsslCtxId:Integer; 39 | caCerts:pSceSslCaCerts):Integer; SysV_ABI_CDecl; 40 | begin 41 | Writeln('sceSslGetCaCerts:',libsslCtxId); 42 | Result:=0; 43 | end; 44 | 45 | function ps4_sceSslFreeCaCerts(libsslCtxId:Integer; 46 | caCerts:pSceSslCaCerts):Integer; SysV_ABI_CDecl; 47 | begin 48 | Writeln('sceSslFreeCaCerts:',libsslCtxId); 49 | Result:=0; 50 | end; 51 | 52 | function Load_libSceSsl(Const name:RawByteString):TElf_node; 53 | var 54 | lib:PLIBRARY; 55 | begin 56 | Result:=TElf_node.Create; 57 | Result.pFileName:=name; 58 | 59 | lib:=Result._add_lib('libSceSsl'); 60 | 61 | lib^.set_proc($85DA551140C55B7B,@ps4_sceSslInit); 62 | lib^.set_proc($D0AD7243A2EFFD87,@ps4_sceSslTerm); 63 | lib^.set_proc($4C37D0A8EFE031B6,@ps4_sceSslGetCaCerts); 64 | lib^.set_proc($A88BCBB34818C62D,@ps4_sceSslFreeCaCerts); 65 | end; 66 | 67 | initialization 68 | //lower priority 69 | ps4_app.RegistredFinLoad('libSceSsl.prx' ,@Load_libSceSsl); 70 | ps4_app.RegistredFinLoad('libSceSsl2.prx',@Load_libSceSsl); 71 | 72 | end. 73 | 74 | -------------------------------------------------------------------------------- /src/ps4_libscecompanionhttpd.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceCompanionHttpd; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program, 9 | ps4_libSceNet, 10 | Classes, 11 | SysUtils; 12 | 13 | const 14 | SCE_COMPANION_HTTPD_ERROR_NOT_INITIALIZED=-2132541434; //0x80E40006 15 | SCE_COMPANION_HTTPD_ERROR_INVALID_PARAM =-2132541436; //0x80E40004 16 | 17 | type 18 | pSceCompanionHttpdOptParam2=^SceCompanionHttpdOptParam2; 19 | SceCompanionHttpdOptParam2=packed record 20 | thisSize :QWORD; 21 | workMemory :Pointer; 22 | workMemorySize :QWORD; 23 | workThreadPriority :Integer; 24 | _align1 :Integer; 25 | workThreadAffinity :QWORD; 26 | workThreadStackSize :QWORD; 27 | transceiverThreadPriority :Integer; 28 | _align2 :Integer; 29 | transceiverThreadAffinity :QWORD; 30 | transceiverStackSize :QWORD; 31 | transceiverThreadCount :QWORD; 32 | port :SceNetInPort_t; 33 | _align3 :word; 34 | screenOrientation :Integer; 35 | workDirectory :PChar; 36 | enableWebSocketProxy :Boolean; 37 | _align4 :Byte; 38 | webSocketServerPort :SceNetInPort_t; 39 | webSocketProxySessionTimeout:DWORD; 40 | end; 41 | 42 | pSceCompanionHttpdHeader=^SceCompanionHttpdHeader; 43 | SceCompanionHttpdHeader=packed record 44 | key :PChar; 45 | value :PChar; 46 | header:pSceCompanionHttpdHeader; 47 | end; 48 | 49 | pSceCompanionHttpdRequest=^SceCompanionHttpdRequest; 50 | SceCompanionHttpdRequest=packed record 51 | method :Integer; 52 | _align :Integer; 53 | url :PChar; 54 | header :pSceCompanionHttpdHeader; 55 | body :PChar; 56 | bodySize:QWORD; 57 | end; 58 | 59 | pSceCompanionHttpdResponse=^SceCompanionHttpdResponse; 60 | SceCompanionHttpdResponse=packed record 61 | status :Integer; 62 | _align :Integer; 63 | header :pSceCompanionHttpdHeader; 64 | body :PChar; 65 | bodySize:QWORD; 66 | end; 67 | 68 | SceCompanionHttpdRequestCallback=function( 69 | userId :Integer; 70 | httpRequest :pSceCompanionHttpdRequest; 71 | httpResponse:pSceCompanionHttpdResponse; 72 | param :Pointer 73 | ):Integer; 74 | 75 | SceCompanionHttpdRequestBodyReceptionCallback=function( 76 | event :Integer; 77 | userId :Integer; 78 | httpRequest:pSceCompanionHttpdRequest; 79 | param :Pointer 80 | ):Integer; 81 | 82 | implementation 83 | 84 | function ps4_sceCompanionHttpdInitialize2(const option:pSceCompanionHttpdOptParam2):Integer; SysV_ABI_CDecl; 85 | begin 86 | Result:=0; 87 | end; 88 | 89 | function ps4_sceCompanionHttpdStart():Integer; SysV_ABI_CDecl; 90 | begin 91 | Result:=0; 92 | end; 93 | 94 | function ps4_sceCompanionHttpdRegisterRequestCallback(_function:SceCompanionHttpdRequestCallback; 95 | param:Pointer):Integer; SysV_ABI_CDecl; 96 | begin 97 | if (param=nil) then Exit(SCE_COMPANION_HTTPD_ERROR_INVALID_PARAM); 98 | Result:=0; 99 | end; 100 | 101 | function ps4_sceCompanionHttpdRegisterRequestBodyReceptionCallback(_function:SceCompanionHttpdRequestBodyReceptionCallback; 102 | param:Pointer):Integer; SysV_ABI_CDecl; 103 | begin 104 | if (param=nil) then Exit(SCE_COMPANION_HTTPD_ERROR_INVALID_PARAM); 105 | Result:=0; 106 | end; 107 | 108 | function Load_libSceCompanionHttpd(Const name:RawByteString):TElf_node; 109 | var 110 | lib:PLIBRARY; 111 | begin 112 | Result:=TElf_node.Create; 113 | Result.pFileName:=name; 114 | 115 | lib:=Result._add_lib('libSceCompanionHttpd'); 116 | lib^.set_proc($380E856CE45E7DBA,@ps4_sceCompanionHttpdInitialize2); 117 | lib^.set_proc($93B17415C0CCFD77,@ps4_sceCompanionHttpdStart); 118 | lib^.set_proc($39A5B0F8854475B2,@ps4_sceCompanionHttpdRegisterRequestCallback); 119 | lib^.set_proc($7C73668A3EE40143,@ps4_sceCompanionHttpdRegisterRequestBodyReceptionCallback); 120 | end; 121 | 122 | initialization 123 | ps4_app.RegistredPreLoad('libSceCompanionHttpd.prx',@Load_libSceCompanionHttpd); 124 | 125 | end. 126 | 127 | -------------------------------------------------------------------------------- /src/ps4_libscecompanionutil.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceCompanionUtil; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program, 9 | ps4_libSceNet, 10 | Classes, 11 | SysUtils; 12 | 13 | const 14 | SCE_COMPANION_UTIL_ERROR_NO_EVENT=-2136145912; //0x80AD0008 15 | 16 | type 17 | pSceCompanionUtilOptParam=^SceCompanionUtilOptParam; 18 | SceCompanionUtilOptParam=packed record 19 | thisSize :QWORD; 20 | workMemory :Pointer; 21 | workMemorySize:QWORD; 22 | end; 23 | 24 | pSceCompanionUtilDeviceInfo=^SceCompanionUtilDeviceInfo; 25 | SceCompanionUtilDeviceInfo=packed record 26 | userId :Integer; 27 | addr :SceNetSockaddrIn; 28 | reserved:array[0..235] of char; 29 | end; 30 | 31 | pSceCompanionUtilEvent=^SceCompanionUtilEvent; 32 | SceCompanionUtilEvent=packed record 33 | event:Integer; 34 | union:packed record 35 | case Byte of 36 | 0:(deviceInfo:SceCompanionUtilDeviceInfo); 37 | 1:(userId :Integer); 38 | 2:(reserved :array[0..255] of char); 39 | end; 40 | end; 41 | 42 | implementation 43 | 44 | function ps4_sceCompanionUtilOptParamInitialize(pOptParam:SceCompanionUtilOptParam):Integer; SysV_ABI_CDecl; 45 | begin 46 | Result:=0; 47 | end; 48 | 49 | function ps4_sceCompanionUtilInitialize(const option:pSceCompanionUtilOptParam):Integer; SysV_ABI_CDecl; 50 | begin 51 | Result:=0; 52 | end; 53 | 54 | function ps4_sceCompanionUtilGetEvent(pEvent:pSceCompanionUtilEvent):Integer; SysV_ABI_CDecl; 55 | begin 56 | Result:=SCE_COMPANION_UTIL_ERROR_NO_EVENT; 57 | end; 58 | 59 | function Load_libSceCompanionUtil(Const name:RawByteString):TElf_node; 60 | var 61 | lib:PLIBRARY; 62 | begin 63 | Result:=TElf_node.Create; 64 | Result.pFileName:=name; 65 | 66 | lib:=Result._add_lib('libSceCompanionUtil'); 67 | lib^.set_proc($20F37F1514AB69F9,@ps4_sceCompanionUtilOptParamInitialize); 68 | lib^.set_proc($C5BD7194885FD106,@ps4_sceCompanionUtilInitialize); 69 | lib^.set_proc($704E4CB32D755A15,@ps4_sceCompanionUtilGetEvent); 70 | end; 71 | 72 | initialization 73 | ps4_app.RegistredPreLoad('libSceCompanionUtil.prx',@Load_libSceCompanionUtil); 74 | 75 | end. 76 | 77 | -------------------------------------------------------------------------------- /src/ps4_libscecontentexport.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceContentExport; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program; 9 | 10 | implementation 11 | 12 | const 13 | SCE_CONTENT_EXPORT_ERROR_CANCELED =$809D3001; 14 | SCE_CONTENT_EXPORT_ERROR_NOTACCEPT =$809D3002; 15 | SCE_CONTENT_EXPORT_ERROR_BUSY =$809D3003; 16 | SCE_CONTENT_EXPORT_ERROR_NOINIT =$809D3004; 17 | SCE_CONTENT_EXPORT_ERROR_MULTIPLEINIT =$809D3005; 18 | SCE_CONTENT_EXPORT_ERROR_NOMEM =$809D3006; 19 | SCE_CONTENT_EXPORT_ERROR_FILE_NOT_FOUND =$809D3011; 20 | SCE_CONTENT_EXPORT_ERROR_NOT_SUPPORTED_FORMAT =$809D3012; 21 | SCE_CONTENT_EXPORT_ERROR_INVALDPARAM =$809D3016; 22 | SCE_CONTENT_EXPORT_ERROR_DISKFULL =$809D3017; 23 | SCE_CONTENT_EXPORT_ERROR_EXECUTION_MAX =$809D3018; 24 | SCE_CONTENT_EXPORT_ERROR_NOT_SUPPORT_FORMAT_THUMBNAIL=$809D3019; 25 | SCE_CONTENT_EXPORT_ERROR_FILES_IN_USE =$809D301A; 26 | SCE_CONTENT_EXPORT_ERROR_DATA_PROVIDE_FUNCTION =$809D301B; 27 | SCE_CONTENT_EXPORT_ERROR_NOT_IMPLEMENTED =$809D3FFF; 28 | 29 | type 30 | sceContentExportMalloc=function(size:size_t;userdata:Pointer):Pointer; 31 | sceContentExportFree=procedure(p:Pointer;userdata:Pointer); 32 | 33 | SceContentExportInitParam=packed record 34 | mallocfunc:sceContentExportMalloc; 35 | freefunc :sceContentExportFree; 36 | userdata :Pointer; 37 | end; 38 | PSceContentExportInitParam=^SceContentExportInitParam; 39 | 40 | var 41 | isInitialized:Boolean=False; 42 | 43 | function ps4_sceContentExportInit(initParams:PSceContentExportInitParam):Integer; SysV_ABI_CDecl; 44 | begin 45 | Writeln('sceContentExportInit'); 46 | Result:=SCE_CONTENT_EXPORT_ERROR_NOT_IMPLEMENTED; 47 | end; 48 | 49 | function Load_libContentExportPlay(Const name:RawByteString):TElf_node; 50 | var 51 | lib:PLIBRARY; 52 | begin 53 | Result:=TElf_node.Create; 54 | Result.pFileName:=name; 55 | 56 | lib:=Result._add_lib('libSceContentExport'); 57 | 58 | lib^.set_proc($1731167989C01652,@ps4_sceContentExportInit); 59 | end; 60 | 61 | initialization 62 | ps4_app.RegistredPreLoad('libSceContentExport.prx',@Load_libContentExportPlay); 63 | 64 | end. 65 | 66 | -------------------------------------------------------------------------------- /src/ps4_libsceconvertkeycode.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceConvertKeycode; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program, 9 | ps4_libSceIme, 10 | Classes, 11 | SysUtils; 12 | 13 | implementation 14 | 15 | function ps4_sceConvertKeycodeGetVirtualKeycode(keycode:Word; 16 | keyboardType:Integer; 17 | vkeycode:PWord):Integer; SysV_ABI_CDecl; 18 | begin 19 | Result:=0; 20 | end; 21 | 22 | function Load_libSceConvertKeycode(Const name:RawByteString):TElf_node; 23 | var 24 | lib:PLIBRARY; 25 | begin 26 | Result:=TElf_node.Create; 27 | Result.pFileName:=name; 28 | 29 | lib:=Result._add_lib('libSceConvertKeycode'); 30 | lib^.set_proc($BC8B2826C2EFBE53,@ps4_sceConvertKeycodeGetVirtualKeycode); 31 | end; 32 | 33 | initialization 34 | //low priority 35 | ps4_app.RegistredFinLoad('libSceConvertKeycode.prx',@Load_libSceConvertKeycode); 36 | 37 | end. 38 | 39 | -------------------------------------------------------------------------------- /src/ps4_libscedepth.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceDepth; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program; 9 | 10 | implementation 11 | 12 | type 13 | PSceDepthInitializeParameter=Pointer; 14 | PSceDepthQueryMemoryResult=Pointer; 15 | 16 | function ps4_sceDepthQueryMemory(initParam:PSceDepthInitializeParameter;queryMem:PSceDepthQueryMemoryResult):Integer; SysV_ABI_CDecl; 17 | begin 18 | Writeln('sceDepthQueryMemory'); 19 | Result:=0; 20 | end; 21 | 22 | function ps4_sceDepthInitialize(initParam:PSceDepthInitializeParameter;queryMem:PSceDepthQueryMemoryResult):Integer; SysV_ABI_CDecl; 23 | begin 24 | Writeln('sceDepthInitialize'); 25 | Result:=0; 26 | end; 27 | 28 | function ps4_sceDepthEnableExtendedMode(param1:DWORD):Integer; SysV_ABI_CDecl; 29 | begin 30 | Result:=0; 31 | end; 32 | 33 | function Load_libSceDepth(Const name:RawByteString):TElf_node; 34 | var 35 | lib:PLIBRARY; 36 | begin 37 | Result:=TElf_node.Create; 38 | Result.pFileName:=name; 39 | 40 | lib:=Result._add_lib('libSceDepth'); 41 | 42 | lib^.set_proc($E4CC31224DFF80BA,@ps4_sceDepthQueryMemory); 43 | lib^.set_proc($3DA6BD7601E71E94,@ps4_sceDepthInitialize); 44 | lib^.set_proc($CF9493F422201DAD,@ps4_sceDepthEnableExtendedMode); 45 | end; 46 | 47 | initialization 48 | ps4_app.RegistredPreLoad('libSceDepth.prx',@Load_libSceDepth); 49 | 50 | end. 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/ps4_libscediscmap.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceDiscMap; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program, 9 | Classes, 10 | SysUtils; 11 | 12 | implementation 13 | 14 | const 15 | SCE_DISC_MAP_ERROR_INVALID_ARGUMENT =-2129657855; //0x81100001 16 | SCE_DISC_MAP_ERROR_LOCATION_NOT_MAPPED=-2129657854; //0x81100002 17 | SCE_DISC_MAP_ERROR_FILE_NOT_FOUND =-2129657853; //0x81100003 18 | SCE_DISC_MAP_ERROR_NO_BITMAP_INFO =-2129657852; //0x81100004 19 | SCE_DISC_MAP_ERROR_FATAL =-2129657601; //0x811000FF 20 | 21 | DM_PATCH_FLAG=$1; 22 | DM_APP1_FLAG =$100; 23 | 24 | function ps4_sceDiscMapIsRequestOnHDD(path:PChar;param2,param3:Int64;pret:PInteger):Integer; SysV_ABI_CDecl; 25 | begin 26 | //pret^:=1; 27 | Result:=SCE_DISC_MAP_ERROR_NO_BITMAP_INFO; 28 | end; 29 | 30 | function ps4_ioKMruft1ek(path:PChar;param2,param3:Int64;pflags,pret1,pret2:PInt64):Integer; SysV_ABI_CDecl; 31 | begin 32 | //pflags^:=0; 33 | //pret1^:=0; 34 | //pret2^:=0; 35 | Result:=SCE_DISC_MAP_ERROR_NO_BITMAP_INFO; 36 | end; 37 | 38 | function ps4_fJgP_wqifno(path:PChar;param2,param3:Int64;pflags,pret1,pret2:PInt64):Integer; SysV_ABI_CDecl; 39 | begin 40 | if (param3<=0) or 41 | (param2<=-2) or 42 | (path=nil) or 43 | (pflags=nil) or 44 | (pret1=nil) or 45 | (pret2=nil) then Exit(SCE_DISC_MAP_ERROR_INVALID_ARGUMENT); 46 | 47 | pflags^:=0; 48 | pret1^:=0; 49 | pret2^:=0; 50 | Result:=0; 51 | end; 52 | 53 | function ps4_sceDiscMapGetPackageSize(fflags:Int64;pret1,pret2:PInt64):Integer; SysV_ABI_CDecl; 54 | begin 55 | Result:=SCE_DISC_MAP_ERROR_NO_BITMAP_INFO; 56 | end; 57 | 58 | function Load_libSceDiscMap(Const name:RawByteString):TElf_node; 59 | var 60 | lib:PLIBRARY; 61 | begin 62 | Result:=TElf_node.Create; 63 | Result.pFileName:=name; 64 | 65 | lib:=Result._add_lib('libSceDiscMap'); 66 | lib^.set_proc($95B40AAAC11186D1,@ps4_sceDiscMapIsRequestOnHDD); 67 | lib^.set_proc($8A828CAEE7EDD5E9,@ps4_ioKMruft1ek); 68 | lib^.set_proc($7C980FFB0AA27E7A,@ps4_fJgP_wqifno); 69 | lib^.set_proc($7E5D5EA039F0438B,@ps4_sceDiscMapGetPackageSize); 70 | end; 71 | 72 | initialization 73 | ps4_app.RegistredPreLoad('libSceDiscMap.prx',@Load_libSceDiscMap); 74 | 75 | end. 76 | 77 | -------------------------------------------------------------------------------- /src/ps4_libscelncutil.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceLncUtil; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program, 9 | Classes, 10 | SysUtils; 11 | 12 | implementation 13 | 14 | function ps4_sceLncUtilInitialize():Integer; SysV_ABI_CDecl; 15 | begin 16 | Result:=0; 17 | end; 18 | 19 | function Load_libSceLncUtil(Const name:RawByteString):TElf_node; 20 | var 21 | lib:PLIBRARY; 22 | begin 23 | Result:=TElf_node.Create; 24 | Result.pFileName:=name; 25 | 26 | lib:=Result._add_lib('libSceLncUtil'); 27 | lib^.set_proc($7FF43C35DDF71417,@ps4_sceLncUtilInitialize); 28 | end; 29 | 30 | initialization 31 | ps4_app.RegistredPreLoad('libSceLncUtil.prx',@Load_libSceLncUtil); 32 | 33 | end. 34 | 35 | -------------------------------------------------------------------------------- /src/ps4_libsceloginservice.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceLoginService; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | 8 | uses 9 | ps4_program, 10 | Classes, 11 | SysUtils; 12 | 13 | implementation 14 | 15 | function ps4_sceLoginServiceInitialize():Integer; SysV_ABI_CDecl; 16 | begin 17 | Result:=0; 18 | end; 19 | 20 | function Load_libSceLoginService(Const name:RawByteString):TElf_node; 21 | var 22 | lib:PLIBRARY; 23 | begin 24 | Result:=TElf_node.Create; 25 | Result.pFileName:=name; 26 | lib:=Result._add_lib('libSceLoginService'); 27 | lib^.set_proc($4FDFCDB921C0BDC4,@ps4_sceLoginServiceInitialize); 28 | end; 29 | 30 | initialization 31 | ps4_app.RegistredPreLoad('libSceLoginService.prx',@Load_libSceLoginService); 32 | 33 | end. 34 | 35 | -------------------------------------------------------------------------------- /src/ps4_libscemouse.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceMouse; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program, 9 | Classes, 10 | SysUtils; 11 | 12 | implementation 13 | 14 | type 15 | pSceMouseOpenParam=^SceMouseOpenParam; 16 | SceMouseOpenParam=packed record 17 | behaviorFlag:Byte; 18 | reserved:array[0..6] of Byte; 19 | end; 20 | 21 | pSceMouseData=^SceMouseData; 22 | SceMouseData=packed record 23 | timestamp:QWORD; 24 | connected:Integer; 25 | buttons:DWORD; 26 | xAxis:Integer; 27 | yAxis:Integer; 28 | wheel:Integer; 29 | tilt :Integer; 30 | reserve:qword; 31 | end; 32 | 33 | const 34 | SCE_MOUSE_ERROR_INVALID_ARG =-2132869119; //0x80DF0001 35 | SCE_MOUSE_ERROR_INVALID_HANDLE =-2132869117; //0x80DF0003 36 | SCE_MOUSE_ERROR_ALREADY_OPENED =-2132869116; //0x80DF0004 37 | SCE_MOUSE_ERROR_NOT_INITIALIZED=-2132869115; //0x80DF0005 38 | SCE_MOUSE_ERROR_FATAL =-2132868865; //0x80DF00FF 39 | 40 | SCE_MOUSE_MAX_DATA_NUM=64; 41 | 42 | function ps4_sceMouseInit:Integer; SysV_ABI_CDecl; 43 | begin 44 | Writeln('sceMouseInit'); 45 | Result:=0; 46 | end; 47 | 48 | function ps4_sceMouseOpen(userId,_type,index:Integer; 49 | pParam:pSceMouseOpenParam):Integer; SysV_ABI_CDecl; 50 | begin 51 | Writeln('sceMouseOpen'); 52 | Result:=0; 53 | end; 54 | 55 | function ps4_sceMouseRead(handle:Integer; 56 | pData:pSceMouseData; 57 | num:Integer):Integer; SysV_ABI_CDecl; 58 | begin 59 | if (pData=nil) then Exit(SCE_MOUSE_ERROR_INVALID_HANDLE); 60 | if (num<=0) or (num>SCE_MOUSE_MAX_DATA_NUM) then Exit(SCE_MOUSE_ERROR_INVALID_HANDLE); 61 | 62 | pData[0]:=Default(SceMouseData); 63 | pData[0].connected:=Integer(False); 64 | Result:=1; 65 | end; 66 | 67 | function Load_libSceMouse(Const name:RawByteString):TElf_node; 68 | var 69 | lib:PLIBRARY; 70 | begin 71 | Result:=TElf_node.Create; 72 | Result.pFileName:=name; 73 | 74 | lib:=Result._add_lib('libSceMouse'); 75 | lib^.set_proc($42CD305AE96097B5,@ps4_sceMouseInit); 76 | lib^.set_proc($45AAB16487FA0EF1,@ps4_sceMouseOpen); 77 | lib^.set_proc($C7CAA75EA87FB623,@ps4_sceMouseRead); 78 | end; 79 | 80 | initialization 81 | ps4_app.RegistredPreLoad('libSceMouse.prx',@Load_libSceMouse); 82 | 83 | end. 84 | 85 | -------------------------------------------------------------------------------- /src/ps4_libscemove.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceMove; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program, 9 | Classes, 10 | SysUtils; 11 | 12 | implementation 13 | 14 | const 15 | SCE_MOVE_ERROR_INVALID_ARG =-2131886077; //0x80EE0003 16 | SCE_MOVE_ERROR_INVALID_HANDLE=-2131886076; //0x80EE0004 17 | SCE_MOVE_ERROR_NOT_INIT =-2131886079; //0x80EE0001 18 | 19 | SCE_MOVE_RETURN_CODE_NO_CONTROLLER_CONNECTED=1; 20 | 21 | SCE_MOVE_MAX_STATE_NUM=32; 22 | 23 | type 24 | pSceMoveDeviceInfo=^SceMoveDeviceInfo; 25 | SceMoveDeviceInfo=packed record 26 | sphereRadius:Single; 27 | accelToSphereOffset:array[0..2] of Single; 28 | end; 29 | 30 | SceMoveButtonData=packed record 31 | digitalButtons:Word; 32 | analogT:Word; 33 | end; 34 | 35 | SceMoveExtensionPortData=packed record 36 | status :Word; 37 | digital1 :Word; 38 | digital2 :Word; 39 | analogRightX:Word; 40 | analogRightY:Word; 41 | analogLeftX :Word; 42 | analogLeftY :Word; 43 | custom:array[0..4] of AnsiChar; 44 | end; 45 | 46 | pSceMoveData=^SceMoveData; 47 | SceMoveData=packed record 48 | accelerometer:array[0..2] of Single; 49 | gyro:array[0..2] of Single; 50 | pad:SceMoveButtonData; 51 | ext:SceMoveExtensionPortData; 52 | timestamp:QWORD; 53 | counter:Integer; 54 | temperature:Single; 55 | end; 56 | 57 | function ps4_sceMoveInit:Integer; SysV_ABI_CDecl; 58 | begin 59 | Writeln('sceMoveInit'); 60 | Result:=0; 61 | end; 62 | 63 | function ps4_sceMoveOpen(userId,_type,index:Integer):Integer; SysV_ABI_CDecl; 64 | begin 65 | Writeln('sceMoveOpen:',userId,' ',_type,' ',index); 66 | Result:=0; 67 | end; 68 | 69 | function ps4_sceMoveClose(handle:Integer):Integer; SysV_ABI_CDecl; 70 | begin 71 | Writeln('sceMoveClose:',handle); 72 | Result:=0; 73 | end; 74 | 75 | function ps4_sceMoveGetDeviceInfo(handle:Integer;pInfo:pSceMoveDeviceInfo):Integer; SysV_ABI_CDecl; 76 | begin 77 | if (pInfo=nil) then Exit(SCE_MOVE_ERROR_INVALID_ARG); 78 | pInfo^:=Default(SceMoveDeviceInfo); 79 | Result:=SCE_MOVE_RETURN_CODE_NO_CONTROLLER_CONNECTED; 80 | end; 81 | 82 | function ps4_sceMoveReadStateLatest(handle:Integer;pData:pSceMoveData):Integer; SysV_ABI_CDecl; 83 | begin 84 | if (pData=nil) then Exit(SCE_MOVE_ERROR_INVALID_ARG); 85 | pData^:=Default(SceMoveData); 86 | Result:=SCE_MOVE_RETURN_CODE_NO_CONTROLLER_CONNECTED; 87 | end; 88 | 89 | function ps4_sceMoveReadStateRecent(handle:Integer; 90 | timestamp:QWORD; 91 | pData:pSceMoveData; 92 | num:Pinteger):Integer; SysV_ABI_CDecl; 93 | begin 94 | if (pData=nil) or (num=nil) then Exit(SCE_MOVE_ERROR_INVALID_ARG); 95 | pData^:=Default(SceMoveData); 96 | num^:=0; 97 | Result:=SCE_MOVE_RETURN_CODE_NO_CONTROLLER_CONNECTED; 98 | end; 99 | 100 | function ps4_sceMoveSetVibration(handle:Integer;motor:Byte):Integer; SysV_ABI_CDecl; 101 | begin 102 | Result:=SCE_MOVE_RETURN_CODE_NO_CONTROLLER_CONNECTED; 103 | end; 104 | 105 | function Load_libSceMove(Const name:RawByteString):TElf_node; 106 | var 107 | lib:PLIBRARY; 108 | begin 109 | Result:=TElf_node.Create; 110 | Result.pFileName:=name; 111 | 112 | lib:=Result._add_lib('libSceMove'); 113 | lib^.set_proc($8F521313F1282661,@ps4_sceMoveInit); 114 | lib^.set_proc($1F30BAD0C7E32715,@ps4_sceMoveOpen); 115 | lib^.set_proc($5D7EB0971A47C9EA,@ps4_sceMoveClose); 116 | lib^.set_proc($1965D3CB1B3841B1,@ps4_sceMoveGetDeviceInfo); 117 | lib^.set_proc($B6D53E24E852865E,@ps4_sceMoveReadStateLatest); 118 | lib^.set_proc($7F66DCA4AEA425F8,@ps4_sceMoveReadStateRecent); 119 | lib^.set_proc($205430B53D82798D,@ps4_sceMoveSetVibration); 120 | end; 121 | 122 | initialization 123 | ps4_app.RegistredPreLoad('libSceMove.prx',@Load_libSceMove); 124 | 125 | end. 126 | 127 | -------------------------------------------------------------------------------- /src/ps4_libscemovetracker.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceMoveTracker; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program; 9 | 10 | const 11 | SCE_MOVE_TRACKER_ERROR_INVALID_ARG=-2131820541; //0x80EF0003 12 | 13 | SCE_MOVE_MAX_CONTROLLERS=4; 14 | SCE_MOVE_MAX_CONTROLLERS_PER_PLAYER=2; 15 | 16 | type 17 | pSceMoveButtonData=^SceMoveButtonData; 18 | SceMoveButtonData=packed record 19 | digitalButtons,analogT:Word; 20 | end; 21 | 22 | pSceMoveExtensionPortData=^SceMoveExtensionPortData; 23 | SceMoveExtensionPortData=packed record 24 | status :Word; 25 | digital1 :Word; 26 | digital2 :Word; 27 | analogRightX:Word; 28 | analogRightY:Word; 29 | analogLeftX :Word; 30 | analogLeftY :Word; 31 | custom :array[0..5] of Byte; 32 | end; 33 | 34 | pSceMoveData=^SceMoveData; 35 | SceMoveData=packed record 36 | accelerometer:array[0..2] of single; 37 | gyro :array[0..2] of single; 38 | pad :SceMoveButtonData; 39 | ext :SceMoveExtensionPortData; 40 | timestamp :Int64; 41 | counter :Integer; 42 | temperature :single; 43 | end; 44 | 45 | pSceMoveTrackerControllerInput=^SceMoveTrackerControllerInput; 46 | SceMoveTrackerControllerInput=packed record 47 | handle:Integer; 48 | _align:Integer; 49 | data:pSceMoveData; 50 | num:Integer; 51 | end; 52 | 53 | implementation 54 | 55 | function ps4_sceMoveTrackerGetWorkingMemorySize(onionSize,garlicSize:PInteger):Integer; SysV_ABI_CDecl; 56 | begin 57 | if (onionSize=nil) or (garlicSize=nil) then Exit(SCE_MOVE_TRACKER_ERROR_INVALID_ARG); 58 | onionSize^ :=$800000 + $200000; 59 | garlicSize^:=$800000; 60 | Result:=0; 61 | end; 62 | 63 | function ps4_sceMoveTrackerInit(onionMemory,garlicMemory:Pointer;pipeId,queueId:Integer):Integer; SysV_ABI_CDecl; 64 | begin 65 | if (onionMemory=nil) or (garlicMemory=nil) then Exit(SCE_MOVE_TRACKER_ERROR_INVALID_ARG); 66 | Result:=0; 67 | end; 68 | 69 | function ps4_sceMoveTrackerControllersUpdate(controllerInputs:pSceMoveTrackerControllerInput):Integer; SysV_ABI_CDecl; 70 | begin 71 | //controllerInputs[SCE_MOVE_MAX_CONTROLLERS] 72 | Result:=0; 73 | end; 74 | 75 | function Load_libSceMoveTracker(Const name:RawByteString):TElf_node; 76 | var 77 | lib:PLIBRARY; 78 | begin 79 | Result:=TElf_node.Create; 80 | Result.pFileName:=name; 81 | 82 | lib:=Result._add_lib('libSceMoveTracker'); 83 | lib^.set_proc($820D5DE0AB32555B,@ps4_sceMoveTrackerGetWorkingMemorySize); 84 | lib^.set_proc($178C366ADC06E36F,@ps4_sceMoveTrackerInit); 85 | lib^.set_proc($FD8F2194C801B2BE,@ps4_sceMoveTrackerControllersUpdate); 86 | end; 87 | 88 | initialization 89 | ps4_app.RegistredPreLoad('libSceMoveTracker.prx',@Load_libSceMoveTracker); 90 | 91 | end. 92 | 93 | -------------------------------------------------------------------------------- /src/ps4_libscerandom.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceRandom; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program, 9 | sys_signal, 10 | sys_kernel; 11 | 12 | const 13 | SCE_RANDOM_MAX_SIZE=64; 14 | 15 | implementation 16 | 17 | function ps4_sceRandomGetRandomNumber(buf:Pointer;size:qword):Integer; SysV_ABI_CDecl; 18 | begin 19 | if (buf=nil) or (size>SCE_RANDOM_MAX_SIZE) then Exit(EINVAL); 20 | 21 | _sig_lock; 22 | Result:=BCryptGenRandom(nil,buf,size,BCRYPT_USE_SYSTEM_PREFERRED_RNG); 23 | _sig_unlock; 24 | 25 | if (Result=0) then 26 | begin 27 | _set_errno(0); 28 | end else 29 | begin 30 | Result:=ENODEV; 31 | _set_errno(ENODEV); 32 | end; 33 | end; 34 | 35 | function Load_libSceRandom(Const name:RawByteString):TElf_node; 36 | var 37 | lib:PLIBRARY; 38 | begin 39 | Result:=TElf_node.Create; 40 | Result.pFileName:=name; 41 | lib:=Result._add_lib('libSceRandom'); 42 | lib^.set_proc($3C8EE32198F8A5C1,@ps4_sceRandomGetRandomNumber); 43 | end; 44 | 45 | initialization 46 | ps4_app.RegistredPreLoad('libSceRandom.prx',@Load_libSceRandom); 47 | 48 | end. 49 | 50 | -------------------------------------------------------------------------------- /src/ps4_libsceremoteplay.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceRemoteplay; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program, 9 | Classes, 10 | SysUtils; 11 | 12 | implementation 13 | 14 | const 15 | SCE_REMOTEPLAY_HEAP_SIZE=6*1024; 16 | 17 | function ps4_sceRemoteplayInitialize(pHeap:Pointer;heapSize:QWORD):Integer; SysV_ABI_CDecl; 18 | begin 19 | Writeln('sceRemoteplayInitialize:',heapSize); 20 | Result:=0; 21 | end; 22 | 23 | function ps4_sceRemoteplayApprove:Integer; SysV_ABI_CDecl; 24 | begin 25 | Result:=0; 26 | end; 27 | 28 | function ps4_sceRemoteplaySetProhibition:Integer; SysV_ABI_CDecl; 29 | begin 30 | Result:=0; 31 | end; 32 | 33 | const 34 | SCE_REMOTEPLAY_CONNECTION_STATUS_DISCONNECT=0; 35 | SCE_REMOTEPLAY_CONNECTION_STATUS_CONNECT =1; 36 | 37 | function ps4_sceRemoteplayGetConnectionStatus(userId:Integer;pStatus:PInteger):Integer; SysV_ABI_CDecl; 38 | begin 39 | if (pStatus<>nil) then 40 | begin 41 | pStatus^:=SCE_REMOTEPLAY_CONNECTION_STATUS_DISCONNECT; 42 | end; 43 | Result:=0; 44 | end; 45 | 46 | function ps4_sceRemoteplayProhibit:Integer; SysV_ABI_CDecl; 47 | begin 48 | Result:=0; 49 | end; 50 | 51 | function Load_libSceRemoteplay(Const name:RawByteString):TElf_node; 52 | var 53 | lib:PLIBRARY; 54 | begin 55 | Result:=TElf_node.Create; 56 | Result.pFileName:=name; 57 | 58 | lib:=Result._add_lib('libSceRemoteplay'); 59 | lib^.set_proc($9354B082431238CF,@ps4_sceRemoteplayInitialize); 60 | lib^.set_proc($C50788AF24D7EDD6,@ps4_sceRemoteplayApprove); 61 | lib^.set_proc($8373CD8D8296AA74,@ps4_sceRemoteplayGetConnectionStatus); 62 | lib^.set_proc($45FD1731547BC4FC,@ps4_sceRemoteplaySetProhibition); 63 | lib^.set_proc($9AB361EFCB41A668,@ps4_sceRemoteplayProhibit); 64 | end; 65 | 66 | initialization 67 | ps4_app.RegistredPreLoad('libSceRemoteplay.prx',@Load_libSceRemoteplay); 68 | 69 | end. 70 | 71 | -------------------------------------------------------------------------------- /src/ps4_libscerudp.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceRudp; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program, 9 | Classes, 10 | SysUtils; 11 | 12 | implementation 13 | 14 | uses 15 | ps4_time; 16 | 17 | function ps4_sceRudpInit(pool:Pointer;poolSize:QWORD):Integer; SysV_ABI_CDecl; 18 | begin 19 | Writeln('sceRudpInit:',HexStr(pool),':',poolSize); 20 | Result:=0; 21 | end; 22 | 23 | function ps4_sceRudpSetEventHandler(handler:Pointer; //SceRudpEventHandler 24 | arg:Pointer):Integer; SysV_ABI_CDecl; 25 | begin 26 | Writeln('sceRudpSetEventHandler:',HexStr(handler),':',HexStr(arg)); 27 | Result:=0; 28 | end; 29 | 30 | function ps4_sceRudpEnableInternalIOThread(stackSize,priority:DWORD):Integer; SysV_ABI_CDecl; 31 | begin 32 | Writeln('sceRudpEnableInternalIOThread:',stackSize,':',priority); 33 | Result:=0; 34 | end; 35 | 36 | function ps4_sceRudpNetFlush:Integer; SysV_ABI_CDecl; 37 | begin 38 | Result:=0; 39 | end; 40 | 41 | function ps4_sceRudpProcessEvents(timeout:QWORD // SceRudpUsec 42 | ):Integer; SysV_ABI_CDecl; 43 | begin 44 | ps4_usleep(timeout); 45 | Result:=0; 46 | end; 47 | 48 | function Load_libSceRudp(Const name:RawByteString):TElf_node; 49 | var 50 | lib:PLIBRARY; 51 | begin 52 | Result:=TElf_node.Create; 53 | Result.pFileName:=name; 54 | lib:=Result._add_lib('libSceRudp'); 55 | 56 | lib^.set_proc($6A6B817C8FC041CE,@ps4_sceRudpInit); 57 | lib^.set_proc($4941157ACF20BE6C,@ps4_sceRudpSetEventHandler); 58 | lib^.set_proc($E8F04DA6C8326B1C,@ps4_sceRudpEnableInternalIOThread); 59 | lib^.set_proc($F8127DB2F0E68D8B,@ps4_sceRudpNetFlush); 60 | lib^.set_proc($F54F66D581F449C4,@ps4_sceRudpProcessEvents); 61 | end; 62 | 63 | initialization 64 | ps4_app.RegistredPreLoad('libSceRudp.prx',@Load_libSceRudp); 65 | 66 | end. 67 | 68 | -------------------------------------------------------------------------------- /src/ps4_libscescreenshot.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceScreenShot; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program, 9 | Classes, 10 | SysUtils; 11 | 12 | implementation 13 | 14 | const 15 | SCE_SCREENSHOT_MAX_FS_PATH =1024; 16 | SCE_SCREENSHOT_MAX_PHOTO_TITLE_LENGTH =64; 17 | SCE_SCREENSHOT_MAX_PHOTO_TITLE_SIZE =SCE_SCREENSHOT_MAX_PHOTO_TITLE_LENGTH*4; 18 | SCE_SCREENSHOT_MAX_GAME_TITLE_LENGTH =64; 19 | SCE_SCREENSHOT_MAX_GAME_TITLE_SIZE =SCE_SCREENSHOT_MAX_GAME_TITLE_LENGTH*4; 20 | SCE_SCREENSHOT_MAX_GAME_COMMENT_LENGTH=128; 21 | SCE_SCREENSHOT_MAX_GAME_COMMENT_SIZE =SCE_SCREENSHOT_MAX_GAME_COMMENT_LENGTH*4; 22 | 23 | //SceScreenShotOrigin 24 | kSceScreenShotOriginLeftTop = 1; 25 | kSceScreenShotOriginLeftCenter = 2; 26 | kSceScreenShotOriginLeftBottom = 3; 27 | kSceScreenShotOriginCenterTop = 4; 28 | kSceScreenShotOriginCenterCenter = 5; 29 | kSceScreenShotOriginCenterBottom = 6; 30 | kSceScreenShotOriginRightTop = 7; 31 | kSceScreenShotOriginRightCenter = 8; 32 | kSceScreenShotOriginRightBottom = 9; 33 | 34 | type 35 | pSceScreenShotParam=^SceScreenShotParam; 36 | SceScreenShotParam=packed record 37 | thisSize :DWORD; 38 | _align :DWORD; 39 | photoTitle :PChar; 40 | gameTitle :PChar; 41 | gameComment:PChar; 42 | reserved :Pointer; 43 | end; 44 | 45 | function ps4_sceScreenShotSetOverlayImage( 46 | filePath:PChar; 47 | offsetx:Integer; 48 | offsety:Integer 49 | ):Integer; SysV_ABI_CDecl; 50 | begin 51 | Writeln('sceScreenShotSetOverlayImage:',filePath); 52 | Result:=0; 53 | end; 54 | 55 | function ps4_sceScreenShotSetOverlayImageWithOrigin( 56 | filePath:PChar; 57 | marginX:Integer; 58 | marginY:Integer; 59 | origin:Integer //SceScreenShotOrigin 60 | ):Integer; SysV_ABI_CDecl; 61 | begin 62 | Writeln('sceScreenShotSetOverlayImageWithOrigin:',filePath); 63 | Result:=0; 64 | end; 65 | 66 | function ps4_sceScreenShotEnable():Integer; SysV_ABI_CDecl; 67 | begin 68 | Writeln('sceScreenShotEnable'); 69 | Result:=0; 70 | end; 71 | 72 | function ps4_sceScreenShotDisable():Integer; SysV_ABI_CDecl; 73 | begin 74 | Writeln('sceScreenShotDisable'); 75 | Result:=0; 76 | end; 77 | 78 | function ps4_sceScreenShotSetParam(param:pSceScreenShotParam):Integer; SysV_ABI_CDecl; 79 | begin 80 | Writeln('sceScreenShotSetParam'); 81 | Result:=0; 82 | end; 83 | 84 | function Load_libSceScreenShot(Const name:RawByteString):TElf_node; 85 | var 86 | lib:PLIBRARY; 87 | begin 88 | Result:=TElf_node.Create; 89 | Result.pFileName:=name; 90 | 91 | lib:=Result._add_lib('libSceScreenShot'); 92 | 93 | lib^.set_proc($6A11E139FF903644,@ps4_sceScreenShotSetOverlayImage); 94 | lib^.set_proc($EF7590E098F49C92,@ps4_sceScreenShotSetOverlayImageWithOrigin); 95 | lib^.set_proc($DB1C54B6E0BF4731,@ps4_sceScreenShotEnable); 96 | lib^.set_proc($B4861FD16E554E2F,@ps4_sceScreenShotDisable); 97 | lib^.set_proc($1BB2A59886052197,@ps4_sceScreenShotSetParam); 98 | end; 99 | 100 | initialization 101 | ps4_app.RegistredPreLoad('libSceScreenShot.prx',@Load_libSceScreenShot); 102 | 103 | end. 104 | 105 | 106 | -------------------------------------------------------------------------------- /src/ps4_libsceshareplay.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceSharePlay; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program, 9 | ps4_libSceNpCommon; 10 | 11 | implementation 12 | 13 | const 14 | SCE_SHARE_PLAY_ERROR_INVALID_ARGS =-2129788927; // 0x810E0001 15 | SCE_SHARE_PLAY_ERROR_OUT_OF_MEMORY =-2129788926; // 0x810E0002 16 | SCE_SHARE_PLAY_ERROR_ALREADY_INITIALIZED=-2129788925; // 0x810E0003 17 | SCE_SHARE_PLAY_ERROR_NOT_INITIALIZED =-2129788924; // 0x810E0004 18 | SCE_SHARE_PLAY_ERROR_FATAL =-2129788923; // 0x810E0005 19 | 20 | SCE_SHARE_PLAY_HEAP_SIZE=6*1024; 21 | 22 | //SceSharePlayConnectionStatus 23 | SCE_SHARE_PLAY_CONNECTION_STATUS_DORMANT =0; 24 | SCE_SHARE_PLAY_CONNECTION_STATUS_READ =1; 25 | SCE_SHARE_PLAY_CONNECTION_STATUS_CONNECTED=2; 26 | 27 | //SceSharePlayControllerMode 28 | SCE_SHARE_PLAY_CONTROLLER_MODE_WATCHING_HOST_PLAY =0; 29 | SCE_SHARE_PLAY_CONTROLLER_MODE_PLAYING_AS_HOST =1; 30 | SCE_SHARE_PLAY_CONTROLLER_MODE_PLAYING_GAME_WITH_HOST=2; 31 | 32 | //SceSharePlayProhibitionMode 33 | SCE_SHARE_PLAY_PROHIBITION_MODE_OFF =0; 34 | SCE_SHARE_PLAY_PROHIBITION_MODE_CONTROL_ONLY =1; 35 | SCE_SHARE_PLAY_PROHIBITION_MODE_CONTROL_SCREEN=2; 36 | 37 | type 38 | pSceSharePlayConnectionInfo=^SceSharePlayConnectionInfo; 39 | SceSharePlayConnectionInfo=packed record 40 | status :Integer; //SceSharePlayConnectionStatus 41 | mode :Integer; //SceSharePlayControllerMode 42 | hostOnlineId :SceNpOnlineId; 43 | visitorOnlineId:SceNpOnlineId; 44 | hostUserId :Integer; //SceUserServiceUserId 45 | visitorUserId :Integer; //SceUserServiceUserId 46 | end; 47 | 48 | pSceSharePlayConnectionInfoA=^SceSharePlayConnectionInfoA; 49 | SceSharePlayConnectionInfoA=packed record 50 | status :Integer; //SceSharePlayConnectionStatus 51 | mode :Integer; //SceSharePlayControllerMode 52 | hostOnlineId :SceNpOnlineId; 53 | visitorOnlineId :SceNpOnlineId; 54 | hostAccountId :SceNpAccountId; 55 | visitorAccountId:SceNpAccountId; 56 | hostUserId :Integer; //SceUserServiceUserId 57 | visitorUserId :Integer; //SceUserServiceUserId 58 | end; 59 | 60 | function ps4_sceSharePlayInitialize(pHeap:Pointer;heapSize:qword):Integer; SysV_ABI_CDecl; 61 | begin 62 | Writeln('sceSharePlayInitialize:',HexStr(pHeap),':',heapSize); 63 | Result:=0; 64 | end; 65 | 66 | function ps4_sceSharePlaySetProhibition(mode:Integer):Integer; SysV_ABI_CDecl; 67 | begin 68 | Writeln('sceSharePlaySetProhibition,mode=',mode); 69 | Result:=0; 70 | end; 71 | 72 | function ps4_sceSharePlayGetCurrentConnectionInfo(pInfo:pSceSharePlayConnectionInfo):Integer; SysV_ABI_CDecl; 73 | begin 74 | if (pInfo=nil) then Exit(SCE_SHARE_PLAY_ERROR_INVALID_ARGS); 75 | 76 | pInfo^:=Default(SceSharePlayConnectionInfo); 77 | Result:=0; 78 | end; 79 | 80 | function ps4_sceSharePlayGetCurrentConnectionInfoA(pInfo:pSceSharePlayConnectionInfoA):Integer; SysV_ABI_CDecl; 81 | begin 82 | if (pInfo=nil) then Exit(SCE_SHARE_PLAY_ERROR_INVALID_ARGS); 83 | 84 | pInfo^:=Default(SceSharePlayConnectionInfoA); 85 | Result:=0; 86 | end; 87 | 88 | function Load_libSceSharePlay(Const name:RawByteString):TElf_node; 89 | var 90 | lib:PLIBRARY; 91 | begin 92 | Result:=TElf_node.Create; 93 | Result.pFileName:=name; 94 | 95 | lib:=Result._add_lib('libSceSharePlay'); 96 | 97 | lib^.set_proc($8ACAEEAAD86961CC,@ps4_sceSharePlayInitialize); 98 | lib^.set_proc($728D8D0A3FFFA677,@ps4_sceSharePlaySetProhibition); 99 | lib^.set_proc($38EACB281D1B483B,@ps4_sceSharePlayGetCurrentConnectionInfo); 100 | lib^.set_proc($F8C09726559D8BEB,@ps4_sceSharePlayGetCurrentConnectionInfoA); 101 | end; 102 | 103 | initialization 104 | ps4_app.RegistredPreLoad('libSceSharePlay.prx',@Load_libSceSharePlay); 105 | 106 | end. 107 | 108 | -------------------------------------------------------------------------------- /src/ps4_libsceshareutility.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceShareUtility; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program, 9 | Classes, 10 | SysUtils; 11 | 12 | const 13 | SCE_SHARE_UTILITY_HEAP_SIZE=128*1024; 14 | 15 | implementation 16 | 17 | function ps4_sceShareUtilityInitializeEx2(functionFlag:QWORD; 18 | heapSize:QWORD; 19 | threadPriority:Integer; 20 | affinityMask:QWORD):Integer; SysV_ABI_CDecl; 21 | begin 22 | Result:=0; 23 | end; 24 | 25 | function ps4_sceShareUtilityAdvanceInitialize(functionFlag:QWORD; 26 | heapSize:QWORD; 27 | threadPriority:Integer; 28 | affinityMask:QWORD):Integer; SysV_ABI_CDecl; 29 | begin 30 | Result:=0; 31 | end; 32 | 33 | function ps4_sceShareUtilityAdvanceSetUploadContentData(const contentData:PChar; 34 | contentDataLength:QWORD):Integer; SysV_ABI_CDecl; 35 | begin 36 | Result:=0; 37 | end; 38 | 39 | function Load_libSceShareUtility(Const name:RawByteString):TElf_node; 40 | var 41 | lib:PLIBRARY; 42 | begin 43 | Result:=TElf_node.Create; 44 | Result.pFileName:=name; 45 | lib:=Result._add_lib('libSceShareUtility'); 46 | lib^.set_proc($8FB0E56A50731E1F,@ps4_sceShareUtilityInitializeEx2); 47 | lib^.set_proc($BB86C21A4AA1381E,@ps4_sceShareUtilityAdvanceInitialize); 48 | lib^.set_proc($91AAE72616A474A8,@ps4_sceShareUtilityAdvanceSetUploadContentData); 49 | end; 50 | 51 | initialization 52 | ps4_app.RegistredPreLoad('libSceShareUtility.prx',@Load_libSceShareUtility); 53 | 54 | end. 55 | 56 | -------------------------------------------------------------------------------- /src/ps4_libscesocialscreen.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceSocialScreen; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program; 9 | 10 | implementation 11 | 12 | function ps4_sceSocialScreenInitialize():Integer; SysV_ABI_CDecl; 13 | begin 14 | Result:=0; 15 | end; 16 | 17 | function Load_libSceSocialScreen(Const name:RawByteString):TElf_node; 18 | var 19 | lib:PLIBRARY; 20 | begin 21 | Result:=TElf_node.Create; 22 | Result.pFileName:=name; 23 | 24 | lib:=Result._add_lib('libSceSocialScreen'); 25 | lib^.set_proc($A48EE81523CFEB90,@ps4_sceSocialScreenInitialize); 26 | end; 27 | 28 | initialization 29 | ps4_app.RegistredPreLoad('libSceSocialScreen.prx',@Load_libSceSocialScreen); 30 | 31 | end. 32 | 33 | -------------------------------------------------------------------------------- /src/ps4_libscesyscore.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceSysCore; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program; 9 | 10 | implementation 11 | 12 | function ps4_sceApplicationInitialize():Integer; SysV_ABI_CDecl; 13 | begin 14 | Writeln('sceApplicationInitialize'); 15 | Result:=0; 16 | end; 17 | 18 | function ps4_sceApplicationSetCanvasHandle(canvasId:Byte;handle:DWORD):Integer; SysV_ABI_CDecl; 19 | begin 20 | Result:=0; 21 | end; 22 | 23 | function Load_libSceSysCore(Const name:RawByteString):TElf_node; 24 | var 25 | lib:PLIBRARY; 26 | begin 27 | Result:=TElf_node.Create; 28 | Result.pFileName:=name; 29 | 30 | lib:=Result._add_lib('libSceSysCore'); 31 | 32 | lib^.set_proc($5C5608B4EC52EABD,@ps4_sceApplicationInitialize); 33 | lib^.set_proc($A931E269B7C4BA4C,@ps4_sceApplicationSetCanvasHandle); 34 | end; 35 | 36 | initialization 37 | ps4_app.RegistredPreLoad('libSceSysCore.prx',@Load_libSceSysCore); 38 | 39 | end. 40 | 41 | -------------------------------------------------------------------------------- /src/ps4_libsceusbd.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceUsbd; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | sys_types, 9 | ps4_program; 10 | 11 | implementation 12 | 13 | const 14 | SCE_USBD_ERROR_NO_DEVICE=$80240004; 15 | SCE_USBD_ERROR_NOT_FOUND=$80240005; 16 | 17 | type 18 | SceUsbdDevice=Pointer; 19 | PSceUsbdDevice=^SceUsbdDevice; 20 | 21 | pSceUsbdDeviceHandle=^SceUsbdDeviceHandle; 22 | SceUsbdDeviceHandle=packed record 23 | end; 24 | 25 | function ps4_sceUsbdInit:Integer; SysV_ABI_CDecl; 26 | begin 27 | Writeln('sceUsbdInit'); 28 | Result:=SCE_USBD_ERROR_NOT_FOUND; 29 | end; 30 | 31 | function ps4_sceUsbdGetDeviceList(list:PSceUsbdDevice):Integer; SysV_ABI_CDecl; 32 | begin 33 | Result:=0; 34 | end; 35 | 36 | procedure ps4_sceUsbdFreeDeviceList(list:PSceUsbdDevice;unrefDevices:Integer); SysV_ABI_CDecl; 37 | begin 38 | end; 39 | 40 | function ps4_sceUsbdHandleEventsTimeout(tv:Ptimeval):Integer; SysV_ABI_CDecl; 41 | begin 42 | Result:=0; 43 | end; 44 | 45 | function ps4_sceUsbdOpenDeviceWithVidPid(vendorId:Word;productId:Word):pSceUsbdDeviceHandle; SysV_ABI_CDecl; 46 | begin 47 | Result:=nil; 48 | end; 49 | 50 | function Load_libSceUsbd(Const name:RawByteString):TElf_node; 51 | var 52 | lib:PLIBRARY; 53 | begin 54 | Result:=TElf_node.Create; 55 | Result.pFileName:=name; 56 | 57 | lib:=Result._add_lib('libSceUsbd'); 58 | 59 | lib^.set_proc($4CE860ECFEA44C7E,@ps4_sceUsbdInit); 60 | lib^.set_proc($F2A07D02BE0FE677,@ps4_sceUsbdGetDeviceList); 61 | lib^.set_proc($110E9208B32ACE43,@ps4_sceUsbdFreeDeviceList); 62 | lib^.set_proc($FB053A086B997169,@ps4_sceUsbdHandleEventsTimeout); 63 | lib^.set_proc($BEB417611A351B09,@ps4_sceUsbdOpenDeviceWithVidPid); 64 | end; 65 | 66 | initialization 67 | ps4_app.RegistredPreLoad('libSceUsbd.prx',@Load_libSceUsbd); 68 | 69 | end. 70 | -------------------------------------------------------------------------------- /src/ps4_libsceusbstorage.pas: -------------------------------------------------------------------------------- 1 | unit ps4_libSceUsbStorage; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_program, 9 | Classes, 10 | SysUtils, 11 | sys_pthread; 12 | 13 | implementation 14 | 15 | function ps4_sceUsbStorageInit(pAttr:p_pthread_attr_t):Integer; SysV_ABI_CDecl; 16 | begin 17 | Result:=0; 18 | end; 19 | 20 | function Load_libSceUsbStorage(Const name:RawByteString):TElf_node; 21 | var 22 | lib:PLIBRARY; 23 | begin 24 | Result:=TElf_node.Create; 25 | Result.pFileName:=name; 26 | 27 | lib:=Result._add_lib('libSceUsbStorage'); 28 | lib^.set_proc($0430D9C05E64B937,@ps4_sceUsbStorageInit); 29 | end; 30 | 31 | initialization 32 | ps4_app.RegistredPreLoad('libSceUsbStorage.prx' ,@Load_libSceUsbStorage); 33 | 34 | end. 35 | 36 | -------------------------------------------------------------------------------- /static/libkernel32.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red-prig/fpPS4/04cefd43e6fddd1ab033e7980cd356d14c964905/static/libkernel32.a -------------------------------------------------------------------------------- /static/libmingwex.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red-prig/fpPS4/04cefd43e6fddd1ab033e7980cd356d14c964905/static/libmingwex.a -------------------------------------------------------------------------------- /static/libmsvcrt.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red-prig/fpPS4/04cefd43e6fddd1ab033e7980cd356d14c964905/static/libmsvcrt.a -------------------------------------------------------------------------------- /static/libportaudio.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red-prig/fpPS4/04cefd43e6fddd1ab033e7980cd356d14c964905/static/libportaudio.a -------------------------------------------------------------------------------- /static/libwinmm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red-prig/fpPS4/04cefd43e6fddd1ab033e7980cd356d14c964905/static/libwinmm.a -------------------------------------------------------------------------------- /sys/sys_crt.pas: -------------------------------------------------------------------------------- 1 | unit sys_crt; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | windows, 9 | sys_pthread; 10 | 11 | var 12 | StdWrn:Text; 13 | 14 | Procedure sys_crt_init; 15 | Procedure CrtOutWriteDirect(T:PText;data:Pointer;len:SizeInt); 16 | 17 | implementation 18 | 19 | uses 20 | sys_kernel, 21 | sys_signal; 22 | 23 | var 24 | StdOutLock:TRTLCriticalSection; 25 | StdOutColor:Word; 26 | 27 | const 28 | StdErrColor=FOREGROUND_RED; 29 | StdWrnColor=14; 30 | 31 | function GetConsoleTextAttribute(hConsoleOutput:HANDLE;var wAttributes:WORD):WINBOOL; 32 | var 33 | info:CONSOLE_SCREEN_BUFFER_INFO; 34 | begin 35 | Result:=GetConsoleScreenBufferInfo(hConsoleOutput,@info); 36 | if Result then 37 | begin 38 | wAttributes:=info.wAttributes 39 | end; 40 | end; 41 | 42 | function GetConsoleCursorPosition(hConsoleOutput:HANDLE;var dwCursorPosition:COORD):WINBOOL; 43 | var 44 | info:CONSOLE_SCREEN_BUFFER_INFO; 45 | begin 46 | Result:=GetConsoleScreenBufferInfo(hConsoleOutput,@info); 47 | if Result then 48 | begin 49 | dwCursorPosition:=info.dwCursorPosition; 50 | end; 51 | end; 52 | 53 | Procedure _CrtOutWrite(var t:TextRec;data:Pointer;len:SizeInt); 54 | var 55 | n:DWORD; 56 | Begin 57 | if (data=nil) or (len=0) then exit; 58 | n:=0; 59 | 60 | _sig_lock(SL_NOINTRRUP); 61 | 62 | if Boolean(t.UserData[2]) then //IsChar 63 | begin 64 | EnterCriticalSection(StdOutLock); 65 | //Text 66 | SetConsoleTextAttribute(t.Handle,t.UserData[1]); 67 | WriteConsole(t.Handle, 68 | data, 69 | len, 70 | @n, 71 | nil); 72 | SetConsoleTextAttribute(t.Handle,StdOutColor); 73 | //Text 74 | LeaveCriticalSection(StdOutLock); 75 | end else 76 | begin 77 | WriteFile(t.Handle, 78 | data^, 79 | len, 80 | n, 81 | nil); 82 | end; 83 | 84 | _sig_unlock(SL_NOINTRRUP); 85 | end; 86 | 87 | Procedure CrtOutWrite(var t:TextRec); 88 | Begin 89 | _CrtOutWrite(t,t.Bufptr,t.BufPos); 90 | t.BufPos:=0; 91 | end; 92 | 93 | Procedure CrtOutWriteDirect(T:PText;data:Pointer;len:SizeInt); 94 | begin 95 | if (T=nil) then Exit; 96 | _CrtOutWrite(TextRec(T^),data,len); 97 | end; 98 | 99 | Procedure CrtClose(Var F:TextRec); 100 | Begin 101 | F.Mode:=fmClosed; 102 | end; 103 | 104 | Procedure CrtOpenOut(Var F:TextRec); 105 | var 106 | _type:Shortint; 107 | IsChar:Boolean; 108 | Begin 109 | _type:=Shortint(TextRec(F).UserData[2]); 110 | 111 | TextRec(F).Handle:=GetStdHandle(_type); 112 | 113 | IsChar:=SwGetFileType(TextRec(F).Handle)=FILE_TYPE_CHAR; 114 | TextRec(F).UserData[2]:=ord(IsChar); 115 | 116 | TextRec(F).InOutFunc:=@CrtOutWrite; 117 | TextRec(F).FlushFunc:=@CrtOutWrite; 118 | TextRec(F).CloseFunc:=@CrtClose; 119 | end; 120 | 121 | procedure AssignCrt(var F:Text;_type:DWORD;clr:Byte); 122 | begin 123 | Assign(F,''); 124 | TextRec(F).OpenFunc:=@CrtOpenOut; 125 | TextRec(F).UserData[1]:=clr; 126 | TextRec(F).UserData[2]:=Shortint(Integer(_type)); 127 | end; 128 | 129 | Procedure sys_crt_init; 130 | begin 131 | tcb_thread:=nil; //need zero tcb 132 | 133 | AssignCrt(Output ,STD_OUTPUT_HANDLE,StdOutColor); 134 | AssignCrt(StdOut ,STD_OUTPUT_HANDLE,StdOutColor); 135 | AssignCrt(ErrOutput,STD_ERROR_HANDLE ,StdErrColor); 136 | AssignCrt(StdErr ,STD_ERROR_HANDLE ,StdErrColor); 137 | 138 | Rewrite(Output); 139 | Rewrite(StdOut); 140 | Rewrite(ErrOutput); 141 | Rewrite(StdErr); 142 | end; 143 | 144 | Procedure _sys_crt_init; 145 | var 146 | F:Thandle; 147 | begin 148 | StdOutColor:=7; 149 | F:=GetStdHandle(STD_OUTPUT_HANDLE); 150 | if (SwGetFileType(F)=FILE_TYPE_CHAR) then 151 | begin 152 | GetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),StdOutColor); 153 | end; 154 | // 155 | AssignCrt(StdWrn,STD_OUTPUT_HANDLE,StdWrnColor); 156 | Rewrite(StdWrn); 157 | end; 158 | 159 | procedure _sys_crt_fini; 160 | var 161 | F:Thandle; 162 | begin 163 | F:=GetStdHandle(STD_OUTPUT_HANDLE); 164 | if (SwGetFileType(F)=FILE_TYPE_CHAR) then 165 | begin 166 | SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),StdOutColor); 167 | end; 168 | end; 169 | 170 | initialization 171 | AddExitProc(@_sys_crt_fini); 172 | InitCriticalSection(StdOutLock); 173 | _sys_crt_init; 174 | 175 | end. 176 | 177 | -------------------------------------------------------------------------------- /tag.inc: -------------------------------------------------------------------------------- 1 | '' 2 | -------------------------------------------------------------------------------- /third_party_gui/GUI/main.py: -------------------------------------------------------------------------------- 1 | import tkinter 2 | import tkinter.messagebox 3 | import tkinter.filedialog 4 | import os 5 | import os.path 6 | 7 | fpps4 = "" 8 | game = "" 9 | #create open fpps4 dialog 10 | def open_fpps4(): 11 | global fpps4 12 | file_path = tkinter.filedialog.askopenfilename(title="Select the fpps4.exe", filetypes=[("Applications", "*.exe")]) 13 | if file_path: 14 | fpps4_path_label['text'] = file_path 15 | fpps4 = file_path 16 | else: 17 | fpps4_path_label['text'] = "No file selected" 18 | #create open game dialog 19 | def open_game(): 20 | global game 21 | file_path = tkinter.filedialog.askdirectory(title="Select the games Folder") 22 | if file_path: 23 | game_path_label['text'] = file_path 24 | game = file_path 25 | else: 26 | game_path_label['text'] = "No file selected" 27 | #autodetect 28 | def autodetect(): 29 | global fpps4 30 | for dirpath, dirnames, filenames in os.walk("../../"): 31 | for filename in [f for f in filenames if f.endswith(".exe")]: 32 | if filename == "fpPS4.exe": 33 | fpps4 = os.path.abspath(os.path.join(dirpath, filename)) 34 | fpps4_path_label['text'] = fpps4 35 | tkinter.messagebox.showinfo(title="Found fpPS4!", message=fpps4) 36 | #rungame 37 | def rungame(): 38 | global fpps4 39 | global game 40 | if fpps4 == "": 41 | autodetect() 42 | if game == "": 43 | open_game() 44 | if game != "" and fpps4 != "": 45 | print(fpps4 + " -e " + game + "/eboot.bin") 46 | os.system(fpps4 + " -e " + game + "/eboot.bin") 47 | else: 48 | tkinter.messagebox.showinfo(title="Error!", message="Please select a game and the fpPS4 folder!") 49 | 50 | #create main window 51 | root = tkinter.Tk() 52 | root.title("fpPS4 GUI") 53 | #open game button 54 | open_game_button = tkinter.Button(root, text="Open game folder", command=open_game) 55 | open_game_button.grid(row=0, column=0) 56 | #open fpps4 button 57 | open_fpps4_button = tkinter.Button(root, text="Open fpps4 file", command=open_fpps4) 58 | open_fpps4_button.grid(row=0, column=2) 59 | #autodetect fpps4 button 60 | open_fpps4_button = tkinter.Button(root, text="Autodedect fpps4", command=autodetect) 61 | open_fpps4_button.grid(row=0, column=4) 62 | #rungame button 63 | open_fpps4_button = tkinter.Button(root, text="Run!", command=rungame) 64 | open_fpps4_button.grid(row=0, column=6) 65 | #print selected game path 66 | game_path_label = tkinter.Label(root, text="No game selected") 67 | game_path_label.grid(row=2, column=0, columnspan=2) 68 | #print selected fpps4 path 69 | fpps4_path_label = tkinter.Label(root, text="fpPS4 not selected") 70 | fpps4_path_label.grid(row=4, column=0, columnspan=2) 71 | #quit 72 | quit_button = tkinter.Button(root, text="Quit", command=root.destroy) 73 | quit_button.grid(row=6, column=6, columnspan=2) 74 | #run main loop 75 | root.mainloop() -------------------------------------------------------------------------------- /third_party_gui/GUI/readme.txt: -------------------------------------------------------------------------------- 1 | Author: https://github.com/GameTec-live 2 | -------------------------------------------------------------------------------- /third_party_gui/README.md: -------------------------------------------------------------------------------- 1 | 2 | ### Various graphical interfaces provided by other developers: 3 | 4 | # 5 | | Name | Author | 6 | | ------------- | ------------- | 7 | | [frofpp4](frofpp4) | [SlrHui](https://github.com/SlrHui) | 8 | | [fpPS4Fro](fpPS4Fro) | [SlrHui](https://github.com/SlrHui) | 9 | | [GUI](GUI) | [GameTec-live](https://github.com/GameTec-live) | 10 | | [fpPS4-Temmie-s-Launcher](https://github.com/themitosan/fpPS4-Temmie-s-Launcher) | [themitosan](https://github.com/themitosan) | 11 | -------------------------------------------------------------------------------- /third_party_gui/fpPS4Fro/AboutBox1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Linq; 6 | using System.Reflection; 7 | using System.Threading.Tasks; 8 | using System.Windows.Forms; 9 | 10 | namespace fpPS4Fro 11 | { 12 | partial class AboutBox1 : Form 13 | { 14 | public AboutBox1() 15 | { 16 | InitializeComponent(); 17 | this.Text = String.Format("Info über {0}", AssemblyTitle); 18 | 19 | } 20 | 21 | #region Assemblyattributaccessoren 22 | 23 | public string AssemblyTitle 24 | { 25 | get 26 | { 27 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false); 28 | if (attributes.Length > 0) 29 | { 30 | AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0]; 31 | if (titleAttribute.Title != "") 32 | { 33 | return titleAttribute.Title; 34 | } 35 | } 36 | return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase); 37 | } 38 | } 39 | 40 | public string AssemblyVersion 41 | { 42 | get 43 | { 44 | return Assembly.GetExecutingAssembly().GetName().Version.ToString(); 45 | } 46 | } 47 | 48 | public string AssemblyDescription 49 | { 50 | get 51 | { 52 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); 53 | if (attributes.Length == 0) 54 | { 55 | return ""; 56 | } 57 | return ((AssemblyDescriptionAttribute)attributes[0]).Description; 58 | } 59 | } 60 | 61 | public string AssemblyProduct 62 | { 63 | get 64 | { 65 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false); 66 | if (attributes.Length == 0) 67 | { 68 | return ""; 69 | } 70 | return ((AssemblyProductAttribute)attributes[0]).Product; 71 | } 72 | } 73 | 74 | public string AssemblyCopyright 75 | { 76 | get 77 | { 78 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); 79 | if (attributes.Length == 0) 80 | { 81 | return ""; 82 | } 83 | return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; 84 | } 85 | } 86 | 87 | public string AssemblyCompany 88 | { 89 | get 90 | { 91 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false); 92 | if (attributes.Length == 0) 93 | { 94 | return ""; 95 | } 96 | return ((AssemblyCompanyAttribute)attributes[0]).Company; 97 | } 98 | } 99 | #endregion 100 | 101 | private void okButton_Click(object sender, EventArgs e) 102 | { 103 | Close(); 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /third_party_gui/fpPS4Fro/AboutBox1.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | text/microsoft-resx 50 | 51 | 52 | 2.0 53 | 54 | 55 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 56 | 57 | 58 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 59 | 60 | 61 | fpPS4 Parameters: 62 | 63 | -e <name> // decrypted elf or self file name 64 | -f <name> //folder of app (/app0) 65 | -p <name> //folder of patch (/app1) 66 | -s <name> //savedata path 67 | -h <name> //enable hack 68 | 69 | DEPTH_DISABLE_HACK // disable depth buffer 70 | COMPUTE_DISABLE_HACK //disable compute shaders 71 | MEMORY_BOUND_HACK //limit the amount of GPU allocated memory (iGPU) 72 | IMAGE_TEST_HACK //never reload texture 73 | DISABLE_SRGB_HACK //disables hacked display of SRGB 74 | 75 | -------------------------------------------------------------------------------- /third_party_gui/fpPS4Fro/Form2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using Ini; 11 | 12 | namespace fpPS4Fro 13 | { 14 | public partial class Form2 : Form 15 | { 16 | string inipath = System.IO.Directory.GetCurrentDirectory(); 17 | public Form2() 18 | { 19 | InitializeComponent(); 20 | } 21 | 22 | private void button1_Click(object sender, EventArgs e) 23 | { 24 | if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) 25 | { 26 | textBox1.Text = folderBrowserDialog1.SelectedPath; 27 | } 28 | } 29 | 30 | private void button2_Click(object sender, EventArgs e) 31 | { 32 | if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) 33 | { 34 | textBox2.Text = folderBrowserDialog1.SelectedPath; 35 | } 36 | } 37 | 38 | private void button3_Click(object sender, EventArgs e) 39 | { 40 | string emu = ""; 41 | string games = ""; 42 | string sd = ""; 43 | 44 | emu = textBox1.Text.ToString(); 45 | games = textBox2.Text.ToString(); 46 | sd = textBox3.Text.ToString(); 47 | IniFile ini = new IniFile(inipath + @"\fpps4fro.ini"); 48 | ini.IniWriteValue("DIR","emu",emu ); 49 | ini.IniWriteValue("DIR","games", games); 50 | ini.IniWriteValue("DIR", "savedata", sd); 51 | Close(); 52 | } 53 | 54 | private void button4_Click(object sender, EventArgs e) 55 | { 56 | Close(); 57 | } 58 | 59 | private void Form2_Load(object sender, EventArgs e) 60 | { 61 | IniFile ini = new IniFile(inipath + @"\fpps4fro.ini"); 62 | textBox1.Text = ini.IniReadValue("DIR", "emu"); 63 | textBox2.Text = ini.IniReadValue("DIR", "games"); 64 | textBox3.Text = ini.IniReadValue("DIR", "savedata"); 65 | } 66 | 67 | private void button5_Click(object sender, EventArgs e) 68 | { 69 | if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) 70 | { 71 | textBox3.Text = folderBrowserDialog1.SelectedPath; 72 | } 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /third_party_gui/fpPS4Fro/Form2.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | text/microsoft-resx 50 | 51 | 52 | 2.0 53 | 54 | 55 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 56 | 57 | 58 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 59 | 60 | 61 | 17, 17 62 | 63 | -------------------------------------------------------------------------------- /third_party_gui/fpPS4Fro/Ini.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | 6 | namespace Ini 7 | { 8 | /// 9 | /// Create a New INI file to store or load data 10 | /// 11 | public class IniFile 12 | { 13 | public string path; 14 | 15 | [DllImport("kernel32")] 16 | private static extern long WritePrivateProfileString(string section,string key,string val,string filePath); 17 | [DllImport("kernel32")] 18 | private static extern int GetPrivateProfileString(string section,string key,string def,StringBuilder retVal,int size,string filePath); 19 | 20 | /// 21 | /// INIFile Constructor. 22 | /// 23 | /// 24 | public IniFile(string INIPath) 25 | { 26 | path = INIPath; 27 | } 28 | /// 29 | /// Write Data to the INI File 30 | /// 31 | /// 32 | /// Section name 33 | /// 34 | /// Key Name 35 | /// 36 | /// Value Name 37 | public void IniWriteValue(string Section,string Key,string Value) 38 | { 39 | WritePrivateProfileString(Section,Key,Value,this.path); 40 | } 41 | 42 | /// 43 | /// Read Data Value From the Ini File 44 | /// 45 | /// 46 | /// 47 | /// 48 | /// 49 | public string IniReadValue(string Section,string Key) 50 | { 51 | StringBuilder temp = new StringBuilder(255); 52 | int i = GetPrivateProfileString(Section,Key,"",temp,255,this.path); 53 | return temp.ToString(); 54 | 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /third_party_gui/fpPS4Fro/Program.cs: -------------------------------------------------------------------------------- 1 | namespace fpPS4Fro 2 | { 3 | internal static class Program 4 | { 5 | /// 6 | /// The main entry point for the application. 7 | /// 8 | [STAThread] 9 | static void Main() 10 | { 11 | // To customize application configuration such as set high DPI settings or default font, 12 | // see https://aka.ms/applicationconfiguration. 13 | ApplicationConfiguration.Initialize(); 14 | Application.Run(new Form1()); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /third_party_gui/fpPS4Fro/fpPS4Fro.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net6.0-windows 6 | enable 7 | true 8 | enable 9 | 10 | 11 | 12 | 13 | True 14 | True 15 | Resources.resx 16 | 17 | 18 | 19 | 20 | 21 | ResXFileCodeGenerator 22 | Resources.Designer.cs 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /third_party_gui/fpPS4Fro/fpPS4Fro.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Form 6 | 7 | 8 | Form 9 | 10 | 11 | Form 12 | 13 | 14 | -------------------------------------------------------------------------------- /third_party_gui/fpPS4Fro/readme.txt: -------------------------------------------------------------------------------- 1 | Author: https://github.com/SlrHui 2 | -------------------------------------------------------------------------------- /third_party_gui/frofpp4/project1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red-prig/fpPS4/04cefd43e6fddd1ab033e7980cd356d14c964905/third_party_gui/frofpp4/project1.ico -------------------------------------------------------------------------------- /third_party_gui/frofpp4/project1.lpi: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | <Scaled Value="True"/> 10 | <ResourceType Value="res"/> 11 | <UseXPManifest Value="True"/> 12 | <XPManifest> 13 | <DpiAware Value="True"/> 14 | </XPManifest> 15 | <Icon Value="0"/> 16 | </General> 17 | <BuildModes> 18 | <Item Name="Default" Default="True"/> 19 | </BuildModes> 20 | <PublishOptions> 21 | <Version Value="2"/> 22 | <UseFileFilters Value="True"/> 23 | </PublishOptions> 24 | <RunParams> 25 | <FormatVersion Value="2"/> 26 | </RunParams> 27 | <RequiredPackages> 28 | <Item> 29 | <PackageName Value="FCL"/> 30 | </Item> 31 | <Item> 32 | <PackageName Value="LazUtils"/> 33 | </Item> 34 | <Item> 35 | <PackageName Value="laz.virtualtreeview_package"/> 36 | </Item> 37 | <Item> 38 | <PackageName Value="LazControls"/> 39 | </Item> 40 | <Item> 41 | <PackageName Value="LCL"/> 42 | </Item> 43 | </RequiredPackages> 44 | <Units> 45 | <Unit> 46 | <Filename Value="project1.lpr"/> 47 | <IsPartOfProject Value="True"/> 48 | </Unit> 49 | <Unit> 50 | <Filename Value="unit1.pas"/> 51 | <IsPartOfProject Value="True"/> 52 | <ComponentName Value="Form1"/> 53 | <HasResources Value="True"/> 54 | <ResourceBaseClass Value="Form"/> 55 | <UnitName Value="Unit1"/> 56 | </Unit> 57 | <Unit> 58 | <Filename Value="unit2.pas"/> 59 | <IsPartOfProject Value="True"/> 60 | <ComponentName Value="Form2"/> 61 | <HasResources Value="True"/> 62 | <ResourceBaseClass Value="Form"/> 63 | <UnitName Value="Unit2"/> 64 | </Unit> 65 | <Unit> 66 | <Filename Value="unit3.pas"/> 67 | <IsPartOfProject Value="True"/> 68 | <ComponentName Value="Form3"/> 69 | <HasResources Value="True"/> 70 | <ResourceBaseClass Value="Form"/> 71 | <UnitName Value="Unit3"/> 72 | </Unit> 73 | </Units> 74 | </ProjectOptions> 75 | <CompilerOptions> 76 | <Version Value="11"/> 77 | <PathDelim Value="\"/> 78 | <Target> 79 | <Filename Value="project1"/> 80 | </Target> 81 | <SearchPaths> 82 | <IncludeFiles Value="$(ProjOutDir)"/> 83 | <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 84 | </SearchPaths> 85 | <Linking> 86 | <Debugging> 87 | <DebugInfoType Value="dsDwarf3"/> 88 | </Debugging> 89 | <Options> 90 | <Win32> 91 | <GraphicApplication Value="True"/> 92 | </Win32> 93 | </Options> 94 | </Linking> 95 | </CompilerOptions> 96 | <Debugging> 97 | <Exceptions> 98 | <Item> 99 | <Name Value="EAbort"/> 100 | </Item> 101 | <Item> 102 | <Name Value="ECodetoolError"/> 103 | </Item> 104 | <Item> 105 | <Name Value="EFOpenError"/> 106 | </Item> 107 | </Exceptions> 108 | </Debugging> 109 | </CONFIG> 110 | -------------------------------------------------------------------------------- /third_party_gui/frofpp4/project1.lpr: -------------------------------------------------------------------------------- 1 | program project1; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | uses 6 | {$IFDEF UNIX} 7 | cthreads, 8 | {$ENDIF} 9 | {$IFDEF HASAMIGA} 10 | athreads, 11 | {$ENDIF} 12 | Interfaces, // this includes the LCL widgetset 13 | Forms, Unit1, lazcontrols, Unit2, Unit3 14 | { you can add units after this }; 15 | 16 | {$R *.res} 17 | 18 | begin 19 | RequireDerivedFormResource:=True; 20 | Application.Scaled:=True; 21 | Application.Initialize; 22 | Application.CreateForm(TForm1, Form1); 23 | Application.CreateForm(TForm2, Form2); 24 | Application.CreateForm(TForm3, Form3); 25 | Application.Run; 26 | end. 27 | 28 | -------------------------------------------------------------------------------- /third_party_gui/frofpp4/project1.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red-prig/fpPS4/04cefd43e6fddd1ab033e7980cd356d14c964905/third_party_gui/frofpp4/project1.res -------------------------------------------------------------------------------- /third_party_gui/frofpp4/readme.txt: -------------------------------------------------------------------------------- 1 | Author: https://github.com/SlrHui 2 | -------------------------------------------------------------------------------- /third_party_gui/frofpp4/unit2.lfm: -------------------------------------------------------------------------------- 1 | object Form2: TForm2 2 | Left = 874 3 | Height = 461 4 | Top = 313 5 | Width = 693 6 | Caption = 'Options' 7 | ClientHeight = 461 8 | ClientWidth = 693 9 | DesignTimePPI = 120 10 | OnActivate = FormActivate 11 | OnCreate = FormCreate 12 | OnShow = FormShow 13 | LCLVersion = '2.2.2.0' 14 | object Button1: TButton 15 | Left = 60 16 | Height = 31 17 | Top = 400 18 | Width = 94 19 | Caption = 'Save' 20 | OnClick = Button1Click 21 | TabOrder = 0 22 | end 23 | object Button2: TButton 24 | Left = 558 25 | Height = 31 26 | Top = 400 27 | Width = 94 28 | Caption = 'Close' 29 | OnClick = Button2Click 30 | TabOrder = 1 31 | end 32 | object GroupBox1: TGroupBox 33 | Left = 24 34 | Height = 211 35 | Top = 32 36 | Width = 639 37 | Caption = 'Directories' 38 | ClientHeight = 186 39 | ClientWidth = 635 40 | TabOrder = 2 41 | object Button3: TButton 42 | Left = 16 43 | Height = 31 44 | Top = 24 45 | Width = 94 46 | Caption = 'Emu' 47 | OnClick = Button3Click 48 | TabOrder = 0 49 | end 50 | object Button4: TButton 51 | Left = 16 52 | Height = 31 53 | Top = 72 54 | Width = 94 55 | Caption = 'Games' 56 | OnClick = Button4Click 57 | TabOrder = 1 58 | end 59 | object Edit1: TEdit 60 | Left = 152 61 | Height = 28 62 | Top = 24 63 | Width = 452 64 | TabOrder = 2 65 | Text = 'Edit1' 66 | end 67 | object Edit2: TEdit 68 | Left = 152 69 | Height = 28 70 | Top = 72 71 | Width = 452 72 | TabOrder = 3 73 | Text = 'Edit2' 74 | end 75 | end 76 | object SelectDirectoryDialog1: TSelectDirectoryDialog 77 | Left = 24 78 | Top = 8 79 | end 80 | end 81 | -------------------------------------------------------------------------------- /third_party_gui/frofpp4/unit2.pas: -------------------------------------------------------------------------------- 1 | unit Unit2; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, ActnList, 9 | ExtCtrls, StdCtrls, ExtendedNotebook, INIFiles; 10 | 11 | type 12 | 13 | { TForm2 } 14 | 15 | TForm2 = class(TForm) 16 | Button1: TButton; 17 | Button2: TButton; 18 | Button3: TButton; 19 | Button4: TButton; 20 | Edit1: TEdit; 21 | Edit2: TEdit; 22 | GroupBox1: TGroupBox; 23 | SelectDirectoryDialog1: TSelectDirectoryDialog; 24 | procedure Button1Click(Sender: TObject); 25 | procedure Button2Click(Sender: TObject); 26 | procedure Button3Click(Sender: TObject); 27 | procedure Button4Click(Sender: TObject); 28 | procedure FormActivate(Sender: TObject); 29 | procedure FormCreate(Sender: TObject); 30 | procedure FormShow(Sender: TObject); 31 | private 32 | 33 | public 34 | 35 | end; 36 | 37 | var 38 | Form2: TForm2; 39 | 40 | implementation 41 | 42 | {$R *.lfm} 43 | 44 | { TForm2 } 45 | 46 | procedure TForm2.Button2Click(Sender: TObject); 47 | begin 48 | Close(); 49 | end; 50 | 51 | procedure TForm2.Button1Click(Sender: TObject); 52 | var 53 | INI: TINIFile; 54 | path: string; 55 | path1: string; 56 | home: string; 57 | begin 58 | home := GetCurrentDir; 59 | home := home + '\Frofpp4.ini'; 60 | INI := TIniFile.Create(home); 61 | path := Edit1.Text; 62 | path1 := Edit2.Text; 63 | 64 | INI.WriteString('PFAD', 'path', path); 65 | INI.WriteString('PFAD', 'path1', path1); 66 | INI.free; 67 | end; 68 | 69 | procedure TForm2.Button3Click(Sender: TObject); 70 | var 71 | path: string; 72 | begin 73 | if SelectDirectoryDialog1.Execute then 74 | begin 75 | path := SelectDirectoryDialog1.FileName; 76 | Edit1.Text := path; 77 | end; 78 | end; 79 | 80 | procedure TForm2.Button4Click(Sender: TObject); 81 | var path: string; 82 | begin 83 | if SelectDirectoryDialog1.Execute then 84 | begin 85 | path := SelectDirectoryDialog1.FileName; 86 | Edit2.Text := path; 87 | end; 88 | end; 89 | 90 | procedure TForm2.FormActivate(Sender: TObject); 91 | begin 92 | begin 93 | 94 | end; 95 | end; 96 | 97 | procedure TForm2.FormCreate(Sender: TObject); 98 | begin 99 | 100 | end; 101 | 102 | procedure TForm2.FormShow(Sender: TObject); 103 | var 104 | INI: TINIFile; 105 | path: string; 106 | path1: string; 107 | home: string; 108 | begin 109 | home := GetCurrentDir; 110 | home := home + '\Frofpp4.ini'; 111 | INI := TIniFile.Create(home); 112 | 113 | path := INI.ReadString('PFAD', 'path', ''); 114 | path1 := INI.ReadString('PFAD', 'path1', ''); 115 | Edit1.Text := path; 116 | Edit2.Text := path1; 117 | INI.free; 118 | end; 119 | 120 | end. 121 | 122 | -------------------------------------------------------------------------------- /third_party_gui/frofpp4/unit3.lfm: -------------------------------------------------------------------------------- 1 | object Form3: TForm3 2 | Left = 892 3 | Height = 368 4 | Top = 406 5 | Width = 461 6 | Caption = 'Info' 7 | ClientHeight = 368 8 | ClientWidth = 461 9 | DesignTimePPI = 120 10 | LCLVersion = '2.2.2.0' 11 | object Button1: TButton 12 | Left = 168 13 | Height = 31 14 | Top = 306 15 | Width = 94 16 | Caption = 'OK' 17 | OnClick = Button1Click 18 | TabOrder = 0 19 | end 20 | object Label1: TLabel 21 | Left = 144 22 | Height = 20 23 | Top = 40 24 | Width = 136 25 | Caption = 'Gui for Emu "fpPS4" ' 26 | ParentColor = False 27 | end 28 | object Label2: TLabel 29 | Left = 168 30 | Height = 20 31 | Top = 80 32 | Width = 80 33 | Caption = 'V 0.000001a' 34 | ParentColor = False 35 | end 36 | object Label3: TLabel 37 | Left = 112 38 | Height = 20 39 | Top = 128 40 | Width = 203 41 | Caption = 'this program is free of charge. ' 42 | ParentColor = False 43 | end 44 | object Label4: TLabel 45 | Left = 144 46 | Height = 20 47 | Top = 160 48 | Width = 133 49 | Caption = 'use at your own risk.' 50 | ParentColor = False 51 | end 52 | object Label5: TLabel 53 | Left = 96 54 | Height = 20 55 | Top = 200 56 | Width = 234 57 | Caption = 'no warranty of any kind is assumed.' 58 | ParentColor = False 59 | end 60 | object Label6: TLabel 61 | Left = 144 62 | Height = 20 63 | Top = 248 64 | Width = 135 65 | Caption = 'SLRHUI 2022 Austria' 66 | ParentColor = False 67 | end 68 | end 69 | -------------------------------------------------------------------------------- /third_party_gui/frofpp4/unit3.pas: -------------------------------------------------------------------------------- 1 | unit Unit3; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls; 9 | 10 | type 11 | 12 | { TForm3 } 13 | 14 | TForm3 = class(TForm) 15 | Button1: TButton; 16 | Label1: TLabel; 17 | Label2: TLabel; 18 | Label3: TLabel; 19 | Label4: TLabel; 20 | Label5: TLabel; 21 | Label6: TLabel; 22 | procedure Button1Click(Sender: TObject); 23 | private 24 | 25 | public 26 | 27 | end; 28 | 29 | var 30 | Form3: TForm3; 31 | 32 | implementation 33 | 34 | {$R *.lfm} 35 | 36 | { TForm3 } 37 | 38 | procedure TForm3.Button1Click(Sender: TObject); 39 | begin 40 | Close; 41 | end; 42 | 43 | end. 44 | 45 | -------------------------------------------------------------------------------- /tools/dump_sym/dump_sym.lpi: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <CONFIG> 3 | <ProjectOptions> 4 | <Version Value="12"/> 5 | <PathDelim Value="\"/> 6 | <General> 7 | <Flags> 8 | <SaveClosedFiles Value="False"/> 9 | <MainUnitHasCreateFormStatements Value="False"/> 10 | <MainUnitHasTitleStatement Value="False"/> 11 | <MainUnitHasScaledStatement Value="False"/> 12 | <SaveJumpHistory Value="False"/> 13 | <SaveFoldState Value="False"/> 14 | <CompatibilityMode Value="True"/> 15 | </Flags> 16 | <SessionStorage Value="InProjectDir"/> 17 | <Title Value="dump_sym"/> 18 | <UseAppBundle Value="False"/> 19 | <ResourceType Value="res"/> 20 | </General> 21 | <BuildModes Count="1"> 22 | <Item1 Name="Default" Default="True"/> 23 | </BuildModes> 24 | <PublishOptions> 25 | <Version Value="2"/> 26 | <UseFileFilters Value="True"/> 27 | </PublishOptions> 28 | <RunParams> 29 | <FormatVersion Value="2"/> 30 | </RunParams> 31 | <Units Count="1"> 32 | <Unit0> 33 | <Filename Value="dump_sym.lpr"/> 34 | <IsPartOfProject Value="True"/> 35 | </Unit0> 36 | </Units> 37 | </ProjectOptions> 38 | <CompilerOptions> 39 | <Version Value="11"/> 40 | <PathDelim Value="\"/> 41 | <Target> 42 | <Filename Value="dump_sym"/> 43 | </Target> 44 | <SearchPaths> 45 | <IncludeFiles Value="$(ProjOutDir)"/> 46 | <OtherUnitFiles Value="..\..;..\..\sys;..\..\rtl"/> 47 | <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 48 | </SearchPaths> 49 | <CodeGeneration> 50 | <SmartLinkUnit Value="True"/> 51 | <RelocatableUnit Value="True"/> 52 | <Optimizations> 53 | <OptimizationLevel Value="3"/> 54 | </Optimizations> 55 | </CodeGeneration> 56 | <Linking> 57 | <Debugging> 58 | <GenerateDebugInfo Value="False"/> 59 | </Debugging> 60 | <LinkSmart Value="True"/> 61 | </Linking> 62 | </CompilerOptions> 63 | <Debugging> 64 | <Exceptions Count="3"> 65 | <Item1> 66 | <Name Value="EAbort"/> 67 | </Item1> 68 | <Item2> 69 | <Name Value="ECodetoolError"/> 70 | </Item2> 71 | <Item3> 72 | <Name Value="EFOpenError"/> 73 | </Item3> 74 | </Exceptions> 75 | </Debugging> 76 | </CONFIG> 77 | -------------------------------------------------------------------------------- /tools/dump_sym/dump_sym.lpr: -------------------------------------------------------------------------------- 1 | 2 | uses 3 | {$IFDEF Linux} 4 | cmem, 5 | cthreads, 6 | {$ENDIF} 7 | Classes,sysutils, 8 | ps4_elf; 9 | 10 | var 11 | ifname:RawByteString=''; 12 | ofname:RawByteString=''; 13 | sfname:RawByteString=''; 14 | 15 | i,n:Integer; 16 | 17 | elf:Telf_file; 18 | F:THandle; 19 | 20 | label 21 | promo; 22 | 23 | begin 24 | DefaultSystemCodePage:=CP_UTF8; 25 | DefaultUnicodeCodePage:=CP_UTF8; 26 | DefaultFileSystemCodePage:=CP_UTF8; 27 | DefaultRTLFileSystemCodePage:=CP_UTF8; 28 | UTF8CompareLocale:=CP_UTF8; 29 | 30 | if (ParamCount=0) then 31 | begin 32 | promo: 33 | Writeln('Tool for dump symbols from *.prx/*.sprx files'); 34 | Writeln(' Parameters:'); 35 | Writeln(' -i <name> //file name to load prx/sprx'); 36 | Writeln(' -o <name> //file name to save txt'); 37 | Writeln(' -s <name> //file name to save prx'); 38 | Exit; 39 | end; 40 | 41 | n:=-1; 42 | For i:=1 to ParamCount do 43 | begin 44 | case LowerCase(ParamStr(i)) of 45 | '-i':n:=0; 46 | '-o':n:=1; 47 | '-s':n:=2; 48 | else 49 | if (n<>-1) then 50 | begin 51 | Case n of 52 | 0:ifname:=ParamStr(i); 53 | 1:ofname:=ParamStr(i); 54 | 2:sfname:=ParamStr(i); 55 | end; 56 | n:=-1; 57 | end; 58 | end; 59 | end; 60 | 61 | if not FileExists(ifname) then 62 | begin 63 | Writeln('File not found:',ifname); 64 | Writeln; 65 | Goto promo; 66 | end; 67 | 68 | elf:=Telf_file(LoadPs4ElfFromFile(ifname)); 69 | elf.Prepare; 70 | 71 | if (sfname<>'') then 72 | elf.SavePs4ElfToFile(sfname); 73 | 74 | if (ofname='') then 75 | begin 76 | ofname:=ChangeFileExt(ifname,'.txt'); 77 | end; 78 | 79 | F:=FileCreate(ofname); 80 | elf.DympSymbol(F); 81 | FileClose(F); 82 | FreeAndNil(elf); 83 | 84 | writeln; 85 | end. 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /tools/elf_sym/elf_sym.lpi: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <CONFIG> 3 | <ProjectOptions> 4 | <Version Value="11"/> 5 | <PathDelim Value="\"/> 6 | <General> 7 | <Flags> 8 | <SaveClosedFiles Value="False"/> 9 | <MainUnitHasCreateFormStatements Value="False"/> 10 | <MainUnitHasTitleStatement Value="False"/> 11 | <MainUnitHasScaledStatement Value="False"/> 12 | <SaveJumpHistory Value="False"/> 13 | </Flags> 14 | <SessionStorage Value="InProjectDir"/> 15 | <MainUnit Value="0"/> 16 | <Title Value="elf_sym"/> 17 | <UseAppBundle Value="False"/> 18 | <ResourceType Value="res"/> 19 | </General> 20 | <BuildModes Count="1"> 21 | <Item1 Name="Default" Default="True"/> 22 | </BuildModes> 23 | <PublishOptions> 24 | <Version Value="2"/> 25 | <UseFileFilters Value="True"/> 26 | </PublishOptions> 27 | <RunParams> 28 | <FormatVersion Value="2"/> 29 | <Modes Count="0"/> 30 | </RunParams> 31 | <Units Count="2"> 32 | <Unit0> 33 | <Filename Value="elf_sym.lpr"/> 34 | <IsPartOfProject Value="True"/> 35 | </Unit0> 36 | <Unit1> 37 | <Filename Value="uarch.pas"/> 38 | <IsPartOfProject Value="True"/> 39 | </Unit1> 40 | </Units> 41 | </ProjectOptions> 42 | <CompilerOptions> 43 | <Version Value="11"/> 44 | <PathDelim Value="\"/> 45 | <Target> 46 | <Filename Value="elf_sym"/> 47 | </Target> 48 | <SearchPaths> 49 | <IncludeFiles Value="$(ProjOutDir)"/> 50 | <OtherUnitFiles Value="..\..\sys"/> 51 | <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 52 | </SearchPaths> 53 | <CodeGeneration> 54 | <SmartLinkUnit Value="True"/> 55 | <RelocatableUnit Value="True"/> 56 | <Optimizations> 57 | <OptimizationLevel Value="3"/> 58 | </Optimizations> 59 | </CodeGeneration> 60 | <Linking> 61 | <Debugging> 62 | <GenerateDebugInfo Value="False"/> 63 | </Debugging> 64 | <LinkSmart Value="True"/> 65 | </Linking> 66 | </CompilerOptions> 67 | <Debugging> 68 | <Exceptions Count="3"> 69 | <Item1> 70 | <Name Value="EAbort"/> 71 | </Item1> 72 | <Item2> 73 | <Name Value="ECodetoolError"/> 74 | </Item2> 75 | <Item3> 76 | <Name Value="EFOpenError"/> 77 | </Item3> 78 | </Exceptions> 79 | </Debugging> 80 | </CONFIG> 81 | -------------------------------------------------------------------------------- /tools/elf_sym/run.cmd: -------------------------------------------------------------------------------- 1 | elf_sym -r *.prx -r *.sym -r *.a -e known_names.txt 2 | pause 3 | -------------------------------------------------------------------------------- /tools/elf_sym/uarch.pas: -------------------------------------------------------------------------------- 1 | unit uarch; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils; 9 | 10 | type 11 | Parch_sig=^Tarch_sig; 12 | Tarch_sig=array[0..7] of AnsiChar; 13 | 14 | Parch_header=^Tarch_header; 15 | Tarch_header=packed record 16 | FileName :array[0..15] of AnsiChar; 17 | timestamp:array[0..11] of AnsiChar; 18 | OwnerID :array[0..5] of AnsiChar; 19 | GroupID :array[0..5] of AnsiChar; 20 | FileMode :array[0..7] of AnsiChar; 21 | FileSize :array[0..9] of AnsiChar; 22 | Ending :array[0..1] of AnsiChar; 23 | end; 24 | 25 | const 26 | arch_sig:Tarch_sig='!<arch>'#$0A; 27 | 28 | implementation 29 | 30 | end. 31 | 32 | -------------------------------------------------------------------------------- /tools/gfx6_chip/chip.lpi: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <CONFIG> 3 | <ProjectOptions> 4 | <Version Value="11"/> 5 | <PathDelim Value="\"/> 6 | <General> 7 | <Flags> 8 | <SaveClosedFiles Value="False"/> 9 | <MainUnitHasCreateFormStatements Value="False"/> 10 | <MainUnitHasTitleStatement Value="False"/> 11 | <MainUnitHasScaledStatement Value="False"/> 12 | <SaveJumpHistory Value="False"/> 13 | <SaveFoldState Value="False"/> 14 | </Flags> 15 | <SessionStorage Value="InProjectDir"/> 16 | <MainUnit Value="0"/> 17 | <Title Value="chip"/> 18 | <UseAppBundle Value="False"/> 19 | <ResourceType Value="res"/> 20 | </General> 21 | <BuildModes Count="1"> 22 | <Item1 Name="Default" Default="True"/> 23 | </BuildModes> 24 | <PublishOptions> 25 | <Version Value="2"/> 26 | <UseFileFilters Value="True"/> 27 | </PublishOptions> 28 | <RunParams> 29 | <FormatVersion Value="2"/> 30 | <Modes Count="0"/> 31 | </RunParams> 32 | <Units Count="1"> 33 | <Unit0> 34 | <Filename Value="chip.lpr"/> 35 | <IsPartOfProject Value="True"/> 36 | </Unit0> 37 | </Units> 38 | </ProjectOptions> 39 | <CompilerOptions> 40 | <Version Value="11"/> 41 | <PathDelim Value="\"/> 42 | <Target> 43 | <Filename Value="chip"/> 44 | </Target> 45 | <SearchPaths> 46 | <IncludeFiles Value="$(ProjOutDir)"/> 47 | <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 48 | </SearchPaths> 49 | </CompilerOptions> 50 | <Debugging> 51 | <Exceptions Count="3"> 52 | <Item1> 53 | <Name Value="EAbort"/> 54 | </Item1> 55 | <Item2> 56 | <Name Value="ECodetoolError"/> 57 | </Item2> 58 | <Item3> 59 | <Name Value="EFOpenError"/> 60 | </Item3> 61 | </Exceptions> 62 | </Debugging> 63 | </CONFIG> 64 | -------------------------------------------------------------------------------- /tools/nid_gui_test/main.lfm: -------------------------------------------------------------------------------- 1 | object frmMain: TfrmMain 2 | Left = 441 3 | Height = 240 4 | Top = 138 5 | Width = 556 6 | Caption = 'nid_gui_test' 7 | ClientHeight = 240 8 | ClientWidth = 556 9 | LCLVersion = '2.3.0.0' 10 | object NidBase64: TLabeledEdit 11 | Left = 8 12 | Height = 33 13 | Top = 24 14 | Width = 536 15 | Anchors = [akTop, akLeft, akRight] 16 | EditLabel.Height = 15 17 | EditLabel.Width = 536 18 | EditLabel.Caption = 'Nid Base64' 19 | Font.Height = -19 20 | ParentFont = False 21 | TabOrder = 0 22 | OnExit = NidBase64Click 23 | OnKeyDown = TextKeyDown 24 | end 25 | object NidHex: TLabeledEdit 26 | Left = 8 27 | Height = 33 28 | Top = 80 29 | Width = 536 30 | Anchors = [akTop, akLeft, akRight] 31 | EditLabel.Height = 15 32 | EditLabel.Width = 536 33 | EditLabel.Caption = 'Nid Hex' 34 | Font.Height = -19 35 | ParentFont = False 36 | TabOrder = 1 37 | OnExit = NidHexClick 38 | OnKeyDown = TextKeyDown 39 | end 40 | object NidName: TLabeledEdit 41 | Left = 8 42 | Height = 33 43 | Top = 136 44 | Width = 536 45 | Anchors = [akTop, akLeft, akRight] 46 | EditLabel.Height = 15 47 | EditLabel.Width = 536 48 | EditLabel.Caption = 'Nid Name' 49 | Font.Height = -19 50 | ParentFont = False 51 | TabOrder = 2 52 | OnExit = NidNameClick 53 | OnKeyDown = TextKeyDown 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /tools/nid_gui_test/main.pas: -------------------------------------------------------------------------------- 1 | unit main; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | sha1, 9 | Classes, 10 | SysUtils, 11 | Forms, 12 | Controls, 13 | Graphics, 14 | Dialogs, 15 | ExtCtrls; 16 | 17 | type 18 | 19 | { TfrmMain } 20 | 21 | TfrmMain = class(TForm) 22 | NidBase64: TLabeledEdit; 23 | NidHex: TLabeledEdit; 24 | NidName: TLabeledEdit; 25 | procedure TextKeyDown(Sender:TObject;var Key:Word;Shift:TShiftState); 26 | procedure NidBase64Click(Sender: TObject); 27 | procedure NidHexClick(Sender: TObject); 28 | procedure NidNameClick(Sender: TObject); 29 | private 30 | 31 | public 32 | 33 | end; 34 | 35 | var 36 | frmMain: TfrmMain; 37 | 38 | implementation 39 | 40 | uses 41 | ps4libdoc; 42 | 43 | {$R *.lfm} 44 | 45 | function ps4_nid_hash(NidName:PChar):QWORD; 46 | const 47 | salt:array[0..15] of Byte=($51,$8D,$64,$A6,$35,$DE,$D8,$C1,$E6,$B0,$39,$B1,$C3,$E5,$52,$30); 48 | var 49 | Context:TSHA1Context; 50 | Digest:TSHA1Digest; 51 | begin 52 | SHA1Init(Context); 53 | SHA1Update(Context,NidName^,StrLen(NidName)); 54 | SHA1Update(Context,salt,Length(salt)); 55 | SHA1Final(Context,Digest); 56 | Result:=PQWORD(@Digest)^; 57 | end; 58 | 59 | function EncodeValue64(nVal:QWORD):RawByteString; 60 | const 61 | nEncLenMax=11; 62 | var 63 | i,nIndex:Integer; 64 | begin 65 | SetLength(Result,nEncLenMax); 66 | For i:=nEncLenMax downto 1 do 67 | begin 68 | if (i<>nEncLenMax) then 69 | begin 70 | nIndex:=nVal and 63; 71 | nVal:=nVal shr 6; 72 | end else 73 | begin 74 | nIndex:=(nVal and 15) shl 2; 75 | nVal:=nVal shr 4; 76 | end; 77 | case nIndex of 78 | 0..25:Result[i]:=Char(nIndex+Byte('A')-0); 79 | 26..51:Result[i]:=Char(nIndex+Byte('a')-26); 80 | 52..61:Result[i]:=Char(nIndex+Byte('0')-52); 81 | 62:Result[i]:='+'; 82 | 63:Result[i]:='-'; 83 | end; 84 | end; 85 | end; 86 | 87 | function DecodeValue64(strEnc:PAnsiChar;len:SizeUint;var nVal:QWORD):Boolean; 88 | const 89 | nEncLenMax=11; 90 | var 91 | i,nIndex:Integer; 92 | begin 93 | Result:=False; 94 | nVal:=0; 95 | if (len>nEncLenMax) or (len=0) then Exit; 96 | For i:=0 to len-1 do 97 | begin 98 | case strEnc[i] of 99 | 'A'..'Z':nIndex:=Byte(strEnc[i])-Byte('A')+0; 100 | 'a'..'z':nIndex:=Byte(strEnc[i])-Byte('a')+26; 101 | '0'..'9':nIndex:=Byte(strEnc[i])-Byte('0')+52; 102 | '+':nIndex:=62; 103 | '-':nIndex:=63; 104 | else Exit; 105 | end; 106 | if (i<(nEncLenMax-1)) then 107 | begin 108 | nVal:=nVal shl 6; 109 | nVal:=nVal or nIndex; 110 | end else 111 | begin 112 | nVal:=nVal shl 4; 113 | nVal:=nVal or (nIndex shr 2); 114 | end; 115 | end; 116 | Result:=True; 117 | end; 118 | 119 | { TfrmMain } 120 | 121 | procedure TfrmMain.TextKeyDown(Sender:TObject;var Key:Word;Shift:TShiftState); 122 | begin 123 | if (Key=13) then 124 | if Sender.InheritsFrom(TLabeledEdit) then 125 | if (TLabeledEdit(Sender).OnExit<>nil) then 126 | begin 127 | TLabeledEdit(Sender).OnExit(Sender); 128 | end; 129 | end; 130 | 131 | procedure TfrmMain.NidBase64Click(Sender: TObject); 132 | var 133 | S:RawByteString; 134 | nid:QWORD; 135 | begin 136 | S:=NidBase64.Text; 137 | nid:=0; 138 | if DecodeValue64(PAnsiChar(S),Length(S),nid) then 139 | begin 140 | NidHex.Text:=HexStr(nid,16); 141 | NidName.Text:=ps4libdoc.GetFunctName(nid); 142 | end else 143 | begin 144 | NidHex.Text:=''; 145 | NidName.Text:=''; 146 | end; 147 | end; 148 | 149 | procedure TfrmMain.NidHexClick(Sender: TObject); 150 | var 151 | S:RawByteString; 152 | nid:QWORD; 153 | begin 154 | S:='$'+NidHex.Text; 155 | nid:=0; 156 | if TryStrToQWord(S,nid) then 157 | begin 158 | NidBase64.Text:=EncodeValue64(nid); 159 | NidName.Text:=ps4libdoc.GetFunctName(nid); 160 | end else 161 | begin 162 | NidBase64.Text:=''; 163 | NidName.Text:=''; 164 | end; 165 | end; 166 | 167 | procedure TfrmMain.NidNameClick(Sender: TObject); 168 | var 169 | S:RawByteString; 170 | nid:QWORD; 171 | begin 172 | S:=NidName.Text; 173 | nid:=ps4_nid_hash(PChar(S)); 174 | NidBase64.Text:=EncodeValue64(nid); 175 | NidHex.Text:=HexStr(nid,16); 176 | end; 177 | 178 | { TfrmMain } 179 | 180 | end. 181 | 182 | -------------------------------------------------------------------------------- /tools/nid_gui_test/nid_gui_test.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red-prig/fpPS4/04cefd43e6fddd1ab033e7980cd356d14c964905/tools/nid_gui_test/nid_gui_test.ico -------------------------------------------------------------------------------- /tools/nid_gui_test/nid_gui_test.lpi: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <CONFIG> 3 | <ProjectOptions> 4 | <Version Value="12"/> 5 | <PathDelim Value="\"/> 6 | <General> 7 | <SessionStorage Value="InProjectDir"/> 8 | <Title Value="nid_gui_test"/> 9 | <Scaled Value="True"/> 10 | <ResourceType Value="res"/> 11 | <UseXPManifest Value="True"/> 12 | <XPManifest> 13 | <DpiAware Value="True"/> 14 | </XPManifest> 15 | <Icon Value="0"/> 16 | </General> 17 | <BuildModes> 18 | <Item Name="Default" Default="True"/> 19 | </BuildModes> 20 | <PublishOptions> 21 | <Version Value="2"/> 22 | <UseFileFilters Value="True"/> 23 | </PublishOptions> 24 | <RunParams> 25 | <FormatVersion Value="2"/> 26 | </RunParams> 27 | <RequiredPackages> 28 | <Item> 29 | <PackageName Value="LCL"/> 30 | </Item> 31 | </RequiredPackages> 32 | <Units> 33 | <Unit> 34 | <Filename Value="nid_gui_test.lpr"/> 35 | <IsPartOfProject Value="True"/> 36 | </Unit> 37 | <Unit> 38 | <Filename Value="main.pas"/> 39 | <IsPartOfProject Value="True"/> 40 | <ComponentName Value="frmMain"/> 41 | <HasResources Value="True"/> 42 | <ResourceBaseClass Value="Form"/> 43 | </Unit> 44 | </Units> 45 | </ProjectOptions> 46 | <CompilerOptions> 47 | <Version Value="11"/> 48 | <PathDelim Value="\"/> 49 | <Target> 50 | <Filename Value="nid_gui_test"/> 51 | </Target> 52 | <SearchPaths> 53 | <IncludeFiles Value="$(ProjOutDir)"/> 54 | <OtherUnitFiles Value="..\.."/> 55 | <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 56 | </SearchPaths> 57 | <Linking> 58 | <Debugging> 59 | <DebugInfoType Value="dsDwarf2"/> 60 | </Debugging> 61 | <Options> 62 | <Win32> 63 | <GraphicApplication Value="True"/> 64 | </Win32> 65 | </Options> 66 | </Linking> 67 | </CompilerOptions> 68 | <Debugging> 69 | <Exceptions> 70 | <Item> 71 | <Name Value="EAbort"/> 72 | </Item> 73 | <Item> 74 | <Name Value="ECodetoolError"/> 75 | </Item> 76 | <Item> 77 | <Name Value="EFOpenError"/> 78 | </Item> 79 | </Exceptions> 80 | </Debugging> 81 | </CONFIG> 82 | -------------------------------------------------------------------------------- /tools/nid_gui_test/nid_gui_test.lpr: -------------------------------------------------------------------------------- 1 | program nid_gui_test; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | uses 6 | {$IFDEF UNIX} 7 | cthreads, 8 | {$ENDIF} 9 | {$IFDEF HASAMIGA} 10 | athreads, 11 | {$ENDIF} 12 | Interfaces, // this includes the LCL widgetset 13 | Forms, main 14 | { you can add units after this }; 15 | 16 | {$R *.res} 17 | 18 | begin 19 | RequireDerivedFormResource:=True; 20 | Application.Scaled:=True; 21 | Application.Initialize; 22 | Application.CreateForm(TfrmMain, frmMain); 23 | Application.Run; 24 | end. 25 | 26 | -------------------------------------------------------------------------------- /tools/nid_gui_test/nid_gui_test.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/red-prig/fpPS4/04cefd43e6fddd1ab033e7980cd356d14c964905/tools/nid_gui_test/nid_gui_test.res -------------------------------------------------------------------------------- /tools/param_sfo/param_sfo_info.lpi: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <CONFIG> 3 | <ProjectOptions> 4 | <Version Value="12"/> 5 | <PathDelim Value="\"/> 6 | <General> 7 | <Flags> 8 | <SaveClosedFiles Value="False"/> 9 | <MainUnitHasCreateFormStatements Value="False"/> 10 | <MainUnitHasTitleStatement Value="False"/> 11 | <MainUnitHasScaledStatement Value="False"/> 12 | <SaveJumpHistory Value="False"/> 13 | <CompatibilityMode Value="True"/> 14 | </Flags> 15 | <SessionStorage Value="InProjectDir"/> 16 | <Title Value="param_sfo_info"/> 17 | <UseAppBundle Value="False"/> 18 | <ResourceType Value="res"/> 19 | </General> 20 | <BuildModes Count="1"> 21 | <Item1 Name="Default" Default="True"/> 22 | </BuildModes> 23 | <PublishOptions> 24 | <Version Value="2"/> 25 | <UseFileFilters Value="True"/> 26 | </PublishOptions> 27 | <RunParams> 28 | <FormatVersion Value="2"/> 29 | </RunParams> 30 | <Units Count="1"> 31 | <Unit0> 32 | <Filename Value="param_sfo_info.lpr"/> 33 | <IsPartOfProject Value="True"/> 34 | </Unit0> 35 | </Units> 36 | </ProjectOptions> 37 | <CompilerOptions> 38 | <Version Value="11"/> 39 | <PathDelim Value="\"/> 40 | <Target> 41 | <Filename Value="param_sfo_info"/> 42 | </Target> 43 | <SearchPaths> 44 | <IncludeFiles Value="$(ProjOutDir)"/> 45 | <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 46 | </SearchPaths> 47 | <CodeGeneration> 48 | <SmartLinkUnit Value="True"/> 49 | </CodeGeneration> 50 | <Linking> 51 | <Debugging> 52 | <DebugInfoType Value="dsDwarf2"/> 53 | </Debugging> 54 | </Linking> 55 | </CompilerOptions> 56 | <Debugging> 57 | <Exceptions Count="3"> 58 | <Item1> 59 | <Name Value="EAbort"/> 60 | </Item1> 61 | <Item2> 62 | <Name Value="ECodetoolError"/> 63 | </Item2> 64 | <Item3> 65 | <Name Value="EFOpenError"/> 66 | </Item3> 67 | </Exceptions> 68 | </Debugging> 69 | </CONFIG> 70 | -------------------------------------------------------------------------------- /tools/playgo/playgo_info.lpi: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <CONFIG> 3 | <ProjectOptions> 4 | <Version Value="12"/> 5 | <PathDelim Value="\"/> 6 | <General> 7 | <Flags> 8 | <SaveClosedFiles Value="False"/> 9 | <MainUnitHasCreateFormStatements Value="False"/> 10 | <MainUnitHasTitleStatement Value="False"/> 11 | <MainUnitHasScaledStatement Value="False"/> 12 | <SaveJumpHistory Value="False"/> 13 | <CompatibilityMode Value="True"/> 14 | </Flags> 15 | <SessionStorage Value="InProjectDir"/> 16 | <Title Value="playgo_info"/> 17 | <UseAppBundle Value="False"/> 18 | <ResourceType Value="res"/> 19 | </General> 20 | <BuildModes Count="1"> 21 | <Item1 Name="Default" Default="True"/> 22 | </BuildModes> 23 | <PublishOptions> 24 | <Version Value="2"/> 25 | <UseFileFilters Value="True"/> 26 | </PublishOptions> 27 | <RunParams> 28 | <FormatVersion Value="2"/> 29 | </RunParams> 30 | <Units Count="1"> 31 | <Unit0> 32 | <Filename Value="playgo_info.lpr"/> 33 | <IsPartOfProject Value="True"/> 34 | </Unit0> 35 | </Units> 36 | </ProjectOptions> 37 | <CompilerOptions> 38 | <Version Value="11"/> 39 | <PathDelim Value="\"/> 40 | <Target> 41 | <Filename Value="playgo_info"/> 42 | </Target> 43 | <SearchPaths> 44 | <IncludeFiles Value="$(ProjOutDir)"/> 45 | <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 46 | </SearchPaths> 47 | <CodeGeneration> 48 | <SmartLinkUnit Value="True"/> 49 | </CodeGeneration> 50 | <Linking> 51 | <Debugging> 52 | <DebugInfoType Value="dsDwarf2"/> 53 | </Debugging> 54 | </Linking> 55 | </CompilerOptions> 56 | <Debugging> 57 | <Exceptions Count="3"> 58 | <Item1> 59 | <Name Value="EAbort"/> 60 | </Item1> 61 | <Item2> 62 | <Name Value="ECodetoolError"/> 63 | </Item2> 64 | <Item3> 65 | <Name Value="EFOpenError"/> 66 | </Item3> 67 | </Exceptions> 68 | </Debugging> 69 | </CONFIG> 70 | -------------------------------------------------------------------------------- /tools/ps4libdoc/funct_helper2.lpi: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <CONFIG> 3 | <ProjectOptions> 4 | <Version Value="12"/> 5 | <PathDelim Value="\"/> 6 | <General> 7 | <Flags> 8 | <SaveClosedFiles Value="False"/> 9 | <MainUnitHasCreateFormStatements Value="False"/> 10 | <MainUnitHasTitleStatement Value="False"/> 11 | <MainUnitHasScaledStatement Value="False"/> 12 | <SaveJumpHistory Value="False"/> 13 | <SaveFoldState Value="False"/> 14 | <CompatibilityMode Value="True"/> 15 | </Flags> 16 | <SessionStorage Value="InProjectDir"/> 17 | <Title Value="funct_helper2"/> 18 | <UseAppBundle Value="False"/> 19 | <ResourceType Value="res"/> 20 | </General> 21 | <BuildModes Count="1"> 22 | <Item1 Name="Default" Default="True"/> 23 | </BuildModes> 24 | <PublishOptions> 25 | <Version Value="2"/> 26 | <UseFileFilters Value="True"/> 27 | </PublishOptions> 28 | <RunParams> 29 | <FormatVersion Value="2"/> 30 | </RunParams> 31 | <Units Count="1"> 32 | <Unit0> 33 | <Filename Value="funct_helper2.lpr"/> 34 | <IsPartOfProject Value="True"/> 35 | </Unit0> 36 | </Units> 37 | </ProjectOptions> 38 | <CompilerOptions> 39 | <Version Value="11"/> 40 | <PathDelim Value="\"/> 41 | <Target> 42 | <Filename Value="funct_helper2"/> 43 | </Target> 44 | <SearchPaths> 45 | <IncludeFiles Value="$(ProjOutDir)"/> 46 | <OtherUnitFiles Value="xpath"/> 47 | <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 48 | </SearchPaths> 49 | <CodeGeneration> 50 | <SmartLinkUnit Value="True"/> 51 | <RelocatableUnit Value="True"/> 52 | <Optimizations> 53 | <OptimizationLevel Value="3"/> 54 | </Optimizations> 55 | </CodeGeneration> 56 | <Linking> 57 | <LinkSmart Value="True"/> 58 | </Linking> 59 | </CompilerOptions> 60 | <Debugging> 61 | <Exceptions Count="3"> 62 | <Item1> 63 | <Name Value="EAbort"/> 64 | </Item1> 65 | <Item2> 66 | <Name Value="ECodetoolError"/> 67 | </Item2> 68 | <Item3> 69 | <Name Value="EFOpenError"/> 70 | </Item3> 71 | </Exceptions> 72 | </Debugging> 73 | </CONFIG> 74 | -------------------------------------------------------------------------------- /tools/ps4libdoc/sceKernelDlsym.txt: -------------------------------------------------------------------------------- 1 | PrxSetSessionImage 2 | PrxSetLoggingEnabled 3 | PrxInitializeWithNpAgeRating 4 | PrxSavedGamesInitialise 5 | PrxCommonDialogInitialise 6 | PrxUpdate 7 | PrxHasMessage 8 | PrxGetFirstMessage 9 | PrxRemoveFirstMessage 10 | PrxCommonDialogUpdate 11 | PrxCommonDialogHasMessage 12 | PrxSavedGamesUpdate 13 | PrxSavedGamesHasMessage 14 | ps4ToolsExt_InitServiceCallback 15 | RegisterCallbacks 16 | UnitySetGraphicsDevice 17 | UnityRenderEvent 18 | UnityGetAudioEffectDefinitions 19 | UnityPluginLoad 20 | UnityPluginUnload 21 | UnitySetEventQueue 22 | PrxTusTssGetLastError 23 | PrxSigninIsBusy 24 | -------------------------------------------------------------------------------- /tools/spirv/spirv_helper.lpi: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <CONFIG> 3 | <ProjectOptions> 4 | <Version Value="12"/> 5 | <PathDelim Value="\"/> 6 | <General> 7 | <Flags> 8 | <SaveClosedFiles Value="False"/> 9 | <MainUnitHasCreateFormStatements Value="False"/> 10 | <MainUnitHasTitleStatement Value="False"/> 11 | <MainUnitHasScaledStatement Value="False"/> 12 | <SaveJumpHistory Value="False"/> 13 | <CompatibilityMode Value="True"/> 14 | </Flags> 15 | <SessionStorage Value="InProjectDir"/> 16 | <Title Value="spirv_helper"/> 17 | <UseAppBundle Value="False"/> 18 | <ResourceType Value="res"/> 19 | </General> 20 | <BuildModes Count="1"> 21 | <Item1 Name="Default" Default="True"/> 22 | </BuildModes> 23 | <PublishOptions> 24 | <Version Value="2"/> 25 | <UseFileFilters Value="True"/> 26 | </PublishOptions> 27 | <RunParams> 28 | <FormatVersion Value="2"/> 29 | </RunParams> 30 | <Units Count="1"> 31 | <Unit0> 32 | <Filename Value="spirv_helper.lpr"/> 33 | <IsPartOfProject Value="True"/> 34 | </Unit0> 35 | </Units> 36 | </ProjectOptions> 37 | <CompilerOptions> 38 | <Version Value="11"/> 39 | <PathDelim Value="\"/> 40 | <Target> 41 | <Filename Value="spirv_helper"/> 42 | </Target> 43 | <SearchPaths> 44 | <IncludeFiles Value="$(ProjOutDir)"/> 45 | <OtherUnitFiles Value="xpath"/> 46 | <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 47 | </SearchPaths> 48 | <Linking> 49 | <Debugging> 50 | <DebugInfoType Value="dsDwarf2Set"/> 51 | </Debugging> 52 | </Linking> 53 | </CompilerOptions> 54 | <Debugging> 55 | <Exceptions Count="3"> 56 | <Item1> 57 | <Name Value="EAbort"/> 58 | </Item1> 59 | <Item2> 60 | <Name Value="ECodetoolError"/> 61 | </Item2> 62 | <Item3> 63 | <Name Value="EFOpenError"/> 64 | </Item3> 65 | </Exceptions> 66 | </Debugging> 67 | </CONFIG> 68 | -------------------------------------------------------------------------------- /vulkan/vPipelineLayoutManager.pas: -------------------------------------------------------------------------------- 1 | unit vPipelineLayoutManager; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | SysUtils, 9 | RWLock, 10 | g23tree, 11 | Vulkan, 12 | vPipeline; 13 | 14 | Function FetchPipelineLayout(const A:AvSetLayout; 15 | const B:AvPushConstantRange):TvPipelineLayout; 16 | 17 | implementation 18 | 19 | type 20 | TvPipelineLayoutCompare=class 21 | class function c(a,b:PvPipelineLayoutKey):Integer; static; 22 | end; 23 | 24 | _TvPipelineLayoutSet=specialize T23treeSet<PvPipelineLayoutKey,TvPipelineLayoutCompare>; 25 | TvPipelineLayoutSet=object(_TvPipelineLayoutSet) 26 | lock:TRWLock; 27 | Procedure Init; 28 | Procedure Lock_wr; 29 | Procedure Unlock; 30 | end; 31 | 32 | var 33 | FPipelineLayoutSet:TvPipelineLayoutSet; 34 | 35 | Procedure TvPipelineLayoutSet.Init; 36 | begin 37 | rwlock_init(lock); 38 | end; 39 | 40 | Procedure TvPipelineLayoutSet.Lock_wr; 41 | begin 42 | rwlock_wrlock(lock); 43 | end; 44 | 45 | Procedure TvPipelineLayoutSet.Unlock; 46 | begin 47 | rwlock_unlock(lock); 48 | end; 49 | 50 | function _Find(F:PvPipelineLayoutKey):TvPipelineLayout; 51 | var 52 | i:TvPipelineLayoutSet.Iterator; 53 | begin 54 | Result:=nil; 55 | i:=FPipelineLayoutSet.find(F); 56 | if (i.Item<>nil) then 57 | begin 58 | Result:=TvPipelineLayout(ptruint(i.Item^)-ptruint(@TvPipelineLayout(nil).key)); 59 | end; 60 | end; 61 | 62 | Function _Fetch(F:PvPipelineLayoutKey):TvPipelineLayout; 63 | var 64 | t:TvPipelineLayout; 65 | begin 66 | t:=_Find(F); 67 | 68 | if (t=nil) then 69 | begin 70 | t:=TvPipelineLayout.Create; 71 | t.key:=F^; 72 | 73 | if not t.Compile then 74 | begin 75 | FreeAndNil(t); 76 | end else 77 | begin 78 | FPipelineLayoutSet.Insert(@t.key); 79 | end; 80 | 81 | end; 82 | 83 | Result:=t; 84 | end; 85 | 86 | Function FetchPipelineLayout(const A:AvSetLayout; 87 | const B:AvPushConstantRange):TvPipelineLayout; 88 | var 89 | key:TvPipelineLayoutKey; 90 | begin 91 | key:=Default(TvPipelineLayoutKey); 92 | key.FLayouts :=A; 93 | key.FPushConsts:=B; 94 | 95 | FPipelineLayoutSet.Lock_wr; 96 | 97 | Result:=_Fetch(@key); 98 | 99 | FPipelineLayoutSet.Unlock; 100 | end; 101 | 102 | function ComparePtruint(buf1,buf2:PPtruint;count:PtrUint):Integer; 103 | begin 104 | Result:=0; 105 | While (count<>0) do 106 | begin 107 | Result:=Integer(buf1^>buf2^)-Integer(buf1^<buf2^); 108 | if (Result<>0) then Exit; 109 | Inc(buf1); 110 | Inc(buf2); 111 | Dec(count); 112 | end; 113 | end; 114 | 115 | function ComparePushRange(var a,b:TVkPushConstantRange):Integer; 116 | begin 117 | //1 stageFlags 118 | Result:=Integer(a.stageFlags>b.stageFlags)-Integer(a.stageFlags<b.stageFlags); 119 | if (Result<>0) then Exit; 120 | //2 offset 121 | Result:=Integer(a.offset>b.offset)-Integer(a.offset<b.offset); 122 | if (Result<>0) then Exit; 123 | //3 size 124 | Result:=Integer(a.size>b.size)-Integer(a.size<b.size); 125 | end; 126 | 127 | function ComparePushRanges(var buf1,buf2:AvPushConstantRange;count:PtrUint):Integer; 128 | var 129 | i:PtrUint; 130 | begin 131 | Result:=0; 132 | if (count<>0) then 133 | For i:=0 to count-1 do 134 | begin 135 | Result:=ComparePushRange(buf1[i],buf2[i]); 136 | if (Result<>0) then Exit; 137 | end; 138 | end; 139 | 140 | class function TvPipelineLayoutCompare.c(a,b:PvPipelineLayoutKey):Integer; 141 | begin 142 | //1 Length(FLayouts) 143 | Result:=Integer(Length(a^.FLayouts)>Length(b^.FLayouts))-Integer(Length(a^.FLayouts)<Length(b^.FLayouts)); 144 | if (Result<>0) then Exit; 145 | //2 Length(FPushConsts) 146 | Result:=Integer(Length(a^.FPushConsts)>Length(b^.FPushConsts))-Integer(Length(a^.FPushConsts)<Length(b^.FPushConsts)); 147 | if (Result<>0) then Exit; 148 | //3 FLayouts 149 | Result:=ComparePtruint(@a^.FLayouts[0],@b^.FLayouts[0],Length(a^.FLayouts)); 150 | if (Result<>0) then Exit; 151 | //4 FPushConsts 152 | Result:=ComparePushRanges(a^.FPushConsts,b^.FPushConsts,Length(a^.FPushConsts)); 153 | end; 154 | 155 | initialization 156 | FPipelineLayoutSet.Init; 157 | 158 | end. 159 | 160 | -------------------------------------------------------------------------------- /vulkan/vSampler.pas: -------------------------------------------------------------------------------- 1 | unit vSampler; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Vulkan, 9 | vDevice; 10 | 11 | type 12 | TvSampler=class 13 | FHandle:TVkSampler; 14 | function Compile(pInfo:PVkSamplerCreateInfo):Boolean; 15 | Destructor Destroy; override; 16 | end; 17 | 18 | implementation 19 | 20 | function TvSampler.Compile(pInfo:PVkSamplerCreateInfo):Boolean; 21 | var 22 | r:TVkResult; 23 | begin 24 | Result:=False; 25 | if (pInfo=nil) then Exit; 26 | 27 | if (FHandle<>VK_NULL_HANDLE) then 28 | begin 29 | vkDestroySampler(Device.FHandle,FHandle,nil); 30 | FHandle:=VK_NULL_HANDLE; 31 | end; 32 | 33 | r:=vkCreateSampler(Device.FHandle,pInfo,nil,@FHandle); 34 | if (r<>VK_SUCCESS) then 35 | begin 36 | Writeln(StdErr,'vkCreateImage:',r); 37 | Exit; 38 | end; 39 | Result:=True; 40 | end; 41 | 42 | Destructor TvSampler.Destroy; 43 | begin 44 | if (FHandle<>VK_NULL_HANDLE) then 45 | vkDestroySampler(Device.FHandle,FHandle,nil); 46 | inherited; 47 | end; 48 | 49 | end. 50 | 51 | -------------------------------------------------------------------------------- /vulkan/vSamplerManager.pas: -------------------------------------------------------------------------------- 1 | unit vSamplerManager; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | ps4_shader, 9 | ps4_gpu_regs, 10 | SysUtils, 11 | RWLock, 12 | g23tree, 13 | Vulkan, 14 | vDevice, 15 | vSampler, 16 | vCmdBuffer; 17 | 18 | function FetchSampler(cmd:TvCustomCmdBuffer;PS:PSSharpResource4):TvSampler; 19 | 20 | implementation 21 | 22 | type 23 | TvSampler2Compare=object 24 | function c(a,b:PSSharpResource4):Integer; static; 25 | end; 26 | 27 | TvSampler2=class(TvSampler) 28 | key:TSSharpResource4; 29 | // 30 | FRefs:ptruint; 31 | Procedure Acquire; 32 | procedure Release(Sender:TObject); 33 | end; 34 | 35 | _TvSampler2Set=specialize T23treeSet<PSSharpResource4,TvSampler2Compare>; 36 | TvSampler2Set=object(_TvSampler2Set) 37 | lock:TRWLock; 38 | Procedure Init; 39 | Procedure Lock_wr; 40 | Procedure Unlock; 41 | end; 42 | 43 | var 44 | FSampler2Set:TvSampler2Set; 45 | 46 | Procedure TvSampler2Set.Init; 47 | begin 48 | rwlock_init(lock); 49 | end; 50 | 51 | Procedure TvSampler2Set.Lock_wr; 52 | begin 53 | rwlock_wrlock(lock); 54 | end; 55 | 56 | Procedure TvSampler2Set.Unlock; 57 | begin 58 | rwlock_unlock(lock); 59 | end; 60 | 61 | Procedure TvSampler2.Acquire; 62 | begin 63 | System.InterlockedIncrement(Pointer(FRefs)); 64 | end; 65 | 66 | procedure TvSampler2.Release(Sender:TObject); 67 | begin 68 | if System.InterlockedDecrement(Pointer(FRefs))=nil then 69 | begin 70 | Free; 71 | end; 72 | end; 73 | 74 | function TvSampler2Compare.c(a,b:PSSharpResource4):Integer; 75 | begin 76 | Result:=CompareByte(a^,b^,SizeOf(TSSharpResource4)); 77 | end; 78 | 79 | function _Find(PS:PSSharpResource4):TvSampler2; 80 | var 81 | i:TvSampler2Set.Iterator; 82 | begin 83 | Result:=nil; 84 | i:=FSampler2Set.find(PS); 85 | if (i.Item<>nil) then 86 | begin 87 | Result:=TvSampler2(ptruint(i.Item^)-ptruint(@TvSampler2(nil).key)); 88 | end; 89 | end; 90 | 91 | function _FetchSampler(PS:PSSharpResource4):TvSampler2; 92 | var 93 | t:TvSampler2; 94 | info:TVkSamplerCreateInfo; 95 | begin 96 | Result:=nil; 97 | 98 | t:=_Find(PS); 99 | 100 | if (t=nil) then 101 | begin 102 | info:=_get_ssharp_info(PS); 103 | 104 | t:=TvSampler2.Create; 105 | t.key:=PS^; 106 | 107 | if not t.Compile(@info) then 108 | begin 109 | FreeAndNil(t); 110 | end else 111 | begin 112 | t.Acquire; 113 | FSampler2Set.Insert(@t.key); 114 | end; 115 | end; 116 | 117 | Result:=t; 118 | end; 119 | 120 | function FetchSampler(cmd:TvCustomCmdBuffer;PS:PSSharpResource4):TvSampler; 121 | begin 122 | Result:=nil; 123 | if (PS=nil) then Exit; 124 | 125 | FSampler2Set.Lock_wr; 126 | 127 | Result:=_FetchSampler(PS); 128 | 129 | if (cmd<>nil) and (Result<>nil) then 130 | begin 131 | if cmd.AddDependence(@TvSampler2(Result).Release) then 132 | begin 133 | TvSampler2(Result).Acquire; 134 | end; 135 | end; 136 | 137 | FSampler2Set.Unlock; 138 | end; 139 | 140 | 141 | initialization 142 | FSampler2Set.Init; 143 | 144 | end. 145 | 146 | -------------------------------------------------------------------------------- /vulkan/vSetLayoutManager.pas: -------------------------------------------------------------------------------- 1 | unit vSetLayoutManager; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | SysUtils, 9 | RWLock, 10 | g23tree, 11 | Vulkan, 12 | vPipeline; 13 | 14 | Function FetchSetLayout(FStage:TVkShaderStageFlags; 15 | FFlags:TVkUInt32; 16 | const A:AVkDescriptorSetLayoutBinding):TvSetLayout; 17 | 18 | implementation 19 | 20 | type 21 | TvSetLayoutCompare=class 22 | class function c(a,b:PvSetLayoutKey):Integer; static; 23 | end; 24 | 25 | _TvSetLayoutsPool=specialize T23treeSet<PvSetLayoutKey,TvSetLayoutCompare>; 26 | TvSetLayoutsPool=object(_TvSetLayoutsPool) 27 | lock:TRWLock; 28 | Procedure Init; 29 | Procedure Lock_wr; 30 | Procedure Unlock; 31 | end; 32 | 33 | var 34 | FSetLayoutsPool:TvSetLayoutsPool; 35 | 36 | Procedure TvSetLayoutsPool.Init; 37 | begin 38 | rwlock_init(lock); 39 | end; 40 | 41 | Procedure TvSetLayoutsPool.Lock_wr; 42 | begin 43 | rwlock_wrlock(lock); 44 | end; 45 | 46 | Procedure TvSetLayoutsPool.Unlock; 47 | begin 48 | rwlock_unlock(lock); 49 | end; 50 | 51 | function CompareBind(var a,b:TVkDescriptorSetLayoutBinding):Integer; forward; 52 | 53 | procedure BubbleSort(Var A:AVkDescriptorSetLayoutBinding); 54 | var 55 | n,w,i:Integer; 56 | 57 | procedure Swap(var A,B:TVkDescriptorSetLayoutBinding); inline; 58 | var 59 | T:TVkDescriptorSetLayoutBinding; 60 | begin 61 | T:=A; 62 | A:=B; 63 | B:=T; 64 | end; 65 | 66 | begin 67 | if (Length(A)=0) then Exit; 68 | n:=High(A); 69 | repeat 70 | w:=0; 71 | for i:=1 to n do 72 | begin 73 | if (CompareBind(A[i-1],A[i])>0) then 74 | begin 75 | Swap(A[i-1],A[i]); 76 | w:=i; 77 | end; 78 | end; 79 | n:=w; 80 | until (n=0); 81 | end; 82 | 83 | Function FetchSetLayout(FStage:TVkShaderStageFlags; 84 | FFlags:TVkUInt32; 85 | const A:AVkDescriptorSetLayoutBinding):TvSetLayout; 86 | var 87 | key:TvSetLayoutKey; 88 | 89 | t:TvSetLayout; 90 | i:TvSetLayoutsPool.Iterator; 91 | begin 92 | key:=Default(TvSetLayoutKey); 93 | key.FStage:=FStage; 94 | key.FFlags:=FFlags; 95 | key.FBinds:=A; 96 | BubbleSort(key.FBinds); 97 | 98 | FSetLayoutsPool.Lock_wr; 99 | 100 | i:=FSetLayoutsPool.find(@key); 101 | if (i.Item=nil) then 102 | begin 103 | t:=TvSetLayout.Create; 104 | t.key:=key; 105 | FSetLayoutsPool.Insert(@t.key); 106 | Result:=t; 107 | end else 108 | begin 109 | t:=TvSetLayout(ptruint(i.Item^)-ptruint(@TvSetLayout(nil).key)); 110 | 111 | Result:=t; 112 | end; 113 | 114 | FSetLayoutsPool.Unlock; 115 | 116 | t.Compile; 117 | end; 118 | 119 | 120 | function CompareBind(var a,b:TVkDescriptorSetLayoutBinding):Integer; 121 | begin 122 | //1 binding 123 | Result:=Integer(a.binding>b.binding)-Integer(a.binding<b.binding); 124 | if (Result<>0) then Exit; 125 | //2 descriptorType 126 | Result:=Integer(a.descriptorType>b.descriptorType)-Integer(a.descriptorType<b.descriptorType); 127 | if (Result<>0) then Exit; 128 | //3 descriptorCount 129 | Result:=Integer(a.descriptorCount>b.descriptorCount)-Integer(a.descriptorCount<b.descriptorCount); 130 | if (Result<>0) then Exit; 131 | //4 stageFlags 132 | Result:=Integer(a.stageFlags>b.stageFlags)-Integer(a.stageFlags<b.stageFlags); 133 | if (Result<>0) then Exit; 134 | //5 pImmutableSamplers 135 | Result:=Integer(a.pImmutableSamplers>b.pImmutableSamplers)-Integer(a.pImmutableSamplers<b.pImmutableSamplers); 136 | end; 137 | 138 | function CompareBinds(var buf1,buf2:AVkDescriptorSetLayoutBinding;count:PtrUint):Integer; 139 | var 140 | i:PtrUint; 141 | begin 142 | Result:=0; 143 | if (count<>0) then 144 | For i:=0 to count-1 do 145 | begin 146 | Result:=CompareBind(buf1[i],buf2[i]); 147 | if (Result<>0) then Exit; 148 | end; 149 | end; 150 | 151 | class function TvSetLayoutCompare.c(a,b:PvSetLayoutKey):Integer; 152 | begin 153 | //1 FStage 154 | Result:=Integer(a^.FStage>b^.FStage)-Integer(a^.FStage<b^.FStage); 155 | if (Result<>0) then Exit; 156 | //2 FFlag 157 | Result:=Integer(a^.FFlags>b^.FFlags)-Integer(a^.FFlags<b^.FFlags); 158 | if (Result<>0) then Exit; 159 | //3 Length(FBinds) 160 | Result:=Integer(Length(a^.FBinds)>Length(b^.FBinds))-Integer(Length(a^.FBinds)<Length(b^.FBinds)); 161 | if (Result<>0) then Exit; 162 | //4 FBinds 163 | Result:=CompareBinds(a^.FBinds,b^.FBinds,Length(a^.FBinds)); 164 | end; 165 | 166 | initialization 167 | FSetLayoutsPool.Init; 168 | 169 | end. 170 | 171 | 172 | --------------------------------------------------------------------------------