PS2 Emulation: Difference between revisions

From PS4 Developer wiki
Jump to navigation Jump to search
No edit summary
 
(763 intermediate revisions by 5 users not shown)
Line 1: Line 1:


=2024-present year=
<pre>No emulator backported yet.</pre>
=2014-2018 emulators=
= Description =
= Description =


PlayStation 2 emulation on the PlayStaion 4 is handled with little difference to the PlayStation 3,
The PlayStation 2 emulation on the PlayStation 4 is handled with little difference to the PlayStation 3. Some issues on PS3's PS2 emulator were left unfixed on the PlayStation 4. Consequently, the PS4 inherited some of PS3's emulation glitches, and even introduced new ones. The new issues came as a result of PS4's weakness with emulation, which likely resulted in the trade of accuracy for performance.
But still many issues that the PlayStation 3 faced have moved into the PlayStation 4 along with many new issues.


The fact of the matter is that the PS4 is too weak for emulation, For that reason alone, Sony had to sacrifice accuracy in order to gain performance, but the PS4's emu has more accuracy than PCSX2 in terms of GS since all emulation is done on the cpu, As for the other parts, PCSX2 is much better at emulating it, For instance PCSX2 syncs VU0 extremely well; the PS4 doesn't, and it's because it doesn't have the horsepower to do that, and that has to lead to games like Rayman 3 being unplayable without overclocking the EE at a specific offset.
Each PS2onPS4 package file (.pkg) includes the PS2 emulator itself. The PS4 does not have a native built-in emulator in its System Software, but it does have a few PS2 emulator specific features, like the usermode functions sceLncUtilIsPs2Emu, sceShellCoreUtilGetImposeMenuFlagForPs2Emu, sceSystemServiceAddLocalProcessForPs2Emu, and sceSystemServiceShowImposeMenuForPs2Emu.


Each PS2 game PS4 package file (.pkg) includes the emulator itself, there is no included emulator in the PS4 firmware. although The PS4 firmware has some PS2 emulator specific features, like the functions sceLncUtilIsPs2Emu, sceShellCoreUtilGetImposeMenuFlagForPs2Emu, sceSystemServiceAddLocalProcessForPs2Emu, or sceSystemServiceShowImposeMenuForPs2Emu.
The PS2 emulators are programmed to be accurate for the games they were designed to emulate. In turn, this makes accurate emulation challenging, as emulators include per-title patches and different default settings. The PlayStation 2 hardware is a complex system to emulate; any small change in configuration can make or break a game. Currently, the most commonly used emulator is "Jakv2" from Jak games, as it is the most compatible one out there. When game crashes are concerned in an emulated PS2 game, then the Resident Evil Code: Veronica X's emulator is typically used, whereas for VU accuracy it is Rogue Galaxy's.


Emulators are programmed to be accurate for the games that they were extracted from, and that alone provides a challenge for accurate emulation. since emulators include per title patches, and different default settings, and since the Playstation 2 hardware is known to be one of the most complex systems to emulate, any small change in configuration can have negative consequences in games.
The PS2 BIOS is included in the game's pkg file. It is the same PS2 BIOS as used in the ps2_netemu in PS3 Operating System. The lack of encryption mechanism for PS2 game disc image files is also huge. This time, it is a plain ISO file, but the emulator still supports LIMG sector that allows the usage of non-2048 sector size discs. Moreover, memory cards are also unencrypted, but the emulator checks the CRC of some of the regions to ensure that the memory card was not modified. The PS2 emulator on PS4 also supports LUA scripting by a "Lua Bridge", which is a powerful interface that may prove exceptionally handy in fixing games.


Currently the most used emulator is Jakv2 since it is the most compatible, but for game crashes we use RECVX, and for VU accuracy we use roguev1.
This is first time that Sony has ever cared about floats in its emulators. Compared to the PS3 CPU, x86-64 is doing a worse job in mimicking FPU and VU floats calculation behavior. This is resolved by clamping, accurate math used per memory offset, and/or converting floats to double precision. The emulator uses OpenCL for GS, and likely other components as well.
 
Also note that the BIOS itself is included in the game's pkg and it is the exact same BIOS that was used in the ps2_netemu. Another important thing is the lack of encryption mechanism for PS2 game disc image file, this time it is just a plain ISO file, but the emulator still supports LIMG sector that allows the usage of non-2048 sector size discs. Memory card is also decrypted, but the emulator checks the crc of some of the regions to ensure that the memory card was Not modified. the PS2 Emulator supports LUA scripting by "Lua Bridge", and it is an extremely powerful interface that provide many possibilities to improve compatibility.
 
This is first time that Sony really cared about floats in their emulator. Compared to the PS3 CPU, x86-64 is doing a worse job in mimicing PS2 FPU, and VU floats calculation behavior. This is resolved by clamping, accurate math used per memory offset, and/or converting floats to double precision. the emulator uses openCL for GS, and probably other components.


= Emulator Configuration =
= Emulator Configuration =
The emulator can be configured through 4 files.


== Files ==
== Files ==
Emulator configuration is handled by 4 files:


* '''config-emu-ps4.txt''' - Stores paths, basic video/audio settings in official packages. But unofficially can be also used for advanced settings for global effect in multi disc .pkg with all commands originally used in cli.conf file.  
* '''config-emu-ps4.txt''' - Stores paths, basic video/audio settings in official packages. But unofficially can be also used for advanced settings for global effect in multi disc .pkg with all commands originally used in cli.conf file.  
Line 29: Line 27:


== Commands ==
== Commands ==
'''Known functions:''' Require cleanup.
The rest of the CLI and LUA commands can all be found inside of any emulator's '''Eboot.bin''' file.
<br>The rest of the cli and lua commands can all be found inside of an emu's decrypted '''eboot.bin'''.
=== config-emu-ps4.txt commands ===
=== config-emu-ps4.txt commands ===


Line 39: Line 36:
|-
|-
| --config-local-lua ||  ||  || --config-local-lua=""
| --config-local-lua ||  ||  || --config-local-lua=""
|-
| --lopnor-config ||  0,1  ||  Enables limited PS3's PS2 config support || --lopnor-config=1
|-
|-
| --load-tooling-lua ||  ||  || --load-tooling-lua=0
| --load-tooling-lua ||  ||  || --load-tooling-lua=0
Line 52: Line 51:
| --path-vmc || dir/folder ||  || --path-vmc="/tmp/vmc"
| --path-vmc || dir/folder ||  || --path-vmc="/tmp/vmc"
|-
|-
| --emulog-file || 0, 1 ||  Creates a log file with information that is Rarely useful || --emulog-file=1
| --emulog-file || 0, 1 ||  Creates a log file with information that is rarely useful || --emulog-file=1
|-
|-
| --path-emulog || dir/folder || Sets the directory of the emulog file, Requires --emulog-file=1 command  || --path-emulog="/tmp/recordings"
| --path-emulog || dir/folder || Sets the directory of the emulog file. Requires --emulog-file=1 command  || --path-emulog="/tmp/recordings"
|-
|-
| --path-manual || dir/folder ||  ||
| --path-manual || dir/folder ||  ||
Line 104: Line 103:
| --framelimit-fps ||  FPS/float || framelimiter || --framelimit-fps=0.8
| --framelimit-fps ||  FPS/float || framelimiter || --framelimit-fps=0.8
|-
|-
| --framelimit-scalar ||  scalar/float || scalar must be between 0.1 and 5.0 || --framelimit-scalar=3.2
| --framelimit-scalar ||  scalar/float || || --framelimit-scalar=3.2
|-
|-
| --framelimit-mode || slowest,slower,slow,normal,fast,fastest,turbo || A Standalone framelimiter || --framelimit-mode=fast
| --framelimit-mode || slowest,slower,slow,normal,fast,fastest,turbo || A Standalone framelimiter || --framelimit-mode=fast
|-
|-
| --ps2-lang || system  || sets language, Might seem like a useless command, but a Tiny number of games refuse to boot without a selected language. || --ps2-lang=system  
| --ps2-lang || system  || Sets language. Might seem like a useless command, but a tiny number of games refuse to boot without a selected language. || --ps2-lang=system  
|-
| --ps2-title-id || XXXX-YYYYY Example: (SLUS-21515) || Sets title-id for patches. Requires the game's region code as value || --ps2-title-id=SLES-50366
|-
|-
| --ps2-title-id || XXXX-YYYYY Example: (SLUS-21515) || Sets title-id for patches, Requires the game's region code as value || --ps2-title-id=SLES-50366
| --verbose-cpu-cycles=1 || 0,1 || ? || --verbose-cpu-cycles=1
|-
|-
| --gs-uprender || none, 2x2 || Internal resolution upscaler. || --gs-uprender=2x2
| --gs-uprender || none, 2x2 || Internal resolution upscaler. || --gs-uprender=2x2
|-
|-
| --gs-upscale || none, gpu, edgesmooth, motionvec, point, motionvector, smooth, motion || upscaling type || --gs-upscale=EdgeSmooth
| --gs-upscale || none, gpu, edgesmooth, motionvec, point, motionvector, smooth, motion || upscaling type || --gs-upscale=EdgeSmooth
|-style="background-color:#ffe680"
|  || CDVD || ||
|-
| --max-disc-num || 1-5  || numbers of discs in package (maximum=5)  || --max-disc-num=1
|-
| --boot-disc-id || 1-5  ||  sets boot disc for multi-disc pkg || --boot-disc-id=0
|-
| --switch-disc-reset || <pre> 1 = Enables resetting the game upon disc swap
0 = Disables resetting the game upon disc swap</pre>|| <pre> 0 Can be used to prevent Resetting the game when switching multiple discs, useful for games like Samurai warriors 2 that have Import data Feature, Sadly this command isn't supported by many emulators, but jakv2 is confirmed to support it</pre> || --switch-disc-reset=1
|-
| --cdvd-sector-read-cycles || <pre>0.1 = Fastest,
80000 = Slowest</pre>|| <pre>Set DVD reading speed, higher values are slower, lower values are faster, Kinetica uses 40000, Psychonauts 4000, Red dead revolver 5000, Rise of kasai 31000, some games require moderate speed, too slow or too fast could cause audio problems.</pre>|| --cdvd-sector-read-cycles=40000
|-
| --cdvd-sector-seek-cycles || <pre>0.1 = Fastest,
80000 = Slowest</pre> || <pre>Set the speed at which the emulated CDVD spins, higher values are slower,
lower values are faster, fixes boot-up sometimes.</pre> More info here [https://github.com/PCSX2/pcsx2/pull/3877]. || --cdvd-sector-seek-cycles=1
|-
| --verbose-cdvd-reads || 0, 1 || Might improve disc reading if set to 1|| --verbose-cdvd-reads=0
|-style="background-color:#ff8080"
|-style="background-color:#ff8080"
|  || Audio || ||
|  || Audio || ||
Line 163: Line 146:
| --host-pad-loses-focus ||  ||  ||  --host-pad-loses-focus=1
| --host-pad-loses-focus ||  ||  ||  --host-pad-loses-focus=1
|-  
|-  
| --host-gamepads || 0, 1 || This command might have a function if multitap is set to byhost || --host-gamepads=1
| --host-gamepads || 0, 1 || || --host-gamepads=1
|-
|-
| --pad-record ||  0, 1  ||  Enables Logging pad info in emulog ||
| --pad-record ||  0, 1  ||  Enables logging pad info in emulog ||
|-
|-
| --pad-analog-to-digital || 0, 1 || Eternel ring Emu uses the value 0 || --pad-analog-to-digital=0
| --pad-analog-to-digital || 0, 1 || Eternel ring emu uses the value 0 || --pad-analog-to-digital=0
|-
|-
| --mtap1 || Disabled, Always, ByHost || Multitap switch, The values are correct but the multitap only works in certain games. || --mtap1=always
| --mtap1 || Disabled, Always, ByHost || Multitap switch. The values are correct but the multitap only works in certain games. || --mtap1=always
|-
|-
| --mtap2 || Disabled, Always, ByHost || Multitap switch, some games require multitap to be selected only on second port (1, 2-a, 2-b, 2-c layout). To achieve that we need to disable first mtap. || --mtap2=always
| --mtap2 || Disabled, Always, ByHost || Multitap switch. Some games require multitap to be selected only on second port (1, 2-a, 2-b, 2-c layout). To achieve that, we need to disable the first mtap. In some cases, the emulator can be flawed in how it handles multi-tap when it involves "--mtap2". All functions for 2A, 2B, 2C, 2D must be redirected to ports on multi-tap 1 by using memory patches. || --mtap2=always
|}
|}


=== XXXX-YYYYY_cli.conf commands ===
=== XXXX-YYYYY_cli.conf commands ===


<pre>Please note that commands listed here also work in config-emu-ps4.txt. But the official way to use them is by CLI file. The CLI file way is also needed for multi-disc packages, Some of the Commands are still not discovered, And some known commands are missing some of their values Due to them being not Discovered. The scene has named "CLI" with 3 names, including TXT, CLI, CONF. all 3 are the exact same thing.</pre>
<pre>These commands work in config-emu-ps4.txt, but the official way to use them is through the CLI file (It is also needed for multi-disc packages). Additionally, some commands are still not discovered, and known commands might be missing their values.
<pre>All CLI commands are pre-made by sony, We sadly cannot create CLI commands out of thin air.
All commands are pre-made. Creating new CLI commands is impossible.
The values of the commands are also pre-defined by sony and /or have a quota for possible values/ranges.
The values of the commands are also pre-defined by Sony and/or have a set of possible values or ranges.
Some CLI commands have no effect, and were added into the eboot.bin without being programmed by sony.
Some CLI commands have no effect, as they were added to the eboot.bin without being programmed. Some useful commands were removed or added in or from different emu revisions, or their effects were changed. In some emulators, CLI configurations can be found in the ram at SceLibcHeap[0]-3-881004000.</pre>
and some useful commands were removed/added from different emu revisions. or their effects were changed.</pre>
====EmotionEngine (MIPS-IV)====
<pre>CLI commands use SCE modules to change default emulator settings.
=====[https://www.psdevwiki.com/ps2/Emotion_Engine EE]=====
for instance --cdvd-sector-seek-cycles is  actually sceCdStSeek, but is still unclear how to use SCE modules in a lua</pre>
<pre>Commands for the emulated Emotion Engine. These commands may improve performance, prevent crashes, or provide better core sync.</pre>
 
====EE====
<pre>Commands for the emulated Emotion Engine. these commands may assist you in gaining performance or better sync.</pre>
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Values !! Notes !! Usage
! Command !! Values !! Notes !! Usage
|-style="background-color:#7698FF"
|-style="background-color:#7698FF"
|  || Speedhacks || ||
|  || Speedhacks / Desync Fixes|| ||
|-
|-
| --ee-cycle-scalar || <pre> [Overclocking]
| --ee-cycle-scalar ||Slowest cycles speed: 5.00<br>Normal cycles speed: 1.000<br>Fastest cycles speed: 0.100 ||  Can benefit core sync or performance (lowering the cycle rate may affect FMVS). The default value for most emulators is ~1.0. It is highly sensitive, as any slight change may break or fix the game. (Possibly divides 100 with the entered value and sets the result as EE's clock speed percentage % .) || --ee-cycle-scalar=1.0  
(0.99 => 0.1)  
[Underclocking]
(1.1 => 5.0)</pre> || <pre>If set Higher than 1.0 the Emotion engine Begins skipping cycles, you might face Problems in FMVs if you skip too many cycles. but you will gain a better performance</pre> || --ee-cycle-scalar=1.0  
|-
|-
| --ee-context-switch-cycles ||<pre> [Overclocking(?)]
| --ee-context-switch-cycles || Accelerate cycles (360 => 0) <br>Decelerate cycles (361 => ∞ ) || Its effects are mysterious. Possibly configures how many CPU cycles the emulator should run before switching between different tasks or threads. Does not work on Jak emulators. Default value is 360. Seems to be useful for Bee Movie, Metal Gear Solid 3, as well as others with IPU issues.|| --ee-context-switch-cycles=2700?
(0.99 => 0.1)  
[Cycle skipping(?)]
(1.1 => ∞ ) </pre>|| <pre>It's still unknown what this command controls, but the higher it is, the more EE cycles are skipped, Doesn't work for jak emulators.</pre> || --ee-context-switch-cycles=2700?
|-
|-
| --ee-hook || <pre>AdvanceClock
| [[--ee-hook|--ee-hook]] || AdvanceClock<br>FastForwardClock<br>Mfifodrain || Runs the specified functionality each time a selected EE offset is reached. FastForwardClock and AdvanceClock help fix core sync issues, but can be used as a speedhack. It is believed that AdvanceClock stalls the EE for a specified amount of cycles, while FastForwardClock behaves similarly. They are commonly used on affected COP2 instructions. Mfifodrain is still unknown. [[--ee-hook|For more examples]] ||--ee-hook=0x0025A9F2,AdvanceClock,,500 <br>--ee-hook=0x0019F0AD,FastForwardClock
FastForwardClock
Mfifodrain</pre> || <pre>Hook a function to a EE offset. it can be used either as a speedhack or to improve sync, FastForwardClock seems to overclock ee at the specified offset, AdvanceClock will do the opposite, FastForwardClock does not need a value to be set, AdvanceClock does.</pre> || --ee-hook=0x0028A7B0,AdvanceClock,,500 <pre>Example for usage: --ee-hook=offset,function,optional opcode,value for advanceclock only</pre>
|-
|-
|-style="background-color:#D7EF54"
|-style="background-color:#D7EF54"
|  || Game fixes || ||
|  || Game fixes || ||
|-
|-
| --ee-jit-pagefault-threshold || 0-254 || Reduces the occurrence of crashes the higher it is, only accepts 1 byte values with 254 being the limit|| --ee-jit-pagefault-threshold=40
| --ee-jit-pagefault-threshold || 0-254 || Ignore JIT pagefaults, usually caused by data placed right after code. JIT try to recompile it, and obviously hit some bad opcodes. This command reduces the occurrence of crashes the higher it is. || --ee-jit-pagefault-threshold=40
|-
| --ee-regalloc-scalar || 0,none,ReadOnly,WriteOnly,RW || Register allocation setting. Setting it to 0 may prevent crashes. ||
|-
|-
| --ee-block-validation || PageProt, PageProtection, Hash, Full, none || way of validating that block been modified, and require recompilation. [[https://github.com/PCSX2/pcsx2/blob/4db6b287cda817345f7ed4268a8a68f9fda76f26/pcsx2/Memory.cpp#L869| Some info about PageProt way]] || --ee-block-validation=None
| --ee-block-validation || PageProt, PageProtection, Hash, Full, none || way of validating that block been modified, and require recompilation. [[https://github.com/PCSX2/pcsx2/blob/4db6b287cda817345f7ed4268a8a68f9fda76f26/pcsx2/Memory.cpp#L869| Some info about PageProt way]] || --ee-block-validation=None
Line 214: Line 188:
| --ee-shorthash-len || inst_count/integer || Length of shorthash in instruction/opcode count. Require --ee-block-validation=Hash ||  
| --ee-shorthash-len || inst_count/integer || Length of shorthash in instruction/opcode count. Require --ee-block-validation=Hash ||  
|-
|-
| --ee-const-folding || None,Gpr,Fpu,All || EE constant folding, could potentially be used as a speedhack, [https://en.wikipedia.org/wiki/Constant_folding More info] || --ee-const-folding=none  
| --ee-const-folding || None,Gpr,Fpu,All || EE constant folding. "All" seems to be the default option. || --ee-const-folding=none  
|-
|-
| --ee-ignore-segfault || [none,R,W,RW] || Ignore segmentation fault, may help with crashes but will probably cause graphical issues || --ee-ignore-segfault=read
| --ee-ignore-segfault || none, read, write, readwrite || Ignore segmentation fault. Ignore rw from/to unmapped memory, known in pcsx2 as TLB miss (load.store) || --ee-ignore-segfault=readwrite
|-
|-
| --ee-native-function || <pre>memcpy  
| --ee-native-function || memset, memcpy, strlen, strcmp, strcasecmp, litodp, dptoli, floatdidf, fptoui, fptodp, dptofp, fabs, fabsf, ieee754_atan2f, ieee754_asinf, ieee754_acosf, ieee754_sinf, ieee754_cosf, ieee754_sqrtf, asinf, acosf, sinf, cosf, sqrtf. || Hook mips function with HLE x64 native version. Much faster, but tricky to keep correct timings on ps2 VM. || --ee-native-function=memcpy,0x11e328
memset </pre>||<pre>Seems to be a command that slows down offsets that use memset and memcpy to move data to VU1.
|-style="background-color:#FFAA00"
Check redfaction's config for more details.</pre>|| --ee-native-function=memcpy,0x11e328
|-style="background-color:#FEA15C"
|  || Other || ||
|  || Other || ||
|-
|-
| --ee-jit-disasm || 0 or 1 for mips and 2 for x86 || Emotion engine Just in Time disassembler mode (seems to be debug log option) || --ee-jit-disasm=1
| --ee-jit-disasm || 0 or 1 for mips and 2 for x86 || Emotion engine Just in Time disassembler mode (Likely a debug log option) || --ee-jit-disasm=1
|-
|-
| --ee-ignore-break || 0, 1 || Ignore Break instructions. ||  
| --ee-ignore-break || 0, 1 || Turns a BREAK instruction into a NOP Instruction. ||  
|-
|-
| --ee-break-as-nop || 0, 1 || Turns a break instruction into a nop Instruction (this seems to be rarely useful as Break usually mean eof) || --ee-break-as-nop=1
| --ee-break-as-nop || 0, 1 || Turns a BREAK instruction into a NOP Instruction. || --ee-break-as-nop=1
|-
|-
| --ee-jit-opt-debug || 0, 1 || ||
| --ee-jit-opt-debug || 0, 1 || ||
|-
|-
| --ee-pc-coherency || 0,1?? || Seems to be a debug option for the Program counter. ||  
| --ee-pc-coherency || 0, 1 || Flush PC register to memory on every mips opcode. Result in more accurate EE PC reg reads. ||  
|-
|-
| --ee-insn-flush-pc || 0, 1 || Flush PC register to memory on every mips opcode. Result in more accurate EE PC reg reads. ||
|-
| --ee-inst-marking || 0,1? || ||  
| --ee-inst-marking || 0,1? || ||  
|-
|-
| --ee-insn-marking || 0,1? || ||  
| --ee-insn-marking || 0,1? || ||  
|-
|-
| --ee-kernel-hle ||  0, 1 || High-level emulation kernel ||  
| --ee-kernel-hle ||  0, 1 || High-level emulation kernel. Apply HLE patches (used in mast1c0re part 2 Vulnerability 2). Apply EE kernel patches which run previously prepared x64 code instead of recompiling real code part. ||  
|-
|-
| --ee-injection-kernel || 0, 1 || ||
| --ee-injection-kernel || 0, 1 || Just like --ee-kernel-hle, except using a different name. ||
|-
|-
| --ee-injection-title || 0, 1 || ||
| --ee-injection-title || 0, 1 || Apply HLE patches (used in mast1c0re part 2 Vulnerability 2). Apply per title patches which run previously prepared x64 code instead of recompiling real code part. ||
|-
|-
| --ee-validate-kernel || 0, 1 || ||  
| --ee-validate-kernel || 0, 1 || ||  
|-
|-
| --ee-regalloc-scalar || 0,none,ReadOnly,WriteOnly,RW || register allocation setting ||  
| --ee-regalloc-simd || readwrite, writeonly, readonly || register allocation setting ||  
|-
|-
| --ee-regalloc-simd || || register allocation setting ||  
| --ee-regalloc-preserve-scalar || LoadOnly, LO, StoreOnly, SO, LoadStore,  LS || EE JIT Scalar/Int Regalloc Mode || --ee-regalloc-preserve-scalar=LoadStore
|-
|-
| --ee-regalloc-preserve-scalar ||  LoadOnly, StoreOnly, SO, LoadStore,  LS || EE JIT Scalar/Int Regalloc Mode || --ee-regalloc-preserve-scalar=LoadStore
| --ee-regalloc-preserve-simd || ReadOnly, RO, WriteOnly WO, RW || EE JIT SIMD/XMM Regalloc Mode || --ee-regalloc-preserve-simd=RW
|-
| --ee-regalloc-preserve-simd || ReadOnly, RO, WO, WriteOnly ,RW || EE JIT SIMD/XMM Regalloc Mode || --ee-regalloc-preserve-simd=RW
|-
|-
| --ee-static-block-links || options Type,Type,... [Branch,Branches,JAL,COP2,All] || || --ee-static-block-links=JAL,COP2
| --ee-static-block-links || options Type,Type,... [Branch,Branches,JAL,COP2,All] || || --ee-static-block-links=JAL,COP2
|-
|-
| --vtune-ee || || Could be support for intel vtune, [https://github.com/PCSX2/pcsx2/blob/master/cmake/FindVtune.cmake Might be related to this] ||
| --vtune-ee || || ||
|-
|-
| --ee-live32 || 0,1? || ||  
| --ee-live32 || 0,1? || ||  
|-
|-
| --ee-cache-breaks-block || 0,1? || ||
| --ee-cache-breaks-block || 0,1 || End recompiler block on r5900 cache opcode. ||
|-
|-
| --ee-evt-check-full || 0, 1 || ||  
| --ee-evt-check-full || 0, 1 || Perform more accurate EE event check ||  
|-
|-
| --ee-peephole || 0, 1? || Use peephole optimization for the EE (?) could possibly be a speedhack ||
| --ee-peephole || 0, 1? || ||
|-
|-
| --ee-load-rewrites || 0,1? || ||  
| --ee-load-rewrites || 0,1? || ||  
Line 272: Line 244:
| --ee-precompile-trace || || ||
| --ee-precompile-trace || || ||
|-
|-
| --ee-penalize-short-blocks || 0, 1 || ||
| --ee-penalize-short-blocks || 0, 1 || Add cycles to short recompiled blocks? ||
|-
|-
| --ee-mem-check-eob || || EE memory check end of block ||  
| --ee-mem-check-eob || || EE memory check end of block ||  
|-
|-
| --ee-insn-flush-pc || 0, 1 || A debug option that updates the EE's program counter more often when enabled ||
|-
| --ee-insn-callmark || || ||
| --ee-insn-callmark || || ||
|-  
|-  
| --ee-inline-limit-full || insn_count/integer || ||
| --ee-inline-limit-full || insn_count/integer || ||
|-
|-
| --ee-inline-limit-partial || || ||
| --ee-inline-limit-partial || || ||
Line 286: Line 256:
| --ee-stlf-cycle-threshold || ? ||?||  
| --ee-stlf-cycle-threshold || ? ||?||  
|-
|-
| --detect-idle-ee || 0, 1 || Enabled by default, Uknown what it does || --detect-idle-ee=1
| --detect-idle-ee || 0, 1 || || --detect-idle-ee=1
|-
|-
|}
|}


====FPU====
=====FPU=====
<pre>The FPU is a fast single-precision unit that serves the EE. It's also called (COP1).</pre>
<pre>The FPU is a fast single-precision unit that typically serves the EE by calculating in-game physics. It mostly controls the accuracy of the movement of in-game objects, or the game's gravity as a whole. In some cases, it is best to use COP2 commands with the FPU's to ensure the accuracy of the game's geometrical calculations.</pre>
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Values !! Notes !! Usage  
! Command !! Values !! Notes !! Usage  
Line 297: Line 267:
|  || Game fixes || ||
|  || Game fixes || ||
|-
|-
| --fpu-no-clamping || <pre> 1 = Enables clamping
| --fpu-no-clamping || 0, 1 || Changes the clamping behavior of the FPU. It's set to 1 by default. Might fix freezing issues, or misplaced characters/items (Inaccuracies with in-game physics) || --fpu-no-clamping=0
0 = Disables clamping</pre> || Setting it to 1 enables clamping for the FPU, Can be used to fix any game with FPU clamping issues, [https://www.psx-place.com/threads/research-ps2-emulator-configuration-on-ps4.16131/page-53#post-265591 More here] || --fpu-no-clamping=0
|-  
|-  
| --fpu-custom-min-max || 0, 1 || <pre>Custom Max/Mini logic for denormals, enabled by default, Disabling it might break some games</pre> || --fpu-custom-min-max=0
| --fpu-custom-min-max || 0, 1 || Custom Max/Mini logic for denormals. Enabled by default. Disabling it might break some games || --fpu-custom-min-max=0
|-  
|-  
| --fpu-accurate-range || start,end offset (0x0 - 0x1FFFFFF) || Accurate Mul/Div/Add/Sub Math instructions for the FPU by using software floats rather than hardware floats, used for full ee/fpu accuracy in specified range|| --fpu-accurate-range=0x1acce0,0x2acce0
| --fpu-accurate-range || start,end offset (0x0 - 0x1FFFFFF) || Accurate Mul/Div/Add/Sub Math instructions for the FPU by using software floats rather than hardware floats. Can be used for full EE/FPU Mathematical accuracy in the specified range. || --fpu-accurate-range=0x1acce0,0x2acce0
|-  
|-  
| --fpu-no-clamp-range || start,end offset (0x0 - 0x1FFFFFF) || Full clamping for fpu in selected memory range || --fpu-no-clamp-range=0x1acce0,0x2acce0
| --fpu-no-clamp-range || start,end offset (0x0 - 0x1FFFFFF) || Per-range clamping for the FPU in the selected memory range. || --fpu-no-clamp-range=0x1acce0,0x2acce0
|-  
|-  
| --fpu-accurate-muldiv  || <pre>0 = Disabled
| --fpu-accurate-muldiv  || 0 = Disabled<br>1 = Enabled || Allows the FPU to accurately Divide/Multiply for all offsets by using software floats rather than hardware floats. (Extremely slow) || --fpu-accurate-muldiv=1
1 = Enabled </pre> || Enable Accurate fpu divide/multiply by 0 for all offsets by using software floats rather than hardware floats || --fpu-accurate-muldiv=1
|-  
|-  
| --fpu-accurate-addsub || <pre>0 = Disabled
| --fpu-accurate-addsub || 0 = Disabled<br>1 = Enabled || Allows the FPU to accurately Add/Subtract for all offsets by using software floats rather than hardware floats. (Extremely slow) || --fpu-accurate-addsub=1
1 = Enabled </pre>|| Enable Accurate fpu Add/Subtract instructions for all offsets by using software floats rather than hardware floats || --fpu-accurate-addsub=1
|-  
|-  
| --fpjk-muldiv-range || offset (0x0 - 0x1FFFFFF) || Bully uses this command, unknown usage, possibly even more accurate divide/multiply || --fpjk-muldiv-range=0x123456
| --fpu-accurate-muldiv-range || start,end offset (0x0 - 0x1FFFFFF) || Allows the FPU to accurately Divide/Multiply in the specified ee memory range by using software floats rather than hardware floats. || --fpu-accurate-muldiv-range=0x1acce0,0x2acce0
|-  
|-  
| --fpu-accurate-muldiv-range || start,end offset (0x0 - 0x1FFFFFF) || Fix for games that divide/multiply by 0 in specified range by using software floats rather than hardware floats || --fpu-accurate-muldiv-range=0x1acce0,0x2acce0
| --fpu-accurate-addsub-range || start,end offset (0x0 - 0x1FFFFFF) || Allows the FPU to accurately Add/Subtract in the specified ee memory range by using software floats rather than hardware floats. || --fpu-accurate-addsub-range=0x1acce0,0x2acce0
|-
| --fpu-accurate-addsub-range || start,end offset (0x0 - 0x1FFFFFF) || Accurate fpu Add/Subtract instructions in specified address range by using software floats rather than hardware floats|| --fpu-accurate-addsub-range=0x1acce0,0x2acce0
|-
|-
|-style="background-color:#7698FF"
|-style="background-color:#7698FF"
|  || Speedhacks || ||
|  || Speedhacks || ||
|-
|-
| --fpu-rsqrt-fast-estimate || 0, 1 || less accurate rsqrt possible speedhack, but can degrade accuracy, enabled by default || --fpu-rsqrt-fast-estimate=1
| --fpu-rsqrt-fast-estimate || 0, 1 || Decreases RSQRT's accuracy. Enabled by default, disabling it helps with achieving full FPU accuracy. || --fpu-rsqrt-fast-estimate=1
|-
|-
| --fpu-accurate-mul-fast || 0, 1 || A speed up option for --fpu-accurate-muldiv-range And only has an effect when muldiv command is being used.  || --fpu-accurate-mul-fast=1
| --fpu-accurate-mul-fast || 0, 1 || Speedhack for CLI FPU muldiv commands.  || --fpu-accurate-mul-fast=1
|-style="background-color:#FEA15C"
|-style="background-color:#FFAA00"
|  || Other || ||
|  || Other || ||
|-
|-
| --fpu-custom-fused-madd || 0, 1 || <pre>Custom FMA (fused multiply-add), Disabled by default </pre>|| --fpu-custom-fused-madd=0
| --fpu-custom-fused-madd || 0, 1 || Custom FMA (fused multiply-add). Disabled by default. || --fpu-custom-fused-madd=0
|-
|-
| --fpu-to-double || 0, 1 || <pre>Converts floats to double, enabling it while
| --fpu-to-double || 0, 1 || Converts floats to doubles (Accurate). Limited testing shows that infinity is still wrong at 7F7FFFFF, rather than 7FFFFFFF with it enabled. || --fpu-to-double=1
clamping is enabled will result in Full FPU clamping</pre> ||
|-  
|-  
| --fpu-clamp-operands || 0, 1 || <pre>A clamping setting that is supposed to increase the fpu's clamping functionality when FPU clamping is enabled, but no difference is noticed for currently unknown reasons, Sony never used it in any official config, therefore no one is really sure of it's correct usage </pre> || --fpu-clamp-operands=1
| --fpu-clamp-operands || 0, 1 || Affects the fpu's clamping behavior || --fpu-clamp-operands=1
|-  
|-  
| --fpu-clamp-results || 0, 1 || <pre>A clamping setting that is supposed to increase the fpu's clamping functionality when FPU clamping is enabled, but no difference is noticed for currently unknown reasons, Sony never used it in any official config, therefore no one is really sure of it's correct usage </pre>  || --fpu-clamp-results=1
| --fpu-clamp-results || 0, 1 || Affects the fpu's clamping behavior || --fpu-clamp-results=1
|-  
|-  
|}
|}


====VIF====
===== COP2 =====
<pre>Decompresses vector data, uploads microprograms to the VUs, and sends graphical data to the GIF,
 
VIF CLI commands are mostly used for fixing games that freeze.</pre>
<pre>VU0 Macro-mode. These commands assist the FPU.</pre>
 
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Values !! Notes !! Usage
! Command !! Values !! Notes !! Usage  
|-style="background-color:#7698FF"
|  || Speedhacks || ||
|-
| --cop2-opt-flags || 0, 1 ,2 || Optimize flags upon recompilation (1 is safe, 2 update sticky, and mac flag on every status flag update) setting it to 0 can in some cases improve FPU accuracy. [https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L280 More Info] || --cop2-opt-flags=1
|-
| --cop2-opt-vf00 || 0, 1, 2 || Optimization for the vf00 register. || --cop2-opt-vf00=1
|-
| --cop2-const-prop || 0, 1 || Disables or enables constant propagation. Can Be Used as speedhack for COP2 hungry games when set to 1 [https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L312 More info] || --cop2-const-prop=1
|-
| --cop2-di-bits || 0, 1 || 0 to skip setting invalid, and div by Zero flags in status register, and therefore improve performance. Can be used as a speedhack to skip costly calculations. || --cop2-di-bits=0
|-style="background-color:#D7EF54"
|-style="background-color:#D7EF54"
|  || VIF || Game fixes ||
|  || Game fixes || ||
|-
|-
| --vif-ignore-invalid-cmd || 0, 1 || <pre>Ignore invalid vif commands, can in some cases fix games that freeze while showing the same frame when set to 1</pre> || --vif-ignore-invalid-cmd=1
| --cop2-no-clamping || 0, 1 || Changes the clamping behavior of the COP2. The default value is set to 1|| --cop2-no-clamping=0
|-
|-
| --vif-thread-chunk-size || 1, 1000 || Can be used to fix freezing in some extreme cases. 1024 seems to be the limit, Integer values only. ||  --vif-thread-chunk-size=100
| --cop2-accurate-range || start,end offset (0x0 - 0x1FFFFFF) ||Accurate Mul/Div/Add/Sub math instructions for the COP2 by using software floats rather than hardware floats. Can be used for full COP2 mathematical accuracy in the specified range. || --cop2-accurate-range=0x123456,0x134567
|-
| --cop2-no-clamp-range || start,end offset (0x0 - 0x1FFFFFF) || Per-range clamping for COP2. || --cop2-no-clamp-range=0x123456,0x134567
|-
| --cop2-accurate-mul-range || start,end offset (0x0 - 0x1FFFFFF) || Accurate multiplication instructions for the COP2 in the specified range by using software floats rather than hardware floats (Offset range seems not to directly match EE's) || --cop2-accurate-mul-range=0x123456,0x134567
|-
| --cop2-accurate-mul || 1 = Enabled<br>0 = Disabled || Allows the COP2 to accurately multiply for all offsets by using software floats rather than hardware floats. (Extremely slow) || --cop2-accurate-mul=1
|-
| --cop2-accurate-addsub ||  1 = Enabled<br>0 = Disabled || Allows the COP2 to accurately Add/Subtract for all offsets by using software floats rather than hardware floats. (Extremely slow) || --cop2-accurate-addsub=1
|-
|-
| --detect-idle-vif || 0, 1 || Enabled by default. Most likely turns off VIF when it's not needed when set to 0 || --detect-idle-vif=0
| --cop2-accurate-addsub-range || start,end offset (0x0 - 0x1FFFFFF) || Allows the COP2 to accurately Add/Sub in the specified ee memory range by using software floats rather than hardware floats. (Offset range seems not to directly match EE's. It is possibly 0x95400~ behind(?) || --cop2-accurate-addsub-range=0x123456,0x134567
|-style="background-color:#ff8080"
|  || VIF1 || Game fixes ||
|-
|-
| --vif1-ignore-cmd-ints || 0, 1 || <pre> ignore cmd ints, can in some cases fix games that freeze while showing the same frame when set to 1
|-style="background-color:#FFAA00"
Games likes "Men in Black II - Alien Escape" and
| || Other || ||
"Test Drive Unlimited" need it to be set to 1 to work</pre> || --vif1-ignore-cmd-ints=1
|-
| --vif1-instant-xfer || <pre> 1 = Instant transfers
0 = Delayed transfers</pre> || <pre>Allows you to change VIF1 timing, 1 is the default one, but 0 is much more correct and recommended, can be used to fix graphical glitches or to prevent the game from freezing when set to 0.</pre> || --vif1-instant-xfer=0
|-
|-
| --cop2-regalloc || 0, 1 ? || Optimized Register Allocation(?). PCSX2 seems to have this enabled by default. Seems to slow down COP2 when disabled. ||
|-
| --cop2-inst-q || 0, 1 || instant Q, no stalling on VWAITQ, or instances of Q. Crashes some games when enabled. ||
|-
| --cop2-inst-p || 0, 1 || instant P, no stalling on VWAITP, or instances of P. ||
|-
| --cop2-use-rcp || 0, 1 || Enables SSE RCP. Disabled by default ||
|-
| --cop2-use-rsqrt || 0, 1 || Enables SSE RSQRT || --cop2-use-rsqrt=0
|-
| --cop2-clamp-operands || 0, 1 || Affects the COP2's clamping behavior|| --cop2-clamp-operands=1
|-
| --cop2-clamp-results || 0, 1 || Affects the COP2's clamping behavior  || --cop2-clamp-results=1
|-
|}
|}


====GS====
==== Vector Units (VU) ====
<pre>GS stands for Graphics Synthesizer PlayStation®2 co-processor responsible for rendering the graphics (but is also used by some games for additional calculations and other purposes) The gs settings are rarely useful since the all rendering is done by software rather than hardware, meaning there will be much less graphical glitches than PCSX2's Hardware renderer, but sometimes autoflush and upscaling fixes will be necessary.</pre>
 
===== VU =====
 
<pre>Custom DSPs used to process vertex data, physics calculations, and other related tasks. Settings found here affect VU1, VU0, and COP2. They fix broken or missing geometry, black screens, and crashes.</pre>
 
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Values !! Notes !! Usage  
! Command !! Values !! Notes !! Usage  
|-style="background-color:#7698FF"
|-style="background-color:#ff99c2"
| || Speedhacks || ||
| || Graphical fixes || ||
|-
|-
| --gs-optimize-30fps || 0, 1 || Speedhack for gpu hungry games || --gs-optimize-30fps=1
| --vu-xgkick-delay  || Limit is between (0 => 31)  || Delay xgkick instruction execution. PCSX2 uses 6 cycles, PS3 uses 2-8 cycles depending on the game. A game with missing graphics will require a low value such as 0, while one that crashes might require a high value such as 7.|| --vu-xgkick-delay=8
|-
| --gs-adaptive-frameskip || 0, 1 || Speedhack, skips frames when the Game starts demanding more resources than there are available. doesn't work on all emulators. confirmed to be working on jak emulators || --gs-adaptive-frameskip=1
|-
|-
| --gs-render-tile-threshold || 0, 3000000 || <pre> Sony uses it for Psychonauts, could be a potential speedhack for the GS</pre> || --gs-render-tile-threshold=300000
| --vu-custom-min-max  || 0, 1 || Custom Max/Mini logic for denormals. Disabled on pcsx2 by default but enabled by default on a couple of emus such as jakv2. Disabling it could potentially restore missing graphics.|| --vu-custom-min-max=0
|-
| --threaded-gs || 0, 1 || Multi-threaded-gs ? unknown if it holds any performance benefits || --threaded-gs=1
|-
|-
|-style="background-color:#D7EF54"
|-style="background-color:#D7EF54"
|  || Gs settings / Behaviour || ||
|  || Game fixes || ||
|-
| --gs-use-deferred-l2h || 0, 1 || <pre>Some delay option for L2H (local to host, GS to EE).</pre> || --gs-use-deferred-l2h=1
|-
|-
| --gs-uprender || none,2x2 || Internal resolution upscaler. || --gs-uprender=2x2
| --vu-hack-triace  || 0, 1 || A hack designed specifically for games developed by Tri Ace. Corrects the VU's addi calculation. Without it, the result will be one bit off, which is enough to break the game's decryption algo. || --vu-hack-triace=1
|-  
|-  
| --gs-upscale || none, gpu, edgesmooth, smooth, motion, motionvec, motionvector, point || Upscaling type Selector || --gs-upscale=EdgeSmooth
| --vu-branch-hazard || 0, 1 || This command relates to how the emulator handles branch hazards in the Vector Units (VU). Setting it to 0 is the compatible option, while 1 might improve performance. Seems to be enabled by default. Disabling it managed to prevent "'''Batman - Rise of Sin Tzu'''" from crashing|| --vu-branch-hazard=0
|-  
|-  
| --gs-kernel-cl-up || "DarkCloud2" "h2lpool2x2", "OptRightTri", "clutmerge2x2", "mipmap2x2", "up2x2simple", "up2x2skipinterp", "up2x2tc", "up2x2", default || Kernel Variant Color lookup Upscaler (?), <pre>Mipmap and clutmerge and h2l will have to be enabled first before using their options</pre>|| --gs-kernel-cl-up="clutmerge2x2"
| --vu-evil-branches || 0, 1 || Take in count branch in delay slot, or not. [https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L306 More Info]||
|-  
|-  
| --gs-override-small-tri-area || 0, 1 || Enabling it might fix missing text. || --gs-override-small-tri-area=1
| --vu-to-double || 0, 1 || Converts floats to double. Enabling it is the accurate option. || --vu-to-double=1
|-
| --gs-dirty-page-policy || 0, 1 || || --gs-dirty-page-policy=1
|-
| --gs-ignore-dirty-page-border || 0, 1 || Could potentially help with lines on the edge of the screen (??) ||--gs-ignore-dirty-page-border=1
|-
| --gs-ignore-rect-correction || 0, 1 || || --gs-ignore-rect-correction=1
|-
|-
| --gs-opt-frbuff-switch || 0, 1 || || --gs-opt-frbuff-switch=0
| --vu-custom-fused-madd  || 0, 1 || Custom FMA (fused multiply-add). Disabled by default || --vu-custom-fused-madd=1
|-
| --gs-kernel-cl || h2lpool, clutmerge, mipmap, DarkCloud2, fantavision, <pre>Mipmap and clutmerge and h2l will have to be enabled first before using their options</pre> ||<pre>Kernel Variant Color lookup(?), you can upscale any option here if you use --gs-kernel-cl-up with it</pre> || --gs-kernel-cl="clutmerge"
|-  
|-  
| --force-frame-blend || 0, 1 || Fix for shaking screens (Deinterlacing), seems to be one of Pcsx2's Blend tff or Blend bff deinterlacing options || --force-frame-blend=1
|-style="background-color:#7698FF"
|| Speedhacks || ||
|-
|-
| --force-pal-60hz || 0, 1 || <pre>Force 60hz PAL mode, it is recommended to use it on Pal games as it can fix graphical corruptions</pre> || --force-pal-60hz=1
| --vu-opt-sf-check  || 0, 1 || Updates status flags only on blocks which will read them. Known in pcsx2 as mVU flag hack. Won't work with most emulators, but will work on Arc Twilight of the Spirits™ || --vu-opt-sf-check=1
|-
|-
| --gs-use-clut-merge || 0, 1 || CLUT = Color lookup table, it could possibly solve graphical issues or improve the quality of the colors. it is Required for CL kernels using merging CLUT || <pre>--gs-use-clut-merge=1</pre>
| --vu-opt-jr-caching  || 0, 1 || Optimize Jump Register caching. (vi15). Won't work with most emulators but will work on Arc Twilight of the Spirits™ || --vu-opt-jr-caching=1
|-style="background-color:#FEA15C"
|  || Other || ||
|-
| --vu-d-bit  || 0, 1 || Debug break. Halts the VU and sends an interrupt to the EE. || --vu-d-bit=0
|-  
| --vu-t-bit  || 0, 1 || Debug halt. Acts similarly to D-bit ||  --vu-t-bit=0
|-  
|-  
| --gs-use-mipmap || 0, 1 || <pre>Mipmapping enabler/disabler, Can be used to fix graphics sometimes.</pre> || <pre>--gs-use-mipmap=1</pre>
| --vu-inst-mflag  || 0, 1 || Instant macflag? It's enabled by default. When disabled, some texture chunks pop and fade. || --vu-inst-mflag=1
|-  
|-  
| --gs-progressive || 0, 1 || Force progressive scan, it's used to fix Graphical glitches/double screen issues when used ||
| --vu-inst-cflag || 0, 1 || Instant cflag? || --vu-inst-cflag=1
|-  
|-  
| --gs-vert-precision || 8, 16 || 3D Rendering vertex precision, the eboot expects the value of 8 or 16 , any other value will cause a blue screen crash. || --gs-vert-precision=8
| --vtune-vu  || ? || ? ||
|-
|-  
| --gs-force-bilinear || 0, 1 || force bilinear filtering. Can fix ghosting problems. but it's not recommended in games that use 2D images || --gs-force-bilinear=1
| --vu-jit-disasm  || 0, 1, 2 || ? || --vu-jit-disasm=1
|-
| --gs-skip-dirty-flush-on-mipmap || 0, 1 || Skip flushing the texture cache when mipmap settings change (?) Require mipmap GS CL kernel || <pre>--gs-skip-dirty-flush-on-mipmap=1</pre>
|-  
|-  
| --gs-packed15-fmv-opt || 0, 1 || || --gs-packed15-fmv-opt=1
| --vu-range-merge || vu_inst_cnt || ? ||  
|-  
|-  
| --gs-fieldswap-delay || 0, 254 || Wait longer than usual to change field, reduces Sharpness ||
|}
|-
 
| --gs-uv-shift-pointsampling || 0, 1 || Can be used with games like manhunt that have issues with [https://github.com/PCSX2/pcsx2/issues/257#issuecomment-1140338680 UV light] || --gs-uv-shift-pointsampling=1
===== VU1 =====
 
<pre>VU1 is the Graphics Synthesizer’s alternate processing unit. Commands here typically improve performance, prevent crashes, and fix SPS (graphical glitches).</pre>
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Values !! Notes !! Usage
|-style="background-color:#7698FF"
|| Speedhacks || ||
|-
| --vu1-mpg-cycles  || Decimals<br>0 - 65535 || Set initial speed for VU1 Micro-programs. 100 is the default value. If VU1 requirements were a bottleneck, increasing it will result in better performance while decreasing it will result in the opposite. Increasing it can be beneficial for MTVU sensitive games.|| --vu1-mpg-cycles=1000<br><pre> Symbols (They change values close to VU1-mpg-cycles' offset):
 
$ goes to the specified succeeding offsets. $0 will go 2 bytes forward and change them. $1 will go 4 bytes forward and change the 2 bytes specified. For example, $0,$1 will change the 4 bytes ahead as the specified 2 bytes' value.
 
'0x' Is like '+' a symbol that modifies succeeding values. 0x0 goes 2 bytes ahead and changes them, 0x1 goes 4 bytes ahead and so on and so forth.
 
'-' or '+' Changes the specified preceding or succeeding 2 bytes of VU1 mpg cycles' offset according to the added number. Adding -1, for example will change the 2 bytes before it. Likewise, adding -2 will go 4 bytes away and change the specified 2 bytes accordingly. It even can change EE cycle scalar itself if you go far enough. These numbers are in HEX. Infinite amounts of '-' and '+' symbols seem to be supported.</pre>
|-
|-
| --gs-aspect-ratio || aspect/float (default=0.81) || || --gs-aspect-ratio=0.65
| --vu1-di-bits || 0, 1 || 0 Skips setting invalid, and Divides by zero flags in status register. Can be used as a speedhack as it can skip costly calculations. But at the same time, it can cause issues such as broken geometry. || --vu1-di-bits=0
|-
|-
| --gs-frontend-opt-mode || 0, 1, 2 || Seems to be an optimization for the gs with 1 being safe and 2 being unstable but with good performance || --gs-frontend-opt-mode=1
| --vu1-const-prop || 0, 1|| Enabled by default. 0 will disable it and cause performance issues but with higher compatability.[https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L312 More info] || --vu1-const-prop=1
|-
| --gs-motion-factor || 25, 50 ||  || --gs-motion-factor=25
|-
|-
| --gs-scanout-delay || 0, 200 || || --gs-scanout-delay=200
| --vu1-opt-flags || 0, 1, 2 || Optimize flags upon recompilation (1 is safe, 2 update sticky, and mac flag on every status flag update) [https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L280 More Info] || --vu1-opt-flags=0
|-  
|-  
| --gs-scanout-offsetx || relative offset/ignored || Directly overwrite GS register? || --gs-scanout-offsetx=27
| --vu1-opt-vf00 || 0, 1, 2 || Optimization for the vf00 register. || --vu1-opt-vf00=2
|-  
|-  
| --gs-scanout-offsety || relative offset/ignored || Directly overwrite GS register? || --gs-scanout-offsety=27
| --vu1-jr-cache-policy || newprog, sameprog, auto, new, same || PCSX2 uses newprog as the default setting. Setting it into newprog has been proven to fix some crashes [https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L319 Info] || --vu1-jr-cache-policy=newprog
|-
| --gs-flush-ad-xyz || always, safe, safeZwrite, off, 0 || Force a primitive flush when a framebuffer is also an input texture, fixes some processing effects but it's very heavy on the GS and will cost you performance, GTA: SA and Jak games need this command. || --gs-flush-ad-xyz=safe
|-
|-
| --gs-check-trans-rejection || 0, || Check transfer rejection ? || --gs-check-trans-rejection=1
| --vu1-jalr-cache-policy || newprog, sameprog, auto, new, same || PCSX2 uses newprog as the default setting. Setting it into newprog has been proven to fix some crashes [https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L319 Info] || --vu1-jalr-cache-policy=newprog
|-  
|-  
| --gs-check-trans-rejection68 || 0, 1 || || --gs-check-trans-rejection68=1
|-style="background-color:#D7EF54"
|| Game fixes / Graphical fixes || ||
|-
|-
| --safe-area-min || area/float (range 0.9 to 1.0) any other values outside of that range will not be accepted by the emulator || || --safe-area-min=0.9
| --vu1 || jit-sync || Selector between IR/JIT and it modes. Jit-sync works similarly to disabling MTVU. jit, trans, and jit-async are unimplemented functions that do not change anything. || --vu1=jit-sync
|-
|-
| --l2h-2d-params || TRXREG,BITBLTBUF,height || || --l2h-2d-params=0x0000000800000001,0x000000003a0a2300,512,2
| --vu1-no-clamping || 0,1 || Changes the clamping behavior of the VU1. Setting specific to ps4 emulators, unimplemented in pcsx2, with 0 being closest to extra, and 1 to extra + preserve sign. The default emulator's value is 1. || --vu1-no-clamping=0
|-
| --vu1-clamp-range || vu1 memory offset start,end (0x0 - 0x7FF) || Values must not exceed 0x7FF ||
|-
|-
| --gs-h2l-accurate-hash || 0, 1 || Used with h2l Upscaler ||--gs-h2l-accurate-hash=1
| --vu1-accurate-addsub-range || vu1 memory offset start,end (0x0 - 0x7FF) ||  Allows the VU1 to accurately add/subtract in the specified ee memory range by using software floats rather than hardware floats.|| --vu1-accurate-addsub-range=0x0000,0x0600
|-
| --vu1-mul0fix-range || vu1 memory offset start,end (0x0 - 0x7FF) || Allows the VU1 to accurately multiply by 0 in the specified ee memory range by using software floats rather than hardware floats. || --vu1-mul0fix-range=0x123,0x123
|-
| --vu1-injection || 0, 1 || unknown || --vu1-injection=1
|-
|-
| --gs-h2l-list-opt || 0, 1 || Used with h2l Upscaler ||--gs-h2l-list-opt=1
| --vu1-native-patch || 0, 1 || Use native patches from recompiler, not compatible with jak emus. Sony uses it for their official release of Primal|| --vu1-native-patch=1
|-
|-
|-style="background-color:#FEA15C"
|-style="background-color:#FEA15C"
|  || Other || ||
|  || Other || ||
|-
|-
| --framelimit-mode || slowest,slower,slow,normal,fast,fastest,turbo || a Standalone Framelimiter|| --framelimit-mode=fast
| --vu1-inst-p ||0, 1 || instant P, no stalling on WAITP, or instances of P || --vu1-inst-p=1
|-
| --vu1-use-rcp || 0, 1 || Use SSE/AVX RCP. Speedhack. Likely used only in EFU pipeline, due to rare use, its really not worth to enable it. Speed improvement will be marginally/unnoticeable. Disabled by default ||
|-
| --vu1-use-rsqrt || 0, 1 || Use SSE/AVX rsqrt instead of doing sqrt and then div. Speedhack, rather safe to use on VU1. ||
|-  
|-  
| --gs-hdr-support || 0, 1? || Enable hdr support ?||
| --vu1-clamp-operands || 0, 1 || Clamp operands before mathematical operation. || --vu1-clamp-operands=1
|-
| --vu1-clamp-results || 0, 1 || Clamp result after mathematical operation. || --vu1-clamp-results=1
|- 
| --vu1-inst-q || 0, 1 || instant Q, no stalling on WAITQ, or instances of Q.  || --vu1-inst-q=1
|-
| --assert-path1-ad || 0, 1 || Path 1 is how the GIF takes data from VU1 via XGKICK instruction. It's unknown what this command does but it's related to VU1, and helps prevent crashes in VU1 sensitive games when enabled. || --assert-path1-ad=1
|-  
|-  
|}
|}


====VU====
=====VU0=====
<pre>Custom DSPs used to process vertex data, physics calculations, and other related tasks. Settings found here affect VU1 & VU0 & COP2</pre>
<pre>VU0 is the Emotion Engine’s alternate processing unit. It is sometimes referred to as "micro-mode". Commands here prevent crashes, and fix SPS (graphical glitches).</pre>
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Values !! Notes !! Usage  
! Command !! Values !! Notes !! Usage  
|-style="background-color:#ff99c2"
|-style="background-color:#7698FF"
| || Graphical fixes || ||
| || Speedhacks || ||
|-
| --vu0-mpg-cycles || Decimals<br>0 - 65535  || Set initial cycle speed for VU0 Micro-programs. 100 is the default value. It is not available in older emulators such as War of the Monsters. Raising the value helps COP2 timing, while lowering does the opposite.|| --vu0-mpg-cycles=1000<br><pre> Symbols (They change values close to VU0-mpg-cycles' offset):
 
$ goes to the specified succeeding offsets. $0 will go 2 bytes forward and changes them. $1 will go 4 bytes forward and changes the 2 bytes specified. For example, $0,$1 will change the 4 bytes ahead as the specified 2 bytes value.
 
'0x' Is like '+' a symbol that modifies succeeding values. 0x0 goes 2 bytes ahead and changes them, 0x1 goes 4 bytes ahead and so on and so forth.
 
'-' or '+' Changes the specified preceding or succeeding 2 bytes of VU0 mpg cycles' offset according to the added number. Adding -1, for example will change the 2 bytes before it. Likewise, adding -2 will go 4 bytes away and change the specified 2 bytes accordingly. It even can change EE cycle scalar itself at -15 (Jakv2). Setting it to --vu0-mpg-cycles=1280,-15 would, for example, set ee-cycle-scalar to 5. These numbers are in HEX. Infinite amounts of '-' and '+' instances seem to be supported.</pre>
|-
|-
| --vu-xgkick-delay  ||<pre> Limit is between
| --vu0-di-bits || 0, 1 || 0 to skip setting invalid, and Div by zero flags in status register. Can be used as speedhack as it skips costly calculations, but at the same time can cause issues like broken geometry, and weird physics behavior. Depending per game.|| --vu0-di-bits=0
(0 => 31) </pre> || <pre>Delay xgkick instruction execution, PCSX2 uses 6 cycles, PS3 uses 2-8 cycles depending on the game, Can be used to either cause or repair missing graphics, 0 is the most compatible</pre> || --vu-xgkick-delay=8
|-
|-
| --vu-custom-min-max || 0, 1 || <pre>Custom Max/Mini logic for denormals, Disabled on pcsx2 by default. But enabled by default on some emus like jakv2, Disabling it might cause/repair missing graphics, Setting it to 0 managed to fix missing graphics in Auto Modellista, and would probably fix many games with a similar problem</pre>|| --vu-custom-min-max=0
| --vu0-const-prop || 0, 1 || Constant propagation, can Be used as speedhack for VU0 hungry games when set to 1 [https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L312 More info] || --vu0-const-prop=1
|-
| --vu0-opt-vf00 || 0, 1, 2 || Optimization for the vf00 register. || --vu0-opt-vf00=1
|-
| --vu0-opt-flags  || 0, 1, 2 || Optimize flags upon recompilation (1 is safe, 2 update sticky, and mac flag on every status flag update) [https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L280 More Info] || --vu0-opt-flags=1
|-
| --vu0-jr-cache-policy || newprog, sameprog, auto, new, same || PCSX2 uses newprog as the default setting [https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L319 Info] || --vu0-jr-cache-policy=sameprog
|-
|-
| --vu0-jalr-cache-policy || newprog, sameprog, auto, new, same || PCSX2 uses newprog as the default setting [https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L319 Info] || --vu0-jalr-cache-policy=sameprog
|-style="background-color:#D7EF54"
|-style="background-color:#D7EF54"
|  || Game fixes || ||
|  || Game fixes || ||
|-
|-
| --vu-hack-triace  || 0, 1 || Special hack for games that were Developed by Tri Ace, correct VU addi calculation. Without it result is one bit off, which is enough to break game decryption algo, and thus crashing the game. || --vu-hack-triace=1
| --vu0-clamp-range || start, end offset (0x0 - 0x1FF) || per range clamping for VU0 || --vu0-clamp-range=0x100,0x120
|-  
|-  
| --vu-branch-hazard || 0, 1 || Disabling it managed to prevent Batman - Rise of Sin Tzu from Crashing|| --vu-branch-hazard=0
| --vu0-no-clamping || 0,1 || Changes the clamping behavior of the VU0. Setting specific to ps4 emulators, unimplemented in pcsx2. The default emulator's value is 1. || --vu0-no-clamping=0
|-  
|-  
| --vu-evil-branches || 0, 1 || Take in count branch in delay slot, or not. [https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L306 More Info]||
| --vu0-accurate-addsub-range || offset (0x0 - 0x1FF) ||Allows the VU0 to accurately Add/Subtract in the specified ee memory range by using software floats rather than hardware floats.||  
|-  
| --vu-to-double || 0, 1 || <pre>Converts floats to double, enabling it
while clamping is also enabled will results in Full VU clamping</pre> ||
|-
|-
| --vu-custom-fused-madd  || 0, 1 || <pre>Custom FMA (fused multiply-add), Disabled by default</pre> || --vu-custom-fused-madd=1
| --vu0-mul0fix-range || vu0 memory offset start,end (0x0 - 0x1FF) || Allows the VU0 to accurately Multiply by 0 in the specified ee memory range by using software floats rather than hardware floats ||
|-
|-style="background-color:#7698FF"
|  || Speedhacks || ||
|-
|-
| --vu-opt-sf-check  || 0, 1 || Updates status flags only on blocks which will read them, known in pcsx2 as mVU flag hack (Speedhack), Won't work with most emulators, confirmed to be supported by Arc Twilight of the Spirits™ || --vu-opt-sf-check=1
|- 
| --vu-opt-jr-caching  || 0, 1 || Optimize Jump Register caching. (vi15). Won't work with most emulators, confirmed to be supported by Arc Twilight of the Spirits™ || --vu-opt-jr-caching=1
|-style="background-color:#FEA15C"
|-style="background-color:#FEA15C"
|  || Other || ||
|  || Other || ||
|-
|-
| --vu-d-bit || 0, 1 || Debug break. Halts the VU and sends an interrupt to the EE. || --vu-d-bit=0
| --vu0-injection || 0, 1 || Unknown usage. || --vu0-injection=1
|-
| --vu0-inst-q || 0, 1 || instant Q, no stalling on WAITQ, or instances of Q  || --vu0-inst-q=1
|-  
|-  
| --vu-t-bit  || 0, 1 || Debug halt. Acts similarly to D-bit ||  --vu-t-bit=0
| --vu0-inst-p || 0, 1 || instant P, no stalling on WAITP, or instances of P|| --vu0-inst-p=1
|-
| --vu-inst-mflag  || 0, 1 || <pre>instant mac flag, enabled by default</pre> || --vu-inst-mflag=1
|-  
|-  
| --vu-inst-cflag || 0, 1 || <pre>instant clip flag enabled by default</pre>  || --vu-inst-cflag=1
| --vu0-use-rcp  || 0, 1 || Use SSE/AVX RCP. Speedhack. Not sure why it is even available for VU0. Disabled by default || --vu0-use-rcp=1
|-  
|-  
| --vtune-vu  || ? || ? ||
| --vu0-use-rsqrt || 0, 1 || Use SSE/AVX rsqrt instead of doing sqrt and then div. Speedhack, rather unsafe to use on VU0. || --vu0-use-rsqrt=1
|-  
|-  
| --vu-jit-disasm || 0, 1, 2 || VU Just-in-time Dissassembler? Seems to be a debug option, both 0 and 1 are mips, 2 is x86 || --vu-jit-disasm=1
| --vu0-clamp-operands || 0, 1 || Clamp operands before mathematical operation. || --vu0-clamp-operands=1
|-  
|-  
| --vu-range-merge || vu_inst_cnt || ? ||  
| --vu0-clamp-results  || 0, 1 || Clamp result after mathematical operation. || --vu0-clamp-results=1
|-  
|-  
|}
|}


====VU1====
====DMA Channels====
<pre>VU1 is the GS’s alternate processing unit, Commands here can possibly improve performance, Prevent crashes, and resolve SPS issues.</pre>
=====VIF=====
<pre>The VIF decompresses vector data, uploads microprograms to the VUs, and sends graphical data to the GIF. Its commands
are often used to fix freezing.</pre>
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Values !! Notes !! Usage  
! Command !! Values !! Notes !! Usage
|-style="background-color:#7698FF"
|-style="background-color:#D7EF54"
|  || Speedhacks || ||
|  || VIF || Game fixes ||
|-
| --vif-ignore-invalid-cmd || 0, 1 || Ignore invalid vif commands. In some cases, setting it to 1 can fix games that freeze while showing the same frame. || --vif-ignore-invalid-cmd=1
|-
|-
| --vu1-mpg-cycles  || <pre> 0.1 =
| --vif-thread-chunk-size || 0, 1024 || Slows down both VIFS the lower it is, and speeds them up the higher it is. 1024 is the limit, with 112 being the default value|| --vif-thread-chunk-size=100
Slowest
100 =
Default
1000 =
30 FPS</pre>|| <pre>Set cycle speed for VU1 Micro-programs, 100 is default value, Increase the value for better VU1 performance, With no downsides to FMVs, There are no limitations to the values, you can set the value more than 1000 though it's not recommended</pre>|| --vu1-mpg-cycles=1000
|-
|-
| --vu1-di-bits || 0, 1 || 0 to skip setting Invalid, and Div by zero flags in status register. Can be used as speedhack as it skips costly calculations, but at the same time can cause issues like broken geometry. however, it has never been found to cause any issues as of yet.|| --vu1-di-bits=0
| --detect-idle-vif || 0, 1 || Enabled by default. Unknown function || --detect-idle-vif=0
|-style="background-color:#ff8080"
|  || VIF1 || Game fixes ||
|-
|-
| --vu1-const-prop || 0, 1|| The constant propagation speedhack is enabled by default. 1 will enable the speedhack and thus improve performance, and 0 will disable it and cause performance issues.[https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L312 More info] || --vu1-const-prop=1
| --vif1-ignore-cmd-ints || 0, 1 || Set to 1 to ignore command interrupt bit. ([https://psi-rockin.github.io/ps2tek/#vifcommands info] , explanation of int bit is right before command list). Can in some cases fix games that freeze while showing the same frame if set to 1. Games likes "Men in Black II - Alien Escape" and "Test Drive Unlimited" Will always need it. || --vif1-ignore-cmd-ints=1
|-
|-
| --vu1-opt-flags || 0, 1, 2 || Optimize flags instances when do VU recompilation (1 is safe, 2 update sticky, and mac flag on every status flag update) [https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L280 More Info] || --vu1-opt-flags=0
| --vif1-instant-xfer || 1 = Instant VIF1<br>0 = Delayed VIF1 || Changes VIF1 timing. 0 slows its timing and is the compatible option for most games, while 1 speeds up its timing, and being more compatible with a small fraction of games. It can be used to fix graphical glitches or potentially prevent games from freezing. || --vif1-instant-xfer=0
|-
|}
| --vu1-opt-vf00 || 0, 1, 2 || Optimization for the vf00 register. Setting it to 1 is safe but setting it to 2 is highly unstable. || --vu1-opt-vf00=2
 
|-  
=====SIF=====
| --vu1-jr-cache-policy || newprog, sameprog, auto, new, same || PCSX2 uses newprog as default setting.[https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L319 Info] || --vu1-jr-cache-policy=sameprog
<pre>The SIF is how the EE and IOP communicate with each other. SIF has some mailbox hardware registers that the CPUs can use to pass values to each other, which happens during SIF initialization. However, once both sides have booted, they use the SIF0 (IOP->EE) and SIF1 (EE->IOP) DMA channels to communicate. Despite common belief, these commands have no effect on performance, and are rarely ever useful.</pre>
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Values !! Notes !! Usage
|-style="background-color:#99bbff"
| || || SIF1 (IOP) ||
|-
|-
| --vu1-jalr-cache-policy || newprog, sameprog, auto, new, same || PCSX2 uses newprog as default setting.[https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L319 Info] || --vu1-jalr-cache-policy=sameprog
| --iop-sif1-cycle-scalar || Accelerate SIF cycles: (0.99 => 0.1)<br>Decelerate SIF cycles: (1.1 => ∞ )|| Controls the speed at which the IOP receives from the EE || --iop-sif1-cycle-scalar=0.1
|-
|-style="background-color:#D7EF54"
|  || Game fixes / Graphical fixes || ||
|-
|-
| --vu1 || jit-sync,  jit, trans, jit-async || <pre>Selector between IR/JIT and it modes, jit-sync works similarly to disabling MTVU, but for some reason can sometimes cause massive graphical issues in some games. as for the options jit, trans, jit-async, it's still unknown if they have any effect</pre> || --vu1=jit-sync
| --ee-sif1-cycle-scalar ||Accelerate SIF cycles: (0.99 => 0.1)<br>Decelerate SIF cycles: (1.1 => ∞ )|| Controls the speed at which the EE sends to the IOP || --ee-sif1-cycle-scalar=0.1
|-style="background-color:#99ddff"
|  ||  || SIF0 (EE) ||
|-
|-
| --vu1-no-clamping || <pre> 1 = Enables clamping
| --iop-sif0-cycle-scalar || Accelerate SIF cycles: (0.99 => 0.1)<br>Decelerate SIF cycles: (1.1 => ∞ )|| Controls the speed at which the IOP sends to the EE || --iop-sif0-cycle-scalar=0.1
0 = Disables clamping</pre> || <pre>Can be used to fix graphical glitches, Some emulators like roguev1 or KOF2000 prefer clamping to be turned off.</pre> || --vu1-no-clamping=0
|-
| --vu1-clamp-range || vu1 memory offset start,end (0x0 - 0x3FF) || Values must be 2 bytes or lower and should not exceed 0x0800 ||
|-
|-
| --vu1-accurate-addsub-range || vu1 memory offset start,end (0x0 - 0x3FF) ||  Accurate VU1 Add/Subtract Instructions in specified Address Range by using software floats rather than hardware floats, Values must be 2 bytes or lower and should not exceed 0x0800 || --vu1-accurate-addsub-range=0x0000,0x0600
| --ee-sif0-cycle-scalar || Accelerate SIF cycles: (0.99 => 0.1)<br>Decelerate SIF cycles: (1.1 => ∞ )|| Controls the speed at which the EE receives from the IOP || --ee-sif0-cycle-scalar=0.1
|-
| --vu1-mul0fix-range || vu1 memory offset start,end (0x0 - 0x3FF) || Enables VU1 to accurately multiply by 0 in specified range || --vu1-mul0fix-range=0x123,0x123
|-
| --vu1-injection || 0, 1 || <pre>unknown</pre> || --vu1-injection=1
|-
| --vu1-native-patch || 0, 1 || <pre>Use native patches from recompiler, not compatible with jak emus, Could be VU1 round mode since sony uses it for their official release of Primal, and Primal is known to require that mode to work correctly.</pre>|| --vu1-native-patch=1
|-
|-
|-style="background-color:#FEA15C"
|  || Other || ||
|-
| --vu1-inst-p ||0, 1 || instant P, no stalling on WAITP, or instances of P || --vu1-inst-p=1
|-
| --vu1-use-rcp || 0, 1 || <pre>Use sse rcp, Disabled by default</pre> ||
|-
| --vu1-use-rsqrt || 0, 1 || <pre>Use sse rsqrt, Enabeled by default</pre> ||
|-
| --vu1-clamp-operands || 0, 1 ||<pre>A clamping setting that is supposed to increase the vu1's clamping functionality when vu1 clamping is enabled, but no difference is noticed for currently unknown reasons, Sony never used it in any official config, therefore no one is really sure of it's correct usage </pre> || --vu1-clamp-operands=1
|-
| --vu1-clamp-results || 0, 1 || <pre>A clamping setting that is supposed to increase the vu1's clamping functionality when vu1 clamping is enabled, but no difference is noticed for currently unknown reasons, Sony never used it in any official config, therefore no one is really sure of it's correct usage </pre>|| --vu1-clamp-results=1
|- 
| --vu1-inst-q || 0, 1 || <pre>Can fix or cause SPS depending on game.  instant Q, no stalling on WAITQ, or instances of Q, it's recommended for advanced users only since over 90% of the time this command will not be needed</pre>  || --vu1-inst-q=1
|-
| --assert-path1-ad || 0, 1 || Path 1 is how the GIF takes data from VU1 via XGKICK instruction. It's unknown what this command does but it's related to VU1 || --assert-path1-ad=1
|-
|}
|}


====VU0====
====[https://www.psdevwiki.com/ps2/Graphics_Synthesizer GS]====
<pre>VU0 is the EE’s alternate processing unit , it is also called "micro-mode"</pre>
<pre>"GS" stands for Graphics Synthesizer. It's the PlayStation®2's co-processor that's responsible for rendering the graphics (but is also used by some games for additional calculations and other purposes)</pre>
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Values !! Notes !! Usage  
! Command !! Values !! Notes !! Usage  
Line 579: Line 575:
|  || Speedhacks || ||
|  || Speedhacks || ||
|-
|-
| --vu0-mpg-cycles || <pre> 0.1 =
| --gs-optimize-30fps || 0, 1 || Speedhack for GS hungry games. || --gs-optimize-30fps=1
Slowest
|-
100 =
| --gs-adaptive-frameskip || 0, 1 || Speedhack. Skips frames when the gs demands more resources than there are available. doesn't work on all emulators.  It does however, work on jak emulators || --gs-adaptive-frameskip=1
Default
1000 =
Fast</pre> || <pre>Set cycle speed for VU0 Micro-programs, 100 is default value, increase the value for better VU0 performance though it won't improve performance as much as vu1, There are no limitations to the values, you can set the value more than 1000 though it's not recommended</pre> || --vu0-mpg-cycles=1000
|-
|-
| --vu0-di-bits || 0, 1 || 0 to skip setting Invalid, and Div by zero flags in status register. Can be used as speedhack as it skips costly calculations, but at the same time can cause issues like broken geometry, and weird physics behavior. Depending per game.|| --vu0-di-bits=0
| --gs-h2l-list-opt || 0, 1 || Setting it to 1 improves GS performance||--gs-h2l-list-opt=1
|-
|-
| --vu0-const-prop || 0, 1 || Constant propagation, can Be used as speedhack for VU0 hungry games when set to 1 [https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L312 More info] || --vu0-const-prop=1
|-style="background-color:#cbddfb"
|  || GS features || ||
|-
| --gs-use-mipmap || 0, 1 || Enables mipmapping support. Can be used to fix graphics. Needs --gs-kernel-cl="mipmap" for full mipmapping support. If upscaling, however, --gs-kernel-cl-up="mipmap2x2" is also needed. It works best on War of the Monsters emulator, as the Ratchet series' mipmapping issues can only be fixed by it.|| --gs-use-mipmap=1
|-  
|-  
| --vu0-opt-vf00  || 0, 1, 2 || Optimization for the vf00 register. Setting it to 1 is safe but setting it to 2 is highly unstable. || --vu0-opt-vf00=1
| --gs-use-deferred-l2h || 0, 1 || Delay option for L2H (local to host, GS to EE). || --gs-use-deferred-l2h=1
|-
| --gs-use-clut-merge || 0, 1 ||  Enabling CLUT merging helps improve how the emulator processes textures that use indexed color palettes. It ensures more accurate emulation of the PS2’s color handling. It sometimes restores missing graphical elements, and fix texture flickering (prominently flickering shadows or UI elements).  It prevents Spyro's shadow from flickering in Enter the Dragonfly. Enabling it is the accurate, albeit slow option. || --gs-use-clut-merge=1
|-  
|-  
| --vu0-opt-flags  || 0, 1, 2 || Optimize flags when do VU recompilation (1 is safe, 2 update sticky, and mac flag on every status flag update) [https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L280 More Info] || --vu0-opt-flags=1
| --gs-flush-ad-xyz || always, safe, safeZwrite, off, 0 || Force a primitive flush when a framebuffer is also an input texture. This fixes some processing effects, but it can sometimes be heavy on the GS in terms of performance. GTA: SA, and Jak 3 use this command. || --gs-flush-ad-xyz=safe
|-  
|-
| --vu0-jr-cache-policy || newprog, sameprog, auto, new, same || PCSX2 use newprog as default setting [https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L319 Info] || --vu0-jr-cache-policy=sameprog
| --gs-force-bilinear || 0, 1 || Forces bilinear filtering, can fix ghosting problems in some cases. Not recommended for games that use 2D images, as it could possibly break games that rely on nearest filtering.|| --gs-force-bilinear=1
|-
|-
| --vu0-jalr-cache-policy || newprog, sameprog, auto, new, same || PCSX2 use newprog as default setting [https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L319 Info] || --vu0-jalr-cache-policy=sameprog
|-style="background-color:#D7EF54"
|-style="background-color:#D7EF54"
|  || Game fixes || ||
|  || Gs settings / Behaviour || ||
|-
|-
| --vu0-clamp-range || start, end offset (0x0 - 0xA000) || per range clamping for VU0 || --vu0-clamp-range=0x100,0x120
| --gs-uprender || none,2x2 || Internal resolution upscaler. || --gs-uprender=2x2
|-  
|-  
| --vu0-no-clamping || <pre> 1 = Enables clamping
| --gs-upscale || none, gpu, edgesmooth, smooth, motion, motionvec, motionvector, point || Upscaling type Selector || --gs-upscale=EdgeSmooth
0 = Disables clamping</pre> || <pre>Can be used to fix graphical glitches, Some emulators like roguev1 or KOF2000 prefer clamping to be turned off.</pre>  || --vu0-no-clamping=0
|-  
|-  
| --vu0-accurate-addsub-range || offset (0x0 - 0xA000) || Accurate VU0 Add/Subtract Instructions in specified Address range by using software floats rather than hardware floats ||
| --gs-kernel-cl-up || "DarkCloud2" "fantavision" "h2lpool2x2", "OptRightTri", "clutmerge2x2", "mipmap2x2", "up2x2simple", "up2x2skipinterp", "up2x2tc", "up2x2", default || Kernel Variant Color lookup Upscaler (?), mipmap and clutmerge and h2l need to be enabled before their options become usable|| --gs-kernel-cl-up="clutmerge2x2"
|-
| --vu0-mul0fix-range || vu0 memory offset start,end (0x0 - 0xA000) || Fix for games that multiply by zero ||
|-
|-style="background-color:#FEA15C"
|  || Other || ||
|-
| --vu0-injection || 0, 1 || Uknown usage. || --vu0-injection=1
|-
| --vu0-inst-q  || 0, || instant Q, no stalling on WAITQ, or instances of Q  || --vu0-inst-q=1
|-  
|-  
| --vu0-inst-p || 0, 1 || instant P, not stalling on WAITP, or instances of P|| --vu0-inst-p=1
| --gs-override-small-tri-area || 0, 1 || This option is designed to modify how the emulator handles or renders small triangles that fall below a certain area threshold. Enabling this option could resolve graphical problems such as missing, flickering, or incorrectly rendered small details, and could potentially restore missing text in some games. || --gs-override-small-tri-area=1
|-  
|-  
| --vu0-use-rcp  || 0, 1 || use sse rcp || --vu0-use-rcp=1
| --gs-dirty-page-policy || 0, 1 || Unknown. Used by Star Wars: Jedi Starfighter || --gs-dirty-page-policy=1
|-  
|-  
| --vu0-use-rsqrt || 0, 1 || use sse rsqrt || --vu0-use-rsqrt=1
| --gs-ignore-dirty-page-border || 0, 1 || Unknown. Used by Samurai Shodown Anthology ||--gs-ignore-dirty-page-border=1
|-  
|-  
| --vu0-clamp-operands  || 0, 1 || <pre>A clamping setting that is supposed to increase the vu0's clamping functionality when vu0 clamping is enabled, but no difference is noticed for currently unknown reasons, Sony never used it in any official config, therefore no one is really sure of it's correct usage </pre> || --vu0-clamp-operands=1
| --gs-ignore-rect-correction || 0, 1 || Setting it to 1 is known to fix flickering textures and graphical glitches in far distances. || --gs-ignore-rect-correction=1
|-
| --gs-opt-frbuff-switch || 0, 1 ||  Unknown. Used by Everybody's Tennis/Hot Shots Tennis || --gs-opt-frbuff-switch=0
|-
| --gs-kernel-cl || h2lpool, clutmerge, mipmap, DarkCloud2, fantavision, Mipmap and clutmerge and h2l need to be enabled before their options become usable ||Kernel Variant Color lookup(?). Options included here can be upscaling if --gs-kernel-cl-up were to be used along with it || --gs-kernel-cl="clutmerge"
|-  
|-  
| --vu0-clamp-results  || 0, 1 || <pre>A clamping setting that is supposed to increase the vu0's clamping functionality when vu0 clamping is enabled, but no difference is noticed for currently unknown reasons, Sony never used it in any official config, therefore no one is really sure of it's correct usage </pre> || --vu0-clamp-results=1
| --force-frame-blend || 0, 1 || Enables blend (Deinterlacing?). Should be used to fix games with shaking screens. || --force-frame-blend=1
|-
| --force-pal-60hz || 0, 1 || Enables 60hz PAL mode. || --force-pal-60hz=1
|-
| --gs-progressive || 0, 1 || Enables progressive scan. Can fix graphical glitches/double screen issues.  ||
|-  
|-  
|}
| --gs-vert-precision || 8, 16 || This option allows the user to choose between 8-bit and 16-bit precision for the vertex calculations in 3D graphics rendering. It reduces the likelihood of visual distortions such as jagged edges, improper alignment of polygons, or model "warping." The emu expects the values of 8 or 16, any other values are not permitted. || --gs-vert-precision=8
 
====COP2====
<pre>COP2, Also known as VU0 Macro-mode. these commands "may" only be useful for games that use M-bit</pre>
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Values !! Notes !! Usage
|-style="background-color:#7698FF"
| || Speedhacks || ||
|-
|-
| --cop2-opt-flags || 0, 1 ,2 || Optimize flags when do VU recompilation (1 is safe, 2 update sticky, and mac flag on every status flag update) [https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L280 More Info] || --cop2-opt-flags=1
| --gs-skip-dirty-flush-on-mipmap || 0, 1 || Skip flushing textures marked as dirty from cache when enabled. It does, however, require mipmap to be enabled first. || --gs-skip-dirty-flush-on-mipmap=1
|-  
|-  
| --cop2-opt-vf00 || 0, 1, 2 || Optimization for the vf00 register. Setting it to 1 is safe but setting it to 2 is highly unstable. || --cop2-opt-vf00=1
| --gs-packed15-fmv-opt || 0, 1 || Unknown. This option likely controls whether the emulator optimizes or processes FMVs that use the 15-bit packed color format. Used by Ape Escape 2|| --gs-packed15-fmv-opt=1
|-  
|-  
| --cop2-const-prop || 0, 1 || Constant propagation, Can Be Used as speedhack for cop2 hungry games when set to 1 [https://github.com/PCSX2/pcsx2/blob/58f5a5b915915293b90e7e8f34c33f9c0424d1e8/pcsx2/x86/microVU_Misc.h#L312 More info] || --cop2-const-prop=1
| --gs-fieldswap-delay || 0, 254 || Wait longer than usual to change field. In essence, it blurs/sharpens image. ||
|- 
| --gs-uv-shift-pointsampling || 0, 1 || Can be used on games like manhunt that have issues with [https://github.com/PCSX2/pcsx2/issues/257#issuecomment-1140338680 UV light rendering] || --gs-uv-shift-pointsampling=1
|-
| --gs-render-tile-threshold || 0, 3000000 || Unknown. Used by Psychonauts|| --gs-render-tile-threshold=300000
|-
| --threaded-gs || 0, 1 || Multi-threaded-gs ? || --threaded-gs=1
|-
| --gs-aspect-ratio || aspect/float (default=0.81) || || --gs-aspect-ratio=0.65
|-
| --gs-frontend-opt-mode || 0, 1, 2 || GS optimization mode? Unknown effect. Used on JakX || --gs-frontend-opt-mode=1
|-  
|-  
| --cop2-di-bits || 0, 1 || 0 to skip setting Invalid, and Div by Zero flags in status register, and therefore improve performance. Can be used as speedhack as it skip costly calculations. || --cop2-di-bits=0
| --gs-motion-factor || 25, 50 || Unknown. Used by Wild ARMS 3|| --gs-motion-factor=25
|-style="background-color:#D7EF54"
|  || Game fixes || ||
|-
|-
| --cop2-no-clamping || <pre> 1 = Full clamping
| --gs-scanout-delay || 0, 200 ||  || --gs-scanout-delay=200
0 = No clamping</pre> || <pre>Can be used to fix graphical glitches, Some emulators like roguev1 or KOF2000 prefer clamping to be turned off.</pre> || --cop2-no-clamping=0
|-
|-
| --cop2-accurate-range || start,end offset (0x0 - 0x1FFFFFF) || Accurate COP2 Assembly instructions in the cop2 Address range by using software floats rather than hardware floats, Can be used to fix SPS || --cop2-accurate-range=0x123456,0x134567
| --gs-check-trans-rejection || 0, || Check transfer rejection? Unknown. Used by Grand Theft Auto: Vice City || --gs-check-trans-rejection=1
|-  
|-  
| --cop2-no-clamp-range || start,end offset (0x0 - 0x1FFFFFF) || Full clamping for COP2 in selected range || --cop2-no-clamp-range=0x123456,0x134567
| --gs-check-trans-rejection68 || 0, 1 || Unknown. Used by Star Wars: Jedi Starfighter || --gs-check-trans-rejection68=1
|-
| --l2h-2d-params || TRXREG,BITBLTBUF,height ||  || --l2h-2d-params=0x0000000800000001,0x000000003a0a2300,512,2
|-
| --gs-h2l-accurate-hash || 0, 1 ||  ||--gs-h2l-accurate-hash=1
|-
|-style="background-color:#9042f5"
|  || Aspect ratio || ||
|-
| --gs-scanout-offsetx || relative offset/ignored || A zoom in setting in the x direction || --gs-scanout-offsetx=27
|-  
|-  
| --cop2-accurate-mul-range || start,end offset (0x0 - 0x1FFFFFF) || Accurate Multiplication instructions in the cop2 Address range by using software floats rather than hardware floats || --cop2-accurate-mul-range=0x123456,0x134567
| --gs-scanout-offsety || relative offset/ignored || A zoom in setting in the y direction || --gs-scanout-offsety=27
|-
| --cop2-accurate-mul || <pre>1 = Enabled
0 = Disabled</pre> || Accurate Multiplication instructions for all offsets by using software floats rather than hardware floats || --cop2-accurate-mul=1
|-
| --cop2-accurate-addsub ||  <pre>1 = Enabled
0 = Disabled </pre>|| Accurate Add/Subtract instructions for all offsets by using software floats rather than hardware floats || --cop2-accurate-addsub=1
|-
|-
| --cop2-accurate-addsub-range || start,end offset (0x0 - 0x1FFFFFF) || Accurate Add/Subtract instructions in the cop2 Address range by using software floats rather than hardware floats || --cop2-accurate-addsub-range=0x123456,0x134567
| --safe-area-min || area/float (range 0.9 to 1.0) any other values outside of that range will be rejected by the emulator || An overscan setting|| --safe-area-min=0.9
|-
|-
|-style="background-color:#FEA15C"
|-style="background-color:#FEA15C"
|  || Other || ||
|  || Other || ||
|-
|-
| --cop2-regalloc || 0, 1 ? || PCSX2 seems to have this enabled by default. ||
| --framelimit-mode || slowest,slower,slow,normal,fast,fastest,turbo ||Standalone Framelimiter|| --framelimit-mode=fast
|-
|-
| --cop2-inst-q || 0, 1 || instant Q, no stalling on VWAITQ, or instances of Q. ||
| --framelimiter || 0, 1 || Enable or disable Frame limiting || --framelimiter=1
|-
| --cop2-inst-p || 0, 1 || instant P, no stalling on VWAITP, or instances of P. ||
|-
| --cop2-use-rcp || 0, 1 || use sse rcp ||
|-
| --cop2-use-rsqrt || 0, 1 || use sse rsqrt || --cop2-use-rsqrt=0
|-  
| --cop2-clamp-operands || 0, 1 || <pre>A clamping setting that is supposed to increase the cop2's clamping functionality when cop2 clamping is enabled, but no difference is noticed for currently unknown reasons, Sony never used it in any official config, therefore no one is really sure of it's correct usage </pre>|| --cop2-clamp-operands=1
|-
| --cop2-clamp-results || 0, 1 || <pre>A clamping setting that is supposed to increase the cop2's clamping functionality when cop2 clamping is enabled, but no difference is noticed for currently unknown reasons, Sony never used it in any official config, therefore no one is really sure of it's correct usage </pre>  || --cop2-clamp-results=1
|-
|}
 
====CDVD====
<pre>Commands for changing the nature of CDVD emulation.</pre>
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Values !! Notes !! Usage
|-style="background-color:#D7EF54"
|  || Game fixes || ||
|-
|-
| --cdvd-sector-read-cycles || <pre>0.1 = Fastest,
| --framelimit-fps ||  FPS/float || framelimiter || --framelimit-fps=0.8
  80000 = Slowest</pre> || <pre>Set DVD reading speed, higher values are slower,
lower values are faster, Kinetica uses 40000,
Psychonauts 4000, Red dead revolver 5000, Rise of kasai 31000,
some games require moderate speed, too slow or too fast could cause audio problems.</pre>|| --cdvd-sector-read-cycles=40000
|-
| --cdvd-sector-seek-cycles || <pre>0.1 = Fastest,
80000 = Slowest</pre> || <pre>Set the speed at which the emulated CDVD spins, higher values are slower,
lower values are faster, fixes boot-up sometimes.</pre> More info here [https://github.com/PCSX2/pcsx2/pull/3877]. || --cdvd-sector-seek-cycles=1
|-style="background-color:#FEA15C"
|  || Misc || ||
|-
| --max-disc-num || 1-5  || Numbers of discs in package (maximum=5)  || --max-disc-num=1
|-
| --boot-disc-id || 1-5  ||  Sets boot disc for multi-disc pkg || --boot-disc-id=0
|-
| --switch-disc-reset || <pre> 1 = Enables resetting the game upon disc swap
0 = Disables resetting the game upon disc swap</pre>|| <pre> 0 Can be used to prevent Resetting the game when switching multiple discs, useful for games like Samurai warriors 2 that have Import data Feature, Sadly this command isn't supported by many emulators, but jakv2 is confirmed to support it</pre> || --switch-disc-reset=1
|-
| --cdvd-determinism || 0, 1|| (?) || --cdvd-determinism=1
|-
| --verbose-cdvd-reads || 0, 1 || Seems to slightly improve reading speed when enabled (?) || --verbose-cdvd-reads=1
|-
|-
| --gs-hdr-support || 0, 1? || ? ||
|}
|}


====IOP====
====IOP====
<pre>The emulated I/O Processor (IOP) settings, Commands here are rarely useful, since the ps4 emulates it very accurately, very few games will require these options. the iop controls the emulated DEV9, SPU2, USB, Memory cards, CDVD, Firewire, along with other input/output Devices</pre>
<pre>The emulated I/O Processor (IOP) settings. Commands here are rarely useful, as very few games will require them. The IOP controls the emulated DEV9, SPU2, USB, Memory cards, CDVD, Firewire, along with other input/output devices</pre>
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Values !! Notes !! Usage  
! Command !! Values !! Notes !! Usage  
Line 720: Line 679:
|  || Game fixes || ||
|  || Game fixes || ||
|-
|-
| --iop-cycle-scalar || <pre> [Overclocking]
| --iop-cycle-scalar ||<br>Accelerate IOP cycles: (0.999 => 0.100)<br>Decelerate IOP cycles: (1.001 => 5.000)|| '''Not a performance speedhack'''. It impacts the speed of loading times and input latency. The default value for most emulators is 0.5|| --iop-cycle-scalar=1.0
(0.99 => 0.1)  
[Underclocking]
(1.1 => 5.0)</pre> || '''Not a Speedhack''', when you lower it below 1.0 the iop is overclocked, when you increase it above 1.0 the iop cycles are skipped. the only thing you will notice from this is faster/slower loading speed|| --iop-cycle-scalar=1.0
|-
|-
| --iop-const-folding || None,Gpr,All || IOP constant folding [https://en.wikipedia.org/wiki/Constant_folding More info] || --iop-const-folding=All
| --iop-const-folding || None,Gpr,All || IOP constant folding [https://en.wikipedia.org/wiki/Constant_folding More info] || --iop-const-folding=All
|-
|-
| --iop-tight-slice-count || 12? || || --iop-tight-slice-count=12
| --iop-tight-slice-count || 0, 2000 || Seems to slow down the iop the higher the value. Can be used to fix CDVD timing issues. || --iop-tight-slice-count=12
|-
|-
| --iop-hook || AdvanceClock, FastForwardClock || <pre>IOP native hook, Sony uses it on their official release of Red dead revolver</pre> || --iop-hook=0x0086ac,FastForwardClock
| --iop-hook || AdvanceClock<br>FastForwardClock<br>Mfifodrain || IOP native hook, Sony uses it on their official release of Red dead revolver. It helps fix timing issues || --iop-hook=0x0086ac,FastForwardClock
|-
|-
| --iop-block-validation || IsC, ShortHash, Hash || Way of validating that block been modified, and require recompilation, other Possible values include PageProt, None, PageProtection || --iop-block-validation=IsC
| --iop-block-validation || IsC, ShortHash, Hash || Way of validating that block been modified, and require recompilation. Other Possible values include PageProt, None, PageProtection || --iop-block-validation=IsC
|-
|-
|-style="background-color:#FEA15C"
|-style="background-color:#FEA15C"
Line 740: Line 696:
| --iop-shorthash-len || inst_count/integer || Length of shorthash in instruction/opcode count. Require --iop-block-validation=ShortHash ||  
| --iop-shorthash-len || inst_count/integer || Length of shorthash in instruction/opcode count. Require --iop-block-validation=ShortHash ||  
|-
|-
| --iop-pc-coherency || 0, 1|| Most likely updates the (Program counter) more frequently for the iop (?)   ||  
| --iop-pc-coherency || 0, 1||  ||  
|-
|-
| --iop-inst-marking || 0, 1? || ||  
| --iop-inst-marking || 0, 1? || ||  
|-
|-
| --detect-idle-iop || 0, 1 || enabled by default, set to 0 in order to disable it || --detect-idle-iop=0
| --detect-idle-iop || 0, 1 || Enabled by default. || --detect-idle-iop=0
|-
|-
| --iop-jit-disasm || || ||  
| --iop-jit-disasm || || ||  
|-
|-
| --iop-evt-check-full || || ||  
| --iop-evt-check-full || 0, 1 ?|| ||  
|-
|-
|}
|}


====SIF====
====CDVD====
<pre>The SIF is how the EE and IOP communicate with each other. SIF has some mailbox hardware registers that the CPUs can use to pass values to each other, which happens during SIF initialization. However, once both sides have booted, they use the SIF0 (IOP->EE) and SIF1 (EE->IOP) DMA channels to communicate. Despite common belief, these commands have no effect on performance, and are rarely ever useful.</pre>
 
<pre>The emulated CDVD settings. These commands help games with timing issues.</pre>
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Values !! Notes !! Usage  
! Command !! Values !! Notes !! Usage  
|-style="background-color:#99bbff"
|-style="background-color:#e9f562"
|  ||  || SIF1 (IOP) ||
|  || General commands || ||
|-
| --max-disc-num || 1-5 || numbers of discs in package (maximum=5) || --max-disc-num=1
|-
| --boot-disc-id || 1-5  ||  sets boot disc for multi-disc pkg || --boot-disc-id=0
|-
|-
| --iop-sif1-cycle-scalar || <pre> [Overclocking]
| --switch-disc-reset || 1 = Enables resetting the game upon disc swap, 0 = Disables resetting the game upon disc swap|| 0 Can be used to prevent resetting the game when switching multiple discs. Useful for games like Samurai warriors 2 that include an import data feature. Sadly this command isn't supported by many emulators, but jakv2 is confirmed to support it || --switch-disc-reset=1
(0.99 => 0.1)
|-style="background-color:#46a4e8"
[Underclocking]
|  || Timing || ||
(1.1 => ∞ )</pre>|| It controls how much data the IOP recieves from the EE || --iop-sif1-cycle-scalar=0.1
|-
|-
| --ee-sif1-cycle-scalar || <pre> [Overclocking]
| --cdvd-sector-read-cycles || 0.1 = Fastest, 80000 = Slowest|| Set DVD reading speed. Higher values are slower, lower values are faster. Kinetica uses 40000, Psychonauts 4000, Red dead revolver 5000, Rise of kasai 31000. Some games require moderate speed, too slow or too fast could cause audio problems.|| --cdvd-sector-read-cycles=0.1
(0.99 => 0.1)
[Underclocking]
(1.1 => ∞ )</pre> || It controls how much data the EE sends to the IOP || --ee-sif1-cycle-scalar=0.1
|-style="background-color:#99ddff"
|  ||  || SIF0 (EE) ||
|-
|-
| --iop-sif0-cycle-scalar || <pre> [Overclocking]
| --cdvd-sector-seek-cycles || 0.1 = Fastest, 80000 = Slowest || Set the speed at which the emulated CDVD spins. Higher values are slower,
(0.99 => 0.1)
lower values are faster. Fixes boot-up sometimes. More info here [https://github.com/PCSX2/pcsx2/pull/3877].
[Underclocking]
(1.1 => ∞ )</pre>|| It controls how much data the IOP sends to the EE || --iop-sif0-cycle-scalar=0.1
|-
|-
| --ee-sif0-cycle-scalar || <pre> [Overclocking]
| --verbose-cdvd-reads || 0, 1 || Significantly helps games with CDVD timing issues when set to 1. || --verbose-cdvd-reads=0
(0.99 => 0.1)
[Underclocking]
(1.1 => ∞ )</pre>|| It controls how much data the EE recieves from the IOP || --ee-sif0-cycle-scalar=0.1
|-
|-
|}
|}


====Misc====
====Misc====
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Values !! Notes !! Usage
! Command !! Values !! Notes !! Usage
|-
|-
| --idec-cycles-per-qwc || int/multiplier || Probably related to the ipu|| --idec-cycles-per-qwc=768
| --idec-cycles-per-qwc || int/multiplier || Multiply how many cycles IDEC command take per whole currently worked on QWC. || --idec-cycles-per-qwc=768
|-
|-
| --mfifo-manual-drain || 0.1/5.0 || A command for changing the functionality of --ee-hook=0x0,Mfifodrain ||--mfifo-manual-drain=0.30  
| --mfifo-manual-drain || 0.1/5.0 || A command for changing the functionality of --ee-hook=0x0,Mfifodrain ||--mfifo-manual-drain=0.30  
Line 793: Line 744:
| --mfifo-chunk-drain-cycles || 1/400000 || A command for changing the functionality of --ee-hook=0x0,Mfifodrain ||--mfifo-chunk-drain-cycles=210000
| --mfifo-chunk-drain-cycles || 1/400000 || A command for changing the functionality of --ee-hook=0x0,Mfifodrain ||--mfifo-chunk-drain-cycles=210000
|-
|-
| --pcr0-delta-hack || 0.1 , 400000 || || --pcr0-delta-hack=1
| --pcr0-delta-hack || 0.1 , 400000.0 || Modify delta of pcr0 when reading it from MFC0. Some games rely on good performance counters accuracy (Spyro ANB cutscenes), and since emulator don't implement most events, hack it is. || --pcr0-delta-hack=1.0
|-
| --jitproc-use-aslr || || Disables compiler process ASLR, useful for easier debugging, as the compiler process will be always on fixed address. Theoretically useful for mast1c0re, but to change it you need to be already in... || --jitproc-use-aslr=0
|-
|-
| --jitproc-use-aslr || || ||
| --detect-idle-intc ||0, 1|| Enabled by default, 0 disables it || --detect-idle-intc=0
|-
|-
| --detect-idle-intc ||0, 1|| enabled by default, set to 0 in order to disable it || --detect-idle-intc=0
| --detect-idle-chcr|| 0, 1|| Enabled by default, 0 disables it || --detect-idle-chcr=0
|-
|-
| --detect-idle-chcr|| 0, 1|| enabled by default, set to 0 in order to disable it || --detect-idle-chcr=0
| --rom || location of the bios that's inside of the fpkg || Could allow to use custom bios, though still not working || --rom="PS20220WD20050620.crack" or --rom="/roms/PS20220WD20050620.crack"
|-
|-
| --rom || <pre>location of the bios that's inside of the fpkg</pre> || <pre>Could allow to use custom bios, though still not working</pre> || <pre>--rom="PS20220WD20050620.crack" or --rom="/roms/PS20220WD20050620.crack"</pre>
| --cop2 || jit, trans || ? ||  
|-
|-
|}
| --vu0 || jit, trans || ? ||
|-
| --r30 || jit, trans || ? ||
|-
|}
 
==== PCSX2's gameindex ====
 
<pre>PCSX2's commands on the PS4 (or the commands which behave similarly)</pre>


====PCSX2's gameindex====
<br>[https://raw.githubusercontent.com/PCSX2/pcsx2/master/bin/resources/GameIndex.yaml Current Gameindex.yaml]
<br>[https://raw.githubusercontent.com/PCSX2/pcsx2/master/bin/resources/GameIndex.yaml Current Gameindex.yaml]
<br>[https://github.com/Scalerize/Pcsx2-gameindexes Old Gameindex.yaml files in case these settings get deleted from PCSX2]
<pre>This list includes the gameindex's equivalent commands in the ps4.
These commands are fully tested. there's no need to edit them</pre>
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! PCSX2 !! PS4 !! Notes
! {{cellcolors|#00d6f2|#000000}}PCSX2 !! {{cellcolors|#38ffc3|#000000}}PS4 !! Notes
|-
|-
| XGKickHack ||--vu-xgkick-delay=0 || <pre> Limit is between
| {{cellcolors|#0b9fb3|#000000}}XGKickHack ||{{cellcolors|#03fcb1|#000000}}--vu-xgkick-delay= || Possible equivalent value is 8
(0 => 31) </pre>
|-
|-
| VuAddSubHack ||--vu-hack-triace=1 || <pre>Required for every single game developed by TriAce</pre>
| {{cellcolors|#0b9fb3|#000000}}VuAddSubHack ||{{cellcolors|#03fcb1|#000000}}--vu-hack-triace=1 || Required for every single game developed by TriAce
|-
|-
| vuClampMode: 2 ||<pre>--vu1-no-clamping=0  
| {{cellcolors|#0b9fb3|#000000}}vuClampMode: 2 ||{{cellcolors|#03fcb1|#000000}}<br>--vu1-no-clamping=0<br>--vu0-no-clamping=0<br>--cop2-no-clamping=0 ||
--vu0-no-clamping=0  
--cop2-no-clamping=0 </pre>||
|-
|-
| vuClampMode: 3  || <pre>--vu1-no-clamping=1  
| {{cellcolors|#0b9fb3|#000000}}vuClampMode: 3  || {{cellcolors|#03fcb1|#000000}}<br>--vu1-no-clamping=1<br>--vu0-no-clamping=1<br>--cop2-no-clamping=1<br>--vu-to-double=1 ||
--vu0-no-clamping=1  
--cop2-no-clamping=1
</pre> ||
|-
|-
|vu0ClampMode: 2 || <pre>--vu0-no-clamping=0
| {{cellcolors|#0b9fb3|#000000}}eeClampMode: 2 || {{cellcolors|#03fcb1|#000000}}--fpu-to-double=0<br>--fpu-no-clamping=0<br> ||
--cop2-no-clamping=0</pre> ||
|-
|-
|vu0ClampMode: 3 || <pre>--vu0-no-clamping=1  
| {{cellcolors|#0b9fb3|#000000}}eeClampMode: 3 || {{cellcolors|#03fcb1|#000000}}--fpu-to-double=1<br>--fpu-no-clamping=1<br> ||
--cop2-no-clamping=1  
</pre>||
|-
|-
|vu1ClampMode: 2 || --vu1-no-clamping=0 ||  
| {{cellcolors|#0b9fb3|#000000}}eeRoundMode: || {{cellcolors|#03fcb1|#000000}}--fpu-accurate-muldiv=1<br>--fpu-accurate-addsub=1 ||
|-
|-
|vu1ClampMode: 3 || <pre>--vu1-no-clamping=1  
| {{cellcolors|#0b9fb3|#000000}}vu0RoundMode: || {{cellcolors|#03fcb1|#000000}}--cop2-accurate-mul=1<br>--cop2-accurate-addsub=1<br>--vu0-accurate-addsub-range=<br>--vu0-mul0fix-range= ||
</pre>||
|-
|-
| eeClampMode: 2 || --fpu-no-clamping=0 ||
| {{cellcolors|#0b9fb3|#000000}}vu1RoundMode: || {{cellcolors|#03fcb1|#000000}}--vu1-accurate-addsub-range=<br>--vu1-mul0fix-range=||
|-
|-
| eeClampMode: || <pre>--fpu-no-clamping=1  
| {{cellcolors|#0b9fb3|#000000}}eeCycleRate: || {{cellcolors|#03fcb1|#000000}}--ee-cycle-scalar= || '''"Potential" equivalent values: PCSX2 - PS4''':<br>300% --> 0.333<br>180% --> 0.555<br>130% -->0.769<br>'''100% --> 1.0'''<br>75% --> 1.333<br>60% --> 1.666<br>50% --> 2
</pre>||
|-
|-
| FpuNegDivHack & FpuMulHack || --fpu-accurate-muldiv=1 || <pre>it'll probably make game lose performance
| {{cellcolors|#0b9fb3|#000000}}FpuNegDivHack<br>FpuMulHack || {{cellcolors|#03fcb1|#000000}}--fpu-accurate-muldiv=1 ||  
therefore use this with it --fpu-accurate-mul-fast=1 </pre>
|-
|-
| cpuCLUTRender: 1 || --gs-uv-shift-pointsampling=1 ||
| {{cellcolors|#0b9fb3|#000000}}cpuCLUTRender: 1 || {{cellcolors|#03fcb1|#000000}}--gs-uv-shift-pointsampling=1 ||
|-
|-
| MTVUSpeedHack: 0 || --vu1=jit-sync ||
| {{cellcolors|#0b9fb3|#000000}}MTVUSpeedHack: 0 || {{cellcolors|#03fcb1|#000000}}--vu1=jit-sync || Some games will also require --vu1-mpg-cycles= to be between "6000 - 19000"
|-
|-
| IbitHack || <pre>--vu1-di-bits=0
| {{cellcolors|#0b9fb3|#000000}}mergeSprite<br>alignSprite || {{cellcolors|#03fcb1|#000000}}--gs-kernel-cl-up="up2x2simple" || Note: works similarly but not the equivalent
--vu1-const-prop=1</pre> || <pre>Note: this emulator has this hack enabled by default
for all games and emulators, these 2 commands are only provided to
assist games that need that hack with performance and are not the equivalent of this hack. </pre>
|-
|-
| roundSprite: 1 || --gs-use-clut-merge=1 || <pre>Note: Works very similar but not the equivalent</pre>
| {{cellcolors|#0b9fb3|#000000}}cpuSpriteRenderBW: 4 || {{cellcolors|#03fcb1|#000000}}--gs-opt-frbuff-switch=1 || Note: works similarly but not the equivalent
|-
|-
| <pre>mergeSprite: 1</pre> || --gs-kernel-cl-up="up2x2simple" || <pre>Note: Works very similar but not the equivalent</pre>
| {{cellcolors|#0b9fb3|#000000}}mipmap || {{cellcolors|#03fcb1|#000000}}--gs-use-mipmap=1<br>--gs-kernel-cl="mipmap" || Note: Works best on War of the Monsters emu
|-
|-
| cpuSpriteRenderBW: 4 || --gs-opt-frbuff-switch=1 || Note: Works very similar to it, But it's not exactly the same
| {{cellcolors|#0b9fb3|#000000}}autoFlush || {{cellcolors|#03fcb1|#000000}}--gs-flush-ad-xyz=safe || Possible values include always, safe, off, 0
|-
|-
| mipmap: 1 || <pre>--gs-use-mipmap=1</pre>  ||
| {{cellcolors|#0b9fb3|#000000}}VIF1StallHack || {{cellcolors|#03fcb1|#000000}}--vif1-instant-xfer=0 || If that doesn't work, the lua command eeObj.SchedulerDelayEvent("vif1.dma", 0x9000) might assist.
|-
|-
| autoFlush: 1 || --gs-flush-ad-xyz=safe || <pre>Possible values include
| {{cellcolors|#0b9fb3|#000000}}wildArmsHack || {{cellcolors|#03fcb1|#000000}}--gs-kernel-cl-up="DarkCloud2" ||
always, safe, off, 0</pre>
|-
|-
| VIF1StallHack || --vif1-instant-xfer=0 || <pre> if that doesn't work you can always use
| {{cellcolors|#0b9fb3|#000000}}deinterlace || {{cellcolors|#03fcb1|#000000}}--force-frame-blend=1 ||
the lua command eeObj.SchedulerDelayEvent("vif1.dma", 0x9000)</pre>
|}
 
=== Emulators ===
 
Every PS2 emulator is programmed differently. Sometimes choosing the right emulator is the only way to fix a game. Emulators are not provided pre-installed in the PS4 OS, but instead they have to be unpacked from an official PS2 CLASSICS PKG file signed by Sony. This list includes the typical usage of those emulators.
 
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Emulator name !! Typical usage - Info !! API Version !! Similar emulators
|-style="background-color:#D7EF54"
|  || 2018 || ||
|-
|-
| VIFFIFOHack || --vif1-ignore-cmd-ints=1 ||
| The King of Fighters '98: Ultimate Match || The only known emulator where '''Mojin-ribbon''' is playable. Commonly known as "KOF98"|| 2.0 ||
|-
|-
| wildArmsHack: 1 || --gs-kernel-cl-up="DarkCloud2" ||
|-style="background-color:#D7EF54"
|  || 2017 || ||
|-
|-
| deinterlace: || --force-frame-blend=1 ||
| Jak and Daxter: The Precursor Legacy || Good compatibility with most ps2 games. It has a very high api version which means more LUA commands are supported. In addition, Jak emus are one of the few emus that can use the '''--gs-adaptive-frameskip=1''' command. It is often referred to as "Jak v2"|| 2.2 || '''JakX,''' '''Jak 2,''' '''Jak 3,'''
|-
|-
|}
| Art of Fighting Anthology || Similar to RECVX. It was successful in fixing "'''Coraline'''." Sometimes called "AOFA" || 2.0 ||
 
|-
=== Emulators ===
| Resident Evil - Code: Veronica || Fixes games like '''Jackie chan Adventures, SpongeBob SquarePants: Creature From the Krust Krab, Pac-man World 3, Yu-Gi-Oh: Capsule monsters, SpongeBob's Atlantis SquarePantis''' freezing at a black/splash screen. Additionally, it fixes many games requiring '''OPL's mode 2'''. Often referred to as "RECVX" || 1.7 || '''Fatal Fury,''' '''Redfaction,''' '''AOFA.'''
<pre>Every emulator is programmed in a different way, sometimes choosing the right emulator is the only possible way to fix a game, emulators are not provided pre-installed on your ps4, they have to be unpacked from your ps2classics backup that's downloaded from the ps store from that specific game. this list includes The typical usage of some of The emulators. and by emulator we mean the fpkg's Eboot.bin</pre>
|-
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
| Fatal Fury Battle Archives: Volume 2 || Similarly to RECVX, it is often used to fix frozen games. ||  ||
! Emulator !! Usage !! API Version !! Similar emulators (Usage)
|-style="background-color:#D7EF54"
|  || 2016 || ||
|-
|-
| <pre>Jak</pre> || Good compatibility with most ps2 games, and it has a very high api version which means more LUA commands are supported.|| 2.2? || '''JakX,''' '''Jak 2,''' '''Jak 3,''' '''Parappa.'''
| Red Faction || It is prominently used to fix VU1 sensitive games. It was used to fix '''Tony Hawk games''' suddenly crashing, as well as MTVU sensitive games such as '''Star Wars Battlefront II'''.|| 1.6 || '''Max payne'''  
|-
|-
| <pre>RECVX</pre> || Fixes Games like '''Jackie chan Adventures, Pac-man World 3, Yu-Gi-Oh: Capsule monsters''' freezing at the splash screen Most likely due to the way it emulates Vector unit 1|| || '''Fatal Fury,''' '''Redfaction,''' '''AOFA.'''
| Forbidden Siren || The only emulator to fix '''Ice age 2''' being stuck at splash screen. It also fixed '''Gran turismo 4''' running abysmally slow. || 0.1 ||
|-
|-
| <pre>Forbidden
| King of Fighters 2000 || Seemingly one of the most VU-accurate emus, fixing sps in games such as '''Crash Twinsanity''', '''Rayman 3''', '''Crazy Frog Racer'''. It also '''prevents Koei tecmo games from suddenly freezing when battle starts. Moreover, it is likely the only emulator where '''Batman Begins''' does not crash.''' Often referred to as "KOF2000"|| 1.2 || '''Roguev1''', '''KOF98''', '''Okage'''
siren</pre> || The only emulator that fixed '''Ice age 2''' being stuck at splash screen using kozarovv's patch, it also fixed '''Gran turismo 4''' running EXTREMELY slow, this emu possibly has EE cache support || ||
|-
|-
| <pre>GTA 3</pre> || Fixed the pal Version of '''Genji: Dawn of the Samurai''', Could be the most GIF accurate emu we have. || ||
| Destroy All Humans! || Fixed '''Tenchu: Fatal Shadows'''' crashing. || 0.1 ||  
|-
|-
| <pre>KOF2000</pre> || Fixes graphical issues and sps in games such as '''Crash Twinsanity''', and '''prevents Koei tecmo games from suddenly freezing when battle starts''', since it emulates COP2/VU1/VU0 timing much more accurately than other emulators || || '''Roguev1''' and '''KOF98'''
| Destroy All Humans! 2 || || 0.7 ||  
|-
|-
| <pre>Star wars racer revenge</pre> || Seems to be the most similar emulator to the ps3. useful for debugging games as it also shows useful information such as pagefault || ||  
| Rise of the Kasai || It fixed most of the '''Harry Potter''' games. Often referred to as "rotk". || 0.2 ||
|-
|-
| <pre>Parappa</pre> || The only emulator that was able to Boot '''Spyro: A Hero's Tail''' || ||
|-style="background-color:#D7EF54"
| || 2015 || ||
|-
|-
| <pre>Redfaction</pre> || It is a very good emulator to use for games that are sensitive to MTVU. it was used to fix '''Tony hawk games''' || 1.6 || '''Max payne'''  
|War of the monsters v1 || Subjectively the best emulator to use. Used as PS2CLASSICSGUI's default emulator, it is the best one around for accurate gs emulation, as some graphical issues on the Ratchet series and Tekken 5 can only be fixed by it. Another interesting case is GTA SA's lack of need for auto flush on it, and being natively performant. Additionally, its VU0 timing is much better than Jakv2's, making it one of the best emulators on the PS4. || 0.1 || '''Rogue v1 and v2, Arc the Lad, Star Wars Jedi Starfighter'''
|-
|-
| <pre>AOFA</pre> || Works similarly to RECVX, It managed to fix '''Coraline''' || ||
| GTA III || Fixed the PAL version of '''Genji: Dawn of the Samurai'''. || 0.6 ||
|-
|-
|<pre>War of the monsters v1</pre> || Probably the most GS accurate emulator we have on the PS4, Fixed '''Enter the Matrix''' crashing with upscaling on, and fixed '''Devil may cry 2''' characters having missing faces, fixed '''Tekken 5''' having graphical corruptions in some levels, it also happens to be the default emulator for PS2ClassicsGUI ||
| PaRappa the Rapper 2 || The only emulator to boot '''Spyro: A Hero's Tail'''. || 0.1 ||
|-
|-
| <pre>rise of the kasai</pre> || Fixed most of the '''Harry potter''' games, it also possibly has a good ipu emulation though not yet confirmed|| || Also referred to as rotk
| Star Wars Racers Revenge || Seemingly the closest emulator to the PS3's. Useful for debugging games as it also shows useful information such as pagefault. || 0.4 ||  
|-
|-
|}
|}
<pre>All you have to do to make these emulators work for your game
is to replace your Fpkg backup's iso with that game's iso</pre>


=== XXXX-YYYYY_config.lua ===
=== XXXX-YYYYY_config.lua ===


<pre>It is the most powerful Configuration on the emulator, it Allows direct patching of EE/IOP/VU memory, hooks registers, hook dma, almost Everything can be done here.  
<br>It is the most powerful configuration on the emulator, it allows for direct patching of EE/IOP/VU memory, hooks registers, hook dma. Almost Everything can be done here.
<br>If needed it can hook registers by using register names from alias files. Alias files (ee-cpr0-alias.lua, ee-gpr-alias.lua, ee-hwaddr.lua) are stored in lua_include folder, and can be included to config by using require ("alias file name").
<br>'''Known functions:
'''
Require cleanup.


If needed it can hook registers by using register names from alias files. Alias files (ee-cpr0-alias.lua, ee-gpr-alias.lua, ee-hwaddr.lua) are stored in lua_include folder, and can be included to config by using require ( "alias file name" ).</pre>
==== ApiRequest ====
 
<pre>The most important part of the LUA script. The LUA script will crash the game if used without it.</pre>


'''Known functions:
'''
Require cleanup.
====ApiRequest====
<pre>The most important part of a lua. without it the lua will crash the game.</pre>
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Usage !! Notes
! Command !! Usage !! Notes
Line 930: Line 880:
|-
|-
|}
|}
=====(Emulator) EmuObject=====
===== (Emulator) EmuObject =====
 
<pre> Commands for the emulator</pre>
<pre> Commands for the emulator</pre>
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Usage !! Notes
! Command !! Usage !! Notes
Line 1,004: Line 956:
|ThrottleFast || emuObj.ThrottleFast() || Faster than default, but exact value is unknown.
|ThrottleFast || emuObj.ThrottleFast() || Faster than default, but exact value is unknown.
|-
|-
|ThrottleMax || emuObj.ThrottleMax() || Disable framelimiter During loading screens, This setting can sometimes be harmful when used globally in config files. Loading times are faster, but the game also runs faster than it should when the PS4 has enough free cpu power.
|ThrottleMax || emuObj.ThrottleMax() || Disable framelimiter during loading screens.  
|-style="background-color:#ffe680"
|-style="background-color:#ffe680"
|  || CDVD ||  
|  || CDVD ||  
Line 1,018: Line 970:
| GetDiscTitleId || ||
| GetDiscTitleId || ||
|-
|-
|ShowDiscSwitchInfo ||emuObj.ShowDiscSwitchInfo() ||
|ShowDiscSwitchInfo || emuObj.ShowDiscSwitchInfo() ||
|-
|-
|-style="background-color:#FEA15C"
|-style="background-color:#FEA15C"
Line 1,025: Line 977:
| EnableImposeMenu || emuObj.EnableImposeMenu(<true/false>) || EnableImposeMenu(false)
| EnableImposeMenu || emuObj.EnableImposeMenu(<true/false>) || EnableImposeMenu(false)
|-
|-
|LoadConfig || ||
|LoadConfig || emuObj.LoadConfig( 0 or 1 )|| emuObj.LoadConfig(0)
|-
|-
|SaveConfig || ||
|SaveConfig || emuObj.LoadConfig( 0 or 1 ) || emuObj.LoadConfig(0)
|-
|-
|GetPad || emuObj.GetPad(<gamepad button by bits>)|| example usage for reading input:  
|GetPad || emuObj.GetPad(<gamepad button by bits>)|| example usage for reading input:  
Line 1,065: Line 1,017:
| GetPs4SystemLang || emuObj.GetPs4SystemLang() || Return PS4 system language (in unknown format).
| GetPs4SystemLang || emuObj.GetPs4SystemLang() || Return PS4 system language (in unknown format).
|-
|-
| SetPs2Lang || emuObj.SetPs2Lang(<Lang ID>) || Set emulated PS2 language, correct Lang IDs are 0-18, Strangely, Some Games can Crash if their Specific Language is not selected
| SetPs2Lang || emuObj.SetPs2Lang(<Lang ID>) || Set emulated PS2 language, correct Lang IDs are 0-18. In some cases, games will hang on a black screen with some other language settings (eg Japanese) - Example for usage: emuObj.SetPs2Lang(1)
<div align="left"><pre>0 - japanese
<div align="left"><pre>0 - japanese
1 - english
1 - english
Line 1,086: Line 1,038:
18 - english-uk</pre></div>
18 - english-uk</pre></div>
|-
|-
|PadSetLightBar || emuObj.PadSetLightBar(<port, red, green, blue>) || Set DS4 light bar color. Correct port values are 0-3, correct light values are 0-255.
|PadSetLightBar || emuObj.PadSetLightBar(<port, red, green, blue>) || Set DS4 light bar color. The correct port values are 0-3, correct light values are 0-255.
|-
|-
|PadPressureStickRemap || emuObj.PadPressureStickRemap()||
|PadPressureStickRemap || emuObj.PadPressureStickRemap()||
Line 1,123: Line 1,075:
|}
|}


=====(EE) EEObject=====
===== (EE) EEObject =====
 
<pre>Commands for the emulated Emotion Engine</pre>
<pre>Commands for the emulated Emotion Engine</pre>
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Usage !! Notes
! Command !! Usage !! Notes
Line 1,136: Line 1,090:
|ReplaceMem64 || eeObj.ReplaceMem64(<address>, <value>)||
|ReplaceMem64 || eeObj.ReplaceMem64(<address>, <value>)||
|-
|-
|ReplaceMem32 || eeObj.ReplaceMem32(<address>, <value>) || Permanently replace an offset without needing addvsynchook
|ReplaceMem32 || eeObj.ReplaceMem32(<address>, <value>) || Permanently replace an offset without needing addvsynchook?
|-
|-
|ReplaceMem16 || eeObj.ReplaceMem16(<address>, <value>)||
|ReplaceMem16 || eeObj.ReplaceMem16(<address>, <value>)||
Line 1,204: Line 1,158:
eeObj.SetFpr(14, eeObj.GetFpr(14) + 50.0) this will add 50.0 to current fpr 14 value
eeObj.SetFpr(14, eeObj.GetFpr(14) + 50.0) this will add 50.0 to current fpr 14 value
|-
|-
|GetPc || eeObj.GetPc() ||This command is very helpful as it will return to you the current EE address that's being read. can be used also with additional var. like eeObj.GetPc()+4
|GetPc || eeObj.GetPc() ||This command is very helpful as it will return to you the current EE address that's being read. Can be used also with additional var. like eeObj.GetPc()+4
|-
|-
|SetPc || eeObj.SetPC(<PC>) ||eeObj.SetPC(0x266B80)
|SetPc || eeObj.SetPC(<PC>) ||eeObj.SetPC(0x266B80)
Line 1,235: Line 1,189:
|RemoveJitResetHook || ||
|RemoveJitResetHook || ||
|-
|-
| AddHookJT || eeObj.AddHookJT(Offset, offset opcode, ???) || Seems to somehow be related to gpr registers
| AddHookJT || eeObj.AddHookJT(Offset, offset opcode, function) || Seems be a hook related to the jit
|-
|-
|-style="background-color:#ffb3b3"
|-style="background-color:#ffb3b3"
Line 1,253: Line 1,207:
|  || Speedhacks ||  
|  || Speedhacks ||  
|-
|-
|FastForwardClock || eeObj.FastForwardClock() || Skip Emotion engine Cycles
|FastForwardClock || eeObj.FastForwardClock() || Skip Emotion Engine cycles?
<pre>
eeObj.AddHook(0x002cc350, 0x78a30000, function()
          eeObj.FastForwardClock()
end)
</pre>
|-
|-
|AdvanceClock || eeObj.AdvanceClock() || it is still unknown how to use this command, check Psychonauts lua for more details.
|AdvanceClock || eeObj.AdvanceClock() || Likely skips an allocated amount of EE cycles.
<pre>
eeObj.AddHook(0x002cc350, 0x78a30000, function()
          eeObj.AdvanceClock(21000)
end)</pre>
|-
|-
| GetClock || eeObj.GetClock() || Returns the value of how many cycles the iop is ahead of normal clock (?)
| GetClock || eeObj.GetClock() || Returns the value of how many cycles the EE is ahead of normal clock (?)
|-
|-
|Vu1MpgCycles || eeObj.Vu1MpgCycles(<cycles>) || Works just like the cli command --vu1-mpg-cycles=, setting it to eeObj.Vu1MpgCycles(1000) would skip 50% of frames When the game enters a VU1 Heavy area and will return to normal framerate when VU1 is not being under heavy usage.
|Vu1MpgCycles || eeObj.Vu1MpgCycles(<cycles>) || Works just like the cli command --vu1-mpg-cycles=
|-style="background-color:#FEA15C"
|-style="background-color:#FEA15C"
|  || Other ||  
|  || Other ||  
Line 1,265: Line 1,228:
| CallPredicate
| CallPredicate
|-
|-
|SchedulerDelayEvent || eeObj.SchedulerDelayEvent("event", cycles) || Parrapa use eeObj.SchedulerDelayEvent("vif1.dma", 0x6500) other events are gif.dma, vif0.dma, vif1.dma, sif0.dma, Sif0-NormalTransfer, sif1.dma, Sif1-NormalTransfer, ipu0.dma, ipu1.dma . This command allow to delay certain DMA transfer by cycles.  
|SchedulerDelayEvent || eeObj.SchedulerDelayEvent("event", cycles)<br>Example:<br>eeObj.AddHook(0x0033A4DC,0xAC430000, function() eeObj.SchedulerDelayEvent("gif.dma", 0x10500) end) || Parrapa use eeObj.SchedulerDelayEvent("vif1.dma", 0x6500) other events are gif.dma, vif0.dma, vif1.dma, sif0.dma, Sif0-NormalTransfer, sif1.dma, Sif1-NormalTransfer, ipu0.dma, ipu1.dma . This command allows for the delayment of certain DMA transfer by cycles.  
|-
|-
|WaitVu1 || eeObj.WaitVu1() || most likely this is --vu1=jit-sync, adding it will Sync the EE with the VU1, Pcsx2 has a similar gamefix called VU Sync which syncs both VU1 and VU0 with the EE.  
|WaitVu1 || eeObj.WaitVu1() || Likely to be the lua equivalent of "--vu1=jit-sync".
|-
|-
|GetPcRingBuffer || ||
|GetPcRingBuffer || ||
Line 1,275: Line 1,238:
|CalcInsnHash || ||
|CalcInsnHash || ||
|-
|-
|getOverlayObject || eeObj.getOverlayObject() || Can be used to get Current EE Offset (???) local eeOverlay = eeObj.getOverlayObject()
|getOverlayObject || eeObj.getOverlayObject() || local eeOverlay = eeObj.getOverlayObject()
|-
|-
| GetVif1Cycles || eeObj.GetVif1Cycles() || local vif1_cycles = eeObj.GetVif1Cycles() create vif_cycles value that can be used later, you can rename it as you wish.
| GetVif1Cycles || eeObj.GetVif1Cycles() || local vif1_cycles = eeObj.GetVif1Cycles() create vif_cycles value that can be used later. You can rename it as you wish.
|-
|-
|}
|}


=====(IOP) IOPObject=====
====== SetGsTitleFix ======
<pre>Commands for the emulated input-output processor</pre>
 
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
<pre>One of the most important LUA commands. It modifies the Graphics Synthesizer's behavior.
! Command !! Usage !! Notes
 
|-style="background-color:#D7EF54"
Part of EmuObject() class, it's frequently used in official configs.</pre>
|  || Object calling class ||
'''Examples'''
|-
<pre>
| getIOPObject || local iopObj = getIOPObject() || Required for all functions using iopObj, that include: <div align="left"><pre>ReplaceMem64 ReplaceMem32 ReplaceMem16 ReplaceMem8 ReadMemFloat
-- fix vision logo (Wild Arms 3)
  WriteMemFloat WriteMem64 WriteMem32 WriteMem16 WriteMem8
local thresholdArea = 0 -- ignore alls items : fix #112276
ReadMemStr AddHook RemoveHook GetGpr SetGpr GetPc SetPc
emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , { texType = 3, cbp = 0x2390, tbp = 0x288000} )
GetCPR0 SetCPR0</pre></div>
------------------------------------------------------------------------------------------------------
|-style="background-color:#7698FF"
-- Ignore up-render shift for triangles when writing mask = write alpha only . Will fix shadows (bug# 6724).
|  || Memory editing ||
emuObj.SetGsTitleFix( "ignoreUpShiftTri", "reserved" , { fbmask = 0x00FFFFFF  } )
|-
------------------------------------------------------------------------------------------------------
|ReplaceMem64 ||iopObj.ReplaceMem64(<address>, <value>) ||
--  Performance  fix ( bug# 9474 )
|-
if 0 then  -- emuObj.IsNeoMode() then  -- neo mode check disabled, due to bug #10442
|ReplaceMem32 || iopObj.ReplaceMem32(<address>, <value>)||
    emuObj.SetGsTitleFix( "globalSet""reserved", { workLoadThreshold = 125000} )
|-
else
|ReplaceMem16 || iopObj.ReplaceMem16(<address>, <value>)||
    emuObj.SetGsTitleFix( "globalSet""reserved", { workLoadThreshold = 100000} )
|-
end
|ReplaceMem8 ||iopObj.ReplaceMem8(<address>, <value>) ||
------------------------------------------------------------------------------------------------------
|-
-- bug# 9972
|ReadMemFloat || iopObj.ReadMemFloat(<address>) || iopObj.ReadMemFloat(0x28c3c)
emuObj.SetGsTitleFix( "ignoreSubBuffCov", "reserved", { } )
|-
------------------------------------------------------------------------------------------------------
|WriteMemFloat || iopObj.WriteMemFloat(<address>, <value>) || iopObj.WriteMemFloat(0x65364, 1.3333333)
-- Bully bug 9392
|-
-- Performace fix
|ReadMem128 || iopObj.ReadMem128(<iop memory offset>)||
local thresholdArea = 600
|-
emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , {alpha=0x80000044 , zmsk=1 , tw=4, th=4 } )
|WriteMem128 || iopObj.WriteMem128(<iop memory offset>, <value>)||
------------------------------------------------------------------------------------------------------
|-  
-- Bug#9174 -
|ReadMemFloat128 ||iopObj.ReadMemFloat128(<iop memory offset>) ||
emuObj.SetGsTitleFix( "ignoreSubBuffCov", "reserved", { } )
|-
------------------------------------------------------------------------------------------------------
|WriteMemFloat128 || iopObj.WriteMemFloat128(<iop memory offset>, <value>)||
-- Bug#9240 (Light maps uprender)
|-
-- Copy z-buffer for future use with light maps. psm = SCE_GS_PSMZ24 (49)
| ReadMem64 || <pre>iopObj.ReadMem64(<iop memory offset>)</pre> || Read 8  Bytes From offset
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", {tw=9, th=9, psm=49, zmsk=1 } )
|-
------------------------------------------------------------------------------------------------------
| WriteMem64 || <pre>iopObj.WriteMem64(<iop memory offset>, <data>)</pre> || Write 8  Bytes From offset
-- Apply light maps texMode=2 (bilinear)  psm= SCE_GS_PSMCT32 (0)
|-
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", {tw=8, th=8, psm=0, ztst=1, texMode=2 } )
| ReadMem32 || <pre>iopObj.ReadMem32(<iop memory offset>)</pre> || Read 4 bytes from offset, examples: iopObj.ReadMem32(0x1198)
------------------------------------------------------------------------------------------------------
iopObj.ReadMem32(gp - 348)
-- Performace fix (bug #9785 )
emuObj.SetGsTitleFix( "globalSet",  "reserved", { waveThreshold = 90000} )
emuObj.SetGsTitleFix( "ignoreAreaUpdate", 0, { } )
------------------------------------------------------------------------------------------------------
-- Accumulate fill area only when conditions are met
emuObj.SetGsTitleFix( "includeAreaUpdate", "reserved" , {alphaIsNot = 0, zmsk = 1, tw = 6, th = 6 , tbp = 0x00302000} )
emuObj.SetGsTitleFix( "ignoreUpRender", 130 , { totalArea= 700} )
------------------------------------------------------------------------------------------------------
-- Fix shadow
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1  } )
------------------------------------------------------------------------------------------------------
-- Reduce flush count
emuObj.SetGsTitleFix( "SetSelfRender", "reserved", { fbmask= 0x00FFFFFF , renderSelf=1 , zmsk=1 , alpha=0 , texMode=1  } )
------------------------------------------------------------------------------------------------------
-- Disable post-processing
emuObj.SetGsTitleFix( "ignoreSprite", "reserved", {  texType=1 , tw=5 , th=8, zmsk=1 , alpha=0x80000044  } )
------------------------------------------------------------------------------------------------------
-- Small triangle rejection. Works in conjunction with CLI setting  gs-override-small-tri-area=1
-- keep default area for texture 256x256 ( no blend)  (Anakin face)
emuObj.SetGsTitleFix( "setRejectionArea", 500,{twIsNot=8, thIsNot=8 } )
------------------------------------------------------------------------------------------------------
-- Set triangle rejection area= 1000  when alpha blend is not 0 ( i.e blend is On)
emuObj.SetGsTitleFix( "setRejectionArea", 1000, {alphaIsNot=0 } )
------------------------------------------------------------------------------------------------------
-- Performace fix
local thresholdArea = 600
emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , {alpha=0x80008068 , zmsk=1 } )
------------------------------------------------------------------------------------------------------
-- Performace fix
local thresholdArea = 700
emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , {alpha=0x80000044 , zmsk=1 } )
------------------------------------------------------------------------------------------------------
-- Disable uprender on the draw command which samples the framebuffer (0x3200) using bilinear sampling (texMode=2)
-- All lighting effects use TriFan prim type, so use that as well to filter against.
emuObj.SetGsTitleFix( "forceSimpleFetch",  "reserved", {prim=5, texMode=2, tbp=0x320000} )
</pre>
 
<br />
'''Commands'''
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Example !! Notes !! Values
|-
|-
| WriteMem32 || <pre>iopObj.WriteMem32(<iop memory offset>, <data>)</pre> || Write 4 bytes to offset, example: iopObj.WriteMem32(0x89ac, 0x001b70f0)
|globalSet || emuObj.SetGsTitleFix( "globalSet", "reserved", { packedRegsLo = 0x42,packedRegsHi = 0, packedRegsNum = 2, packedFlags = 3, packedPrim = 5}) || used with workLoadThreshold or  waveThreshold or loadThreshold
|-
|-
| ReadMem16 || <pre>iopObj.ReadMem16(<iop memory offset>)</pre> || Read 2 bytes from offset, example: iopObj.ReadMem16(0x1198)
|reserved || ||
|-
|ignoreSubBuffCov||  ||ignore ? buffer coverage
|-
|ignoreUpRenderTimeout|| emuObj.SetGsTitleFix( "globalSet", "reserved", {ignoreUpRenderTimeout=2} ) ||
|-
|-
| WriteMem16 || <pre>iopObj.WriteMem16(<iop memory offset>, <data>)</pre> || Write 2 bytes to offset, example: iopObj.WriteMem16(0x89ac, 0x70f0)
|ignoreAreaUpdate|| emuObj.SetGsTitleFix( "ignoreAreaUpdate", 0, { alpha=0x80000048 } ) ||
|-
|-
| ReadMem8 || <pre>iopObj.ReadMem8(<iop memory offset>)</pre> || Read 1 byte from offset, example: iopObj.ReadMem8(0x1198)
|ignoreSprite|| emuObj.SetGsTitleFix( "ignoreSprite", "reserved", {  texType=1 , tw=5 , th=8, zmsk=1 , alpha=0x80000044  } ) ||
|-
|-
| WriteMem8 || <pre>iopObj.WriteMem8(<iop memory offset>, <data>)</pre> || Write 1 byte to offset, example: iopObj.WriteMem8(0x89ac, 0xf0)
|ignoreUpShiftTri|| emuObj.SetGsTitleFix( "ignoreUpShiftTri", "reserved", {psm=0} ) ||
|-
|-
|ReadMemStr || ||
|clipScissors|| emuObj.SetGsTitleFix( "clipScissors", "reserved", {alpha = 0 , frameW = 4 , psm = 0} ) ||
|-
|-
|GetGpr || iopObj.GetGPR(<gpr register>) || iopObj.GetGPR(a1)
|trianglesAsParticles|| emuObj.SetGsTitleFix( "trianglesAsParticles", "reserved", { hasClut=1,zmsk=1 } ) ||
|-
|-
|SetGpr || iopObj.SetGPR(<gpr register> ,<value>) || example: iopObj.SetGPR(gpr.v0 ,3)
|SetSelfRender|| emuObj.SetGsTitleFix( "SetSelfRender", "reserved", { fbmask= 0x00FFFFFF , renderSelf=1 , zmsk=1 , alpha=0 , texMode=1  } ) ||
|-
|-
|GetPc || iopObj.GetPc() || can be used also with additional var. like iopObj.GetPc()+8
|forceBiLinear || ||
|-
|-
|SetPc || iopObj.SetPC(<PC>) ||iopObj.SetPC(0x6B80)
|forcePoint|| emuObj.SetGsTitleFix( "forcePoint", "reserved", {mipIsGt=0,  mmin=0} ) ||
|-
|-
|GetCPR0 || iopObj.GetCPR0(<COP0 register>) ||
|forceSimpleFetch ||   emuObj.SetGsTitleFix( "forceSimpleFetch",  "reserved", {psm=0} ) ||Used frequently to fix graphical corruptions
|-
|-
|SetCPR0 || iopObj.SetCPR0(<COP0 register>) ||
|forcePointSampling|| emuObj.SetGsTitleFix( "forcePointSampling", "reserved", {alpha = 0x80000048, twIsLess=5, thIsLess=5 } ) ||
|-
|-
|-style="background-color:#FEA15C"
|setRejectionArea|| emuObj.SetGsTitleFix( "setRejectionArea", 1000, { } ) ||
|  || Clock speed ||  
|-
|-
| FastForwardClock || iopObj.FastForwardClock() ||
|ignoreUpRender|| emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , {  texType = 3, cbp = 0x2390, tbp = 0x288000} ) || Ignore uprender for texture type described in params
|-
|-
| AdvanceClock || iopObj.AdvanceClock() || Increase Iop Clock speed at hooked iop offset
|includeAreaUpdate|| ||
|-
|-
| GetClock || iopObj.GetClock() || Returns the value of how many cycles the iop is ahead of normal clock (?)
|fetchFromCurrBuff|| emuObj.SetGsTitleFix( "fetchFromCurrBuff", "reserved", {psm=0} ) ||
|-style="background-color:#c6ecd9"
|  || Hooks ||
|-
|-
|AddHook || iopObj.AddHook()||
|skipPacked|| emuObj.SetGsTitleFix( "skipPacked", "reserved", { alpha = 0x80000044, tbp = 0x3a4000 , zmsk=1 }) ||
|-
|-
|RemoveHook || iopObj.RemoveHook()||
|changeAlpha|| ||
|-
|-
|}
|}


=====(GS) GsObject=====
<br>'''Arguments/variables'''
<pre>Commands for the emulated Graphics synthesizer</pre>
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Usage !! Notes
! Argument !! Usage !! Notes
|-style="background-color:#D7EF54"
|-style="background-color:#7698FF"
|  || Object calling class ||
|  || Variable ||  
|-
|-
| getGsObject || local gsObj = getGsObject() ||
|alpha_mask ||  ||
|-style="background-color:#c6ecd9"
|| Graphical fixes / Improvement ||  
|-
|-
|SetL2HMode || gsObj.SetL2HMode()||
|texType || {texType = 3}|| (1-3, more? )
|-
|-
|SetUprenderMode ||gsObj.SetUprenderMode(1)|| Set uprender mode. Overrides CLI, 0=none, 1=2x2
|texMode || || 1 - Point? , 2 - bilinear
|-style="background-color:#D7EF54"
|| Argument ||
|-
|-
|SetUpscaleMode || gsObj.SetUpscaleMode() ||
|alphaIsNot || || alpha - is not X
|-
|-
|GetFramesInQueue || gsObj.GetFramesInQueue() || Returns the value of the frames that are still in queue
|twIsLess || || texture width - is less than X
|-
|-
|SetFrameSkipping || gsObj.SetFrameSkipping(true) || false and true are the values.
|thIsLess || || texture height - is less than X
|-
|-
|SetDeinterlaceShift || gsObj.SetDeinterlaceShift(0) || The values are 1 and 0, Enable or disable interlacing, requires emulators with high api
|twIsNot || || texture width - is not X
|-
|-
|}
|thIsNot || || texture width - is not X
 
=====Does not require Object calling or Uknown=====
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Usage !! Notes
|-
|-
| eeInsnReplace || eeInsnReplace(EE memory offset, Original opcode (BE), Replace opcode (BE)) || Replace 4 bytes opcode in ee memory, correct memory range is 0x0 to 0x1FFFFFFF
|psmIsNot || || texture pixel storage format - is not X
<pre>PSMCT32  = 0  PSMT4HL = 36
PSMCT24  = 1  PSMT4HH = 44
PSMCT16  = 2  PSMZ32  = 48
PSMCT16S = 10  PSMZ24  = 49
PSMT8    = 19  PSMZ16  = 50
PSMT4    = 20  PSMZ16S = 58
PSMT8H  = 27  </pre>
|-
|-
| vuInsnReplace || <pre>vuInsnReplace(vu 0/1, vu memory offset divided by 8, (original opcode<<32) | original opcode, (replace opcode<<32) | replace opcode) </pre>|| Replace 2 x 4 bytes in VU memory, correct memory range depend on selected VU, left shift by 32 is used for VU lower opcodes. Command will fail if size is above 254. <pre>example:
|primIsNot || || GS primitive type - is not
vuInsnReplace(0, 0x167, (0x000002ff << 32) | 0x520507ff,(0x000002ff << 32) | 0x8000033c)
<pre>Point        = 0
Replace 64 bits of VU0 at offset 0xB38</pre>
Line          = 1
LineStrip    = 2
Triangle      = 3
TriangleStrip = 4
TriangleFan  = 5
Sprite        = 6</pre>
|-
|-
| iopInsnReplace || iopInsnReplace(IOP memory offset, Original opcode, opcode replacement) || Replace 4 bytes in iop memory, correct memory range is 0x0 to 0x1FFFFF, iopInsnReplace(0x1FFFFF, 0x0, 0x0803fff0)
|mipIsGt || || mip level is grater than X (?)
|-
|-
| eeNativeFunction || eeNativeFunction(<ee offset>, <original opcode>, <function>) || eeNativeFunction(0x11fa9c, 0x0080402d, 'memcpy')
|-style="background-color:#FEA15C"
Different emulators can have different functions included, vide SO3. Require api 1.4 or higher.
|| Needs wikify ||
But functions from this list should be available in every emu:
<pre>ieee754_acosf ieee754_asinf ieee754_sqrtf
fabs cosf fabsf
sinf acosf asinf
sqrtf fptoui fptodp
litodp dptoli dptofp
memcpy memset strlen</pre>
|-
|-
| eeNativeHook || eeNativeHook(<ee ofset>, <original opcode>, <action>) || eeNativeHook require apiRequest(1.4) or higher.
|zmsk || || Z (depth) draw mask
<pre>update Z buffer      = 0
don't update Z buffer = 1
 
When 1 depth test result will be ignored</pre>
|-
|-
| GsCustomShader || ||  
|tw || || texture width
|-
|-
| Unlock || ||  
|th || || texture height
|-
|-
| IsUnlocked || ||  
|ztst || || Z (depht) test method
<pre>ZNOUSE  = 0
ZALWAYS  = 1
ZGEQUAL  = 2
ZGREATER = 3
 
0 -                      All pixels fail
1 -                      All pixels pass
2 - Pass if Z grater or equal to Z buffer
3 -        Pass if Z grater than Z buffer</pre>
|-
|-
| InsnOverlay || InsnOverlay({<opcode, opcode, opcode...>}) || example: <div align="left"><pre>InsnOverlay({
|mmin || || MMIN flag
0x27bdfff0, -- addiu $sp, -0x10
<pre>NEAREST                = 0
0xffbf0000, -- sd $ra, 0(sp)
LINEAR                = 1
0xffb00008, -- sd $s0, 8(sp)
NEAREST_MIPMAP_NEAREST = 2
0x3c05000f, -- lui $a1, 0x000f
NEAREST_MIPMAP_LINEAR  = 3
0x34a57000, -- ori $a1, 0x7000
LINEAR_MIPMAP_NEAREST = 4
0x0c0db8b6, -- jal Script::State::DoString
LINEAR_MIPMAP_LINEAR  = 5</pre>
0x0080802d, -- move $s0, $a0
0x24050001, -- li $a1, 1
0x0c0dba4c, -- jal Script::State::IsNull(int)
0x0200202d, -- move $a0, $s0
0xdfb00008, -- ld $s0, 8(sp)
0xdfbf0000, -- ld $ra, 0(sp)
0x03e00008, -- jr ra
0x27bd0010 -- addiu $sp, 0x10
})</pre></div>
|-
|-
| eeDebugBreak || ||  
|prim || || GS primitive type
|-
<pre>Point        = 0
| CsBindShader || ||
Line          = 1
LineStrip    = 2
Triangle      = 3
TriangleStrip = 4
TriangleFan  = 5
Sprite        = 6</pre>
|-
|-
| CsSetParamInt32 || ||  
|fillArea || ||  
|-
|-
| CsSetParamFloat || ||  
|frameW || ||  
|-
|-
| CsResetContext || ||  
|renderSelf || ||  
|-
|-
| CsPrintContext || ||  
|hasClut || ||  
|-
|-
| PsBindShader || ||  
|alphaTest || ||  
|-
|-
| PsSetParamInt32 || ||  
|primTest || ||  
|-
|-
| PsSetParamFloat || ||  
|workLoadThreshold || ||  
|-
|-
| PsResetContext || ||  
|alpha || || <pre> example: alpha=0x80000044
alpha=0</pre>
|-
|-
| PsPrintContext || ||  
|tbp || || texture base pointer
|-
|-
|}
|cbp ||  {cbp = 0x2390} || CLUT buffer base pointer
<pre>Note: eeObj, emuObj, gsObj, etc are described as required, this is not really true. You can set functions locals they use as whatever you want, but due to specify of that emulator it will be better to keep official naming used in official configs.</pre>
 
=====Other objects=====
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Usage !! Notes
|-
|-
! !! getGLSObject class !!
|psm ||  {psm=0}  || texture pixel storage format
<pre>PSMCT32  = 0  PSMT4HL = 36
PSMCT24  = 1  PSMT4HH = 44
PSMCT16  = 2  PSMZ32  = 48
PSMCT16S = 10  PSMZ24  = 49
PSMT8    = 19  PSMZ16  = 50
PSMT4    = 20  PSMZ16S = 58
PSMT8H  = 27  </pre>
|-
|-
| getGLSObject || ||  
|mxl || || maximum mip level (0-6)
|-
|-
|Enable || ||
|fbmask || { fbmask= 0x00FFFFFF}|| Framebuffer mask(?)
|-
|-
|EnableServerRecording || ||  
|totalArea || ||  
|-
|-
|Pause || ||  
|packedRegs || ||  
|-
|-
! !! getGsObject class !!
|packedRegsLo || ||
|-
|-
! !! getAudioObject class !!
|packedRegsHi || ||
|-
|-
| getAudioObject || ||  
|packedRegsNum || ||  
|-
|-
| muteStreamingAll || ||  
|packedFlags || ||  
|-
|-
| muteStreamingMain || ||  
|packedPrim || ||  
|-
|-
| muteStreamingBGM || ||  
|areaNumFrames || ||  
|-
|-
! !! getRemotePlayObject class !!
|waveThreshold || ||
|-
|-
| getRemotePlayObject || ||  
|loadThreshold || ||  
|-
|-
| Enable || ||  
|fixSpriteDivTab || ||
|}
 
===== (IOP) IOPObject =====
 
<pre>Commands for the emulated input-output processor</pre>
 
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Usage !! Notes
|-style="background-color:#D7EF54"
|  || Object calling class ||
|-
|-
! !! getVideoRecordingObject class !!
| getIOPObject || local iopObj = getIOPObject() || Required for all functions using iopObj, that include: <div align="left"><pre>ReplaceMem64 ReplaceMem32 ReplaceMem16 ReplaceMem8 ReadMemFloat
WriteMemFloat WriteMem64 WriteMem32 WriteMem16 WriteMem8
ReadMemStr AddHook RemoveHook GetGpr SetGpr GetPc SetPc
GetCPR0 SetCPR0</pre></div>
|-style="background-color:#7698FF"
|  || Memory editing ||
|-
|-
| getVideoRecordingObject || ||
|ReplaceMem64 ||iopObj.ReplaceMem64(<address>, <value>) ||
|-
|-
| Enable || ||  
|ReplaceMem32 || iopObj.ReplaceMem32(<address>, <value>)||
|-
|-
! !! getSharePlayObject class !!
|ReplaceMem16 || iopObj.ReplaceMem16(<address>, <value>)||
|-
|-
| getSharePlayObject || ||  
|ReplaceMem8 ||iopObj.ReplaceMem8(<address>, <value>) ||
|-
|-
| Enable || ||  
|ReadMemFloat || iopObj.ReadMemFloat(<address>) || iopObj.ReadMemFloat(0x28c3c)
|-
|-
! !! getSpriteObject group  !!
|WriteMemFloat || iopObj.WriteMemFloat(<address>, <value>) || iopObj.WriteMemFloat(0x65364, 1.3333333)
|-
|-
|getSpriteObject || ||
|ReadMem128 || iopObj.ReadMem128(<iop memory offset>)||  
|-
|-
|Enable || ||
|WriteMem128 || iopObj.WriteMem128(<iop memory offset>, <value>)||
|-
|ReadMemFloat128 ||iopObj.ReadMemFloat128(<iop memory offset>) ||
|-
|-
|Disable || ||
|WriteMemFloat128 || iopObj.WriteMemFloat128(<iop memory offset>, <value>)||
|-
|-
|BindFragmentShader || ||
| ReadMem64 || <pre>iopObj.ReadMem64(<iop memory offset>)</pre> || Read 8  Bytes From offset
|-
|-
|SetShaderParams || || <div align="left">
| WriteMem64 || <pre>iopObj.WriteMem64(<iop memory offset>, <data>)</pre> || Write 8  Bytes From offset
<pre> Is not clear that params depend on shader, or are somehow hardcoded.
Example usage:
 
local sprite0 = getSpriteObject(0)
local scanlineParams = {
240.0, -- float scanlineCount
  0.7, -- float scanlineHeight;
1.5,        -- float scanlineBrightScale;
0.5,        -- float scanlineAlpha;
0.5        -- float vignetteStrength;
}
 
sprite0.SetShaderParams(scanlineParams)</pre></div>
|-
|-
|BindTexture || ||
| ReadMem32 || <pre>iopObj.ReadMem32(<iop memory offset>)</pre> || Read 4 bytes from offset, examples: iopObj.ReadMem32(0x1198)
iopObj.ReadMem32(gp - 348)
|-
|-
|SetPosXY || ||
| WriteMem32 || <pre>iopObj.WriteMem32(<iop memory offset>, <data>)</pre> || Write 4 bytes to offset, example: iopObj.WriteMem32(0x89ac, 0x001b70f0)
|-
|-
|SetSizeXY || ||
| ReadMem16 || <pre>iopObj.ReadMem16(<iop memory offset>)</pre> || Read 2 bytes from offset, example: iopObj.ReadMem16(0x1198)
|-
|-
|SetPosUV || ||
| WriteMem16 || <pre>iopObj.WriteMem16(<iop memory offset>, <data>)</pre> || Write 2 bytes to offset, example: iopObj.WriteMem16(0x89ac, 0x70f0)
|-
|-
|SetSizeUV || ||
| ReadMem8 || <pre>iopObj.ReadMem8(<iop memory offset>)</pre> || Read 1 byte from offset, example: iopObj.ReadMem8(0x1198)
|-
|-
|PrintContext || ||
| WriteMem8 || <pre>iopObj.WriteMem8(<iop memory offset>, <data>)</pre> || Write 1 byte to offset, example: iopObj.WriteMem8(0x89ac, 0xf0)
|-
|-
|SetBlendColor || sprite<X>.SetBlendColor(<R,G,B,A>) in floats, max val. 1.0 || <div align="left">
|ReadMemStr || ||
<pre>local sprite0 = getSpriteObject(0)
sprite0.SetBlendColor(1.0,1.0,1.0,1.0)</pre></div>
|-
|-
| getTrophyObject || local trophyObj = getTrophyObject() || Required for all functions using trophyObj
|GetGpr || iopObj.GetGPR(<gpr register>) || iopObj.GetGPR(a1)
|-
|-
| getDmaObject || local dmaObj = getDmaObject() || Depreciated API - use EE:DmaAddHook / EE:DmaRemoveHook instead. Is not clear when it was depreciated, JAK emu don't use it.
|SetGpr || iopObj.SetGPR(<gpr register> ,<value>) || example: iopObj.SetGPR(gpr.v0 ,3)
|-
|-
| getScreenShotObject || ||  
|GetPc || iopObj.GetPc() || can be used also with additional var. like iopObj.GetPc()+8
|-
|SetPc || iopObj.SetPC(<PC>) ||iopObj.SetPC(0x6B80)
|-
|GetCPR0 || iopObj.GetCPR0(<COP0 register>) ||
|-
|SetCPR0 || iopObj.SetCPR0(<COP0 register>) ||
|-
|-style="background-color:#FEA15C"
|  || Clock speed ||
|-
| FastForwardClock || iopObj.FastForwardClock() ||
<pre>
iopObj.AddHook(0x002cc350, 0x78a30000, function()
          iopObj.FastForwardClock()
end)
</pre>
|-
| AdvanceClock || iopObj.AdvanceClock() || Skip an allocated amount of IOP cycles
<pre>
iopObj.AddHook(0x002cc350, 0x78a30000, function()
          iopObj.AdvanceClock(21000)end)
</pre>
|-
| GetClock || iopObj.GetClock() || Returns the value of cycles the iop is ahead of (?)
|-style="background-color:#c6ecd9"
|  || Hooks ||
|-
|AddHook || iopObj.AddHook()||
|-
|RemoveHook || iopObj.RemoveHook()||
|-
|-
|}
|}


====Registers for hook====
===== (GS) GsObject =====
Registers defined in alias files.
 
<pre>Commands for the emulated Graphics Synthesizer</pre>


'''GetGpr/SetGpr
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
'''
! Command !! Usage !! Notes
<pre>gpr.zero gpr.at
|-style="background-color:#D7EF54"
gpr.v0 gpr.v1
| || Object calling class ||
gpr.a0 gpr.a1  gpr.a2  gpr.a3
|-
gpr.t0  gpr.t1 gpr.t2  gpr.t3
| getGsObject || local gsObj = getGsObject() ||
gpr.t4  gpr.t5 gpr.t6  gpr.t7
|-style="background-color:#c6ecd9"
gpr.s0  gpr.s1  gpr.s2  gpr.s3
| || Graphical fixes / Improvement ||
gpr.s4  gpr.s5  gpr.s6  gpr.s7
|-
gpr.t8  gpr.t9
|SetL2HMode || gsObj.SetL2HMode(true)|| (true) and (false) are only known options
gpr.k0  gpr.k1
|-
gpr.gp  gpr.sp  gpr.fp  gpr.ra
|SetUprenderMode ||gsObj.SetUprenderMode(1)|| Set uprender modeOverrides CLI, 0=none, 1=2x2
gpr.lo  gpr.hi  gpr.sa
|-
|SetUpscaleMode || gsObj.SetUpscaleMode("EdgeSmooth") || Sets upscale modeOverrides CLI
|-
|GetFramesInQueue || gsObj.GetFramesInQueue() || Returns the value of the frames that are still in queue
|-
|SetFrameSkipping || gsObj.SetFrameSkipping(true) || false and true are the values.
|-
|SetDeinterlaceShift || gsObj.SetDeinterlaceShift(0) || The values are 1 and 0, Enable or disable interlacing, requires emulators with high api
|-
|}


example: eeObj.GetGpr(gpr.a1)
===== Does not require Object calling or Unknown =====
</pre>


</pre>
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
'''GetCPR0/SetCPR0
! Command !! Usage !! Notes
'''
|-
<pre>cpr.index   cpr.pagemask
| eeInsnReplace || eeInsnReplace(EE memory offset, Original opcode (BE), Replace opcode (BE)) || Replace 4 bytes opcode in ee memory, correct memory range is 0x0 to 0x1FFFFFFF
cpr.random   cpr.wired
|-
cpr.entrylo0      cpr.badvaddr
| vuInsnReplace || <pre>vuInsnReplace(vu 0/1, vu memory offset divided by 8, (original opcode<<32) | original opcode, (replace opcode<<32) | replace opcode) </pre>|| Replace 2 x 4 bytes in VU memory, correct memory range depend on selected VU, left shift by 32 is used for VU lower opcodes. Command will fail if size is above 254. <pre>example:
cpr.entrylo1      cpr.count
vuInsnReplace(0, 0x167, (0x000002ff << 32) | 0x520507ff,(0x000002ff << 32) | 0x8000033c)
cpr.context   cpr.entryhi
Replace 64 bits of VU0 at offset 0xB38</pre>
 
|-
 
| iopInsnReplace || iopInsnReplace(IOP memory offset, Original opcode, opcode replacement) || Replace 4 bytes in iop memory, correct memory range is 0x0 to 0x1FFFFF, iopInsnReplace(0x1FFFFF, 0x0, 0x0803fff0)
cpr.compare   cpr.config    cpr.taglo
|-
cpr.status   cpr.badpaddr  cpr.taghi
| eeNativeFunction || eeNativeFunction(<ee offset>, <original opcode>, <function>) || eeNativeFunction(0x11fa9c, 0x0080402d, 'memcpy')
cpr.cause   cpr.hwbk cpr.errorepc
Different emulators can have different functions included, vide SO3. Require api 1.4 or higher.
cpr.epc   cpr.pccr
But functions from this list should be available in every emu:
cpr.prid
<pre>ieee754_acosf ieee754_asinf ieee754_sqrtf
 
fabs cosf fabsf
example: eeObj.GetCPR0(cpr.status) </pre>
sinf acosf asinf
 
sqrtf fptoui fptodp
====SetGsTitleFix====
litodp dptoli dptofp
 
memcpy memset strlen</pre>
<pre>One of the most important commands in lua, allows to change the GS's behavior.
|-
Part of EmuObject() class, used frequently in official configs.</pre>
| eeNativeHook || eeNativeHook(<ee ofset>, <original opcode>, <action>) || eeNativeHook require apiRequest(1.4) or higher.
'''Examples'''
|-
<pre>
| GsCustomShader || ||
-- fix vision logo (Wild Arms 3)
|-
local thresholdArea = 0 -- ignore alls items : fix #112276
| Unlock || ||
emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , {  texType = 3, cbp = 0x2390, tbp = 0x288000} )
|-
------------------------------------------------------------------------------------------------------
| IsUnlocked || ||
-- Ignore up-render shift for triangles when writing mask = write alpha only . Will fix shadows (bug# 6724).
|-
emuObj.SetGsTitleFix( "ignoreUpShiftTri", "reserved" , { fbmask = 0x00FFFFFF  } )
| InsnOverlay || InsnOverlay({<opcode, opcode, opcode...>}) || example: <div align="left"><pre>InsnOverlay({
------------------------------------------------------------------------------------------------------
0x27bdfff0, -- addiu $sp, -0x10
--  Performance  fix ( bug# 9474 )
0xffbf0000, -- sd $ra, 0(sp)
if 0 then  -- emuObj.IsNeoMode() then  -- neo mode check disabled, due to bug #10442
0xffb00008, -- sd $s0, 8(sp)
    emuObj.SetGsTitleFix( "globalSet", "reserved", { workLoadThreshold = 125000} )
0x3c05000f, -- lui $a1, 0x000f
else
0x34a57000, -- ori $a1, 0x7000
    emuObj.SetGsTitleFix( "globalSet", "reserved", { workLoadThreshold = 100000} )
0x0c0db8b6, -- jal Script::State::DoString
end
0x0080802d, -- move $s0, $a0
------------------------------------------------------------------------------------------------------
0x24050001, -- li $a1, 1
-- bug# 9972
0x0c0dba4c, -- jal Script::State::IsNull(int)
emuObj.SetGsTitleFix( "ignoreSubBuffCov", "reserved", { } )
0x0200202d, -- move $a0, $s0
------------------------------------------------------------------------------------------------------
0xdfb00008, -- ld $s0, 8(sp)
-- Bully bug 9392
0xdfbf0000, -- ld $ra, 0(sp)
-- Performace fix
0x03e00008, -- jr ra
local thresholdArea = 600
0x27bd0010  -- addiu $sp, 0x10
emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , {alpha=0x80000044 , zmsk=1 , tw=4, th=4  } )
})</pre></div>
------------------------------------------------------------------------------------------------------
|-
-- Bug#9174 -
| eeDebugBreak || ||
emuObj.SetGsTitleFix( "ignoreSubBuffCov", "reserved", { } )
|-
------------------------------------------------------------------------------------------------------
| CsBindShader || ||
-- Bug#9240 (Light maps uprender)
|-
-- Copy z-buffer for future use with light maps. psm = SCE_GS_PSMZ24 (49)
| CsSetParamInt32 || ||
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", {tw=9, th=9, psm=49, zmsk=1 } )
|-
------------------------------------------------------------------------------------------------------
| CsSetParamFloat || ||
-- Apply light maps texMode=2 (bilinear)  psm= SCE_GS_PSMCT32 (0)
|-
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", {tw=8, th=8, psm=0, ztst=1, texMode=2 } )
| CsResetContext || ||
------------------------------------------------------------------------------------------------------
|-
-- Performace fix (bug #9785 )
| CsPrintContext || ||
emuObj.SetGsTitleFix( "globalSet", "reserved", { waveThreshold = 90000} )
|-
emuObj.SetGsTitleFix( "ignoreAreaUpdate", 0, { } )
| PsBindShader || ||
------------------------------------------------------------------------------------------------------
|-
-- Accumulate fill area only when conditions are met
| PsSetParamInt32 || ||
emuObj.SetGsTitleFix( "includeAreaUpdate", "reserved" , {alphaIsNot = 0, zmsk = 1, tw = 6, th = 6 , tbp = 0x00302000} )
|-
emuObj.SetGsTitleFix( "ignoreUpRender", 130 , { totalArea= 700} )
| PsSetParamFloat || ||
------------------------------------------------------------------------------------------------------
|-
-- Fix shadow
| PsResetContext || ||
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1  } )
|-
------------------------------------------------------------------------------------------------------
| PsPrintContext || ||
-- Reduce flush count
|-
emuObj.SetGsTitleFix( "SetSelfRender", "reserved", { fbmask= 0x00FFFFFF , renderSelf=1 , zmsk=1 , alpha=0 , texMode=1  } )
|}
------------------------------------------------------------------------------------------------------
 
-- Disable post-processing
<pre>Note: eeObj, emuObj, gsObj, etc. are described as required but this is not really true. You can set the functions locals that they use as whatever you want, but due to the specificity of that emulator, it will be better to keep official naming used in official configs.</pre>
emuObj.SetGsTitleFix( "ignoreSprite", "reserved", {  texType=1 , tw=5 , th=8, zmsk=1 , alpha=0x80000044  } )
------------------------------------------------------------------------------------------------------
-- Small triangle rejection. Works in conjunction with CLI setting  gs-override-small-tri-area=1
-- keep default area for texture 256x256 ( no blend)  (Anakin face)
emuObj.SetGsTitleFix( "setRejectionArea", 500,{twIsNot=8, thIsNot=8 } )
------------------------------------------------------------------------------------------------------
-- Set triangle rejection area= 1000  when alpha blend is not 0 ( i.e blend is On)
emuObj.SetGsTitleFix( "setRejectionArea", 1000, {alphaIsNot=0 } )
------------------------------------------------------------------------------------------------------
-- Performace fix
local thresholdArea = 600
emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , {alpha=0x80008068 , zmsk=1 } )
------------------------------------------------------------------------------------------------------
-- Performace fix
local thresholdArea = 700
emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , {alpha=0x80000044 , zmsk=1 } )
------------------------------------------------------------------------------------------------------
-- Disable uprender on the draw command which samples the framebuffer (0x3200) using bilinear sampling (texMode=2)
-- All lighting effects use TriFan prim type, so use that as well to filter against.
emuObj.SetGsTitleFix( "forceSimpleFetch",  "reserved", {prim=5, texMode=2, tbp=0x320000} )
</pre>


===== Other objects =====


'''Commands'''
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Command !! Notes
! Command !! Usage !! Notes
|-
|-
|globalSet || used with workLoadThreshold or  waveThreshold or loadThreshold
! !! getGLSObject class !!
|-
|-
|reserved ||
| getGLSObject || ||  
|-
|-
|forceBiLinear ||
|Enable || ||
|-
|-
|ignoreSubBuffCov|| ignore ? buffer coverage
|EnableServerRecording || ||  
|-
|-
|trianglesAsParticles||
|Pause || ||  
|-
|-
|ignoreAreaUpdate||
! !! getAudioObject class !!
|-
|-
|SetSelfRender||
| getAudioObject || ||  
|-
|-
|ignoreSprite||
| muteStreamingAll || ||  
|-
|-
|clipScissors||
| muteStreamingMain || ||  
|-
|-
|forcePoint||
| muteStreamingBGM || ||  
|-
|-
|forcePointSampling||
! !! getRemotePlayObject class !!
|-
|-
|setRejectionArea||
| getRemotePlayObject || ||  
|-
|-
|ignoreUpRender|| Ignore uprender for texture type described in params
| Enable || ||  
|-
|-
|includeAreaUpdate||
! !! getVideoRecordingObject class !!
|-
|-
|forceSimpleFetch|| Used Frequently To Fix Graphical Corruptions, emuObj.SetGsTitleFix( "forceSimpleFetch",  "reserved", {psm=0} )
| getVideoRecordingObject || ||
|-
|-
|fetchFromCurrBuff|| emuObj.SetGsTitleFix( "fetchFromCurrBuff", "reserved", {psm=0} )
| Enable || ||  
|-
|-
|ignoreUpShiftTri|| emuObj.SetGsTitleFix( "ignoreUpShiftTri", "reserved", {psm=0} )
! !! getSharePlayObject class !!
|-
|-
|skipPacked||
| getSharePlayObject || ||  
|-
|-
|changeAlpha||
| Enable || ||  
|-
|-
|ignoreUpRenderTimeout||
! !! getSpriteObject group  !!
|-
|-
|}
|getSpriteObject || ||
 
'''Arguments/variables
'''
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Argument !! Notes
|-
|-
|alpha_mask ||  
|Enable || ||
|-
|-
|alphaIsNot || alpha - is not X
|Disable || ||
|-
|-
|texMode || 1 - Point? , 2 - bilinear
|BindFragmentShader || ||
|-
|-
|twIsLess || texture width - is less than X
|SetShaderParams || || <div align="left">
|-
<pre> Is not clear that params depend on shader, or are somehow hardcoded.
|thIsLess || texture height - is less than X
Example usage:
|-
 
|twIsNot || texture width - is not X
local sprite0 = getSpriteObject(0)
|-
local scanlineParams = {
|thIsNot || texture width - is not X
240.0, -- float scanlineCount
|-
  0.7, -- float scanlineHeight;
|psmIsNot || texture pixel storage format - is not X
1.5,        -- float scanlineBrightScale;
<pre>PSMCT32  = 0   PSMT4HL = 36
0.5,        -- float scanlineAlpha;
PSMCT24  = 1   PSMT4HH = 44
0.5        -- float vignetteStrength;
PSMCT16  = 2  PSMZ32  = 48
}
PSMCT16S = 10  PSMZ24  = 49
 
PSMT8    = 19  PSMZ16  = 50
sprite0.SetShaderParams(scanlineParams)</pre></div>
PSMT4    = 20  PSMZ16S = 58
PSMT8H  = 27  </pre>
|-
|-
|zmsk || Z (depth) draw mask
|BindTexture || ||
<pre>update Z buffer      = 0
don't update Z buffer = 1
 
When 1 depth test result will be ignored</pre>
|-
|-
|tw || texture width
|SetPosXY || ||
|-
|-
|th || texture height
|SetSizeXY || ||
|-
|-
|ztst || Z (depht) test method
|SetPosUV || ||
<pre>ZNOUSE  = 0
ZALWAYS  = 1
ZGEQUAL  = 2
ZGREATER = 3
 
0 -                      All pixels fail
1 -                      All pixels pass
2 - Pass if Z grater or equal to Z buffer
3 -        Pass if Z grater than Z buffer</pre>
|-
|-
|mipIsGt || mip level is grater than X (?)
|SetSizeUV || ||
|-
|-
|mmin || MMIN flag
|PrintContext || ||
<pre>NEAREST                = 0
LINEAR                = 1
NEAREST_MIPMAP_NEAREST = 2
NEAREST_MIPMAP_LINEAR  = 3
LINEAR_MIPMAP_NEAREST  = 4
LINEAR_MIPMAP_LINEAR  = 5</pre>
|-
|-
|prim || GS primitive type
|SetBlendColor || sprite<X>.SetBlendColor(<R,G,B,A>) in floats, max val. 1.0 || <div align="left">
<pre>Point        = 0
<pre>local sprite0 = getSpriteObject(0)
Line          = 1
sprite0.SetBlendColor(1.0,1.0,1.0,1.0)</pre></div>
LineStrip    = 2
Triangle      = 3
TriangleStrip = 4
TriangleFan  = 5
Sprite        = 6</pre>
|-
|-
|primIsNot || GS primitive type - is not
| getTrophyObject || local trophyObj = getTrophyObject() || Required for all functions using trophyObj
<pre>Point        = 0
Line          = 1
LineStrip    = 2
Triangle      = 3
TriangleStrip = 4
TriangleFan  = 5
Sprite        = 6</pre>
|-
|-
|fillArea ||  
| getDmaObject || local dmaObj = getDmaObject() || Depreciated API - use EE:DmaAddHook / EE:DmaRemoveHook instead. Is not clear when it was depreciated, JAK emu don't use it.
|-
|-
|frameW ||  
| getScreenShotObject || ||  
|-
|-
|renderSelf ||
|}
|-
 
|hasClut ||
==== Registers for hook ====
|-
 
|alphaTest ||
Registers defined in alias files.
|-
 
|primTest ||
'''GetGpr/SetGpr
|-
'''
|workLoadThreshold ||
<pre>gpr.zero gpr.at
|-
gpr.v0  gpr.v1
|alpha || <pre> example: alpha=0x80000044
gpr.a0  gpr.a1  gpr.a2  gpr.a3
alpha=0</pre>
gpr.t0  gpr.t1  gpr.t2  gpr.t3
|-
gpr.t4  gpr.t5  gpr.t6  gpr.t7
|texType || (1-3, more? )
gpr.s0  gpr.s1  gpr.s2 gpr.s3
|-
gpr.s4 gpr.s5 gpr.s6 gpr.s7
|tbp || texture base pointer
gpr.t8 gpr.t9
|-
gpr.k0 gpr.k1
|cbp || CLUT buffer base pointer
gpr.gp  gpr.sp gpr.fp gpr.ra
|-
gpr.lo gpr.hi gpr.sa
|psm || texture pixel storage format
 
<pre>PSMCT32 = 0  PSMT4HL = 36
example: eeObj.GetGpr(gpr.a1)
PSMCT24 = 1  PSMT4HH = 44
</pre>
PSMCT16 = 2  PSMZ32 = 48
 
PSMCT16S = 10 PSMZ24 = 49
'''GetCPR0/SetCPR0
PSMT8    = 19 PSMZ16 = 50
'''
PSMT4    = 20 PSMZ16S = 58
<pre>cpr.index   cpr.pagemask
PSMT8H  = 27 </pre>
cpr.random   cpr.wired
|-
cpr.entrylo0      cpr.badvaddr
|mxl || maximum mip level (0-6)
cpr.entrylo1      cpr.count
|-
cpr.context   cpr.entryhi
|fbmask || ?
 
|-
 
|totalArea ||
cpr.compare   cpr.config    cpr.taglo
|-
cpr.status   cpr.badpaddr  cpr.taghi
|packedRegs ||
cpr.cause   cpr.hwbk cpr.errorepc
|-
cpr.epc   cpr.pccr
|packedRegsLo ||
cpr.prid
|-
 
|packedRegsHi ||
example: eeObj.GetCPR0(cpr.status) </pre>
|-
 
|packedRegsNum ||
 
|-
==== Official PS2 configuration examples ====
|packedFlags ||
 
|-
*You can find the rest of the PS2 configurations in [https://www.psdevwiki.com/ps4/Official_Configuration_Files here].
|packedPrim ||
|-
|areaNumFrames ||
|-
|waveThreshold ||
|-
|loadThreshold ||
|-
|fixSpriteDivTab ||
|}


====Official examples====
[https://www.psdevwiki.com/ps4/Talk:PS2_Classics_Emulator_Compatibility_List#Official_PS2emu_Configuration_Files You can find the rest of them here]
<br>Canis Canem Edit
<br>Canis Canem Edit
<br>'''SLES 535.61'''
<br>'''SLES 535.61'''
Line 1,864: Line 1,851:
</pre>
</pre>


====Custom config.lua examples====
==== Custom config.lua examples ====
Here is the first custom lua config created by the community:
 
Here is the first custom LUA configuration created by the community:


<pre>
<pre>
Line 1,874: Line 1,862:
eeInsnReplace(0x1CF3CC, 0x4100ffff, 0x00000000) -- bc0f 0x1CF3CC to nop
eeInsnReplace(0x1CF3CC, 0x4100ffff, 0x00000000) -- bc0f 0x1CF3CC to nop
</pre>
</pre>
This is very basic command to replace part of EE memory with other instruction.  
This is a very basic command to replace a part of the EE memory with another instruction.  
* apiRequest(0.1) - Is required for every config. Used version depend on your original eboot highest supported api. 0.1 seems to be enough for basic patches like here. 2.3 is highest known for now.  
* apiRequest(0.1) - Is required for every config. Used version depend on your original eboot highest supported api. 0.1 seems to be enough for basic patches like here. 2.3 is highest known for now.  
* -- Fix black screen SLUS-20064 is comment
* -- Fix black screen SLUS-20064 is comment
Line 1,881: Line 1,869:
[https://www.psdevwiki.com/ps4/Talk:PS2_Classics_Emulator_Compatibility_List#Custom_PS2emu_Configuration_Files Other custom configurations made by users can be found here]
[https://www.psdevwiki.com/ps4/Talk:PS2_Classics_Emulator_Compatibility_List#Custom_PS2emu_Configuration_Files Other custom configurations made by users can be found here]


=Memory Mapping=
= Memory Map =


{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: left;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: left;"
Line 1,899: Line 1,887:
|-
|-
! !! Host's EE Memory Map !!
! !! Host's EE Memory Map !!
|-
| EE Registers Map                ||  0x0000001000000000 ||  0x0000001000004000
|-
|-
|EE RAM - Kernel                  ||  0x0000008000000000 ||  0x0000008000080000
|EE RAM - Kernel                  ||  0x0000008000000000 ||  0x0000008000080000
Line 1,938: Line 1,924:
|}
|}


==Registers Map==
== Registers Map ==
===EE - FPU - COP0 - IOP===
 
<br>'''Incomplete, there could be some incorrect information in this list.'''
=== EE-IOP ===
<pre>Warning: 0x1000000xxx base is not guaranteed in different emu revisions, but layout should be the same regardless of base.
 
if base is different (Like on kof2000), simply reduce these offsets by 8 hex values.
<pre>
This list was made for the purpose of making a future debugger for the PS4's PS2 emulator.
This list of registers is yet to be completed. Some registers are incorrectly named or include incorrect offsets. 0x1000000xxx base is not guaranteed in different emu revisions, but layout should be the same regardless. Assuming base is different (Like on kof2000), simply reduce these offsets by 8 hex values (IOP, VU0, and VU1 registers' offsets are static in all emulators).
</pre>
 
<pre>
List was designed for Jak v2
Eboot md5:c644f6879af225a6e5a70233fc4625a3
</pre>
</pre>
<pre> Tested on Jak v2
 
Eboot md5:c644f6879af225a6e5a70233fc4625a3</pre>
{| class=wikitable style="border: none; background: none;"
{| class=wikitable style="border: none; background: none;"
! scope=col | GPR / EE
! scope=col | GPR-EE
! scope=col | Address
! scope=col | Address
| rowspan=900 style="border: none; background: none;"|
| rowspan=900 style="border: none; background: none;"|
! scope=col | FPR / FPU
! scope=col | FPR
! scope=col | Address
! scope=col | Address
| rowspan=900 style="border: none; background: none;"|
| rowspan=900 style="border: none; background: none;"|
! scope=col | CP0 / COP0
! scope=col | CP0
! scope=col | Address
! scope=col | Address
| rowspan=900 style="border: none; background: none;"|
| rowspan=900 style="border: none; background: none;"|
! scope=col | GPR / IOP
! scope=col | GPR-IOP
! scope=col | Address
! scope=col | Address
|-
|-
Line 2,024: Line 2,014:
|  ra || 0x10000001F0  || f31  || 0x10000002AC ||  Rsvd31 ||    0x100000034C ||    ra || 0x102000007C  
|  ra || 0x10000001F0  || f31  || 0x10000002AC ||  Rsvd31 ||    0x100000034C ||    ra || 0x102000007C  
|-
|-
unk (pc?) || 0x1000000200  ||  fACC ||  0x10000002B0 || {{cellcolors|#7698FF|#000000}}COP0 additional registers  || ||    pc || 0x102000008C     
hi/hi1 (2x 64bit) || 0x1000000200  ||  fACC ||  0x10000002B0 || {{cellcolors|#7698FF|#000000}}COP0 additional registers  || ||    pc || 0x102000008C     
|-style="background-color:#EEEFF2"
|-style="background-color:#EEEFF2"
hi/lo (2 x 64?) || 0x1000000210  || {{cellcolors|#7698FF|#000000}}FPU CTRL (FCR) ||  || real Pcr0 ||  0x1000000350 ||  hi ||0x1020000090 ??
lo/lo1 (2x 64bit) || 0x1000000210  || {{cellcolors|#7698FF|#000000}}FPU CTRL (FCR) ||  || real Pcr0 ||  0x1000000350 ||  hi ||0x1020000090 ??
|-
|-
|  sa  ||  0x1000000220 ||  cp1cond  ||  0x10000002B4 || real Pcr1  || 0x1000000358  ||  lo  || 0x1020000094 ??
|  sa  ||  0x1000000220 ||  cp1cond  ||  0x10000002B4 || real Pcr1  || 0x1000000358  ||  lo  || 0x1020000094 ??
Line 2,040: Line 2,030:
|}
|}


===Emulator related regs===
=== Emulator related registers ===
 
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! {{cellcolors|#7698FF|#000000}}"Fake" register !! Address !! Notes   
! {{cellcolors|#7698FF|#000000}}"Fake" registers !! Address !! Notes   
|-
|-
| unknown || 0x1000000360      || Locking the value seems to cause a crash.
| (?) || 0x1000000360      || Locking the value seems to cause a crash.
|-style="background-color:#8b9dc3"
|Current PC<br>(4 Bytes) || 0x1000000368 || Shows the current offset that's being executed by the EE.<br>
Updated only on branch/jump tests, unless commands such as --ee-pc-coherency  or --ee-insn-flush-pc are used.<br>
Then updates are instant, right when instructions are executed. <br>
Commonly used by sceners as a way of finding troublesome offsets. Can be found in some emulators here too: 0x8000016830
|-
|-
|Current PC || 0x1000000368 || Shows the current offset that's being read by the EE
| (?) || 0x100000036C ||
|-
Updated on branch/jump instructions, emulator seems to use it to store next address that will be executed.
| ?? || 0x100000036C || it showed 0x80000184 in dbz bd 1
At least in recompiler to interpreter fallback mode. During tests it shows 0x80000184
|-
|-
| Delta counter  || 0x1000000370  ||<pre>(Passed cycles, likely decrementer).  
| Delta counter  || 0x1000000370  ||<pre>(Passed cycles, likely decrementer).  
Line 2,055: Line 2,051:
advanceclock subtract value from this fake reg)</pre>
advanceclock subtract value from this fake reg)</pre>
|-
|-
|Cycles ||0x1000000378|| (need work)
|Cycles ||0x1000000378||
|-
| (?) || 0x1000000384 || <pre>Address when last exception occurred on r5900.
This register most of times will hold last executed syscall address,
sometimes last tlb miss or break(if "as nop" is disabled).
Unlike the pc, this one doesn't change after a crash and has much lower latency.
Thus meaning it's better at diagnosing problems.</pre>
|-
|-
|}
|}


---------------------------------------------------------------------------------------------------------------------------------
=== VU0 Registers ===
===VU0===
 
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| class=wikitable style="border: none; background: none;"
{| class=wikitable style="border: none; background: none;"
Line 2,131: Line 2,133:
|  vi05|| 0x1030000260  || I || 0x1030000360
|  vi05|| 0x1030000260  || I || 0x1030000360
|-
|-
|  vi06||  0x1030000270 || Q || 0x1030000370??
|  vi06||  0x1030000270 || Q || 0x1030000590
|-style="background-color:#EEEFF2"
|-style="background-color:#EEEFF2"
|  vi07||  0x1030000280 || c2c23 || 0x1030000380??
|  vi07||  0x1030000280 || c2c23 || 0x1030000380??
Line 2,152: Line 2,154:
|-
|-
|}
|}
=== VU1 Registers ===


---------------------------------------------------------------------------------------------------------------------------------
===VU1===
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| class=wikitable style="border: none; background: none;"
{| class=wikitable style="border: none; background: none;"
Line 2,214: Line 2,214:
! scope=col | Address
! scope=col | Address
|-  
|-  
| vi00 || 0x1040000210 ||Status|| 0x1040000310??
| vi00 || 0x1040000210 ||vi16|| 0x1040000310??
|-style="background-color:#EEEFF2"
|-style="background-color:#EEEFF2"
| vi01 || 0x1040000220  || MACflag || 0x1040000320??
| vi01 || 0x1040000220  || vi17 || 0x1040000320??
|-
|-
|  vi02|| 0x1040000230  || Clipflag || 0x1040000330??
|  vi02|| 0x1040000230  || vi18 || 0x1040000330??
|-style="background-color:#EEEFF2"
|-style="background-color:#EEEFF2"
|  vi03||  0x1040000240 || c2c19 || 0x1040000340??
|  vi03||  0x1040000240 || vi19 || 0x1040000340??
|-
|-
|  vi04||  0x1040000250 ||  R || 0x1040000350??
|  vi04||  0x1040000250 ||  vi20 || 0x1040000350??
|-style="background-color:#EEEFF2"
|-style="background-color:#EEEFF2"
|  vi05|| 0x1040000260  || I || 0x1040000360
|  vi05|| 0x1040000260  || vi21 || 0x1040000360
|-
|-
|  vi06||  0x1040000270 || Q || 0x1040000370??
|  vi06||  0x1040000270 || vi22 || 0x1040000370??
|-style="background-color:#EEEFF2"
|-style="background-color:#EEEFF2"
|  vi07||  0x1040000280 || c2c23 || 0x1040000380??
|  vi07||  0x1040000280 || vi23 || 0x1040000380??
|-
|-
|  vi08||  0x1040000290 || c2c24 || 0x1040000390??
|  vi08||  0x1040000290 || vi24 || 0x1040000390??
|-style="background-color:#EEEFF2"
|-style="background-color:#EEEFF2"
|  vi09||  0x10400002A0 || c2c25 || 0x10400003A0??
|  vi09||  0x10400002A0 || vi25 || 0x10400003A0??
|-
|-
|  vi10||  0x10400002B0 || TPC || 0x10400003B0
|  vi10||  0x10400002B0 || vi26 || 0x10400003B0
|-style="background-color:#EEEFF2"
|-style="background-color:#EEEFF2"
|  vi11||  0x10400002C0|| CMSAR0 || 0x10400003C0??
|  vi11||  0x10400002C0|| vi27 || 0x10400003C0??
|-
|-
|  vi12||  0x10400002D0 || FBRST || 0x10400003D0
|  vi12||  0x10400002D0 || vi28 || 0x10400003D0
|-style="background-color:#EEEFF2"
|-style="background-color:#EEEFF2"
|  vi13||  0x10400002E0 || VPU-STAT || 0x10400003E0??
|  vi13||  0x10400002E0 || vi29 || 0x10400003E0??
|-
|-
|  vi14||  0x10400002F0 || CMSAR1 || 0x10400003F0??
|  vi14||  0x10400002F0 || vi30 || 0x10400003F0??
|-style="background-color:#EEEFF2"
|-style="background-color:#EEEFF2"
|  vi15||  0x1040000300 || c2c30 || 0x1040000400??
|  vi15||  0x1040000300 || vi31 || 0x1040000400??
|-
|-
|}
|}
====Registers information====
[https://psi-rockin.github.io/ps2tek/ Information taken from here]
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Name !! Purpose / info
|-
|  zero    ||  Hardwired to 0, writes are ignored
|-
|  at      ||  Temporary register used for pseudo-instructions
|-
| v0-v1    ||  Return register, holds values returned by functions
|-
|  a0-a3    ||  Argument registers, holds first four parameters passed to a function
|-
| t0-t7    ||  Temporary registers. t0-t3 may also be used as additional argument registers
|-
|  s0-s7    || Saved registers. Functions must save and restore these before using them
|-
|  t8-t9    || Temporary registers
|-
|  k0-k1    || Reserved for use by kernels
|-
|  gp        || Global pointer
|-
|  sp        || Stack pointer, address of currently-executing function
|-
|  fp        || Frame pointer
|-
|  ra        || Return address. Used by JAL and (usually) JALR to store the address to return to after a function
|-
! Special registers !!
|-
|  pc        || Program counter, address of currently-executing instruction (32-bit)
|-
| hi/lo    || Stores multiplication and division results (64-bit)
|-
|  hi1/lo1  || Used by MULT1/DIV1 type instructions, same as above (64-bit)
|-
|  sa        ||Shift amount used by QFSRV instruction
|-
|}
<pre>
Aside from zero, all GPRs may be freely accessed if convention rules are respected.
</pre>


=Open CL and Floats=
= Open CL and Floats =
 
In this part, we describe the PS4 native Floating point support and OpenCL information, for both CPU and GPU. The understanding of floating point conversion is very important for emulating the PS2. The information below came from this [https://gist.github.com/masterzorag/06cadbc5fbe7d3375704fc52518f434e#file-gistfile1-md gist].


PS4 native Floating point supports and OpenCL info, for both CPU, and GPU. Understanding of floating points conversion is very important in emulating PS2.
== CPU ==
<br>Below info comes from this [https://gist.github.com/masterzorag/06cadbc5fbe7d3375704fc52518f434e#file-gistfile1-md gist]
<br>There you can find more info about PS4 OpenCL.


==CPU==
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Info !! Value
! Info !! Value
Line 2,378: Line 2,334:
|}
|}


==GPU==
== GPU ==


{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
Line 2,476: Line 2,432:
|}
|}


=PS3 Config support=
= PS3 Configuration support =
 
<pre>
<pre>
Emulator support configs in format known from ps2_netemu/ps2classic from PS3. This feature was
The PS2 emulator of the PS4 supports configurations in the known format from ps2_netemu/ps2classic that came from the PS3. This feature was officially used in Arc the Lad Twilight of the Spirits ps2-ps4 classic. To enable PS3 style configuration, add this to config-emu-ps4.txt:
officially used in Arc the Lad Twilight of the Spirits ps2-ps4 classic.
To enable ps3 style config add this to config-emu-ps4.txt:


--lopnor-config=1
--lopnor-config=1
--ps2-title-id=TITLE-ID
--ps2-title-id=TITLE-ID


Config file need to be in folder ...'''/patches/{TITLE-ID}/''' and file need to have name '''{TITLE-ID}_lopnor.cfgbin'''. title id need to be in XXXX-YYYYY format (ex. SLUS-12345).  
The configuration file needs to be in folder ...'''/patches/{TITLE-ID}/''' and the file need to have name '''{TITLE-ID}_lopnor.cfgbin'''. The Title ID needs to be in XXXX-YYYYY format (ex. SLUS-12345). Example path: /patches/SLUS-12345/SLUS-12345_lopnor.cfgbin. A tester confirmed that configurations work as is without even the need to edit them.
Example path: /patches/SLUS-12345/SLUS-12345_lopnor.cfgbin
Tester confirmed that configs work like that. We don't even need to edit them, they work as is.
</pre>
</pre>


<pre>
<pre>
Please keep in mind that not all commands are recognized, only 0x01 (can depend upon emu revision), 0x09, 0x0A, 0x0B, 0x0F, 0x10, 0x26, 0x27, 0x42.
Please keep in mind that not all PS3 commands are recognized, only 0x01 (can depend upon emu revision), 0x09, 0x0A, 0x0B, 0x0F, 0x10, 0x26, 0x27 and 0x42.
For example Rayman 3 config Does not work due to the command being unsupported
For example, the Rayman 3 configuration does not work due to the command being unsupported on PS4.
Command 0x07 is NOT recognized, but can be manually translated to cli config (to: --vu-xgkick-delay=value).
Command 0x07 is NOT recognized, but can be manually translated to CLI configuration (to "--vu-xgkick-delay=value").
Same goes for 0x11 (--vu0-accurate-addsub-range can be used).
Same goes for command 0x11 (--vu0-accurate-addsub-range can be used).
</pre>
</pre>
*Configs explained in text form: https://github.com/Zarh/Get_CONFIG/blob/master/log.txt
*Configs explained in text form: https://github.com/Zarh/Get_CONFIG/blob/master/log.txt
*More about PS3 style configs/commands: https://www.psdevwiki.com/ps3/PS2_Emulation#Game_CONFIG
*More about PS3 style configurations/commands: https://www.psdevwiki.com/ps3/PS2_Emulation#Game_CONFIG
*Log from loading that kind of config: https://pastebin.com/ZpUyU8DE
*A PS4 log from loading that kind of config: https://pastebin.com/ZpUyU8DE
 
= Known issues =


=Known issues=
<pre>List of known issues in the PS4's PS2 emulator</pre>
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Issue !! Games affected !! Solution !! Description
! Issue !! Games affected !! Solution !! Description
|-
|-
| <pre> Uknown GIFIFO issue </pre> || <pre>Genji dawn of the samurai, Harry potter and the prisoner of azkaban, Batman begins, Lara Croft Tomb Raider - The Angel of Darkness, Dragon ball z budokai tenkaichi 1, Possibly many more! </pre>|| LUA patches || nop instructions similar to bnez bqez that go up the disassembler window rather than down and hope for the best
| No support for EE Cache || Ice Age 2, DOA2: Extreme, Nascar 2009, Barnyard, [https://github.com/PCSX2/pcsx2/issues/2248 Others]|| Lua patches to the EE memory and picking the right emulator ||
|-
|-
| <pre>No support for EE Cache</pre> || <pre>Ice Age 2, DOA2: Extreme, Nascar 2009, Barnyard,</pre> [https://github.com/PCSX2/pcsx2/issues/2248 Others]|| <pre>Lua patches to the EE memory and picking the right emulator</pre> || <pre>It's not a ps4 issue per say since these issues are also encountered by Pcsx2. but Pcsx2 does have support for EE cache, though it doesn't use it to fix these games because emulating EE cache is extremely slow. so that's why the Pcsx2 team decided to use pnach patches to fix this issue.</pre>
| Missing COP2 pipeline emulation. || [https://github.com/PCSX2/pcsx2/issues/4439 other games affected by COP2 timing] || Rearranging code through lua patches. || While COP2 is a part of EE, in terms of emulation it's a separate processor that can run on its own. Consequently, some operations take a long time while EE still minds own its business. Some games abuse this and do their own thing, knowing that COP2 calculation takes an expected number of cycles. On this emu, every COP2 opcode is instant, which break games that expect it to take some time.
|-
|-
|<pre> VU0/COP2 is not running in sync with EE core </pre>|| <pre>24 The Game, ATV Quad Power Racing 2, Twisted Metal Head-On, Primal, Ghosthunter, Rayman Arena, Rayman 3, Largo winch. All games using M-bit.</pre> [https://github.com/PCSX2/pcsx2/issues/4439 other games affected by COP2 timing] || <pre>ee hook AdvanceClock or fastforwardclock commands on affected addresses, Most of the time it will be CTC2 instructions that are affected</pre> <pre>Or using Kozraovv's method of EE memory patching</pre> || [[Talk:PS2_Classics_Emulator_Compatibility_List#Rayman_3:_Hoodlum_havoc | Rayman 3's fix for example]]
| VU0 is not running in sync with EE core || 24 The Game, ATV Quad Power Racing 2, Ghosthunter, Rayman Arena, Rayman 3, Largo winch, Ratchet and clank games. All games using M-bit. || EE hook AdvanceClock or fastforwardclock commands on affected addresses to push VU0 ahead while stalling EE, setting the value of 5 to ee cycle scalar, and patches to rearrange code. Most of the time, it will be CTC2/QMTC2 instructions with interlock that are affected. || Emulator kickstarts VU0 for 256 cycles, while reporting that 512 cycles passed. Yup, we are out of sync right from the start of VU0 mpg because people working for $ony don't know that VU0 run at EE MHz, not at EE bus MHz. Not to mention, that a 256 cycles kickstart is too much even on the correct speed. Later things just got worse. This issue can be partially replicated on Pcsx2 if you overclock the EE by +3
[[Talk:PS2_Classics_Emulator_Compatibility_List#Largo_Winch | Largo winch's fix for example]]
<pre>This issue can also be replicated on Pcsx2 if you overclock the EE by +3</pre>
|-
|-
| <pre>No roundmode support for VU or FPU </pre>|| <pre>Koun, Tony hawk games, Devil may cry 3, Gun, TY the Tasmanian Tiger 3, Beyond Good & Evil, MTX Mototrax, Many others</pre> || <pre>Lua patches to the EE memory</pre> ||
| FPU/VU math inaccuracies. || Koun, Tony hawk games, Devil may cry 3, Gun, TY the Tasmanian Tiger 3, Beyond Good & Evil, MTX Mototrax, Max payne, Bully, Jackie chan adventures, Wild arms 3, Pac-man World 3, Gran turismo 4, Many others  || Lua patches to the EE memory, accurate math commands. || PS2 use really obscure floating point math, only one guard bit is used in calculations. PCSX2 hack it with different rounding modes, emu on ps4 fix it with soft floats, usually applied per offset. Sometime with patches directly to affected code (THPS engine).
<br>It's worth noting that pcsx2 by default applies "accurate add/sub" for every single FPU opcode, and only to fpu opcodes. That's why accurate add/sub is needed on the PS4 while pcsx2 is happy with its default settings.
|-
|-
| <pre>No M-Bit support</pre> || '''Every game that uses M-Bit'''. <pre>Totally Spies! Totally Party, Mike Tyson Heavyweight Boxing, My Street, Crash Twinsanity, Marvel Nemesis, Panzer Elite Action - Fields of Glory, Super Monkey Ball Adventure, most Eko Software games, and many more.</pre> [https://github.com/PCSX2/pcsx2/pull/3593] || <pre>Lua patches to the EE memory</pre> || <pre>M-bit: Only applicable for VU0. Ends interlock on a single QMTC2.I/CTC2.I instruction, allowing the EE to continue execution</pre>
| M-Bit support is broken || '''Every game that uses M-Bit'''. Totally Spies! Totally Party, Mike Tyson Heavyweight Boxing, My Street, Crash Twinsanity, Marvel Nemesis, Panzer Elite Action - Fields of Glory, Super Monkey Ball Adventure, most Eko Software games, and many more. [https://github.com/PCSX2/pcsx2/pull/3593] || Lua patches to the EE memory || While emulator respect m-bit, way that VU0 work on it make it broken most of times (check "VU0 is not running in sync with EE core" issue).
|-
|-
| <pre>Wrong read speed for some games</pre> || <pre>Shadowman(Textures), God of war (Music), Ratchet and clank size matters (Music), every game that's listed to require CDVD_READ_DELAY.</pre> [https://github.com/PCSX2/pcsx2/pull/3877 and many other affected games] || Try your luck with IOP and CDVD CLI commands. || Also known in sony's bios as CDVD_READ_DELAY
| Multitap doesn't support all games || Urban reign, Digimon Rumble Arena 2, others || Lua patches || Emulator expect PS4 to be able to use 8 controllers (well, who doesn't? Even PS1 can do it...). That cause all kind of mess with controller detection when game expect multitap in second port.
|-
|-
| <pre>In-accurate VU0/VU1/COP2 emulation</pre> || <pre>Sly cooper games, Crash twinsanity, Crazy frog racer, Rayman 3, Koei tecmo games, Klonoa 2, others.</pre>  || <pre>Choosing a VU accurate emulator such as Roguev1 or Kof2000 with the right clamping commands</pre> || <pre>The issue leads to SPS and graphical issues and sometimes freezing.</pre>
| DMA writes when busy signal is engaged || Ratchet and clank games, Metal gear solid 2, others || None yet || AKA eetiminghack
|-
|-
| <pre>In-accurate Multiply/Divide/Add/Subtract instructions</pre> || <pre>Max payne, Bully, Jackie chan adventures, Wild arms 3, Pac-man World 3, Gran turismo 4, Others </pre>|| <pre>Addsub/Muldiv Cli commands</pre> || <pre>Causes many geometry issues and black screens. Sony reduced the accuracy of these instructions to improve performance</pre>
|VIF1 runs too fast || Urban reign, Avatar, Parappa 2, Eternal Poison, Soul Calibur 2, Soul Calibur 3, Others   || Using LUA's SchedulerDelayEvent command or Using CLI'S vif1-instant-xfer command || Sony wanted to improve the performance, which is the reason VIF1 is instant. The lua's command can be customizable to set the delay period, the cli can't, therefore lua's command is much more compatible
|-
|-
| <pre>Multitap doesn't support all games</pre> || <pre>Urban reign, many others</pre> || None ||
|Reading VU TPC registers returns wrong values || Street Fighter 3 EX(VU0), R: Racing Revolution(VU0), Spiderman 3 (VU0, in T-Bit handler...), Edge of Reality games(VU1) || Patches in lua. || In this emu TPC stores full addresses, which is wrong. Real hardware keep there addr >> 3. Worth noting that EoR games read VU1 TPC in a nasty way, accessing 0x43A0(VU1 TPC) from COP2 code.
|-
|-
| <pre>DMA writes when busy signal is engaged</pre> || Ratchet and clank games, Metal gear solid 2, others || None yet || AKA eetiminghack
|VIF command interrupts handled before VIFn_CODE is updated. || Onimusha Blade Warriors || Fixed by patch in intr handler. || This is very specific case because Onimusha check VIFn_CODE register in interrupt handler and do nothing if code is not 0x80 (NOP with I). But VIFn_CODE seems to be updated after interrupt is handled. This practically makes everything out of sync later as interrupts are happening, but handler does nothing about them.
|-
|-
|<pre>VU1 running too fast (DMA sync)</pre> || Harry Potter the Chamber of secrets, Mercenaries 2 || None yet ||
| CDVD register 0x1F402038 (KeysValid) return wrong result. || Every "SCCS" game || Patches in lua. || Likely specific to NTSC-C releases, because that region uses special SDK. This issue makes cdvdman become stuck on any request because it thinks that the cdvd key is invalid.
|-
|-
|<pre>VIF1 runs instantly</pre> || <pre>Urban reign, Avatar, Parappa 2, Eternal Poison, Soul Calibur 2, Soul Calibur 3, Others</pre>  || <pre>Using LUA's SchedulerDelayEvent command or Using CLI'S vif1-instant-xfer command</pre> || <pre>Sony wanted to improve the performance, which is the reason VIF1 is instant. The lua's command can be customizable to set the delay period, the cli can't, therefore lua's command is much more compatible</pre>
| Lack of CDVD error handling || Demon Chaos, Spyro A new Beginning, Silent Hill 2 Black Ribbon, games from pcsx2 #5174 PR. || Patches in lua if needed. || One correctly supported error is SCECdErABRT, rest is just not handled or what's worst trigger emu panic on purpose like SCECdErILI (but not for 0 sector request - Spyro). Some affected games can still work if error is just accidental and not checked by game code.
|-
|-
|<pre>Inaccuracies in the IPU</pre> || Burnout 3, Onimusha dawn of dreams || None yet ||
| Corrupted SIF0 transfer when not full QW is send by IOP || True Crime: LA, PDC DC 2008, Street Racing Syndicate(1.03) || Patches in lua. || IOP is able to send words by SIF0, EE DMAC can only transfer Quadwords. When IOP send not full QW real hardware use whatever was in buffer from previous transfer for missing words (only words that are requested by iop are overwritten in transfer buffer). Emu probably memset 0 that part.
|-
|-
|}
|}


===Diagnosing problems===
= PCSX2 glitches not present on PS4=
<pre>This guide will assist you in tracing the issue's cause,The list is based on what you can possibly solve using CLI</pre>
<pre>
<br>''also don't forget to Check out'' [https://www.psdevwiki.com/ps3/PS2_Emulation#Known_Emulation_Bugs ps3 Emulator] Bugs, since many of them also exist in the ps4
This is a list of glitches that the PS4 does not suffer from, as opposed to PCSX2.</pre>
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;" class="wikitable"
{| cellspacing="0" cellpadding="2" border="1" class="wikitable" style="text-align: center;"
! Issue !! VU1 !! EE !! GS !! VIF !! IOP !! COP2!! VU0 !! VU !! FPU !! SIF
! Issue !! PCSX2's fix !! Games affected !! Description !! PCSX2 issue no.
|--style="background-color:#7698FF"
| || || Natively fixed || ||
|-
| Bad FPU math || Disabling EE recompiler / Janky GameDB patch ||Armored Core Nine Breaker || The AI becomes stuck on some levels, working only when EE recompiler's disabled || #8587
|-
| ? || Enabling EETimingHack || Pac-Man World 2 || Hanging in Butane Pain, Ghost Bayou, Pinky's Revenge and Clyde in the Caldera levels. || Unavailable
|-
|-
| {{cellcolors|#b3e0ff|#000000}}''Performance'' || ✔ || ✔ || ✔ || ? || || || ||  ||  ||
| ? || Unavailable || Persona 3 || Stuttering noise when saving || #7316
|-
|-
| {{cellcolors|#ff8080|#000000}}''Crashes'' || || || || ✔ || ✔ || ✔ || ✔ || ✔ || ✔ || ✔
| ? || Unavailable || Mega Man X8 || Flickering subtitles on FMVS || #5192
|-
|-
| {{cellcolors|#ffff99|#000000}}''Broken graphics'' || || || ✔ || ✔ ||  || ✔|| ✔ || ✔ ||  ||
| Bad timing. || Unavailable || Spyro Enter the Dragonfly || Audio-video desync || #8286
|-
|-
| {{cellcolors|#b3ffb3|#000000}}''Glitches'' || || || || || || || || || ||  
| ? || Unavailable || Petit Copter 2 || In-game hang || #10380
|-
| ? || Unavailable || Yu-Gi-Oh! The Duelists of the Roses || In-game data corruption (?) leading to a hang || #11576
|-
| IPU running faster than it should? || Janky patch || Flame of Recca: Final Burning ||  || #11335
|-
| Bad timing || Unavailable || Ape Escape 3 || Sudden burst of in-game speed at some random points in the map || Unavailable
|-
| ? || vu0RoundMode: 2 || Ape Escape 3 || The character's buster malforms when spawning anew || #11386
|--style="background-color:#D7EF54"
| || || Fixed by using certain commands || ||
|-
| Inaccurate COP2 add/sub implementation|| Unavailable || Driv3r || AI cop car drives at the incorrect direction (Fixed on PS4 with accurate COP2 add/sub) || #11714
|-
|-
|}
|}
'''Performance bottleneck order:'''
<pre>
VU1 ==> EE ==> GS
As you can see, the biggest bottleneck for the ps4 is the emulated VU1,
therefore it's speedhacks will be the most effective for performance.
</pre>


====Debugging through PS4CHEATER====
= PS2 Bios =
<pre>
You can also use for instance the program PS4CHEATER and add the addresses of


1000000368 (Jakv2 uses this offset)
== Description ==
1000000360 (Emus with older revision use this one)


And change the type into > View as Hex.
The PS2 BIOS is the file '''PS20220WD20050620.crack''' included in every PS2 game .pkg. It is the same BIOS used by Sony in PS3's ps2_netemu.self. The lack of many X modules here means that homebrew compatibility is limited, as many of those need to be recompiled to use non X versions of modules, or need to load open source versions of them through MC/CDVD. An important non X module that is missing is LIBSD, therefore, homebrews that require it will likely fail to boot, or cause an error.
Make sure live cheats is on.
One of them will show the Current (Program counter) which will lead you to
find out which EE offset the game gets stuck on! or offsets that get repeated/cause performance problems
</pre>


=Faqs=
This PS2 BIOS is known to blacklist some titles, and refuse to boot them. This includes all titles with the 00000000 000000A0 flag, documented [[PS2_Emulation#Game_ID/DiscID in PS20220WD20050620.crack|here]].
<pre>A section dedicated to sharing knowledge about PS2 emulation in PS4</pre>
==Emulator's grammar==
'''This list was made since most of the emulator's Commands and /or Wiki instructions are hard to comprehend for most users.'''
<pre>
Insn = Instruction                          | lopnor = (Ps3 config) [It's unknown what lopnor stands for]
Addsub = Add / Subtract (MATH)              | CLI = Command line instruction (?)
muldiv = Multiply / Divide (MATH)          | Mem = Memory
opt = Optimize (?)  Option(?)              | Int = Integer (?)
jr = Jump register                          | cmd = Command
ad = Address (?)                            | XXXX-YYYYY = The ps2 game's region code
inst = Instant (?)                          | PC = Program counter
Scalar = A multiplier for the default value | Hook = Attach a function to an offset
r59 = EE                                    | ∞ = No limit for possible values (Int32)
r30 = IOP                                  | SPS = Spiky polygon syndrome (Another type of graphical glitches)
===============================================================================================================================
</pre>


==CLI==
'''More about the PS2 BIOS'''
'''Making a comment inside the CLI'''
<pre>
<pre>
1.You can make a comment inside a cli by using a Hashtag (#) at the start of the comment
The version of the PS2 BIOS seems to be the developement v2.20 from the Japanese region (22/01/2007), and is not limited to booting only NTSC-J games.
Example:
The PS2 emulator does not support USB peripherals, but this seems not to be a limitation of the BIOS, as it is used also in CECH C/E PS3 consoles.
#Speedup
There are signs that different PS2 BIOS versions exist, named PS20190AC20030623_nordram_miniOSD.bin. This PS2 BIOS has included handy extensions for debugging, and can debug print with "debug osd verbosity" from CLI set to "verbose". The most noticeable difference for both BIOS files seems to be the special RDRAM module.
--vu1-mpg-cycles=1000
 
2.Your comments will be fully ignored if they are in the same line as the hashtag
Example:
#This is a comment


Incorrect example:
Whilst the PS3 patches its PS2 BIOS to preferred regions, the PS4 uses a so called CallHook which is better known for PCSX2 users as fastboot. For more information about this patch, look at PCSX2's fastboot code. It is the same code except that PS2 emulators for PS4 do not have patches for different BIOS revisions.
#This is a comment
This is not a part of the comment and will crash the emu
 
 
3. hyphens are the start of a command in CLI (--)
And as for the equals, (=) everything that comes after it is the value that the command will use
 
On a lua hyphens (--) mean it is a comment, but on the cli it's the start of the command.
4. Commands cannot contain spaces
Example: --ee-cycle-scalar=0.1
 
Incorrect example: --ee cycle scalar = 0.1
</pre>
</pre>
'''Making a CLI.'''
<pre>
1. You can use any text editor to make a CLI
2. Each command has to be below the previous one and they cannot share the same line.


Correct CLI example:
'''PS2 BIOS file information:'''
--vu1-mpg-cycles=1000
--ee-cycle-scalar=1.1
 
Incorrect CLI example:
 
--vu1-mpg-cycles=1000 --ee-cycle-scalar=1.1
 
3. Your commands cannot contain spaces
4. Values start after the (=) sign
5. Commands can possibly contain multiple value entries and some values can be skipped by adding (,,).
Example: --ee-hook=0x0028A578,AdvanceClock,,1000
 
Unskipped value example: --ee-hook=0x0028A578,AdvanceClock,0x13a893bd,1000</pre>
 
==LUA==
'''Making a lua'''
<pre>
<pre>
When making a lua there is 1 part that is always necessary (Apirequest)
File name: PS20220WD20050620.crack
and 2 parts that are almost always necessary (Object) (Object's commands).
MD5: 83AD2B530C9C102A561BA1CDC6D996D5
By order it goes like this:
1. Apirequest
2. Object calling, gsobj/eeobj/iopobj, etc
3. the object's command
You cannot call an object without first requesting an api, as that will cause a crash.
and you most certainly cannot use an object's command without calling the object first
 
For instance you cannot use
iopObj.ReadMem32(0x400000)
 
Without first having this in your lua
local iopObj = getIOPObject()
</pre>
</pre>


'''Making a comment inside the lua'''
== Files inside ROM image ==
<pre>
You can make a comment in a lua by using two hyphens (--)
Your comments will be ignored by the lua


You can also use --[[ (comment) --]]
{| class="wikitable" style="font-size:small;"
All text between --[[ and --]] will be ignored by lua
! File !! Offset in exported bin !! Description !! File type (exportable)
 
|-
 
| RESET || 0x00 || Bootstrap code for the EE and IOP. || BIN
</pre>
|-
==Commands==
| ROMDIR || 0x2780 || The ROMDIR part of the ROM image, which provides information on the location and name of files contained in the image. || BIN
<br>'''(Cycle scalars)'''
|-
<pre>
| EXTINFO || 0x2CC0 || Contains the "EXTINFO" for all files in the ROM image. || BIN
Cycle scalar is basically a scale between overclock and cycle skip (Underclock), we say that to simplify
for anyone making configs, but in the truth it controls cycle speed of that Processor whether it be (IOP) or (SIF) or (EE).
 
Slowing the cycles can be done by setting it higher than 1.0 (Underclock) (Cycle skip)
Speeding up the cycles can be done by setting it anything lower than 1.0 (Overclock)
 
So, it's basically a multiplier of the Processor's cycle speed in a way that's connected to the Delta counter.
 
Sony uses all of them to improve sync, It's recommended to use them for sync also considering that using them can possibly
cause stuttering or input lag with no real benefit.
 
Except for eecyclescalar. as using it can be very helpful for performance gain
when you slow down the cycles (Anything higher than 1.0).
 
Some games like (Metal gear solid 3) want a very fast EE cycle speed,
and will refuse to work if it's at the Default speed.
 
(0.1) is the highest number for overclocking
And (1.0) is the Default clock value.
And (5.0) is the highest value for Underclocking (Cycle skipping) For the (IOP) and (EE)
 
As for the (SIF) it has no limit for underclocking.
</pre>
 
'''(vu1/0 mpg cycles)'''
<pre>
This command sets the cycle speed of vu1 or vu0.
0.1 is the fastest cycle speed and the most compatible (Slowest in terms of performance).
100 is the default value set by sony
1000 is the recommended value for performance gain but you can increase it to any value you like.
</pre>
 
==PS2 emulation related links==
*[https://github.com/Scalerize/PS2-tutorials-archive How to create general patches for PS2 games]
*[https://github.com/Scalerize/Ps2-assembly Knowledge about Assembly instructions in PS2]
*[https://forums.pcsx2.net/Thread-60-fps-codes Thread with 60 fps patches]
*[https://psi-rockin.github.io/ps2tek/ A great website for learning about PS2 hardware]
 
= PS2 Bios =
 
==Description==
 
The PS2 bios is the file '''PS20220WD20050620.crack''' included in every PS2 game .pkg. It Is '''exactly''' the same BIOS that Sony used in ps2_netemu.self in PS3. Due to lack of many X modules homebrew compatibility is limited, and many of those need to be recompiled to use non X versions of modules, or need to load open source versions of them thru mc/cdvd. Important non X module that is missing is libsd, and homebrew that need it, will most likely fail to boot, or error.
<br>Bios is know to blacklist some titles, and refuse to boot them. This include all titles with 00000000 000000A0 flag from that  [[PS2_Emulation#Game_ID/DiscID in PS20220WD20050620.crack | list (click here)]]
 
<br>'''More about the bios'''
<pre>
Bios version seems to be Developement v2.20 from Japan region (22/01/2007), but it's of course not limited to booting only NTSC-J games.
Emulator not support USB peripherals, but this seems to be not limitation of BIOS, as it is used also in CECH C/E PS3 consoles.
There are signs that different bios version exist, named PS20190AC20030623_nordram_miniOSD.bin. This bios have included handy extensions for debugging, and can debug print with "debug osd verbosity" from CLI set to "verbose". Most noticeable difference for both bios files seems to be special RDRAM module.
 
While PS3 emulators patch bios to preferred region, emulator used in PS4 use so called CallHook which is known better for pcsx2 users as fastboot. No need to describe patch here, just look at PCSX2 fastboot code. It's literally the same code, but PS4 emus don't have patches for different bios revisions.
</pre>
<br>'''Bios file information:'''
<pre>
File name: PS20220WD20050620.crack
MD5: 83AD2B530C9C102A561BA1CDC6D996D5
</pre>
 
==Files inside ROM image==
 
{| class="wikitable" style="font-size:small;"
! File !! Offset in exported bin !! Description !! File type (exportable)
|-
| RESET || 0x00 || Bootstrap code for the EE and IOP. || BIN
|-
| ROMDIR || 0x2780 || The ROMDIR part of the ROM image, which provides information on the location and name of files contained in the image. || BIN
|-
| EXTINFO || 0x2CC0 || Contains the "EXTINFO" for all files in the ROM image. || BIN
|-
|-
| SBIN || 0x3330 || Seems to be the pad controller library for the PS1 monitor. || BIN
| SBIN || 0x3330 || Seems to be the pad controller library for the PS1 monitor. || BIN
Line 2,894: Line 2,714:
| KERNEL || 0x1BB7E0 || The EE kernel || BIN
| KERNEL || 0x1BB7E0 || The EE kernel || BIN
|}
|}
Description source: https://gist.github.com/uyjulian/25291080f083987d3f3c134f593483c5
Description source: https://gist.github.com/uyjulian/25291080f083987d3f3c134f593483c5


== Game_ID/DiscID in PS20220WD20050620.crack ==
== Game_ID/DiscID in PS20220WD20050620.crack ==


<pre>There are 193 titleIDs listed inside XPARAM2.ELF file of PS2 Bios included in PS20220WD20050620.crack. XPARAM2.ELF is called by OSDSYS, then ID check is performed. If titleID match to one of included in the table, different IOP emulation settings are applied. This include blacklisting for some specific titles.  
<pre>There are 193 titleIDs listed inside XPARAM2.ELF file of PS2 BIOS included in PS20220WD20050620.crack. XPARAM2.ELF is called by OSDSYS, then ID check is performed. If titleID match to one of included in the table, different IOP emulation settings are applied. This include blacklisting for some specific titles.  


Original PS2 bios from models with emulated IOP, include similar list file called XPARAM.ELF. Title IDs there are not the same, although some of them exist on both lists.</pre>
The original PS2 BIOS from models with emulated IOP, include a similar list file called XPARAM.ELF. The Title IDs there are not the same, although some of them exist on both lists.</pre>


{| class="wikitable sortable" ||  
{| class="wikitable sortable" ||  
|-  
|-  
! Command !! Name !! Fix on ps4 / Explanation
! Command !! Name
|-
|-
| 0x00 || TITLE_MASK || Black-listed games if 0xA0000000 value
| 0x00 || TITLE_MASK  
|-
|-
| 0x01 || SIO2_MASK ||
| 0x01 || SIO2_MASK  
|-
|-
| 0x02 || DEV9_MASK || Emulates dummy ethernet connection
| 0x02 || DEV9_MASK
|-
|-
| 0x03 || USB_MASK ||
| 0x03 || USB_MASK  
|-
|-
| 0x04 || SIF_DMA_SYNC ||
| 0x04 || SIF_DMA_SYNC  
|-
|-
| 0x05 || SIF_DMA_LOAD ||
| 0x05 || SIF_DMA_LOAD  
|-
|-
| 0x06 || DMAC_CH10_INT_DELAY ||
| 0x06 || DMAC_CH10_INT_DELAY
|-
|-
| 0x07 || MECHA_RECOGTIME ||
| 0x07 || MECHA_RECOGTIME
|-
|-
| 0x08 || CPU_DELAY ||<pre> Most likely requires
| 0x08 || CPU_DELAY  
different IOP clock speed 
--iop-cycle-scalar=0.1 </pre>
|-
|-
| 0x09 || DEV5_INT_SPEED ||
| 0x09 || DEV5_INT_SPEED  
|-
|-
| 0x0A || CDVD_READ_DELAY || <pre> CDVD commands</pre>
| 0x0A || CDVD_READ_DELAY
|-
|-
| 0x0B || SPU2_BEHAVIOR ||
| 0x0B || SPU2_BEHAVIOR
|-
|-
|}
|}
Line 3,431: Line 3,250:
└── trophy_data
└── trophy_data
     └── SLES-50326_trophies.lua
     └── SLES-50326_trophies.lua
</pre>


= LUA include files =
<pre>
Files that some official PS2 Classics PKG files use in order for the lua files to be separate.
</pre>
</pre>
=LUA include files=
 
<pre>Files that the lua sometimes need to be inside of the lua_include folder
'''pad-connect-type.lua'''
</pre>
<br>'''ee-cpr0-alias.lua'''
<pre>
<pre>
cpr = {}
local PadConnectType = {}


cpr.index = 0
PadConnectType.DS4 = 0
cpr.random = 1
PadConnectType.HID              = 1 -- any 3rd party USB controller (fight stick, turbo controller, etc), always local.
cpr.entrylo0 = 2
PadConnectType.REMOTE_DS4      = 2 -- remote DS4 should behave just like regular DS4
cpr.entrylo1 = 3
PadConnectType.REMOTE_VITA      = 3 -- remote VITA lacks analog L2/R2
cpr.context = 4
cpr.pagemask = 5
cpr.wired = 6
cpr.badvaddr = 8
cpr.count = 9
cpr.entryhi = 10
cpr.compare = 11
cpr.status = 12
cpr.cause = 13
cpr.epc = 14
cpr.prid = 15
cpr.config = 16
cpr.badpaddr = 23
cpr.hwbk = 24
cpr.pccr = 25
cpr.taglo = 28
cpr.taghi = 29
cpr.errorepc = 30


return cpr
return PadConnectType
</pre>
</pre>
'''ee-gpr-alias.lua'''
 
'''sprite.lua'''
<pre>
<pre>
local kFilterMode = {}
kFilterMode.Point                          = 0x00000000 -- < Sample the one texel nearest to the sample point.
kFilterMode.Bilinear                        = 0x00000001 -- < Sample the four texels nearest the sample point, and blend linearly.
local kWrapMode = {}
kWrapMode.Wrap                              = 0x00000000 -- < The integer portion of the input coordinate is discarded, and the fractional portion is used instead. <c>U=U-floorf(U);</c>
kWrapMode.Mirror                            = 0x00000001 -- < The input coordinate is "reflected" across the texture boundary. This reflection may occur multiple times until the coordinate falls within the <c>[0..1]</c> range. <c>U=isOdd(floorf(U)) ? 1-fracf(U) : fracf(U)</c>
kWrapMode.ClampLastTexel                    = 0x00000002 -- < The input coordinate is clamped to the range <c>[0..1]</c>. <c>U=max(0,min(1,U));</c>
kWrapMode.MirrorOnceLastTexel              = 0x00000003 -- < The input coordinate is reflected at most one time and then clamped to the range <c>[0..1]</c>. <c>U=abs(max(-1,min(1,U));</c>
kWrapMode.ClampHalfBorder                  = 0x00000004 -- < Similar to kWrapModeClampLastTexel, but if clamping is necessary, the output color will be the border color specified by the Sampler. For this mode, coordinates that are not within half a pixel of the border are considered clamped.
kWrapMode.MirrorOnceHalfBorder              = 0x00000005 -- < Similar to kWrapModeMirrorOnceLastTexel, but if clamping is necessary, the output color will be the border color specified by the Sampler. For this mode, coordinates that are not within half a pixel of the border are considered clamped.
kWrapMode.ClampBorder                      = 0x00000006 -- < Similar to kWrapModeClampLastTexel, but if clamping is necessary, the output color will be the border color specified by the Sampler. For this mode, coordinates that are outside the range <c>[0..1]</c> are considered clamped.
kWrapMode.MirrorOnceBorder                  = 0x00000007 -- < Similar to kWrapModeMirrorOnceLastTexel, but if clamping is necessary, the output color will be the border color specified by the Sampler. For this mode, coordinates that are outside the range <c>[0..1]</c> are considered clamped.
local kBlendMultiplier = {}
kBlendMultiplier.Zero                            = 0x00000000  -- < Multiply the associated input by zero.
kBlendMultiplier.One                              = 0x00000001  -- < Multiply the associated input by one.
kBlendMultiplier.SrcColor                        = 0x00000002  -- < Multiply the associated input by the fragment color.
kBlendMultiplier.OneMinusSrcColor                = 0x00000003  -- < Multiply the associated input by one minus the fragment color.
kBlendMultiplier.SrcAlpha                        = 0x00000004  -- < Multiply the associated input by the fragment alpha.
kBlendMultiplier.OneMinusSrcAlpha                = 0x00000005  -- < Multiply the associated input by one minus the fragment alpha.
kBlendMultiplier.DestAlpha                        = 0x00000006  -- < Multiply the associated input by the render target alpha.
kBlendMultiplier.OneMinusDestAlpha                = 0x00000007  -- < Multiply the associated input by one minus the render target alpha.
kBlendMultiplier.DestColor                        = 0x00000008  -- < Multiply the associated input by the render target color.
kBlendMultiplier.OneMinusDestColor                = 0x00000009  -- < Multiply the associated input by one minus the render target color.
kBlendMultiplier.SrcAlphaSaturate                = 0x0000000a  -- < Multiply the associated input by the minimum of 1 or fragment alpha.
kBlendMultiplier.ConstantColor                    = 0x0000000d  -- < Multiply the associated input by the constant color. @see DrawCommandBuffer::setBlendColor()
kBlendMultiplier.OneMinusConstantColor            = 0x0000000e  -- < Multiply the associated input by one minus the constant color. @see DrawCommandBuffer::setBlendColor()
kBlendMultiplier.Src1Color                        = 0x0000000f  -- < Multiply the associated input by a secondary fragment color.
kBlendMultiplier.InverseSrc1Color                = 0x00000010  -- < Multiply the associated input by one minus a secondary fragment color.
kBlendMultiplier.Src1Alpha                        = 0x00000011  -- < Multiply the associated input by a secondary fragment alpha.
kBlendMultiplier.InverseSrc1Alpha                = 0x00000012  -- < Multiply the associated input by one minus a secondary fragment alpha.
kBlendMultiplier.ConstantAlpha                    = 0x00000013  -- < Multiply the associated input by the constant color alpha. @see DrawCommandBuffer::setBlendColor()
kBlendMultiplier.OneMinusConstantAlpha            = 0x00000014  -- < Multiply the associated input by one minus the constant color alpha. @see DrawCommandBuffer::setBlendColor()


-- Recommended method to import this module:
local kBlendFunc = {}
--  local gpr = require("ee-gpr-alias")
kBlendFunc.Add                          = 0x00000000  -- < The source value is added to the destination value.
--  
kBlendFunc.Subtract                    = 0x00000001  -- < The destination value is subtracted from the source value.
-- Using the global 'lang' variable is depreciatedThis will change to a local-scope variable after
kBlendFunc.Min                          = 0x00000002  -- < The minimum of the source and destination values is selected.
-- the depreciation period has expired in April 2016.
kBlendFunc.Max                          = 0x00000003  -- < The maximum of the source and destination values is selected.
kBlendFunc.ReverseSubtract              = 0x00000004 -- < The source value is subtracted from the destination value.


gpr = {}
-- Default blending mode, ideal for typical alpha channel embedded into a PNG image.
blendDefaultEquation = {
kBlendMultiplier.SrcAlpha, -- src multiplier
kBlendFunc.Add,                         -- blend function
kBlendMultiplier.OneMinusSrcAlpha,     -- dest multiplier
}


gpr.zero = 0
blendConstFadeEquation = {
gpr.at  = 1
kBlendMultiplier.ConstantAlpha, -- src multiplier
gpr.v0  = 2
kBlendFunc.Add,                       -- blend function
gpr.v1  = 3
kBlendMultiplier.OneMinusConstantAlpha,     -- dest multiplier
gpr.a0  = 4
}
gpr.a1  = 5
gpr.a2  = 6
gpr.a3  = 7
gpr.t0  = 8
gpr.t1  = 9
gpr.t2  = 10
gpr.t3  = 11
gpr.t4  = 12
gpr.t5  = 13
gpr.t6  = 14
gpr.t7  = 15
gpr.s0  = 16
gpr.s1  = 17
gpr.s2  = 18
gpr.s3  = 19
gpr.s4  = 20
gpr.s5  = 21
gpr.s6  = 22
gpr.s7  = 23
gpr.t8  = 24
gpr.t9  = 25
gpr.k0  = 26
gpr.k1  = 27
gpr.gp  = 28
gpr.sp  = 29
gpr.fp  = 30
gpr.ra  = 31


return gpr
return kFilterMode, kWrapMode, kBlendMultiplier, kBlendFunc
</pre>


</pre>
'''MipsInsn.lua'''
'''ee-hwaddr.lua'''
<pre>
<pre>
gif_hw  = {}
MipsInsn = {}
vif0_hw = {}
MipsInsn.IsAddi = function(insn) return (insn & 0xfc000000) == 0x20000000 end -- addi rt,rs,simm
vif1_hw = {}
MipsInsn.IsAddiu = function(insn) return (insn & 0xfc000000) == 0x24000000 end -- addiu rt,rs,simm
MipsInsn.IsDaddu = function(insn) return (insn & 0xfc0007ff) == 0x0000002d end -- daddu rd,rs,rt
MipsInsn.IsAddu = function(insn) return (insn & 0xfc0007ff) == 0x00000021 end -- addu rd,rs,rt
MipsInsn.IsBeq = function(insn) return (insn & 0xfc000000) == 0x10000000 end -- beq rs,rt,off
MipsInsn.IsJ = function(insn) return (insn & 0xfc000000) == 0x08000000 end -- j target
MipsInsn.IsJal = function(insn) return (insn & 0xfc000000) == 0x0c000000 end -- jal target
MipsInsn.IsJr = function(insn) return (insn & 0xfc1fffff) == 0x00000008 end -- jr rs
MipsInsn.IsLq = function(insn) return (insn & 0xfc000000) == 0x78000000 end -- lq rt,simm(rs)
MipsInsn.IsLd = function(insn) return (insn & 0xfc000000) == 0xdc000000 end -- ld rt,simm(rs)
MipsInsn.IsLw = function(insn) return (insn & 0xfc000000) == 0x8c000000 end -- lw rt,simm(rs)
MipsInsn.IsSq = function(insn) return (insn & 0xfc000000) == 0x7c000000 end -- sq rt,simm(rs)
MipsInsn.IsSd = function(insn) return (insn & 0xfc000000) == 0xfc000000 end -- sd rt,simm(rs)
MipsInsn.IsSw = function(insn) return (insn & 0xfc000000) == 0xac000000 end -- sw rt,simm(rs)
MipsInsn.IsEnd = function(insn) return (insn & 0xfc00003f) == 0x0000000d end -- break [code]


gif_hw.CHCR = 0x1000A000
MipsInsn.GetRt = function(insn) return (insn >> 16) & 0x1f end
gif_hw.MADR = 0x1000A010
MipsInsn.GetRs = function(insn) return (insn >> 21) & 0x1f end
gif_hw.QWC = 0x1000A020
MipsInsn.GetRd = function(insn) return (insn >> 11) & 0x1f end
gif_hw.TADR = 0x1000A030
--MipsInsn.GetSimm = function(insn) return ((insn << 48) >> 48) end -- this can't create a negative value correctly
gif_hw.ASR0 = 0x1000A040
MipsInsn.GetSimm = function(insn)
gif_hw.ASR1 = 0x1000A050
  -- Lua5.3 shifts are all logical (WHY!?). threfore (insn<<48)>>48 cannot extend the sign.
gif_hw.SADR = 0x1000A080
  -- Instead of using shift, do following
  local bit = 16 -- sign bit place.
  local v = insn & 0xffff
  local m = 1 << (bit - 1)
  v = v & ((1 << bit) - 1)
  return (v ~ m) - m -- '~' is xor in Lua... how strange it is.
end
MipsInsn.GetOff = function(insn) return MipsInsn.GetSimm(insn) end
MipsInsn.GetTarget = function(insn) return insn & 0x3ffffff end


vif0_hw.CHCR = 0x10008000
return MipsInsn
vif0_hw.MADR = 0x10008010
</pre>
vif0_hw.QWC = 0x10008020
vif0_hw.TADR = 0x10008030
vif0_hw.ASR0 = 0x10008040
vif0_hw.ASR1 = 0x10008050
vif0_hw.SADR = 0x10008080


vif1_hw.CHCR = 0x10009000
'''ee-cpr0-alias.lua'''
vif1_hw.MADR = 0x10009010
<pre>
vif1_hw.QWC = 0x10009020
cpr = {}
vif1_hw.TADR = 0x10009030
 
vif1_hw.ASR0 = 0x10009040
cpr.index = 0
vif1_hw.ASR1 = 0x10009050
cpr.random = 1
vif1_hw.SADR = 0x10009080
cpr.entrylo0 = 2
cpr.entrylo1 = 3
cpr.context = 4
cpr.pagemask = 5
cpr.wired = 6
cpr.badvaddr = 8
cpr.count = 9
cpr.entryhi = 10
cpr.compare = 11
cpr.status = 12
cpr.cause = 13
cpr.epc = 14
cpr.prid = 15
cpr.config = 16
cpr.badpaddr = 23
cpr.hwbk = 24
cpr.pccr = 25
cpr.taglo = 28
cpr.taghi = 29
cpr.errorepc = 30


return gif_hw, vif0_hw, vif1_hw, nil
return cpr
</pre>
</pre>
'''language.lua'''
 
'''ee-gpr-alias.lua'''
<pre>
<pre>
-- Recommended method to import this module:
-- Recommended method to import this module:
--  local lang = require("language")
--  local gpr = require("ee-gpr-alias")
--  
--  
-- Using the global 'lang' variable is depreciated.  This will change to a local-scope variable after
-- Using the global 'lang' variable is depreciated.  This will change to a local-scope variable after
-- the depreciation period has expired in April 2016.
-- the depreciation period has expired in April 2016.


lang = {}
gpr = {}


lang.japanese = 0
gpr.zero = 0
lang.english = 1
gpr.at  = 1
lang.french = 2
gpr.v0  = 2
lang.spanish = 3
gpr.v1  = 3
lang.german = 4
gpr.a0  = 4
lang.italian = 5
gpr.a1  = 5
lang.dutch = 6
gpr.a2  = 6
lang.portuguese = 7
gpr.a3  = 7
lang.russian = 8
gpr.t0  = 8
lang.korean = 9
gpr.t1  = 9
lang.chinese_traditional = 10
gpr.t2  = 10
lang.chinese_simplified = 11
gpr.t3  = 11
lang.finnish = 12
gpr.t4  = 12
lang.swedish = 13
gpr.t5  = 13
lang.danish = 14
gpr.t6  = 14
lang.norwegian = 15
gpr.t7  = 15
lang.polish = 16
gpr.s0  = 16
lang.portuguese_brazil = 17
gpr.s1  = 17
lang.english_gb = 18
gpr.s2  = 18
lang.turkish = 19
gpr.s3  = 19
lang.spanish_la = 20
gpr.s4  = 20
lang.arabic = 21
gpr.s5  = 21
lang.french_canada = 22
gpr.s6  = 22
gpr.s7  = 23
gpr.t8  = 24
gpr.t9  = 25
gpr.k0  = 26
gpr.k1  = 27
gpr.gp  = 28
gpr.sp  = 29
gpr.fp  = 30
gpr.ra  = 31


return lang
return gpr
</pre>
</pre>
'''pad-and-key.lua'''
 
'''ee-hwaddr.lua'''
<pre>
<pre>
gif_hw  = {}
vif0_hw = {}
vif1_hw = {}


pad = {}
gif_hw.CHCR = 0x1000A000
gif_hw.MADR = 0x1000A010
gif_hw.QWC = 0x1000A020
gif_hw.TADR = 0x1000A030
gif_hw.ASR0 = 0x1000A040
gif_hw.ASR1 = 0x1000A050
gif_hw.SADR = 0x1000A080


-- Left Side
vif0_hw.CHCR = 0x10008000
pad.LU = 0x0010 -- Up
vif0_hw.MADR = 0x10008010
pad.LD = 0x0040 -- Down
vif0_hw.QWC = 0x10008020
pad.LL = 0x0080 -- Left
vif0_hw.TADR = 0x10008030
pad.LR = 0x0020 -- Right
vif0_hw.ASR0 = 0x10008040
vif0_hw.ASR1 = 0x10008050
vif0_hw.SADR = 0x10008080


-- Right Side
vif1_hw.CHCR = 0x10009000
pad.RU = 0x1000 -- Up (Triangle)
vif1_hw.MADR = 0x10009010
pad.RD = 0x4000 -- Down (Cross)
vif1_hw.QWC = 0x10009020
pad.RL = 0x8000 -- Left (Square)
vif1_hw.TADR = 0x10009030
pad.RR = 0x2000 -- Right (Circle)
vif1_hw.ASR0 = 0x10009040
vif1_hw.ASR1 = 0x10009050
vif1_hw.SADR = 0x10009080


-- aliases
return gif_hw, vif0_hw, vif1_hw, nil
pad.UP = 0x0010 -- LU
</pre>
pad.DOWN = 0x0040 -- LD
pad.LEFT = 0x0080 -- LL
pad.RIGHT = 0x0020 -- LR
pad.TRIANGLE= 0x1000
pad.CROSS = 0x4000
pad.SQUARE = 0x8000
pad.CIRCLE = 0x2000


pad.L1 = 0x0400
'''language.lua'''
pad.L2 = 0x0100
<pre>
pad.L3 = 0x0002
-- Recommended method to import this module:
--  local lang = require("language")
--
-- Using the global 'lang' variable is depreciated. This will change to a local-scope variable after
-- the depreciation period has expired in April 2016.


pad.R1 = 0x0800
lang = {}
pad.R2 = 0x0200
pad.R3 = 0x0004


pad.SELECT = 0x0001
lang.japanese = 0
pad.START = 0x0008
lang.english = 1
lang.french = 2
lang.spanish = 3
lang.german = 4
lang.italian = 5
lang.dutch = 6
lang.portuguese = 7
lang.russian = 8
lang.korean = 9
lang.chinese_traditional = 10
lang.chinese_simplified = 11
lang.finnish = 12
lang.swedish = 13
lang.danish = 14
lang.norwegian = 15
lang.polish = 16
lang.portuguese_brazil = 17
lang.english_gb = 18
lang.turkish = 19
lang.spanish_la = 20
lang.arabic = 21
lang.french_canada = 22


keyboard = {}
return lang
</pre>


keyboard.ESCAPE = 0x1000
'''pad-and-key.lua'''
keyboard.SLASH = 0x1001
keyboard.SEPARATOR = 0x1002 -- backslash or pipe (\|)
keyboard.BACKQUOTE = 0x1003
keyboard.PAGEDOWN = 0x1004
keyboard.PAGEUP = 0x1005
keyboard.F1 = 0x1006
keyboard.F2 = 0x1007
keyboard.F3 = 0x1008
keyboard.F4 = 0x1009
keyboard.F5 = 0x100a
keyboard.F6 = 0x100b
keyboard.F7 = 0x100c
keyboard.F8 = 0x100d
keyboard.F9 = 0x100e
keyboard.F10 = 0x100f
keyboard.F11 = 0x1010
keyboard.F12 = 0x1011
</pre>
'''ps2.lua'''
<pre>
<pre>
pad = {}


require("ee-gpr-alias")
-- Left Side
require("utils")
pad.LU = 0x0010 -- Up
pad.LD = 0x0040 -- Down
pad.LL = 0x0080 -- Left
pad.LR = 0x0020 -- Right


MipsInsn = {}
-- Right Side
MipsInsn.IsAddi = function(insn) return (insn & 0xfc000000) == 0x20000000 end -- addi rt,rs,simm
pad.RU = 0x1000 -- Up (Triangle)
MipsInsn.IsAddiu = function(insn) return (insn & 0xfc000000) == 0x24000000 end -- addiu rt,rs,simm
pad.RD = 0x4000 -- Down (Cross)
MipsInsn.IsBeq = function(insn) return (insn & 0xfc000000) == 0x10000000 end -- beq rs,rt,off
pad.RL = 0x8000 -- Left (Square)
MipsInsn.IsJ = function(insn) return (insn & 0xfc000000) == 0x08000000 end -- j target
pad.RR = 0x2000 -- Right (Circle)
MipsInsn.IsJal = function(insn) return (insn & 0xfc000000) == 0x0c000000 end -- jal target
 
MipsInsn.IsJr = function(insn) return (insn & 0xfc1fffff) == 0x00000008 end -- jr rs
-- aliases
MipsInsn.IsLq = function(insn) return (insn & 0xfc000000) == 0x78000000 end -- lq rt,simm(rs)
pad.UP = 0x0010 -- LU
MipsInsn.IsLd = function(insn) return (insn & 0xfc000000) == 0xdc000000 end -- ld rt,simm(rs)
pad.DOWN = 0x0040 -- LD
MipsInsn.IsLw = function(insn) return (insn & 0xfc000000) == 0x8c000000 end -- lw rt,simm(rs)
pad.LEFT = 0x0080 -- LL
MipsInsn.IsSq = function(insn) return (insn & 0xfc000000) == 0x7c000000 end -- sq rt,simm(rs)
pad.RIGHT = 0x0020 -- LR
MipsInsn.IsSd = function(insn) return (insn & 0xfc000000) == 0xfc000000 end -- sd rt,simm(rs)
pad.TRIANGLE= 0x1000
MipsInsn.IsSw = function(insn) return (insn & 0xfc000000) == 0xac000000 end -- sw rt,simm(rs)
pad.CROSS = 0x4000
MipsInsn.IsEnd = function(insn) return (insn & 0xfc00003f) == 0x0000000d end
pad.SQUARE = 0x8000
pad.CIRCLE = 0x2000


MipsInsn.GetRt = function(insn) return (insn >> 16) & 0x1f end
pad.L1 = 0x0400
MipsInsn.GetRs = function(insn) return (insn >> 21) & 0x1f end
pad.L2 = 0x0100
MipsInsn.GetSimm = function(insn) return ((insn << 48) >> 48) end
pad.L3 = 0x0002
MipsInsn.GetOff = function(insn) return MipsInsn.GetSimm(insn) end
MipsInsn.GetTarget = function(insn) return insn & 0x3ffffff end


-- return FIFO queue of stack trace
pad.R1 = 0x0800
-- the queue item is { caller-addr, return-from }
pad.R2 = 0x0200
--
pad.R3 = 0x0004
-- example:
--    print("=== stack trace ===")
--   local stack_trace = MipsStackTrace(eeObj, eeObj.GetPc()+4, eeObj.GetGpr(gpr.ra), eeObj.GetGpr(gpr.sp))
--   while not stack_trace:isEmpty() do
-- local caller = stack_trace:dequeue()
-- print( string.format(" 0x%08x [will return from : %x]", caller[1], caller[2]) )
--   end
--
-- NOTE: you must +4 against GetPc() if you in a EE/IOP hook.
-- Because EE/IOP jit executed the instruction at the address already and it might affect $sp or $ra.
--
-- obj : eeObj or iopObj
-- pc  : current pc (from GetPC or readout from thread context)
-- ra  : current ra (from GetGpr or readout from thread context)
-- sp  : current sp (from GetGpr or readout from thread context)
MipsStackTrace = function (obj, pc, ra, sp, depth)
  local max_depth = depth or 10 -- max trace depth
  local n_j = 1
  local jmax = {}
  local depth = 0
  local bdl_count = 0
  local new_pc    = 0
  local icount    = 0


  local result = Queue.new()
pad.SELECT = 0x0001
  local pushed_ra = Queue.new()
pad.START = 0x0008
  while depth < max_depth and icount < 2048 do
  -- TODO: error checks
  if (pc & 3) ~= 0 then
return result
  end
  pc = pc & 0x01ffffff
  sp = sp & 0x01ffffff
  local insn = obj.ReadMem32(pc)
  -- print(string.format("trace .. pc=%x insn=%x", pc, insn))
  -- result:enqueue( { pc, insn } )


  if MipsInsn.IsJr(insn) and MipsInsn.GetRs(insn) == gpr.ra then
keyboard = {}
bdl_count = 1
 
depth = depth + 1
keyboard.ESCAPE = 0x1000
new_pc = ra
keyboard.SLASH = 0x1001
-- print(string.format("jr ra : ra=%x", ra))
keyboard.SEPARATOR = 0x1002 -- backslash or pipe (\|)
icount = 0
keyboard.BACKQUOTE = 0x1003
-- print(string.format("enqueue caller pc=%x ret addr=%x", new_pc-8, pc))
keyboard.PAGEDOWN = 0x1004
result:enqueue( {new_pc-8, pc} ) -- {return-addr, where-from}
keyboard.PAGEUP = 0x1005
  elseif MipsInsn.IsAddiu(insn) and MipsInsn.GetRt(insn) == gpr.sp and MipsInsn.GetRs(insn) == gpr.sp then
keyboard.F1 = 0x1006
sp = sp + MipsInsn.GetSimm(insn) -- ((insn<<48) >>48)
keyboard.F2 = 0x1007
-- print(string.format("addiu sp,sp,** : new sp = %x", sp))
keyboard.F3 = 0x1008
  elseif MipsInsn.IsLq(insn) or MipsInsn.IsLd(insn) or MipsInsn.IsLw(insn) then
keyboard.F4 = 0x1009
if MipsInsn.GetRt(insn) == gpr.ra and MipsInsn.GetRs(insn) == gpr.sp then
keyboard.F5 = 0x100a
-- the code might push $ra on the stack after start pc.
keyboard.F6 = 0x100b
-- in such case, we must not retrieve $ra value from the memory.
keyboard.F7 = 0x100c
if pushed_ra:isEmpty() then
keyboard.F8 = 0x100d
  local imm = MipsInsn.GetSimm(insn) -- ((insn<<48) >>48)
keyboard.F9 = 0x100e
  -- print(string.format("retrieve ra from stack(%x) : sp=%x imm=%x", sp+imm, sp, imm))
keyboard.F10 = 0x100f
  ra = obj.ReadMem32(sp + imm)
keyboard.F11 = 0x1010
  -- print(string.format("load ra,%x(sp) : sp = %x+%x, ra = %x", imm, sp, imm, ra))
keyboard.F12 = 0x1011
else
</pre>
  -- print(string.format("retrieve ra from pushed one"))
  pushed_ra:dequeue()
end
end
  elseif MipsInsn.IsSq(insn) or MipsInsn.IsSd(insn) or MipsInsn.IsSw(insn) then
if MipsInsn.GetRt(insn) == gpr.ra and MipsInsn.GetRs(insn) == gpr.sp then
pushed_ra:enqueue(pc);
end
  elseif MipsInsn.IsJ(insn) then -- j **
local imm = MipsInsn.GetTarget(insn)
imm = imm << 2
if pc == imm then
-- jump to self? maybe we can ignore it.
else
new_pc = imm
-- print(string.format("j ** : new_pc = %x", new_pc))
bdl_count = 1
for t=1, n_j do
  if jmax[t] == new_pc then
  return result -- closed loop
  end
end
if n_j > 1024 then
  return result -- jump buffer overflow
end
jmax[n_j] = new_pc
n_j = n_j + 1
end
  elseif MipsInsn.IsBeq(insn) and MipsInsn.GetRs(insn) == gpr.zero then -- beq zero,**
local offset = MipsInsn.GetOff(insn) -- ((insn<<48) >> 48)
offset = offset << 2
new_pc = pc + 4 + offset


if pc == new_pc then
'''ps2.lua'''
-- jump to self? maybe we can ignore it
<pre>
else
require("ee-gpr-alias")
-- print(string.format("beq zero,** : new_pc=%x", new_pc))
require("utils")
bdl_count = 1
for t = 1, n_j do
  if jmax[t] == new_pc then
  return result
  end
end
if n_j > 1024 then
  return result
end
jmax[n_j] = new_pc
n_j = n_j + 1
end
  elseif MipsInsn.IsEnd(insn) then -- end
-- print(string.format("end"))
return result
  elseif MipsInsn.IsJal(insn) then -- jal **
local imm = insn & 0x03ffffff
imm = imm << 2
-- print(string.format("jal ** : addr = %x", imm))
-- call
  end


  icount = icount + 1
MipsInsn = {}
  pc = pc + 4
MipsInsn.IsAddi = function(insn) return (insn & 0xfc000000) == 0x20000000 end -- addi rt,rs,simm
 
MipsInsn.IsAddiu = function(insn) return (insn & 0xfc000000) == 0x24000000 end -- addiu rt,rs,simm
  -- -- print(string.format("bdl_count=%d", bdl_count))
MipsInsn.IsBeq = function(insn) return (insn & 0xfc000000) == 0x10000000 end -- beq rs,rt,off
  if bdl_count > 0 then
MipsInsn.IsJ = function(insn) return (insn & 0xfc000000) == 0x08000000 end -- j target
if bdl_count == 2 then
MipsInsn.IsJal = function(insn) return (insn & 0xfc000000) == 0x0c000000 end -- jal target
pc = new_pc
MipsInsn.IsJr = function(insn) return (insn & 0xfc1fffff) == 0x00000008 end -- jr rs
bdl_count = 0
MipsInsn.IsLq = function(insn) return (insn & 0xfc000000) == 0x78000000 end -- lq rt,simm(rs)
else
MipsInsn.IsLd = function(insn) return (insn & 0xfc000000) == 0xdc000000 end -- ld rt,simm(rs)
bdl_count = bdl_count + 1
MipsInsn.IsLw = function(insn) return (insn & 0xfc000000) == 0x8c000000 end -- lw rt,simm(rs)
end
MipsInsn.IsSq = function(insn) return (insn & 0xfc000000) == 0x7c000000 end -- sq rt,simm(rs)
  end
MipsInsn.IsSd = function(insn) return (insn & 0xfc000000) == 0xfc000000 end -- sd rt,simm(rs)
  end
MipsInsn.IsSw = function(insn) return (insn & 0xfc000000) == 0xac000000 end -- sw rt,simm(rs)
  return result
MipsInsn.IsEnd = function(insn) return (insn & 0xfc00003f) == 0x0000000d end
end
 
MipsInsn.GetRt = function(insn) return (insn >> 16) & 0x1f end
MipsInsn.GetRs = function(insn) return (insn >> 21) & 0x1f end
MipsInsn.GetSimm = function(insn) return ((insn << 48) >> 48) end
MipsInsn.GetOff = function(insn) return MipsInsn.GetSimm(insn) end
MipsInsn.GetTarget = function(insn) return insn & 0x3ffffff end


PS2 = {}
-- return FIFO queue of stack trace
PS2.GetCurrentThread = function(eeObj) return eeObj.ReadMem32(0x12fac) end
-- the queue item is { caller-addr, return-from }
PS2.GetThreads = function(eeObj)
--
   local EE_THREAD_BASE = 0x18000
-- example:
   local EE_NUM_THREADS = 0x100
--    print("=== stack trace ===")
   local th = EE_THREAD_BASE
--   local stack_trace = MipsStackTrace(eeObj, eeObj.GetPc()+4, eeObj.GetGpr(gpr.ra), eeObj.GetGpr(gpr.sp))
   local result = Queue.new()
--   while not stack_trace:isEmpty() do
   for t = 0, EE_NUM_THREADS-1 do
-- local caller = stack_trace:dequeue()
  -- 0 : node_prev
-- print( string.format(" 0x%08x [will return from : %x]", caller[1], caller[2]) )
  -- 4 : node_next
--   end
  -- 8 : status
--
  -- 12: pc
-- NOTE: you must +4 against GetPc() if you in a EE/IOP hook.
  -- 16: sp
-- Because EE/IOP jit executed the instruction at the address already and it might affect $sp or $ra.
  -- 20: gp
--
  -- 24: init_pri
-- obj : eeObj or iopObj
  -- 26: curr_pri
-- pc  : current pc (from GetPC or readout from thread context)
  -- 28: wstat
-- ra  : current ra (from GetGpr or readout from thread context)
  -- 32: waitId
-- sp  : current sp (from GetGpr or readout from thread context)
  -- 36: wakeupCount
MipsStackTrace = function (obj, pc, ra, sp, depth)
  -- 40: attr
  local max_depth = depth or 10 -- max trace depth
  -- 44: option
  local n_j = 1
  -- 48: func
  local jmax = {}
  -- 52: argc
  local depth = 0
  -- 56: args
  local bdl_count = 0
  -- 60: stack
  local new_pc    = 0
  local icount    = 0
 
  local result = Queue.new()
  local pushed_ra = Queue.new()
  while depth < max_depth and icount < 2048 do
  -- TODO: error checks
  if (pc & 3) ~= 0 then
return result
  end
  pc = pc & 0x01ffffff
  sp = sp & 0x01ffffff
  local insn = obj.ReadMem32(pc)
  -- print(string.format("trace .. pc=%x insn=%x", pc, insn))
  -- result:enqueue( { pc, insn } )
 
  if MipsInsn.IsJr(insn) and MipsInsn.GetRs(insn) == gpr.ra then
bdl_count = 1
depth = depth + 1
new_pc = ra
-- print(string.format("jr ra : ra=%x", ra))
icount = 0
-- print(string.format("enqueue caller pc=%x ret addr=%x", new_pc-8, pc))
result:enqueue( {new_pc-8, pc} ) -- {return-addr, where-from}
  elseif MipsInsn.IsAddiu(insn) and MipsInsn.GetRt(insn) == gpr.sp and MipsInsn.GetRs(insn) == gpr.sp then
sp = sp + MipsInsn.GetSimm(insn) -- ((insn<<48) >>48)
-- print(string.format("addiu sp,sp,** : new sp = %x", sp))
  elseif MipsInsn.IsLq(insn) or MipsInsn.IsLd(insn) or MipsInsn.IsLw(insn) then
if MipsInsn.GetRt(insn) == gpr.ra and MipsInsn.GetRs(insn) == gpr.sp then
-- the code might push $ra on the stack after start pc.
-- in such case, we must not retrieve $ra value from the memory.
if pushed_ra:isEmpty() then
  local imm = MipsInsn.GetSimm(insn) -- ((insn<<48) >>48)
  -- print(string.format("retrieve ra from stack(%x) : sp=%x imm=%x", sp+imm, sp, imm))
  ra = obj.ReadMem32(sp + imm)
  -- print(string.format("load ra,%x(sp) : sp = %x+%x, ra = %x", imm, sp, imm, ra))
else
  -- print(string.format("retrieve ra from pushed one"))
  pushed_ra:dequeue()
end
end
  elseif MipsInsn.IsSq(insn) or MipsInsn.IsSd(insn) or MipsInsn.IsSw(insn) then
if MipsInsn.GetRt(insn) == gpr.ra and MipsInsn.GetRs(insn) == gpr.sp then
pushed_ra:enqueue(pc);
end
  elseif MipsInsn.IsJ(insn) then -- j **
local imm = MipsInsn.GetTarget(insn)
imm = imm << 2
if pc == imm then
-- jump to self? maybe we can ignore it.
else
new_pc = imm
-- print(string.format("j ** : new_pc = %x", new_pc))
bdl_count = 1
for t=1, n_j do
  if jmax[t] == new_pc then
  return result -- closed loop
  end
end
if n_j > 1024 then
  return result -- jump buffer overflow
end
jmax[n_j] = new_pc
n_j = n_j + 1
end
  elseif MipsInsn.IsBeq(insn) and MipsInsn.GetRs(insn) == gpr.zero then -- beq zero,**
local offset = MipsInsn.GetOff(insn) -- ((insn<<48) >> 48)
offset = offset << 2
new_pc = pc + 4 + offset
 
if pc == new_pc then
-- jump to self? maybe we can ignore it
else
-- print(string.format("beq zero,** : new_pc=%x", new_pc))
bdl_count = 1
for t = 1, n_j do
  if jmax[t] == new_pc then
  return result
  end
end
if n_j > 1024 then
  return result
end
jmax[n_j] = new_pc
n_j = n_j + 1
end
  elseif MipsInsn.IsEnd(insn) then -- end
-- print(string.format("end"))
return result
  elseif MipsInsn.IsJal(insn) then -- jal **
local imm = insn & 0x03ffffff
imm = imm << 2
-- print(string.format("jal ** : addr = %x", imm))
-- call
  end
 
  icount = icount + 1
  pc = pc + 4
 
  -- -- print(string.format("bdl_count=%d", bdl_count))
  if bdl_count > 0 then
if bdl_count == 2 then
pc = new_pc
bdl_count = 0
else
bdl_count = bdl_count + 1
end
  end
  end
  return result
end
 
PS2 = {}
PS2.GetCurrentThread = function(eeObj) return eeObj.ReadMem32(0x12fac) end
PS2.GetThreads = function(eeObj)
   local EE_THREAD_BASE = 0x18000
   local EE_NUM_THREADS = 0x100
   local th = EE_THREAD_BASE
   local result = Queue.new()
   for t = 0, EE_NUM_THREADS-1 do
  -- 0 : node_prev
  -- 4 : node_next
  -- 8 : status
  -- 12: pc
  -- 16: sp
  -- 20: gp
  -- 24: init_pri
  -- 26: curr_pri
  -- 28: wstat
  -- 32: waitId
  -- 36: wakeupCount
  -- 40: attr
  -- 44: option
  -- 48: func
  -- 52: argc
  -- 56: args
  -- 60: stack
  -- 64: size
  -- 64: size
  -- 68: root
  -- 68: root
  -- 72: endOfHeap
  -- 72: endOfHeap
  local status = eeObj.ReadMem32(th + 8)
  local status = eeObj.ReadMem32(th + 8)
  if status ~= 0 then
  if status ~= 0 then
local id    = t
local id    = t
local pri  = eeObj.ReadMem16(th + 26)
local pri  = eeObj.ReadMem16(th + 26)
local gp    = eeObj.ReadMem32(th + 20)
local gp    = eeObj.ReadMem32(th + 20)
local pc    = eeObj.ReadMem32(th + 12)
local pc    = eeObj.ReadMem32(th + 12)
local sp    = eeObj.ReadMem32(th + 16)
local sp    = eeObj.ReadMem32(th + 16)
result:enqueue( {id=id, status=status, pri=pri, gp=gp, pc=pc, sp=sp} )
result:enqueue( {id=id, status=status, pri=pri, gp=gp, pc=pc, sp=sp} )
  end
  end
  th = th + 76
  th = th + 76
   end
   end
   return result
   return result
end
</pre>
 
'''utils.lua'''
<pre>
-- utility classes/functions
 
-- Stack
-- ex:
-- my_stack = Stack.new()
--  my_stack:push( val )
-- print( my_stack:pop( val ) )
Stack = {}
 
function Stack.new()
  local obj = { buff = {} }
  return setmetatable(obj, {__index = Stack})
end
 
function Stack:push(x)
  table.insert(self.buff, x)
end
 
function Stack:pop()
  return table.remove(self.buff)
end
 
function Stack:top()
  return self.buff[#self.buff]
end
 
function Stack:isEmpty()
  return #self.buff == 0
end
 
 
-- Queue
-- ex:
-- my_queue = Queue.new()
-- my_queue:enqueue( val )
-- print( my_queue:dequeue(val) )
Queue = {}
 
function Queue.new()
  local obj = { buff = {} }
  return setmetatable(obj, {__index = Queue})
end
 
function Queue:enqueue(x)
  table.insert(self.buff, x)
end
 
function Queue:dequeue()
  return table.remove(self.buff, 1)
end
 
function Queue:top()
  if #self.buff > 0 then
    return self.buff[1]
  end
end
 
function Queue:isEmpty()
  return #self.buff == 0
end
end
</pre>
</pre>
'''utils.lua'''
<pre>
-- utility classes/functions
-- Stack
-- ex:
-- my_stack = Stack.new()
--  my_stack:push( val )
-- print( my_stack:pop( val ) )
Stack = {}
function Stack.new()
  local obj = { buff = {} }
  return setmetatable(obj, {__index = Stack})
end
function Stack:push(x)
  table.insert(self.buff, x)
end
function Stack:pop()
  return table.remove(self.buff)
end
function Stack:top()
  return self.buff[#self.buff]
end
function Stack:isEmpty()
  return #self.buff == 0
end


= Links =


-- Queue
* [https://psi-rockin.github.io/ps2tek/ PS2 Hardware Documentation]
-- ex:
* [https://pastebin.com/yf802Up3 Graphics Synthetizer title fix guide]
-- my_queue = Queue.new()
* [https://www.psdevwiki.com/ps3/PS2_Custom_Configs PS3 custom configs]
-- my_queue:enqueue( val )
* [http://www.psx-place.com/threads/research-ps2-emulator-configuration-on-ps4.16131/ A place for research and sharing successful configurations for the emulator]
-- print( my_queue:dequeue(val) )
* [https://www.psdevwiki.com/ps4/Talk:PS2_Classics_Emulator_Compatibility_List Configuration examples]
Queue = {}
* [https://www.romhacking.net/utilities/692/ PS2DIS, a very helpful tool for debugging executables]
 
* [https://forums.pcsx2.net/Thread-Fixing-unplayable-games A thread filled with patches for ps2 games]
function Queue.new()
* [https://github.com/florinsdistortedvision/ps2-classics-emus Most base emulators for PS2 Classics released on PS4 by florinsdistortedvision]
  local obj = { buff = {} }
* [https://github.com/Zcor3x/Playstation-2-Classics-PS4 Most base emulators for PS2 Classics released on PS4 by Zcor3x]
  return setmetatable(obj, {__index = Queue})
end
 
function Queue:enqueue(x)
  table.insert(self.buff, x)
end
 
function Queue:dequeue()
  return table.remove(self.buff, 1)
end
 
function Queue:top()
  if #self.buff > 0 then
    return self.buff[1]
  end
end
 
function Queue:isEmpty()
  return #self.buff == 0
end
</pre>


=Links=
*[https://psi-rockin.github.io/ps2tek/ Ps2 Hardware Documentation]
*[https://pastebin.com/yf802Up3 GS title fix guide]
*[https://www.psdevwiki.com/ps3/PS2_Custom_Configs PS3 custom configs]
*[http://www.psx-place.com/threads/research-ps2-emulator-configuration-on-ps4.16131/ A place for research and sharing successful configurations for the emulator]
*[https://www.psdevwiki.com/ps4/Talk:PS2_Classics_Emulator_Compatibility_List Configuration examples]
*[https://www.romhacking.net/utilities/692/ PS2DIS, very helpful for debugging games]
*[https://forums.pcsx2.net/Thread-Fixing-unplayable-games A thread filled with patches for ps2 games]
{{Reverse Engineering}}
{{Reverse Engineering}}
<noinclude>[[Category:Main]]</noinclude>
<noinclude>
[[Category:Main]]
</noinclude>

Latest revision as of 00:28, 15 November 2024

2024-present year[edit | edit source]

No emulator backported yet.

2014-2018 emulators[edit | edit source]

Description[edit | edit source]

The PlayStation 2 emulation on the PlayStation 4 is handled with little difference to the PlayStation 3. Some issues on PS3's PS2 emulator were left unfixed on the PlayStation 4. Consequently, the PS4 inherited some of PS3's emulation glitches, and even introduced new ones. The new issues came as a result of PS4's weakness with emulation, which likely resulted in the trade of accuracy for performance.

Each PS2onPS4 package file (.pkg) includes the PS2 emulator itself. The PS4 does not have a native built-in emulator in its System Software, but it does have a few PS2 emulator specific features, like the usermode functions sceLncUtilIsPs2Emu, sceShellCoreUtilGetImposeMenuFlagForPs2Emu, sceSystemServiceAddLocalProcessForPs2Emu, and sceSystemServiceShowImposeMenuForPs2Emu.

The PS2 emulators are programmed to be accurate for the games they were designed to emulate. In turn, this makes accurate emulation challenging, as emulators include per-title patches and different default settings. The PlayStation 2 hardware is a complex system to emulate; any small change in configuration can make or break a game. Currently, the most commonly used emulator is "Jakv2" from Jak games, as it is the most compatible one out there. When game crashes are concerned in an emulated PS2 game, then the Resident Evil Code: Veronica X's emulator is typically used, whereas for VU accuracy it is Rogue Galaxy's.

The PS2 BIOS is included in the game's pkg file. It is the same PS2 BIOS as used in the ps2_netemu in PS3 Operating System. The lack of encryption mechanism for PS2 game disc image files is also huge. This time, it is a plain ISO file, but the emulator still supports LIMG sector that allows the usage of non-2048 sector size discs. Moreover, memory cards are also unencrypted, but the emulator checks the CRC of some of the regions to ensure that the memory card was not modified. The PS2 emulator on PS4 also supports LUA scripting by a "Lua Bridge", which is a powerful interface that may prove exceptionally handy in fixing games.

This is first time that Sony has ever cared about floats in its emulators. Compared to the PS3 CPU, x86-64 is doing a worse job in mimicking FPU and VU floats calculation behavior. This is resolved by clamping, accurate math used per memory offset, and/or converting floats to double precision. The emulator uses OpenCL for GS, and likely other components as well.

Emulator Configuration[edit | edit source]

The emulator can be configured through 4 files.

Files[edit | edit source]

  • config-emu-ps4.txt - Stores paths, basic video/audio settings in official packages. But unofficially can be also used for advanced settings for global effect in multi disc .pkg with all commands originally used in cli.conf file.
  • XXXX-YYYYY_cli.conf - Stores per disc advanced settings. GS, VU, EE, IOP, FPU, COP2 emulation settings, are here. Also hacks, and hooks.
  • XXXX-YYYYY_config.lua - Used for per disc advanced scripts. Patching EE/IOP memory, Conditional hooks.
  • disc-swap-cli.conf - Stores info of multi disc games.

Commands[edit | edit source]

The rest of the CLI and LUA commands can all be found inside of any emulator's Eboot.bin file.

config-emu-ps4.txt commands[edit | edit source]

Command Values Notes Usage
Misc
--config-local-lua --config-local-lua=""
--lopnor-config 0,1 Enables limited PS3's PS2 config support --lopnor-config=1
--load-tooling-lua --load-tooling-lua=0
--max-console-spam
--path-snaps dir/folder Path to savestates folder --path-snaps="/tmp/snapshots"
--path-recordings dir/folder --path-recordings="/tmp/recordings"
--path-memcards dir/folder
--path-vmc dir/folder --path-vmc="/tmp/vmc"
--emulog-file 0, 1 Creates a log file with information that is rarely useful --emulog-file=1
--path-emulog dir/folder Sets the directory of the emulog file. Requires --emulog-file=1 command --path-emulog="/tmp/recordings"
--path-manual dir/folder
--path-patches dir/folder Path to patches folder --path-patches="/app0/patches"
--path-trophydata dir/folder --path-trophydata="/app0/trophy_data"
--path-featuredata dir/folder Path to folder with XXXX-YYYYY_features.lua file --path-featuredata="/app0/feature_data"
--path-postproc dir/folder Post-processing (shaders?)
--path-toolingscript dir/folder --path-toolingscript="/app0/patches"
--snapshot-name
--snapshot-datafile
--snapshot-restore
--snapshot-save frameId(?)
--snapshot-mcd-files
--snapshot-repeat repeat_count
--snapshot-modulo
--host-keyboard slot [0-7] --host-keyboard=4
--host-window-scale scale/float --host-window-scale=0.5
--host-window-pos x,y
--host-display-mode normal,full,4:3,16:9 Set display mode --host-display-mode=full
--host-graph fps Debug option that requires an unleaked debug ps2 bios --host-graph=fps
--host-osd verbose, minimal --host-osd=0
--host-vsync 0, 1 Enable or disable vsync --host-vsync=1
--host-trophy-support
--rtc-epoch unix_time (seconds since epoch) --rtc-epoch=1523776362
--framelimiter 0, 1 Enable or disable Frame limiting --framelimiter=1
--framelimit-fps FPS/float framelimiter --framelimit-fps=0.8
--framelimit-scalar scalar/float --framelimit-scalar=3.2
--framelimit-mode slowest,slower,slow,normal,fast,fastest,turbo A Standalone framelimiter --framelimit-mode=fast
--ps2-lang system Sets language. Might seem like a useless command, but a tiny number of games refuse to boot without a selected language. --ps2-lang=system
--ps2-title-id XXXX-YYYYY Example: (SLUS-21515) Sets title-id for patches. Requires the game's region code as value --ps2-title-id=SLES-50366
--verbose-cpu-cycles=1 0,1 ? --verbose-cpu-cycles=1
--gs-uprender none, 2x2 Internal resolution upscaler. --gs-uprender=2x2
--gs-upscale none, gpu, edgesmooth, motionvec, point, motionvector, smooth, motion upscaling type --gs-upscale=EdgeSmooth
Audio
--host-audio-latency msec/float Audio latency must be between 0.010 and 4.0 --host-audio-latency=1.5
--path-audio-images dir/folder
--record-audio
--record-audio-img
--record-audio-image
--record-audio-ext
--host-audio 1,0,on,off,mono --host-audio=1
--mute-audio all,none,main,bgm --mute-audio=all
--mute-streaming-audio all,none,main,bgm --mute-streaming-audio=all
Controllers
--ds4-deadzone-adjust
--ds4-diagonal-adjust
--host-pad-loses-focus --host-pad-loses-focus=1
--host-gamepads 0, 1 --host-gamepads=1
--pad-record 0, 1 Enables logging pad info in emulog
--pad-analog-to-digital 0, 1 Eternel ring emu uses the value 0 --pad-analog-to-digital=0
--mtap1 Disabled, Always, ByHost Multitap switch. The values are correct but the multitap only works in certain games. --mtap1=always
--mtap2 Disabled, Always, ByHost Multitap switch. Some games require multitap to be selected only on second port (1, 2-a, 2-b, 2-c layout). To achieve that, we need to disable the first mtap. In some cases, the emulator can be flawed in how it handles multi-tap when it involves "--mtap2". All functions for 2A, 2B, 2C, 2D must be redirected to ports on multi-tap 1 by using memory patches. --mtap2=always

XXXX-YYYYY_cli.conf commands[edit | edit source]

These commands work in config-emu-ps4.txt, but the official way to use them is through the CLI file (It is also needed for multi-disc packages). Additionally, some commands are still not discovered, and known commands might be missing their values.
All commands are pre-made. Creating new CLI commands is impossible.
The values of the commands are also pre-defined by Sony and/or have a set of possible values or ranges.
Some CLI commands have no effect, as they were added to the eboot.bin without being programmed. Some useful commands were removed or added in or from different emu revisions, or their effects were changed. In some emulators, CLI configurations can be found in the ram at SceLibcHeap[0]-3-881004000.

EmotionEngine (MIPS-IV)[edit | edit source]

EE[edit | edit source]
Commands for the emulated Emotion Engine. These commands may improve performance, prevent crashes, or provide better core sync.
Command Values Notes Usage
Speedhacks / Desync Fixes
--ee-cycle-scalar Slowest cycles speed: 5.00
Normal cycles speed: 1.000
Fastest cycles speed: 0.100
Can benefit core sync or performance (lowering the cycle rate may affect FMVS). The default value for most emulators is ~1.0. It is highly sensitive, as any slight change may break or fix the game. (Possibly divides 100 with the entered value and sets the result as EE's clock speed percentage % .) --ee-cycle-scalar=1.0
--ee-context-switch-cycles Accelerate cycles (360 => 0)
Decelerate cycles (361 => ∞ )
Its effects are mysterious. Possibly configures how many CPU cycles the emulator should run before switching between different tasks or threads. Does not work on Jak emulators. Default value is 360. Seems to be useful for Bee Movie, Metal Gear Solid 3, as well as others with IPU issues. --ee-context-switch-cycles=2700?
--ee-hook AdvanceClock
FastForwardClock
Mfifodrain
Runs the specified functionality each time a selected EE offset is reached. FastForwardClock and AdvanceClock help fix core sync issues, but can be used as a speedhack. It is believed that AdvanceClock stalls the EE for a specified amount of cycles, while FastForwardClock behaves similarly. They are commonly used on affected COP2 instructions. Mfifodrain is still unknown. For more examples --ee-hook=0x0025A9F2,AdvanceClock,,500
--ee-hook=0x0019F0AD,FastForwardClock
Game fixes
--ee-jit-pagefault-threshold 0-254 Ignore JIT pagefaults, usually caused by data placed right after code. JIT try to recompile it, and obviously hit some bad opcodes. This command reduces the occurrence of crashes the higher it is. --ee-jit-pagefault-threshold=40
--ee-regalloc-scalar 0,none,ReadOnly,WriteOnly,RW Register allocation setting. Setting it to 0 may prevent crashes.
--ee-block-validation PageProt, PageProtection, Hash, Full, none way of validating that block been modified, and require recompilation. [Some info about PageProt way] --ee-block-validation=None
--ee-shorthash-len inst_count/integer Length of shorthash in instruction/opcode count. Require --ee-block-validation=Hash
--ee-const-folding None,Gpr,Fpu,All EE constant folding. "All" seems to be the default option. --ee-const-folding=none
--ee-ignore-segfault none, read, write, readwrite Ignore segmentation fault. Ignore rw from/to unmapped memory, known in pcsx2 as TLB miss (load.store) --ee-ignore-segfault=readwrite
--ee-native-function memset, memcpy, strlen, strcmp, strcasecmp, litodp, dptoli, floatdidf, fptoui, fptodp, dptofp, fabs, fabsf, ieee754_atan2f, ieee754_asinf, ieee754_acosf, ieee754_sinf, ieee754_cosf, ieee754_sqrtf, asinf, acosf, sinf, cosf, sqrtf. Hook mips function with HLE x64 native version. Much faster, but tricky to keep correct timings on ps2 VM. --ee-native-function=memcpy,0x11e328
Other
--ee-jit-disasm 0 or 1 for mips and 2 for x86 Emotion engine Just in Time disassembler mode (Likely a debug log option) --ee-jit-disasm=1
--ee-ignore-break 0, 1 Turns a BREAK instruction into a NOP Instruction.
--ee-break-as-nop 0, 1 Turns a BREAK instruction into a NOP Instruction. --ee-break-as-nop=1
--ee-jit-opt-debug 0, 1
--ee-pc-coherency 0, 1 Flush PC register to memory on every mips opcode. Result in more accurate EE PC reg reads.
--ee-insn-flush-pc 0, 1 Flush PC register to memory on every mips opcode. Result in more accurate EE PC reg reads.
--ee-inst-marking 0,1?
--ee-insn-marking 0,1?
--ee-kernel-hle 0, 1 High-level emulation kernel. Apply HLE patches (used in mast1c0re part 2 Vulnerability 2). Apply EE kernel patches which run previously prepared x64 code instead of recompiling real code part.
--ee-injection-kernel 0, 1 Just like --ee-kernel-hle, except using a different name.
--ee-injection-title 0, 1 Apply HLE patches (used in mast1c0re part 2 Vulnerability 2). Apply per title patches which run previously prepared x64 code instead of recompiling real code part.
--ee-validate-kernel 0, 1
--ee-regalloc-simd readwrite, writeonly, readonly register allocation setting
--ee-regalloc-preserve-scalar LoadOnly, LO, StoreOnly, SO, LoadStore, LS EE JIT Scalar/Int Regalloc Mode --ee-regalloc-preserve-scalar=LoadStore
--ee-regalloc-preserve-simd ReadOnly, RO, WriteOnly WO, RW EE JIT SIMD/XMM Regalloc Mode --ee-regalloc-preserve-simd=RW
--ee-static-block-links options Type,Type,... [Branch,Branches,JAL,COP2,All] --ee-static-block-links=JAL,COP2
--vtune-ee
--ee-live32 0,1?
--ee-cache-breaks-block 0,1 End recompiler block on r5900 cache opcode.
--ee-evt-check-full 0, 1 Perform more accurate EE event check
--ee-peephole 0, 1?
--ee-load-rewrites 0,1?
--ee-store-rewrites 0,1?
--ee-precompile-trace
--ee-penalize-short-blocks 0, 1 Add cycles to short recompiled blocks?
--ee-mem-check-eob EE memory check end of block
--ee-insn-callmark
--ee-inline-limit-full insn_count/integer
--ee-inline-limit-partial
--ee-stlf-cycle-threshold ? ?
--detect-idle-ee 0, 1 --detect-idle-ee=1
FPU[edit | edit source]
The FPU is a fast single-precision unit that typically serves the EE by calculating in-game physics. It mostly controls the accuracy of the movement of in-game objects, or the game's gravity as a whole. In some cases, it is best to use COP2 commands with the FPU's to ensure the accuracy of the game's geometrical calculations.
Command Values Notes Usage
Game fixes
--fpu-no-clamping 0, 1 Changes the clamping behavior of the FPU. It's set to 1 by default. Might fix freezing issues, or misplaced characters/items (Inaccuracies with in-game physics) --fpu-no-clamping=0
--fpu-custom-min-max 0, 1 Custom Max/Mini logic for denormals. Enabled by default. Disabling it might break some games --fpu-custom-min-max=0
--fpu-accurate-range start,end offset (0x0 - 0x1FFFFFF) Accurate Mul/Div/Add/Sub Math instructions for the FPU by using software floats rather than hardware floats. Can be used for full EE/FPU Mathematical accuracy in the specified range. --fpu-accurate-range=0x1acce0,0x2acce0
--fpu-no-clamp-range start,end offset (0x0 - 0x1FFFFFF) Per-range clamping for the FPU in the selected memory range. --fpu-no-clamp-range=0x1acce0,0x2acce0
--fpu-accurate-muldiv 0 = Disabled
1 = Enabled
Allows the FPU to accurately Divide/Multiply for all offsets by using software floats rather than hardware floats. (Extremely slow) --fpu-accurate-muldiv=1
--fpu-accurate-addsub 0 = Disabled
1 = Enabled
Allows the FPU to accurately Add/Subtract for all offsets by using software floats rather than hardware floats. (Extremely slow) --fpu-accurate-addsub=1
--fpu-accurate-muldiv-range start,end offset (0x0 - 0x1FFFFFF) Allows the FPU to accurately Divide/Multiply in the specified ee memory range by using software floats rather than hardware floats. --fpu-accurate-muldiv-range=0x1acce0,0x2acce0
--fpu-accurate-addsub-range start,end offset (0x0 - 0x1FFFFFF) Allows the FPU to accurately Add/Subtract in the specified ee memory range by using software floats rather than hardware floats. --fpu-accurate-addsub-range=0x1acce0,0x2acce0
Speedhacks
--fpu-rsqrt-fast-estimate 0, 1 Decreases RSQRT's accuracy. Enabled by default, disabling it helps with achieving full FPU accuracy. --fpu-rsqrt-fast-estimate=1
--fpu-accurate-mul-fast 0, 1 Speedhack for CLI FPU muldiv commands. --fpu-accurate-mul-fast=1
Other
--fpu-custom-fused-madd 0, 1 Custom FMA (fused multiply-add). Disabled by default. --fpu-custom-fused-madd=0
--fpu-to-double 0, 1 Converts floats to doubles (Accurate). Limited testing shows that infinity is still wrong at 7F7FFFFF, rather than 7FFFFFFF with it enabled. --fpu-to-double=1
--fpu-clamp-operands 0, 1 Affects the fpu's clamping behavior --fpu-clamp-operands=1
--fpu-clamp-results 0, 1 Affects the fpu's clamping behavior --fpu-clamp-results=1
COP2[edit | edit source]
VU0 Macro-mode. These commands assist the FPU.
Command Values Notes Usage
Speedhacks
--cop2-opt-flags 0, 1 ,2 Optimize flags upon recompilation (1 is safe, 2 update sticky, and mac flag on every status flag update) setting it to 0 can in some cases improve FPU accuracy. More Info --cop2-opt-flags=1
--cop2-opt-vf00 0, 1, 2 Optimization for the vf00 register. --cop2-opt-vf00=1
--cop2-const-prop 0, 1 Disables or enables constant propagation. Can Be Used as speedhack for COP2 hungry games when set to 1 More info --cop2-const-prop=1
--cop2-di-bits 0, 1 0 to skip setting invalid, and div by Zero flags in status register, and therefore improve performance. Can be used as a speedhack to skip costly calculations. --cop2-di-bits=0
Game fixes
--cop2-no-clamping 0, 1 Changes the clamping behavior of the COP2. The default value is set to 1. --cop2-no-clamping=0
--cop2-accurate-range start,end offset (0x0 - 0x1FFFFFF) Accurate Mul/Div/Add/Sub math instructions for the COP2 by using software floats rather than hardware floats. Can be used for full COP2 mathematical accuracy in the specified range. --cop2-accurate-range=0x123456,0x134567
--cop2-no-clamp-range start,end offset (0x0 - 0x1FFFFFF) Per-range clamping for COP2. --cop2-no-clamp-range=0x123456,0x134567
--cop2-accurate-mul-range start,end offset (0x0 - 0x1FFFFFF) Accurate multiplication instructions for the COP2 in the specified range by using software floats rather than hardware floats (Offset range seems not to directly match EE's) --cop2-accurate-mul-range=0x123456,0x134567
--cop2-accurate-mul 1 = Enabled
0 = Disabled
Allows the COP2 to accurately multiply for all offsets by using software floats rather than hardware floats. (Extremely slow) --cop2-accurate-mul=1
--cop2-accurate-addsub 1 = Enabled
0 = Disabled
Allows the COP2 to accurately Add/Subtract for all offsets by using software floats rather than hardware floats. (Extremely slow) --cop2-accurate-addsub=1
--cop2-accurate-addsub-range start,end offset (0x0 - 0x1FFFFFF) Allows the COP2 to accurately Add/Sub in the specified ee memory range by using software floats rather than hardware floats. (Offset range seems not to directly match EE's. It is possibly 0x95400~ behind(?) --cop2-accurate-addsub-range=0x123456,0x134567
Other
--cop2-regalloc 0, 1 ? Optimized Register Allocation(?). PCSX2 seems to have this enabled by default. Seems to slow down COP2 when disabled.
--cop2-inst-q 0, 1 instant Q, no stalling on VWAITQ, or instances of Q. Crashes some games when enabled.
--cop2-inst-p 0, 1 instant P, no stalling on VWAITP, or instances of P.
--cop2-use-rcp 0, 1 Enables SSE RCP. Disabled by default
--cop2-use-rsqrt 0, 1 Enables SSE RSQRT --cop2-use-rsqrt=0
--cop2-clamp-operands 0, 1 Affects the COP2's clamping behavior --cop2-clamp-operands=1
--cop2-clamp-results 0, 1 Affects the COP2's clamping behavior --cop2-clamp-results=1

Vector Units (VU)[edit | edit source]

VU[edit | edit source]
Custom DSPs used to process vertex data, physics calculations, and other related tasks. Settings found here affect VU1, VU0, and COP2. They fix broken or missing geometry, black screens, and crashes.
Command Values Notes Usage
Graphical fixes
--vu-xgkick-delay Limit is between (0 => 31) Delay xgkick instruction execution. PCSX2 uses 6 cycles, PS3 uses 2-8 cycles depending on the game. A game with missing graphics will require a low value such as 0, while one that crashes might require a high value such as 7. --vu-xgkick-delay=8
--vu-custom-min-max 0, 1 Custom Max/Mini logic for denormals. Disabled on pcsx2 by default but enabled by default on a couple of emus such as jakv2. Disabling it could potentially restore missing graphics. --vu-custom-min-max=0
Game fixes
--vu-hack-triace 0, 1 A hack designed specifically for games developed by Tri Ace. Corrects the VU's addi calculation. Without it, the result will be one bit off, which is enough to break the game's decryption algo. --vu-hack-triace=1
--vu-branch-hazard 0, 1 This command relates to how the emulator handles branch hazards in the Vector Units (VU). Setting it to 0 is the compatible option, while 1 might improve performance. Seems to be enabled by default. Disabling it managed to prevent "Batman - Rise of Sin Tzu" from crashing --vu-branch-hazard=0
--vu-evil-branches 0, 1 Take in count branch in delay slot, or not. More Info
--vu-to-double 0, 1 Converts floats to double. Enabling it is the accurate option. --vu-to-double=1
--vu-custom-fused-madd 0, 1 Custom FMA (fused multiply-add). Disabled by default --vu-custom-fused-madd=1
Speedhacks
--vu-opt-sf-check 0, 1 Updates status flags only on blocks which will read them. Known in pcsx2 as mVU flag hack. Won't work with most emulators, but will work on Arc Twilight of the Spirits™ --vu-opt-sf-check=1
--vu-opt-jr-caching 0, 1 Optimize Jump Register caching. (vi15). Won't work with most emulators but will work on Arc Twilight of the Spirits™ --vu-opt-jr-caching=1
Other
--vu-d-bit 0, 1 Debug break. Halts the VU and sends an interrupt to the EE. --vu-d-bit=0
--vu-t-bit 0, 1 Debug halt. Acts similarly to D-bit --vu-t-bit=0
--vu-inst-mflag 0, 1 Instant macflag? It's enabled by default. When disabled, some texture chunks pop and fade. --vu-inst-mflag=1
--vu-inst-cflag 0, 1 Instant cflag? --vu-inst-cflag=1
--vtune-vu ? ?
--vu-jit-disasm 0, 1, 2 ? --vu-jit-disasm=1
--vu-range-merge vu_inst_cnt ?
VU1[edit | edit source]
VU1 is the Graphics Synthesizer’s alternate processing unit. Commands here typically improve performance, prevent crashes, and fix SPS (graphical glitches).
Command Values Notes Usage
Speedhacks
--vu1-mpg-cycles Decimals
0 - 65535
Set initial speed for VU1 Micro-programs. 100 is the default value. If VU1 requirements were a bottleneck, increasing it will result in better performance while decreasing it will result in the opposite. Increasing it can be beneficial for MTVU sensitive games. --vu1-mpg-cycles=1000
 Symbols (They change values close to VU1-mpg-cycles' offset):

$ goes to the specified succeeding offsets. $0 will go 2 bytes forward and change them. $1 will go 4 bytes forward and change the 2 bytes specified. For example, $0,$1 will change the 4 bytes ahead as the specified 2 bytes' value.

'0x' Is like '+' a symbol that modifies succeeding values. 0x0 goes 2 bytes ahead and changes them, 0x1 goes 4 bytes ahead and so on and so forth. 

'-' or '+' Changes the specified preceding or succeeding 2 bytes of VU1 mpg cycles' offset according to the added number. Adding -1, for example will change the 2 bytes before it. Likewise, adding -2 will go 4 bytes away and change the specified 2 bytes accordingly. It even can change EE cycle scalar itself if you go far enough. These numbers are in HEX. Infinite amounts of '-' and '+' symbols seem to be supported.
--vu1-di-bits 0, 1 0 Skips setting invalid, and Divides by zero flags in status register. Can be used as a speedhack as it can skip costly calculations. But at the same time, it can cause issues such as broken geometry. --vu1-di-bits=0
--vu1-const-prop 0, 1 Enabled by default. 0 will disable it and cause performance issues but with higher compatability.More info --vu1-const-prop=1
--vu1-opt-flags 0, 1, 2 Optimize flags upon recompilation (1 is safe, 2 update sticky, and mac flag on every status flag update) More Info --vu1-opt-flags=0
--vu1-opt-vf00 0, 1, 2 Optimization for the vf00 register. --vu1-opt-vf00=2
--vu1-jr-cache-policy newprog, sameprog, auto, new, same PCSX2 uses newprog as the default setting. Setting it into newprog has been proven to fix some crashes Info --vu1-jr-cache-policy=newprog
--vu1-jalr-cache-policy newprog, sameprog, auto, new, same PCSX2 uses newprog as the default setting. Setting it into newprog has been proven to fix some crashes Info --vu1-jalr-cache-policy=newprog
Game fixes / Graphical fixes
--vu1 jit-sync Selector between IR/JIT and it modes. Jit-sync works similarly to disabling MTVU. jit, trans, and jit-async are unimplemented functions that do not change anything. --vu1=jit-sync
--vu1-no-clamping 0,1 Changes the clamping behavior of the VU1. Setting specific to ps4 emulators, unimplemented in pcsx2, with 0 being closest to extra, and 1 to extra + preserve sign. The default emulator's value is 1. --vu1-no-clamping=0
--vu1-clamp-range vu1 memory offset start,end (0x0 - 0x7FF) Values must not exceed 0x7FF
--vu1-accurate-addsub-range vu1 memory offset start,end (0x0 - 0x7FF) Allows the VU1 to accurately add/subtract in the specified ee memory range by using software floats rather than hardware floats. --vu1-accurate-addsub-range=0x0000,0x0600
--vu1-mul0fix-range vu1 memory offset start,end (0x0 - 0x7FF) Allows the VU1 to accurately multiply by 0 in the specified ee memory range by using software floats rather than hardware floats. --vu1-mul0fix-range=0x123,0x123
--vu1-injection 0, 1 unknown --vu1-injection=1
--vu1-native-patch 0, 1 Use native patches from recompiler, not compatible with jak emus. Sony uses it for their official release of Primal --vu1-native-patch=1
Other
--vu1-inst-p 0, 1 instant P, no stalling on WAITP, or instances of P --vu1-inst-p=1
--vu1-use-rcp 0, 1 Use SSE/AVX RCP. Speedhack. Likely used only in EFU pipeline, due to rare use, its really not worth to enable it. Speed improvement will be marginally/unnoticeable. Disabled by default
--vu1-use-rsqrt 0, 1 Use SSE/AVX rsqrt instead of doing sqrt and then div. Speedhack, rather safe to use on VU1.
--vu1-clamp-operands 0, 1 Clamp operands before mathematical operation. --vu1-clamp-operands=1
--vu1-clamp-results 0, 1 Clamp result after mathematical operation. --vu1-clamp-results=1
--vu1-inst-q 0, 1 instant Q, no stalling on WAITQ, or instances of Q. --vu1-inst-q=1
--assert-path1-ad 0, 1 Path 1 is how the GIF takes data from VU1 via XGKICK instruction. It's unknown what this command does but it's related to VU1, and helps prevent crashes in VU1 sensitive games when enabled. --assert-path1-ad=1
VU0[edit | edit source]
VU0 is the Emotion Engine’s alternate processing unit. It is sometimes referred to as "micro-mode". Commands here prevent crashes, and fix SPS (graphical glitches).
Command Values Notes Usage
Speedhacks
--vu0-mpg-cycles Decimals
0 - 65535
Set initial cycle speed for VU0 Micro-programs. 100 is the default value. It is not available in older emulators such as War of the Monsters. Raising the value helps COP2 timing, while lowering does the opposite. --vu0-mpg-cycles=1000
 Symbols (They change values close to VU0-mpg-cycles' offset):

$ goes to the specified succeeding offsets. $0 will go 2 bytes forward and changes them. $1 will go 4 bytes forward and changes the 2 bytes specified. For example, $0,$1 will change the 4 bytes ahead as the specified 2 bytes value.

'0x' Is like '+' a symbol that modifies succeeding values. 0x0 goes 2 bytes ahead and changes them, 0x1 goes 4 bytes ahead and so on and so forth. 

'-' or '+' Changes the specified preceding or succeeding 2 bytes of VU0 mpg cycles' offset according to the added number. Adding -1, for example will change the 2 bytes before it. Likewise, adding -2 will go 4 bytes away and change the specified 2 bytes accordingly. It even can change EE cycle scalar itself at -15 (Jakv2). Setting it to --vu0-mpg-cycles=1280,-15 would, for example, set ee-cycle-scalar to 5. These numbers are in HEX. Infinite amounts of '-' and '+' instances seem to be supported.
--vu0-di-bits 0, 1 0 to skip setting invalid, and Div by zero flags in status register. Can be used as speedhack as it skips costly calculations, but at the same time can cause issues like broken geometry, and weird physics behavior. Depending per game. --vu0-di-bits=0
--vu0-const-prop 0, 1 Constant propagation, can Be used as speedhack for VU0 hungry games when set to 1 More info --vu0-const-prop=1
--vu0-opt-vf00 0, 1, 2 Optimization for the vf00 register. --vu0-opt-vf00=1
--vu0-opt-flags 0, 1, 2 Optimize flags upon recompilation (1 is safe, 2 update sticky, and mac flag on every status flag update) More Info --vu0-opt-flags=1
--vu0-jr-cache-policy newprog, sameprog, auto, new, same PCSX2 uses newprog as the default setting Info --vu0-jr-cache-policy=sameprog
--vu0-jalr-cache-policy newprog, sameprog, auto, new, same PCSX2 uses newprog as the default setting Info --vu0-jalr-cache-policy=sameprog
Game fixes
--vu0-clamp-range start, end offset (0x0 - 0x1FF) per range clamping for VU0 --vu0-clamp-range=0x100,0x120
--vu0-no-clamping 0,1 Changes the clamping behavior of the VU0. Setting specific to ps4 emulators, unimplemented in pcsx2. The default emulator's value is 1. --vu0-no-clamping=0
--vu0-accurate-addsub-range offset (0x0 - 0x1FF) Allows the VU0 to accurately Add/Subtract in the specified ee memory range by using software floats rather than hardware floats.
--vu0-mul0fix-range vu0 memory offset start,end (0x0 - 0x1FF) Allows the VU0 to accurately Multiply by 0 in the specified ee memory range by using software floats rather than hardware floats
Other
--vu0-injection 0, 1 Unknown usage. --vu0-injection=1
--vu0-inst-q 0, 1 instant Q, no stalling on WAITQ, or instances of Q --vu0-inst-q=1
--vu0-inst-p 0, 1 instant P, no stalling on WAITP, or instances of P --vu0-inst-p=1
--vu0-use-rcp 0, 1 Use SSE/AVX RCP. Speedhack. Not sure why it is even available for VU0. Disabled by default --vu0-use-rcp=1
--vu0-use-rsqrt 0, 1 Use SSE/AVX rsqrt instead of doing sqrt and then div. Speedhack, rather unsafe to use on VU0. --vu0-use-rsqrt=1
--vu0-clamp-operands 0, 1 Clamp operands before mathematical operation. --vu0-clamp-operands=1
--vu0-clamp-results 0, 1 Clamp result after mathematical operation. --vu0-clamp-results=1

DMA Channels[edit | edit source]

VIF[edit | edit source]
The VIF decompresses vector data, uploads microprograms to the VUs, and sends graphical data to the GIF. Its commands
are often used to fix freezing.
Command Values Notes Usage
VIF Game fixes
--vif-ignore-invalid-cmd 0, 1 Ignore invalid vif commands. In some cases, setting it to 1 can fix games that freeze while showing the same frame. --vif-ignore-invalid-cmd=1
--vif-thread-chunk-size 0, 1024 Slows down both VIFS the lower it is, and speeds them up the higher it is. 1024 is the limit, with 112 being the default value.  --vif-thread-chunk-size=100
--detect-idle-vif 0, 1 Enabled by default. Unknown function --detect-idle-vif=0
VIF1 Game fixes
--vif1-ignore-cmd-ints 0, 1 Set to 1 to ignore command interrupt bit. (info , explanation of int bit is right before command list). Can in some cases fix games that freeze while showing the same frame if set to 1. Games likes "Men in Black II - Alien Escape" and "Test Drive Unlimited" Will always need it. --vif1-ignore-cmd-ints=1
--vif1-instant-xfer 1 = Instant VIF1
0 = Delayed VIF1
Changes VIF1 timing. 0 slows its timing and is the compatible option for most games, while 1 speeds up its timing, and being more compatible with a small fraction of games. It can be used to fix graphical glitches or potentially prevent games from freezing. --vif1-instant-xfer=0
SIF[edit | edit source]
The SIF is how the EE and IOP communicate with each other. SIF has some mailbox hardware registers that the CPUs can use to pass values to each other, which happens during SIF initialization. However, once both sides have booted, they use the SIF0 (IOP->EE) and SIF1 (EE->IOP) DMA channels to communicate. Despite common belief, these commands have no effect on performance, and are rarely ever useful.
Command Values Notes Usage
SIF1 (IOP)
--iop-sif1-cycle-scalar Accelerate SIF cycles: (0.99 => 0.1)
Decelerate SIF cycles: (1.1 => ∞ )
Controls the speed at which the IOP receives from the EE --iop-sif1-cycle-scalar=0.1
--ee-sif1-cycle-scalar Accelerate SIF cycles: (0.99 => 0.1)
Decelerate SIF cycles: (1.1 => ∞ )
Controls the speed at which the EE sends to the IOP --ee-sif1-cycle-scalar=0.1
SIF0 (EE)
--iop-sif0-cycle-scalar Accelerate SIF cycles: (0.99 => 0.1)
Decelerate SIF cycles: (1.1 => ∞ )
Controls the speed at which the IOP sends to the EE --iop-sif0-cycle-scalar=0.1
--ee-sif0-cycle-scalar Accelerate SIF cycles: (0.99 => 0.1)
Decelerate SIF cycles: (1.1 => ∞ )
Controls the speed at which the EE receives from the IOP --ee-sif0-cycle-scalar=0.1

GS[edit | edit source]

"GS" stands for Graphics Synthesizer. It's the PlayStation®2's co-processor that's responsible for rendering the graphics (but is also used by some games for additional calculations and other purposes)
Command Values Notes Usage
Speedhacks
--gs-optimize-30fps 0, 1 Speedhack for GS hungry games. --gs-optimize-30fps=1
--gs-adaptive-frameskip 0, 1 Speedhack. Skips frames when the gs demands more resources than there are available. doesn't work on all emulators. It does however, work on jak emulators --gs-adaptive-frameskip=1
--gs-h2l-list-opt 0, 1 Setting it to 1 improves GS performance --gs-h2l-list-opt=1
GS features
--gs-use-mipmap 0, 1 Enables mipmapping support. Can be used to fix graphics. Needs --gs-kernel-cl="mipmap" for full mipmapping support. If upscaling, however, --gs-kernel-cl-up="mipmap2x2" is also needed. It works best on War of the Monsters emulator, as the Ratchet series' mipmapping issues can only be fixed by it. --gs-use-mipmap=1
--gs-use-deferred-l2h 0, 1 Delay option for L2H (local to host, GS to EE). --gs-use-deferred-l2h=1
--gs-use-clut-merge 0, 1 Enabling CLUT merging helps improve how the emulator processes textures that use indexed color palettes. It ensures more accurate emulation of the PS2’s color handling. It sometimes restores missing graphical elements, and fix texture flickering (prominently flickering shadows or UI elements). It prevents Spyro's shadow from flickering in Enter the Dragonfly. Enabling it is the accurate, albeit slow option. --gs-use-clut-merge=1
--gs-flush-ad-xyz always, safe, safeZwrite, off, 0 Force a primitive flush when a framebuffer is also an input texture. This fixes some processing effects, but it can sometimes be heavy on the GS in terms of performance. GTA: SA, and Jak 3 use this command. --gs-flush-ad-xyz=safe
--gs-force-bilinear 0, 1 Forces bilinear filtering, can fix ghosting problems in some cases. Not recommended for games that use 2D images, as it could possibly break games that rely on nearest filtering. --gs-force-bilinear=1
Gs settings / Behaviour
--gs-uprender none,2x2 Internal resolution upscaler. --gs-uprender=2x2
--gs-upscale none, gpu, edgesmooth, smooth, motion, motionvec, motionvector, point Upscaling type Selector --gs-upscale=EdgeSmooth
--gs-kernel-cl-up "DarkCloud2" "fantavision" "h2lpool2x2", "OptRightTri", "clutmerge2x2", "mipmap2x2", "up2x2simple", "up2x2skipinterp", "up2x2tc", "up2x2", default Kernel Variant Color lookup Upscaler (?), mipmap and clutmerge and h2l need to be enabled before their options become usable --gs-kernel-cl-up="clutmerge2x2"
--gs-override-small-tri-area 0, 1 This option is designed to modify how the emulator handles or renders small triangles that fall below a certain area threshold. Enabling this option could resolve graphical problems such as missing, flickering, or incorrectly rendered small details, and could potentially restore missing text in some games. --gs-override-small-tri-area=1
--gs-dirty-page-policy 0, 1 Unknown. Used by Star Wars: Jedi Starfighter --gs-dirty-page-policy=1
--gs-ignore-dirty-page-border 0, 1 Unknown. Used by Samurai Shodown Anthology --gs-ignore-dirty-page-border=1
--gs-ignore-rect-correction 0, 1 Setting it to 1 is known to fix flickering textures and graphical glitches in far distances. --gs-ignore-rect-correction=1
--gs-opt-frbuff-switch 0, 1 Unknown. Used by Everybody's Tennis/Hot Shots Tennis --gs-opt-frbuff-switch=0
--gs-kernel-cl h2lpool, clutmerge, mipmap, DarkCloud2, fantavision, Mipmap and clutmerge and h2l need to be enabled before their options become usable Kernel Variant Color lookup(?). Options included here can be upscaling if --gs-kernel-cl-up were to be used along with it --gs-kernel-cl="clutmerge"
--force-frame-blend 0, 1 Enables blend (Deinterlacing?). Should be used to fix games with shaking screens. --force-frame-blend=1
--force-pal-60hz 0, 1 Enables 60hz PAL mode. --force-pal-60hz=1
--gs-progressive 0, 1 Enables progressive scan. Can fix graphical glitches/double screen issues.
--gs-vert-precision 8, 16 This option allows the user to choose between 8-bit and 16-bit precision for the vertex calculations in 3D graphics rendering. It reduces the likelihood of visual distortions such as jagged edges, improper alignment of polygons, or model "warping." The emu expects the values of 8 or 16, any other values are not permitted. --gs-vert-precision=8
--gs-skip-dirty-flush-on-mipmap 0, 1 Skip flushing textures marked as dirty from cache when enabled. It does, however, require mipmap to be enabled first. --gs-skip-dirty-flush-on-mipmap=1
--gs-packed15-fmv-opt 0, 1 Unknown. This option likely controls whether the emulator optimizes or processes FMVs that use the 15-bit packed color format. Used by Ape Escape 2 --gs-packed15-fmv-opt=1
--gs-fieldswap-delay 0, 254 Wait longer than usual to change field. In essence, it blurs/sharpens image.
--gs-uv-shift-pointsampling 0, 1 Can be used on games like manhunt that have issues with UV light rendering --gs-uv-shift-pointsampling=1
--gs-render-tile-threshold 0, 3000000 Unknown. Used by Psychonauts --gs-render-tile-threshold=300000
--threaded-gs 0, 1 Multi-threaded-gs ? --threaded-gs=1
--gs-aspect-ratio aspect/float (default=0.81) --gs-aspect-ratio=0.65
--gs-frontend-opt-mode 0, 1, 2 GS optimization mode? Unknown effect. Used on JakX --gs-frontend-opt-mode=1
--gs-motion-factor 25, 50 Unknown. Used by Wild ARMS 3 --gs-motion-factor=25
--gs-scanout-delay 0, 200 --gs-scanout-delay=200
--gs-check-trans-rejection 0, 1 Check transfer rejection? Unknown. Used by Grand Theft Auto: Vice City --gs-check-trans-rejection=1
--gs-check-trans-rejection68 0, 1 Unknown. Used by Star Wars: Jedi Starfighter --gs-check-trans-rejection68=1
--l2h-2d-params TRXREG,BITBLTBUF,height --l2h-2d-params=0x0000000800000001,0x000000003a0a2300,512,2
--gs-h2l-accurate-hash 0, 1 --gs-h2l-accurate-hash=1
Aspect ratio
--gs-scanout-offsetx relative offset/ignored A zoom in setting in the x direction --gs-scanout-offsetx=27
--gs-scanout-offsety relative offset/ignored A zoom in setting in the y direction --gs-scanout-offsety=27
--safe-area-min area/float (range 0.9 to 1.0) any other values outside of that range will be rejected by the emulator An overscan setting --safe-area-min=0.9
Other
--framelimit-mode slowest,slower,slow,normal,fast,fastest,turbo Standalone Framelimiter --framelimit-mode=fast
--framelimiter 0, 1 Enable or disable Frame limiting --framelimiter=1
--framelimit-fps FPS/float framelimiter --framelimit-fps=0.8
--gs-hdr-support 0, 1? ?

IOP[edit | edit source]

The emulated I/O Processor (IOP) settings. Commands here are rarely useful, as very few games will require them. The IOP controls the emulated DEV9, SPU2, USB, Memory cards, CDVD, Firewire, along with other input/output devices
Command Values Notes Usage
Game fixes
--iop-cycle-scalar
Accelerate IOP cycles: (0.999 => 0.100)
Decelerate IOP cycles: (1.001 => 5.000)
Not a performance speedhack. It impacts the speed of loading times and input latency. The default value for most emulators is 0.5 --iop-cycle-scalar=1.0
--iop-const-folding None,Gpr,All IOP constant folding More info --iop-const-folding=All
--iop-tight-slice-count 0, 2000 Seems to slow down the iop the higher the value. Can be used to fix CDVD timing issues. --iop-tight-slice-count=12
--iop-hook AdvanceClock
FastForwardClock
Mfifodrain
IOP native hook, Sony uses it on their official release of Red dead revolver. It helps fix timing issues --iop-hook=0x0086ac,FastForwardClock
--iop-block-validation IsC, ShortHash, Hash Way of validating that block been modified, and require recompilation. Other Possible values include PageProt, None, PageProtection --iop-block-validation=IsC
Other
--iop-validate-kernel 0, 1
--iop-shorthash-len inst_count/integer Length of shorthash in instruction/opcode count. Require --iop-block-validation=ShortHash
--iop-pc-coherency 0, 1
--iop-inst-marking 0, 1?
--detect-idle-iop 0, 1 Enabled by default. --detect-idle-iop=0
--iop-jit-disasm
--iop-evt-check-full 0, 1 ?

CDVD[edit | edit source]

The emulated CDVD settings. These commands help games with timing issues.
Command Values Notes Usage
General commands
--max-disc-num 1-5 numbers of discs in package (maximum=5) --max-disc-num=1
--boot-disc-id 1-5 sets boot disc for multi-disc pkg --boot-disc-id=0
--switch-disc-reset 1 = Enables resetting the game upon disc swap, 0 = Disables resetting the game upon disc swap 0 Can be used to prevent resetting the game when switching multiple discs. Useful for games like Samurai warriors 2 that include an import data feature. Sadly this command isn't supported by many emulators, but jakv2 is confirmed to support it --switch-disc-reset=1
Timing
--cdvd-sector-read-cycles 0.1 = Fastest, 80000 = Slowest Set DVD reading speed. Higher values are slower, lower values are faster. Kinetica uses 40000, Psychonauts 4000, Red dead revolver 5000, Rise of kasai 31000. Some games require moderate speed, too slow or too fast could cause audio problems. --cdvd-sector-read-cycles=0.1
--cdvd-sector-seek-cycles 0.1 = Fastest, 80000 = Slowest Set the speed at which the emulated CDVD spins. Higher values are slower,

lower values are faster. Fixes boot-up sometimes. More info here [1].

--verbose-cdvd-reads 0, 1 Significantly helps games with CDVD timing issues when set to 1. --verbose-cdvd-reads=0

Misc[edit | edit source]

Command Values Notes Usage
--idec-cycles-per-qwc int/multiplier Multiply how many cycles IDEC command take per whole currently worked on QWC. --idec-cycles-per-qwc=768
--mfifo-manual-drain 0.1/5.0 A command for changing the functionality of --ee-hook=0x0,Mfifodrain --mfifo-manual-drain=0.30
--mfifo-chunk-drain-cycles 1/400000 A command for changing the functionality of --ee-hook=0x0,Mfifodrain --mfifo-chunk-drain-cycles=210000
--pcr0-delta-hack 0.1 , 400000.0 Modify delta of pcr0 when reading it from MFC0. Some games rely on good performance counters accuracy (Spyro ANB cutscenes), and since emulator don't implement most events, hack it is. --pcr0-delta-hack=1.0
--jitproc-use-aslr Disables compiler process ASLR, useful for easier debugging, as the compiler process will be always on fixed address. Theoretically useful for mast1c0re, but to change it you need to be already in... --jitproc-use-aslr=0
--detect-idle-intc 0, 1 Enabled by default, 0 disables it --detect-idle-intc=0
--detect-idle-chcr 0, 1 Enabled by default, 0 disables it --detect-idle-chcr=0
--rom location of the bios that's inside of the fpkg Could allow to use custom bios, though still not working --rom="PS20220WD20050620.crack" or --rom="/roms/PS20220WD20050620.crack"
--cop2 jit, trans ?
--vu0 jit, trans ?
--r30 jit, trans ?

PCSX2's gameindex[edit | edit source]

PCSX2's commands on the PS4 (or the commands which behave similarly)


Current Gameindex.yaml

PCSX2 PS4 Notes
XGKickHack --vu-xgkick-delay= Possible equivalent value is 8
VuAddSubHack --vu-hack-triace=1 Required for every single game developed by TriAce
vuClampMode: 2
--vu1-no-clamping=0
--vu0-no-clamping=0
--cop2-no-clamping=0
vuClampMode: 3
--vu1-no-clamping=1
--vu0-no-clamping=1
--cop2-no-clamping=1
--vu-to-double=1
eeClampMode: 2 --fpu-to-double=0
--fpu-no-clamping=0
eeClampMode: 3 --fpu-to-double=1
--fpu-no-clamping=1
eeRoundMode: --fpu-accurate-muldiv=1
--fpu-accurate-addsub=1
vu0RoundMode: --cop2-accurate-mul=1
--cop2-accurate-addsub=1
--vu0-accurate-addsub-range=
--vu0-mul0fix-range=
vu1RoundMode: --vu1-accurate-addsub-range=
--vu1-mul0fix-range=
eeCycleRate: --ee-cycle-scalar= "Potential" equivalent values: PCSX2 - PS4:
300% --> 0.333
180% --> 0.555
130% -->0.769
100% --> 1.0
75% --> 1.333
60% --> 1.666
50% --> 2
FpuNegDivHack
FpuMulHack
--fpu-accurate-muldiv=1
cpuCLUTRender: 1 --gs-uv-shift-pointsampling=1
MTVUSpeedHack: 0 --vu1=jit-sync Some games will also require --vu1-mpg-cycles= to be between "6000 - 19000"
mergeSprite
alignSprite
--gs-kernel-cl-up="up2x2simple" Note: works similarly but not the equivalent
cpuSpriteRenderBW: 4 --gs-opt-frbuff-switch=1 Note: works similarly but not the equivalent
mipmap --gs-use-mipmap=1
--gs-kernel-cl="mipmap"
Note: Works best on War of the Monsters emu
autoFlush --gs-flush-ad-xyz=safe Possible values include always, safe, off, 0
VIF1StallHack --vif1-instant-xfer=0 If that doesn't work, the lua command eeObj.SchedulerDelayEvent("vif1.dma", 0x9000) might assist.
wildArmsHack --gs-kernel-cl-up="DarkCloud2"
deinterlace --force-frame-blend=1

Emulators[edit | edit source]

Every PS2 emulator is programmed differently. Sometimes choosing the right emulator is the only way to fix a game. Emulators are not provided pre-installed in the PS4 OS, but instead they have to be unpacked from an official PS2 CLASSICS PKG file signed by Sony. This list includes the typical usage of those emulators.

Emulator name Typical usage - Info API Version Similar emulators
2018
The King of Fighters '98: Ultimate Match The only known emulator where Mojin-ribbon is playable. Commonly known as "KOF98" 2.0
2017
Jak and Daxter: The Precursor Legacy Good compatibility with most ps2 games. It has a very high api version which means more LUA commands are supported. In addition, Jak emus are one of the few emus that can use the --gs-adaptive-frameskip=1 command. It is often referred to as "Jak v2" 2.2 JakX, Jak 2, Jak 3,
Art of Fighting Anthology Similar to RECVX. It was successful in fixing "Coraline." Sometimes called "AOFA" 2.0
Resident Evil - Code: Veronica Fixes games like Jackie chan Adventures, SpongeBob SquarePants: Creature From the Krust Krab, Pac-man World 3, Yu-Gi-Oh: Capsule monsters, SpongeBob's Atlantis SquarePantis freezing at a black/splash screen. Additionally, it fixes many games requiring OPL's mode 2. Often referred to as "RECVX" 1.7 Fatal Fury, Redfaction, AOFA.
Fatal Fury Battle Archives: Volume 2 Similarly to RECVX, it is often used to fix frozen games.
2016
Red Faction It is prominently used to fix VU1 sensitive games. It was used to fix Tony Hawk games suddenly crashing, as well as MTVU sensitive games such as Star Wars Battlefront II. 1.6 Max payne
Forbidden Siren The only emulator to fix Ice age 2 being stuck at splash screen. It also fixed Gran turismo 4 running abysmally slow. 0.1
King of Fighters 2000 Seemingly one of the most VU-accurate emus, fixing sps in games such as Crash Twinsanity, Rayman 3, Crazy Frog Racer. It also prevents Koei tecmo games from suddenly freezing when battle starts. Moreover, it is likely the only emulator where Batman Begins does not crash. Often referred to as "KOF2000" 1.2 Roguev1, KOF98, Okage
Destroy All Humans! Fixed Tenchu: Fatal Shadows' crashing. 0.1
Destroy All Humans! 2 0.7
Rise of the Kasai It fixed most of the Harry Potter games. Often referred to as "rotk". 0.2
2015
War of the monsters v1 Subjectively the best emulator to use. Used as PS2CLASSICSGUI's default emulator, it is the best one around for accurate gs emulation, as some graphical issues on the Ratchet series and Tekken 5 can only be fixed by it. Another interesting case is GTA SA's lack of need for auto flush on it, and being natively performant. Additionally, its VU0 timing is much better than Jakv2's, making it one of the best emulators on the PS4. 0.1 Rogue v1 and v2, Arc the Lad, Star Wars Jedi Starfighter
GTA III Fixed the PAL version of Genji: Dawn of the Samurai. 0.6
PaRappa the Rapper 2 The only emulator to boot Spyro: A Hero's Tail. 0.1
Star Wars Racers Revenge Seemingly the closest emulator to the PS3's. Useful for debugging games as it also shows useful information such as pagefault. 0.4

XXXX-YYYYY_config.lua[edit | edit source]


It is the most powerful configuration on the emulator, it allows for direct patching of EE/IOP/VU memory, hooks registers, hook dma. Almost Everything can be done here.
If needed it can hook registers by using register names from alias files. Alias files (ee-cpr0-alias.lua, ee-gpr-alias.lua, ee-hwaddr.lua) are stored in lua_include folder, and can be included to config by using require ("alias file name").
Known functions: Require cleanup.

ApiRequest[edit | edit source]

The most important part of the LUA script. The LUA script will crash the game if used without it.
Command Usage Notes
apiRequest apiRequest(0.1) apiRequest(<api version>)

Different emu versions support different highest api. Calling api is mandatory. some commands require higher version. Highest known version is 2.3 api from JAK 2,3,X game emulator.

(Emulator) EmuObject[edit | edit source]
 Commands for the emulator
Command Usage Notes
Object calling class
getEmuObject local emuObj = getEmuObject() Required for all functions using emuObj, that include:
LoadConfig SaveConfig GetPad AddVsyncHook
RemoveVsyncHook AddEntryPointHook RemoveEntryPointHook
AddLoginHook RemoveLoginHook AddLogoutHook RemoveLogoutHook
CheckEntitlement AddImageHook AddGifTagHook SwapMemCard
SetFormattedCard OpenDiscTray CloseDiscTray SwitchDisc
EnableImposeMenu GetDiscId GetDiscTitleId
AddSectorReadHook AddMCWriteHook ShowDiscSwitchInfo GetPs4SystemLang SetPs2Lang
ThrottleNorm ThrottleFast ThrottleMax AddAssertionHook 
SetGsTitleFix SetDeinterlace SetDisplayAspectWide SetDisplayAspectNormal 
ForceRefreshRate LoadFsShader SetDisplaySafeArea PadSetLightBar 
AddPadHook PadPressureStickRemap SetVolumes GetVolumes 
SetAudioRoute GetAudioRoute AddSnapshotLoadedHook
RemoveSnapshotLoadedHook IsNeoMode IsToolingVerbose emuMediaPatch 
Hooks
AddVsyncHook emuObj.AddVsyncHook(<task to be done every vsync>) emuObj.AddVsyncHook(my_function)

my_function can be anything, from simple patches, to extensive hook. Example usage can be found in SLUS-21550 features file. some games are not compatible with it and will crash upon startup.

RemoveVsyncHook emuObj.RemoveVsyncHook(<previously added task to be removed>) emuObj.RemoveVsyncHook(my_function)
AddEntryPointHook emuObj.AddEntryPointHook(<task>) Task to be done at ps2 game main elf entry point (right where game is loaded).
RemoveEntryPointHook
AddLoginHook
RemoveLoginHook
AddLogoutHook
RemoveLogoutHook
AddImageHook
AddGifTagHook
AddSectorReadHook emuObj.AddSectorReadHook(<sector, unk, task>) Hook to do task when disc image sector is read. Not all values are known (ex. emuObj.AddSectorReadHook(776480, 32, <task/function>) )
AddMCWriteHook emuObj.AddMCWriteHook()
AddAssertionHook emuObj.AddAssertionHook()
AddSnapshotLoadedHook
RemoveSnapshotLoadedHook
AddPadHook emuObj.AddPadHook()
Audio
SetVolumes emuObj.SetVolumes('global', 'main', 'bgm') Set volume, usually setting global is enough. Example: emuObj.SetVolumes(0.31, 1.0, 1.0) values, in floats 1.0 = 100%
GetVolumes emuObj.GetVolumes() Return current volume levels for ('global', 'main', 'bgm') in floating point values.
SetAudioRoute
GetAudioRoute
Game loading speed
ThrottleNorm emuObj.ThrottleNorm() Enable default framelimiter (50/60 fps depend on region).
ThrottleFast emuObj.ThrottleFast() Faster than default, but exact value is unknown.
ThrottleMax emuObj.ThrottleMax() Disable framelimiter during loading screens.
CDVD
OpenDiscTray
CloseDiscTray
SwitchDisc emuObj.SwitchDisc(<disc ID>) ID can be provided as is, or for example read from memory or register when needed.
GetDiscId emuObj.GetDiscId() Return DiscId in XXXX_YYY.ZZ format
GetDiscTitleId
ShowDiscSwitchInfo emuObj.ShowDiscSwitchInfo()
Other
EnableImposeMenu emuObj.EnableImposeMenu(<true/false>) EnableImposeMenu(false)
LoadConfig emuObj.LoadConfig( 0 or 1 ) emuObj.LoadConfig(0)
SaveConfig emuObj.LoadConfig( 0 or 1 ) emuObj.LoadConfig(0)
GetPad emuObj.GetPad(<gamepad button by bits>) example usage for reading input:
local CheckInputs = function()

local pad_bits = emuObj.GetPad()
local UP		= pad_bits &  0x0010
local DOWN		= pad_bits &  0x0040
local LEFT		= pad_bits &  0x0080
local RIGHT		= pad_bits &  0x0020
local Triangle		= pad_bits &  0x1000
local Cross		= pad_bits &  0x4000
local Square		= pad_bits &  0x8000
local Circle		= pad_bits &  0x2000
local L1		= pad_bits &  0x0400
local L2		= pad_bits &  0x0100
local L3		= pad_bits &  0x0002
local R1		= pad_bits &  0x0800
local R2		= pad_bits &  0x0200
local R3		= pad_bits &  0x0004
local Select		= pad_bits &  0x0001
local Start		= pad_bits &  0x0008	

if (L2 ~= 0) then
	<here function that should be done when L2 is pushed>
end
	
end

emuObj.AddVsyncHook(CheckInputs) <to trigger check at every vsync>
SwapMemCard
SetFormattedCard emuObj.SetFormattedCard(<"file name">) emuObj.SetFormattedCard("custom_formatted.card")
Allow to use custom memory card. 
GetPs4SystemLang emuObj.GetPs4SystemLang() Return PS4 system language (in unknown format).
SetPs2Lang emuObj.SetPs2Lang(<Lang ID>) Set emulated PS2 language, correct Lang IDs are 0-18. In some cases, games will hang on a black screen with some other language settings (eg Japanese) - Example for usage: emuObj.SetPs2Lang(1)
0 - japanese
1 - english
2 - french
3 - spanish
4 - german
5 - italian
6 - dutch
7 - portuguese
8 - russian
9 - korean
10 - traditonal-chinese
11 - simplified-chinese
12 - finnish
13 - swedish
14 - danish
15 - norwegian
16 - polish
17 - portuguese-brazil
18 - english-uk
PadSetLightBar emuObj.PadSetLightBar(<port, red, green, blue>) Set DS4 light bar color. The correct port values are 0-3, correct light values are 0-255.
PadPressureStickRemap emuObj.PadPressureStickRemap()
IsNeoMode emuObj.IsNeoMode() Check that PS4 run in NEO (PRO) mode. Return 1/0
IsToolingVerbose
CheckEntitlement
emuMediaPatch emuMediaPatch(disc sector, 12/24 + offset, { original data }, { replace data }) Replace 4 bytes from loaded iso file. For unknown reason we always need to add 12 to real offset for DVD game, and 24 for CD game.
GS related
CountFrameOnPS2 emuObj.CountFrameOnPS2() updates FRAPS/Actual FPS reading in olympus
SetGsTitleFix emuObj.SetGsTitleFix() More info
SetDisplayAspectWide emuObj.SetDisplayAspectWide() Force display area to 16:9 (If game not support widescreen, it will be stretched).
SetDisplayAspectNormal emuObj.SetDisplayAspectNormal() Force display area to 4:3.
ForceRefreshRate emuObj.ForceRefreshRate(<hz>) emuObj.ForceRefreshRate(50) correct values are 0, 50, 60 where 0 = default.
LoadFsShader emuObj.LoadFsShader(<slot?>, "<path>")
Shaders must be loaded right after GS has been initialized. 
Example:
Global_InitGpuResources = function()
	emuObj.LoadFsShader(1, "./shader.sb")
end

That only load Fragment Shader to program memory, to use it we need BindFragmentShader, 
and if depend on shader SetShaderParams.
SetDisplaySafeArea
(EE) EEObject[edit | edit source]
Commands for the emulated Emotion Engine
Command Usage Notes
Object calling class
getEEObject local eeObj = getEEObject() Required for all functions using eeObj
Memory editing
ReplaceMem64 eeObj.ReplaceMem64(<address>, <value>)
ReplaceMem32 eeObj.ReplaceMem32(<address>, <value>) Permanently replace an offset without needing addvsynchook?
ReplaceMem16 eeObj.ReplaceMem16(<address>, <value>)
ReplaceMem8 eeObj.ReplaceMem8(<address>, <value>)
ReadMemFloat eeObj.ReadMemFloat(<address>) eeObj.ReadMemFloat(0x258c3c)
WriteMemFloat eeObj.WriteMemFloat(<address>, <value>) eeObj.WriteMemFloat(0x365364, 1.3333333)
ReadMem128
eeObj.ReadMem128(<ee memory offset>)
Read 16 bytes from offset, examples: eeObj.ReadMem128(0x100198)
ReadMemFloat128
eeObj.ReadMemFloat128(<ee memory offset>)
return 16 bytes from offset in float form
WriteMem128
WriteMemFloat128
ReadMem64
eeObj.ReadMem64(<ee memory offset>)
Read 8 bytes from offset, examples: eeObj.ReadMem64(0x100198)
WriteMem64
eeObj.WriteMem64(<ee memory offset>, <data>)
ReadMem32
eeObj.ReadMem32(<ee memory offset>)
Read 4 bytes from offset, examples: eeObj.ReadMem32(0x100198)

eeObj.ReadMem32(gp - 31348)

WriteMem32
eeObj.WriteMem32(<ee memory offset>, <data>)
Write 4 bytes to offset, example: eeObj.WriteMem32(0x2c89ac, 0x001b70f0)
ReadMem16
eeObj.ReadMem16(<ee memory offset>)
Read 2 bytes from offset, example: eeObj.ReadMem16(0x100198)
WriteMem16
eeObj.WriteMem16(<ee memory offset>, <data>)
Write 2 bytes to offset, example: eeObj.WriteMem16(0x2c89ac, 0x70f0)
ReadMem8
eeObj.ReadMem8(<ee memory offset>)
Read 1 byte from offset, example: eeObj.ReadMem8(0x100198)
WriteMem8
eeObj.WriteMem8(<ee memory offset>, <data>)
Write 1 byte to offset, example: eeObj.WriteMem8(0x2c89ac, 0xf0)
ReadMemStr eeObj.ReadMemStr(address/register) Read string from address until null terminator
WriteMemStr eeObj.WriteMemStr(address, string)
WriteMemStrZ eeObj.WriteMemStrZ(string pointer, string) . Pointer can be read from GPR
GPR require (Necessary for register related commands)
local gpr = require( "ee-gpr-alias" )
GetGpr64 eeObj.GetGPR64(<gpr register>) example: eeObj.GetGPR64(t3)
SetGpr64
GetGprFloat Get gpr value as float value
SetGprFloat Set gpr value as float value
GetGpr eeObj.GetGPR(<gpr register>) eeObj.GetGPR(t3)
SetGpr eeObj.SetGPR(<gpr register> ,<value>) example: eeObj.SetGPR(gpr.a3 ,1)

Require defined getEEObject() as eeObj

GetFprHex eeObj.GetFprHex(<FPU register (0-31)>) Get/return floating point register value as hex string
SetFprHex eeObj.SetFprHex(<FPU register (0-31), value (u32)>) Set floating point register value as hex string
GetFpr eeObj.GetFpr(<register number>) example eeObj.GetFpr(14)
SetFpr eeObj.SetFpr(<fpr register number>, <value>) Simple example eeObj.SetFpr(14, 50.0) will set frp 14 to 50.0

But we can also combine commands to add/sub from registers eeObj.SetFpr(14, eeObj.GetFpr(14) + 50.0) this will add 50.0 to current fpr 14 value

GetPc eeObj.GetPc() This command is very helpful as it will return to you the current EE address that's being read. Can be used also with additional var. like eeObj.GetPc()+4
SetPc eeObj.SetPC(<PC>) eeObj.SetPC(0x266B80)
GetCPR0 eeObj.GetCPR0(<COP0 register>)
SetCPR0 eeObj.SetCPR0(<COP0 register>)
Hooks
AddHook eeObj.AddHook(<ee offset>, <original opcode>, <definied hook name>) example:
local W1 = 
	function()
		emuObj.SetDisplayAspectNormal()
	end

local ws1 = eeObj.AddHook(0x1c9840, 0xaf808c78, W1)
RemoveHook
AddPreHook
AddPostHook
RemovePreHook
RemovePostHook
AddJitResetHook
RemoveJitResetHook
AddHookJT eeObj.AddHookJT(Offset, offset opcode, function) Seems be a hook related to the jit
Dma
DmaAddHook
eeobj.DmaAddHook(channel=%d key=%x)
Possible Dma channel numbers (?)
 GIF = 0 VIF0 = 1 
VIF1 = 2 SIF0 = 4 
SIF1 = 5 IPU0 = 6
IPU1 = 7  

Possible values for hooks

DmaTransfer [VIF0/VIF1], RaiseIntc [VIF0/VIF1], NormalTransfer [SIF0/SIF1]. 
DmaRemoveHook
Speedhacks
FastForwardClock eeObj.FastForwardClock() Skip Emotion Engine cycles?
eeObj.AddHook(0x002cc350, 0x78a30000, function()
          eeObj.FastForwardClock()
end)
AdvanceClock eeObj.AdvanceClock() Likely skips an allocated amount of EE cycles.
eeObj.AddHook(0x002cc350, 0x78a30000, function()
          eeObj.AdvanceClock(21000)
end)
GetClock eeObj.GetClock() Returns the value of how many cycles the EE is ahead of normal clock (?)
Vu1MpgCycles eeObj.Vu1MpgCycles(<cycles>) Works just like the cli command --vu1-mpg-cycles=
Other
CallPredicate
SchedulerDelayEvent eeObj.SchedulerDelayEvent("event", cycles)
Example:
eeObj.AddHook(0x0033A4DC,0xAC430000, function() eeObj.SchedulerDelayEvent("gif.dma", 0x10500) end)
Parrapa use eeObj.SchedulerDelayEvent("vif1.dma", 0x6500) other events are gif.dma, vif0.dma, vif1.dma, sif0.dma, Sif0-NormalTransfer, sif1.dma, Sif1-NormalTransfer, ipu0.dma, ipu1.dma . This command allows for the delayment of certain DMA transfer by cycles.
WaitVu1 eeObj.WaitVu1() Likely to be the lua equivalent of "--vu1=jit-sync".
GetPcRingBuffer
Precompile Requires unknown values
CalcInsnHash
getOverlayObject eeObj.getOverlayObject() local eeOverlay = eeObj.getOverlayObject()
GetVif1Cycles eeObj.GetVif1Cycles() local vif1_cycles = eeObj.GetVif1Cycles() create vif_cycles value that can be used later. You can rename it as you wish.
SetGsTitleFix[edit | edit source]
One of the most important LUA commands. It modifies the Graphics Synthesizer's behavior.

Part of EmuObject() class, it's frequently used in official configs.

Examples

-- fix vision logo (Wild Arms 3)
local thresholdArea = 0 -- ignore alls items : fix #112276
emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , {  texType = 3, cbp = 0x2390, tbp = 0x288000} )
------------------------------------------------------------------------------------------------------
-- Ignore up-render shift for triangles when writing mask = write alpha only . Will fix shadows (bug# 6724).
emuObj.SetGsTitleFix( "ignoreUpShiftTri", "reserved" , { fbmask = 0x00FFFFFF  } )
------------------------------------------------------------------------------------------------------
--  Performance  fix ( bug# 9474 )
if 0 then   -- emuObj.IsNeoMode() then  -- neo mode check disabled, due to bug #10442
    emuObj.SetGsTitleFix( "globalSet",  "reserved", { workLoadThreshold = 125000} )
else
    emuObj.SetGsTitleFix( "globalSet",  "reserved", { workLoadThreshold = 100000} )
end
------------------------------------------------------------------------------------------------------
-- bug# 9972
emuObj.SetGsTitleFix( "ignoreSubBuffCov", "reserved", { } )
------------------------------------------------------------------------------------------------------
-- Bully bug 9392
-- Performace fix
local thresholdArea = 600
emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , {alpha=0x80000044 , zmsk=1 , tw=4, th=4  } )
------------------------------------------------------------------------------------------------------
-- Bug#9174 -
emuObj.SetGsTitleFix( "ignoreSubBuffCov", "reserved", { } )
------------------------------------------------------------------------------------------------------
-- Bug#9240 (Light maps uprender)
-- Copy z-buffer for future use with light maps. psm = SCE_GS_PSMZ24 (49)
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", {tw=9, th=9, psm=49, zmsk=1 } )
------------------------------------------------------------------------------------------------------
-- Apply light maps texMode=2 (bilinear)   psm= SCE_GS_PSMCT32 (0)
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", {tw=8, th=8, psm=0, ztst=1, texMode=2 } )
------------------------------------------------------------------------------------------------------
-- Performace fix (bug #9785 )
emuObj.SetGsTitleFix( "globalSet",  "reserved", { waveThreshold = 90000} )
emuObj.SetGsTitleFix( "ignoreAreaUpdate", 0, { } )
------------------------------------------------------------------------------------------------------
-- Accumulate fill area only when conditions are met
emuObj.SetGsTitleFix( "includeAreaUpdate", "reserved" , {alphaIsNot = 0, zmsk = 1, tw = 6, th = 6 , tbp = 0x00302000} )
emuObj.SetGsTitleFix( "ignoreUpRender", 130 , { totalArea= 700} )
------------------------------------------------------------------------------------------------------
-- Fix shadow
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1  } )
------------------------------------------------------------------------------------------------------
-- Reduce flush count
emuObj.SetGsTitleFix( "SetSelfRender", "reserved", { fbmask= 0x00FFFFFF , renderSelf=1 , zmsk=1 , alpha=0 , texMode=1  } )
------------------------------------------------------------------------------------------------------
-- Disable post-processing
emuObj.SetGsTitleFix( "ignoreSprite", "reserved", {  texType=1 , tw=5 , th=8, zmsk=1 , alpha=0x80000044  } )
------------------------------------------------------------------------------------------------------
-- Small triangle rejection. Works in conjunction with CLI setting   gs-override-small-tri-area=1
-- keep default area for texture 256x256 ( no blend)  (Anakin face)
emuObj.SetGsTitleFix( "setRejectionArea", 500,{twIsNot=8, thIsNot=8 } )
------------------------------------------------------------------------------------------------------
-- Set triangle rejection area= 1000  when alpha blend is not 0 ( i.e blend is On)
emuObj.SetGsTitleFix( "setRejectionArea", 1000, {alphaIsNot=0 } )
------------------------------------------------------------------------------------------------------
-- Performace fix
local thresholdArea = 600
emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , {alpha=0x80008068 , zmsk=1 } )
------------------------------------------------------------------------------------------------------
-- Performace fix
local thresholdArea = 700
emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , {alpha=0x80000044 , zmsk=1 } )
------------------------------------------------------------------------------------------------------
-- Disable uprender on the draw command which samples the framebuffer (0x3200) using bilinear sampling (texMode=2)
-- All lighting effects use TriFan prim type, so use that as well to filter against.
emuObj.SetGsTitleFix( "forceSimpleFetch",  "reserved", {prim=5, texMode=2, tbp=0x320000} )


Commands

Command Example Notes Values
globalSet emuObj.SetGsTitleFix( "globalSet", "reserved", { packedRegsLo = 0x42,packedRegsHi = 0, packedRegsNum = 2, packedFlags = 3, packedPrim = 5}) used with workLoadThreshold or waveThreshold or loadThreshold
reserved
ignoreSubBuffCov ignore ? buffer coverage
ignoreUpRenderTimeout emuObj.SetGsTitleFix( "globalSet", "reserved", {ignoreUpRenderTimeout=2} )
ignoreAreaUpdate emuObj.SetGsTitleFix( "ignoreAreaUpdate", 0, { alpha=0x80000048 } )
ignoreSprite emuObj.SetGsTitleFix( "ignoreSprite", "reserved", { texType=1 , tw=5 , th=8, zmsk=1 , alpha=0x80000044 } )
ignoreUpShiftTri emuObj.SetGsTitleFix( "ignoreUpShiftTri", "reserved", {psm=0} )
clipScissors emuObj.SetGsTitleFix( "clipScissors", "reserved", {alpha = 0 , frameW = 4 , psm = 0} )
trianglesAsParticles emuObj.SetGsTitleFix( "trianglesAsParticles", "reserved", { hasClut=1,zmsk=1 } )
SetSelfRender emuObj.SetGsTitleFix( "SetSelfRender", "reserved", { fbmask= 0x00FFFFFF , renderSelf=1 , zmsk=1 , alpha=0 , texMode=1 } )
forceBiLinear
forcePoint emuObj.SetGsTitleFix( "forcePoint", "reserved", {mipIsGt=0, mmin=0} )
forceSimpleFetch emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", {psm=0} ) Used frequently to fix graphical corruptions
forcePointSampling emuObj.SetGsTitleFix( "forcePointSampling", "reserved", {alpha = 0x80000048, twIsLess=5, thIsLess=5 } )
setRejectionArea emuObj.SetGsTitleFix( "setRejectionArea", 1000, { } )
ignoreUpRender emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , { texType = 3, cbp = 0x2390, tbp = 0x288000} ) Ignore uprender for texture type described in params
includeAreaUpdate
fetchFromCurrBuff emuObj.SetGsTitleFix( "fetchFromCurrBuff", "reserved", {psm=0} )
skipPacked emuObj.SetGsTitleFix( "skipPacked", "reserved", { alpha = 0x80000044, tbp = 0x3a4000 , zmsk=1 })
changeAlpha


Arguments/variables

Argument Usage Notes
Variable
alpha_mask
texType {texType = 3} (1-3, more? )
texMode 1 - Point? , 2 - bilinear
Argument
alphaIsNot alpha - is not X
twIsLess texture width - is less than X
thIsLess texture height - is less than X
twIsNot texture width - is not X
thIsNot texture width - is not X
psmIsNot texture pixel storage format - is not X
PSMCT32  = 0   PSMT4HL = 36
PSMCT24  = 1   PSMT4HH = 44
PSMCT16  = 2   PSMZ32  = 48
PSMCT16S = 10  PSMZ24  = 49
PSMT8    = 19  PSMZ16  = 50
PSMT4    = 20  PSMZ16S = 58
PSMT8H   = 27  
primIsNot GS primitive type - is not
Point         = 0
Line          = 1
LineStrip     = 2
Triangle      = 3
TriangleStrip = 4
TriangleFan   = 5
Sprite        = 6
mipIsGt mip level is grater than X (?)
Needs wikify
zmsk Z (depth) draw mask
update Z buffer       = 0
don't update Z buffer = 1

When 1 depth test result will be ignored
tw texture width
th texture height
ztst Z (depht) test method
ZNOUSE   = 0
ZALWAYS  = 1
ZGEQUAL  = 2
ZGREATER = 3

0 -                       All pixels fail
1 -                       All pixels pass
2 - Pass if Z grater or equal to Z buffer
3 -        Pass if Z grater than Z buffer
mmin MMIN flag
NEAREST                = 0
LINEAR                 = 1
NEAREST_MIPMAP_NEAREST = 2
NEAREST_MIPMAP_LINEAR  = 3
LINEAR_MIPMAP_NEAREST  = 4
LINEAR_MIPMAP_LINEAR   = 5
prim GS primitive type
Point         = 0
Line          = 1
LineStrip     = 2
Triangle      = 3
TriangleStrip = 4
TriangleFan   = 5
Sprite        = 6
fillArea
frameW
renderSelf
hasClut
alphaTest
primTest
workLoadThreshold
alpha
 example: alpha=0x80000044
alpha=0
tbp texture base pointer
cbp {cbp = 0x2390} CLUT buffer base pointer
psm {psm=0} texture pixel storage format
PSMCT32  = 0   PSMT4HL = 36
PSMCT24  = 1   PSMT4HH = 44
PSMCT16  = 2   PSMZ32  = 48
PSMCT16S = 10  PSMZ24  = 49
PSMT8    = 19  PSMZ16  = 50
PSMT4    = 20  PSMZ16S = 58
PSMT8H   = 27  
mxl maximum mip level (0-6)
fbmask { fbmask= 0x00FFFFFF} Framebuffer mask(?)
totalArea
packedRegs
packedRegsLo
packedRegsHi
packedRegsNum
packedFlags
packedPrim
areaNumFrames
waveThreshold
loadThreshold
fixSpriteDivTab
(IOP) IOPObject[edit | edit source]
Commands for the emulated input-output processor
Command Usage Notes
Object calling class
getIOPObject local iopObj = getIOPObject() Required for all functions using iopObj, that include:
ReplaceMem64 ReplaceMem32 ReplaceMem16 ReplaceMem8 ReadMemFloat
 WriteMemFloat WriteMem64 WriteMem32 WriteMem16 WriteMem8
 ReadMemStr AddHook RemoveHook GetGpr SetGpr GetPc SetPc
 GetCPR0 SetCPR0
Memory editing
ReplaceMem64 iopObj.ReplaceMem64(<address>, <value>)
ReplaceMem32 iopObj.ReplaceMem32(<address>, <value>)
ReplaceMem16 iopObj.ReplaceMem16(<address>, <value>)
ReplaceMem8 iopObj.ReplaceMem8(<address>, <value>)
ReadMemFloat iopObj.ReadMemFloat(<address>) iopObj.ReadMemFloat(0x28c3c)
WriteMemFloat iopObj.WriteMemFloat(<address>, <value>) iopObj.WriteMemFloat(0x65364, 1.3333333)
ReadMem128 iopObj.ReadMem128(<iop memory offset>)
WriteMem128 iopObj.WriteMem128(<iop memory offset>, <value>)
ReadMemFloat128 iopObj.ReadMemFloat128(<iop memory offset>)
WriteMemFloat128 iopObj.WriteMemFloat128(<iop memory offset>, <value>)
ReadMem64
iopObj.ReadMem64(<iop memory offset>)
Read 8 Bytes From offset
WriteMem64
iopObj.WriteMem64(<iop memory offset>, <data>)
Write 8 Bytes From offset
ReadMem32
iopObj.ReadMem32(<iop memory offset>)
Read 4 bytes from offset, examples: iopObj.ReadMem32(0x1198)

iopObj.ReadMem32(gp - 348)

WriteMem32
iopObj.WriteMem32(<iop memory offset>, <data>)
Write 4 bytes to offset, example: iopObj.WriteMem32(0x89ac, 0x001b70f0)
ReadMem16
iopObj.ReadMem16(<iop memory offset>)
Read 2 bytes from offset, example: iopObj.ReadMem16(0x1198)
WriteMem16
iopObj.WriteMem16(<iop memory offset>, <data>)
Write 2 bytes to offset, example: iopObj.WriteMem16(0x89ac, 0x70f0)
ReadMem8
iopObj.ReadMem8(<iop memory offset>)
Read 1 byte from offset, example: iopObj.ReadMem8(0x1198)
WriteMem8
iopObj.WriteMem8(<iop memory offset>, <data>)
Write 1 byte to offset, example: iopObj.WriteMem8(0x89ac, 0xf0)
ReadMemStr
GetGpr iopObj.GetGPR(<gpr register>) iopObj.GetGPR(a1)
SetGpr iopObj.SetGPR(<gpr register> ,<value>) example: iopObj.SetGPR(gpr.v0 ,3)
GetPc iopObj.GetPc() can be used also with additional var. like iopObj.GetPc()+8
SetPc iopObj.SetPC(<PC>) iopObj.SetPC(0x6B80)
GetCPR0 iopObj.GetCPR0(<COP0 register>)
SetCPR0 iopObj.SetCPR0(<COP0 register>)
Clock speed
FastForwardClock iopObj.FastForwardClock()
iopObj.AddHook(0x002cc350, 0x78a30000, function()
          iopObj.FastForwardClock()
end)
AdvanceClock iopObj.AdvanceClock() Skip an allocated amount of IOP cycles
iopObj.AddHook(0x002cc350, 0x78a30000, function()
          iopObj.AdvanceClock(21000)end)
GetClock iopObj.GetClock() Returns the value of cycles the iop is ahead of (?)
Hooks
AddHook iopObj.AddHook()
RemoveHook iopObj.RemoveHook()
(GS) GsObject[edit | edit source]
Commands for the emulated Graphics Synthesizer
Command Usage Notes
Object calling class
getGsObject local gsObj = getGsObject()
Graphical fixes / Improvement
SetL2HMode gsObj.SetL2HMode(true) (true) and (false) are only known options
SetUprenderMode gsObj.SetUprenderMode(1) Set uprender mode. Overrides CLI, 0=none, 1=2x2
SetUpscaleMode gsObj.SetUpscaleMode("EdgeSmooth") Sets upscale mode. Overrides CLI
GetFramesInQueue gsObj.GetFramesInQueue() Returns the value of the frames that are still in queue
SetFrameSkipping gsObj.SetFrameSkipping(true) false and true are the values.
SetDeinterlaceShift gsObj.SetDeinterlaceShift(0) The values are 1 and 0, Enable or disable interlacing, requires emulators with high api
Does not require Object calling or Unknown[edit | edit source]
Command Usage Notes
eeInsnReplace eeInsnReplace(EE memory offset, Original opcode (BE), Replace opcode (BE)) Replace 4 bytes opcode in ee memory, correct memory range is 0x0 to 0x1FFFFFFF
vuInsnReplace
vuInsnReplace(vu 0/1, vu memory offset divided by 8, (original opcode<<32) | original opcode, (replace opcode<<32) | replace opcode) 
Replace 2 x 4 bytes in VU memory, correct memory range depend on selected VU, left shift by 32 is used for VU lower opcodes. Command will fail if size is above 254.
example:
vuInsnReplace(0, 0x167, (0x000002ff << 32) | 0x520507ff,(0x000002ff << 32) | 0x8000033c)
Replace 64 bits of VU0 at offset 0xB38
iopInsnReplace iopInsnReplace(IOP memory offset, Original opcode, opcode replacement) Replace 4 bytes in iop memory, correct memory range is 0x0 to 0x1FFFFF, iopInsnReplace(0x1FFFFF, 0x0, 0x0803fff0)
eeNativeFunction eeNativeFunction(<ee offset>, <original opcode>, <function>) eeNativeFunction(0x11fa9c, 0x0080402d, 'memcpy')

Different emulators can have different functions included, vide SO3. Require api 1.4 or higher. But functions from this list should be available in every emu:

ieee754_acosf ieee754_asinf ieee754_sqrtf
fabs cosf fabsf
sinf acosf asinf
sqrtf fptoui fptodp
litodp dptoli dptofp
memcpy memset strlen
eeNativeHook eeNativeHook(<ee ofset>, <original opcode>, <action>) eeNativeHook require apiRequest(1.4) or higher.
GsCustomShader
Unlock
IsUnlocked
InsnOverlay InsnOverlay({<opcode, opcode, opcode...>}) example:
InsnOverlay({
	0x27bdfff0, -- addiu $sp, -0x10
	0xffbf0000, -- sd $ra, 0(sp)
	0xffb00008, -- sd $s0, 8(sp)
	0x3c05000f, -- lui $a1, 0x000f
	0x34a57000, -- ori $a1, 0x7000
	0x0c0db8b6, -- jal Script::State::DoString
	0x0080802d, -- move $s0, $a0
	0x24050001, -- li $a1, 1
	0x0c0dba4c, -- jal Script::State::IsNull(int)
	0x0200202d, -- move $a0, $s0
	0xdfb00008, -- ld $s0, 8(sp)
	0xdfbf0000, -- ld $ra, 0(sp)
	0x03e00008, -- jr ra
	0x27bd0010  -- addiu $sp, 0x10
})
eeDebugBreak
CsBindShader
CsSetParamInt32
CsSetParamFloat
CsResetContext
CsPrintContext
PsBindShader
PsSetParamInt32
PsSetParamFloat
PsResetContext
PsPrintContext
Note: eeObj, emuObj, gsObj, etc. are described as required but this is not really true. You can set the functions locals that they use as whatever you want, but due to the specificity of that emulator, it will be better to keep official naming used in official configs.
Other objects[edit | edit source]
Command Usage Notes
getGLSObject class
getGLSObject
Enable
EnableServerRecording
Pause
getAudioObject class
getAudioObject
muteStreamingAll
muteStreamingMain
muteStreamingBGM
getRemotePlayObject class
getRemotePlayObject
Enable
getVideoRecordingObject class
getVideoRecordingObject
Enable
getSharePlayObject class
getSharePlayObject
Enable
getSpriteObject group
getSpriteObject
Enable
Disable
BindFragmentShader
SetShaderParams
 Is not clear that params depend on shader, or are somehow hardcoded.
Example usage:

local sprite0 = getSpriteObject(0)
local scanlineParams = {
	240.0,		-- float scanlineCount
   	0.7,		-- float scanlineHeight;
	1.5,        -- float scanlineBrightScale;
	0.5,        -- float scanlineAlpha;
	0.5         -- float vignetteStrength;
}

sprite0.SetShaderParams(scanlineParams)
BindTexture
SetPosXY
SetSizeXY
SetPosUV
SetSizeUV
PrintContext
SetBlendColor sprite<X>.SetBlendColor(<R,G,B,A>) in floats, max val. 1.0
local sprite0 = getSpriteObject(0)
sprite0.SetBlendColor(1.0,1.0,1.0,1.0)
getTrophyObject local trophyObj = getTrophyObject() Required for all functions using trophyObj
getDmaObject local dmaObj = getDmaObject() Depreciated API - use EE:DmaAddHook / EE:DmaRemoveHook instead. Is not clear when it was depreciated, JAK emu don't use it.
getScreenShotObject

Registers for hook[edit | edit source]

Registers defined in alias files.

GetGpr/SetGpr

gpr.zero gpr.at 
gpr.v0  gpr.v1 
gpr.a0  gpr.a1  gpr.a2  gpr.a3 
gpr.t0  gpr.t1  gpr.t2  gpr.t3 
gpr.t4  gpr.t5  gpr.t6  gpr.t7 
gpr.s0  gpr.s1  gpr.s2  gpr.s3 
gpr.s4  gpr.s5  gpr.s6  gpr.s7 
gpr.t8  gpr.t9
gpr.k0  gpr.k1 
gpr.gp  gpr.sp  gpr.fp  gpr.ra 
gpr.lo  gpr.hi  gpr.sa

example: eeObj.GetGpr(gpr.a1)

GetCPR0/SetCPR0

cpr.index	  cpr.pagemask
cpr.random	  cpr.wired	
cpr.entrylo0      cpr.badvaddr
cpr.entrylo1      cpr.count	
cpr.context	  cpr.entryhi	


cpr.compare	  cpr.config    cpr.taglo	
cpr.status	  cpr.badpaddr  cpr.taghi	
cpr.cause	  cpr.hwbk	cpr.errorepc
cpr.epc		  cpr.pccr	
cpr.prid

example: eeObj.GetCPR0(cpr.status) 


Official PS2 configuration examples[edit | edit source]

  • You can find the rest of the PS2 configurations in here.


Canis Canem Edit
SLES 535.61
LUA

require( "ee-gpr-alias" ) -- you can access EE GPR by alias (gpr.a0 / gpr["a0"])
apiRequest(0.1)
-- EA sports cricket 07 bug 9392
-- Performance fix
local emuObj = getEmuObject()	
local thresholdArea = 600
emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , {alpha=0x80000044 , zmsk=1 , tw=4, th=4  } )

Custom config.lua examples[edit | edit source]

Here is the first custom LUA configuration created by the community:

apiRequest(0.1)

-- Fix black screen SLUS-20064

eeInsnReplace(0x1CF3CC, 0x4100ffff, 0x00000000)	-- bc0f 0x1CF3CC to nop

This is a very basic command to replace a part of the EE memory with another instruction.

  • apiRequest(0.1) - Is required for every config. Used version depend on your original eboot highest supported api. 0.1 seems to be enough for basic patches like here. 2.3 is highest known for now.
  • -- Fix black screen SLUS-20064 is comment
  • eeInsnReplace(0x1CF3CC, 0x4100ffff, 0x00000000) is our true command here. We are replacing the value 0x4100FFFF to 0x00000000 at the offset of 0x1CF3CC . Like you can see we need to add what opcode is replaced. Not only patch, and memory offset.
  • -- bc0f 0x1CF3CC to nop is just another comment, in this case explaining what is changed

Other custom configurations made by users can be found here

Memory Map[edit | edit source]

Name From To
EE Flat Memory (4gb) 0x0000008000000000 0x0000008100000000
IOP Flat Memory (4gb) 0x0000009000000000 0x0000009100000000
R59 Binary Cache 0x0000000914B10000 0x0000000916B10000
R30 Binary Cache 0x0000000916B14000 0x0000000917314000
jitVU0 0x0000000917318000 0x0000000917B18000
jitVU1 0x0000000917B1C000 0x0000000918B1C000
Host's EE Memory Map
EE RAM - Kernel 0x0000008000000000 0x0000008000080000
EE RAM - Debug 0x0000008000078000 0x0000008000080000
EE RAM - User 0x0000008000080000 0x0000008002000000
EE Hw Devices 0x0000008010000000 0x0000008010010000
EE ROM 0x000000801FC00000 0x000000801FFE0000
EE RAM - Uncached 0x0000008020080000 0x0000008022000000
EE RAM - UncachedAccel 0x0000008030100000 0x0000008032000000
EE Scratchpad 0x0000008070000000 0x0000008070004000
EE Debug 0x00000080FFFF8000 0x0000008100000000
Host's IOP Memory Map
IOP RAM 0x0000009000000000 0x0000009000200000
IOP RAM (mirror 1) 0x0000009000200000 0x0000009000400000
IOP RAM (mirror 2) 0x0000009000400000 0x0000009000600000
IOP RAM (mirror 3) 0x0000009000600000 0x0000009000800000
IOP Scratchpad 0x000000901F800000 0x000000901F801000
IOP HW 0x000000901F801000 0x000000901F810000
IOP ROM 0x000000901FC00000 0x000000901FFE0000

Registers Map[edit | edit source]

EE-IOP[edit | edit source]

This list of registers is yet to be completed. Some registers are incorrectly named or include incorrect offsets. 0x1000000xxx base is not guaranteed in different emu revisions, but layout should be the same regardless. Assuming base is different (Like on kof2000), simply reduce these offsets by 8 hex values (IOP, VU0, and VU1 registers' offsets are static in all emulators).
List was designed for Jak v2
Eboot md5:c644f6879af225a6e5a70233fc4625a3
GPR-EE Address FPR Address CP0 Address GPR-IOP Address
zero 0x1000000000 f00 0x1000000230 Index 0x10000002D0 zero 0x1020000000
at 0x1000000010 f01 0x1000000234 Random 0x10000002D4 at 0x1020000004
v0 0x1000000020 f02 0x1000000238 EntryLo0 0x10000002D8 v0 0x1020000008
v1 0x1000000030 f03 0x100000023C EntryLo1 0x10000002DC v1 0x102000000C
a0 0x1000000040 f04 0x1000000240 Context 0x10000002E0 a0 0x1020000010
a1 0x1000000050 f05 0x1000000244 PageMask 0x10000002E4 a1 0x1020000014
a2 0x1000000060 f06 0x1000000248 Wired 0x10000002E8 a2 0x1020000018
a3 0x1000000070 f07 0x100000024C rsvd7 0x10000002EC a3 0x102000001C
t0 0x1000000080 f08 0x1000000250 BadVAddr 0x10000002F0 t0 0x1020000020
t1 0x1000000090 f09 0x1000000254 Count 0x10000002F4 t1 0x1020000024
t2 0x10000000A0 f10 0x1000000258 EntryHi 0x10000002F8 t2 0x1020000028
t3 0x10000000B0 f11 0x100000025C Compare 0x10000002FC t3 0x102000002C
t4 0x10000000C0 f12 0x1000000260 Status 0x1000000300 t4 0x1020000030
t5 0x10000000D0 f13 0x1000000264 Cause 0x1000000304 t5 0x1020000034
t6 0x10000000E0 f14 0x1000000268 EPC 0x1000000308 t6 0x1020000038
t7 0x10000000F0 f15 0x100000026C PRid 0x100000030C t7 0x102000003C
s0 0x1000000100 f16 0x1000000270 Config 0x1000000310 s0 0x1020000040
s1 0x1000000110 f17 0x1000000274 Iab 0x1000000314 s1 0x1020000044
s2 0x1000000120 f18 0x1000000278 Iabm 0x1000000318 s2 0x1020000048
s3 0x1000000130 f19 0x100000027C Dab 0x100000031C s3 0x102000004C
s4 0x1000000140 f20 0x1000000280 Dabm 0x1000000320 s4 0x1020000050
s5 0x1000000150 f21 0x1000000284 Dvm 0x1000000324 s5 0x1020000054
s6 0x1000000160 f22 0x1000000288 Dvbm 0x1000000328 s6 0x1020000058
s7 0x1000000170 f23 0x100000028C BadPAddr 0x100000032C s7 0x102000005C
t8 0x1000000180 f24 0x1000000290 Debug 0x1000000330 t8 0x1020000060
t9 0x1000000190 f25 0x1000000294 Perf 0x1000000334 t9 0x1020000064
k0 0x10000001A0 f26 0x1000000298 Pcr0 0x1000000338 k0 0x1020000068
k1 0x10000001B0 f27 0x100000029C Pcr1 0x100000033C k1 0x102000006C
gp 0x10000001C0 f28 0x10000002A0 TagLo 0x1000000340 gp 0x1020000070
sp 0x10000001D0 f29 0x10000002A4 TagHi 0x1000000344 sp 0x1020000074
fp 0x10000001E0 f30 0x10000002A8 ErrorEPC 0x1000000348 fp 0x1020000078
ra 0x10000001F0 f31 0x10000002AC Rsvd31 0x100000034C ra 0x102000007C
hi/hi1 (2x 64bit) 0x1000000200 fACC 0x10000002B0 COP0 additional registers pc 0x102000008C
lo/lo1 (2x 64bit) 0x1000000210 FPU CTRL (FCR) real Pcr0 0x1000000350 hi 0x1020000090 ??
sa 0x1000000220 cp1cond 0x10000002B4 real Pcr1 0x1000000358 lo 0x1020000094 ??
fpu ver 0x10000002B8
fpu sticky 0x10000002BC
fpu ctrl 0x10000002C0
2CF unknown 0x10000002C4

Emulator related registers[edit | edit source]

"Fake" registers Address Notes
(?) 0x1000000360 Locking the value seems to cause a crash.
Current PC
(4 Bytes)
0x1000000368 Shows the current offset that's being executed by the EE.

Updated only on branch/jump tests, unless commands such as --ee-pc-coherency or --ee-insn-flush-pc are used.
Then updates are instant, right when instructions are executed.
Commonly used by sceners as a way of finding troublesome offsets. Can be found in some emulators here too: 0x8000016830

(?) 0x100000036C
Updated on branch/jump instructions, emulator seems to use it to store next address that will be executed.
At least in recompiler to interpreter fallback mode. During tests it shows 0x80000184
Delta counter 0x1000000370
(Passed cycles, likely decrementer). 
Evt check is performed on branch test when 0.
Fastforwardclock set this to 0,
advanceclock subtract value from this fake reg)
Cycles 0x1000000378
(?) 0x1000000384
Address when last exception occurred on r5900.
This register most of times will hold last executed syscall address,
sometimes last tlb miss or break(if "as nop" is disabled).
Unlike the pc, this one doesn't change after a crash and has much lower latency.
Thus meaning it's better at diagnosing problems.

VU0 Registers[edit | edit source]

Register W Z Y X Register W Z Y X
vf00 0x103000000C 0x1030000008 0x1030000004 0x1030000000 vf17 0x103000011C 0x1030000118 0x1030000114 0x1030000110
vf01 0x103000001C 0x1030000018 0x1030000014 0x1030000010 vf18 0x103000012C 0x1030000128 0x1030000124 0x1030000120
vf02 0x103000002C 0x1030000028 0x1030000024 0x1030000020 vf19 0x103000013C 0x1030000138 0x1030000134 0x1030000130
vf03 0x103000003C 0x1030000038 0x1030000034 0x1030000030 vf20 0x103000014C 0x1030000148 0x1030000144 0x1030000140
vf04 0x103000004C 0x1030000048 0x1030000044 0x1030000040 vf21 0x103000015C 0x1030000158 0x1030000154 0x1030000150
vf05 0x103000005C 0x1030000058 0x1030000054 0x1030000050 vf22 0x103000016C 0x1030000168 0x1030000164 0x1030000160
vf06 0x103000006C 0x1030000068 0x1030000064 0x1030000060 vf23 0x103000017C 0x1030000178 0x1030000174 0x1030000170
vf07 0x103000007C 0x1030000078 0x1030000074 0x1030000070 vf24 0x103000018C 0x1030000188 0x1030000184 0x1030000180
vf08 0x103000008C 0x1030000088 0x1030000084 0x1030000080 vf25 0x103000019C 0x1030000198 0x1030000194 0x1030000190
vf09 0x103000009C 0x1030000098 0x1030000094 0x1030000090 vf26 0x10300001AC 0x10300001A8 0x10300001A4 0x10300001A0
vf10 0x10300000AC 0x10300000A8 0x10300000A4 0x10300000A0 vf27 0x10300001BC 0x10300001B8 0x10300001B4 0x10300001B0
vf11 0x10300000BC 0x10300000B8 0x10300000B4 0x10300000B0 vf28 0x10300001CC 0x10300001C8 0x10300001C4 0x10300001C0
vf12 0x10300000CC 0x10300000C8 0x10300000C4 0x10300000C0 vf29 0x10300001DC 0x10300001D8 0x10300001D4 0x10300001D0
vf13 0x10300000DC 0x10300000D8 0x10300000D4 0x10300000D0 vf30 0x10300001EC 0x10300001E8 0x10300001E4 0x10300001E0
vf14 0x10300000EC 0x10300000E8 0x10300000E4 0x10300000E0 vf31 0x10300001FC 0x10300001F8 0x10300001F4 0x10300001F0
vf15 0x10300000FC 0x10300000F8 0x10300000F4 0x10300000F0 ACC 0x103000020C 0x1030000208 0x1030000204 0x1030000200
vf16 0x103000010C 0x1030000108 0x1030000104 0x1030000100
Register Address Register Address
vi00 0x1030000210 Status 0x1030000310??
vi01 0x1030000220 MACflag 0x1030000320??
vi02 0x1030000230 Clipflag 0x1030000330??
vi03 0x1030000240 c2c19 0x1030000340??
vi04 0x1030000250 R 0x1030000350??
vi05 0x1030000260 I 0x1030000360
vi06 0x1030000270 Q 0x1030000590
vi07 0x1030000280 c2c23 0x1030000380??
vi08 0x1030000290 c2c24 0x1030000390??
vi09 0x10300002A0 c2c25 0x10300003A0??
vi10 0x10300002B0 TPC 0x10300003B0
vi11 0x10300002C0 CMSAR0 0x10300003C0??
vi12 0x10300002D0 FBRST 0x10300003D0
vi13 0x10300002E0 VPU-STAT 0x10300003E0??
vi14 0x10300002F0 CMSAR1 0x10300003F0??
vi15 0x1030000300 c2c30 0x1030000400??

VU1 Registers[edit | edit source]

Register W Z Y X Register W Z Y X
vf00 0x104000000C 0x1040000008 0x1040000004 0x1040000000 vf17 0x104000011C 0x1040000118 0x1040000114 0x1040000110
vf01 0x104000001C 0x1040000018 0x1040000014 0x1040000010 vf18 0x104000012C 0x1040000128 0x1040000124 0x1040000120
vf02 0x104000002C 0x1040000028 0x1040000024 0x1040000020 vf19 0x104000013C 0x1040000138 0x1040000134 0x1040000130
vf03 0x104000003C 0x1040000038 0x1040000034 0x1040000030 vf20 0x104000014C 0x1040000148 0x1040000144 0x1040000140
vf04 0x104000004C 0x1040000048 0x1040000044 0x1040000040 vf21 0x104000015C 0x1040000158 0x1040000154 0x1040000150
vf05 0x104000005C 0x1040000058 0x1040000054 0x1040000050 vf22 0x104000016C 0x1040000168 0x1040000164 0x1040000160
vf06 0x104000006C 0x1040000068 0x1040000064 0x1040000060 vf23 0x104000017C 0x1040000178 0x1040000174 0x1040000170
vf07 0x104000007C 0x1040000078 0x1040000074 0x1040000070 vf24 0x104000018C 0x1040000188 0x1040000184 0x1040000180
vf08 0x104000008C 0x1040000088 0x1040000084 0x1040000080 vf25 0x104000019C 0x1040000198 0x1040000194 0x1040000190
vf09 0x104000009C 0x1040000098 0x1040000094 0x1040000090 vf26 0x10400001AC 0x10400001A8 0x10400001A4 0x10400001A0
vf10 0x10400000AC 0x10400000A8 0x10400000A4 0x10400000A0 vf27 0x10400001BC 0x10400001B8 0x10400001B4 0x10400001B0
vf11 0x10400000BC 0x10400000B8 0x10400000B4 0x10400000B0 vf28 0x10400001CC 0x10400001C8 0x10400001C4 0x10400001C0
vf12 0x10400000CC 0x10400000C8 0x10400000C4 0x10400000C0 vf29 0x10400001DC 0x10400001D8 0x10400001D4 0x10400001D0
vf13 0x10400000DC 0x10400000D8 0x10400000D4 0x10400000D0 vf30 0x10400001EC 0x10400001E8 0x10400001E4 0x10400001E0
vf14 0x10400000EC 0x10400000E8 0x10400000E4 0x10400000E0 vf31 0x10400001FC 0x10400001F8 0x10400001F4 0x10400001F0
vf15 0x10400000FC 0x10400000F8 0x10400000F4 0x10400000F0 ACC 0x104000020C 0x1040000208 0x1040000204 0x1040000200
vf16 0x104000010C 0x1040000108 0x1040000104 0x1040000100
Register Address Register Address
vi00 0x1040000210 vi16 0x1040000310??
vi01 0x1040000220 vi17 0x1040000320??
vi02 0x1040000230 vi18 0x1040000330??
vi03 0x1040000240 vi19 0x1040000340??
vi04 0x1040000250 vi20 0x1040000350??
vi05 0x1040000260 vi21 0x1040000360
vi06 0x1040000270 vi22 0x1040000370??
vi07 0x1040000280 vi23 0x1040000380??
vi08 0x1040000290 vi24 0x1040000390??
vi09 0x10400002A0 vi25 0x10400003A0??
vi10 0x10400002B0 vi26 0x10400003B0
vi11 0x10400002C0 vi27 0x10400003C0??
vi12 0x10400002D0 vi28 0x10400003D0
vi13 0x10400002E0 vi29 0x10400003E0??
vi14 0x10400002F0 vi30 0x10400003F0??
vi15 0x1040000300 vi31 0x1040000400??

Open CL and Floats[edit | edit source]

In this part, we describe the PS4 native Floating point support and OpenCL information, for both CPU and GPU. The understanding of floating point conversion is very important for emulating the PS2. The information below came from this gist.

CPU[edit | edit source]

Info Value
Device Name CXD90026AG - DG1002FGF84HT
Device Vendor AuthenticAMD
Device Vendor ID 0x1022
Device OpenCL C Version OpenCL C 1.2 pocl
Device Type CPU
Max compute units 8
Max work item dimensions 3
Max work item sizes 4096x4096x4096
Max work group size 4096
Preferred work group size multiple 8
Half-precision Floating-point support (n/a)
Single-precision Floating-point support (core)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add No
Support is emulated in software No
Correctly-rounded divide and sqrt operations Yes
Double-precision Floating-point support (cl_khr_fp64)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add Yes
Support is emulated in software No
Execution capabilities
Run OpenCL kernels Yes
Run native kernels Yes
SPIR versions 1.2
Device Extensions
 cl_khr_byte_addressable_store
 cl_khr_global_int32_base_atomics
 cl_khr_global_int32_extended_atomics
 cl_khr_local_int32_base_atomics
 cl_khr_local_int32_extended_atomics
 cl_khr_3d_image_writes 
 cl_khr_spir
 cl_khr_fp64 
 cl_khr_int64_base_atomics
 cl_khr_int64_extended_atomics 

GPU[edit | edit source]

Info Values
Device Name AMD LIVERPOOL
Device Vendor AMD
Device Vendor ID 0x1002
Device Version OpenCL 1.1
Device OpenCL C Version OpenCL C 1.1
Device Type GPU
Max compute units 18
Max work item dimensions 3
Max work item sizes 256x256x256
Max work group size 256
Compiler Available Yes
Preferred work group size multiple 64
Half-precision Floating-point support (cl_khr_fp16)
Denormals No
Infinity and NANs Yes
Round to nearest Yes
Round to zero No
Round to infinity No
IEEE754-2008 fused multiply-add No
Support is emulated in software No
Single-precision Floating-point support (core)
Denormals No
Infinity and NANs Yes
Round to nearest Yes
Round to zero No
Round to infinity No
IEEE754-2008 fused multiply-add No
Support is emulated in software No
Correctly-rounded divide and sqrt operations No
Double-precision Floating-point support (cl_khr_fp64)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add Yes
Support is emulated in software No
Execution capabilities
Run OpenCL kernels Yes
Run native kernels No
Device Extensions
cl_khr_byte_addressable_store
cl_khr_byte_addressable_store
cl_khr_global_int32_base_atomics 
cl_khr_global_int32_extended_atomics
cl_khr_local_int32_base_atomics
cl_khr_local_int32_extended_atomics
cl_khr_int64_base_atomics
cl_khr_int64_extended_atomics
cl_khr_fp64
cl_khr_fp16

PS3 Configuration support[edit | edit source]

The PS2 emulator of the PS4 supports configurations in the known format from ps2_netemu/ps2classic that came from the PS3. This feature was officially used in Arc the Lad Twilight of the Spirits ps2-ps4 classic. To enable PS3 style configuration, add this to config-emu-ps4.txt:

--lopnor-config=1
--ps2-title-id=TITLE-ID

The configuration file needs to be in folder ...'''/patches/{TITLE-ID}/''' and the file need to have name '''{TITLE-ID}_lopnor.cfgbin'''. The Title ID needs to be in XXXX-YYYYY format (ex. SLUS-12345). Example path: /patches/SLUS-12345/SLUS-12345_lopnor.cfgbin. A tester confirmed that configurations work as is without even the need to edit them.
Please keep in mind that not all PS3 commands are recognized, only 0x01 (can depend upon emu revision), 0x09, 0x0A, 0x0B, 0x0F, 0x10, 0x26, 0x27 and 0x42.
For example, the Rayman 3 configuration does not work due to the command being unsupported on PS4.
Command 0x07 is NOT recognized, but can be manually translated to CLI configuration (to "--vu-xgkick-delay=value").
Same goes for command 0x11 (--vu0-accurate-addsub-range can be used).

Known issues[edit | edit source]

Issue Games affected Solution Description
No support for EE Cache Ice Age 2, DOA2: Extreme, Nascar 2009, Barnyard, Others Lua patches to the EE memory and picking the right emulator
Missing COP2 pipeline emulation. other games affected by COP2 timing Rearranging code through lua patches. While COP2 is a part of EE, in terms of emulation it's a separate processor that can run on its own. Consequently, some operations take a long time while EE still minds own its business. Some games abuse this and do their own thing, knowing that COP2 calculation takes an expected number of cycles. On this emu, every COP2 opcode is instant, which break games that expect it to take some time.
VU0 is not running in sync with EE core 24 The Game, ATV Quad Power Racing 2, Ghosthunter, Rayman Arena, Rayman 3, Largo winch, Ratchet and clank games. All games using M-bit. EE hook AdvanceClock or fastforwardclock commands on affected addresses to push VU0 ahead while stalling EE, setting the value of 5 to ee cycle scalar, and patches to rearrange code. Most of the time, it will be CTC2/QMTC2 instructions with interlock that are affected. Emulator kickstarts VU0 for 256 cycles, while reporting that 512 cycles passed. Yup, we are out of sync right from the start of VU0 mpg because people working for $ony don't know that VU0 run at EE MHz, not at EE bus MHz. Not to mention, that a 256 cycles kickstart is too much even on the correct speed. Later things just got worse. This issue can be partially replicated on Pcsx2 if you overclock the EE by +3
FPU/VU math inaccuracies. Koun, Tony hawk games, Devil may cry 3, Gun, TY the Tasmanian Tiger 3, Beyond Good & Evil, MTX Mototrax, Max payne, Bully, Jackie chan adventures, Wild arms 3, Pac-man World 3, Gran turismo 4, Many others Lua patches to the EE memory, accurate math commands. PS2 use really obscure floating point math, only one guard bit is used in calculations. PCSX2 hack it with different rounding modes, emu on ps4 fix it with soft floats, usually applied per offset. Sometime with patches directly to affected code (THPS engine).


It's worth noting that pcsx2 by default applies "accurate add/sub" for every single FPU opcode, and only to fpu opcodes. That's why accurate add/sub is needed on the PS4 while pcsx2 is happy with its default settings.

M-Bit support is broken Every game that uses M-Bit. Totally Spies! Totally Party, Mike Tyson Heavyweight Boxing, My Street, Crash Twinsanity, Marvel Nemesis, Panzer Elite Action - Fields of Glory, Super Monkey Ball Adventure, most Eko Software games, and many more. [2] Lua patches to the EE memory While emulator respect m-bit, way that VU0 work on it make it broken most of times (check "VU0 is not running in sync with EE core" issue).
Multitap doesn't support all games Urban reign, Digimon Rumble Arena 2, others Lua patches Emulator expect PS4 to be able to use 8 controllers (well, who doesn't? Even PS1 can do it...). That cause all kind of mess with controller detection when game expect multitap in second port.
DMA writes when busy signal is engaged Ratchet and clank games, Metal gear solid 2, others None yet AKA eetiminghack
VIF1 runs too fast Urban reign, Avatar, Parappa 2, Eternal Poison, Soul Calibur 2, Soul Calibur 3, Others Using LUA's SchedulerDelayEvent command or Using CLI'S vif1-instant-xfer command Sony wanted to improve the performance, which is the reason VIF1 is instant. The lua's command can be customizable to set the delay period, the cli can't, therefore lua's command is much more compatible
Reading VU TPC registers returns wrong values Street Fighter 3 EX(VU0), R: Racing Revolution(VU0), Spiderman 3 (VU0, in T-Bit handler...), Edge of Reality games(VU1) Patches in lua. In this emu TPC stores full addresses, which is wrong. Real hardware keep there addr >> 3. Worth noting that EoR games read VU1 TPC in a nasty way, accessing 0x43A0(VU1 TPC) from COP2 code.
VIF command interrupts handled before VIFn_CODE is updated. Onimusha Blade Warriors Fixed by patch in intr handler. This is very specific case because Onimusha check VIFn_CODE register in interrupt handler and do nothing if code is not 0x80 (NOP with I). But VIFn_CODE seems to be updated after interrupt is handled. This practically makes everything out of sync later as interrupts are happening, but handler does nothing about them.
CDVD register 0x1F402038 (KeysValid) return wrong result. Every "SCCS" game Patches in lua. Likely specific to NTSC-C releases, because that region uses special SDK. This issue makes cdvdman become stuck on any request because it thinks that the cdvd key is invalid.
Lack of CDVD error handling Demon Chaos, Spyro A new Beginning, Silent Hill 2 Black Ribbon, games from pcsx2 #5174 PR. Patches in lua if needed. One correctly supported error is SCECdErABRT, rest is just not handled or what's worst trigger emu panic on purpose like SCECdErILI (but not for 0 sector request - Spyro). Some affected games can still work if error is just accidental and not checked by game code.
Corrupted SIF0 transfer when not full QW is send by IOP True Crime: LA, PDC DC 2008, Street Racing Syndicate(1.03) Patches in lua. IOP is able to send words by SIF0, EE DMAC can only transfer Quadwords. When IOP send not full QW real hardware use whatever was in buffer from previous transfer for missing words (only words that are requested by iop are overwritten in transfer buffer). Emu probably memset 0 that part.

PCSX2 glitches not present on PS4[edit | edit source]

This is a list of glitches that the PS4 does not suffer from, as opposed to PCSX2.
Issue PCSX2's fix Games affected Description PCSX2 issue no.
Natively fixed
Bad FPU math Disabling EE recompiler / Janky GameDB patch Armored Core Nine Breaker The AI becomes stuck on some levels, working only when EE recompiler's disabled #8587
? Enabling EETimingHack Pac-Man World 2 Hanging in Butane Pain, Ghost Bayou, Pinky's Revenge and Clyde in the Caldera levels. Unavailable
? Unavailable Persona 3 Stuttering noise when saving #7316
? Unavailable Mega Man X8 Flickering subtitles on FMVS #5192
Bad timing. Unavailable Spyro Enter the Dragonfly Audio-video desync #8286
? Unavailable Petit Copter 2 In-game hang #10380
? Unavailable Yu-Gi-Oh! The Duelists of the Roses In-game data corruption (?) leading to a hang #11576
IPU running faster than it should? Janky patch Flame of Recca: Final Burning #11335
Bad timing Unavailable Ape Escape 3 Sudden burst of in-game speed at some random points in the map Unavailable
? vu0RoundMode: 2 Ape Escape 3 The character's buster malforms when spawning anew #11386
Fixed by using certain commands
Inaccurate COP2 add/sub implementation Unavailable Driv3r AI cop car drives at the incorrect direction (Fixed on PS4 with accurate COP2 add/sub) #11714

PS2 Bios[edit | edit source]

Description[edit | edit source]

The PS2 BIOS is the file PS20220WD20050620.crack included in every PS2 game .pkg. It is the same BIOS used by Sony in PS3's ps2_netemu.self. The lack of many X modules here means that homebrew compatibility is limited, as many of those need to be recompiled to use non X versions of modules, or need to load open source versions of them through MC/CDVD. An important non X module that is missing is LIBSD, therefore, homebrews that require it will likely fail to boot, or cause an error.

This PS2 BIOS is known to blacklist some titles, and refuse to boot them. This includes all titles with the 00000000 000000A0 flag, documented here.

More about the PS2 BIOS

The version of the PS2 BIOS seems to be the developement v2.20 from the Japanese region (22/01/2007), and is not limited to booting only NTSC-J games.
The PS2 emulator does not support USB peripherals, but this seems not to be a limitation of the BIOS, as it is used also in CECH C/E PS3 consoles. 
There are signs that different PS2 BIOS versions exist, named PS20190AC20030623_nordram_miniOSD.bin. This PS2 BIOS has included handy extensions for debugging, and can debug print with "debug osd verbosity" from CLI set to "verbose". The most noticeable difference for both BIOS files seems to be the special RDRAM module.

Whilst the PS3 patches its PS2 BIOS to preferred regions, the PS4 uses a so called CallHook which is better known for PCSX2 users as fastboot. For more information about this patch, look at PCSX2's fastboot code. It is the same code except that PS2 emulators for PS4 do not have patches for different BIOS revisions.

PS2 BIOS file information:

File name: PS20220WD20050620.crack
MD5: 83AD2B530C9C102A561BA1CDC6D996D5

Files inside ROM image[edit | edit source]

File Offset in exported bin Description File type (exportable)
RESET 0x00 Bootstrap code for the EE and IOP. BIN
ROMDIR 0x2780 The ROMDIR part of the ROM image, which provides information on the location and name of files contained in the image. BIN
EXTINFO 0x2CC0 Contains the "EXTINFO" for all files in the ROM image. BIN
SBIN 0x3330 Seems to be the pad controller library for the PS1 monitor. BIN
LOGO 0xA2D0 PS1 logo? BIN
IOPBTCONF 00x1EA20 Boot configuration file for the IOP, during the final phase of the IOP reset. If no UDNL module is specified, the IOP will only have a single IOP reset in the reboot process, with the modules listed in IOPBTCONF. BIN
IOPBTCON2 0x1EB10 Boot configuration file for the IOP, for the first phase of the IOP reset (before UDNL is loaded). BIN
SYSMEM 0x1EBE0 System Memory Manager. ELF
LOADCORE 0x1FE00 The core of IOP module loading. Provides the lowest level of IOP module loading functions. Also handles the startup of the IOP. ELF
EXCEPMAN 0x22380 Exception manager. ELF
INTRMANP 0x22F60 Interrupt Manager. According to wisi, it is for PS mode. ELF
INTRMANI 0x24970 Interrupt Manager. According to wisi, it is for IOP mode. ELF
SSBUSC 0x267B0 SSBUS Controller library. The SSBUS seems to be the bus that all peripherals get connected to. It seems to have the power to control the mapping of the device registers, as well as access timing. ELF
TIMEMANP 0x26F20 Timer Manager (PS mode) ELF
TIMEMANI 0x27B00 Timer Manager (IOP mode) ELF
DMACMAN 0x28730 DMA Controller Manager. ELF
SYSCLIB 0x2BE30 System C Library. ELF
HEAPLIB 0x2E590 Memory HEAP LIBrary (i.e. thvpool, thfpool) ELF
THREADLIB 0x2F290 Multi_Thread_Manager ELF
VBLANK 0x38020 V-Blank management ELF
IOMAN 0x38DB0 IO Manager ELF
MODLOAD 0x3AD20 IOP module loader. ELF
ROMDRV 0x3D070 ROM driver. Provides access to the boot ROM (rom0). ELF
ADDDRV 0x3DF60 Adds support for the DVD ROM (rom1:), via ROMDRV. ELF
STDIO 0x3D3C0 Standard I/O library. ELF
SIFMAN 0x3EFB0 SIF manager. ELF
SIFINIT 0x40550 Initializes the SIF. ELF
EESYNC 0x40970 For synchronizing with the EE, at the end of IOP resets. EESYNC from DNAS images are evil; they also perform a memory wipe of the region from 0x00084000 to .0x00100000. ELF
EENULL 0x40E10 The idle thread (id #0) module, in ps2 loaded to 0x00081FC0. BIN
PS1ID 0x40E50 Only found in newer boot ROMs BIN
LIBFI 0x40E60 Not present in the boot ROM of the SCPH-10000 and SCPH-15000. BIN
PS1VERJ 0x40F50 BIN
PS1VERA 0x40F60 BIN
PS1VERE 0x40F70 BIN
PS1VERC 0x40F80 BIN
PS1VERH 0x40F90 BIN
OSDSYS 0x40FA0 The browser BIN
- 0x40FB0 BIN
RDRAM 0x41000 Provides a RDRAM test for the EE at power-on. This is run from RESET. BIN
EELOADCNF 0x43D50 Contains the IOP boot configuration file for EELOAD. BIN
SIFCMD 0x43F00 SIF command module. Contains the SIF command and SIF RPC functions. ELF
REBOOT 0x46140 The reboot service. Receives IOP reset packets from the EE, from across the SIF. ELF
LOADFILE 0x46910 The RPC server for MODLOAD ELF
EECONF 0x49070 Loads part of the system configuration from the MECHACON EEPROM. Also configures and resets some peripherals, depending on the model version. In slimlines, and possibly on PS3 EECONF will also load the MAC address. ELF
- 0x49FF0 BIN
IOPBOOT 0x4A000 IOP bootup program BIN
- 0x4B160 BIN
TBIN 0x4B800 The PS1 monitor program. Seems to be the PS1 BIOS. This is started by RESET, when the IOP is in PS1 mode. BIN
XSHA1 0x59770 sha1 - this only present in PS3. It is used as additional antipiracy check. It seems that it calculate disc main elf checksum and compares it with some database. Config related? ELF
XLOADFILE 0x5A740 Updated module ELF
SIO2MAN 0x5D7F0 SIO2 manager. Provides access to the SIO2 interface. ELF
- 0x5F420 BIN
MCSERV 0x61340 RPC server for MCMAN. ELF
- 0x63040 BIN
KROMG 0x64000 BIN
- 0x65CC0 BIN
KROM 0x66000 Kanji ROM? Not sure where this is used. BIN
- 0x7FE70 BIN
ROMVER 0x7FF00 ROM version. BIN
- 0x7FF10 BIN
VERSTR 0x7FF30 Version string. Probably PS1 ROM will use this because that this string is also present in PlayStation consoles. BIN
- 0x7FF90 BIN
ROMGSCRT 0x80000 BIN
NCDVDMAN 0x82D30 It seems to be a heavily stripped-down CDVDMAN module, with no support for some S-command functions like sceCdRI. ELF
SECRMAN 0x8F770 Security Manager. Signing is NOT done with the one in ROM, but with a special version that comes with the utility discs. Looks like PS3 units have a different SECRMAN module from retail sets, similar to PS2 TOOL one. ELF
MCMAN 0x93C30 Memory Card Manager. ELF
PADMAN 0xA30C0 Pad manager. ELF
CDVDMAN 0xAC810 The CD/DVD manager. ELF
CDVDFSV 0xB4BC0 The RPC server for CDVDMAN. ELF
FILEIO 0xBCF80 RPC server for IOMAN. Sony has greatly changed the semantics and design of FILEIO after some point. Connecting an old FILEIO EE RPC client to a newer server will result in a severe IOP crash. ELF
CLEARSPU 0xBF080 Seems to clear/reset the SPU, but is known to cause crashes under some conditions. Not sure if it's buggy or not. Only used by the OSDSYS of the SCPH-10000 and SCPH-15000, probably retained for backward-compatibility. ELF
UDNL 0xC0CC0 It is responsible for selecting the modules and starting the IOP, during the final phase of the IOP reset where the desired modules are to be loaded into the IOP. ELF
IGREETING 0xC2BC0 Displays boot information (i.e. IOP boot type, EBOOTP, IBOOTP, switch positions for DSW602 and the type of DSW602 board installed ELF
EELOAD 0xC3C20 The EE ELF loader, which is loaded by LoadExecPS2() to 0x00082000 in PS2 for loading ELFs. BIN
XCDVDMAN 0xD2DA0 cdvd_driver - Updated module ELF
XCDVDFSV 0xE1B30 cdvd_ee_driver - Updated module ELF
OSDSND 0xEFF60 OSD sound library. This is actually the tentative sound driver, which is called "librspu2" in the Sony SDK. ELF
PS2LOGO 0x11ABB0 Displays the PlayStation 2 logo from the inserted disc. For newer consoles, if the logo cannot be decrypted properly, it will fall back to the browser. Not actually required to boot games, but the Sony OSDSYS boots PS2 games through this program. ELF
XPARAM2 0x137500 File store per title settings for IOP emulation (XPARAM available also in real PS2 since 750XX where Deckard powerPC was introduced) ELF
OSDSYS 0x139A00 The browser BIN
PIOPRP 0x177880 Present in the PS3 ps2_(gx/soft/net)emu; contains version 3.1.0 of the IOP software (compared to version 1.3.4 on the root). BIN
KERNEL 0x1BB7E0 The EE kernel BIN

Description source: https://gist.github.com/uyjulian/25291080f083987d3f3c134f593483c5

Game_ID/DiscID in PS20220WD20050620.crack[edit | edit source]

There are 193 titleIDs listed inside XPARAM2.ELF file of PS2 BIOS included in PS20220WD20050620.crack. XPARAM2.ELF is called by OSDSYS, then ID check is performed. If titleID match to one of included in the table, different IOP emulation settings are applied. This include blacklisting for some specific titles. 

The original PS2 BIOS from models with emulated IOP, include a similar list file called XPARAM.ELF. The Title IDs there are not the same, although some of them exist on both lists.
Command Name
0x00 TITLE_MASK
0x01 SIO2_MASK
0x02 DEV9_MASK
0x03 USB_MASK
0x04 SIF_DMA_SYNC
0x05 SIF_DMA_LOAD
0x06 DMAC_CH10_INT_DELAY
0x07 MECHA_RECOGTIME
0x08 CPU_DELAY
0x09 DEV5_INT_SPEED
0x0A CDVD_READ_DELAY
0x0B SPU2_BEHAVIOR
ID Title Command Value Remarks
PBPX_952.01 DVD Utility Disc Version 1.00 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PBPX_952.02 DVD Utility Disc Version 1.01 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PBPX_952.03 DVD Utility Disc Version 1.01 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PBPX_952.06 DVD Player (Version 2.01) 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PBPX_952.07 DVD Player (Version 2.10) 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PBPX_952.08 DVD Player (Version 2.10) 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PBPX_952.09 DVD Player (Version 2.10) 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PBPX_952.10 DVD Utility Disc Version 2.10 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PBPX_952.11 DVD Utility Disc Version 1.00 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PBPX_952.21 DVD Player (Version 2.12) 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PBPX_952.22 DVD Player (Version 2.14) 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PBPX_952.24 DVD Player (Version 2.16) 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PBPX_952.28 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PBPX_952.35 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PBPX_952.39 Online Start Up Disc v3.0 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PBPX_955.01 Linux for PS2 Beta Release 1 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PBPX_955.07 Playstation 2 Linux Runtime Environment v1.0 (Disc 1) 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PBPX_955.09 Linux for PS2 Release 1.0 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PBPX_955.18 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PDPX_991.09 DVD Player (Version 3.04) 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PSXC_002.01 PSX Update Disc 1.10 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PSXC_002.02 PSX Update Disc 1.20 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PSXC_002.03 PSX Update Disc 1.31 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
PTPX_970.38 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
SCAJ_201.25 Tekken 5 0x0B 0x40000000 SPU2_BEHAVIOR
SCAJ_201.26 Tekken 5 0x0B 0x40000000 SPU2_BEHAVIOR
SCES_532.02 Tekken 5 0x0B 0x40000000 SPU2_BEHAVIOR
SCKA_200.49 Tekken 5 0x0B 0x40000000 SPU2_BEHAVIOR
SCPM_621.15 0x00 0x1000000 TITLE_MASK
SCPM_621.16 0x00 0x1000000 TITLE_MASK
SCPN_601.01 PlayStation BB Navigator (Version 0.10) 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
SCPN_601.30 PlayStation BB Navigator (Version 0.20) 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
SCPN_601.40 PlayStation BB Navigator (Version 0.30) 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
SCPN_601.50 PlayStation BB Navigator (Version 0.31) 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
SCPN_601.60 PlayStation BB Navigator (Version 0.32) 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
SCPS_110.01 I.Q. Remix 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
SCPS_110.10 Yoake no Mariko (Performance Pack Edition) 0x01 0x1800 SIO2_MASK
SCPS_110.18 Yoake no Mariko 0x01 0x1800 SIO2_MASK
SCPS_110.21 Yoake no Mariko 2nd Act (Limited Edition) 0x01 0x1800 SIO2_MASK
SCPS_110.22 Yoake no Mariko 2nd Act 0x01 0x1800 SIO2_MASK
SCPS_150.38 Lifeline 0x0A 0x80300 CDVD_READ_DELAY
SCPS_150.39 Lifeline 0x0A 0x80300 CDVD_READ_DELAY
SCPS_170.01 Gran Turismo 4 0x0B 0x10000000 SPU2_BEHAVIOR
SCPS_175.01 Linux (for PlayStation2) Release 1.0 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
SCPS_200.39 0x00 0x4000000 TITLE_MASK
SCUS_971.67 PaRappa the Rapper 2 0x04 0x2000 SIF_DMA_SYNC
SCUS_972.69 Final Fantasy XI [Disc 2] 0x02 0xB DEV9_MASK
SLES_500.48 Donald Duck: Quack Attack 0x01 0x800 SIO2_MASK
SLES_500.62 Orphen: Scion of Sorcery 0x08 0xC1C CPU_DELAY
SLES_503.64 City Crisis 0x0A 0x80BB8 CDVD_READ_DELAY
SLES_504.46 Shadow Man 2: The Second Coming 0x0A 0x80600 CDVD_READ_DELAY
SLES_505.40 Simpsons: Road Rage 0x01 0x800 SIO2_MASK
SLES_506.08 Shadow Man 2: The Second Coming 0x0A 0x80600 CDVD_READ_DELAY
SLES_506.28 Simpsons: Road Rage 0x01 0x800 SIO2_MASK
SLES_507.28 Tiger Woods PGA Tour 2002 0x0A 0x803E8 CDVD_READ_DELAY
SLES_507.29 0x0A 0x803E8 CDVD_READ_DELAY
SLES_512.82 Tiger Woods PGA Tour 2003 0x0A 0x803E8 CDVD_READ_DELAY
SLES_514.79 Def Jam Vendetta 0x01 0x802 SIO2_MASK
SLES_518.41 SpyHunter 2 0x01 0x800 SIO2_MASK
SLES_518.44 Time Crisis 3 0x01 0x800 SIO2_MASK
SLES_519.97 SWAT: Global Strike Team 0x01 0x800 SIO2_MASK
SLES_520.97 SWAT: Global Strike Force 0x01 0x800 SIO2_MASK
SLES_530.37 Super Monkey Ball Deluxe 0x01 0x802 SIO2_MASK
SLES_536.68 Micro Machines v4 0x01 0x801 SIO2_MASK
SLES_537.55 Castlevania: Curse of Darkness 0x04 0x10 SIF_DMA_SYNC
SLES_537.96 FIFA Street 2 0x01 0x1800 SIO2_MASK
SLPM_620.42 Kurogane no Houkou: Warship Commander 0x01 0x3000 SIO2_MASK
SLPM_620.62 Gitaroo Man One 0x0A 0x80540 CDVD_READ_DELAY
SLPM_621.05 Taikou Risshiden IV 0x09 0x2B47000A DEV5_INT_SPEED
SLPM_621.24 Ready 2 Rumble Boxing: Round 2 0x08 0x1388 CPU_DELAY
SLPM_621.25 Gauntlet: Dark Legacy 0x08 0xC1C CPU_DELAY
SLPM_621.25 Gauntlet: Dark Legacy 0x09 0x2B470005 DEV5_INT_SPEED
SLPM_621.35 Final Fantasy: XI (Beta Version) 0x00 0xA0000000 TITLE_MASK, 0xA0000000 = Blacklist, boot after removing flag
SLPM_621.54 DDRMAX Dance Dance Revolution 6thMix 0x08 0x1A5E CPU_DELAY
SLPM_622.39 Supercar Street Challenge 0x0A 0x80300 CDVD_READ_DELAY
SLPM_623.69 Karaoke Revolution: J-Pop Vol.1 0x08 0x1388 CPU_DELAY
SLPM_623.79 Karaoke Revolution: J-Pop Vol.2 0x08 0x1388 CPU_DELAY
SLPM_623.80 Karaoke Revolution: J-Pop Vol.3 0x08 0x1388 CPU_DELAY
SLPM_623.81 Karaoke Revolution: J-Pop Vol.4 0x08 0x1388 CPU_DELAY
SLPM_623.82 Karaoke Revolution: Love & Ballad 0x08 0x1388 CPU_DELAY
SLPM_623.83 Karaoke Revolution: Night Selection 2003 0x08 0x1388 CPU_DELAY
SLPM_624.14 Karaoke Revolution: Dreams & Memories 0x08 0x1388 CPU_DELAY
SLPM_624.37 Suisui Sweet: Amai Ai no Mitsukekata 0x0B 0x40000000 SPU2_BEHAVIOR
SLPM_624.50 Karaoke Revolution: Anime Song Selection 0x08 0x1388 CPU_DELAY
SLPM_624.51 Karaoke Revolution: J-Pop Vol.5 0x08 0x1388 CPU_DELAY
SLPM_624.54 Karaoke Revolution: J-Pop Vol.6 0x08 0x1388 CPU_DELAY
SLPM_624.55 Karaoke Revolution: J-Pop Vol.7 0x08 0x1388 CPU_DELAY
SLPM_624.56 Karaoke Revolution: J-Pop Vol.8 0x08 0x1388 CPU_DELAY
SLPM_624.57 Karaoke Revolution: Snow & Party 0x08 0x1388 CPU_DELAY
SLPM_624.64 Pop'n Taisen Pazurudame Online 0x08 0x1F40 CPU_DELAY
SLPM_624.79 Karaoke Revolution: J-Pop Vol.9 0x08 0x1388 CPU_DELAY
SLPM_624.91 Mega Man: The Power Battle 0x04 0x2000 SIF_DMA_SYNC
SLPM_624.92 Karaoke Revolution: Kids Song Selection 0x08 0x1388 CPU_DELAY
SLPM_625.28 Karaoke Revolution: Kazoku Idol Sengen (Bundle Edition) 0x08 0x1388 CPU_DELAY
SLPM_625.29 Karaoke Revolution: Kazoku Idol Sengen 0x08 0x1388 CPU_DELAY
SLPM_650.86 A Visual Mix: Ayumi Hamasaki Dome Tour 2001 (Disc 1) 0x08 0x1450 CPU_DELAY
SLPM_650.87 A Visual Mix: Ayumi Hamasaki Dome Tour 2001 (Disc 2) 0x08 0x1450 CPU_DELAY
SLPM_650.90 Spy Hunter 0x01 0x1800 SIO2_MASK
SLPM_651.97 Nobunaga's Ambition Online 0x02 0xB DEV9_MASK
SLPM_652.09 Star Ocean: Till the End of Time 0x0B 0x20014 SPU2_BEHAVIOR
SLPM_654.38 Star Ocean: Till the End of Time (Director's Cut) (Disc 1) 0x0B 0x20014 SPU2_BEHAVIOR
SLPM_654.39 Star Ocean: Till the End of Time (Director's Cut) (Disc 2) 0x0B 0x20014 SPU2_BEHAVIOR
SLPM_654.88 Grand Theft Auto: Vice City 0x0A 0x300 CDVD_READ_DELAY
SLPM_654.88 Grand Theft Auto: Vice City 0x09 0x36000200 DEV5_INT_SPEED
SLPM_656.33 I Love Baseball: Pro Yakyu wo Koyonaku 0x08 0xFA0 CPU_DELAY
SLPM_656.98 Love Songs: ADV Futaba Riho 14-sai Natsu 0x0A 0x80380 CDVD_READ_DELAY
SLPM_657.05 Final Fantasy XI: Chains of Promathia (Expansion Disc) 0x02 0xB DEV9_MASK
SLPM_657.06 Final Fantasy XI: Chains of Promathia (All-In-One Edition) 0x02 0xB DEV9_MASK
SLPM_657.19 Burnout 3: Takedown 0x01 0x1C00 SIO2_MASK
SLPM_657.83 Nobunaga no Yabou Online: Tappi no Shou 0x02 0xB DEV9_MASK
SLPM_658.94 Winning Post 6: 2005 Version 0x01 0x2400 SIO2_MASK
SLPM_659.34 Maple Colors 0x0A 0x80300 CDVD_READ_DELAY
SLPM_659.53 Final Fantasy: XI (Entry Disc 2005) 0x02 0xB DEV9_MASK
SLPM_659.84 Grand Theft Auto: San Andreas 0x0A 0x803E8 CDVD_READ_DELAY
SLPM_660.33 The Sword of Etheria 0x08 0xC1C CPU_DELAY
SLPM_660.33 The Sword of Etheria 0x00 0x2000000 TITLE_MASK
SLPM_660.48 The Sword of Etheria 0x08 0xC1C CPU_DELAY
SLPM_660.48 The Sword of Etheria 0x00 0x2000000 TITLE_MASK
SLPM_660.57 Taito Memories Vol.1 0x08 0xCE4 CPU_DELAY
SLPM_661.56 Marheaven: Arm Fight Dream 0x01 0x1800 SIO2_MASK
SLPM_661.75 Akumajo Dracula: Yami no Juin 0x08 0x60 CPU_DELAY
SLPM_661.75 Akumajo Dracula: Yami no Juin 0x0B 0x2001C SPU2_BEHAVIOR
SLPM_663.93 Final Fantasy XI: Treasures of Aht Urhgan (All-In-One Edition) 0x0A 0x803E8 CDVD_READ_DELAY
SLPM_663.93 Final Fantasy XI: Treasures of Aht Urhgan (All-In-One Edition) 0x09 0x2B47000A DEV5_INT_SPEED
SLPM_663.93 Final Fantasy XI: Treasures of Aht Urhgan (All-In-One Edition) 0x02 0xB DEV9_MASK
SLPM_663.94 Final Fantasy XI: Treasures of Aht Urhgan 0x02 0xB DEV9_MASK
SLPM_664.36 Aria the Natural 0x01 0x1800 SIO2_MASK
SLPM_664.36 Aria the Natural 0x00 0xA000000 TITLE_MASK
SLPM_665.39 Nobunaga no Yabou Online: Haten no Shou 0x02 0xB DEV9_MASK
SLPM_665.58 Tomb Raider: Legend 0x08 0x3E8 CPU_DELAY
SLPM_665.74 Detective Evangelion 0x00 0x2000000 TITLE_MASK
SLPM_680.07 Karaoke Revolution (Trial) 0x08 0x1388 CPU_DELAY
SLPM_680.10 0x08 0x1388 CPU_DELAY
SLPS_200.08 Morita Shogi 0x08 0x1388 CPU_DELAY
SLPS_200.20 FIFA 2000 World Championship 0x04 0x2001 SIF_DMA_SYNC
SLPS_200.37 Go Go Golf 0x09 0x2B47000A DEV5_INT_SPEED
SLPS_200.38 Grappler Baki: Baki Saidai no Tournament 0x08 0x1194 CPU_DELAY
SLPS_200.53 Tenshi no Present: Marle Oukoku Monogatari (Limited Edition) 0x0B 0x20000000 SPU2_BEHAVIOR
SLPS_200.66 Tenshi no Present: Marle Oukoku Monogatari 0x0B 0x20000000 SPU2_BEHAVIOR
SLPS_201.01 City Crisis 0x0A 0x80BB8 CDVD_READ_DELAY
SLPS_201.11 Magical Sports Pro Baseball 2001 0x09 0x2B47000A DEV5_INT_SPEED
SLPS_201.72 Koushien: Konpeki no Sora 0x09 0x2B47000A DEV5_INT_SPEED
SLPS_201.73 Hard Hitter 2 0x0A 0x80300 CDVD_READ_DELAY
SLPS_201.97 Surfing Air Show with RatBoy 0x09 0x2B47000A DEV5_INT_SPEED
SLPS_201.99 F1 2002 0x0B 0x20005 SPU2_BEHAVIOR
SLPS_202.00 Final Fantasy XI 0x02 0xB DEV9_MASK
SLPS_204.04 Rakushou! Pachi-Slot Sengen 2 0x0A 0x80300 CDVD_READ_DELAY
SLPS_204.29 Hissatsu Pachi-Slot Evolution: Ninja Hattori-Kun V 0x08 0x1B58 CPU_DELAY
SLPS_204.55 Simple 2000 Series Vol.94: The Aka-Champion - Come on Baby 0x0B 0x40000000 SPU2_BEHAVIOR
SLPS_250.08 Sorcerous Stabber Orphen 0x08 0xC1C CPU_DELAY
SLPS_250.71 A Visual Mix: Ayumi Hamasaki Dome Tour 2001 0x08 0x1450 CPU_DELAY
SLPS_250.72 A Visual Mix: Ayumi Hamasaki Dome Tour 2001 0x08 0x1450 CPU_DELAY
SLPS_250.81 Saishuu Densha 0x0A 0x803E8 CDVD_READ_DELAY
SLPS_251.36 Kuon no Kizuna Sairin Mikotonori 0x0A 0x805DC CDVD_READ_DELAY
SLPS_251.42 Tiger Woods PGA Tour 2002 0x0A 0x803E8 CDVD_READ_DELAY
SLPS_251.50 Only You 0x0B 0x40000000 SPU2_BEHAVIOR
SLPS_252.37 Only You 0x0B 0x40000000 SPU2_BEHAVIOR
SLPS_252.75 Def Jam: Vendetta 0x01 0x802 SIO2_MASK
SLPS_252.78 Memories Off: Mix 0x0A 0x80300 CDVD_READ_DELAY
SLPS_252.90 Time Crisis 3 0x01 0x800 SIO2_MASK
SLPS_253.15 One Piece: Grand Battle 3 0x01 0x1800 SIO2_MASK
SLPS_253.57 3-Nen B-Gumi Kinpachi Sensei: Densetsu no Kyoudan ni Tate! 0x01 0x1800 SIO2_MASK
SLPS_253.79 Tokyo Majin Gakuen: Kaihoujyou Kefurokou 0x0A 0x803E8 CDVD_READ_DELAY
SLPS_254.06 Hitman: Contracts 0x08 0xDAC CPU_DELAY
SLPS_254.18 Ace Combat 5: The Unsung War 0x0A 0x500000 CDVD_READ_DELAY
SLPS_255.10 Tekken 5 0x0B 0x40000000 SPU2_BEHAVIOR
SLPS_255.85 Monster Farm 5: Circus Caravan 0x07 5 MECHA_RECOGTIME
SLPS_255.86 Tales of the Abyss 0x0A 0x803E8 CDVD_READ_DELAY
SLPS_256.04 Ar tonelico Qoga: Knell of Ar Ciel 0x00 0xA000000 TITLE_MASK
SLPS_256.67 Daito Giken Premium Pachi-Slot Collection: Yoshimune 0x01 0x1800 SIO2_MASK
SLPS_256.98 Fatal Fury Battle Archives Volume 2 0x00 0xA000000 TITLE_MASK
SLPS_257.08 The Familiar of Zero (Limited Edition) 0x0A 0x803E8 CDVD_READ_DELAY
SLPS_257.09 The Familiar of Zero 0x0A 0x803E8 CDVD_READ_DELAY
SLPS_257.21 HimeHibi - Princess Days 0x0B 0x8000000 SPU2_BEHAVIOR
SLPS_257.22 Routes PE (Limited Edition) 0x08 0x3E8 CPU_DELAY
SLPS_257.27 Routes PE 0x08 0x3E8 CPU_DELAY
SLPS_732.49 Ar tonelico Qoga: Knell of Ar Ciel (Platinum) 0x00 0xA000000 TITLE_MASK
SLUS_200.11 Orphen: Ocion of Sorcery 0x08 0x1388 CPU_DELAY
SLUS_200.11 Orphen: Ocion of Sorcery 0x09 0x8000010 DEV5_INT_SPEED
SLUS_200.77 Donald Duck: Go'in Quackers 0x01 0x800 SIO2_MASK
SLUS_202.74 City Crisis 0x0A 0x80BB8 CDVD_READ_DELAY
SLUS_203.05 Simpsons: Road Rage 0x01 0x800 SIO2_MASK
SLUS_203.64 Tiger Woods PGA Tour 2002 0x0A 0x803E8 CDVD_READ_DELAY
SLUS_204.13 Shadowman 2 0x0A 0x80600 CDVD_READ_DELAY
SLUS_204.33 SWAT: Global Strike Team 0x01 0x800 SIO2_MASK
SLUS_204.88 Star Ocean: Til the end of Time [Disc 1] 0x08 0x1388 CPU_DELAY
SLUS_205.72 Tiger Woods PGA Tour 2003 0x0A 0x803E8 CDVD_READ_DELAY
SLUS_205.90 Spyhunter 2 0x01 0x800 SIO2_MASK
SLUS_206.35 Muppets Party Cruise 0x01 0x801 SIO2_MASK
SLUS_206.39 Def Jam Vendetta 0x01 0x800 SIO2_MASK
SLUS_206.86 Splashdown: Rides Gone Wild 0x0A 0x80400 CDVD_READ_DELAY
SLUS_208.38 All-Star Baseball 2005 0x01 0x802 SIO2_MASK
SLUS_208.51 Ace Combat 5: The Unsung War 0x0A 0x500000 CDVD_READ_DELAY
SLUS_208.91 Star Ocean: Til the end of Time [Disc 2] 0x08 0x1388 CPU_DELAY
SLUS_209.18 Super Monkey Ball: Deluxe 0x01 0x800 SIO2_MASK
SLUS_210.59 Tekken 5 0x0B 0x40000000 SPU2_BEHAVIOR
SLUS_210.70 Final Fantasy XI: Chains of Promathia 0x02 0xB DEV9_MASK
SLUS_210.89 Karaoke Revolution Vol.3 0x08 0x1388 CPU_DELAY
SLUS_213.31 Sonic Riders 0x01 0x800 SIO2_MASK
SLUS_213.39 Puzzle Challenge 0x01 0x800 SIO2_MASK
SLUS_214.04 Final Fantasy XI: Treasures of Aht Urhgan 0x02 0xB DEV9_MASK
SLUS_214.52 Valkyrie Profile 2: Silmeria 0x08 0x1388 CPU_DELAY

Folder/File layout[edit | edit source]

Example: Max Payne Classic

├── config-emu-ps4.txt
├── docs
│   └── revision.h
├── eboot.bin
├── feature_data
│   └── SLES-50326_features.lua
├── formatted.card
├── image
│   └── disc01.iso
├── lua_include
│   ├── ee-cpr0-alias.lua
│   ├── ee-gpr-alias.lua
│   ├── ee-hwaddr.lua
│   ├── language.lua
│   ├── pad-and-key.lua
│   ├── ps2.lua
│   └── utils.lua
├── patches
│   └── SLES-50326_cli.conf
├── PS20220WD20050620.crack
├── ps2-emu-compiler.self
├── sce_companion_httpd
│   └── html
│       ├── BackCover.jpg
│       ├── base
│       │   ├── arrow_up.png
│       │   └── sprites.png
│       ├── css
│       │   ├── default-skin.png
│       │   └── styles.min.css
│       ├── index.html
│       ├── js
│       │   └── app.min.js
│       ├── large
│       │   ├── Box01.jpg
│       │   ├── Box04.jpg
│       │   ├── landscape
│       │   │   ├── Box01.jpg
│       │   │   ├── Box04.jpg
│       │   │   ├── Page01.jpg From 01 to 59
│       │   │   └── Page59.jpg
│       │   ├── Page01.jpg From 01 to 116
│       │   └── Page116.jpg
│       ├── medium
│       │   ├── Box01.jpg
│       │   ├── Box04.jpg
│       │   ├── landscape
│       │   │   ├── Box01.jpg
│       │   │   ├── Box04.jpg
│       │   │   ├── Page01.jpg From 01 to 59
│       │   │   └── Page59.jpg
│       │   ├── Page01.jpg from 01 to 116
│       │   └── Page116.jpg
│       ├── small
│       │   ├── Box01.jpg from 01 to 04
│       │   ├── Box04.jpg
│       │   ├── landscape
│       │   │   ├── Box01.jpg from 01 to 04
│       │   │   ├── Box04.jpg
│       │   │   ├── Page01.jpg From 01 to 59
│       │   │   └── Page59.jpg
│       │   ├── Page01.jpg From 01 to 116
│       │   └── Page116.jpg
│       └── thumbnails
│           ├── BoxThumb01.jpg
│           ├── BoxThumb04.jpg
│           ├── landscape
│           │   ├── BoxThumb01.jpg
│           │   ├── BoxThumb04.jpg
│           │   ├── Thumb01.jpg from 01 to 59
│           │   └── Thumb59.jpg
│           ├── Thumb01.jpg From 01 to 116
│           └── Thumb116.jpg
├── sce_module
│   ├── libc.prx
│   └── libSceFios2.prx
├── sce_sys
│   ├── about
│   │   └── right.sprx
│   └── keystone
└── trophy_data
    └── SLES-50326_trophies.lua

LUA include files[edit | edit source]

Files that some official PS2 Classics PKG files use in order for the lua files to be separate.

pad-connect-type.lua

local PadConnectType = {}

PadConnectType.DS4				= 0
PadConnectType.HID              = 1		-- any 3rd party USB controller (fight stick, turbo controller, etc), always local.
PadConnectType.REMOTE_DS4       = 2		-- remote DS4 should behave just like regular DS4
PadConnectType.REMOTE_VITA      = 3		-- remote VITA lacks analog L2/R2

return PadConnectType

sprite.lua

local kFilterMode = {}
kFilterMode.Point                         		  = 0x00000000	-- < Sample the one texel nearest to the sample point.
kFilterMode.Bilinear                      		  = 0x00000001	-- < Sample the four texels nearest the sample point, and blend linearly.

local kWrapMode = {}
kWrapMode.Wrap                            		  = 0x00000000	-- < The integer portion of the input coordinate is discarded, and the fractional portion is used instead. <c>U=U-floorf(U);</c>
kWrapMode.Mirror                          		  = 0x00000001	-- < The input coordinate is "reflected" across the texture boundary. This reflection may occur multiple times until the coordinate falls within the <c>[0..1]</c> range. <c>U=isOdd(floorf(U)) ? 1-fracf(U) : fracf(U)</c>
kWrapMode.ClampLastTexel                  		  = 0x00000002	-- < The input coordinate is clamped to the range <c>[0..1]</c>. <c>U=max(0,min(1,U));</c>
kWrapMode.MirrorOnceLastTexel             		  = 0x00000003	-- < The input coordinate is reflected at most one time and then clamped to the range <c>[0..1]</c>. <c>U=abs(max(-1,min(1,U));</c>
kWrapMode.ClampHalfBorder                 		  = 0x00000004	-- < Similar to kWrapModeClampLastTexel, but if clamping is necessary, the output color will be the border color specified by the Sampler. For this mode, coordinates that are not within half a pixel of the border are considered clamped.
kWrapMode.MirrorOnceHalfBorder            		  = 0x00000005	-- < Similar to kWrapModeMirrorOnceLastTexel, but if clamping is necessary, the output color will be the border color specified by the Sampler. For this mode, coordinates that are not within half a pixel of the border are considered clamped.
kWrapMode.ClampBorder                     		  = 0x00000006	-- < Similar to kWrapModeClampLastTexel, but if clamping is necessary, the output color will be the border color specified by the Sampler. For this mode, coordinates that are outside the range <c>[0..1]</c> are considered clamped.
kWrapMode.MirrorOnceBorder                		  = 0x00000007	-- < Similar to kWrapModeMirrorOnceLastTexel, but if clamping is necessary, the output color will be the border color specified by the Sampler. For this mode, coordinates that are outside the range <c>[0..1]</c> are considered clamped.

local kBlendMultiplier = {}
kBlendMultiplier.Zero                             = 0x00000000  -- < Multiply the associated input by zero.
kBlendMultiplier.One                              = 0x00000001  -- < Multiply the associated input by one.
kBlendMultiplier.SrcColor                         = 0x00000002  -- < Multiply the associated input by the fragment color.
kBlendMultiplier.OneMinusSrcColor                 = 0x00000003  -- < Multiply the associated input by one minus the fragment color.
kBlendMultiplier.SrcAlpha                         = 0x00000004  -- < Multiply the associated input by the fragment alpha.
kBlendMultiplier.OneMinusSrcAlpha                 = 0x00000005  -- < Multiply the associated input by one minus the fragment alpha.
kBlendMultiplier.DestAlpha                        = 0x00000006  -- < Multiply the associated input by the render target alpha.
kBlendMultiplier.OneMinusDestAlpha                = 0x00000007  -- < Multiply the associated input by one minus the render target alpha.
kBlendMultiplier.DestColor                        = 0x00000008  -- < Multiply the associated input by the render target color.
kBlendMultiplier.OneMinusDestColor                = 0x00000009  -- < Multiply the associated input by one minus the render target color.
kBlendMultiplier.SrcAlphaSaturate                 = 0x0000000a  -- < Multiply the associated input by the minimum of 1 or fragment alpha.
kBlendMultiplier.ConstantColor                    = 0x0000000d  -- < Multiply the associated input by the constant color. @see DrawCommandBuffer::setBlendColor()
kBlendMultiplier.OneMinusConstantColor            = 0x0000000e  -- < Multiply the associated input by one minus the constant color. @see DrawCommandBuffer::setBlendColor()
kBlendMultiplier.Src1Color                        = 0x0000000f  -- < Multiply the associated input by a secondary fragment color.
kBlendMultiplier.InverseSrc1Color                 = 0x00000010  -- < Multiply the associated input by one minus a secondary fragment color.
kBlendMultiplier.Src1Alpha                        = 0x00000011  -- < Multiply the associated input by a secondary fragment alpha.
kBlendMultiplier.InverseSrc1Alpha                 = 0x00000012  -- < Multiply the associated input by one minus a secondary fragment alpha.
kBlendMultiplier.ConstantAlpha                    = 0x00000013  -- < Multiply the associated input by the constant color alpha. @see DrawCommandBuffer::setBlendColor()
kBlendMultiplier.OneMinusConstantAlpha            = 0x00000014  -- < Multiply the associated input by one minus the constant color alpha. @see DrawCommandBuffer::setBlendColor()

local kBlendFunc = {}
kBlendFunc.Add                        			  = 0x00000000  -- < The source value is added to the destination value.
kBlendFunc.Subtract                   			  = 0x00000001  -- < The destination value is subtracted from the source value.
kBlendFunc.Min                        			  = 0x00000002  -- < The minimum of the source and destination values is selected.
kBlendFunc.Max                        			  = 0x00000003  -- < The maximum of the source and destination values is selected.
kBlendFunc.ReverseSubtract            			  = 0x00000004  -- < The source value is subtracted from the destination value.

-- Default blending mode, ideal for typical alpha channel embedded into a PNG image.
blendDefaultEquation = {
	kBlendMultiplier.SrcAlpha,					-- src multiplier
	kBlendFunc.Add,		                        -- blend function
	kBlendMultiplier.OneMinusSrcAlpha,		    -- dest multiplier
}

blendConstFadeEquation = {
	kBlendMultiplier.ConstantAlpha,					-- src multiplier
	kBlendFunc.Add,		                  	 	    -- blend function
	kBlendMultiplier.OneMinusConstantAlpha,		    -- dest multiplier
}

return kFilterMode, kWrapMode, kBlendMultiplier, kBlendFunc

MipsInsn.lua

MipsInsn = {}
MipsInsn.IsAddi			= function(insn) return (insn & 0xfc000000) == 0x20000000 end	-- addi rt,rs,simm
MipsInsn.IsAddiu		= function(insn) return (insn & 0xfc000000) == 0x24000000 end	-- addiu rt,rs,simm
MipsInsn.IsDaddu		= function(insn) return (insn & 0xfc0007ff) == 0x0000002d end	-- daddu rd,rs,rt
MipsInsn.IsAddu			= function(insn) return (insn & 0xfc0007ff) == 0x00000021 end	-- addu rd,rs,rt
MipsInsn.IsBeq			= function(insn) return (insn & 0xfc000000) == 0x10000000 end	-- beq rs,rt,off
MipsInsn.IsJ			= function(insn) return (insn & 0xfc000000) == 0x08000000 end	-- j target
MipsInsn.IsJal			= function(insn) return (insn & 0xfc000000) == 0x0c000000 end	-- jal target
MipsInsn.IsJr			= function(insn) return (insn & 0xfc1fffff) == 0x00000008 end	-- jr rs
MipsInsn.IsLq			= function(insn) return (insn & 0xfc000000) == 0x78000000 end	-- lq rt,simm(rs)
MipsInsn.IsLd			= function(insn) return (insn & 0xfc000000) == 0xdc000000 end	-- ld rt,simm(rs)
MipsInsn.IsLw			= function(insn) return (insn & 0xfc000000) == 0x8c000000 end	-- lw rt,simm(rs)
MipsInsn.IsSq			= function(insn) return (insn & 0xfc000000) == 0x7c000000 end	-- sq rt,simm(rs)
MipsInsn.IsSd			= function(insn) return (insn & 0xfc000000) == 0xfc000000 end	-- sd rt,simm(rs)
MipsInsn.IsSw			= function(insn) return (insn & 0xfc000000) == 0xac000000 end	-- sw rt,simm(rs)
MipsInsn.IsEnd			= function(insn) return (insn & 0xfc00003f) == 0x0000000d end	-- break [code]

MipsInsn.GetRt			= function(insn) return (insn >> 16) & 0x1f end
MipsInsn.GetRs			= function(insn) return (insn >> 21) & 0x1f end
MipsInsn.GetRd			= function(insn) return (insn >> 11) & 0x1f end
--MipsInsn.GetSimm		= function(insn) return ((insn << 48) >> 48) end	-- this can't create a negative value correctly
MipsInsn.GetSimm		= function(insn)
   -- Lua5.3 shifts are all logical (WHY!?). threfore (insn<<48)>>48 cannot extend the sign.
   -- Instead of using shift, do following
   local bit = 16		-- sign bit place.
   local v = insn & 0xffff
   local m = 1 << (bit - 1)
   v = v & ((1 << bit) - 1)
   return (v ~ m) - m		-- '~' is xor in Lua... how strange it is.
end
MipsInsn.GetOff			= function(insn) return MipsInsn.GetSimm(insn) end
MipsInsn.GetTarget		= function(insn) return insn & 0x3ffffff end

return MipsInsn

ee-cpr0-alias.lua

cpr = {}

cpr.index		= 0
cpr.random		= 1
cpr.entrylo0	= 2
cpr.entrylo1	= 3
cpr.context		= 4
cpr.pagemask	= 5
cpr.wired		= 6
cpr.badvaddr	= 8
cpr.count		= 9
cpr.entryhi		= 10
cpr.compare		= 11
cpr.status		= 12
cpr.cause		= 13
cpr.epc			= 14
cpr.prid		= 15
cpr.config		= 16
cpr.badpaddr	= 23
cpr.hwbk		= 24
cpr.pccr		= 25
cpr.taglo		= 28
cpr.taghi		= 29
cpr.errorepc	= 30

return cpr

ee-gpr-alias.lua

-- Recommended method to import this module:
--   local gpr = require("ee-gpr-alias")
-- 
-- Using the global 'lang' variable is depreciated.  This will change to a local-scope variable after
-- the depreciation period has expired in April 2016.

gpr = {}

gpr.zero = 0
gpr.at   = 1
gpr.v0   = 2
gpr.v1   = 3
gpr.a0   = 4
gpr.a1   = 5
gpr.a2   = 6
gpr.a3   = 7
gpr.t0   = 8
gpr.t1   = 9
gpr.t2   = 10
gpr.t3   = 11
gpr.t4   = 12
gpr.t5   = 13
gpr.t6   = 14
gpr.t7   = 15
gpr.s0   = 16
gpr.s1   = 17
gpr.s2   = 18
gpr.s3   = 19
gpr.s4   = 20
gpr.s5   = 21
gpr.s6   = 22
gpr.s7   = 23
gpr.t8   = 24
gpr.t9   = 25
gpr.k0   = 26
gpr.k1   = 27
gpr.gp   = 28
gpr.sp   = 29
gpr.fp   = 30
gpr.ra   = 31

return gpr

ee-hwaddr.lua

gif_hw  = {}
vif0_hw = {}
vif1_hw = {}

gif_hw.CHCR			= 0x1000A000
gif_hw.MADR			= 0x1000A010
gif_hw.QWC			= 0x1000A020
gif_hw.TADR			= 0x1000A030
gif_hw.ASR0			= 0x1000A040
gif_hw.ASR1			= 0x1000A050
gif_hw.SADR			= 0x1000A080

vif0_hw.CHCR		= 0x10008000
vif0_hw.MADR		= 0x10008010
vif0_hw.QWC			= 0x10008020
vif0_hw.TADR		= 0x10008030
vif0_hw.ASR0		= 0x10008040
vif0_hw.ASR1		= 0x10008050
vif0_hw.SADR		= 0x10008080

vif1_hw.CHCR		= 0x10009000
vif1_hw.MADR		= 0x10009010
vif1_hw.QWC			= 0x10009020
vif1_hw.TADR		= 0x10009030
vif1_hw.ASR0		= 0x10009040
vif1_hw.ASR1		= 0x10009050
vif1_hw.SADR		= 0x10009080

return gif_hw, vif0_hw, vif1_hw, nil

language.lua

-- Recommended method to import this module:
--   local lang = require("language")
-- 
-- Using the global 'lang' variable is depreciated.  This will change to a local-scope variable after
-- the depreciation period has expired in April 2016.

lang = {}

lang.japanese		= 0
lang.english		= 1
lang.french			= 2
lang.spanish		= 3
lang.german			= 4
lang.italian		= 5
lang.dutch			= 6
lang.portuguese		= 7
lang.russian		= 8
lang.korean			= 9
lang.chinese_traditional	= 10
lang.chinese_simplified		= 11
lang.finnish		= 12
lang.swedish		= 13
lang.danish			= 14
lang.norwegian		= 15
lang.polish			= 16
lang.portuguese_brazil	= 17
lang.english_gb		= 18
lang.turkish		= 19
lang.spanish_la		= 20
lang.arabic			= 21
lang.french_canada	= 22

return lang

pad-and-key.lua

pad = {}

-- Left Side
pad.LU	= 0x0010	-- Up
pad.LD	= 0x0040	-- Down
pad.LL	= 0x0080	-- Left
pad.LR	= 0x0020	-- Right

-- Right Side
pad.RU	= 0x1000	-- Up (Triangle)
pad.RD	= 0x4000	-- Down (Cross)
pad.RL	= 0x8000	-- Left (Square)
pad.RR	= 0x2000	-- Right (Circle)

-- aliases
pad.UP		= 0x0010	-- LU
pad.DOWN	= 0x0040	-- LD
pad.LEFT	= 0x0080	-- LL
pad.RIGHT	= 0x0020	-- LR
pad.TRIANGLE= 0x1000
pad.CROSS	= 0x4000
pad.SQUARE	= 0x8000
pad.CIRCLE	= 0x2000

pad.L1	= 0x0400
pad.L2	= 0x0100
pad.L3	= 0x0002

pad.R1	= 0x0800
pad.R2	= 0x0200
pad.R3	= 0x0004

pad.SELECT	= 0x0001
pad.START	= 0x0008

keyboard = {}

keyboard.ESCAPE		= 0x1000
keyboard.SLASH		= 0x1001
keyboard.SEPARATOR	= 0x1002	-- backslash or pipe (\|)
keyboard.BACKQUOTE	= 0x1003
keyboard.PAGEDOWN	= 0x1004
keyboard.PAGEUP		= 0x1005
keyboard.F1			= 0x1006
keyboard.F2			= 0x1007
keyboard.F3			= 0x1008
keyboard.F4			= 0x1009
keyboard.F5			= 0x100a
keyboard.F6			= 0x100b
keyboard.F7			= 0x100c
keyboard.F8			= 0x100d
keyboard.F9			= 0x100e
keyboard.F10		= 0x100f
keyboard.F11		= 0x1010
keyboard.F12		= 0x1011

ps2.lua

require("ee-gpr-alias")
require("utils")

MipsInsn = {}
MipsInsn.IsAddi			= function(insn) return (insn & 0xfc000000) == 0x20000000 end	-- addi rt,rs,simm
MipsInsn.IsAddiu		= function(insn) return (insn & 0xfc000000) == 0x24000000 end	-- addiu rt,rs,simm
MipsInsn.IsBeq			= function(insn) return (insn & 0xfc000000) == 0x10000000 end	-- beq rs,rt,off
MipsInsn.IsJ			= function(insn) return (insn & 0xfc000000) == 0x08000000 end	-- j target
MipsInsn.IsJal			= function(insn) return (insn & 0xfc000000) == 0x0c000000 end	-- jal target
MipsInsn.IsJr			= function(insn) return (insn & 0xfc1fffff) == 0x00000008 end	-- jr rs
MipsInsn.IsLq			= function(insn) return (insn & 0xfc000000) == 0x78000000 end	-- lq rt,simm(rs)
MipsInsn.IsLd			= function(insn) return (insn & 0xfc000000) == 0xdc000000 end	-- ld rt,simm(rs)
MipsInsn.IsLw			= function(insn) return (insn & 0xfc000000) == 0x8c000000 end	-- lw rt,simm(rs)
MipsInsn.IsSq			= function(insn) return (insn & 0xfc000000) == 0x7c000000 end	-- sq rt,simm(rs)
MipsInsn.IsSd			= function(insn) return (insn & 0xfc000000) == 0xfc000000 end	-- sd rt,simm(rs)
MipsInsn.IsSw			= function(insn) return (insn & 0xfc000000) == 0xac000000 end	-- sw rt,simm(rs)
MipsInsn.IsEnd			= function(insn) return (insn & 0xfc00003f) == 0x0000000d end

MipsInsn.GetRt			= function(insn) return (insn >> 16) & 0x1f end
MipsInsn.GetRs			= function(insn) return (insn >> 21) & 0x1f end
MipsInsn.GetSimm		= function(insn) return ((insn << 48) >> 48) end
MipsInsn.GetOff			= function(insn) return MipsInsn.GetSimm(insn) end
MipsInsn.GetTarget		= function(insn) return insn & 0x3ffffff end

-- return FIFO queue of stack trace
-- the queue item is { caller-addr, return-from }
--
-- example:
--    print("=== stack trace ===")
--	  local stack_trace = MipsStackTrace(eeObj, eeObj.GetPc()+4, eeObj.GetGpr(gpr.ra), eeObj.GetGpr(gpr.sp))
--	  while not stack_trace:isEmpty() do
--		 local caller = stack_trace:dequeue()
--		 print( string.format(" 0x%08x [will return from : %x]", caller[1], caller[2]) )
--	  end
--
-- NOTE: you must +4 against GetPc() if you in a EE/IOP hook.
--		 Because EE/IOP jit executed the instruction at the address already and it might affect $sp or $ra.
--
-- obj : eeObj or iopObj
-- pc  : current pc (from GetPC or readout from thread context)
-- ra  : current ra (from GetGpr or readout from thread context)
-- sp  : current sp (from GetGpr or readout from thread context)
MipsStackTrace = function (obj, pc, ra, sp, depth)
   local max_depth = depth or 10		-- max trace depth
   local n_j = 1
   local jmax = {}
   local depth = 0
   local bdl_count = 0
   local new_pc    = 0
   local icount    = 0

   local result = Queue.new()
   local pushed_ra = Queue.new()
   while depth < max_depth and icount < 2048 do
	  -- TODO: error checks
	  if (pc & 3) ~= 0 then
		 return result
	  end
	  pc = pc & 0x01ffffff
	  sp = sp & 0x01ffffff
	  local insn = obj.ReadMem32(pc)
	  -- print(string.format("trace .. pc=%x insn=%x", pc, insn))
	  -- result:enqueue( { pc, insn } )

	  if MipsInsn.IsJr(insn) and MipsInsn.GetRs(insn) == gpr.ra then
		 bdl_count = 1
		 depth = depth + 1
		 new_pc = ra
		 -- print(string.format("jr ra : ra=%x", ra))
		 icount = 0
		 -- print(string.format("enqueue caller pc=%x ret addr=%x", new_pc-8, pc))
		 result:enqueue( {new_pc-8, pc} )	-- {return-addr, where-from}
	  elseif MipsInsn.IsAddiu(insn) and MipsInsn.GetRt(insn) == gpr.sp and MipsInsn.GetRs(insn) == gpr.sp then
		 sp = sp + MipsInsn.GetSimm(insn) -- ((insn<<48) >>48)
		 -- print(string.format("addiu sp,sp,** : new sp = %x", sp))
	  elseif MipsInsn.IsLq(insn) or MipsInsn.IsLd(insn) or MipsInsn.IsLw(insn) then
		 if MipsInsn.GetRt(insn) == gpr.ra and MipsInsn.GetRs(insn) == gpr.sp then
			-- the code might push $ra on the stack after start pc.
			-- in such case, we must not retrieve $ra value from the memory.
			if pushed_ra:isEmpty() then
			   local imm = MipsInsn.GetSimm(insn) -- ((insn<<48) >>48)
			   -- print(string.format("retrieve ra from stack(%x) : sp=%x imm=%x", sp+imm, sp, imm))
			   ra = obj.ReadMem32(sp + imm)
			   -- print(string.format("load ra,%x(sp) : sp = %x+%x, ra = %x", imm, sp, imm, ra))
			else
			   -- print(string.format("retrieve ra from pushed one"))
			   pushed_ra:dequeue()
			end
		 end
	  elseif MipsInsn.IsSq(insn) or MipsInsn.IsSd(insn) or MipsInsn.IsSw(insn) then
		 if MipsInsn.GetRt(insn) == gpr.ra and MipsInsn.GetRs(insn) == gpr.sp then
			pushed_ra:enqueue(pc);
		 end
	  elseif MipsInsn.IsJ(insn) then	-- j **
		 local imm = MipsInsn.GetTarget(insn)
		 imm = imm << 2
		 if pc == imm then
			-- jump to self? maybe we can ignore it.
		 else
			new_pc = imm
			-- print(string.format("j ** : new_pc = %x", new_pc))
			bdl_count = 1
			for t=1, n_j do
			   if jmax[t] == new_pc then
				  return result							-- closed loop
			   end
			end
			if n_j > 1024 then
			   return result							-- jump buffer overflow
			end
			jmax[n_j] = new_pc
			n_j = n_j + 1
		 end
	  elseif MipsInsn.IsBeq(insn) and MipsInsn.GetRs(insn) == gpr.zero then	-- beq zero,**
		 local offset = MipsInsn.GetOff(insn) -- ((insn<<48) >> 48)
		 offset = offset << 2
		 new_pc = pc + 4 + offset

		 if pc == new_pc then
			-- jump to self? maybe we can ignore it
		 else
			-- print(string.format("beq zero,** : new_pc=%x", new_pc))
			bdl_count = 1
			for t = 1, n_j do
			   if jmax[t] == new_pc then
				  return result
			   end
			end
			if n_j > 1024 then
			   return result
			end
			jmax[n_j] = new_pc
			n_j = n_j + 1
		 end
	  elseif MipsInsn.IsEnd(insn) then	-- end
		 -- print(string.format("end"))
		 return result
	  elseif MipsInsn.IsJal(insn) then	-- jal **
		 local imm = insn & 0x03ffffff
		 imm = imm << 2
		 -- print(string.format("jal ** : addr = %x", imm))
		 -- call
	  end

	  icount = icount + 1
	  pc = pc + 4

	  -- -- print(string.format("bdl_count=%d", bdl_count))
	  if bdl_count > 0 then
		 if bdl_count == 2 then
			pc = new_pc
			bdl_count = 0
		 else
			bdl_count = bdl_count + 1
		 end
	  end
   end
   return result
end

PS2 = {}
PS2.GetCurrentThread	= function(eeObj) return eeObj.ReadMem32(0x12fac) end
PS2.GetThreads			= function(eeObj)
   local EE_THREAD_BASE	= 0x18000
   local EE_NUM_THREADS = 0x100
   local th = EE_THREAD_BASE
   local result = Queue.new()
   for t = 0, EE_NUM_THREADS-1 do
	  -- 0 : node_prev
	  -- 4 : node_next
	  -- 8 : status
	  -- 12: pc
	  -- 16: sp
	  -- 20: gp
	  -- 24: init_pri
	  -- 26: curr_pri
	  -- 28: wstat
	  -- 32: waitId
	  -- 36: wakeupCount
	  -- 40: attr
	  -- 44: option
	  -- 48: func
	  -- 52: argc
	  -- 56: args
	  -- 60: stack
	  -- 64: size
	  -- 68: root
	  -- 72: endOfHeap
	  local status = eeObj.ReadMem32(th + 8)
	  if status ~= 0 then
		 local id    = t
		 local pri   = eeObj.ReadMem16(th + 26)
		 local gp    = eeObj.ReadMem32(th + 20)
		 local pc    = eeObj.ReadMem32(th + 12)
		 local sp    = eeObj.ReadMem32(th + 16)
		 result:enqueue( {id=id, status=status, pri=pri, gp=gp, pc=pc, sp=sp} )
	  end
	  th = th + 76
   end
   return result
end

utils.lua

-- utility classes/functions

-- Stack
-- ex:
--		my_stack = Stack.new()
--  	my_stack:push( val )
--		print( my_stack:pop( val ) )
Stack = {}

function Stack.new()
   local obj = { buff = {} }
   return setmetatable(obj, {__index = Stack})
end

function Stack:push(x)
  table.insert(self.buff, x)
end

function Stack:pop()
  return table.remove(self.buff)
end

function Stack:top()
  return self.buff[#self.buff]
end

function Stack:isEmpty()
  return #self.buff == 0
end


-- Queue
-- ex:
--		my_queue = Queue.new()
--		my_queue:enqueue( val )
--		print( my_queue:dequeue(val) )
Queue = {}

function Queue.new()
  local obj = { buff = {} }
  return setmetatable(obj, {__index = Queue})
end

function Queue:enqueue(x)
  table.insert(self.buff, x)
end

function Queue:dequeue()
  return table.remove(self.buff, 1)
end

function Queue:top()
  if #self.buff > 0 then
    return self.buff[1]
  end
end

function Queue:isEmpty()
  return #self.buff == 0
end

Links[edit | edit source]