Talk:PS2 Classics Emulator Compatibility List: Difference between revisions

From PS4 Developer wiki
Jump to navigation Jump to search
m (Protected "Talk:PS2 Classics Emulator Compatibility List": High traffic page ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)))
 
(353 intermediate revisions by 13 users not shown)
Line 5: Line 5:
<pre>Configurations that are made for more than one game for a specific purpose</pre>
<pre>Configurations that are made for more than one game for a specific purpose</pre>


===SkipMpegHack===
===SkipMpegHack (FMV skip)===
'''''LUA file'''''
'''''LUA file'''''
<br>
<br>
Line 42: Line 42:
== Official PS2emu Configuration Files ==
== Official PS2emu Configuration Files ==


Here are configuration files extracted from official packages, to improve PS2 emulator compatibility on PS4. Most of them require also emulator/recompiler files from extracted pkg to work correctly.
Here are configuration files extracted from official packages to improve PS2 emulator compatibility on PS4. Most of them require also emulator/recompiler files from extracted pkg to work correctly.
====ADK Damashii====
====ADK Damashii====
'''CLI'''
'''CLI'''
Line 115: Line 115:
</pre>
</pre>


====Canis Canem Edit/Bully====
====Canis Canem Edit (Bully)====
<br>CLI
<br>CLI
<pre>--fpu-accurate-mul-fast=1
<pre>--fpu-accurate-mul-fast=1
--fpjk-muldiv-range=0x3fa5c0,0x3fa5c0
--fpu-muldiv-range=0x3fa5c0,0x3fa5c0
--gs-flush-ad-xyz=SafeZWrite
--gs-flush-ad-xyz=SafeZWrite
--vu1-opt-vf00=2
--vu1-opt-vf00=2
Line 586: Line 586:
eeInsnReplace(0x1c5d24, 0x10400005, 0) -- QDT::KCOM::COM_SERVICE::RetrieveComHandle
eeInsnReplace(0x1c5d24, 0x10400005, 0) -- QDT::KCOM::COM_SERVICE::RetrieveComHandle
#Official widescreen support, forced 60Hz/NTSC, along with a game crash bug fix.</pre>
#Official widescreen support, forced 60Hz/NTSC, along with a game crash bug fix.</pre>
====Fantavision====
'''CLI'''
<br>SCES-50002
<pre>
--gs-kernel-cl-up="fantavision"
--gs-motion-factor=1
</pre>
'''LUA'''
<br>SCES-50002
<pre>
require("ee-gpr-alias")
require( "ee-hwaddr" )
apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.
eeObj = getEEObject()
--
-- Bug#93709 (JP Bugzilla)
-- Same as Parappa the Rapper 2, it's VIF1 vs GIF xfer timing issue.
-- The game expects PATH3 happens before VU1 xgkick, but actually Olympus doesn't do like that.
-- Game kicks  : PATH3(Context1) PATH1(Rendering using Context1&2) PATH3(Context2)
-- Game expects: PATH3(Context1) PATH3(Context2) PATH1(Rendering using Context1&2)
-- Hence VIF1 DMA needs to be delayed.
eeObj.AddHook(0x1b1468, 0xae020000, function()
local ee = eeObj
local s0 = ee.GetGpr(gpr.s0)
if s0 == vif1_hw.CHCR then
local chcr = ee.GetGpr(gpr.v0)
if (chcr & 0x05) == 0x05 then
  local tadr = ee.ReadMem32(vif1_hw.TADR)
  if tadr == 0x8883e0 or tadr == 0x9f6b60 then
  ee.SchedulerDelayEvent("vif1.dma", 0x5000)
  end
end
end
end)
-- Performace fix
local emuObj = getEmuObject()
-- twIsLess=5 - texture width is less or eq. than 32
emuObj.SetGsTitleFix( "forcePointSampling", "reserved", {alpha = 0x80000048, twIsLess=5, thIsLess=5 } )
</pre>


====Fatal Fury: Battle Archives volume 2====
====Fatal Fury: Battle Archives volume 2====
Line 1,053: Line 1,097:


</pre>
</pre>
 
====Jak 3====
====Kinetica====
'''CLI'''
<br>SCUS-97132
<pre>
--vu1-clamp-range=0x386,0x386
--vu1-clamp-range=0x5e0,0x5f0 # another gritches
--gs-kernel-cl-up="up2x2skipinterp"
--vu1-injection=1
--vu1-jr-cache-policy=sameprog
--vu1-jalr-cache-policy=sameprog
--vu1-mpg-cycles=900
--host-audio-latency=0.10
--cdvd-sector-read-cycles=40000
</pre>
 
'''LUA'''
'''LUA'''
<br>SCUS-97132
<br>SCUS-97330
<pre>
<pre>
local gpr = require("ee-gpr-alias")
apiRequest(2.3)
apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.


local emuObj = getEmuObject()
local gpr    = require("ee-gpr-alias")
local eeObj         = getEEObject()
local emuObj = getEmuObject()
local eeObj = getEEObject()
local gsObj = getGsObject()
local eeOverlay = eeObj.getOverlayObject()


-- require("debughooks")
-- Fix shadow
-- local iopObj = getIOPObject()
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1  } )
-- iopObj.AddHook(0x000135ac, 0x27bdffe0, DebugHooks.h_IOP_ioman_write)


-- bug#8123
-- Reduce flush count
-- Skip resetting VAG stream which happens on an error.
emuObj.SetGsTitleFix( "SetSelfRender", "reserved", { fbmask= 0x00FFFFFF , renderSelf=1 , zmsk=1 , alpha=0 , texMode=1  } )
iopInsnReplace(0x00090028, 0x16220009, 0x08024014) -- bne $s1,$v0,0x00090050 => j 0x00090050
 
-- Disabled due to embossing effect problem --jstine
--emuObj.SetGsTitleFix( "trianglesAsParticles", "reserved", { hasClut=1,zmsk=1 } )


-- bug#9405 - advance EE clock according to spinning-loop SIF activity.
local skip_syncDCache = function()
-- Original value when actually processing syncDCache was 3300
-- Boosting to 8000 helps reduce bottleneck
eeObj.AdvanceClock(8000)
end


eeInsnReplace(0x1ca9e0, 0x27bdffe0, 0x03e00008)
-- All JAK titles have a silly way of obtaining the PS2 Timestamp Counter. A binary code snippet is written
eeInsnReplace(0x1ca9e4, 0x0080302d, 0x00000000)
-- into a NON-CONST array, like so:  static u32 getTSC[] = { 0x40024800, 0x03E00008 }; and then that snippet is
eeObj.AddHookJT(0x1ca9e0, 0x03e00008, skip_syncDCache)
-- called via:  ((u32 (*)())getTSC)()
--
-- Actual disasm of snippet:
--    129780:40024800    mfc0        $v0,$count
--    129784:03E00008    jr          $ra
--
-- Because the code is right next to data in the .data section of the process, the emulator's page fault protection
-- gets tripped up constantly and the code must be re-validated on every invocation.  Interesting aside: had the devs
-- marked the array as 'const' and thus had it placed in .ro_data, there wouldn't be a perf issue in the emu since
-- page invalidations only occur on writes.
--
-- Solution: rewrite the code which calls this function to simply execute mfc0 inline instead.  Typical pattern which
-- invokes the PS2 TSC read:
--    108c80:8c629790 lw v0,-26736(v1)
--    108c84:0040f809 jalr v0


-- gametime to be from realtim....
-- Replace four separate instances:
-- # this causes the time elapses even while in pause. so bugged
eeInsnReplace(0x108a78, 0x8c629790, 0x40024800) -- lw     v0,-26736(v1) -> mfc0      $v0,$count
-- # also maybe this causes 'negative' race time as well.
eeInsnReplace(0x108a7c, 0x0040f809, 0x00000000) -- jalr v0          -> jr        $ra
-- we should be OK even without this because skipping frame works (mostly).
eeInsnReplace(0x108c80, 0x8c629790, 0x40024800) -- lw     v0,-26736(v1) -> mfc0      $v0,$count
--  
eeInsnReplace(0x108c84, 0x0040f809, 0x00000000) -- jalr v0          -> jr        $ra
-- local prevtime = 0.0
eeInsnReplace(0x108ea4, 0x8c629790, 0x40024800) -- lw     v0,-26736(v1) -> mfc0      $v0,$count
-- eeObj.AddHook(0x12350c, 0x27bdfec0, function()
eeInsnReplace(0x108ea8, 0x0040f809, 0x00000000) -- jalr v0          -> jr        $ra
-- local curtime = os.clock()
eeInsnReplace(0x10902c, 0x8c629790, 0x40024800) -- lw     v0,-26736(v1) -> mfc0      $v0,$count
-- if prevtime ~= 0.0 then
eeInsnReplace(0x109030, 0x0040f809, 0x00000000) -- jalr v0          -> jr        $ra
-- eeObj.WriteMemFloat(eeObj.GetGpr(gpr.gp)-31776, curtime - prevtime)
-- end
-- prevtime = curtime
-- end)


-- to work skipping frame mechanism correctly...
-- ------------------------- OVERLAY MANAGER --------------------------
-- the game checks a flag set by INTC GS whether GS still does his job or not to
g_OnOverlayRegistered = function(filename, start, size)
-- determine whether it should skip a frame or not.
-- global function provided for adding per-overlay callback handlers.
-- Unfortunately we don't have the actual timing of GS FINISH signal.
end
-- Instead of that, we check EE clock to determine to skip or not.


local ee_frequency = 294912000
local DH8 = function()
local vsync_frequency = 59.94 -- use interlace freq.  
local s1 = eeObj.GetGpr    (gpr.s1)
local filename = eeObj.ReadMemStr(s1 + 17)
local segment = eeObj.ReadMem32 (s1 +  8)
local main = eeObj.ReadMem32 (segment +  4)
local mainSize = eeObj.ReadMem32 (segment +  8)
local top = eeObj.ReadMem32 (segment + 36)
local topSize = eeObj.ReadMem32 (segment + 40)


local one_vsync_clock_on_ntsc = math.floor(ee_frequency / vsync_frequency)
if emuObj.IsToolingVerbose() then
print( string.format("--> LOADED SEGMENT \"%s\" MAIN %08x size %x TOP %08x size %x", filename, main, mainSize, top, topSize) )
end


eeOverlay.Register(filename .. ".main", main, mainSize, false)
eeOverlay.Register(filename .. ".top",  top,  topSize,  true )


-- Kinetica has some inconsistency among frames -- some frames take unusually long, possibly due
--local debugObj = getDebugObject()
-- to AI updatesIn these cases, it is necessary to skip multiple frames to catch the game's
--debugObj.eDumpDisasmToFile ("./DisasmGoal/Jak3/" .. filename .. ".main.dasm", main, mainSize, 0)
-- clock back up to realtimeTo do so, we track 'expected_clock' over time, so that especially
--debugObj.eDumpDisasmToFile ("./DisasmGoal/Jak3/" .. filename .. ".top.dasm",  top, topSize, 0)
-- slow frames are compensated for over time.
--debugObj.eDumpAotToFile    ("./DisasmGoal/Jak3/" .. filename .. ".main.aot", main, mainSize, 0)
--debugObj.eDumpAotToFile    ("./DisasmGoal/Jak3/" .. filename .. ".top.aot",  top,  topSize,  0)


local prev_clock = 0
if (g_OnOverlayRegistered ~= nil) then
local expected_clock = 0
-- Make sure to execute any previously registered OnOverlay handler
g_OnOverlayRegistered(filename .. ".main", main, mainSize)
g_OnOverlayRegistered(filename .. ".top",  top,  topSize )
end


eeObj.AddHook(0x181f7c, 0x8f82bf54, function()
end
-- It hits here when it skips a frame.
 
--local diff = eeObj.GetClock() - prev_clock
eeObj.AddHook(0x1091d4, 0x0080c825, DH8)    --    <ndi::link_control::finish(void)>:
 
local clock = eeObj.GetClock()
-- --------------------------------------------------------------------
--local diff  = clock - expected_clock
assert(g_OnOverlayRegistered ~= nil)
--print(string.format("SKIP FRAME: diff=%7d", diff))
local prev_OnOverlayRegistered = g_OnOverlayRegistered


--prev_clock    = eeObj.GetClock() -- just update the clock.
g_OnOverlayRegistered = function(filename, start, size)
expected_clock = expected_clock + one_vsync_clock_on_ntsc
if (prev_OnOverlayRegistered ~= nil) then
end)
-- Make sure to execute any previously registered OnOverlay handler
eeObj.AddHook(0x18202c, 0x8f84bf54, function()
prev_OnOverlayRegistered(filename, start, size)
local clock = eeObj.GetClock()
end
--local diff = clock - prev_clock
--print(string.format("diff=%d vsync_term=%f %s", diff, one_vsync_clock_on_ntsc, diff > one_vsync_clock_on_ntsc and "SKIP" or ""))
local diff = clock - expected_clock
-- Sanity correction -- to handle cases where expected_clock contents is
-- zero or out-dated.
if (math.abs(diff) > (one_vsync_clock_on_ntsc * 6)) then
expected_clock = clock
end
-- print(string.format("diff=%7d %s", diff, diff > 17000 and "SKIP" or ""))
               
if diff > 17000 then
eeObj.SetGpr(gpr.a0, 1)
end
               
-- update clock
--prev_clock    = clock
expected_clock = expected_clock + one_vsync_clock_on_ntsc
end)


if filename == "sparticle-launcher.main" then
-- this RNG-sqrt instance is removed for performance.  Additionally, not corrupting the RNG seed with
-- bad sqrt math is always a good thing in my book --jstine


-- Applies a cycle rate hack to what I presume is the game logic pipeline, for roughly per-frame updates.
assert(eeObj.ReadMem32(start + 0x005de4) == 0x4be1043d) -- vrget.wxyz  vf01,r
assert(eeObj.ReadMem32(start + 0x005de8) == 0x4a0103bd) -- vsqrt        q,vf01x
assert(eeObj.ReadMem32(start + 0x005df0) == 0x4b0000a0) -- vaddq.x      vf02,vf00,q


local mpgCycles_default = 900
assert(eeObj.ReadMem32(start + 0x005e4c) == 0x4a00143f) -- vrxor        r,vf02x
local currentMpgCycles = mpgCycles_default
assert(eeObj.ReadMem32(start + 0x005ef8) == 0x4a00143f) -- vrxor        r,vf02x
assert(eeObj.ReadMem32(start + 0x005f80) == 0x4a00143f) -- vrxor        r,vf02x
assert(eeObj.ReadMem32(start + 0x006018) == 0x4a00143f) -- vrxor        r,vf02x


local checkNeedsSpeedHack = function()
eeObj.WriteMem32(start + 0x005de4, 0x00000000)
local stageId    = eeObj.ReadMem32(0x01fce8c)
eeObj.WriteMem32(start + 0x005de8, 0x00000000)
local numPlayers = eeObj.ReadMem32(0x01ffd78) -- 0x01ffd7c seems to always match this one...
eeObj.WriteMem32(start + 0x005df0, 0x00000000)


-- print(string.format("stageId = %d, numPlayers = %d", stageId, numPlayers))
eeObj.WriteMem32(start + 0x005e4c, 0x00000000)
eeObj.WriteMem32(start + 0x005ef8, 0x00000000)
-- 3 = Electrica
eeObj.WriteMem32(start + 0x005f80, 0x00000000)
-- 7 = Electrica II
eeObj.WriteMem32(start + 0x006018, 0x00000000)
-- 8 = Cliffhanger
end
end
local newMpgCycles = mpgCycles_default
 
if (stageId == 3 or stageId == 7 or stageId == 8) then
-- --------------------------------------------------------------------------------------
-- diagnostic for checking the Jak engine's internal frame skipping mechanism.
-- $fp30 contains a ratio of time-taken-to-16ms to render the scene, eg. 18 ms is approx 1.15.
-- The engine will proceed to make a series of logical decisions according to this value.
-- The value read out here will be affected by both EE cycle rates and adaptive GS penalties.
-- I tried modifiying this value directly but it gives somewhat unsatisfactory results.


-- note: this will also apply to demo loops (0 players)
-- eeOverlay.AddPreHook("drawable.main",0x208+8, 0x461E0034, function()
newMpgCycles = newMpgCycles + 120
-- local v1 = eeObj.GetGpr(gpr.v1)
-- print(string.format("fpuCompare fpr0=%f fpr30=%f", eeObj.GetFpr(0), eeObj.GetFpr(30)))
if stageId == 7 then
-- end)
-- Electrica 2 is extra-special slow in some areas.
-- --------------------------------------------------------------------------------------
-- (and 2-player mode on this map runs enough mpgs that extra penalty isn't needed)
</pre>
if numPlayers == 2 then
newMpgCycles = newMpgCycles - 100
else
newMpgCycles = newMpgCycles + 275
end
elseif numPlayers == 2 then
-- increment is not so big here because two player mode already runs many more VU programs.
newMpgCycles = newMpgCycles + 100
end


end
====Jak 2====
'''CLI'''
<br>SCUS-97265
<pre>
--ee-jit-pagefault-threshold=20
--gs-frontend-opt-mode=1
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--cop2-no-clamping=1
--cop2-clamp-range=0x2A18,0x2a20,joint.seg1
--vu1-mpg-cycles=250
</pre>
'''LUA'''
<br>SCUS-97265
<pre>
apiRequest(2.2)


if currentMpgCycles ~= newMpgCycles then
local gpr    = require("ee-gpr-alias")
-- print ( string.format("################### Setting mpg-cycles = %d", newMpgCycles) )
local emuObj = getEmuObject()
eeObj.Vu1MpgCycles(newMpgCycles)
local eeObj = getEEObject()
currentMpgCycles = newMpgCycles
local eeOverlay = eeObj.getOverlayObject()
end
local iopObj    = getIOPObject()
end
local gsObj = getGsObject()


eeObj.AddHookJT(0x15ca2c,0x27bdff20,checkNeedsSpeedHack)


</pre>
-- Fix shadow
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1  } )


====King of Fighters 98 Ultimate Match====
-- Reduce flush count
ALL
emuObj.SetGsTitleFix( "SetSelfRender", "reserved", { fbmask= 0x00FFFFFF , renderSelf=1 , zmsk=1 , alpha=0 , texMode=1 } )
<br>CLI
<pre>--force-frame-blend=1
--gs-use-deferred-l2h=0
#Graphical fix.</pre>


SLES_552.80
---------------------------------------------------------------------------------
<br>SLES-55280_features.lua
-- Basic Block breakers for EE AOT Injection
<pre>This is a substantial file. Over 800 lines with additional controller/fightstick support and various shader/bezel files. I'm sharing the file itself as a download link.
eeOverlay.AddPreHook("traffic-engine.seg1", 0x004474, 0x0080e025, "nop" )
eeOverlay.AddPreHook("spatial-hash.seg1", 0x004474, 0x0080e025, "nop" )


https://drive.google.com/file/d/1-lArL1Yqe079Ni3G-ZtHr8hqNPUsjQJy/view
---------------------------------------------------------------------------------


#More stick support, shaders, bezels, widescreen fix.</pre>
-- ------------------------- OVERLAY MANAGER --------------------------
g_OnOverlayRegistered = function(filename, start, size)
-- global function provided for adding per-overlay callback handlers.
end


====King of Fighters 2000====
local DH8 = function()
ALL
local s0 = eeObj.GetGpr(gpr.s0)
<br>CLI
<pre>--gs-uprender=none
local linkblock = eeObj.ReadMem32(s0+0x60) -- was 0x5c on Jak1
--gs-upscale=point
--host-audio-latency=0.01
--print( string.format("--> PRELOAD %08x %08x",s0, linkblock) )
--hid-pad=1
#graphical fixes and support for further fightsticks.</pre>
local linkblock_allocate_length = eeObj.ReadMem32 (linkblock + 0x00)
local linkblock_allocate_version = eeObj.ReadMem32 (linkblock + 0x04)
local linkblock_allocate_segment_count = eeObj.ReadMem32 (linkblock + 0x08)
local linkblock_allocate_name = eeObj.ReadMemStr(linkblock + 0x0c)
local linkblock_allocate_seg1_linkptr = eeObj.ReadMem32 (linkblock + 0x4C)
local linkblock_allocate_seg1_dataptr = eeObj.ReadMem32 (linkblock + 0x50)
local linkblock_allocate_seg1_size = eeObj.ReadMem32 (linkblock + 0x54)
local linkblock_allocate_seg1_flags = eeObj.ReadMem32 (linkblock + 0x58)
                                                             
local linkblock_allocate_seg2_linkptr = eeObj.ReadMem32 (linkblock + 0x5C)
local linkblock_allocate_seg2_dataptr = eeObj.ReadMem32 (linkblock + 0x60)
local linkblock_allocate_seg2_size = eeObj.ReadMem32 (linkblock + 0x64)
local linkblock_allocate_seg2_flags = eeObj.ReadMem32 (linkblock + 0x68)
                                                             
local linkblock_allocate_seg3_linkptr = eeObj.ReadMem32 (linkblock + 0x6C)
local linkblock_allocate_seg3_dataptr = eeObj.ReadMem32 (linkblock + 0x70)
local linkblock_allocate_seg3_size = eeObj.ReadMem32 (linkblock + 0x74)
local linkblock_allocate_seg3_flags = eeObj.ReadMem32 (linkblock + 0x78)
-- seg1 is equiv to main in Jak3
-- seg3 is equiv to top  in Jak3
-- seg2 appears to be unused ... --jstine (it's a debug segment, so likely unused on retail) DH


SLUS_208.34
if emuObj.IsToolingVerbose() then
<br>LUA
print( string.format("--> LOADED SEGMENT alloc_len %08x ver %08x segcount %08x  name:\"%s\"", linkblock_allocate_length, linkblock_allocate_version, linkblock_allocate_segment_count, linkblock_allocate_name) )
<pre>-- The King of Fighters 2000
print( string.format("    seg1linkptr %08x seg1dataptr %08x seg1size %08x seg1flags %08x", linkblock_allocate_seg1_linkptr, linkblock_allocate_seg1_dataptr, linkblock_allocate_seg1_size, linkblock_allocate_seg1_flags) )
print( string.format("    seg2linkptr %08x seg2dataptr %08x seg2size %08x seg2flags %08x", linkblock_allocate_seg2_linkptr, linkblock_allocate_seg2_dataptr, linkblock_allocate_seg2_size, linkblock_allocate_seg2_flags) )
print( string.format("    seg3linkptr %08x seg3dataptr %08x seg3size %08x seg3flags %08x", linkblock_allocate_seg3_linkptr, linkblock_allocate_seg3_dataptr, linkblock_allocate_seg3_size, linkblock_allocate_seg3_flags) )
end


apiRequest(1.1)
-- local debugObj = getDebugObject()
-- debugObj.eDumpDisasmToFile("./DisasmGoal/JakII/" .. linkblock_allocate_name .. ".seg1.dasm", linkblock_allocate_seg1_dataptr, linkblock_allocate_seg1_size, 0)
-- debugObj.eDumpDisasmToFile("./DisasmGoal/JakII/" .. linkblock_allocate_name .. ".seg3.dasm", linkblock_allocate_seg3_dataptr, linkblock_allocate_seg3_size, 0)
-- debugObj.eDumpAotToFile  ("./DisasmGoal/JakII/" .. linkblock_allocate_name .. ".seg1.aot",  linkblock_allocate_seg1_dataptr, linkblock_allocate_seg1_size, 0)
-- debugObj.eDumpAotToFile  ("./DisasmGoal/JakII/" .. linkblock_allocate_name .. ".seg3.aot",  linkblock_allocate_seg3_dataptr, linkblock_allocate_seg3_size, 0)


if linkblock_allocate_seg1_size ~= 0 then eeOverlay.Register(linkblock_allocate_name .. ".seg1",  linkblock_allocate_seg1_dataptr, linkblock_allocate_seg1_size, false) end
if linkblock_allocate_seg3_size ~= 0 then eeOverlay.Register(linkblock_allocate_name .. ".seg3",  linkblock_allocate_seg3_dataptr, linkblock_allocate_seg3_size, true)  end


local emuObj = getEmuObject()
if (g_OnOverlayRegistered ~= nil) then
--will fix sprite rendering artifact
-- Make sure to execute any previously registered OnOverlay handler
ndx = 28
if linkblock_allocate_seg1_size ~= 0 then g_OnOverlayRegistered(linkblock_allocate_name .. ".seg1", linkblock_allocate_seg1_dataptr, linkblock_allocate_seg1_size) end
val = 0x86
if linkblock_allocate_seg1_size ~= 0 then g_OnOverlayRegistered(linkblock_allocate_name .. ".seg3", linkblock_allocate_seg3_dataptr, linkblock_allocate_seg3_size) end
-- spriteCorrectionTab[ndx] = val
end
emuObj.SetGsTitleFix( "globalSet", "reserved", { fixSpriteDivTab = val | ( ndx<<16) })
end
#graphical fixes.</pre>


SLUS_208.34
assert(g_OnOverlayRegistered ~= nil)
<br>SLUS-20834_features.lua
local prev_OnOverlayRegistered = g_OnOverlayRegistered
<pre>This is a substantial file. Over 700 lines with additional controller/fightstick support and various shader/bezel files. I'm sharing the file itself as a download link.


https://drive.google.com/file/d/1FsPnuxgEa0ymnGdU6w2tdy-eamRN6l3e/view
g_OnOverlayRegistered = function(filename, start, size)
if (prev_OnOverlayRegistered ~= nil) then
-- Make sure to execute any previously registered OnOverlay handler
prev_OnOverlayRegistered(filename, start, size)
end


#More stick support, shaders, bezels, widescreen fix.</pre>
if filename == "sparticle-launcher.seg1" then
-- this RNG-sqrt instance is removed for performance.  Additionally, not corrupting the RNG seed with
-- bad sqrt math is always a good thing in my book --jstine


====Manhunt====
assert(eeObj.ReadMem32(start + 0x0044ec) == 0x4be1043d) -- vrget.wxyz  vf01,r
SLUS_208.27
assert(eeObj.ReadMem32(start + 0x0044f0) == 0x4a0103bd) -- vsqrt        q,vf01x
<br>CLI
assert(eeObj.ReadMem32(start + 0x0044f8) == 0x4b0000a0) -- vaddq.x      vf02,vf00,q
<pre>--ee-hook=0x4329e0,FastForwardClock,0x1600fff1
--gs-uv-shift-pointsampling=1
--ee-hook=0x1d1d60,AdvanceClock,0x27bdffb0,225
--ee-hook=0x1d71e0,AdvanceClock,0x0c09a4d0,100
#Fix crane issue, and probably fixing lightsourcing.</pre>


SLUS_208.27
assert(eeObj.ReadMem32(start + 0x00454c) == 0x4a00143f) -- vrxor        r,vf02x
<br>Lua
assert(eeObj.ReadMem32(start + 0x0045f8) == 0x4a00143f) -- vrxor        r,vf02x
<pre>-- Manhunt [US]
assert(eeObj.ReadMem32(start + 0x004680) == 0x4a00143f) -- vrxor        r,vf02x
assert(eeObj.ReadMem32(start + 0x004718) == 0x4a00143f) -- vrxor        r,vf02x


local gpr = require('ee-gpr-alias')
eeObj.WriteMem32(start + 0x0044ec, 0x00000000)
eeObj.WriteMem32(start + 0x0044f0, 0x00000000)
eeObj.WriteMem32(start + 0x0044f8, 0x00000000)


apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.
eeObj.WriteMem32(start + 0x00454c, 0x00000000)
eeObj.WriteMem32(start + 0x0045f8, 0x00000000)
eeObj.WriteMem32(start + 0x004680, 0x00000000)
eeObj.WriteMem32(start + 0x004718, 0x00000000)
end
end


local emuObj = getEmuObject()
-- hooked in link_control::finish(void)>:
local eeObj = getEEObject()
function install_c_hooks(offset)
eeObj.AddHook(0x1085a0 + offset , 0x0080c825, DH8)  
end


-- Bug #9413
-- 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} )


-- Bug#9277
local Ready = 0
-- Shorten the timeout period for some particular execution command(s).
-- When entering the crane, some instruction is executed with a wait period of 0x7333.
-- Shortening the wait period to 0x4000 it.  Note that 0x5000 is enough to fix entering the
-- crane once, but a more aggressive value was needed for subsequent entry into the crane.


local FixBug9277 = function()
local DetectFunc = function()
local s0 = eeObj.GetGpr(gpr.s0)
if Ready == 0 then
--local v0 = eeObj.GetGpr(gpr.v0)
--print( string.format("-------- v0=0x%08x s0=0x%08x", v0, s0) )
local discID = eeObj.ReadMemStr(0x0012fc8)
if s0 == 0x7333 then
eeObj.SetGpr(gpr.s0, 0x5800)
if (discID ~= "") then
end
if (discID == "cdrom0:\\SCUS_972.65;1") or (discID == "cdrom0:\\SCPS_150.57;1") then
-- US or Japan Disc
Ready = 1
install_c_hooks(0)
print( string.format("********************* DETECTED USA, JAPAN DISC ********************" ) )
elseif (discID == "cdrom0:\\SCKA_200.10;1") then
Ready = 1
install_c_hooks(0x08)
print( string.format("********************* KOREA DISC ********************" ) )
elseif (discID == "cdrom0:\\SCES_516.08;1") then
-- European Disc
Ready = 1
install_c_hooks(0xb8)
print( string.format("********************* DETECTED EUROPE DISC (SCES-51608) ********************" ) )
elseif (discID == "rom0:PS2LOGO") then
-- loading PS2 logo
elseif (discID == "EELOAD") then
-- loading?
elseif (discID == "rom0:OSDSYS") then
-- loading initial boot
else
print( string.format("--> DISC ID \"%s\"", discID ) )
end
end
end
end
end


-- No longer seems necessary, when FastForwardClock is applied here instead (see _cli.conf)
emuObj.AddVsyncHook(DetectFunc)
eeObj.AddHookJT(0x1d71f8, 0x10000036, FixBug9277)
</pre>
#Further bug fixes as well as fixing bloom/overglare from lightsources.</pre>
====Max Payne====
SLES_503.26
<br>CLI
<pre>--gs-use-clut-merge=1
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"
--vu1-no-clamping=1
--vu0-no-clamping=1
--fpu-no-clamping=1
--force-pal-60hz=1
--vu1-mpg-cycles=1000
--safe-area-min=1.0
--fpu-accurate-mul-fast=1
--fpu-accurate-muldiv-range=0x2acce0,0x2acce0


#Graphics clean-up</pre>
====Kinetica====
 
'''CLI'''
SLES_503.26
<br>SCUS-97132
<br> Features Lua
<pre>
<pre>-- Max Payne [US]
--vu1-clamp-range=0x386,0x386
--vu1-clamp-range=0x5e0,0x5f0 # another gritches
--gs-kernel-cl-up="up2x2skipinterp"
--vu1-injection=1
--vu1-jr-cache-policy=sameprog
--vu1-jalr-cache-policy=sameprog
--vu1-mpg-cycles=900
--host-audio-latency=0.10
--cdvd-sector-read-cycles=40000
</pre>


-- Lua 5.3
'''LUA'''
-- Title: Max Payne - SLES-50326 (Europe FIGS) v1.00
<br>SCUS-97132
<pre>
local gpr = require("ee-gpr-alias")
apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.


local emuObj  = getEmuObject()
local eeObj        = getEEObject()


require( "ee-gpr-alias" ) -- you can access EE GPR by alias (gpr.a0 / gpr["a0"])
-- require("debughooks")
-- local iopObj = getIOPObject()
-- iopObj.AddHook(0x000135ac, 0x27bdffe0, DebugHooks.h_IOP_ioman_write)


apiRequest(0.2) -- request version 0.2 API for throttling control.
-- bug#8123
-- Skip resetting VAG stream which happens on an error.
iopInsnReplace(0x00090028, 0x16220009, 0x08024014) -- bne $s1,$v0,0x00090050 => j 0x00090050


local eeObj = getEEObject()
-- bug#9405 - advance EE clock according to spinning-loop SIF activity.
local emuObj = getEmuObject()
local skip_syncDCache = function()
-- Original value when actually processing syncDCache was 3300
-- Boosting to 8000 helps reduce bottleneck
eeObj.AdvanceClock(8000)
end


eeInsnReplace(0x1ca9e0, 0x27bdffe0, 0x03e00008)
eeInsnReplace(0x1ca9e4, 0x0080302d, 0x00000000)
eeObj.AddHookJT(0x1ca9e0, 0x03e00008, skip_syncDCache)


-- gametime to be from realtim....
-- # this causes the time elapses even while in pause. so bugged
-- # also maybe this causes 'negative' race time as well.
-- we should be OK even without this because skipping frame works (mostly).
--
-- local prevtime = 0.0
-- eeObj.AddHook(0x12350c, 0x27bdfec0, function()
-- local curtime = os.clock()
-- if prevtime ~= 0.0 then
-- eeObj.WriteMemFloat(eeObj.GetGpr(gpr.gp)-31776, curtime - prevtime)
-- end
-- prevtime = curtime
-- end)


local TH1A = -- start of main()
-- to work skipping frame mechanism correctly...
function()
-- the game checks a flag set by INTC GS whether GS still does his job or not to
emuObj.ThrottleMax()
-- determine whether it should skip a frame or not.
end
-- Unfortunately we don't have the actual timing of GS FINISH signal.
-- Instead of that, we check EE clock to determine to skip or not.


local TH1B = -- init loading screen
local ee_frequency = 294912000
function()
local vsync_frequency = 59.94 -- use interlace freq.  
local mode = eeObj.GetGpr(gpr.a0)


if mode ~= 4 then -- not sure what mode 4 is, but doesn't precede a real loading
local one_vsync_clock_on_ntsc = math.floor(ee_frequency / vsync_frequency)
emuObj.ThrottleMax()
end
end


local TH1C = -- advance progress bar
function()
local pct = eeObj.GetFpr(2)


if pct >= 1.0 then
-- Kinetica has some inconsistency among frames -- some frames take unusually long, possibly due
emuObj.ThrottleNorm()
-- to AI updates. In these cases, it is necessary to skip multiple frames to catch the game's
end
-- clock back up to realtime. To do so, we track 'expected_clock' over time, so that especially
end
-- slow frames are compensated for over time.


local prev_clock = 0
local expected_clock = 0


eeObj.AddHook(0x181f7c, 0x8f82bf54, function()
-- It hits here when it skips a frame.
--local diff = eeObj.GetClock() - prev_clock
local clock = eeObj.GetClock()
--local diff  = clock - expected_clock
--print(string.format("SKIP FRAME: diff=%7d", diff))


-- register hooks
--prev_clock    = eeObj.GetClock() -- just update the clock.
 
expected_clock = expected_clock + one_vsync_clock_on_ntsc
local registeredHooks = {}
end)
 
eeObj.AddHook(0x18202c, 0x8f84bf54, function()
maxpayne_features_unregisterHooks = function() -- global function (called by trophy_data)
local clock = eeObj.GetClock()
for _, hook in pairs(registeredHooks) do
--local diff = clock - prev_clock
eeObj.RemoveHook(hook)
--print(string.format("diff=%d vsync_term=%f %s", diff, one_vsync_clock_on_ntsc, diff > one_vsync_clock_on_ntsc and "SKIP" or ""))
end
local diff = clock - expected_clock
registeredHooks = {}
end
-- Sanity correction -- to handle cases where expected_clock contents is
-- zero or out-dated.
if (math.abs(diff) > (one_vsync_clock_on_ntsc * 6)) then
expected_clock = clock
end
-- print(string.format("diff=%7d %s", diff, diff > 17000 and "SKIP" or ""))
               
if diff > 17000 then
eeObj.SetGpr(gpr.a0, 1)
end
               
-- update clock
--prev_clock    = clock
expected_clock = expected_clock + one_vsync_clock_on_ntsc
end)


maxpayne_features_registerHooks = function() -- global function (called by trophy_data)
registeredHooks = {
eeObj.AddHook(0x133dc8, 0x24030001, TH1A), -- <main>:
eeObj.AddHook(0x15ed7c, 0x24030003, TH1B), -- <MaxPayne_GameMode::initLoadingScreen(void)>:
eeObj.AddHook(0x133078, 0xc4a20000, TH1C), -- <UpdateProgressBarKH(void)>:
}
end</pre>


====Metal Slug Anthology====
-- Applies a cycle rate hack to what I presume is the game logic pipeline, for roughly per-frame updates.
ALL
<br>CLI
<pre>--host-audio-latency=0.010
--gs-upscale=point
--gs-uprender=none
#fix for graphical glitches.</pre>


SLUS_215.50
local mpgCycles_default = 900
<br>LUA
local currentMpgCycles = mpgCycles_default
<pre>
-- Metal Slug Anthology PS2 - SLUS-21550 (USA)


apiRequest(1.2) -- request version 0.1 API. Calling apiRequest() is mandatory.
local checkNeedsSpeedHack = function()
local stageId    = eeObj.ReadMem32(0x01fce8c)
local numPlayers = eeObj.ReadMem32(0x01ffd78) -- 0x01ffd7c seems to always match this one...


local eeObj = getEEObject()
-- print(string.format("stageId = %d, numPlayers = %d", stageId, numPlayers))
local emuObj = getEmuObject()
-- 3 = Electrica
-- 7 = Electrica II
-- 8 = Cliffhanger
local newMpgCycles = mpgCycles_default
if (stageId == 3 or stageId == 7 or stageId == 8) then


-- Fix for black screen booting an elf. This is a game bug.
-- note: this will also apply to demo loops (0 players)
-- The v1.0 of the game suffered from an intermittent bug on the real PS2
newMpgCycles = newMpgCycles + 120
-- where sometimes it would hang on a black screen trying to launch a new elf.
-- This is apparently due to a bad IOP state, which caused sceCdInit to hang.
if stageId == 7 then
-- Later versions of the game (1.1, 1.2) attempted to fix this in different ways.
-- Electrica 2 is extra-special slow in some areas.
-- On Olympus, v1.0 (USA) hangs always, while v1.2 (EUR/JPN) works always.
-- (and 2-player mode on this map runs enough mpgs that extra penalty isn't needed)
-- The fix implemented here replaces a call to FlushCache() to loadImageAndReboot(),
if numPlayers == 2 then
-- which is a function that reboots the IOP and resolves the hang.
newMpgCycles = newMpgCycles - 100
else
newMpgCycles = newMpgCycles + 275
end
elseif numPlayers == 2 then
-- increment is not so big here because two player mode already runs many more VU programs.
newMpgCycles = newMpgCycles + 100
end
 
end
 
if currentMpgCycles ~= newMpgCycles then
-- print ( string.format("################### Setting mpg-cycles = %d", newMpgCycles) )
eeObj.Vu1MpgCycles(newMpgCycles)
currentMpgCycles = newMpgCycles
end
end
 
eeObj.AddHookJT(0x15ca2c,0x27bdff20,checkNeedsSpeedHack)


eeInsnReplace(0x189c24, 0x0c08f7f8, 0x0c061dd2) -- FlushCache() -> loadImageAndReboot()
eeInsnReplace(0x117804, 0x0c0c1e08, 0x0c045e20) -- FlushCache() -> loadImageAndReboot()
</pre>
</pre>


====Okage====
====King of Fighters 98 Ultimate Match====
'''TXT'''
ALL
<br>SCUS-97129
<br>CLI
<pre>
<pre>--force-frame-blend=1
--vu1-mpg-cycles=50
--gs-use-deferred-l2h=0
--vu1-mpg-cycles=850,$037,$7b3
#Graphical fix.</pre>
--vu1-mpg-cycles=150,$2b4,$7c4
</pre>
'''LUA'''
<br>SCUS-97129
<pre>
require("ee-gpr-alias")
require("ps2")
apiRequest(0.6) -- request version 0.1 API. Calling apiRequest() is mandatory.


local eeObj = getEEObject()
SLES_552.80
<br>SLES-55280_features.lua
<pre>This is a substantial file. Over 800 lines with additional controller/fightstick support and various shader/bezel files. I'm sharing the file itself as a download link.


-- bug#8740
https://drive.google.com/file/d/1-lArL1Yqe079Ni3G-ZtHr8hqNPUsjQJy/view
-- SPSetDirect(addr, char-pos, char-pos, x-coord, y-coord, width, height)
-- reduce width just 1 pix.
local Replace_1a1fb0 = InsnOverlay( {
0x0806720a, --        j      0x19c828
0x2529ffff, --        addiu  t1,t1,-1
})
eeInsnReplace(0x1a1fb0, 0x0c06720a, 0x0c000000 | (Replace_1a1fb0>>2)) -- jal 19c828 <SPSetDirect>


</pre>
#More stick support, shaders, bezels, widescreen fix.</pre>


====Parappa the Rapper 2====
====King of Fighters 2000====
ALL
ALL
<br>CLI
<br>CLI
<pre>--host-audio-latency=0.01
<pre>--gs-uprender=none
--gs-upscale=point
--host-audio-latency=0.01
--hid-pad=1
#graphical fixes and support for further fightsticks.</pre>


#fix for audio off sync.</pre>
SLUS_208.34
 
SCUS_971.67
<br>LUA
<br>LUA
<pre>
<pre>-- The King of Fighters 2000


-- Parappa the Rapper 2  [SCUS-97167]
apiRequest(1.1)




apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.
local emuObj = getEmuObject()
--will fix sprite rendering artifact
ndx = 28
val = 0x86
-- spriteCorrectionTab[ndx] = val
emuObj.SetGsTitleFix( "globalSet",  "reserved", { fixSpriteDivTab = val | ( ndx<<16) })
#graphical fixes.</pre>


require( "ee-gpr-alias" )
SLUS_208.34
require( "ee-hwaddr" )
<br>SLUS-20834_features.lua
<pre>This is a substantial file. Over 700 lines with additional controller/fightstick support and various shader/bezel files. I'm sharing the file itself as a download link.


local eeObj = getEEObject()
https://drive.google.com/file/d/1FsPnuxgEa0ymnGdU6w2tdy-eamRN6l3e/view


-- ================================================================================================
#More stick support, shaders, bezels, widescreen fix.</pre>
-- Title issues racy combination of VIF1 and GIF transfers.  It expects GIF to finish ahead of VU
-- XGKICK (via VIF1), which is atypical among PS2 titles (XGKICK has HW priority over GIF, and so
-- GIF can only finish ahead of XGKICK in certain extreme cases).
--
-- Fixed by delaying the specific VIF1 transfer (identified by MADR) for a long time to ensure GIF
-- gains arbitration and finishes ahead of XGKICKs.
--
local fix01_dma_vif1 =
function()
local ee = eeObj
local tgtaddr = ee.GetGpr(gpr.s0)


-- print( string.format("success pt.1 : %x %x", vif1_hw.CHCR, tgtaddr ) )
====Manhunt====
SLUS_208.27
<br>CLI
<pre>--ee-hook=0x4329e0,FastForwardClock,0x1600fff1
--gs-uv-shift-pointsampling=1
--ee-hook=0x1d1d60,AdvanceClock,0x27bdffb0,225
--ee-hook=0x1d71e0,AdvanceClock,0x0c09a4d0,100
#Fix crane issue, and probably fixing lightsourcing.</pre>


if tgtaddr == vif1_hw.CHCR then
SLUS_208.27
<br>Lua
<pre>-- Manhunt [US]


-- expected:
local gpr = require('ee-gpr-alias')
--  # DIR==1 and MOD==1  (chain)
-- # TADR==0x01C76AA0


local chcr = ee.GetGPR(gpr.v0)
apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.


if (chcr & 0x05) == 0x05 then
local emuObj = getEmuObject()
local tadr = ee.ReadMem32(vif1_hw.TADR);
local eeObj  = getEEObject()
if tadr == 0x01C76AA0 then
-- 0x6000 works fine, 0x6500 adds a little extra cushion.
ee.SchedulerDelayEvent("vif1.dma", 0x6500)
-- print( "Parappa fix applied!" )
end
end
end
end
-- ================================================================================================


eeObj.AddHook(0x0015A008, 0xAE020000, fix01_dma_vif1)
-- Bug #9413
-- 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} )


-- ================================================================================================
-- Bug#9277
-- Our emulator has accuracy problems on so many places. In this title, we have problems on VU.
-- Shorten the timeout period for some particular execution command(s).
-- To be accurate on VU is quite painful (we won't be able to get reasonable performance with it)
-- When entering the crane, some instruction is executed with a wait period of 0x7333.
-- So as workaround, we just disable bilinear textures on Render-To-Texture drawing.
-- Shortening the wait period to 0x4000 it.  Note that 0x5000 is enough to fix entering the
-- Bug#8122
-- crane once, but a more aggressive value was needed for subsequent entry into the crane.
eeInsnReplace(0x118084, 0xde260008, 0x24060000) -- ld a2,8(s1)
eeInsnReplace(0x118798, 0xde260008, 0x24060000) -- ld a2,8(s1)
eeInsnReplace(0x118868, 0xde660008, 0x24060000) -- ld a2,8(s3)
eeInsnReplace(0x119d18, 0xdc460008, 0x24060000) -- ld a2,8(v0)
eeInsnReplace(0x119d18, 0xdc460008, 0x24060000) -- ld a2,8(v0)


</pre>
local FixBug9277 = function()
local s0 = eeObj.GetGpr(gpr.s0)
--local v0 = eeObj.GetGpr(gpr.v0)
--print( string.format("-------- v0=0x%08x s0=0x%08x", v0, s0) )
if s0 == 0x7333 then
eeObj.SetGpr(gpr.s0, 0x5800)
end
end


====Primal====
-- No longer seems necessary, when FastForwardClock is applied here instead (see _cli.conf)
CLI
eeObj.AddHookJT(0x1d71f8, 0x10000036, FixBug9277)
<pre>
#Further bug fixes as well as fixing bloom/overglare from lightsources.</pre>
--vu1-mul0fix-range=0x22f,0x22f
====Max Payne====
--vu1-mul0fix-range=0x298,0x29c
SLES_503.26
--vu1-native-patch=1
<br>CLI
--ee-hook=0x2f76c0,FastForwardClock,0x1200ffbf
<pre>--gs-use-clut-merge=1
--vu1-mpg-cycles=700
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="up2x2Simple"
--gs-kernel-cl-up="clutmerge2x2"
--cop2-no-clamp-range=0x37bd78,0x37c514    ;; CMatrix functions         
--vu1-no-clamping=1
--cop2-no-clamp-range=0x38c0e0,0x38c174    ;; CModel::CalcSkinningMatrices
--vu0-no-clamping=1
--cop2-no-clamp-range=0x391cf0,0x392084    ;; CSkelton::Update           
--fpu-no-clamping=1
</pre>
--force-pal-60hz=1
--vu1-mpg-cycles=1000
--safe-area-min=1.0
--fpu-accurate-mul-fast=1
--fpu-accurate-muldiv-range=0x2acce0,0x2acce0


LUA
#Graphics clean-up</pre>
<pre>
-- Primal  [EU]


apiRequest(1.1)
SLES_503.26
<br> Features Lua
<pre>-- Max Payne [US]


local eeObj = getEEObject()
-- Lua 5.3
local emuObj = getEmuObject()
-- Title: Max Payne - SLES-50326 (Europe FIGS) v1.00


-- Bug 9094 - Title exhibits poor performance due to VU0 spin loops.
-- The spin loops are meant to be an optimizaion on PS2 and the best way of handling them is
-- to remove them from the original code.  This can be done since the VF09 register is unsed by
-- the first portion of the VU0 mpg.
--
-- Insn replacements Summarized:
--  1. NOP the spin loop from VU0.
--  2. NOP the setup code for VI05, which is the reg tested by the VU0 spin loop
--  3. Reorder the vcallms and qmtc2.


require( "ee-gpr-alias" ) -- you can access EE GPR by alias (gpr.a0 / gpr["a0"])


-- [$167:520507ff] IBNE vi05, vi00, [$167]
apiRequest(0.2) -- request version 0.2 API for throttling control.
-- [$167:000002ff] NOP
local orig = (0x000002ff << 32) | 0x520507ff


vuInsnReplace(0, 0x167, orig, 0x8000033c | (0x000002ff << 32)) -- NOP / NOP2
local eeObj = getEEObject()
vuInsnReplace(0, 0x172, orig, 0x8000033c | (0x000002ff << 32)) -- NOP / NOP2
local emuObj = getEmuObject()


local region_base = 0x399c5c


eeInsnReplace(region_base + 0x000, 0x24040001, 0x00000000)  -- li a0,1 -> NOP
eeInsnReplace(region_base + 0x010, 0x48c42800, 0x00000000)  -- ctc2.ni a0,$5      -> NOP
eeInsnReplace(region_base + 0x090, 0x24040001, 0x00000000)  -- li a0,1            -> NOP
eeInsnReplace(region_base + 0x0a0, 0x48c42800, 0x00000000)  -- ctc2.ni a0,$5      -> NOP


eeInsnReplace(region_base + 0x05c, 0x48c02800, 0x00000000) -- ctc2.ni zero,$5 -> NOP
local TH1A = -- start of main()
eeInsnReplace(region_base + 0x114, 0x48c02800, 0x00000000) -- ctc2.ni zero,$5 -> NOP
function()
emuObj.ThrottleMax()
end


eeInsnReplace(region_base + 0x054,  0x4a00d839, 0x48a44800) -- vcallmsr vi27 -> qmtc2 a0,vf9
local TH1B = -- init loading screen
eeInsnReplace(region_base + 0x058,  0x48a44800, 0x4a00d839) -- qmtc2 a0,vf9 -> vcallmsr vi27
function()
eeInsnReplace(region_base + 0x10c, 0x4a00d839, 0x48a44800) -- vcallmsr vi27 -> qmtc2 a0,vf9
local mode = eeObj.GetGpr(gpr.a0)
eeInsnReplace(region_base + 0x110, 0x48a44800, 0x4a00d839) -- qmtc2 a0,vf9 -> vcallmsr vi27


-- remove heat haze distortion ( for performance reason Bug#8827 )
if mode ~= 4 then -- not sure what mode 4 is, but doesn't precede a real loading
-- reg = 0x42  packedFlags = 3( iip, tme, fst)   packedPrim  = 5(SCE_GS_PRIM_TRIFAN)
emuObj.ThrottleMax()
emuObj.SetGsTitleFix( "globalSet",  "reserved", { packedRegsLo = 0x42,packedRegsHi = 0, packedRegsNum = 2, packedFlags = 3, packedPrim = 5})
end
emuObj.SetGsTitleFix( "skipPacked", "reserved", { alpha = 0x80000044, tbp = 0x3a4000 , zmsk=1 })
end
emuObj.SetGsTitleFix( "skipPacked", "reserved", { alpha = 0x80000044, tbp = 0x348000 , zmsk=1 })
 
local TH1C = -- advance progress bar
function()
local pct = eeObj.GetFpr(2)
 
if pct >= 1.0 then
emuObj.ThrottleNorm()
end
end




-- NOP out cacheline prefetch instructions.
-- Prefetch might have been a good idea on PS2, but it is entirely unhelpful on the PS4 target.
if 1 then
eeInsnReplace(0x381e60, 0x78400040, 0x00000000) -- lq zero,64(v0)
eeInsnReplace(0x3822c0, 0x78400040, 0x00000000) -- lq zero,64(v0)
eeInsnReplace(0x38ec7c, 0x78800040, 0x00000000) -- lq zero,64(a0)
eeInsnReplace(0x38ed78, 0x78600040, 0x00000000) -- lq zero,64(v1)
eeInsnReplace(0x38eec0, 0x78a00040, 0x00000000) -- lq zero,64(a1)
eeInsnReplace(0x38fe28, 0x7a600040, 0x00000000) -- lq zero,64(s3)
eeInsnReplace(0x38fea4, 0x78800040, 0x00000000) -- lq zero,64(a0)
eeInsnReplace(0x390da8, 0x78400040, 0x00000000) -- lq zero,64(v0)
eeInsnReplace(0x391020, 0x78400040, 0x00000000) -- lq zero,64(v0)
eeInsnReplace(0x391174, 0x78a00040, 0x00000000) -- lq zero,64(a1)
eeInsnReplace(0x3912b0, 0x78a00040, 0x00000000) -- lq zero,64(a1)
eeInsnReplace(0x398790, 0x7a000040, 0x00000000) -- lq zero,64(s0)
eeInsnReplace(0x399e60, 0x78400050, 0x00000000) -- lq zero,80(v0)
eeInsnReplace(0x399ee8, 0x78400050, 0x00000000) -- lq zero,80(v0)
end


-- NOP out an idle loop meant to flush some cache lines...
-- register hooks
if 1 then
eeInsnReplace(0x331038, 0x18a00009, 0x00000000) --  blez a1,331060 <CDMAStreamIterator::AllocateBlock(unsigned int)+0x110>
eeInsnReplace(0x33103c, 0x00d41821, 0x00000000) --  addu v1,a2,s4
eeInsnReplace(0x331040, 0xbc5a0000, 0x00000000) --  cache 0x1a,0(v0)
eeInsnReplace(0x331044, 0x24a5ffff, 0x00000000) --  addiu a1,a1,-1
eeInsnReplace(0x331054, 0x1ca0fffa, 0x00000000) --  bgtz a1,331040 <CDMAStreamIterator::AllocateBlock(unsigned int)+0xf0>
eeInsnReplace(0x331058, 0x24420040, 0x00000000) --  addiu v0,v0,64
end
 
-- perf. fix bug 9094
emuObj.SetGsTitleFix( "globalSet", "reserved", {ignoreUpRenderTimeout=2} )
emuObj.SetGsTitleFix( "ignoreUpRender",  230, {} )
emuObj.SetGsTitleFix( "ignoreAreaUpdate", 0, { alpha=0x00000000 } )
emuObj.SetGsTitleFix( "ignoreAreaUpdate", 0, { alpha=0x80000048 } )


</pre>
local registeredHooks = {}


====Red Dead Revolver====
maxpayne_features_unregisterHooks = function() -- global function (called by trophy_data)
<br>SLUS-20500
for _, hook in pairs(registeredHooks) do
<br>CLI
eeObj.RemoveHook(hook)
<pre>
end
--gs-kernel-cl-up="up2x2skipInterp"
--fpu-rsqrt-fast-estimate=0
registeredHooks = {}
--mtap1=Always
end
--vif1-ignore-cmd-ints=1
 
--iop-cycle-scalar=0.80
maxpayne_features_registerHooks = function() -- global function (called by trophy_data)
--iop-hook=0x0086ac,FastForwardClock
registeredHooks = {
--ee-sif0-cycle-scalar=2.0
eeObj.AddHook(0x133dc8, 0x24030001, TH1A), -- <main>:
--ee-sif1-cycle-scalar=2.0
eeObj.AddHook(0x15ed7c, 0x24030003, TH1B), -- <MaxPayne_GameMode::initLoadingScreen(void)>:
--iop-sif1-cycle-scalar=5.0
eeObj.AddHook(0x133078, 0xc4a20000, TH1C), -- <UpdateProgressBarKH(void)>:
--iop-sif0-cycle-scalar=5.0
}
--iop-tight-slice-count=12
end</pre>
--cdvd-sector-read-cycles=5000
 
--ee-hook=0x352dd0,AdvanceClock,0x0c0ef9a2,4500
====Metal Slug Anthology====
--ee-hook=0x3b5068,FastForwardClock,0x00481024
ALL
--ee-hook=0x46fb68,FastForwardClock,0x8ca30000
<br>CLI
--ee-hook=0x46fb38,FastForwardClock,0x8c620000
<pre>--host-audio-latency=0.010
--ee-hook=0x46fb68,MfifoDrain,0x8ca30000
--gs-upscale=point
--ee-hook=0x46fb38,MfifoDrain,0x8c620000
--gs-uprender=none
--mfifo-manual-drain=0.30
#fix for graphical glitches.</pre>
--mfifo-chunk-drain-cycles=210000
 
</pre>
SLUS_215.50
<br>SLUS-20500
<br>LUA
<br>LUA
<pre>
<pre>
-- red_dead_revolver
-- Metal Slug Anthology PS2 - SLUS-21550 (USA)
local gpr = require("ee-gpr-alias")


apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.
apiRequest(1.2) -- request version 0.1 API. Calling apiRequest() is mandatory.


-- Bug 9309
local eeObj = getEEObject()
local emuObj = getEmuObject()
local emuObj = getEmuObject()
-- psm= SCE_GS_PSMCT32 (0)
emuObj.SetGsTitleFix( "forceSimpleFetch",  "reserved", {psm=0} )
emuObj.SetGsTitleFix( "fetchFromCurrBuff", "reserved", {psm=0} )


-- bug#9490 - Disable post-processing effect - <imgImageryDeriver<fxDistort>::Draw(void)>
-- Fix for black screen booting an elf. This is a game bug.
eeInsnReplace(0x4c4b78, 0x27bdfff0, 0x03e00008) -- JR $ra
-- The v1.0 of the game suffered from an intermittent bug on the real PS2
eeInsnReplace(0x4c4b7c, 0xffbf0000, 0x00000000) -- NOP
-- where sometimes it would hang on a black screen trying to launch a new elf.
-- This is apparently due to a bad IOP state, which caused sceCdInit to hang.
-- Later versions of the game (1.1, 1.2) attempted to fix this in different ways.
-- On Olympus, v1.0 (USA) hangs always, while v1.2 (EUR/JPN) works always.
-- The fix implemented here replaces a call to FlushCache() to loadImageAndReboot(),
-- which is a function that reboots the IOP and resolves the hang.


-- gfxState class writes bytes and then reads them back as words later on.
eeInsnReplace(0x189c24, 0x0c08f7f8, 0x0c061dd2) -- FlushCache() -> loadImageAndReboot()
-- This replaces most of the word readbacks with lbu equivalents to avoid STLF.
eeInsnReplace(0x117804, 0x0c0c1e08, 0x0c045e20) -- FlushCache() -> loadImageAndReboot()
-- 003c0950 <gfxState::Update_TEST(void)>:
</pre>
eeInsnReplace(0x3c0970, 0x8ce6efd8, 0x90e6efd8) -- lw a2,-4136(a3)
eeInsnReplace(0x3c09a0, 0x8ce3f37c, 0x90e3f37c) -- lw v1,-3204(a3)


-- 0032aa70 <fxFloatPropGrid::Get(Vector2 const &) const>:
====Okage====
--   The original  compiler couldn't assume that Vector2 was an aligned object, so it generated
'''TXT'''
--   ldr/sdr instructions to access it. The lack of assumption seems to have also caused it to
<br>SCUS-97129
--   spill FPU registers to memory needlessly.
<pre>
--vu1-mpg-cycles=50
--vu1-mpg-cycles=850,$037,$7b3
--vu1-mpg-cycles=150,$2b4,$7c4
</pre>
'''LUA'''
<br>SCUS-97129
<pre>
require("ee-gpr-alias")
require("ps2")
apiRequest(0.6) -- request version 0.1 API. Calling apiRequest() is mandatory.


if true then
local eeObj = getEEObject()
eeInsnReplace(0x32aa74, 0x68a20007, 0x00000000)
eeInsnReplace(0x32aa78, 0x6ca20000, 0x00000000)
eeInsnReplace(0x32aa7c, 0xb3a20017, 0xc4a00000) -- lwc1 $f0,0(a1)
eeInsnReplace(0x32aa80, 0xb7a20010, 0xc4a10004) -- lwc1 $f1,4(a1)


eeInsnReplace(0x32aa8c, 0xc7a00010, 0x00000000) -- nop
-- bug#8740
eeInsnReplace(0x32aa9c, 0xc7a10014, 0x00000000) -- nop
-- SPSetDirect(addr, char-pos, char-pos, x-coord, y-coord, width, height)
-- reduce width just 1 pix.
local Replace_1a1fb0 = InsnOverlay( {
0x0806720a, --       j      0x19c828
0x2529ffff, --        addiu  t1,t1,-1
})
eeInsnReplace(0x1a1fb0, 0x0c06720a, 0x0c000000 | (Replace_1a1fb0>>2)) -- jal 19c828 <SPSetDirect>
 
</pre>


eeInsnReplace(0x32aaa8, 0xe7a00010, 0x00000000) -- nop
====Parappa the Rapper 2====
eeInsnReplace(0x32aaac, 0x46020082, 0x46020002) -- mul.s $f0,$f0,$f2 
ALL
eeInsnReplace(0x32aab0, 0x3c014480, 0x3c014480) -- lui at,0x4480
<br>CLI
eeInsnReplace(0x32aab4, 0x34211000, 0x34211000) -- ori at,at,0x1000
<pre>--host-audio-latency=0.01
eeInsnReplace(0x32aab8, 0x44812000, 0x44812000) -- mtc1 at,$f4
eeInsnReplace(0x32aabc, 0xe7a10014, 0x00000000) -- nop
eeInsnReplace(0x32aac0, 0x460308c2, 0x46030842) -- mul.s $f1,$f1,$f3
eeInsnReplace(0x32aac4, 0xe7a20010, 0xe7a00000) -- swc1 $f0,0(sp)
eeInsnReplace(0x32aac8, 0x90a4001c, 0x90a4001c) -- lbu $a0,28($a1)
eeInsnReplace(0x32aacc, 0xe7a30014, 0xe7a10004) -- swc1 $f1,4(sp)


eeInsnReplace(0x32aad0, 0x6baa0017, 0x00000000) -- nop
#fix for audio off sync.</pre>
eeInsnReplace(0x32aad4, 0x6faa0010, 0x00000000) -- nop
eeInsnReplace(0x32aad8, 0xb3aa0007, 0x00000000) -- nop
eeInsnReplace(0x32aadc, 0xb7aa0000, 0x00000000) -- nop
eeInsnReplace(0x32aae0, 0xc7a00000, 0x00000000) -- nop
eeInsnReplace(0x32aae4, 0xc7a10004, 0x00000000) -- nop
end


</pre>
SCUS_971.67
<br>Features.lua
<br>LUA
<br>SLUS-20500
<br>Even though it's features.lua, it's still a very good example for learning
<pre>
<pre>
-- Lua 5.3
-- Title: Red Dead Revolver - SLUS-20500 (USA) v1.03
-- Author:  Nicola Salmoria
-- Date: March 23, 2016


-- Parappa the Rapper 2  [SCUS-97167]


require( "ee-gpr-alias" ) -- you can access EE GPR by alias (gpr.a0 / gpr["a0"])


apiRequest(0.7) -- need widescreen support
apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.


local eeObj = getEEObject()
require( "ee-gpr-alias" )
local emuObj = getEmuObject()
require( "ee-hwaddr" )


local eeObj = getEEObject()


local GFXPIPELINE_16BY9_ADDRESS = 0x79eeec
-- ================================================================================================
local GLOBALS_UNIVERSALDATA_ADDRESS = 0x742120
-- Title issues racy combination of VIF1 and GIF transfers.  It expects GIF to finish ahead of VU
 
-- XGKICK (via VIF1), which is atypical among PS2 titles (XGKICK has HW priority over GIF, and so
 
-- GIF can only finish ahead of XGKICK in certain extreme cases).
local TH1A = -- start loading screen
--
-- Fixed by delaying the specific VIF1 transfer (identified by MADR) for a long time to ensure GIF
-- gains arbitration and finishes ahead of XGKICKs.
--
local fix01_dma_vif1 =  
function()
function()
emuObj.ThrottleMax()
local ee = eeObj
end
local tgtaddr = ee.GetGpr(gpr.s0)


local TH1B = -- switch to threaded loading (over cutscene etc.)
-- print( string.format("success pt.1 : %x %x", vif1_hw.CHCR, tgtaddr ) )
function()
emuObj.ThrottleNorm()
end


if tgtaddr == vif1_hw.CHCR then


local TH2A = -- start flashing loading message
-- expected:
function()
--  # DIR==1 and MOD==1  (chain)
emuObj.ThrottleMax()
--  # TADR==0x01C76AA0
end


local TH2B = -- pause loading message
local chcr = ee.GetGPR(gpr.v0)
function()
emuObj.ThrottleNorm()
end


local TH2C = -- unpause loading message
if (chcr & 0x05) == 0x05 then
function()
local tadr = ee.ReadMem32(vif1_hw.TADR);
emuObj.ThrottleMax()
if tadr == 0x01C76AA0 then
end
-- 0x6000 works fine, 0x6500 adds a little extra cushion.
 
ee.SchedulerDelayEvent("vif1.dma", 0x6500)
local TH2D = -- end loading message
-- print( "Parappa fix applied!" )
function()
end
emuObj.ThrottleNorm()
end
end
end
end
-- ================================================================================================


eeObj.AddHook(0x0015A008, 0xAE020000, fix01_dma_vif1)


-- ================================================================================================
-- Our emulator has accuracy problems on so many places. In this title, we have problems on VU.
-- To be accurate on VU is quite painful (we won't be able to get reasonable performance with it)
-- So as workaround, we just disable bilinear textures on Render-To-Texture drawing.
-- Bug#8122
eeInsnReplace(0x118084, 0xde260008, 0x24060000) -- ld a2,8(s1)
eeInsnReplace(0x118798, 0xde260008, 0x24060000) -- ld a2,8(s1)
eeInsnReplace(0x118868, 0xde660008, 0x24060000) -- ld a2,8(s3)
eeInsnReplace(0x119d18, 0xdc460008, 0x24060000) -- ld a2,8(v0)
eeInsnReplace(0x119d18, 0xdc460008, 0x24060000) -- ld a2,8(v0)


local showdownLoading = false
</pre>


local TH3A = -- draw "Loading" on Showdown info screen
====Primal====
function()
CLI
if showdownLoading == false then
<pre>
emuObj.ThrottleMax()
--vu1-mul0fix-range=0x22f,0x22f
showdownLoading = true
--vu1-mul0fix-range=0x298,0x29c
end
--vu1-native-patch=1
end
--ee-hook=0x2f76c0,FastForwardClock,0x1200ffbf
--vu1-mpg-cycles=700
--gs-kernel-cl-up="up2x2Simple"
--cop2-no-clamp-range=0x37bd78,0x37c514    ;; CMatrix functions         
--cop2-no-clamp-range=0x38c0e0,0x38c174    ;; CModel::CalcSkinningMatrices
--cop2-no-clamp-range=0x391cf0,0x392084    ;; CSkelton::Update           
</pre>


local TH3B = -- draw "Press START" on Showdown info screen
LUA
function()
<pre>
if showdownLoading == true then
-- Primal  [EU]
emuObj.ThrottleNorm()
showdownLoading = false
end
end


apiRequest(1.1)


local WH1 = -- update 16:9 flag
local eeObj = getEEObject()
function()
local emuObj = getEmuObject()
local isWidescreen = eeObj.GetGpr(gpr.a0)
if isWidescreen == 0 then
emuObj.SetDisplayAspectNormal()
else
emuObj.SetDisplayAspectWide()
end
end


local WH2 = -- init universal data
-- Bug 9094 - Title exhibits poor performance due to VU0 spin loops.
function()
-- The spin loops are meant to be an optimizaion on PS2 and the best way of handling them is
local v1 = eeObj.GetGpr(gpr.v1)
-- to remove them from the original code. This can be done since the VF09 register is unsed by
eeObj.SetGpr(gpr.v1, v1 | 1) -- enable widescreen
-- the first portion of the VU0 mpg.
end
--
-- Insn replacements Summarized:
--  1. NOP the spin loop from VU0.
--  2. NOP the setup code for VI05, which is the reg tested by the VU0 spin loop
--   3. Reorder the vcallms and qmtc2.


local WH3 = -- end of boot up sequence
function()
local universalData = eeObj.ReadMem32(GLOBALS_UNIVERSALDATA_ADDRESS)
local isWidescreen = eeObj.ReadMem32(universalData + 92) & 1


eeObj.WriteMem8(GFXPIPELINE_16BY9_ADDRESS, isWidescreen)
-- [$167:520507ff] IBNE vi05, vi00, [$167]
-- [$167:000002ff] NOP
local orig = (0x000002ff << 32) | 0x520507ff


if isWidescreen == 0 then
vuInsnReplace(0, 0x167, orig, 0x8000033c | (0x000002ff << 32)) -- NOP / NOP2
emuObj.SetDisplayAspectNormal()
vuInsnReplace(0, 0x172, orig, 0x8000033c | (0x000002ff << 32)) -- NOP / NOP2
else
emuObj.SetDisplayAspectWide()
end
end


local region_base = 0x399c5c


eeInsnReplace(region_base + 0x000, 0x24040001, 0x00000000)  -- li a0,1 -> NOP
eeInsnReplace(region_base + 0x010, 0x48c42800, 0x00000000)  -- ctc2.ni a0,$5      -> NOP
eeInsnReplace(region_base + 0x090, 0x24040001, 0x00000000)  -- li a0,1            -> NOP
eeInsnReplace(region_base + 0x0a0, 0x48c42800, 0x00000000)  -- ctc2.ni a0,$5      -> NOP


-- unthrottle loading screens
eeInsnReplace(region_base + 0x05c, 0x48c02800, 0x00000000) -- ctc2.ni zero,$5 -> NOP
local thr1a = eeObj.AddHook(0x21e02c, 0x0080982d, TH1A) -- <staNewLoadShow::Enter(void)>:
eeInsnReplace(region_base + 0x114, 0x48c02800, 0x00000000) -- ctc2.ni zero,$5 -> NOP
local thr1b = eeObj.AddHook(0x220100, 0x27bdfff0, TH1B) -- <staNewLoadShow::DoThreadedLoadShow(void)>:
local thr2a = eeObj.AddHook(0x233970, 0x27bdfff0, TH2A) -- <ThreadedLoadingMessage::Start(void)>:
local thr2b = eeObj.AddHook(0x233a30, 0x27bdfff0, TH2B) -- <ThreadedLoadingMessage::Pause(void)>:
local thr2c = eeObj.AddHook(0x233a80, 0x3c02004f, TH2C) -- <ThreadedLoadingMessage::Unpause(void)>:
local thr2d = eeObj.AddHook(0x2339d8, 0x27bdfff0, TH2D) -- <ThreadedLoadingMessage::Stop(void)>:
local thr3a = eeObj.AddHook(0x226110, 0x8e850008, TH3A) -- <staNewLoadShow::DrawMultiplayerInfo(void)>:
local thr3b = eeObj.AddHook(0x226058, 0x8e650008, TH3B) -- <staNewLoadShow::DrawMultiplayerInfo(void)>:


-- widescreen support
eeInsnReplace(region_base + 0x054,  0x4a00d839, 0x48a44800) -- vcallmsr vi27 -> qmtc2 a0,vf9
local wide1 = eeObj.AddHook(0x3b9050, 0x46010003, WH1) -- <gfxPipeline::Set16By9(bool)>:
eeInsnReplace(region_base + 0x058,  0x48a44800, 0x4a00d839) -- qmtc2 a0,vf9 -> vcallmsr vi27
local wide2 = eeObj.AddHook(0x180f90, 0x00641824, WH2) -- <swcSaveUniversalData::swcSaveUniversalData(void)>:
eeInsnReplace(region_base + 0x10c, 0x4a00d839, 0x48a44800) -- vcallmsr vi27 -> qmtc2 a0,vf9
local wide3 = eeObj.AddHook(0x102b70, 0x24040003, WH3) -- <gmGame::DoBootUpSequence(void)>:
eeInsnReplace(region_base + 0x110, 0x48a44800, 0x4a00d839) -- qmtc2 a0,vf9 -> vcallmsr vi27
 
-- remove heat haze distortion ( for performance reason Bug#8827 )
--  reg = 0x42  packedFlags = 3( iip, tme, fst)  packedPrim  = 5(SCE_GS_PRIM_TRIFAN)
emuObj.SetGsTitleFix( "globalSet",  "reserved", { packedRegsLo = 0x42,packedRegsHi = 0, packedRegsNum = 2, packedFlags = 3, packedPrim = 5})
emuObj.SetGsTitleFix( "skipPacked", "reserved", { alpha = 0x80000044, tbp = 0x3a4000 , zmsk=1 })
emuObj.SetGsTitleFix( "skipPacked", "reserved", { alpha = 0x80000044, tbp = 0x348000 , zmsk=1 })
 
 
-- NOP out cacheline prefetch instructions.
-- Prefetch might have been a good idea on PS2, but it is entirely unhelpful on the PS4 target.
if 1 then
eeInsnReplace(0x381e60, 0x78400040, 0x00000000) -- lq zero,64(v0)
eeInsnReplace(0x3822c0, 0x78400040, 0x00000000) -- lq zero,64(v0)
eeInsnReplace(0x38ec7c, 0x78800040, 0x00000000) -- lq zero,64(a0)
eeInsnReplace(0x38ed78, 0x78600040, 0x00000000) -- lq zero,64(v1)
eeInsnReplace(0x38eec0, 0x78a00040, 0x00000000) -- lq zero,64(a1)
eeInsnReplace(0x38fe28, 0x7a600040, 0x00000000) -- lq zero,64(s3)
eeInsnReplace(0x38fea4, 0x78800040, 0x00000000) -- lq zero,64(a0)
eeInsnReplace(0x390da8, 0x78400040, 0x00000000) -- lq zero,64(v0)
eeInsnReplace(0x391020, 0x78400040, 0x00000000) -- lq zero,64(v0)
eeInsnReplace(0x391174, 0x78a00040, 0x00000000) -- lq zero,64(a1)
eeInsnReplace(0x3912b0, 0x78a00040, 0x00000000) -- lq zero,64(a1)
eeInsnReplace(0x398790, 0x7a000040, 0x00000000) -- lq zero,64(s0)
eeInsnReplace(0x399e60, 0x78400050, 0x00000000) -- lq zero,80(v0)
eeInsnReplace(0x399ee8, 0x78400050, 0x00000000) -- lq zero,80(v0)
end
 
-- NOP out an idle loop meant to flush some cache lines...
if 1 then
eeInsnReplace(0x331038, 0x18a00009, 0x00000000) -- blez a1,331060 <CDMAStreamIterator::AllocateBlock(unsigned int)+0x110>
eeInsnReplace(0x33103c, 0x00d41821, 0x00000000) --  addu v1,a2,s4
eeInsnReplace(0x331040, 0xbc5a0000, 0x00000000) --  cache 0x1a,0(v0)
eeInsnReplace(0x331044, 0x24a5ffff, 0x00000000) --  addiu a1,a1,-1
eeInsnReplace(0x331054, 0x1ca0fffa, 0x00000000) -- bgtz a1,331040 <CDMAStreamIterator::AllocateBlock(unsigned int)+0xf0>
eeInsnReplace(0x331058, 0x24420040, 0x00000000) --  addiu v0,v0,64
end
 
-- perf. fix bug 9094
emuObj.SetGsTitleFix( "globalSet", "reserved", {ignoreUpRenderTimeout=2} )
emuObj.SetGsTitleFix( "ignoreUpRender",  230, {} )
emuObj.SetGsTitleFix( "ignoreAreaUpdate", 0, { alpha=0x00000000 } )
emuObj.SetGsTitleFix( "ignoreAreaUpdate", 0, { alpha=0x80000048 } )


</pre>
</pre>


====Psychonauts====
====Red Dead Revolver====
SLUS_211.20
<br>SLUS-20500
<br>CLI
<br>CLI
<pre>--vu1-jr-cache-policy=sameprog
<pre>
--vu1-jalr-cache-policy=sameprog
--gs-kernel-cl-up="up2x2skipInterp"
--ee-hook=0x101fc0,FastForwardClock,0x3c0f0036
--fpu-rsqrt-fast-estimate=0
--ee-hook=0x110390,FastForwardClock,0x8d8f0000
--mtap1=Always
--ee-hook=0x101c10,FastForwardClock,0x51cf0052
--vif1-ignore-cmd-ints=1
--gs-vert-precision=8
--iop-cycle-scalar=0.80
--gs-kernel-cl="h2lpool"
--iop-hook=0x0086ac,FastForwardClock
--gs-kernel-cl-up="h2lpool2x2"
--ee-sif0-cycle-scalar=2.0
--gs-render-tile-threshold=300000
--ee-sif1-cycle-scalar=2.0
--vu-custom-min-max=0
--iop-sif1-cycle-scalar=5.0
--vu1-di-bits=0
--iop-sif0-cycle-scalar=5.0
--vu0-di-bits=0
--iop-tight-slice-count=12
--vu1-opt-vf00=2
--cdvd-sector-read-cycles=5000
--vu0-opt-vf00=2
--ee-hook=0x352dd0,AdvanceClock,0x0c0ef9a2,4500
--vu1-injection=1
--ee-hook=0x3b5068,FastForwardClock,0x00481024
--vu1-mpg-cycles=666
--ee-hook=0x46fb68,FastForwardClock,0x8ca30000
--vu1-mpg-cycles=1166,$000
--ee-hook=0x46fb38,FastForwardClock,0x8c620000
--vu1-mpg-cycles=950,0xffffffff
--ee-hook=0x46fb68,MfifoDrain,0x8ca30000
--vu0-mpg-cycles=300,0xfc
--ee-hook=0x46fb38,MfifoDrain,0x8c620000
--ee-hook=0x127630,AdvanceClock,0x27bdffd0,2100
--mfifo-manual-drain=0.30
--cdvd-sector-read-cycles=4000
--mfifo-chunk-drain-cycles=210000
--iop-cycle-scalar=1.6
</pre>
#Seems like substantial performance fixes</pre>
<br>SLUS-20500
 
SLUS_211.20
<br>LUA
<br>LUA
<pre>-- psychonauts_slus21120
<pre>
local gpr   = require("ee-gpr-alias")
-- red_dead_revolver
local emuObj = getEmuObject()
local gpr = require("ee-gpr-alias")


apiRequest(1.0) -- request version 0.1 API. Calling apiRequest() is mandatory.
apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.


-- Bug#9174 -  
-- Bug 9309
emuObj.SetGsTitleFix( "ignoreSubBuffCov", "reserved", { } )
local emuObj = getEmuObject()
-- psm= SCE_GS_PSMCT32 (0)
emuObj.SetGsTitleFix( "forceSimpleFetch",  "reserved", {psm=0} )
emuObj.SetGsTitleFix( "fetchFromCurrBuff", "reserved", {psm=0} )


-- Bug#9240 (Light maps uprender)
-- bug#9490 - Disable post-processing effect - <imgImageryDeriver<fxDistort>::Draw(void)>
-- Copy z-buffer for future use with light maps. psm = SCE_GS_PSMZ24 (49)
eeInsnReplace(0x4c4b78, 0x27bdfff0, 0x03e00008) -- JR $ra
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", {tw=9, th=9, psm=49, zmsk=1 } )
eeInsnReplace(0x4c4b7c, 0xffbf0000, 0x00000000) -- NOP


-- Apply light maps texMode=2 (bilinear)  psm= SCE_GS_PSMCT32 (0)
-- gfxState class writes bytes and then reads them back as words later on.
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", {tw=8, th=8, psm=0, ztst=1, texMode=2 } )
-- This replaces most of the word readbacks with lbu equivalents to avoid STLF.
-- 003c0950 <gfxState::Update_TEST(void)>:
eeInsnReplace(0x3c0970, 0x8ce6efd8, 0x90e6efd8) -- lw a2,-4136(a3)
eeInsnReplace(0x3c09a0, 0x8ce3f37c, 0x90e3f37c) -- lw v1,-3204(a3)


-- Bug#9176
-- 0032aa70 <fxFloatPropGrid::Get(Vector2 const &) const>:
--
--   The original  compiler couldn't assume that Vector2 was an aligned object, so it generated
-- This bug seems GPUGS interpolation problem.
--   ldr/sdr instructions to access it.  The lack of assumption seems to have also caused it to
-- The game draws clouds as undiscovered area on the map, but
--   spill FPU registers to memory needlessly.
-- Z value is unstable --- sometimes 0x320, sometimes 0x321.
-- On drawing 'Highlight' object (which is missing one), it uses z=0x320 with
-- ZTST=GEQUAL. Therefore if the cloud renders with z=0x321, this highlighted object
-- doesn't appear. But it's OK on the real PS2 because of no-drawing right edge,
-- z=0x321 won't be available on the packet (interpolation differences between
-- the real PS2 and our gs)
-- it gives some values (50.0f) to get +1 on Z value for the highlighted object.
-- this value will be used later to create the packet in _sprite_ps2_push_data(ESprite*).
--
-- This old one causes a problem on some other scenes.
-- local eeObj = getEEObject()
-- eeObj.AddHook(0x1b276c, 0xe4400024, function()
-- local v0 = eeObj.GetGpr(gpr.v0)
-- local z = eeObj.ReadMemFloat(v0+32)
-- eeObj.WriteMemFloat(v0+32, z+50.0)
-- end)
-- New one by Ernesto :
-- The idea is to apply the offset only on the marker.
local eeObj = getEEObject()
local adjustMapZHook = function() -- EMapRenderWindow::drawHighlightSprites
    eeObj.SetFpr(14, eeObj.GetFpr(14) + 50.0)
end
eeObj.AddHook(0x25d654, 0x8de40068, adjustMapZHook) -- \/
eeObj.AddHook(0x25d714, 0xe7b500cc, adjustMapZHook) -- /\
eeObj.AddHook(0x25d7d0, 0xe7b500cc, adjustMapZHook) -- <
eeObj.AddHook(0x25d894, 0x46000386, adjustMapZHook) -- >


if true then
eeInsnReplace(0x32aa74, 0x68a20007, 0x00000000)
eeInsnReplace(0x32aa78, 0x6ca20000, 0x00000000)
eeInsnReplace(0x32aa7c, 0xb3a20017, 0xc4a00000) -- lwc1 $f0,0(a1)
eeInsnReplace(0x32aa80, 0xb7a20010, 0xc4a10004) -- lwc1 $f1,4(a1)


-- bug#9423 - menus render 20+ times over again, causing very low fps.
eeInsnReplace(0x32aa8c, 0xc7a00010, 0x00000000) -- nop
-- The whole game in general has no concept of pacing and will re-draw frames multiple times
eeInsnReplace(0x32aa9c, 0xc7a10014, 0x00000000) -- nop
-- between vsync refreshes.  Hook placed on GameApp::EndFrame() measures time between frames and
-- if it's too short, the EE clock is advanced significantly to compensate.
 
local last_time = 0
local last_diff = 0
local advanceClockForAny = function()
local thistime = eeObj.GetClock()
local diff = thistime - last_time
local adv  = 0


if diff <= 0 then
eeInsnReplace(0x32aaa8, 0xe7a00010, 0x00000000) -- nop
-- sanity check, mostly for snapshot restore.
eeInsnReplace(0x32aaac, 0x46020082, 0x46020002) -- mul.s $f0,$f0,$f2 
last_diff = diff
eeInsnReplace(0x32aab0, 0x3c014480, 0x3c014480) -- lui at,0x4480
last_time = thistime
eeInsnReplace(0x32aab4, 0x34211000, 0x34211000) -- ori at,at,0x1000
return
eeInsnReplace(0x32aab8, 0x44812000, 0x44812000) -- mtc1 at,$f4
end
eeInsnReplace(0x32aabc, 0xe7a10014, 0x00000000) -- nop
eeInsnReplace(0x32aac0, 0x460308c2, 0x46030842) -- mul.s $f1,$f1,$f3
-- EE @ 30fps == roughly 10 million cycles
eeInsnReplace(0x32aac4, 0xe7a20010, 0xe7a00000) -- swc1 $f0,0(sp)
-- bug#9555 - We need to make a reasonable tally of VIF cycles across game display swaps.
eeInsnReplace(0x32aac8, 0x90a4001c, 0x90a4001c) -- lbu $a0,28($a1)
--   Use a combination heuristic of EE and VIF1 cycles to gues at whether the title should
eeInsnReplace(0x32aacc, 0xe7a30014, 0xe7a10004) -- swc1 $f1,4(sp)
--   lock to 45fps, 30fps, or something worse.
local fastminEE = 1600000 -- less than this it's safe to run > 30 fps
local fastminVIF_30 = 2200000 -- VU1 total that merits 30hz throttle
local fastminVIF_45 = 1700000 -- VU1 total that merit 45hz throttle.
local baremin_wo_vif= 6100000 -- EE values below this get promoted to this value  (~50hz)
local forced30hz = 9330000
local forced45hz = 7820000
local vif1_cycles = eeObj.GetVif1Cycles()
if (vif1_cycles > forced30hz) then
vif1_cycles = forced30hz
end


local diff_vif = diff + vif1_cycles
eeInsnReplace(0x32aad0, 0x6baa0017, 0x00000000) -- nop
adv = adv + vif1_cycles
eeInsnReplace(0x32aad4, 0x6faa0010, 0x00000000) -- nop
eeInsnReplace(0x32aad8, 0xb3aa0007, 0x00000000) -- nop
eeInsnReplace(0x32aadc, 0xb7aa0000, 0x00000000) -- nop
eeInsnReplace(0x32aae0, 0xc7a00000, 0x00000000) -- nop
eeInsnReplace(0x32aae4, 0xc7a10004, 0x00000000) -- nop
end


-- Lock anything that seems like "Real Work" to either 30 or 45 FPS:
</pre>
<br>Features.lua
if diff_vif < fastminEE then
<br>SLUS-20500
adv = adv + (fastminEE*2 - diff_vif)
<br>Even though it's features.lua, it's still a very good example for learning
elseif vif1_cycles > fastminVIF_30 and (diff+(fastminVIF_30)//2) < forced30hz then
<pre>
adv = adv + (forced30hz  - diff - (fastminVIF_30)//2)
-- Lua 5.3
elseif vif1_cycles > fastminVIF_45 and (diff+(fastminVIF_45)//2) < forced45hz then
-- Title: Red Dead Revolver - SLUS-20500 (USA) v1.03
adv = adv + (forced45hz  - diff - (fastminVIF_45)//2)
-- Author:  Nicola Salmoria
elseif diff < baremin_wo_vif then
-- Date: March 23, 2016
adv = adv + (baremin_wo_vif  - diff)
 
end
 
require( "ee-gpr-alias" ) -- you can access EE GPR by alias (gpr.a0 / gpr["a0"])


-- print (string.format("DELTA: %d  ADV: %d  VIF1: %d", diff, adv, vif1_cycles))
apiRequest(0.7) -- need widescreen support


if adv ~= 0 then
local eeObj = getEEObject()
eeObj.AdvanceClock(adv)
local emuObj = getEmuObject()
end


-- Ensure next frame's delta time takes into consideration this frame's advancement.
-- Otherwise each fraem delta time would get progressively worse.


thistime = thistime + adv
local GFXPIPELINE_16BY9_ADDRESS = 0x79eeec
last_time = thistime
local GLOBALS_UNIVERSALDATA_ADDRESS = 0x742120
last_diff = diff
end


local advanceClockForGame = function() advanceClockForAny(5300000, 2700000) end
eeObj.AddHookJT(0x207cf8, 0x27bdfff0, advanceClockForGame)   -- <GameApp::EndFrame()>:
#Performance and optimisations</pre>


====Red Faction====
local TH1A = -- start loading screen
SLUS_200.73
function()
<br>CLI
emuObj.ThrottleMax()
<pre>--gs-use-deferred-l2h=1
end
--l2h-2d-params=0x0000000800000001,0x000000003a0a2300,512,2
 
--vu1=jit-sync
local TH1B = -- switch to threaded loading (over cutscene etc.)
--ee-cycle-scalar=1.02
function()
--ee-hook=0x00213370,FastForwardClock,0x8F8293A8
emuObj.ThrottleNorm()
--ee-hook=0x24ce30,AdvanceClock,0x8c620000,20000
end
--ee-hook=0x272b44,FastForwardClock,0x3c0201ee
 
--ee-hook=0x272bc4,FastForwardClock,0x3c0201ee
--ee-hook=0x21b354,AdvanceClock,0x3c031000,0x1240
#performance fixes.</pre>


SLUS_200.73
local TH2A = -- start flashing loading message
<br>LUA
function()
<pre>-- Red Faction [US]
emuObj.ThrottleMax()
end


apiRequest(1.6)
local TH2B = -- pause loading message
local gpr = require("ee-gpr-alias")
function()
emuObj.ThrottleNorm()
end


-- title uses memcpy() to write to VU1 memory, so some instances will be hotfixed to
local TH2C = -- unpause loading message
-- use slowpath_memcpy() at runtime.
function()
emuObj.ThrottleMax()
end


eeNativeFunction(0x259820, 0x0080402d, 'memcpy')
local TH2D = -- end loading message
eeNativeFunction(0x2599d8, 0x2cc20008, 'memset')
function()
emuObj.ThrottleNorm()
end


eeNativeFunction(0x253870, 0x27bdffd0, 'ieee754_acosf')
eeNativeFunction(0x254620, 0x44026000, 'ieee754_sqrtf')
eeNativeFunction(0x255a50, 0x44026000, 'cosf')
eeNativeFunction(0x255df0, 0x44026000, 'sinf')
eeNativeFunction(0x256318, 0x27bdffa0, 'acosf')


eeInsnReplace(0x24d7e0, 0x24030064, 0x03e00008)                -- <FlushCache>
eeInsnReplace(0x24d7e4, 0x0000000c, 0x00000000)
eeNativeHook (0x24d7e0, 0x03e00008,'AdvanceClock',0xa00)
eeInsnReplace(0x24d810, 0x2403ff98, 0x03e00008)                -- <iFlushCache>
eeInsnReplace(0x24d814, 0x0000000c, 0x00000000)
eeNativeHook (0x24d810, 0x03e00008,'AdvanceClock',0xa00)


eeInsnReplace(0x24de20, 0x27bdffe0, 0x03e00008)                -- <SyncDCache>
local showdownLoading = false
eeInsnReplace(0x24de24, 0x0080302d, 0x00000000)
eeNativeHook (0x24de20, 0x03e00008,'AdvanceClock',0x600)
eeInsnReplace(0x24de98, 0x3c02ffff, 0x03e00008)                -- <iSyncDCache>
eeInsnReplace(0x24de9c, 0x3442ffc0, 0x00000000)
eeNativeHook (0x24de98, 0x03e00008,'AdvanceClock',0x600)
eeInsnReplace(0x24df58, 0x27bdffe0, 0x03e00008)                -- <InvalidDCache>
eeInsnReplace(0x24df5c, 0x0080302d, 0x00000000)
eeNativeHook (0x24df58, 0x03e00008,'AdvanceClock',0x600)
eeInsnReplace(0x24dfd0, 0x3c02ffff, 0x03e00008)                -- <iInvalidDCache>
eeInsnReplace(0x24dfd4, 0x3442ffc0, 0x00000000)
eeNativeHook (0x24dfd0, 0x03e00008,'AdvanceClock',0x600)


local emuObj = getEmuObject()
local TH3A = -- draw "Loading" on Showdown info screen
local eeObj = getEEObject()
function()
if showdownLoading == false then
emuObj.ThrottleMax()
showdownLoading = true
end
end


-- bug#10159 workaround
local TH3B = -- draw "Press START" on Showdown info screen
-- slowdown the jeep speed....
function()
if showdownLoading == true then
emuObj.ThrottleNorm()
showdownLoading = false
end
end


local jeepObj = 0
eeObj.AddHook(0x1376f0, 0xc6600174, function()
jeepObj = eeObj.GetGpr(gpr.s1)
end)
eeObj.AddHook(0x137a48, 0xc7ac00bc, function()
local s1 = eeObj.GetGpr(gpr.s1)
if s1 == jeepObj then
eeObj.SetFpr(12, eeObj.GetFpr(12)*0.90)
end
end)


-- bug#10249 workaround
local WH1 = -- update 16:9 flag
-- forcibly calculate the jeep's suspension.
function()
eeObj.AddHook(0x19ee08, 0x8ec2120c, function()
local isWidescreen = eeObj.GetGpr(gpr.a0)
if jeepObj - 624 == eeObj.GetGpr(gpr.s6) then
eeObj.SetGpr(gpr.v0, 1)
if isWidescreen == 0 then
end
emuObj.SetDisplayAspectNormal()
end)
else
emuObj.SetDisplayAspectWide()
end
end


-- debug code for jeep movment target.
local WH2 = -- init universal data
-- local px = 0.0
function()
-- local pz = 0.0
local v1 = eeObj.GetGpr(gpr.v1)
-- eeObj.AddHook(0x1375bc, 0x26650174, function()
eeObj.SetGpr(gpr.v1, v1 | 1) -- enable widescreen
-- local s1 = eeObj.GetGpr(gpr.s1)
end
-- if s1 == jeepObj then
-- local s3 = eeObj.GetGpr(gpr.s3)
-- px = eeObj.ReadMemFloat(s3 + 372)
-- pz = eeObj.ReadMemFloat(s3 + 380)
-- end
-- end)
-- eeObj.AddHook(0x1375c8, 0xa2620170, function()
-- local s1 = eeObj.GetGpr(gpr.s1)
-- if s1 == 0x19a7a00 then
-- local s3 = eeObj.GetGpr(gpr.s3)
-- local x = eeObj.ReadMemFloat(s3 + 372)
-- local z = eeObj.ReadMemFloat(s3 + 380)
-- if px ~= x or pz ~= z then
--   print(string.format("[%f %f] => [%f %f] v0=%d",
--   px, pz, x, z, eeObj.GetGpr(gpr.v0)))
-- end
--  end
-- end)
#physics calculations and performance fix.</pre>


SLUS_200.73
local WH3 = -- end of boot up sequence
<br>SLUS-20073_features.lua
function()
<pre>-- Lua 5.3
local universalData = eeObj.ReadMem32(GLOBALS_UNIVERSALDATA_ADDRESS)
-- Title:  Red Faction PS2 - SLUS-20073 (USA)
local isWidescreen = eeObj.ReadMem32(universalData + 92) & 1
-- Author:  Ernesto Corvi, Adam McInnis


-- Changelog:
eeObj.WriteMem8(GFXPIPELINE_16BY9_ADDRESS, isWidescreen)


apiRequest(1.1) -- request version 1.1 API. Calling apiRequest() is mandatory.
if isWidescreen == 0 then
emuObj.SetDisplayAspectNormal()
else
emuObj.SetDisplayAspectWide()
end
end


local eeObj = getEEObject()
local emuObj = getEmuObject()


local L1 =  -- main
function()
emuObj.ThrottleMax()
end
local L2 =  -- main
function()
emuObj.ThrottleNorm()
end
local load1 = eeObj.AddHook(0x165590, 0x27bdffb0, L1) -- game_load_level
local load2 = eeObj.AddHook(0x16578C, 0x7bb10010, L2) -- game_load_level


-- Widescreen support --
-- unthrottle loading screens
eeInsnReplace(0x2071c4, 0x00000000, 0x3c013f40) -- gr_setup_3d
local thr1a = eeObj.AddHook(0x21e02c, 0x0080982d, TH1A) -- <staNewLoadShow::Enter(void)>:
eeInsnReplace(0x2071d0, 0x00000000, 0x4481f000) -- gr_setup_3d
local thr1b = eeObj.AddHook(0x220100, 0x27bdfff0, TH1B) -- <staNewLoadShow::DoThreadedLoadShow(void)>:
eeInsnReplace(0x2072e0, 0x00000000, 0x461ea502) -- gr_setup_3d
local thr2a = eeObj.AddHook(0x233970, 0x27bdfff0, TH2A) -- <ThreadedLoadingMessage::Start(void)>:
eeInsnReplace(0x2072e8, 0x00000000, 0x461ead43) -- gr_setup_3d
local thr2b = eeObj.AddHook(0x233a30, 0x27bdfff0, TH2B) -- <ThreadedLoadingMessage::Pause(void)>:
eeInsnReplace(0x23a34c, 0x44826000, 0x461e0303) -- shadow_ngps_render_and_copy
local thr2c = eeObj.AddHook(0x233a80, 0x3c02004f, TH2C) -- <ThreadedLoadingMessage::Unpause(void)>:
eeInsnReplace(0x23a444, 0x3c024334, 0x3c024309) -- shadow_ngps_render_and_copy
local thr2d = eeObj.AddHook(0x2339d8, 0x27bdfff0, TH2D) -- <ThreadedLoadingMessage::Stop(void)>:
emuObj.SetDisplayAspectWide()
local thr3a = eeObj.AddHook(0x226110, 0x8e850008, TH3A) -- <staNewLoadShow::DrawMultiplayerInfo(void)>:
#Official widescreen support.</pre>
local thr3b = eeObj.AddHook(0x226058, 0x8e650008, TH3B) -- <staNewLoadShow::DrawMultiplayerInfo(void)>:
 
-- widescreen support
local wide1 = eeObj.AddHook(0x3b9050, 0x46010003, WH1) -- <gfxPipeline::Set16By9(bool)>:
local wide2 = eeObj.AddHook(0x180f90, 0x00641824, WH2) -- <swcSaveUniversalData::swcSaveUniversalData(void)>:
local wide3 = eeObj.AddHook(0x102b70, 0x24040003, WH3) -- <gmGame::DoBootUpSequence(void)>:


====Red faction II====
CUSA06356
<br>CLI
<pre>
--gs-use-deferred-l2h=0
--l2h-2d-params=0x0000000800000001,0x000000003a083000,612,2
--mtap1=disabled
--mtap2=disabled
</pre>
</pre>
====Resident Evil Code: Veronica X====
 
ALL
====Psychonauts====
SLUS_211.20
<br>CLI
<br>CLI
<pre>--ee-jit-pagefault-threshold=30
<pre>--vu1-jr-cache-policy=sameprog
#crash fix.</pre>
--vu1-jalr-cache-policy=sameprog
 
--ee-hook=0x101fc0,FastForwardClock,0x3c0f0036
ALL
--ee-hook=0x110390,FastForwardClock,0x8d8f0000
--ee-hook=0x101c10,FastForwardClock,0x51cf0052
--gs-vert-precision=8
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
--gs-render-tile-threshold=300000
--vu-custom-min-max=0
--vu1-di-bits=0
--vu0-di-bits=0
--vu1-opt-vf00=2
--vu0-opt-vf00=2
--vu1-injection=1
--vu1-mpg-cycles=666
--vu1-mpg-cycles=1166,$000
--vu1-mpg-cycles=950,0xffffffff
--vu0-mpg-cycles=300,0xfc
--ee-hook=0x127630,AdvanceClock,0x27bdffd0,2100
--cdvd-sector-read-cycles=4000
--iop-cycle-scalar=1.6
#Seems like substantial performance fixes</pre>
 
SLUS_211.20
<br>LUA
<br>LUA
<pre>-- VeronicaX
<pre>-- psychonauts_slus21120
apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.
local gpr    = require("ee-gpr-alias")
 
-- Bug# 9976
local emuObj = getEmuObject()
local emuObj = getEmuObject()
emuObj.SetGsTitleFix( "clipScissors", "reserved", {alpha = 0 , frameW = 4 , psm = 0} )
#graphical fix.</pre>


====Rogue Galaxy====
apiRequest(1.0) -- request version 0.1 API. Calling apiRequest() is mandatory.
ALL
<br>CLI
<pre>--gs-kernel-cl-up="up2x2skipinterp"
--gs-optimize-30fps=1
#visual fixes and performance optimisation.</pre>


SCUS_974_90
-- Bug#9174 -
<br>LUA
emuObj.SetGsTitleFix( "ignoreSubBuffCov", "reserved", { } )
<pre>require("ee-gpr-alias")
apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.


-- Bug#8404 WORKAROUND
-- Bug#9240 (Light maps uprender)
-- See https://pss.usrd.scea.com/bugzilla/show_bug.cgi?id=8404
-- Copy z-buffer for future use with light maps. psm = SCE_GS_PSMZ24 (49)
eeInsnReplace(0x124898, 0x3442ffff, 0x3442fffe) -- ori v0,v0,0xffff
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", {tw=9, th=9, psm=49, zmsk=1 } )
#unsure what this fixes.</pre>


====Rise of the Kasai====
-- Apply light maps texMode=2 (bilinear)  psm= SCE_GS_PSMCT32 (0)
'''CLI'''
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", {tw=8, th=8, psm=0, ztst=1, texMode=2 } )
<br>SCUS-97416
<pre>
--gs-kernel-cl-up="up2x2skipinterp"
--cdvd-sector-read-cycles=31000
--iop-cycle-scalar=0.7
</pre>


-- Bug#9176
--
-- This bug seems GPUGS interpolation problem.
-- The game draws clouds as undiscovered area on the map, but
-- Z value is unstable --- sometimes 0x320, sometimes 0x321.
-- On drawing 'Highlight' object (which is missing one), it uses z=0x320 with
-- ZTST=GEQUAL. Therefore if the cloud renders with z=0x321, this highlighted object
-- doesn't appear. But it's OK on the real PS2 because of no-drawing right edge,
-- z=0x321 won't be available on the packet (interpolation differences between
-- the real PS2 and our gs)
-- it gives some values (50.0f) to get +1 on Z value for the highlighted object.
-- this value will be used later to create the packet in _sprite_ps2_push_data(ESprite*).
--
-- This old one causes a problem on some other scenes.
-- local eeObj = getEEObject()
-- eeObj.AddHook(0x1b276c, 0xe4400024, function()
-- local v0 = eeObj.GetGpr(gpr.v0)
-- local z  = eeObj.ReadMemFloat(v0+32)
-- eeObj.WriteMemFloat(v0+32, z+50.0)
-- end)
-- New one by Ernesto :
-- The idea is to apply the offset only on the marker.
local eeObj = getEEObject()
local adjustMapZHook = function() -- EMapRenderWindow::drawHighlightSprites
    eeObj.SetFpr(14, eeObj.GetFpr(14) + 50.0)
end
eeObj.AddHook(0x25d654, 0x8de40068, adjustMapZHook) -- \/
eeObj.AddHook(0x25d714, 0xe7b500cc, adjustMapZHook) -- /\
eeObj.AddHook(0x25d7d0, 0xe7b500cc, adjustMapZHook) -- <
eeObj.AddHook(0x25d894, 0x46000386, adjustMapZHook) -- >


'''LUA'''
<br>SCUS-97416
<pre>
-- rise_of_kasai
require("ee-gpr-alias")
apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.


-- bug#9423 - menus render 20+ times over again, causing very low fps.
-- The whole game in general has no concept of pacing and will re-draw frames multiple times
-- between vsync refreshes.  Hook placed on GameApp::EndFrame() measures time between frames and
-- if it's too short, the EE clock is advanced significantly to compensate.


local emuObj = getEmuObject()
local last_time = 0
local eeObj  = getEEObject()
local last_diff = 0
local advanceClockForAny = function()
local thistime = eeObj.GetClock()
local diff = thistime - last_time
local adv  = 0
 
if diff <= 0 then
-- sanity check, mostly for snapshot restore.
last_diff = diff
last_time = thistime
return
end
-- EE @ 30fps == roughly 10 million cycles
-- bug#9555 - We need to make a reasonable tally of VIF cycles across game display swaps.
--  Use a combination heuristic of EE and VIF1 cycles to gues at whether the title should
--  lock to 45fps, 30fps, or something worse.
local fastminEE = 1600000 -- less than this it's safe to run > 30 fps
local fastminVIF_30 = 2200000 -- VU1 total that merits 30hz throttle
local fastminVIF_45 = 1700000 -- VU1 total that merit 45hz throttle.
local baremin_wo_vif= 6100000 -- EE values below this get promoted to this value (~50hz)
local forced30hz = 9330000
local forced45hz = 7820000
local vif1_cycles = eeObj.GetVif1Cycles()
if (vif1_cycles > forced30hz) then
vif1_cycles = forced30hz
end


-- bug #9037.
local diff_vif = diff + vif1_cycles
-- Force point sampling when max mip map > 0 and min filter is set to nearest( 0). 
adv = adv + vif1_cycles
-- This is done generically when mipmaping is On , however  we prefer to disable mip maps for this title.
emuObj.SetGsTitleFix( "forcePoint", "reserved", {mipIsGt=0,  mmin=0} )


-- bug#9241
-- Lock anything that seems like "Real Work" to either 30 or 45 FPS:
-- SwapMemCard to Mark of Kri
-- bug#136347 (SCEI bugzilla)
if diff_vif < fastminEE then
-- we re-use US image for Rise of Kasai EU package and want to let use be able to have Mark of Kri completion bonus.
adv = adv + (fastminEE*2 - diff_vif)
-- unfortunately we don't have any ways to distinguish which PS4 package we are working on.
elseif vif1_cycles > fastminVIF_30 and (diff+(fastminVIF_30)//2) < forced30hz then
-- instead of US => EU reading out modification, let the game retry EU saved data when it fails.
adv = adv + (forced30hz  - diff - (fastminVIF_30)//2)
--
elseif vif1_cycles > fastminVIF_45 and (diff+(fastminVIF_45)//2) < forced45hz then
-- NOTE: you can write down the filepath directly(onto strptr) at boot time if we can distinguish the differences of the packages.
adv = adv + (forced45hz  - diff - (fastminVIF_45)//2)
local first_attempt = true
elseif diff < baremin_wo_vif then
local buffer = -1
adv = adv + (baremin_wo_vif  - diff)
local strptr = -1
end
local write_str = function (ptr, str)
 
  for i=1,string.len(str) do
-- print (string.format("DELTA: %d  ADV: %d  VIF1: %d", diff, adv, vif1_cycles))
  eeObj.WriteMem8(ptr + i - 1, string.byte(str, i, i))
 
  end
if adv ~= 0 then
eeObj.AdvanceClock(adv)
end
 
-- Ensure next frame's delta time takes into consideration this frame's advancement.
-- Otherwise each fraem delta time would get progressively worse.
 
thistime = thistime + adv
last_time = thistime
last_diff = diff
end
end
eeObj.AddHook(0x1aa904, 0x0040382d, function()
strptr = eeObj.GetGpr(gpr.a2)
local fname = eeObj.ReadMemStr(strptr)
-- print(string.format("%s", fname))
if fname == "BASCUS-97140/BASCUS-97140" then
if first_attempt then
  buffer = eeObj.GetGpr(gpr.a3)
  --print("Trying to read out SCUS-97140 Mark of Kri US saved data");
  --print(string.format("%x:ReadFile(%x, %x, %x)", eeObj.GetGpr(gpr.a0), 0, eeObj.GetGpr(gpr.a2), eeObj.GetGpr(gpr.a3)))
  emuObj.SwapMemCard(0, 0, "SCUS-97140") -- 2nd argument, user-id isn't used in the current implementation.
else
  -- this is the case of re-trying : reading out EU mark of kri
  --print("Trying to read out SCES-51164 Mark of Kri EU saved data");
  write_str(strptr, "BESCES-51164/BESCES-51164")
  eeObj.SetGpr(gpr.a3, buffer);
  --print(string.format("%x:ReadFile(%x, %x, %x)", eeObj.GetGpr(gpr.a0), 0, eeObj.GetGpr(gpr.a2), eeObj.GetGpr(gpr.a3)))
  emuObj.SwapMemCard(0, 0, "SCES-51164")
end
end
end)
eeInsnReplace(0x1aa910, 0x10400020, 0x00000000)
eeObj.AddHook(0x1aa910, 0x00000000, function()
local v0 = eeObj.GetGpr(gpr.v0)
if v0 == 0 then -- failed
--print("File Load Failed")
if first_attempt then
  first_attempt = false
  eeObj.SetPc(0x1aa8fc)
else
  first_attempt = true
  eeObj.SetPc(0x1aa994)
end
end
end)
-- SwapMemCard to Rise of Kasai
eeObj.AddHook(0x1aa9e8, 0xdfbf0000, function()
emuObj.SwapMemCard(0, 0, "SCUS-97416")
write_str(strptr, "BASCUS-97140/BASCUS-97140") -- write back the original string to the place.
strptr = -1
buffer = -1
end)
</pre>


====Samurai Shodown Anthology====
local advanceClockForGame = function() advanceClockForAny(5300000, 2700000) end
SLUS_216.29
eeObj.AddHookJT(0x207cf8, 0x27bdfff0, advanceClockForGame)   -- <GameApp::EndFrame()>:
<br>CLI
#Performance and optimisations</pre>
<pre>--gs-upscale=point
 
--gs-uprender=2x2
====Red Faction====
--gs-motion-factor=25
SLUS_200.73
--host-audio-latency=0.01
<br>CLI
--gs-ignore-dirty-page-border=1
<pre>--gs-use-deferred-l2h=1
--gs-kernel-cl="h2lpool"
--l2h-2d-params=0x0000000800000001,0x000000003a0a2300,512,2
--gs-kernel-cl-up="h2lpool2x2"
--vu1=jit-sync
--gs-h2l-list-opt=1
--ee-cycle-scalar=1.02
--gs-h2l-accurate-hash=1
--ee-hook=0x00213370,FastForwardClock,0x8F8293A8
#fix for substantial slowdown during combat.</pre>
--ee-hook=0x24ce30,AdvanceClock,0x8c620000,20000
--ee-hook=0x272b44,FastForwardClock,0x3c0201ee
--ee-hook=0x272bc4,FastForwardClock,0x3c0201ee
--ee-hook=0x21b354,AdvanceClock,0x3c031000,0x1240
#performance fixes.</pre>
 
SLUS_200.73
<br>LUA
<pre>-- Red Faction [US]


====Star Wars Bounty Hunter====
apiRequest(1.6)
ALL
local gpr = require("ee-gpr-alias")
<br>CLI
<pre>--gs-kernel-cl-up="OptRightTri"
--gs-vert-precision=8</pre>


====Star Wars: Jedi Starfighter====
-- title uses memcpy() to write to VU1 memory, so some instances will be hotfixed to
SLES_503.71
-- use slowpath_memcpy() at runtime.
<br>CLI
 
<pre>--gs-check-trans-rejection68=1
eeNativeFunction(0x259820, 0x0080402d, 'memcpy')
--gs-dirty-page-policy=1</pre>
eeNativeFunction(0x2599d8, 0x2cc20008, 'memset')
SLES_503.71
 
<br>Lua
eeNativeFunction(0x253870, 0x27bdffd0, 'ieee754_acosf')
<pre>-- Star Wars: Jedi Starfighter [SLES-50371] [EU]
eeNativeFunction(0x254620, 0x44026000, 'ieee754_sqrtf')
eeNativeFunction(0x255a50, 0x44026000, 'cosf')
eeNativeFunction(0x255df0, 0x44026000, 'sinf')
eeNativeFunction(0x256318, 0x27bdffa0, 'acosf')
 
eeInsnReplace(0x24d7e0, 0x24030064, 0x03e00008)                -- <FlushCache>
eeInsnReplace(0x24d7e4, 0x0000000c, 0x00000000)
eeNativeHook (0x24d7e0, 0x03e00008,'AdvanceClock',0xa00)
eeInsnReplace(0x24d810, 0x2403ff98, 0x03e00008)                -- <iFlushCache>
eeInsnReplace(0x24d814, 0x0000000c, 0x00000000)
eeNativeHook (0x24d810, 0x03e00008,'AdvanceClock',0xa00)


require("ee-gpr-alias")
eeInsnReplace(0x24de20, 0x27bdffe0, 0x03e00008)                -- <SyncDCache>
require("pad-and-key")
eeInsnReplace(0x24de24, 0x0080302d, 0x00000000)
apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.
eeNativeHook (0x24de20, 0x03e00008,'AdvanceClock',0x600)
eeInsnReplace(0x24de98, 0x3c02ffff, 0x03e00008)                -- <iSyncDCache>
eeInsnReplace(0x24de9c, 0x3442ffc0, 0x00000000)
eeNativeHook (0x24de98, 0x03e00008,'AdvanceClock',0x600)
eeInsnReplace(0x24df58, 0x27bdffe0, 0x03e00008)                -- <InvalidDCache>
eeInsnReplace(0x24df5c, 0x0080302d, 0x00000000)
eeNativeHook (0x24df58, 0x03e00008,'AdvanceClock',0x600)
eeInsnReplace(0x24dfd0, 0x3c02ffff, 0x03e00008)                -- <iInvalidDCache>
eeInsnReplace(0x24dfd4, 0x3442ffc0, 0x00000000)
eeNativeHook (0x24dfd0, 0x03e00008,'AdvanceClock',0x600)


local emuObj = getEmuObject()
local eeObj = getEEObject()
local eeObj = getEEObject()
local emuObj = getEmuObject()


-- Bug#9013 - title calls PS2::Exit() at the end of a bonus stage.
-- bug#10159 workaround
eeInsnReplace(0x323398, 0x0c116bb4, 0x00000000) --  jal    Stop__12CTaskManagerFv
-- slowdown the jeep speed....
 
-- Bug#8905
local jeepObj = 0
-- The game sets a little bit big DH values for GS Display Register.
eeObj.AddHook(0x1376f0, 0xc6600174, function()
-- mimic overscan cropping (generic crop happens in GsScanoutArea::Populate)
jeepObj = eeObj.GetGpr(gpr.s1)
local dump_display = function()
end)
  local a5 = eeObj.GetGpr(gpr.t1)
eeObj.AddHook(0x137a48, 0xc7ac00bc, function()
  local ds1_h = eeObj.ReadMem32(a5+892)
local s1 = eeObj.GetGpr(gpr.s1)
  local ds2_h = eeObj.ReadMem32(a5+908)
if s1 == jeepObj then
  local dh1  = (ds1_h>>(44-32))&0x7ff
eeObj.SetFpr(12, eeObj.GetFpr(12)*0.90)
  local dh2  = (ds2_h>>(44-32))&0x7ff
end
  if dh1 >= 574 then
end)
  dh1 = 558 -- 574-16
  ds1_h = (ds1_h & 0xfff) | (dh1 << (44-32))
  eeObj.WriteMem32(a5+892, ds1_h)
  end
  if dh2 >= 575 then
  dh2 = 559 -- 575-16
  ds2_h = (ds2_h & 0xfff) | (dh2 << (44-32))
  eeObj.WriteMem32(a5+908, ds2_h)
  end
end
eeObj.AddHook(0x4fc33c, 0x02084821, dump_display)
eeObj.AddHook(0x4fc068, 0x02084821, dump_display)


-- Bug#8944
-- bug#10249 workaround
-- The game doesn't clear the framebuffer on movie-startup and movie-display.
-- forcibly calculate the jeep's suspension.
-- call clear functions at the appropriate points by using Replacement.
eeObj.AddHook(0x19ee08, 0x8ec2120c, function()
local Replace_CVideoDecoder_Draw = InsnOverlay( {
if jeepObj - 624 == eeObj.GetGpr(gpr.s6) then
0x27bdfff0, -- addiu sp,sp,-16
eeObj.SetGpr(gpr.v0, 1)
0xffbf0000, -- sd ra,0(sp)
end
end)


-- swap
-- debug code for jeep movment target.
0x0c13f044, -- jal 0x4fc110
-- local px = 0.0
0x00000000, -- nop
-- local pz = 0.0
-- clear
-- eeObj.AddHook(0x1375bc, 0x26650174, function()
0x0c13f228, -- jal 0x4fc8a0
-- local s1 = eeObj.GetGpr(gpr.s1)
0x24044000, -- li a0,16384
-- if s1 == jeepObj then
 
-- local s3 = eeObj.GetGpr(gpr.s3)
0xdfbf0000, -- ld ra,0(sp)
-- px = eeObj.ReadMemFloat(s3 + 372)
0x03e00008, -- jr ra
-- pz = eeObj.ReadMemFloat(s3 + 380)
0x27bd0010, -- addiu sp,sp,16
-- end
})
-- end)
eeInsnReplace(0x427fe0, 0x0c13f044,0x0c000000 | (Replace_CVideoDecoder_Draw>>2))
-- eeObj.AddHook(0x1375c8, 0xa2620170, function()
local Replace_CPS2MpegPlayer_Open = InsnOverlay( {
-- local s1 = eeObj.GetGpr(gpr.s1)
0x27bdfff0, -- addiu sp,sp,-16
-- if s1 == 0x19a7a00 then
0xffbf0000, -- sd ra,0(sp)
-- local s3 = eeObj.GetGpr(gpr.s3)
-- local x = eeObj.ReadMemFloat(s3 + 372)
-- local z = eeObj.ReadMemFloat(s3 + 380)
-- if px ~= x or pz ~= z then
--   print(string.format("[%f %f] => [%f %f] v0=%d",
--   px, pz, x, z, eeObj.GetGpr(gpr.v0)))
-- end
--  end
-- end)
#physics calculations and performance fix.</pre>


-- clear color
SLUS_200.73
0x44806000, -- mtc1 zero,$f12
<br>SLUS-20073_features.lua
0x46006346, -- mov.s $f13,$f12
<pre>-- Lua 5.3
0x0c13f1d8, -- jal 0x4fc760
-- Title:  Red Faction PS2 - SLUS-20073 (USA)
0x46006386, -- mov.s $f14,$f12
-- Author: Ernesto Corvi, Adam McInnis
-- clear
0x0c13f228, -- jal 0x4fc8a0
0x24044000, --  li a0,16384
-- swap
0x0c13f044, --  jal 4fc110 <glSwapBuffersPSX2>
0x00000000, --  nop


-- restore some registers
-- Changelog:
0x0220302d, -- move a2,s1
0x0200382d, -- move a3,s0


0xdfbf0000, -- ld ra,0(sp)
apiRequest(1.1) -- request version 1.1 API. Calling apiRequest() is mandatory.
0x03e00008, -- jr ra
0x27bd0010, -- addiu sp,sp,16
})
eeInsnReplace(0x423c3c, 0x0220302d, 0x0c000000 | (Replace_CPS2MpegPlayer_Open>>2))


--
local eeObj = getEEObject()
-- Bug#8981 / Bug#9006
local emuObj = getEmuObject()
--
local std_string_c_str = function(ptr)
  return eeObj.ReadMemStr(eeObj.ReadMem32(eeObj.ReadMem32(ptr) + 12))
end
local player_obj_found_flag = 0
local player_obj = 0
eeObj.AddHook(0x464530, 0x27bdff90, function()
if std_string_c_str(eeObj.GetGpr(gpr.a1)) == "_player" then
--print(string.format("LookupGameObject %s", std_string_c_str(eeObj.GetGpr(gpr.a1))))
player_obj_found_flag = 1
end
end)
eeObj.AddHook(0x464720, 0x7bb10010, function()
if player_obj_found_flag == 1 then
player_obj = eeObj.ReadMem32(eeObj.GetGpr(gpr.v0)+92)
--print(string.format("    obj    = %x", eeObj.GetGpr(gpr.v0)))
--print(string.format("    92(v0) = %x", player_obj))
--print(string.format("    [%f, %f, %f]", eeObj.ReadMemFloat(player_obj+116), eeObj.ReadMemFloat(player_obj+120), eeObj.ReadMemFloat(player_obj+124)))
--print(string.format("    [%f, %f, %f]", eeObj.ReadMemFloat(player_obj+52), eeObj.ReadMemFloat(player_obj+56), eeObj.ReadMemFloat(player_obj+60)))
player_obj_found_flag = 0
end
end)


eeObj.AddHook(0x147444, 0x0040282d, function()
local L1 = -- main
local strptr = eeObj.GetGpr(gpr.v0)
function()
local str    = std_string_c_str(strptr)
emuObj.ThrottleMax()
if string.match(str, "ExplosionFire")
end
-- or string.match(str, "ExplosionSpark")
then
local L2 = -- main
local explosion_object = eeObj.ReadMem32(eeObj.GetGpr(gpr.s0)+92)
function()
local eo_x = eeObj.ReadMemFloat(explosion_object+116)
emuObj.ThrottleNorm()
local eo_y = eeObj.ReadMemFloat(explosion_object+120)
end
local eo_z = eeObj.ReadMemFloat(explosion_object+124)
-- print(string.format("exp obj : %x", explosion_object))
local load1 = eeObj.AddHook(0x165590, 0x27bdffb0, L1) -- game_load_level
-- print(string.format("        [%f, %f, %f]", eo_x, eo_y, eo_z))
local load2 = eeObj.AddHook(0x16578C, 0x7bb10010, L2) -- game_load_level
-- print(string.format("        [%f, %f, %f]", eeObj.ReadMemFloat(explosion_object+52), eeObj.ReadMemFloat(explosion_object+56), eeObj.ReadMemFloat(explosion_object+60)))


local pl_x = eeObj.ReadMemFloat(player_obj+116)
-- Widescreen support --
local pl_y = eeObj.ReadMemFloat(player_obj+120)
eeInsnReplace(0x2071c4, 0x00000000, 0x3c013f40) -- gr_setup_3d
local pl_z = eeObj.ReadMemFloat(player_obj+124)
eeInsnReplace(0x2071d0, 0x00000000, 0x4481f000) -- gr_setup_3d
-- print(string.format("pl  obj : %x", player_obj))
eeInsnReplace(0x2072e0, 0x00000000, 0x461ea502) -- gr_setup_3d
-- print(string.format("        [%f, %f, %f]", pl_x, pl_y, pl_z));
eeInsnReplace(0x2072e8, 0x00000000, 0x461ead43) -- gr_setup_3d
eeInsnReplace(0x23a34c, 0x44826000, 0x461e0303) -- shadow_ngps_render_and_copy
eeInsnReplace(0x23a444, 0x3c024334, 0x3c024309) -- shadow_ngps_render_and_copy
emuObj.SetDisplayAspectWide()
#Official widescreen support.</pre>


local len = (eo_x-pl_x)*(eo_x-pl_x) + (eo_y-pl_y)*(eo_y-pl_y) + (eo_z-pl_z)*(eo_z-pl_z)
====Red faction II====
-- print(string.format("lengh^2 = %f", len))
CUSA06356
<br>CLI
<pre>
--gs-use-deferred-l2h=0
--l2h-2d-params=0x0000000800000001,0x000000003a083000,612,2
--mtap1=disabled
--mtap2=disabled
</pre>
====Resident Evil Code: Veronica X====
ALL
<br>CLI
<pre>--ee-jit-pagefault-threshold=30
#crash fix.</pre>


-- print(string.format("str : %s", std_string_c_str(strptr)))
ALL
<br>LUA
<pre>-- VeronicaX
apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.


if len < 960000.0 then
-- Bug# 9976
  -- print("    REMOVED")
local emuObj = getEmuObject()
  eeObj.SetPc(0x1474b0)
emuObj.SetGsTitleFix( "clipScissors", "reserved", {alpha = 0 , frameW = 4 , psm = 0} )
end
#graphical fix.</pre>
end
end)


local overlay_addr = InsnOverlay( {
====Rogue Galaxy====
0x8c700008, --  lw      $s0, 8($v1)
ALL
0x8e040000, --  lw      $a0, 0($s0)
<br>CLI
0x8c840000, --  lw      $a0, 0($a0)
<pre>--gs-kernel-cl-up="up2x2skipinterp"
0x3c05006c, --  lui    $a1,0x6c
--gs-optimize-30fps=1
0x34a5ce28, --  ori    $a1,$a1,0xce28
#visual fixes and performance optimisation.</pre>
0x14850002, --  bne    $a0, $a1, <ret>
0x00000000, -- nop
0xac600004, -- sw      zero, 4($v1)
0x03e00008, -- ret: jr      $ra
0x8c630004, -- lw      $v1, 4($v1)
} )
local call_insn = (overlay_addr >> 2) | 0x0c000000
eeInsnReplace( 0x267f84, 0x8c700008, call_insn ) -- lw $s0, 8($v1) -> jal overlay_addr
eeInsnReplace( 0x267f88, 0x8c630004, 0x00000000 ) -- lw $v1, 4($v1) -> nop


-- The game has a bug when you replay the last campaign mission in coop mode ("The Jedi Master").
SCUS_974_90
-- Upon completing the mission successfully, the game asks to "Continue" or "Quit".
<br>LUA
-- Selecting "Continue" causes the game to hang, as there's nothing to continue to (it's the last mission)
<pre>require("ee-gpr-alias")
-- The following patch fixes this problem by changing to prompt to "Retry" or "Quit", as it behaves in 1p mode
apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.
eeObj.AddHook(0x39debc, 0x0220202d, function()
    local strptr = eeObj.GetGpr(gpr.v0)
    local str    = std_string_c_str(strptr)
    if string.match(str, "m16_fleet") then
    eeObj.SetGpr(gpr.s0, 1)
    end
end)
-- fix for a node corruption.
-- here's what happens (from Ernesto)
--
-- Well, I was finally able to track down the issue. It's actually difficult to explain and the actual trigger is still unknown to me, as it seems to be timing related somehow.
-- But, I found a way to reliably detect it and work around it. Basically, when the bug happens, CSGNode::AddChild will try to add a child node that's already a children of a different root node.
-- That causes all sorts of havok and it's what ends up causing the node child list to eventually be deallocated and the render to crash.
eeObj.AddHook(0x266A70, 0x27bdffc0, function()
--  local obj = eeObj.GetGpr(gpr.a0)
    local node = eeObj.GetGpr(gpr.a1)
    local parent = eeObj.ReadMem32(node+0x10)
--  local caller = eeObj.GetGpr(gpr.ra)


    if parent ~= 0 then
-- Bug#8404 WORKAROUND
--     print(string.format("Node %08x already has a parent (%08x, caller: %08x)", node, parent, caller))
-- See https://pss.usrd.scea.com/bugzilla/show_bug.cgi?id=8404
      eeObj.SetPC(0x266B80)
eeInsnReplace(0x124898, 0x3442ffff, 0x3442fffe) -- ori v0,v0,0xffff
    end
#unsure what this fixes.</pre>
end)
</pre>


====Star Wars Racer Revenge====
====Rise of the Kasai====
 
'''CLI'''
SLES_503.66
<br>SCUS-97416
<br>CLI
<pre>
<pre>--ee-hook=0x0025b3b0,FastForwardClock
--gs-kernel-cl-up="up2x2skipinterp"
--ee-hook=0x0025b188,FastForwardClock
--cdvd-sector-read-cycles=31000
--ee-hook=0x00243274,FastForwardClock
--iop-cycle-scalar=0.7
--gs-vert-precision=8
</pre>
--idec-cycles-per-qwc=768
--host-audio-latency=0.60
--fpu-no-clamping=1
--cop2-no-clamping=1
--vu1-di-bits=0
--gs-override-small-tri-area=1
--assert-path1-ad=0
--ee-ignore-segfault=Read</pre>
SLES_503.66
<br>Lua
<pre>require( "ee-gpr-alias" ) -- you can access EE GPR by alias (gpr.a0 / gpr["a0"])
apiRequest(0.4)


-- Star Wars: Racer Revenge (SLES-50366) [US]


local eeObj = getEEObject()
'''LUA'''
local emuObj  = getEmuObject()
<br>SCUS-97416
<pre>
-- rise_of_kasai
require("ee-gpr-alias")


eeInsnReplace(0x13d7f0, 0x1000ffff, 0x0804f45d) -- retry FREAD() for fix #9025,
apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.


-- Track#
-- The Grand Reefs : 6
-- Ruins of Carnuss Gorgull : 9
eeObj.AddHook(0x187330, 0x3c010001, function()
local track = eeObj.GetGpr(gpr.a1)
print(string.format("Track : %d", track))
if track == 6 or track == 9 then
eeObj.Vu1MpgCycles(1000) -- makes it be 30fps.
else
eeObj.Vu1MpgCycles(100) -- default value.
end
end)


-- Small triangle rejection. Works in conjunction with CLI setting  gs-override-small-tri-area=1
local emuObj = getEmuObject()
-- keep default area for texture 256x256 ( no blend)  (Anakin face) 
local eeObj = getEEObject()
emuObj.SetGsTitleFix( "setRejectionArea", 500,{twIsNot=8, thIsNot=8 } )


-- Set triangle rejection area= 1000  when alpha blend is not 0 ( i.e blend is On)
-- bug #9037.
emuObj.SetGsTitleFix( "setRejectionArea", 1000, {alphaIsNot=0 } )</pre>
-- Force point sampling when max mip map > 0 and min filter is set to nearest( 0).  
SLES_503.66
-- This is done generically when mipmaping is On , however  we prefer to disable mip maps for this title.
<br>Lua Features
emuObj.SetGsTitleFix( "forcePoint", "reserved", {mipIsGt=0,  mmin=0} )
<br>Seems to also include some game fix
<pre>-- Lua 5.3
-- Title:  Star Wars Racer Revenge PS2 - SLES-50366 (EUR)
-- Author:  Ernesto Corvi


-- Changelog:
-- bug#9241
 
-- SwapMemCard to Mark of Kri
apiRequest(0.2) -- request version 0.2 API. Calling apiRequest() is mandatory.
-- bug#136347 (SCEI bugzilla)
 
-- we re-use US image for Rise of Kasai EU package and want to let use be able to have Mark of Kri completion bonus.
local eeObj = getEEObject()
-- unfortunately we don't have any ways to distinguish which PS4 package we are working on.
local emuObj = getEmuObject()
-- instead of US => EU reading out modification, let the game retry EU saved data when it fails.
 
--
local L1 = -- PodUILoadingPage::PodUILoadingPage
-- NOTE: you can write down the filepath directly(onto strptr) at boot time if we can distinguish the differences of the packages.
function()
local first_attempt = true
emuObj.ThrottleMax()
local buffer = -1
end
local strptr = -1
local write_str = function (ptr, str)
local L2 =  -- PodUILoadingPage::~PodUILoadingPage
  for i=1,string.len(str) do
function()
  eeObj.WriteMem8(ptr + i - 1, string.byte(str, i, i))
emuObj.ThrottleNorm()
  end
end
end
eeObj.AddHook(0x1aa904, 0x0040382d, function()
local load1 = eeObj.AddHook(0x1caa30, 0x27bdffe0, L1) -- PodUILoadingPage::PodUILoadingPage
strptr = eeObj.GetGpr(gpr.a2)
local load2 = eeObj.AddHook(0x1caa70, 0x27bdffd0, L2) -- PodUILoadingPage::~PodUILoadingPage
local fname = eeObj.ReadMemStr(strptr)
 
-- print(string.format("%s", fname))
 
if fname == "BASCUS-97140/BASCUS-97140" then
 
if first_attempt then
-- BUG 9244 - This title exhibits memory allocation problems as described on the
  buffer = eeObj.GetGpr(gpr.a3)
-- PS2 tech note titled "malloc() Issues". Overlay the FullAllocAndFree() and hook it to main()
  --print("Trying to read out SCUS-97140 Mark of Kri US saved data");
 
  --print(string.format("%x:ReadFile(%x, %x, %x)", eeObj.GetGpr(gpr.a0), 0, eeObj.GetGpr(gpr.a2), eeObj.GetGpr(gpr.a3)))
local overlay_addr = InsnOverlay( {
  emuObj.SwapMemCard(0, 0, "SCUS-97140") -- 2nd argument, user-id isn't used in the current implementation.
0x27bdfff0, -- addiu $sp, -0x10
else
0x7fbf0000, -- sq $ra, 0($sp)
  -- this is the case of re-trying : reading out EU mark of kri
0x0c0c1710, -- jal malloc
  --print("Trying to read out SCES-51164 Mark of Kri EU saved data");
0x3c0401e0, -- lui $a0, 0x01e0
  write_str(strptr, "BESCES-51164/BESCES-51164")
0x0c0c171a, --  jal free
  eeObj.SetGpr(gpr.a3, buffer);
0x70402628, --  paddub $a0, $v0, 0
  --print(string.format("%x:ReadFile(%x, %x, %x)", eeObj.GetGpr(gpr.a0), 0, eeObj.GetGpr(gpr.a2), eeObj.GetGpr(gpr.a3)))
0x7bbf0000, --  lq $ra, 0($sp)
  emuObj.SwapMemCard(0, 0, "SCES-51164")
0x03e00008, -- jr $ra
end
0x27bd0010  -- addiu  $sp, 0x10
end
} )
end)
local call_insn = (overlay_addr >> 2) | 0x0c000000
eeInsnReplace(0x1aa910, 0x10400020, 0x00000000)
eeInsnReplace(0x23a020, 0x0c0be0a2, call_insn) -- jal scePrintf
eeObj.AddHook(0x1aa910, 0x00000000, function()
 
local v0 = eeObj.GetGpr(gpr.v0)
-- BUG 9244 - move stack down to 0x01f80000 to free up an extra 512KB
if v0 == 0 then -- failed
eeInsnReplace(0x100038, 0x3c0501f0, 0x3c0501f8)
--print("File Load Failed")
if first_attempt then
  first_attempt = false
  eeObj.SetPc(0x1aa8fc)
else
  first_attempt = true
  eeObj.SetPc(0x1aa994)
end
end
end)
-- SwapMemCard to Rise of Kasai
eeObj.AddHook(0x1aa9e8, 0xdfbf0000, function()
emuObj.SwapMemCard(0, 0, "SCUS-97416")
write_str(strptr, "BASCUS-97140/BASCUS-97140") -- write back the original string to the place.
strptr = -1
buffer = -1
end)
</pre>
</pre>


====Twisted Metal Black====
====Samurai Shodown Anthology====
SLUS_216.29
<br>CLI
<pre>--gs-upscale=point
--gs-uprender=2x2
--gs-motion-factor=25
--host-audio-latency=0.01
--gs-ignore-dirty-page-border=1
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
--gs-h2l-list-opt=1
--gs-h2l-accurate-hash=1
#fix for substantial slowdown during combat.</pre>
 
====Star Wars Bounty Hunter====
ALL
ALL
<br>CLI
<br>CLI
<pre>--mtap1=always
<pre>--gs-kernel-cl-up="OptRightTri"
--gs-use-deferred-l2h=0
--gs-vert-precision=8</pre>
--l2h-2d-params=0x0000000400000004,0x00000000300a0000,240
 
--vu1-di-bits=0
====Star Wars: Jedi Starfighter====
--vu1-opt-vf00=2
SLES_503.71
#performance fix.</pre>
<br>CLI
<pre>--gs-check-trans-rejection68=1
--gs-dirty-page-policy=1</pre>
SLES_503.71
<br>Lua
<pre>-- Star Wars: Jedi Starfighter [SLES-50371] [EU]


SCUS_971.01
require("ee-gpr-alias")
<br>LUA
require("pad-and-key")
<pre>require("ee-gpr-alias")
apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.
apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.


-- This game uses an old kernel which has a bug on _TerminateThread.
local eeObj = getEEObject()
-- It is necessary to check the target thread is already in readyqueue or not.
local emuObj = getEmuObject()


iopObj = getIOPObject()
-- Bug#9013 - title calls PS2::Exit() at the end of a bonus stage.
iopInsnReplace(0x0000C5C0, 0x0C004430, 0) -- jal         0x000110C0 // unlink_element (in TerminateThread)
eeInsnReplace(0x323398, 0x0c116bb4, 0x00000000) --   jal     Stop__12CTaskManagerFv
iopInsnReplace(0x0000C6EC, 0x0C004430, 0) -- jal        0x000110C0 // unlink_element (in iTerminateThread)
local fix_TerminateThread = function()
-- Bug#8905
   local TCB = iopObj.GetGpr(gpr.s0)
-- The game sets a little bit big DH values for GS Display Register.
   local TCB_status = iopObj.ReadMem8(TCB + 0xc)
-- mimic overscan cropping (generic crop happens in GsScanoutArea::Populate)
   local TCB_h_l = TCB
local dump_display = function()
   if TCB_status == 0x2 then
   local a5 = eeObj.GetGpr(gpr.t1)
  -- the target thread is on ready.
   local ds1_h = eeObj.ReadMem32(a5+892)
  local TCB_h_l_prev = iopObj.ReadMem32(TCB_h_l + 0)
   local ds2_h = eeObj.ReadMem32(a5+908)
  local TCB_h_l_next = iopObj.ReadMem32(TCB_h_l + 4)
   local dh1  = (ds1_h>>(44-32))&0x7ff
  if TCB_h_l_prev == TCB_h_l_next then -- last_one_element(&tcb->h.l)
  local dh2  = (ds2_h>>(44-32))&0x7ff
-- we need to maintain threadManCB.readymap.
  if dh1 >= 574 then
-- print("WE NEED TO MAINTAIN threadManCB.readymap!")
  dh1 = 558 -- 574-16
local s0 = iopObj.ReadMem16(TCB + 0xe) -- prio
  ds1_h = (ds1_h & 0xfff) | (dh1 << (44-32))
local s1 = TCB
  eeObj.WriteMem32(a5+892, ds1_h)
local a0 = s0 >> 5
  end
a0 = a0 << 2
  if dh2 >= 575 then
local v1 = s0 & 0x1f
  dh2 = 559 -- 575-16
local v0 = 1 << v1
  ds2_h = (ds2_h & 0xfff) | (dh2 << (44-32))
v1 = 0x10000 + a0
  eeObj.WriteMem32(a5+908, ds2_h)
v1 = iopObj.ReadMem32(v1 + 0x1a08)
  end
v0 = ~v0
end
v1 = v1 & v0
eeObj.AddHook(0x4fc33c, 0x02084821, dump_display)
local at = 0x10000+a0
eeObj.AddHook(0x4fc068, 0x02084821, dump_display)
iopObj.WriteMem32(at+0x1a08, v1)


-- 0000B798  00102142 srl        a0,s0,5
-- Bug#8944
-- 0000B79C  00042080 sll        a0,a0,2
-- The game doesn't clear the framebuffer on movie-startup and movie-display.
-- 0000B7A0  3203001F andi        v1,s0,0x1F
-- call clear functions at the appropriate points by using Replacement.
-- 0000B7A4  24020001 li          v0,0x1
local Replace_CVideoDecoder_Draw = InsnOverlay( {
-- 0000B7A8  00621004 sllv        v0,v0,v1
0x27bdfff0, -- addiu sp,sp,-16
-- 0000B7AC  3C030001 lui        v1,0x1
0xffbf0000, -- sd ra,0(sp)
-- 0000B7B0  00641821 addu        v1,v1,a0
 
-- 0000B7B4  8C631A08 lw          v1,0x1A08(v1)
-- swap
-- 0000B7B8  00021027 nor        v0,zero,v0
0x0c13f044, -- jal 0x4fc110
-- 0000B7BC  00621824 and        v1,v1,v0
0x00000000, -- nop
-- 0000B7C0  3C010001 lui        at,0x1
-- clear
-- 0000B7C4  00240821 addu        at,at,a0
0x0c13f228, -- jal 0x4fc8a0
-- 0000B7C8  AC231A08 sw          v1,0x1A08(at)
0x24044000, -- li a0,16384


  end
0xdfbf0000, -- ld ra,0(sp)
  end
0x03e00008, -- jr ra
  -- do unlink_element
0x27bd0010, -- addiu sp,sp,16
  local v1 = iopObj.ReadMem32(TCB_h_l+0) -- element->prev
})
  local v0 = iopObj.ReadMem32(TCB_h_l+4) -- element->next
eeInsnReplace(0x427fe0, 0x0c13f044,0x0c000000 | (Replace_CVideoDecoder_Draw>>2))
  iopObj.WriteMem32(v1 + 4, v0) -- element->prev->next = element->next
local Replace_CPS2MpegPlayer_Open = InsnOverlay( {
  iopObj.WriteMem32(v0 + 0, v1)
0x27bdfff0, -- addiu sp,sp,-16
end
0xffbf0000, -- sd ra,0(sp)
iopObj.AddHook(0x0000C5C4, 0x02002021, fix_TerminateThread) -- move        a0,s0
iopObj.AddHook(0x0000C6F0, 0x02002021, fix_TerminateThread) -- move      a0,s0


-- _waitIpuIdle64 spin perf down problem. Bug#8289
-- clear color
-- NOTE: new libarary also loops just 500dec around. 0x1389 is too much.
0x44806000, -- mtc1 zero,$f12
eeInsnReplace(0x0020CF80, 0x28421389, 0x28420200) -- slti        v0,v0,0x1389
0x46006346, -- mov.s $f13,$f12
#Performance and stall fixes.</pre>
0x0c13f1d8, -- jal 0x4fc760
0x46006386, -- mov.s $f14,$f12
-- clear
0x0c13f228, -- jal 0x4fc8a0
0x24044000, -- li a0,16384
-- swap
0x0c13f044, --  jal 4fc110 <glSwapBuffersPSX2>
0x00000000, --  nop


-- restore some registers
0x0220302d, -- move a2,s1
0x0200382d, -- move a3,s0


====The Mark of Kri====
0xdfbf0000, -- ld ra,0(sp)
<br>CLI
0x03e00008, -- jr ra
<br>SCES-51164
0x27bd0010, -- addiu sp,sp,16
<pre>
})
--gs-scanout-offsetx=27
eeInsnReplace(0x423c3c, 0x0220302d, 0x0c000000 | (Replace_CPS2MpegPlayer_Open>>2))
</pre>


====The Warriors====
--
ALL
-- Bug#8981 / Bug#9006
<br>CLI
--
<pre>--vu1-injection=1
local std_string_c_str = function(ptr)
--vu1-mpg-cycles=2300
  return eeObj.ReadMemStr(eeObj.ReadMem32(eeObj.ReadMem32(ptr) + 12))
--vu1-mpg-cycles=2600,-1
end
--vu1-clamp-range=0x028,0x060
local player_obj_found_flag = 0
--ee-hook=0x48c660,FastForwardClock,0x1620ffe3
local player_obj = 0
--force-pal-60hz=1</pre>
eeObj.AddHook(0x464530, 0x27bdff90, function()
if std_string_c_str(eeObj.GetGpr(gpr.a1)) == "_player" then
--print(string.format("LookupGameObject %s", std_string_c_str(eeObj.GetGpr(gpr.a1))))
player_obj_found_flag = 1
end
end)
eeObj.AddHook(0x464720, 0x7bb10010, function()
if player_obj_found_flag == 1 then
player_obj = eeObj.ReadMem32(eeObj.GetGpr(gpr.v0)+92)
--print(string.format("    obj    = %x", eeObj.GetGpr(gpr.v0)))
--print(string.format("    92(v0) = %x", player_obj))
--print(string.format("    [%f, %f, %f]", eeObj.ReadMemFloat(player_obj+116), eeObj.ReadMemFloat(player_obj+120), eeObj.ReadMemFloat(player_obj+124)))
--print(string.format("    [%f, %f, %f]", eeObj.ReadMemFloat(player_obj+52), eeObj.ReadMemFloat(player_obj+56), eeObj.ReadMemFloat(player_obj+60)))
player_obj_found_flag = 0
end
end)


?
eeObj.AddHook(0x147444, 0x0040282d, function()
<br>LUA
local strptr = eeObj.GetGpr(gpr.v0)
<pre>-- Lua 5.3
local str    = std_string_c_str(strptr)
-- Title: The Warriors (USA)   SLUS-21215 ( 1.04 NTSC )
if string.match(str, "ExplosionFire")
--        The Warriors (Europe) SLES-53443 ( 1.01 PAL )
-- or string.match(str, "ExplosionSpark")
-- Features version: 1.00
then
-- Author: David Haywood
local explosion_object = eeObj.ReadMem32(eeObj.GetGpr(gpr.s0)+92)
-- Date: November 15th 2015
local eo_x = eeObj.ReadMemFloat(explosion_object+116)
local eo_y = eeObj.ReadMemFloat(explosion_object+120)
local eo_z = eeObj.ReadMemFloat(explosion_object+124)
-- print(string.format("exp obj : %x", explosion_object))
-- print(string.format("        [%f, %f, %f]", eo_x, eo_y, eo_z))
-- print(string.format("        [%f, %f, %f]", eeObj.ReadMemFloat(explosion_object+52), eeObj.ReadMemFloat(explosion_object+56), eeObj.ReadMemFloat(explosion_object+60)))


local pl_x = eeObj.ReadMemFloat(player_obj+116)
local pl_y = eeObj.ReadMemFloat(player_obj+120)
local pl_z = eeObj.ReadMemFloat(player_obj+124)
-- print(string.format("pl  obj : %x", player_obj))
-- print(string.format("        [%f, %f, %f]", pl_x, pl_y, pl_z));


local len = (eo_x-pl_x)*(eo_x-pl_x) + (eo_y-pl_y)*(eo_y-pl_y) + (eo_z-pl_z)*(eo_z-pl_z)
-- print(string.format("lengh^2 = %f", len))


require( "ee-gpr-alias" ) -- you can access EE GPR by alias (gpr.a0 / gpr["a0"])
-- print(string.format("str : %s", std_string_c_str(strptr)))


apiRequest(0.7) -- request version 0.7 API. Calling apiRequest() is mandatory. -- request version 0.7 API. Calling apiRequest() is mandatory. (0.7 is needed for Widescreen switching)
if len < 960000.0 then
  -- print("    REMOVED")
  eeObj.SetPc(0x1474b0)
end
end
end)


-- obtain necessary objects.
local overlay_addr = InsnOverlay( {
local eeObj = getEEObject()
0x8c700008, --  lw      $s0, 8($v1)
local emuObj = getEmuObject()
0x8e040000, --  lw      $a0, 0($s0)
local trophyObj = getTrophyObject()
0x8c840000, --  lw      $a0, 0($a0)
local dmaObj = getDmaObject()
0x3c05006c, --  lui    $a1,0x6c
0x34a5ce28, --  ori    $a1,$a1,0xce28
0x14850002, --  bne    $a0, $a1, <ret>
0x00000000, --  nop
0xac600004, --  sw      zero, 4($v1)
0x03e00008, -- ret: jr      $ra
0x8c630004, --  lw      $v1, 4($v1)
} )
local call_insn = (overlay_addr >> 2) | 0x0c000000
eeInsnReplace( 0x267f84, 0x8c700008, call_insn ) -- lw $s0, 8($v1) -> jal overlay_addr
eeInsnReplace( 0x267f88, 0x8c630004, 0x00000000 ) -- lw $v1, 4($v1) -> nop


-- load configuration if exist
-- The game has a bug when you replay the last campaign mission in coop mode ("The Jedi Master").
local SaveData = emuObj.LoadConfig(0)
-- Upon completing the mission successfully, the game asks to "Continue" or "Quit".
 
-- Selecting "Continue" causes the game to hang, as there's nothing to continue to (it's the last mission)
 
-- The following patch fixes this problem by changing to prompt to "Retry" or "Quit", as it behaves in 1p mode
local firstCall = 0
eeObj.AddHook(0x39debc, 0x0220202d, function()
    local strptr = eeObj.GetGpr(gpr.v0)
    local str    = std_string_c_str(strptr)
    if string.match(str, "m16_fleet") then
    eeObj.SetGpr(gpr.s0, 1)
    end
end)
-- fix for a node corruption.
-- here's what happens (from Ernesto)
--
-- Well, I was finally able to track down the issue. It's actually difficult to explain and the actual trigger is still unknown to me, as it seems to be timing related somehow.
-- But, I found a way to reliably detect it and work around it. Basically, when the bug happens, CSGNode::AddChild will try to add a child node that's already a children of a different root node.
-- That causes all sorts of havok and it's what ends up causing the node child list to eventually be deallocated and the render to crash.
eeObj.AddHook(0x266A70, 0x27bdffc0, function()
--  local obj = eeObj.GetGpr(gpr.a0)
    local node = eeObj.GetGpr(gpr.a1)
    local parent = eeObj.ReadMem32(node+0x10)
--  local caller = eeObj.GetGpr(gpr.ra)


    if parent ~= 0 then
--      print(string.format("Node %08x already has a parent (%08x, caller: %08x)", node, parent, caller))
      eeObj.SetPC(0x266B80)
    end
end)
</pre>


--[[
====Star Wars Racer Revenge====
 
SLES_503.66
<br>CLI
<pre>--ee-hook=0x0025b3b0,FastForwardClock
--ee-hook=0x0025b188,FastForwardClock
--ee-hook=0x00243274,FastForwardClock
--gs-vert-precision=8
--idec-cycles-per-qwc=768
--host-audio-latency=0.60
--fpu-no-clamping=1
--cop2-no-clamping=1
--vu1-di-bits=0
--gs-override-small-tri-area=1
--assert-path1-ad=0
--ee-ignore-segfault=Read</pre>
SLES_503.66
<br>Lua
<pre>require( "ee-gpr-alias" ) -- you can access EE GPR by alias (gpr.a0 / gpr["a0"])
apiRequest(0.4)


this is the 'setWideScreen' function of the gfx devices
-- Star Wars: Racer Revenge (SLES-50366) [US]
from studying the code it seems that the content of 'a1' that
gets passed in determines if the requested mode is widescreen.


DevRWGraphicsDevice::setWideScreenMode(void)
local eeObj = getEEObject()
00194E28  27BDFFD0 addiu      sp,sp,-0x30
local emuObj  = getEmuObject()
00194E2C  7FB00010 sq          s0,0x0010(sp)
00194E30  E7B50028 swc1        f21,0x0028(sp)
00194E34  0080802D dmove      s0,a0
00194E38  FFBF0000 sd          ra,0x0000(sp)
00194E3C  E7B40020 swc1        f20,0x0020(sp)
00194E40  4480A800 mtc1        zero,f21
00194E44  C600044C lwc1        f0,0x044C(s0)
00194E48  46150032 c.eq.s      f0,f21
00194E4C  00000000 nop
00194E50  45010053 bc1t        0x00194FA0
00194E54  AE05045C sw          a1,0x045C(s0)
--]]
 
local WidesrceenFunction = function()
local a1 = eeObj.GetGPR(gpr.a1)
a1 = a1 & 1
-- force to widescreen on boot, ensures new profiles get created in widescreen mode by default etc.
-- has some unwanted side-effects tho, so don't do it
if firstCall == 1 then
a1 = 1
eeObj.SetGPR(gpr.a1, a1)
firstCall = 0
end
if a1 == 1 then
print( string.format("********* Request WIDE SCREEN mode **************" ) )
emuObj.SetDisplayAspectWide()
else
print( string.format("********* Request 4:3 mode **************" ) )
emuObj.SetDisplayAspectNormal()
end
end


eeInsnReplace(0x13d7f0, 0x1000ffff, 0x0804f45d) -- retry FREAD() for fix #9025,


-- Track#
-- The Grand Reefs : 6
-- Ruins of Carnuss Gorgull : 9
eeObj.AddHook(0x187330, 0x3c010001, function()
local track = eeObj.GetGpr(gpr.a1)
print(string.format("Track : %d", track))
if track == 6 or track == 9 then
eeObj.Vu1MpgCycles(1000) -- makes it be 30fps.
else
eeObj.Vu1MpgCycles(100) -- default value.
end
end)


-- 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 } )</pre>
SLES_503.66
<br>Lua Features
<br>Seems to also include some game fix
<pre>-- Lua 5.3
-- Title:  Star Wars Racer Revenge PS2 - SLES-50366 (EUR)
-- Author:  Ernesto Corvi


-- this hook address actually differs between Europe / US.
-- Changelog:
WidescreenHook = eeObj.AddHook(0x194e18,0x27BDFFD0,WidesrceenFunction)


#official widescreen patch for The Warrior's emulator. The typos are apparently deliberate.</pre>
apiRequest(0.2) -- request version 0.2 API. Calling apiRequest() is mandatory.


====Wild ARMS 3====
local eeObj = getEEObject()
ALL
local emuObj = getEmuObject()
<br>CLI
<pre>--gs-motion-factor=50
--ee-static-block-links=JAL,COP2
#graphical fixes.</pre>


SCUS_972.03
local L1 =  -- PodUILoadingPage::PodUILoadingPage
<br>LUA
function()
<pre>require("ee-gpr-alias")
emuObj.ThrottleMax()
apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.
end
local L2 =  -- PodUILoadingPage::~PodUILoadingPage
function()
emuObj.ThrottleNorm()
end
local load1 = eeObj.AddHook(0x1caa30, 0x27bdffe0, L1) -- PodUILoadingPage::PodUILoadingPage
local load2 = eeObj.AddHook(0x1caa70, 0x27bdffd0, L2) -- PodUILoadingPage::~PodUILoadingPage


local emuObj = getEmuObject()
-- fix vision logo (Wild Arms 3)
local thresholdArea = 0 -- ignore alls items : fix #112276
emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , {  texType = 3, cbp = 0x2390, tbp = 0x288000} )




-- fix bug #9072
-- BUG 9244 - This title exhibits memory allocation problems as described on the
-- this is caused by a wrong string, which we patch directly on the disc.
-- PS2 tech note titled "malloc() Issues". Overlay the FullAllocAndFree() and hook it to main()
emuMediaPatch(0x438a, 12 + 0x174, { 0x6e5c2535 }, { 0x11202535 })


-- Bug#8907. accuracy-muldiv is too slow to use, so here added some value to get correct value.
local overlay_addr = InsnOverlay( {
local eeObj = getEEObject()
0x27bdfff0, -- addiu $sp, -0x10
eeObj.AddHook(0x001ef6ec, 0x00000000, function()
0x7fbf0000, -- sq $ra, 0($sp)
eeObj.SetFpr(0, eeObj.GetFpr(0) + 0.00001)
0x0c0c1710, --  jal malloc
end)
0x3c0401e0, --  lui $a0, 0x01e0
#Graphical glitches and stall fix.</pre>
0x0c0c171a, --  jal free
0x70402628, --  paddub $a0, $v0, 0
0x7bbf0000, --  lq $ra, 0($sp)
0x03e00008, --  jr $ra
0x27bd0010  --  addiu  $sp, 0x10
} )
local call_insn = (overlay_addr >> 2) | 0x0c000000
eeInsnReplace(0x23a020, 0x0c0be0a2, call_insn) -- jal scePrintf


==Custom PS2emu Configuration Files ==
-- BUG 9244 - move stack down to 0x01f80000 to free up an extra 512KB
<pre>
eeInsnReplace(0x100038, 0x3c0501f0, 0x3c0501f8)
Configuration files created by users, to improve PS2 emulator compatibility on PS4.
</pre>
</pre>
<pre>
Describing what Your configuration is doing is recommended.
On cli you can do it with #
and on a lua you can do it with --
</pre>
====18 Wheeler - American Pro Trucker====
<br>NTSC
<br>LUA
<pre>-- boot fix by Kozarovv
-- widescreen by Stayhye(ported from PAL version by El_Patas)
-- ported to PS4 lua
-- emu used=psycho v2


local gpr = require("ee-gpr-alias")
====Twisted Metal Black====
ALL
<br>CLI
<pre>--mtap1=always
--gs-use-deferred-l2h=0
--l2h-2d-params=0x0000000400000004,0x00000000300a0000,240
--vu1-di-bits=0
--vu1-opt-vf00=2
#performance fix.</pre>


apiRequest(0.1)
SCUS_971.01
<br>LUA
<pre>require("ee-gpr-alias")
apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.


local eeObj = getEEObject()
-- This game uses an old kernel which has a bug on _TerminateThread.
local emuObj = getEmuObject()
-- It is necessary to check the target thread is already in readyqueue or not.


local patcher = function()
iopObj = getIOPObject()
--16:9
iopInsnReplace(0x0000C5C0, 0x0C004430, 0) -- jal        0x000110C0 // unlink_element (in TerminateThread)
eeObj.WriteMem32(0x001d4c3c, 0x3c013f40) -- 0x3c013f80
iopInsnReplace(0x0000C6EC, 0x0C004430, 0) -- jal        0x000110C0 // unlink_element (in iTerminateThread)
-- Skip debugger hook.
local fix_TerminateThread = function()
eeObj.WriteMem32(0x001EB2A0, 0x00000000)
  local TCB = iopObj.GetGpr(gpr.s0)
eeObj.WriteMem32(0x001EB2A8, 0x10000003)
  local TCB_status = iopObj.ReadMem8(TCB + 0xc)
  local TCB_h_l = TCB
  if TCB_status == 0x2 then
  -- the target thread is on ready.
  local TCB_h_l_prev = iopObj.ReadMem32(TCB_h_l + 0)
  local TCB_h_l_next = iopObj.ReadMem32(TCB_h_l + 4)
  if TCB_h_l_prev == TCB_h_l_next then -- last_one_element(&tcb->h.l)
-- we need to maintain threadManCB.readymap.
-- print("WE NEED TO MAINTAIN threadManCB.readymap!")
local s0 = iopObj.ReadMem16(TCB + 0xe) -- prio
local s1 = TCB
local a0 = s0 >> 5
a0 = a0 << 2
local v1 = s0 & 0x1f
local v0 = 1 << v1
v1 = 0x10000 + a0
v1 = iopObj.ReadMem32(v1 + 0x1a08)
v0 = ~v0
v1 = v1 & v0
local at = 0x10000+a0
iopObj.WriteMem32(at+0x1a08, v1)


emuObj.ThrottleMax()
-- 0000B798  00102142 srl        a0,s0,5
end
-- 0000B79C  00042080 sll        a0,a0,2
-- 0000B7A0  3203001F andi        v1,s0,0x1F
-- 0000B7A4  24020001 li          v0,0x1
-- 0000B7A8  00621004 sllv        v0,v0,v1
-- 0000B7AC  3C030001 lui        v1,0x1
-- 0000B7B0  00641821 addu        v1,v1,a0
-- 0000B7B4  8C631A08 lw          v1,0x1A08(v1)
-- 0000B7B8  00021027 nor        v0,zero,v0
-- 0000B7BC  00621824 and        v1,v1,v0
-- 0000B7C0  3C010001 lui        at,0x1
-- 0000B7C4  00240821 addu        at,at,a0
-- 0000B7C8  AC231A08 sw          v1,0x1A08(at)


emuObj.AddVsyncHook(patcher)
  end
 
  end
--math.random() + math.random(1, 99)
  -- do unlink_element
</pre>
  local v1 = iopObj.ReadMem32(TCB_h_l+0) -- element->prev
====24 The Game====
  local v0 = iopObj.ReadMem32(TCB_h_l+4) -- element->next
'''''CLI'''''
  iopObj.WriteMem32(v1 + 4, v0) -- element->prev->next = element->next
<pre>
  iopObj.WriteMem32(v0 + 0, v1)
--ee-kernel-hle=1
end
--ee-injection-kernel=1
iopObj.AddHook(0x0000C5C4, 0x02002021, fix_TerminateThread) -- move        a0,s0
--ee-injection-title=1
iopObj.AddHook(0x0000C6F0, 0x02002021, fix_TerminateThread) -- move      a0,s0
--ee-cycle-scalar=1.9
--safe-area-min=1.0
--vu0-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1


# Fixed lags issue.
-- _waitIpuIdle64 spin perf down problem. Bug#8289
# <JAK v2emu Used>
-- NOTE: new libarary also loops just 500dec around. 0x1389 is too much.
</pre>
eeInsnReplace(0x0020CF80, 0x28421389, 0x28420200) -- slti        v0,v0,0x1389
<br>LUA
#Performance and stall fixes.</pre>
<br>SLUS_212.68
<pre>
apiRequest(0.1)


local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()
-- this lua was only tested on pcsx2
eeObj.WriteMem32(0x53d5d4,0x21c828bd)
eeObj.WriteMem32(0x53d62c,0x21c821bc)
end


emuObj.AddVsyncHook(patcher)
====The Mark of Kri====
</pre>
<br>CLI
 
<br>SCES-51164
====10000 Bullets====
'''''CLI'''''
<pre>
<pre>
--vu1=jit-sync
--gs-scanout-offsetx=27
 
# Fixes Blackscreen after PS2 Logo.
# Jak v1 used
</pre>
</pre>


====Ace Combat 4====
====The Warriors====
'''''CLI'''''
ALL
<br>
<br>CLI
<pre>--gs-kernel-cl="mipmap"
<pre>--vu1-injection=1
--gs-kernel-cl-up="mipmap2x2"
--vu1-mpg-cycles=2300
--gs-use-mipmap=1
--vu1-mpg-cycles=2600,-1
--vu1-clamp-range=0x028,0x060
--ee-hook=0x48c660,FastForwardClock,0x1620ffe3
--force-pal-60hz=1</pre>


#Fix for terrain textures</pre>
?
<br>LUA
<pre>-- Lua 5.3
-- Title: The Warriors (USA)    SLUS-21215 ( 1.04 NTSC )
--        The Warriors (Europe) SLES-53443 ( 1.01 PAL )
-- Features version: 1.00
-- Author: David Haywood
-- Date: November 15th 2015


====Ace Combat 5====
'''''CLI'''''


<br>All versions
<pre>--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--gs-use-mipmap=1


#Same fix for terrain textures</pre>
require( "ee-gpr-alias" ) -- you can access EE GPR by alias (gpr.a0 / gpr["a0"])


<br>'''''LUA file'''''
apiRequest(0.7) -- request version 0.7 API. Calling apiRequest() is mandatory. -- request version 0.7 API. Calling apiRequest() is mandatory. (0.7 is needed for Widescreen switching)


<br>SLUS_208.51
-- obtain necessary objects.
<pre>apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.
local eeObj = getEEObject()
local emuObj = getEmuObject()
local trophyObj = getTrophyObject()
local dmaObj = getDmaObject()


-- Collision detection fix for Stage 3 onwards // Rearranging COP2 instructions that use old results
-- load configuration if exist
local SaveData = emuObj.LoadConfig(0)


eeInsnReplace(0x1A3B94, 0x4B00682C, 0x48498800)
eeInsnReplace(0x1A3B98, 0x4B0C682C, 0x4B00682C)
eeInsnReplace(0x1A3BA4, 0x48498800, 0x484A8800)
eeInsnReplace(0x1A3BA8, 0x484A8800, 0x4B0C682C)
</pre>


<br>'''''LUA file'''''
local firstCall = 0


<br>SCES_504.10
<pre>apiRequest(2.2) -- request version 0.1 API. Calling apiRequest() is mandatory.


-- Wrong sky shader
--[[


local emuObj = getEmuObject()
this is the 'setWideScreen' function of the gfx devices
from studying the code it seems that the content of 'a1' that
gets passed in determines if the requested mode is widescreen.


-- Fix for wrong sky shader
DevRWGraphicsDevice::setWideScreenMode(void)
00194E28  27BDFFD0 addiu      sp,sp,-0x30
00194E2C  7FB00010 sq          s0,0x0010(sp)
00194E30  E7B50028 swc1        f21,0x0028(sp)
00194E34  0080802D dmove      s0,a0
00194E38  FFBF0000 sd          ra,0x0000(sp)
00194E3C  E7B40020 swc1        f20,0x0020(sp)
00194E40  4480A800 mtc1        zero,f21
00194E44  C600044C lwc1        f0,0x044C(s0)
00194E48  46150032 c.eq.s      f0,f21
00194E4C  00000000 nop
00194E50  45010053 bc1t        0x00194FA0
00194E54  AE05045C sw          a1,0x045C(s0)
--]]


emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )
local WidesrceenFunction = function()
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=2 } )</pre>
local a1 = eeObj.GetGPR(gpr.a1)
a1 = a1 & 1
-- force to widescreen on boot, ensures new profiles get created in widescreen mode by default etc.
-- has some unwanted side-effects tho, so don't do it
if firstCall == 1 then
a1 = 1
eeObj.SetGPR(gpr.a1, a1)
firstCall = 0
end
if a1 == 1 then
print( string.format("********* Request WIDE SCREEN mode **************" ) )
emuObj.SetDisplayAspectWide()
else
print( string.format("********* Request 4:3 mode **************" ) )
emuObj.SetDisplayAspectNormal()
end
end


====Ace Combat Zero: The Belkan War====
'''''CLI'''''
<br>All Versions
<pre>--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--gs-use-mipmap=1
#Once again, same fix for terrain textures.</pre>


<br>'''''LUA file'''''


<br>SLUS_213.46


<pre>apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.
-- this hook address actually differs between Europe / US.
WidescreenHook = eeObj.AddHook(0x194e18,0x27BDFFD0,WidesrceenFunction)


-- Collision detection fix.
#official widescreen patch for The Warrior's emulator. The typos are apparently deliberate.</pre>


eeInsnReplace(0x131EBC, 0x4B00682C, 0x48498800)
====Wild ARMS 3====
eeInsnReplace(0x131EC0, 0x4B0C682C, 0x4B00682C)
ALL
eeInsnReplace(0x131ECC, 0x48498800, 0x484A8800)
<br>CLI
eeInsnReplace(0x131ED0, 0x484A8800, 0x4B0C682C)</pre>
<pre>--gs-motion-factor=50
--ee-static-block-links=JAL,COP2
#graphical fixes.</pre>


<br>'''''LUA file'''''
SCUS_972.03
<br>LUA
<pre>require("ee-gpr-alias")
apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.


<br>SCES_540.41
local emuObj = getEmuObject()
-- fix vision logo (Wild Arms 3)
local thresholdArea = 0 -- ignore alls items : fix #112276
emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , {  texType = 3, cbp = 0x2390, tbp = 0x288000} )


<pre>apiRequest(2.2) -- request version 0.1 API. Calling apiRequest() is mandatory.


-- Wrong sky shader
-- fix bug #9072
-- this is caused by a wrong string, which we patch directly on the disc.
emuMediaPatch(0x438a, 12 + 0x174, { 0x6e5c2535 }, { 0x11202535 })


local emuObj = getEmuObject()
-- Bug#8907. accuracy-muldiv is too slow to use, so here added some value to get correct value.
local eeObj = getEEObject()
eeObj.AddHook(0x001ef6ec, 0x00000000, function()
eeObj.SetFpr(0, eeObj.GetFpr(0) + 0.00001)
end)
#Graphical glitches and stall fix.</pre>


-- Fix for wrong sky shader
==Custom PS2emu Configuration Files ==
 
<pre>
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )
Configuration files created by users, to improve PS2 emulator compatibility on PS4.
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=2 } )
</pre>
 
<pre>
-- Collision detection fix.
Describing what Your configuration is doing is recommended.
 
On cli you can do it with #
eeInsnReplace(0x131EB8, 0x4B00682C, 0x48498800)
and on a lua you can do it with --
eeInsnReplace(0x131EC8, 0x4B0C682C, 0x4B00682C)
</pre>
eeInsnReplace(0x131FB8, 0x48498800, 0x484A8800)
====18 Wheeler - American Pro Trucker====
eeInsnReplace(0x131EC4, 0x484A8800, 0x4B0C682C)</pre>
<br>NTSC
<br>LUA
<pre>-- boot fix by Kozarovv
-- widescreen by Stayhye(ported from PAL version by El_Patas)
-- ported to PS4 lua
-- emu used=psycho v2


====AirBlade====
local gpr = require("ee-gpr-alias")
'''''CLI'''''


<br>All versions
apiRequest(0.1)


<pre>--vu0-no-clamping=0
local eeObj = getEEObject()
--vu1-no-clamping=0
local emuObj = getEmuObject()


#emu used=GTA 3 v1
local patcher = function()
#Fix for flickering models and textures</pre>
--16:9
eeObj.WriteMem32(0x001d4c3c, 0x3c013f40) -- 0x3c013f80
-- Skip debugger hook.
eeObj.WriteMem32(0x001EB2A0, 0x00000000)
eeObj.WriteMem32(0x001EB2A8, 0x10000003)


====Ape Escape 2====
emuObj.ThrottleMax()
'''''CLI'''''
end


<br>All versions
emuObj.AddVsyncHook(patcher)


<pre>--gs-use-mipmap=1
--math.random() + math.random(1, 99)
--gs-kernel-cl="mipmap"
</pre>
--gs-kernel-cl-up="mipmap2x2"
====24 The Game====
 
#Fix for flickering textures</pre>
 
====Ape Escape: Pumped & Primed====
'''''CLI'''''
'''''CLI'''''
<pre>
--gs-uprender=2x2
--gs-upscale=edgesmooth


<br>All versions
--host-display-mode=16:9


<pre>--ee-jit-pagefault-threshold=30
--ee-kernel-hle=1
--gs-frontend-opt-mode=1
--ee-injection-kernel=1
--gs-use-mipmap=1
--ee-injection-title=1
--gs-kernel-cl="mipmap"
--ee-cycle-scalar=1.9
--gs-kernel-cl-up="mipmap2x2"
--safe-area-min=1.0
--cop2-no-clamping=1
--vu0-no-clamping=0
--vu1-mpg-cycles=250
--vu0-clamp-operands=1
#Fix for flickering textures</pre>
--vu0-clamp-results=1
'''''LUA'''''
--vu1-no-clamping=0
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1
 
 
# Fixed lags issue.
# <emu used=psychonauts v2>
</pre>
<br>LUA
<br>SLUS_212.68
<pre>
-- 24 The Game NTSC
-- performace fix by kozarovv
-- ported to PS4
-- emu used=psychonauts v2
 
local gpr = require("ee-gpr-alias")


<pre>--emu used=jakx v2
apiRequest(1.0)
apiRequest(1.0)
local eeObj = getEEObject()
local eeObj = getEEObject()
local emuObj = getEmuObject()
local emuObj = getEmuObject()
local patcher = function()
local patcher = function()


--Fix game frame rate
--Widescreen hack 16:9
eeObj.WriteMem32(0x3816e0,0x10000025) -- NTSC ONLY!!
end


emuObj.AddVsyncHook(patcher)</pre>
--Force turn on the native widescreen
eeObj.WriteMem32(0x205FBD2C,0x00000001)


====Auto modellista====
--Zoom Fix
'''CLI'''
--6000023c 2cbd428c
<br>All versions
eeObj.WriteMem32(0x002fbea0,0x3c020000)  --3c020060
<pre>
eeObj.WriteMem32(0x002fbea4,0x34420000)
#Fix for missing graphics
--vu-custom-min-max=0
--vu-xgkick-delay=0
</pre>


====Area 51====
eeObj.WriteMem32(0x00139e2c,0x3c020000) --3c020060
'''''CLI'''''
eeObj.WriteMem32(0x00139e30,0x34420000) --8c42bd2c


<br>All versions
--X-Fov (4:3)
--aa3f013c a8aa2134
--2a8e2134 e33f013c
--eeObj.WriteMem32(0x00460364,0x3c013fe3) --3c013faa
--eeObj.WriteMem32(0x00460368,0x34218e2a) --3421aaa8


<pre>
--Fix slow and choppy gameplay
--ee-cycle-scalar=2.0
eeObj.WriteMem32(0x004155a8,0x48a44800)
--iop-cycle-scalar=0.58
eeObj.WriteMem32(0x004155ac,0x48c02800)
eeObj.WriteMem32(0x004155b0,0x4a00d839)


--vu1-mpg-cycles=1400
eeObj.WriteMem32(0x00415660,0x48a44800)
eeObj.WriteMem32(0x00415664,0x48c02800)
eeObj.WriteMem32(0x00415668,0x4a00d839)


--host-audio-latency=2.7
end


--host-vsync=1
emuObj.AddVsyncHook(patcher)


--vu0-opt-flags=1
</pre>
--vu1-opt-flags=1
--cop2-opt-flags=1
--vu0-const-prop=1
--vu1-const-prop=1
--vu1-jr-cache-policy=newprog
--vu1-jalr-cache-policy=newprog
--vu0-jr-cache-policy=newprog
--vu0-jalr-cache-policy=newprog


#Speed improvement</pre>
====10000 Bullets====
'''''CLI'''''
<pre>
--vu1=jit-sync


====Avatar The last airbender====
# Fixes Blackscreen after PS2 Logo.
<br> All Versions
# Jak v1 used
<br>LUA
</pre>
<pre>
 
-- emu used=psychonauts v2, Fix For Freeze when starting new game
====Ace Combat 4====
'''''CLI'''''
<br>
<pre>--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--gs-use-mipmap=1


local gpr = require("ee-gpr-alias")
#Fix for terrain textures</pre>


apiRequest(0.1)
====Ace Combat 5====
'''''CLI'''''


local eeObj = getEEObject()
<br>All versions
local emuObj = getEmuObject()
<pre>--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--gs-use-mipmap=1


local patcher = function()
#Same fix for terrain textures</pre>


eeObj.SchedulerDelayEvent("vif1.dma", 0x6500) -- "--vif1-instant-xfer=0" replacement
<br>'''''LUA file'''''
emuObj.ThrottleMax()
end


emuObj.AddVsyncHook(patcher)
<br>SLUS_208.51
</pre>
<pre>apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.


====Battle Engine Aquila====
-- Collision detection fix for Stage 3 onwards // Rearranging COP2 instructions that use old results
<pre>
 
#Graphical corruption fix
eeInsnReplace(0x1A3B94, 0x4B00682C, 0x48498800)
--vu1-no-clamping=1
eeInsnReplace(0x1A3B98, 0x4B0C682C, 0x4B00682C)
#Performance boost
eeInsnReplace(0x1A3BA4, 0x48498800, 0x484A8800)
--ee-cycle-scalar=1.5
eeInsnReplace(0x1A3BA8, 0x484A8800, 0x4B0C682C)
--vu1-mpg-cycles=1000
--vu1-di-bits=0
--vu1-const-prop=1
--gs-adaptive-frameskip=1
#Jakv2
</pre>
</pre>


====Batman - Rise of Sin Tzu====
<br>'''''LUA file'''''
'''CLI'''
<br>All Versions
<pre>--vu1-no-clamping=0  #gfx fix A
--vu0-no-clamping=0  #gfx fix B
--vu-branch-hazard=0 #fixes loading freeze


emu used=recvx v1</pre>
<br>SCES_504.10
<pre>apiRequest(2.2) -- request version 0.1 API. Calling apiRequest() is mandatory.


<br>LUA
-- Wrong sky shader
<pre>
-- Batman - Rise of Sin Tzu (Prototype) Aug 15 2003
-- Retail has slowdown during FMVs that I can't fix
-- Widescreen & 60fps by Stayhye
-- emu used=recvx v1


local gpr = require("ee-gpr-alias")
local emuObj = getEmuObject()


apiRequest(0.1)
-- Fix for wrong sky shader


local eeObj = getEEObject()
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )
local emuObj = getEmuObject()
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=2 } )</pre>


local patcher = function()
====Ace Combat Zero: The Belkan War====
--16:9
'''''CLI'''''
--X-Fov
<br>All Versions
eeObj.WriteMem32(0x004ad5d8,0x3f5a7408) --0x3f23d70a >> @15833 lui v1, $d70a
<pre>--gs-kernel-cl="mipmap"
--Render Fix
--gs-kernel-cl-up="mipmap2x2"
eeObj.WriteMem32(0x00306928,0x3c023f40) --0x3c023f00 >> lui v0, $3f00
--gs-use-mipmap=1
#Once again, same fix for terrain textures.</pre>


emuObj.ThrottleMax()
<br>'''''LUA file'''''
end


emuObj.AddVsyncHook(patcher)
<br>SLUS_213.46


--60 fps
<pre>apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.
eeInsnReplace(0x20532748,0x00000002,0x00000001) --0x00000002 >> rwDMAVsyncCnt
</pre>


====Baldur's Gate: Dark Alliance II====
-- Collision detection fix.
'''CLI'''
<br>All Versions
<pre>
--gs-uprender=2x2
--gs-upscale=EdgeSmooth


--host-display-mode=16:9
eeInsnReplace(0x131EBC, 0x4B00682C, 0x48498800)
eeInsnReplace(0x131EC0, 0x4B0C682C, 0x4B00682C)
eeInsnReplace(0x131ECC, 0x48498800, 0x484A8800)
eeInsnReplace(0x131ED0, 0x484A8800, 0x4B0C682C)</pre>


--vif1-instant-xfer=0
<br>'''''LUA file'''''


--vu0-no-clamping=0
<br>SCES_540.41
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-clamp-results=1
</pre>


====Bard's tale, the====
<pre>apiRequest(2.2) -- request version 0.1 API. Calling apiRequest() is mandatory.
'''CLI'''
<br>All versions
<br>War of the monsters v1 fixes the crash.
<pre>
#Speedhacks
--ee-cycle-scalar=1.1
--vu1-di-bits=0
#Missing graphics fix
--vif1-instant-xfer=0
--vu1-no-clamping=0
</pre>


====Black====
-- Wrong sky shader
'''''CLI'''''
<br>All versions
<pre>
#graphical glitches fixes
--gs-use-mipmap=1
--gs-kernel-cl-up="up2x2simple"
--vu1-no-clamping=1
#Performance boost
--vu1-di-bits=0
--vu1-mpg-cycles=750
--ee-cycle-scalar=1.3
</pre>


<br>LUA
local emuObj = getEmuObject()
<br>SLUS-21376
<pre>
--author=refraction
--COP2 Rearrangement. Fixes broken collisions.
apiRequest(0.1)


local eeObj = getEEObject()
-- Fix for wrong sky shader
local emuObj = getEmuObject()
local patcher = function()
eeObj.WriteMem32(0x0037EB14,0x4b000460)
eeObj.WriteMem32(0x0037EB18,0x4af103bc)
eeObj.WriteMem32(0x0037EB30,0x4a800460)
eeObj.WriteMem32(0x0037EB34,0x4b7103bc)
end


emuObj.AddVsyncHook(patcher)
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )
</pre>
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=2 } )


====Bloody Roar 4====
-- Collision detection fix.
'''''CLI'''''


<br>All Versions
eeInsnReplace(0x131EB8, 0x4B00682C, 0x48498800)
eeInsnReplace(0x131EC8, 0x4B0C682C, 0x4B00682C)
eeInsnReplace(0x131FB8, 0x48498800, 0x484A8800)
eeInsnReplace(0x131EC4, 0x484A8800, 0x4B0C682C)</pre>
 
====AirBlade====
'''''CLI'''''
 
<br>All versions


<pre>--vu0-no-clamping=0
<pre>--vu0-no-clamping=0
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-no-clamping=0
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-results=1


#SPS Fix</pre>
#emu used=GTA 3 v1
#Fix for flickering models and textures</pre>


====Burnout 2: POI====
====Ape Escape 2====
<br>'''''LUA file'''''
'''''CLI'''''


<br>SLES_510.44 / SLES_529.68
<br>All versions


<pre>apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.
<pre>--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"


-- SLES-51044 / SLES-52968 - Fix white parts
#Fix for flickering textures</pre>
-- Major thanks to Maori-Jigglypuff for reversing that


eeInsnReplace(0x2485B8, 0xC6800D18, 0x3C014316)
====Ape Escape: Pumped & Primed====
eeInsnReplace(0x2485CC, 0xE4400000, 0xAC410000)
'''''CLI'''''
eeInsnReplace(0x262604, 0xC7809780, 0x3C014316)
eeInsnReplace(0x262618, 0xE4400000, 0xAC410000)
eeInsnReplace(0x2564B8, 0x8F829764, 0x24020000)</pre>


<br>'''''LUA file'''''
<br>All versions


<br>SLUS_204.97
<pre>--ee-jit-pagefault-threshold=30
--gs-frontend-opt-mode=1
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--cop2-no-clamping=1
--vu1-mpg-cycles=250
#Fix for flickering textures</pre>
'''''LUA'''''


<pre>apiRequest(0.1)   -- request version 0.1 API. Calling apiRequest() is mandatory.
<pre>--emu used=jakx v2
 
apiRequest(1.0)
-- SLUS_204.97 - Fix white parts
local eeObj = getEEObject()
-- Major thanks to Maori-Jigglypuff for reversing that
local emuObj = getEmuObject()
local patcher = function()
 
--Fix game frame rate
eeObj.WriteMem32(0x3816e0,0x10000025) -- NTSC ONLY!!
end


eeInsnReplace(0x2485A8, 0xC6800D18, 0x3C014316)
emuObj.AddVsyncHook(patcher)</pre>
eeInsnReplace(0x2485BC, 0xE4400000, 0xAC410000)
eeInsnReplace(0x2625F4, 0xC7809780, 0x3C014316)
eeInsnReplace(0x262608, 0xE4400000, 0xAC410000)
eeInsnReplace(0x2564A8, 0x8F829764, 0x24020000)</pre>


====Castlevania: Curse of Darkness====
====Avatar The last airbender====
<br>SLUS-21168
<br> All Versions
<br>LUA
<br>LUA
<pre>
<pre>
-- Widescreen hack by nemesis2000
-- emu used=psychonauts v2, Fix For Freeze when starting new game
-- new graphics fix by kozarovv
-- emu used=


local gpr = require("ee-gpr-alias")
local gpr = require("ee-gpr-alias")
Line 3,204: Line 3,387:


local patcher = function()
local patcher = function()
--gameplay
eeObj.WriteMem32(0x00751384,0x3c013f40) --hor value
eeObj.WriteMem32(0x00751388,0x44810000)
eeObj.WriteMem32(0x00751390,0x4600c602)
--FMV's fix
eeObj.WriteMem32(0x00443eb8,0x00000000)
eeObj.WriteMem32(0x00775398,0x24056e40)
eeObj.WriteMem32(0x007753a4,0x24072380)
-- Clamp value manually. Clamping from emulator change value to FLT_MIN
-- While we need correct lower bits + 1 due to x86 rounding...
eeObj.WriteMem32(0x92FD50, 0xFF7F8001)


eeObj.SchedulerDelayEvent("vif1.dma", 0x6500) -- "--vif1-instant-xfer=0" replacement
emuObj.ThrottleMax()
emuObj.ThrottleMax()
end
end


emuObj.AddVsyncHook(patcher)
emuObj.AddVsyncHook(patcher)
</pre>


</pre>
====Battle Engine Aquila====
LUA
<br>SLES_537.55
<pre>
<pre>
-- Widescreen hack by nemesis2000
#Graphical corruption fix
-- new graphics fix by kozarovv
--vu1-no-clamping=1
-- emu used=
#Performance boost
 
--ee-cycle-scalar=1.5
local gpr = require("ee-gpr-alias")
--vu1-mpg-cycles=1000
--vu1-di-bits=0
--vu1-const-prop=1
--gs-adaptive-frameskip=1
#Jakv2
</pre>


apiRequest(0.1)
====Baldur's Gate: Dark Alliance II====
'''CLI'''
<br>All Versions
<pre>
--gs-uprender=2x2
--gs-upscale=EdgeSmooth


local eeObj  = getEEObject()
--host-display-mode=16:9
local emuObj = getEmuObject()


local patcher = function()
--vif1-instant-xfer=0


--Widescreen
--gameplay
eeObj.WriteMem32(0x007526fc,0x3c013f40) --hor value
eeObj.WriteMem32(0x00752700,0x44810000)
eeObj.WriteMem32(0x00752708,0x4600c602)
--FMV's fix
eeObj.WriteMem32(0x004448d0,0x00000000)
eeObj.WriteMem32(0x00776718,0x24056d80)
eeObj.WriteMem32(0x00776724,0x24072380)
-- Clamp value manually. Clamping from emulator change value to FLT_MIN
-- While we need correct lower bits + 1 due to x86 rounding...
eeObj.WriteMem32(0x00931280, 0xFF7F8001)
emuObj.ThrottleMax()
end
emuObj.AddVsyncHook(patcher)
</pre>
==== Call of Duty: World at War - Final Fronts ====
<pre>
--ee-kernel-hle=1
--ee-injection-kernel=1
--ee-injection-title=1
--ee-cycle-scalar=1.9
--safe-area-min=1.0
--vu0-no-clamping=0
--vu0-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-no-clamping=0
--vu1-clamp-operands=1
--vu1-clamp-results=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1
# Fixed low framrate issue, !!!JAK EMULATOR Used!!!
</pre>
</pre>


====Cold Winter====
====Bard's tale, the====
'''CLI'''
<br>All versions
<br>War of the monsters v1 fixes the crash.
<pre>
#Speedhacks
--ee-cycle-scalar=1.1
--vu1-di-bits=0
#Missing graphics fix
--vif1-instant-xfer=0
--vu1-no-clamping=0
</pre>
 
====Bloody Roar 4====
'''''CLI'''''
'''''CLI'''''


Line 3,287: Line 3,444:


<pre>--vu0-no-clamping=0
<pre>--vu0-no-clamping=0
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-clamp-operands=1
--vu1-clamp-results=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-results=1


# fix graphic and physics, there are still issue with fmv, and minor stering issue.</pre>
#SPS Fix</pre>


====Crash Bandicoot - Wrath of Cortex====
====Burnout 2: POI====
'''''CLI'''''
<br>'''''LUA file'''''


<br>SLES50386
<br>SLES_510.44 / SLES_529.68
<pre>
#Fixes White lines
--gs-kernel-cl-up="up2x2simple"
#Added Just in case you encounter performance issues
--vu1-const-prop=1
--vu1-di-bits=0
</pre>


====Crash Tag Team Racing====
<pre>apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.
'''''CLI'''''


<br>All Versions
-- SLES-51044 / SLES-52968 - Fix white parts
<br>Emu: Jakv2
-- Major thanks to Maori-Jigglypuff for reversing that
<pre>
#Fix For Extreme slowdowns,
#This game Is known for being EXTREMELY VU1 hungry.
--vu1-mpg-cycles=1200
--vu1-di-bits=0
--vu1-const-prop=1
--vu1=jit-async
--ee-cycle-scalar=1.3
</pre>


<br>CLI
eeInsnReplace(0x2485B8, 0xC6800D18, 0x3C014316)
<br>SLUS_211.91 only
eeInsnReplace(0x2485CC, 0xE4400000, 0xAC410000)
<br>Emu: Jakv2
eeInsnReplace(0x262604, 0xC7809780, 0x3C014316)
<br> This config is the best one to use, FULL FIX for slowdowns!
eeInsnReplace(0x262618, 0xE4400000, 0xAC410000)
<pre>
eeInsnReplace(0x2564B8, 0x8F829764, 0x24020000)</pre>
#one of them will probably make audio stutter in the balloon's minigames,
#but i have no time to find out which one.
--ee-hook=0x00354904,FastForwardClock
--ee-hook=0x003547C8,FastForwardClock
--ee-hook=0x003548E8,FastForwardClock
--ee-hook=0x003548B8,FastForwardClock
--ee-hook=0x00354818,FastForwardClock
#EEunderclocking here for performance gain
--ee-hook=0x00354898,AdvanceClock,,250
--ee-hook=0x0039C174,AdvanceClock,,250
--ee-hook=0x00332454,AdvanceClock,,250
--ee-hook=0x00372B48,AdvanceClock,,250
#Speedhacks
--ee-cycle-scalar=1.2
--vu1-di-bits=0
#This one was the culprit for micro-stutters, increase it all you like
--ee-hook=0x0034C098,AdvanceClock,,500
#Full fix
</pre>


====Crash Twinsanity====
<br>'''''LUA file'''''
'''''CLI'''''


'''KOF2000 EMU USED'''
<br>SLUS_204.97
<br>All Versions


<pre>
<pre>apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.
--ee-cycle-scalar=1.6
--vu1-mpg-cycles=400
--vu-xgkick-delay=5
--vu1-di-bits=0
--vu1-const-prop=1
--vu1-injection=1
--gs-use-clut-merge=1
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"
--host-audio-latency=2.0
</pre>
'''''LUA'''''
<br>SLES-52568
<pre>
apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.


-- Fix random crashes
-- SLUS_204.97 - Fix white parts
eeInsnReplace(0x1923E8,0x5440FFFB,0x00000000)
-- Major thanks to Maori-Jigglypuff for reversing that
eeInsnReplace(0x1923EC,0x0071182F,0x00000000)
eeInsnReplace(0x1923F0,0x0223102F,0x00000000)


-- Eliminate color scan lines
eeInsnReplace(0x2485A8, 0xC6800D18, 0x3C014316)
local emuObj = getEmuObject()
eeInsnReplace(0x2485BC, 0xE4400000, 0xAC410000)
eeInsnReplace(0x2625F4, 0xC7809780, 0x3C014316)
eeInsnReplace(0x262608, 0xE4400000, 0xAC410000)
eeInsnReplace(0x2564A8, 0x8F829764, 0x24020000)</pre>


emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )</pre>
====Castlevania: Curse of Darkness====
'''''LUA'''''
<br>SLUS-21168
<br>SLUS-20909
<br>LUA
<pre>
<pre>
apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.
-- Widescreen hack by nemesis2000
-- new graphics fix by kozarovv
-- emu used=
 
local gpr = require("ee-gpr-alias")


-- Fix random crashes
apiRequest(0.1)
eeInsnReplace(0x191C58,0x5440FFFB,0x00000000)
eeInsnReplace(0x191C5C,0x0071182F,0x00000000)
eeInsnReplace(0x191C60,0x0223102F,0x00000000)


-- Eliminate color scan lines
local eeObj = getEEObject()
local emuObj = getEmuObject()
local emuObj = getEmuObject()


emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )</pre>
local patcher = function()
--gameplay
eeObj.WriteMem32(0x00751384,0x3c013f40) --hor value
eeObj.WriteMem32(0x00751388,0x44810000)
eeObj.WriteMem32(0x00751390,0x4600c602)
 
--FMV's fix
eeObj.WriteMem32(0x00443eb8,0x00000000)
eeObj.WriteMem32(0x00775398,0x24056e40)
eeObj.WriteMem32(0x007753a4,0x24072380)
 
-- Clamp value manually. Clamping from emulator change value to FLT_MIN
-- While we need correct lower bits + 1 due to x86 rounding...
eeObj.WriteMem32(0x92FD50, 0xFF7F8001)


====Crash Nitro Kart====
emuObj.ThrottleMax()
'''''CLI'''''
end


<br>All Versions
emuObj.AddVsyncHook(patcher)


<pre>--vu1=jit-sync          #fixes black screen after ps2 logo
--vu1-di-bits=0          #eliminates micro-freezes during races
--ee-cycle-scalar=1.6
--host-audio-latency=2.0
--vu1-mpg-cycles=750
--vu1-const-prop=1
</pre>
</pre>
LUA
<br>SLES_537.55
<pre>
-- Widescreen hack by nemesis2000
-- new graphics fix by kozarovv
-- emu used=


====Dead or Alive 2: Hardcore====
local gpr = require("ee-gpr-alias")
<br>'''''LUA file'''''


<br>SLUS_200.71
apiRequest(0.1)


<pre>apiRequest(0.1)
local eeObj  = getEEObject()
local emuObj = getEmuObject()


-- Fix hang, fix music, and sounds effects
local patcher = function()


emuMediaPatch(0x186A71, 12 + 0x7e4, { 0x2404002b }, { 0x27c40010 })
--Widescreen
emuMediaPatch(0x186A71, 12 + 0x7e8, { 0x0c0032b3 }, { 0x0c0032b7 })
--gameplay
emuMediaPatch(0x186A71, 12 + 0x7ec, { 0x27c50010 }, { 0x00000000 })
eeObj.WriteMem32(0x007526fc,0x3c013f40) --hor value
emuMediaPatch(0x186A71, 12 + 0x5e8, { 0x27bdfff0 }, { 0x03e00008 })
eeObj.WriteMem32(0x00752700,0x44810000)
emuMediaPatch(0x186A71, 12 + 0x5ec, { 0xafbe0008 }, { 0x00000000 })
eeObj.WriteMem32(0x00752708,0x4600c602)
emuMediaPatch(0x186A7B, 12 + 0x6fc, { 0x27bdfff0 }, { 0x03e00008 })
emuMediaPatch(0x186A7B, 12 + 0x700, { 0xafbe0008 }, { 0x00000000 })
emuMediaPatch(0x186A85, 12 + 0x164, { 0x27bdfff0 }, { 0x03e00008 })
emuMediaPatch(0x186A85, 12 + 0x168, { 0xafbe0008 }, { 0x00000000 })
emuMediaPatch(0x186A85, 12 + 0x10c, { 0x27bdfff0 }, { 0x03e00008 })
emuMediaPatch(0x186A85, 12 + 0x110, { 0xafbe0008 }, { 0x00000000 })
emuMediaPatch(0x186A85, 12 + 0x1bc, { 0x27bdfff0 }, { 0x03e00008 })
emuMediaPatch(0x186A85, 12 + 0x1c0, { 0xafbe0008 }, { 0x00000000 })
emuMediaPatch(0x186A86, 12 + 0x7f0, { 0x27bdfff0 }, { 0x03e00008 })
emuMediaPatch(0x186A86, 12 + 0x7f4, { 0xafbe0008 }, { 0x00000000 })
emuMediaPatch(0x186C38, 12 + 0x6ec, { 0x24060001 }, { 0x24060000 })</pre>


For the Japanese version (SLPS-25026) you can also use config files from PS3's PS2 emu with
--FMV's fix
<pre>--lopnor-config=1</pre>
eeObj.WriteMem32(0x004448d0,0x00000000)
in config.
eeObj.WriteMem32(0x00776718,0x24056d80)
eeObj.WriteMem32(0x00776724,0x24072380)


Place config file named as "SLPS-25026_lopnor.cfgbin" in /patches/SLPS-25026/
-- Clamp value manually. Clamping from emulator change value to FLT_MIN
-- While we need correct lower bits + 1 due to x86 rounding...
eeObj.WriteMem32(0x00931280, 0xFF7F8001)


emuObj.ThrottleMax()


'''''*Alternate fix Jak emus'''''
end
 
<br>'''''LUA file'''''


emuObj.AddVsyncHook(patcher)
</pre>


==== Call of Duty: World at War - Final Fronts ====
<pre>
<pre>
--DOA 2 Hardcore NTSC US
--ee-kernel-hle=1
--ee-injection-kernel=1
--ee-injection-title=1
--ee-cycle-scalar=1.9
--safe-area-min=1.0
--vu0-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1
# Fixed low framrate issue, !!!JAK EMULATOR Used!!!
</pre>
====Cold Winter====
'''''CLI'''''


apiRequest(2.2)
<br>All Versions


local gpr      = require("ee-gpr-alias")
<pre>--vu0-no-clamping=0
local emuObj      = getEmuObject()
--vu1-no-clamping=0
local eeObj      = getEEObject()
--vu0-clamp-operands=1
local gsObj      = getGsObject()
--vu0-clamp-results=1
local eeOverlay    = eeObj.getOverlayObject()
--vu1-clamp-operands=1
local iopObj  = getIOPObject()
--vu1-clamp-results=1


local patcher = function()
# fix graphic and physics, there are still issue with fmv, and minor stering issue.</pre>


eeObj.WriteMem32(0x0021b63c,0x3c014534) -- Widescreen
====Crash Bandicoot - Wrath of Cortex====
eeObj.WriteMem32(0x002b06ec,0x24060000) -- Fixes game hanging on boot.
'''''CLI'''''
   
<br>SLUS20238
iopObj.WriteMem32(0x001D77E4,0x27C40010) --fixes music/sound effects
'''SLUS-20238_cli.conf'''
iopObj.WriteMem32(0x001D77E8,0x0C0032B7) --fixes music/sound effects 
<pre>
iopObj.WriteMem32(0x001D77EC,0x00000000) --fixes music/sound effects
--host-display-mode=16:9
--force-frame-blend=1
--gs-kernel-cl="h2lpool"  
--gs-kernel-cl-up="h2lpool2x2"
#Speedhacks
--vu1-di-bits=0
</pre>
'''SLUS-20238_config.lua'''
<pre>
-- Crash Bandicoot The Wrath of Cortex [SLUS-20238] (U)
-- emu used=KOF 98


end
apiRequest(1.0) 


emuObj.AddVsyncHook(patcher)
local gpr = require("ee-gpr-alias")


emuObj.PadSetLightBar(0,255,200,250)
local eeObj  = getEEObject()
emuObj.SetDisplayAspectWide()
local emuObj = getEmuObject()


emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=2  } )</pre>
local patcher = function()


====Def Jam Vendetta====
--16:9 hack
'''''CLI'''''
eeObj.WriteMem32(0x001138B8,0x3c013f11) --vertical fov
eeObj.WriteMem32(0x001127A0,0x3c013f2a) --zoom value
eeObj.WriteMem32(0x0011287C,0x3c013f2a) --render value


<br>All Versions
--No interlace
eeObj.WriteMem32(0x2016A048,0xAF80E750)
eeObj.WriteMem32(0x2016A054,0xAF80E750)


<pre>--vu-xgkick-delay=0.58
--Underwater FX Fix
eeObj.WriteMem32(0x202438AC,0x0000182D)


#Fix for missing character models/textures
--Mech FX Fix
eeObj.WriteMem32(0x20257CF0,0x0000182D)


</pre>
--Cortex Vortex FX Fix
eeObj.WriteMem32(0x20242894,0x100000BC)


====Devil Kings====
--Disable Dark Effect
All versions
eeObj.WriteMem32(0x20258588,0x44801000)  
<br>CLI
<pre>
#Fix For Graphical Glitches (SPS)
--vu1-no-clamping=0
</pre>


====Disgaea 2: Cursed Memories====
emuObj.ThrottleMax()
'''''CLI'''''
end


<br>SLUS-21397
emuObj.AddVsyncHook(patcher)
 
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } ) --texMode=1
</pre>
<br>SLES50386
'''SLES-50386_cli.conf'''
<pre>
--host-display-mode=16:9
--gs-progressive=1
</pre>
'''SLES-50386_config.lua'''
<pre>
-- Crash Bandicoot The Wrath of Cortex [SLES-50386] (E)
-- emu used=KOF 2000


<pre>--gs-kernel-cl="mipmap"
apiRequest(1.0) 
--gs-kernel-cl-up="mipmap2x2"
--gs-use-mipmap=1


#Fix for lines in terrain textures and flickering textures</pre>
local gpr = require("ee-gpr-alias")


====Digimon rumble arena 2====
local eeObj  = getEEObject()
'''''CLI'''''
local emuObj = getEmuObject()


<br>ALL
local patcher = function()


<pre>
--16:9 hack
#Fix for game being stuck at main menu with selections moving very fast
eeObj.WriteMem32(0x21D43044,0x3F100000) --3F400000
--fpu-no-clamping=1
#Speedhack
--vu1-di-bits=0
</pre>


====Digimon World 4====
emuObj.ThrottleMax()
'''''CLI'''''
end


<br>All Versions
emuObj.AddVsyncHook(patcher)


emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } ) --texMode=1
</pre>
'''Crash Bandicoot 4: Sakuretsu! Majin Power'''
'''クラッシュ・バンディクー4 ~さくれつ!魔神・パワー~'''
<br>SLPM62114
'''SLPM-62114_cli.conf'''
<pre>
<pre>
#Fixes slowdowns in The game
--gs-uprender=2x2
--gs-upscale=edgesmooth
--host-display-mode=16:9
--force-frame-blend=1
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
#Speedhacks
--vu1-di-bits=0
--vu1-di-bits=0
--vu1-const-prop=1
 
--vu1-mpg-cycles=700
#emu used=KOF 98
--ee-cycle-scalar=1.2
#Fixes black screen caused by MTVU
--vu1=jit-sync
#Jakv2
</pre>
</pre>
'''SLPM-62114_config.lua'''
<pre>
-- Crash Bandicoot 4: Sakuretsu! Majin Power [SLPM-62114] (NTSC-J)
-- emu used=KOF 98


====Disney Golf====
apiRequest(1.0)
'''''CLI'''''


<br>All Versions
local gpr = require("ee-gpr-alias")
local eeObj = getEEObject()
local emuObj = getEmuObject()
 
local patcher = function()


<pre>
--16:9 hack
#Fixes graphical glitches
eeObj.WriteMem32(0x00113990,0x3C013F11) --vertical fov
--gs-uprender=2x2
eeObj.WriteMem32(0x0011250C,0x3C013F2A) --zoom value
--gs-upscale=EdgeSmooth
eeObj.WriteMem32(0x00112958,0x3C013F2A) --render value
--gs-use-clut-merge=1
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"
--force-frame-blend=1
--vu1-mpg-cycles=1000
--cdvd-sector-read-cycles=5000
--host-display-mode=16:9
--vu1-jr-cache-policy=newprog


#aofa
--No interlace
</pre>
eeObj.WriteMem32(0x2016A2F8,0xAF80E750)
eeObj.WriteMem32(0x2016A304,0xAF80E750)


====Dragon Ball Z: Budokai Tenkaichi 2====
--Underwater FX Fix
'''''CLI'''''
eeObj.WriteMem32(0x2024D534,0x0000182D)


<br>All Versions
--Mech FX Fix
eeObj.WriteMem32(0x20261D78,0x0000182D)


<pre>--gs-use-clut-merge=1
--Cortex Vortex FX Fix
--gs-kernel-cl="clutmerge"
eeObj.WriteMem32(0x2024CBA4,0x100000BC)
--gs-kernel-cl-up="clutmerge2x2"


#Fix for missing life bars and other UI elements.</pre>
--Disable Dark Effect
eeObj.WriteMem32(0x20262658,0x44801000)


====Dragon Ball Z: Budokai Tenkaichi 3====
emuObj.ThrottleMax()
'''''CLI'''''
end


<br>All Versions
emuObj.AddVsyncHook(patcher)


<pre>#Fix for missing life bars and other UI elements
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } ) --texMode=1
--gs-use-clut-merge=1
#Fix for mis-aligned glow caused by upscaling
--gs-kernel-cl-up="up2x2simple"
#Fix for Performance
--vu1-mpg-cycles=200
--vu1-di-bits=0
--ee-cycle-scalar=1.2
</pre>
</pre>


====Dragon Quest VIII: Journey of the Cursed King====
====Crash Tag Team Racing====
'''''CLI'''''
'''''CLI'''''
<br>'''Pal'''
<pre>
#Fix For Extreme slowdowns,
#This game is known for being EXTREMELY VU1 hungry.
--vu1-mpg-cycles=1200
--vu1-di-bits=0
--vu1-const-prop=1
--ee-cycle-scalar=1.3
</pre>


<br>All Versions
'''CLI'''
 
<br>'''SLUS_211.91 only'''
<pre>--gs-kernel-cl-up="up2x2skipinterp"
<pre>
--gs-optimize-30fps=1
 
#Fix lines in shadows</pre>
 
====Dreamworks: Shrek the third====
<br>All Versions
<br>'''CLI'''
<pre>
#Slowdown fixes
--vu1-di-bits=0
--vu1-di-bits=0
--vu1-mpg-cycles=600
--vu1-mpg-cycles=250
--ee-cycle-scalar=1.2
--ee-cycle-scalar=1.2
 
--ee-hook=0x0034C098,AdvanceClock,,500
#Disable try to fix graphics if creating using ps2fpkg v0.6
#This will cause stuttering during car transformation animation
</pre>
#But it is better than having slowdowns
 
--ee-hook=0x003547C8,AdvanceClock,,9000
====DreamWorks Madagascar====
'''CLI'''
<br>All versions
<pre>
#Game hates upscaling, so this will be enough to fix all upscaling problems.
--gs-kernel-cl-up="up2x2simple"
#Speedhacks
--vu1-mpg-cycles=300
--ee-cycle-scalar=1.2
--vu1-di-bits=0
</pre>
</pre>


'''LUA'''
'''LUA'''
<br>SLES-53225
<br>'''SLUS_211.91 only'''
<br>This patch fixes this [https://github.com/PCSX2/pcsx2/issues/7866 issue]
<pre>
<pre>
apiRequest(0.1)
apiRequest(0.1)
--Fix for graphical problems, Game needs vu1 nearest rounding.
--Credit goes to Goatman13, Untested on ps4.
--Add one bit in LOI 8388609.0


local eeObj = getEEObject()
local eeObj = getEEObject()
local emuObj = getEmuObject()
local emuObj = getEmuObject()
local patcher = function()
local patcher = function()
eeobj.writemem8(0x0034BA40,0x01)
 
eeobj.writemem8(0x0034BDE0,0x01)
--Author: MrJaredBeta
eeobj.writemem8(0x0034C100,0x01)
--Fixes: Stuttering during coin animations
eeobj.writemem8(0x0034C490,0x01)
eeObj.WriteMem32(0x0022e3e4, 0x1000000c)
eeobj.writemem8(0x0034C810,0x01)
 
end
end
emuObj.AddVsyncHook(patcher)
emuObj.AddVsyncHook(patcher)
</pre>
</pre>


====Drakengard====
====Crash Twinsanity====
<br>All versions
<br>CLI
<pre>
#Fix for Characters being visible in-game.
--fpu-no-clamping=1
#Fixes misaligned white lines.
--gs-kernel-cl-up="up2x2simple"
</pre>
 
====Eternal Poison====
'''''CLI'''''
'''''CLI'''''


'''KOF2000 EMU USED'''
<br>All Versions
<br>All Versions


<pre>
<pre>
#Fixes black screen after ps2 logo since game is not compatible with MTVU
#Speedhacks
--vu1=jit-sync
--ee-cycle-scalar=1.6
#Fixes graphical glitches
--vu1-mpg-cycles=400
--vif1-instant-xfer=0
--vu1-di-bits=0
#Graphical glitches fixes
--vu-xgkick-delay=5
--gs-use-clut-merge=1
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"
</pre>
</pre>
'''''LUA'''''
<br>SLES-52568
<pre>
apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.


====Ephemeral Fantasia™ ====
-- Fix random crashes
'''''CLI'''''
eeInsnReplace(0x1923E8,0x5440FFFB,0x00000000)
eeInsnReplace(0x1923EC,0x0071182F,0x00000000)
eeInsnReplace(0x1923F0,0x0223102F,0x00000000)
 
-- Eliminate color scan lines
local emuObj = getEmuObject()


<br>All Versions
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )</pre>
'''''LUA'''''
<br>SLUS-20909
<pre>
apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.


<pre>--gs-uprender=2x2
-- Fix random crashes
--gs-upscale=EdgeSmooth
eeInsnReplace(0x191C58,0x5440FFFB,0x00000000)
eeInsnReplace(0x191C5C,0x0071182F,0x00000000)
eeInsnReplace(0x191C60,0x0223102F,0x00000000)


--host-display-mode=16:9
-- Eliminate color scan lines
--framelimit-mode=normal
local emuObj = getEmuObject()
#Fix for missing character/world parts
--vu1-no-clamping=0
</pre>


====Everblue 2====
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )</pre>
'''''LUA file'''''


<br>SLES_513.81
====Crash Nitro Kart====


<pre>apiRequest(0.1)


eeInsnReplace(0x230b68, 0x4be503bc, 0x4b0c211c)
<br>All Versions
eeInsnReplace(0x230b6c, 0x4b0c211c, 0x4be503bc)
<br>'''''CLI'''''
eeInsnReplace(0x230b84, 0x4be603bc, 0x4bc0295c)
<pre>
eeInsnReplace(0x230b88, 0x4bc0295c, 0x4be603bc)
--gs-uprender=2x2
eeInsnReplace(0x230ba0, 0x4be703bc, 0x4bc0319c)
--gs-upscale=edgesmooth
eeInsnReplace(0x230ba4, 0x4bc0319c, 0x4be703bc)
--gs-adaptive-frameskip=1
eeInsnReplace(0x230bbc, 0x4be803bc, 0x4bc039dc)
--force-frame-blend=1
eeInsnReplace(0x230bc0, 0x4bc039dc, 0x4be803bc)
eeInsnReplace(0x230bd8, 0x4be903bc, 0x4bc0421c)
eeInsnReplace(0x230bdc, 0x4bc0421c, 0x4be903bc)
eeInsnReplace(0x230bf4, 0x4bea03bc, 0x4bc04a5c)
eeInsnReplace(0x230bf8, 0x4bc04a5c, 0x4bea03bc)
eeInsnReplace(0x230c10, 0x4beb03bc, 0x4bc0529c)
eeInsnReplace(0x230c14, 0x4bc0529c, 0x4beb03bc)


#Missing textures fix</pre>
--vu0-no-clamping=0
--vu1-no-clamping=0
--vu1-di-bits=0
--vu1=jit-sync


====Fight Club====
--vu1-mpg-cycles=2200
--vu1-jalr-cache-policy=newprog
--vu0-jr-cache-policy=sameprog


'''''CLI'''''
--ee-hook=0x005dbc38,AdvanceClock,,21000
<br>SLUS_208.57
<pre>--gs-uprender=2x2
--gs-upscale=EdgeSmooth
--gs-override-small-tri-area=1
--cdvd-sector-read-cycles=2000
 
--ee-cycle-scalar=1.10
 
--vu0-mpg-cycles=1
--vu0-no-clamping=0
 
#emu used=aofa
</pre>
</pre>
'''''LUA file'''''
<br>'''''LUA (NTSC ONLY!)'''''
<pre>
<pre>
-- Fight Club (U)(SLUS-20857)
-- Crash Nitro Kart NTSC
-- Widescreen Hack by Arapapa
-- Widescreen by Stayhye
-- ported to PS4 by Stayhye
-- ported to PS4 by Stayhye
-- emu used=aofa
-- emu used=jakx v2


apiRequest(1.0)
local gpr = require("ee-gpr-alias")


local gpr    = require("ee-gpr-alias")
apiRequest(2.0)


local emuObj = getEmuObject()
local emuObj = getEmuObject()
local eeObj = getEEObject()
local eeObj = getEEObject()
local gsObj = getGsObject()
local eeOverlay = eeObj.getOverlayObject()
local iopObj        = getIOPObject()


emuObj.PadSetLightBar(0, 255,0,255)
emuObj.SetDisplayAspectWide()
emuObj.SetDisplayAspectWide()
gsObj.SetDeinterlaceShift(1)
gsObj.SetUprenderMode(1) -- 0=none <> 1=2x2
emuObj.SetDeinterlace(true)
local patcher = function()
--freeze fix
eeObj.WriteMem32(0x003e8170,0)
--16:9
eeObj.WriteMem32(0x0058bcf8,0x3c023f40) -- 0x3c023f00 - hor. axis
eeObj.WriteMem32(0x0058bd0c,0x3c023f40) -- 0x3c023f00 -- zoom


local widescreen = function()
--eeObj.WriteMem32(0x005dbc18,0x24030001)
--Widescreen hack 16:9
eeObj.SchedulerDelayEvent("vif1.dma",0x5000)
eeObj.WriteMem32(0x0025909c,0x3c013ec0)
emuObj.ThrottleMax() -- No negative.
--CHEATS
--Fred by MadCatz
--eeObj.WriteMem32(0x2046E434,0x00000001)
--Halo by MadCatz
--eeObj.WriteMem32(0x2046E438,0x00000001)
--Abe by MadCatz
--eeObj.WriteMem32(0x2046E43C,0x00000001)
--Chesler by MadCatz
--eeObj.WriteMem32(0x2046E440,0x00000001)
--Tyler by MadCatz
--eeObj.WriteMem32(0x2046E3D4,0x00000001)
--Jack by MadCatz
--eeObj.WriteMem32(0x2046E3D8,0x00000001)
--Bob by MadCatz
--eeObj.WriteMem32(0x2046E3DC,0x00000001)
--Angel Face by MadCatz
--eeObj.WriteMem32(0x2046E3E0,0x00000001)
--Irvine by MadCatz
--eeObj.WriteMem32(0x2046E3E4,0x00000001)
--Mechanic by MadCatz
--eeObj.WriteMem32(0x2046E3E8,0x00000001)
--Ricky by MadCatz
--eeObj.WriteMem32(0x2046E3EC,0x00000001)
--Lou by MadCatz
--eeObj.WriteMem32(0x2046E3F0,0x00000001)
--Raymond by MadCatz
--eeObj.WriteMem32(0x2046E3F4,0x00000001)
--Detective Stern by MadCatz
--eeObj.WriteMem32(0x2046E3F8,0x00000001)
--Fred by MadCatz
--eeObj.WriteMem32(0x2046E3FC,0x00000001)
--Halo by MadCatz
--eeObj.WriteMem32(0x2046E400,0x00000001)
--Abe by MadCatz
--eeObj.WriteMem32(0x2046E404,0x00000001)
--Chesler by MadCatz
--eeObj.WriteMem32(0x2046E408,0x00000001)
-- fixes graphical glitches...still slight flicker. better results than "--vif1-instant-xfer=0" in CLI
eeObj.SchedulerDelayEvent("vif1.dma", 0x5000) -- needs to find exact value
eeObj.Vu1MpgCycles(1) -- reduces flicker further
emuObj.ThrottleMax()
end
end
emuObj.AddVsyncHook(widescreen)


-- Small triangle rejection. Works in conjunction with CLI setting  --gs-override-small-tri-area=1 
emuObj.AddVsyncHook(patcher)
emuObj.SetGsTitleFix( "setRejectionArea", 100,{twIsNot=12, thIsNot=12 } )
</pre>
</pre>


====Flatout 2====
====Dead or Alive 2: Hardcore====
'''LUA'''
<br>'''''LUA file'''''
<br>SLUS212.51
 
<pre>
<br>SLUS_200.71
apiRequest(0.1)
local eeObj = getEEObject()
local emuObj = getEmuObject()


local patcher = function()
<pre>apiRequest(0.1)


----Disable graphics overlay to fix all slowdown + widescreen code
-- Fix hang, fix music, and sounds effects
eeObj.WriteMem32(0x3a0498,0x3c013f14)
eeObj.WriteMem32(0x2d4b40,0x3c014010)
eeObj.WriteMem32(0x22e768,0x3C013F8A)
eeObj.WriteMem32(0x2d5B30,0x00000000)
end


emuObj.AddVsyncHook(patcher)
emuMediaPatch(0x186A71, 12 + 0x7e4, { 0x2404002b }, { 0x27c40010 })
</pre>
emuMediaPatch(0x186A71, 12 + 0x7e8, { 0x0c0032b3 }, { 0x0c0032b7 })
'''LUA'''
emuMediaPatch(0x186A71, 12 + 0x7ec, { 0x27c50010 }, { 0x00000000 })
<br>SLES540.02
emuMediaPatch(0x186A71, 12 + 0x5e8, { 0x27bdfff0 }, { 0x03e00008 })
<pre>
emuMediaPatch(0x186A71, 12 + 0x5ec, { 0xafbe0008 }, { 0x00000000 })
apiRequest(0.1)
emuMediaPatch(0x186A7B, 12 + 0x6fc, { 0x27bdfff0 }, { 0x03e00008 })
local eeObj = getEEObject()
emuMediaPatch(0x186A7B, 12 + 0x700, { 0xafbe0008 }, { 0x00000000 })
local emuObj = getEmuObject()
emuMediaPatch(0x186A85, 12 + 0x164, { 0x27bdfff0 }, { 0x03e00008 })
emuMediaPatch(0x186A85, 12 + 0x168, { 0xafbe0008 }, { 0x00000000 })
emuMediaPatch(0x186A85, 12 + 0x10c, { 0x27bdfff0 }, { 0x03e00008 })
emuMediaPatch(0x186A85, 12 + 0x110, { 0xafbe0008 }, { 0x00000000 })
emuMediaPatch(0x186A85, 12 + 0x1bc, { 0x27bdfff0 }, { 0x03e00008 })
emuMediaPatch(0x186A85, 12 + 0x1c0, { 0xafbe0008 }, { 0x00000000 })
emuMediaPatch(0x186A86, 12 + 0x7f0, { 0x27bdfff0 }, { 0x03e00008 })
emuMediaPatch(0x186A86, 12 + 0x7f4, { 0xafbe0008 }, { 0x00000000 })
emuMediaPatch(0x186C38, 12 + 0x6ec, { 0x24060001 }, { 0x24060000 })</pre>


local patcher = function()
For the Japanese version (SLPS-25026) you can also use config files from PS3's PS2 emu with
<pre>--lopnor-config=1</pre>
in config.


--Disable graphics overlay to fix all slowdown + widescreen code
Place config file named as "SLPS-25026_lopnor.cfgbin" in /patches/SLPS-25026/
eeObj.WriteMem32(0x3A1F28,0x3c013f14)
eeObj.WriteMem32(0x2D6650,0x3c014010)
eeObj.WriteMem32(0x234F18,0x3C013F8A)
eeObj.WriteMem32(0x2d7640,0x00000000)
end


emuObj.AddVsyncHook(patcher)
</pre>


====Frogger: Ancient Shadow====
'''''*Alternate fix Jak emus'''''
'''''CLI'''''
 
<br>'''''LUA file'''''


<br>SLUS_210.98


<pre>
<pre>
#This one might be the only one you need
--DOA 2 Hardcore NTSC US
--vu1-no-clamping=0
#use the rest just in case
--vu0-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1
#Fixes disappearing models during cutscenes and during gameplay</pre>


====Galactic Wrestling Featuring Ultimate Muscle====
apiRequest(2.2)
NTSC/U
<br>CLI
<pre>--fpu-no-clamping=0
--fpu-clamp-results=1
--vu0-no-clamping=0
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-results=1
#fix for missing character models
--vu-xgkick-delay=0.58
#KOF98Emu used</pre>


====Galarians: Ash====
local gpr      = require("ee-gpr-alias")
'''''CLI'''''
local emuObj      = getEmuObject()
<pre>--gs-uprender=2x2
local eeObj      = getEEObject()
--gs-upscale=EdgeSmooth
local gsObj      = getGsObject()
--gs-adaptive-frameskip=1
local eeOverlay    = eeObj.getOverlayObject()
local iopObj  = getIOPObject()


--vif-ignore-invalid-cmd=0
local patcher = function()
--vif1-ignore-cmd-ints=1
--vif1-instant-xfer=0


--ee-jit-pagefault-threshold=30
eeObj.WriteMem32(0x0021b63c,0x3c014534) -- Widescreen
 
eeObj.WriteMem32(0x002b06ec,0x24060000) -- Fixes game hanging on boot.
--lopnor-config=1 #found here http://ps3.aldostools.org/ps2config.html
iopObj.WriteMem32(0x001D77E4,0x27C40010) --fixes music/sound effects
iopObj.WriteMem32(0x001D77E8,0x0C0032B7) --fixes music/sound effects 
iopObj.WriteMem32(0x001D77EC,0x00000000) --fixes music/sound effects
 
end
 
emuObj.AddVsyncHook(patcher)


--ee-cycle-scalar=2.0
emuObj.PadSetLightBar(0,255,200,250)
emuObj.SetDisplayAspectWide()


</pre>
</pre>
'''''LUA file'''''
 
====Devil Kings====
All versions
<br>CLI
<pre>
<pre>
-- Galarians Ash NTSC
#Fix For Graphical Glitches (SPS)
-- emu used=jakx v2
--vu1-no-clamping=0
</pre>


local gpr = require("ee-gpr-alias")
====Disgaea 2: Cursed Memories====
'''''CLI'''''


apiRequest(2.2)
<br>SLUS-21397


local eeObj = getEEObject()
<pre>#Fix for lines in terrain textures and flickering textures
local emuObj = getEmuObject()
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--gs-use-mipmap=1</pre>


local patcher = function()
====Digimon Rumble Arena 2====
'''''CLI'''''


eeObj.WriteMem32(0x001e0100,0x3c013f40) -- 16:9
<br>ALL
emuObj.ThrottleMax() -- Drastically reduces loading screens duration on most games


end
<pre>
 
#Fix for game being stuck at main menu with selections moving very fast
emuObj.AddVsyncHook(patcher)
--fpu-no-clamping=1
#Speedhack
--vu1-di-bits=0
</pre>
</pre>


====Ghost in the Shell: Stand Alone Complex====
====Digimon World 4====
<br>'''''LUA file'''''
'''''CLI'''''


<br>SLES_530.20
<br>All Versions


<pre>apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.
<pre>
 
#Fixes slowdowns in The game
eeInsnReplace(0x10BC88, 0x4BEC682C, 0x48468800)
eeInsnReplace(0x10BC8C, 0x4B8D617D, 0x4bec682c)
eeInsnReplace(0x10BC90, 0x4A6D617C, 0x4b8d617d)
eeInsnReplace(0x10BC98, 0x48468800, 0x4a6d617c)
eeInsnReplace(0x12B2CC, 0x4BEC682C, 0x48468800)
eeInsnReplace(0x12B2D0, 0x4B8D617D, 0x4bec682c)
eeInsnReplace(0x12B2D4, 0x4A6D617C, 0x4b8d617d)
eeInsnReplace(0x12B2DC, 0x48468800, 0x4a6d617c)
eeInsnReplace(0x12B5F4, 0x4BEC682C, 0x48468800)
eeInsnReplace(0x12B5F8, 0x4B8D617D, 0x4bec682c)
eeInsnReplace(0x12B5FC, 0x4A6D617C, 0x4b8d617d)
eeInsnReplace(0x12B604, 0x48468800, 0x4a6d617c)
eeInsnReplace(0x1B0B58, 0x4BEC682C, 0x48468800)
eeInsnReplace(0x1B0B5C, 0x4BED617D, 0x4bec682c)
eeInsnReplace(0x1B0B68, 0x48468800, 0x4b8d617d)
eeInsnReplace(0x1BF5FC, 0x4A0002FF, 0x48588800)
eeInsnReplace(0x1BF60C, 0x48588800, 0x4a0002ff)
eeInsnReplace(0x1BFBB8, 0x4A0002FF, 0x48588800)
eeInsnReplace(0x1BFBC8, 0x48588800, 0x4a0002ff)
eeInsnReplace(0x1BF818, 0x4A0002FF, 0x48588800)
eeInsnReplace(0x1BF828, 0x48588800, 0x4a0002ff)
eeInsnReplace(0x1C017C, 0x4A0002FF, 0x48588800)
eeInsnReplace(0x1C018C, 0x48588800, 0x4a0002ff)
 
-- Potential fix for broken interactive door // Rearranging COP2 ops so as to avoid macflag bad stuff</pre>
 
====Gran turismo 4====
'''CLI'''
<br>All versions
<br>Forbidden siren v2 emu only
<pre>
#Fix incomplete letters in menu
--vu0-no-clamping=0
--vu1-no-clamping=0
#Speedhacks
--ee-cycle-scalar=1.2
--vu1-di-bits=0
--vu1-di-bits=0
--vu1-const-prop=1
--vu1-mpg-cycles=700
--vu1-mpg-cycles=700
#Fix video anticipated race license
--ee-cycle-scalar=1.2
--fpu-accurate-muldiv=1
#Fixes black screen caused by MTVU
#Speedhack so that the muldiv doesn't cause slowdown
--vu1=jit-sync
--fpu-accurate-mul-fast=1
#Jakv2
#Gfx fix
--vif1-instant-xfer=0
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
</pre>
</pre>


'''LUA'''
====Disney Golf====
<br>SCES-51719 only
'''''CLI'''''
 
<br>All Versions
 
<pre>
<pre>
--gametitle=Gran Turismo 4 [SCES-51719] (E)
#Fixes graphical glitches
--emu=siren v2
--gs-use-clut-merge=1
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"
--force-frame-blend=1
#Other
--cdvd-sector-read-cycles=5000
#Speedhacks
--vu1-mpg-cycles=1000
--vu1-jr-cache-policy=newprog


apiRequest(0.1)
#aofa
</pre>


local eeObj    = getEEObject()
====Dokapon Kingdom====
local emuObj = getEmuObject()
'''''CLI'''''
local gsObj    = getGsObject()
<br>All Versions
<pre>
#Fixes black screen freeze.
--vu1=jit-sync
</pre>


local widescreen = function()
====Dragon Ball Z: Budokai Tenkaichi 2====
'''''CLI'''''


-- force progressive scan
<br>All Versions
eeObj.WriteMem32(0x20A57E70,0x00000001)
eeObj.WriteMem32(0x201074A0,0x24050003) --8E050004
eeObj.WriteMem32(0x2061868C,0x00000001) --00000000
eeObj.WriteMem32(0x20618694,0x00000000) --00000001


-- Autoboot in 480p
<pre>#Fix for missing life bars and other UI elements.
eeObj.WriteMem32(0x20436820,0xAE0516B0) --AE0010E8
--gs-use-clut-merge=1
eeObj.WriteMem16(0x20436910,0x10E8) --
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"
</pre>


--Field of View
====Dragon Ball Z: Budokai Tenkaichi 3====
'''''CLI'''''


-- Screen Width  (mm)
<br>All Versions
eeObj.WriteMem32(0x20A567F0,0x446E0000) -- 952mm in my case


-- Screen Height (mm)
<pre>#Fix for missing life bars and other UI elements
eeObj.WriteMem32(0x20A567F4,0x4405C000) -- 535mm in my case
--gs-use-clut-merge=1
 
#Fix for mis-aligned glow caused by upscaling
-- Eye Distance to Screen (mm)
--gs-kernel-cl-up="up2x2simple"
eeObj.WriteMem32(0x20A567EC,0x44610000) -- 900mm in my case
#Fix for Performance
--vu1-mpg-cycles=200
--vu1-di-bits=0
--ee-cycle-scalar=1.2
</pre>


-- Zoom Level (-2.0 to 2.0)
====Dragon Quest VIII: Journey of the Cursed King====
eeObj.WriteMem32(0x20A567E8,0x3f800000) -- 1.0, we already have the right FoV Better don't touch this
'''''CLI'''''


<br>All Versions


--Aspect Ratio
<pre>--gs-kernel-cl-up="up2x2skipinterp"
--gs-optimize-30fps=1


--  Single Screen Aspect Ratios
#Fix lines in shadows</pre>
--    1 x 16:9  3f800000
--    1 x 21:9  3FAAAAAB
--    1 x 32:9  40000000


--   Triple Screen Aspect Ratios
====Dragon Quest V: Tenkuu no Hanayome====
--   3 x 16:9  40400000
'''CLI'''
<pre>
#Speedhacks
--ee-cycle-scalar=1.2
--vu1-di-bits=0
#Fix for being stuck in Faerie land.
--fpu-accurate-range=0x00693f88,0x00693f88
</pre>


eeObj.WriteMem32(0x20A567F8,0x3f800000) -- 16:9 in my case
====Dreamworks: Shrek the third====
<br>All Versions
<br>'''CLI'''
<pre>
#Slowdown fixes
--vu1-di-bits=0
--vu1-mpg-cycles=600
--ee-cycle-scalar=1.2


-- disable colour correction channel shuffle effect
#Disable try to fix graphics if creating using ps2fpkg v0.6
eeObj.WriteMem32(0x0033F8B8,0x1000000B) --5440000B
</pre>


-- disable rendering of light sources
====DreamWorks Madagascar====
eeObj.WriteMem32(0x0033F6B0,0x10000031) --10400031
'''CLI'''
 
<br>All versions
-- Fix shadows
<pre>
eeObj.WriteMem32(0x001D6598,0x00000000) --0C075A6A
#Game hates upscaling, so this will be enough to fix all upscaling problems.
 
--gs-kernel-cl-up="up2x2simple"
-- Added GT4 First Preview camera mode (far chase camera)
#Speedhacks
eeObj.WriteMem32(0x2037AFAC,0x84E30000)
--vu1-mpg-cycles=300
eeObj.WriteMem16(0x2037AFB0,0x0002)
--ee-cycle-scalar=1.2
eeObj.WriteMem16(0x2037AFC0,0x0004)
--vu1-di-bits=0
eeObj.WriteMem32(0x2037AFD0,0x84E30000)
 
eeObj.WriteMem16(0x2037AFE0,0x0004)
eeObj.WriteMem8(0x0037AFF8,0x40)
eeObj.WriteMem16(0x2037B00A,0x8442)
 
eeObj.WriteMem32(0x206211E8,0x00010000)
eeObj.WriteMem32(0x206211EC,0x00060014)
 
end
 
emuObj.AddVsyncHook(widescreen)
</pre>
</pre>


====Gran Turismo 4 - Prologue====
'''LUA'''
<br>PBPX-95524
<br>SLES-53225
<br>LUA
<br>This patch fixes this [https://github.com/PCSX2/pcsx2/issues/7866 issue]
<pre>
<pre>
local gpr = require("ee-gpr-alias")
apiRequest(0.1)


apiRequest(0.1)
--Fix for graphical problems, Game needs vu1 nearest rounding.
--Credit goes to Goatman13, Untested on ps4.
--Add one bit in LOI 8388609.0


local eeObj = getEEObject()
local eeObj = getEEObject()
local emuObj = getEmuObject()
local emuObj = getEmuObject()
local patcher = function()
local patcher = function()
 
eeobj.writemem8(0x0034BA40,0x01)
--fix IPU DMA
eeobj.writemem8(0x0034BDE0,0x01)
eeObj.WriteMem32(0x166814,0x0)
eeobj.writemem8(0x0034C100,0x01)
eeObj.WriteMem32(0x3a36b8,0x0)
eeobj.writemem8(0x0034C490,0x01)
eeObj.WriteMem32(0x3a36f4,0x0)
eeobj.writemem8(0x0034C810,0x01)
 
emuObj.ThrottleMax()
end
end
emuObj.AddVsyncHook(patcher)


emuObj.AddVsyncHook(patcher)
</pre>
</pre>


====Grand Theft Auto: Vice City Stories====
====DreamWorks Bee Movie Game====
SLUS_215.90
'''CLI'''
<br>CLI
<br>All versions
<pre>
<pre>
--gs-uprender=2x2
--ee-cycle-scalar=4.0 #fix pass fmv
--vu0-di-bits=0
--vu1-di-bits=0
--vu1-jr-cache-policy=newprog #fix random crash?
--gs-uprender=1
--gs-upscale=edgesmooth
--gs-upscale=edgesmooth
--gs-kernel-cl="h2lpool"
--host-display-mode=full
--gs-kernel-cl-up="h2lpool2x2"


--host-display-mode=16:9
# Emu used = Primal
#emu used=psychonauts v2
</pre>
</pre>
<br>LUA
<pre>
-- emu used=psychonauts v2
local gpr = require("ee-gpr-alias")


apiRequest(1.0)
====Ephemeral Fantasia™ ====
'''''CLI'''''


local eeObj = getEEObject()
<br>All Versions
local emuObj = getEmuObject()


local patcher = function()
<pre>--gs-uprender=2x2
--gs-upscale=EdgeSmooth


--widescreen fix
--host-display-mode=16:9
eeObj.WriteMem32(0x002653d8,0x3c013f9d)
--framelimit-mode=normal
eeObj.WriteMem32(0x002653dc,0x44810000)
#Fix for missing character/world parts
eeObj.WriteMem32(0x002653e0,0x46006302)
--vu1-no-clamping=0
eeObj.WriteMem32(0x002653e4,0x3c020048)
</pre>
eeObj.WriteMem32(0x002653e8,0x03e00008)
eeObj.WriteMem32(0x002653ec,0xe44c7484)


eeObj.WriteMem32(0x0037add4,0x0c0994f6)
====Everblue 2====
eeObj.WriteMem32(0x003b9d14,0x0c0994f9)
'''''LUA file'''''
eeObj.WriteMem32(0x003ba1b0,0x0c0994f9)


eeObj.WriteMem32(0x20370314,0x10820019)--60fps
<br>SLES_513.81


--eeObj.WriteMem32(0x20447EDC,0x00000000)--no interlace
<pre>apiRequest(0.1)


end
eeInsnReplace(0x230b68, 0x4be503bc, 0x4b0c211c)
 
eeInsnReplace(0x230b6c, 0x4b0c211c, 0x4be503bc)
emuObj.AddVsyncHook(patcher)
eeInsnReplace(0x230b84, 0x4be603bc, 0x4bc0295c)
 
eeInsnReplace(0x230b88, 0x4bc0295c, 0x4be603bc)
-- Bug#9174 -
eeInsnReplace(0x230ba0, 0x4be703bc, 0x4bc0319c)
emuObj.SetGsTitleFix( "ignoreSubBuffCov", "reserved", { } )
eeInsnReplace(0x230ba4, 0x4bc0319c, 0x4be703bc)
eeInsnReplace(0x230bbc, 0x4be803bc, 0x4bc039dc)
eeInsnReplace(0x230bc0, 0x4bc039dc, 0x4be803bc)
eeInsnReplace(0x230bd8, 0x4be903bc, 0x4bc0421c)
eeInsnReplace(0x230bdc, 0x4bc0421c, 0x4be903bc)
eeInsnReplace(0x230bf4, 0x4bea03bc, 0x4bc04a5c)
eeInsnReplace(0x230bf8, 0x4bc04a5c, 0x4bea03bc)
eeInsnReplace(0x230c10, 0x4beb03bc, 0x4bc0529c)
eeInsnReplace(0x230c14, 0x4bc0529c, 0x4beb03bc)
 
#Missing textures fix</pre>


-- Bug#9240 (Light maps uprender)
====Fire Pro Wrestling Z™®====
-- Copy z-buffer for future use with light maps. psm = SCE_GS_PSMZ24 (49)
'''LUA'''
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", {tw=9, th=9, psm=49, zmsk=1 } )
<pre>
-- Fire Pro Wrestling Z™® (English v0.5b)
-- boot fix
-- needs graphics fix
-- emu used=aofa
 
local gpr = require("ee-gpr-alias")
 
apiRequest(0.1)


-- Apply light maps texMode=2 (bilinear)  psm= SCE_GS_PSMCT32 (0)
local eeObj  = getEEObject()
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", {tw=8, th=8, psm=0, ztst=1, texMode=2 } )
local emuObj = getEmuObject()
</pre>


====Grand Theft Auto: Liberty City Stories====
local patcher = function()
SLUS_214.23
-- black screen after spike logo fix
<br>CLI
eeObj.WriteMem32(0x001eaa14,0x0) --0x1440fffa >> bne v0, zero, $001eaa00
<pre>
emuObj.ThrottleMax()
--gs-uprender=2x2
end
--gs-upscale=edgesmooth
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
--gs-h2l-list-opt=1
--gs-h2l-accurate-hash=1
--gs-adaptive-frameskip=1


--vu0-mpg-cycles=600
emuObj.AddVsyncHook(patcher)
--vu1-mpg-cycles=600


--ee-cycle-scalar=1.3
</pre>
</pre>


====Gregory Horror Show====
====Flatout 2====
'''LUA'''
'''LUA'''
<br>PAL
<br>SLUS212.51
<pre>
<pre>
-- Gregory Horror Show
-- Boot Fix by kozarovv
-- ported to PS4 lua by Stayhye
-- emu used=destroy all humans 2
apiRequest(0.1)
apiRequest(0.1)
local eeObj = getEEObject()
local emuObj = getEmuObject()


-- Mask upper bits (irq?) (lw --> lh)
local patcher = function()
eeInsnReplace(0x1953f4, 0x8e050054, 0x86050054)


</pre>
----Disable graphics overlay to fix all slowdown + widescreen code
 
eeObj.WriteMem32(0x3a0498,0x3c013f14)
====God Hand====
eeObj.WriteMem32(0x2d4b40,0x3c014010)
eeObj.WriteMem32(0x22e768,0x3C013F8A)
eeObj.WriteMem32(0x2d5B30,0x00000000)
end
 
emuObj.AddVsyncHook(patcher)
</pre>
'''LUA'''
<br>SLES540.02
<pre>
apiRequest(0.1)
local eeObj = getEEObject()
local emuObj = getEmuObject()
 
local patcher = function()
 
--Disable graphics overlay to fix all slowdown + widescreen code
eeObj.WriteMem32(0x3A1F28,0x3c013f14)
eeObj.WriteMem32(0x2D6650,0x3c014010)
eeObj.WriteMem32(0x234F18,0x3C013F8A)
eeObj.WriteMem32(0x2d7640,0x00000000)
end
 
emuObj.AddVsyncHook(patcher)
</pre>
 
====Frogger: Ancient Shadow====
'''''CLI'''''
'''''CLI'''''


<pre>--vu0-no-clamping=0
<br>SLUS_210.98
 
<pre>
#This one might be the only one you need
--vu1-no-clamping=0
--vu1-no-clamping=0
#use the rest just in case
--vu0-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu0-clamp-results=1
Line 4,149: Line 4,246:
--cop2-no-clamping=0
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-operands=1
--cop2-clamp-results=1
#Fixes disappearing models during cutscenes and during gameplay</pre>
====Galactic Wrestling Featuring Ultimate Muscle====
NTSC/U
<br>CLI
<pre>--fpu-no-clamping=0
--fpu-clamp-results=1
--vu0-no-clamping=0
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-results=1
--cop2-clamp-results=1
#fix for missing character models
--vu-xgkick-delay=0.58
#KOF98Emu used</pre>


#fix for graphical glitches, specially the missing ground.
====Galarians: Ash====
</pre>
'''''CLI'''''
<pre>--gs-uprender=2x2
--gs-upscale=EdgeSmooth
--gs-adaptive-frameskip=1
 
--vif-ignore-invalid-cmd=0
--vif1-ignore-cmd-ints=1
--vif1-instant-xfer=0
 
--ee-jit-pagefault-threshold=30
 
--lopnor-config=1 #found here http://ps3.aldostools.org/ps2config.html
 
--ee-cycle-scalar=2.0


==== God Of War ====
<br>'''EU'''
'''''CLI'''''
<pre>
--vu1-di-bits=0
--vu1-mpg-cycles=800
--vu1-jr-cache-policy=newprog
--vu1-jalr-cache-policy=newprog
--ee-block-validation=PageProt
--ee-cycle-scalar=1.2
--ee-hook=0x0017A2DC,AdvanceClock,,45
#Fix for upscaling glitches
--gs-kernel-cl-up="up2x2simple"
#Fix for audio re-starting
--iop-cycle-scalar=0.1
--cdvd-sector-seek-cycles=0.1
--cdvd-sector-read-cycles=4500
</pre>
</pre>
<br>'''US'''
'''''LUA file'''''
<pre>
<pre>
#Upscaling fix
-- Galarians Ash NTSC
--gs-kernel-cl-up="up2x2simple"
-- emu used=jakx v2
#Speedhacks
--ee-cycle-scalar=1.2
--vu1-jr-cache-policy=newprog
--vu1-jalr-cache-policy=newprog
--vu1-mpg-cycles=2500
--vu1-di-bits=0
#Cdvd timing
--iop-cycle-scalar=0.20
--cdvd-sector-read-cycles=4000</pre>


'''''LUA file'''''
local gpr = require("ee-gpr-alias")
<pre>-- God Of War EU


-- 01 Music sound problem: music restarts every time there are many sounds to play
-- 02 Latest emu removes a lot of game lag, anyway the game still suffer of shuttering in the next levels
-- 03 Corrupted green lines around the objects, uprendering problem
-- Slowdowns and performances patched in cli.conf file
apiRequest(2.2)
apiRequest(2.2)
local emuObj = getEmuObject()
local gsObj = getGsObject()
-- 03 removes corrupted lines around the objects when use --gs-uprender
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )
-- Disable internal field shift compensation, part of post-process removal feature.
gsObj.SetDeinterlaceShift(0)
</pre>
====God of War 2====
'''''CLI'''''
<pre>--vu1-jr-cache-policy=newprog
--vu1-jalr-cache-policy=newprog
--vu1-mpg-cycles=1000
--vu1-di-bits=1
--vu1-injection=1
--vu1-opt-flags=2
--ee-block-validation=PageProt
--ee-hook=0x186B64,AdvanceClock
--ee-hook=0x186CE4,AdvanceClock
--ee-cycle-scalar=1.2
--ee-kernel-hle=1
--ee-injection-kernel=1
--ee-injection-title=1
--gs-frontend-opt-mode=2
--gs-optimize-30fps=1
*Jak Emu used*</pre>
'''''LUA File'''''
<pre>-- God of War II EU
apiRequest(2.2)
local emuObj = getEmuObject()
-- Graphic improvement: removes corrupted lines on screen with uprender on for PAL version
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } ) --texMode=1 ?
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=2 } ) --texMode=2 is BILINEAR
# Fixed 90% of glitches, still has lag issues (For NTSC / PAL versions). Korean and Japanese versions works fine with this configuration.
</pre>
====Gun====
'''CLI'''
<br>Redfaction emu used
<br>NTSC
<pre>
#Graphics upscaling glitch fix
--gs-kernel-cl-up="up2x2skipinterp"
#To reduce crash occurence
--vif1-instant-xfer=0
</pre>
'''LUA'''
<br>NTSC
<pre>
-- Gun NTSC
-- various T.H.U.G. engine fixes by kozarovv
-- ported to Gun by Stayhye
-- emu used=redfaction
apiRequest(0.1)


local eeObj = getEEObject()
local eeObj = getEEObject()
Line 4,264: Line 4,294:


local patcher = function()
local patcher = function()
-- freeze fix
eeObj.WriteMem32(0x001a0f08,0x100000a6) -- 0x120000a6 >> beq s0, zero, $001a11a4
-- rounding patch
eeObj.WriteMem32(0x004738c0,0xd3400000)


--mtvu patch
eeObj.WriteMem32(0x001e0100,0x3c013f40) -- 16:9
eeObj.WriteMem32(0x0019fbbc,0x0803fff0)
emuObj.ThrottleMax() -- Drastically reduces loading screens duration on most games


eeObj.WriteMem32(0x000fffc0,0x0c067f36)
eeObj.WriteMem32(0x000fffc4,0x24186000)
eeObj.WriteMem32(0x000fffc8,0x3c191200)
eeObj.WriteMem32(0x000fffcc,0x37391010)
eeObj.WriteMem32(0x000fffd0,0x2718ffff)
eeObj.WriteMem32(0x000fffd4,0x1418fffe)
eeObj.WriteMem32(0x000fffdc,0x08067ef1)
eeObj.WriteMem32(0x000fffe0,0xaf200000)
end
end


Line 4,285: Line 4,303:
</pre>
</pre>


====Gradius V====
====Ghost in the Shell: Stand Alone Complex====
'''''CLI'''''
<br>'''''LUA file'''''
<pre>--vu1=jit-sync
 
<br>SLES_530.20


#fix for blackscreen after PS2 Logo.
<pre>apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.
</pre>


====Hunter the Reckoning Wayward====
eeInsnReplace(0x10BC88, 0x4BEC682C, 0x48468800)
'''''CLI'''''
eeInsnReplace(0x10BC8C, 0x4B8D617D, 0x4bec682c)
eeInsnReplace(0x10BC90, 0x4A6D617C, 0x4b8d617d)
eeInsnReplace(0x10BC98, 0x48468800, 0x4a6d617c)
eeInsnReplace(0x12B2CC, 0x4BEC682C, 0x48468800)
eeInsnReplace(0x12B2D0, 0x4B8D617D, 0x4bec682c)
eeInsnReplace(0x12B2D4, 0x4A6D617C, 0x4b8d617d)
eeInsnReplace(0x12B2DC, 0x48468800, 0x4a6d617c)
eeInsnReplace(0x12B5F4, 0x4BEC682C, 0x48468800)
eeInsnReplace(0x12B5F8, 0x4B8D617D, 0x4bec682c)
eeInsnReplace(0x12B5FC, 0x4A6D617C, 0x4b8d617d)
eeInsnReplace(0x12B604, 0x48468800, 0x4a6d617c)
eeInsnReplace(0x1B0B58, 0x4BEC682C, 0x48468800)
eeInsnReplace(0x1B0B5C, 0x4BED617D, 0x4bec682c)
eeInsnReplace(0x1B0B68, 0x48468800, 0x4b8d617d)
eeInsnReplace(0x1BF5FC, 0x4A0002FF, 0x48588800)
eeInsnReplace(0x1BF60C, 0x48588800, 0x4a0002ff)
eeInsnReplace(0x1BFBB8, 0x4A0002FF, 0x48588800)
eeInsnReplace(0x1BFBC8, 0x48588800, 0x4a0002ff)
eeInsnReplace(0x1BF818, 0x4A0002FF, 0x48588800)
eeInsnReplace(0x1BF828, 0x48588800, 0x4a0002ff)
eeInsnReplace(0x1C017C, 0x4A0002FF, 0x48588800)
eeInsnReplace(0x1C018C, 0x48588800, 0x4a0002ff)


<br>All Versions
-- Potential fix for broken interactive door // Rearranging COP2 ops so as to avoid macflag bad stuff</pre>


<pre>--fpu-no-clamping=0
====Gran turismo 4====
--fpu-clamp-results=1
'''CLI'''
<br>All
<br>Forbidden siren v2 emu only
<pre>
#Fix incomplete letters in menu
--vu0-no-clamping=0
--vu0-no-clamping=0
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-no-clamping=0
--vu1-clamp-results=1
#Speedhacks
--cop2-no-clamping=0
--ee-cycle-scalar=1.2
--cop2-clamp-results=1
--vu1-di-bits=0
--vu0-opt-flags=1
--vu1-mpg-cycles=700
--vu1-opt-flags=1
#Fix video anticipated race license
--cop2-opt-flags=1
--fpu-accurate-muldiv-range=0x00579EB8,0x00579EB8
--vu0-const-prop=0
--fpu-accurate-muldiv-range=0x00579EDC,0x00579EDC
--vu1-jr-cache-policy=newprog
--fpu-accurate-muldiv-range=0x0057A008,0x0057A008
--vu1-jalr-cache-policy=newprog
--fpu-accurate-muldiv-range=0x0057A030,0x0057A030
--vu0-jalr-cache-policy=newprog
#Gfx fix
--vif1-instant-xfer=0
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
</pre>


#fix for graphical glitches.
'''CLI'''
<br>SCPS-17001
<br>Forbidden siren v2 emu only
<pre>
#Fix incomplete letters in menu
--vu0-no-clamping=0
--vu1-no-clamping=0
#Speedhacks
--ee-cycle-scalar=1.2
--vu1-di-bits=0
--vu1-mpg-cycles=700
#Fix video anticipated race license
--fpu-accurate-muldiv-range=0x00571A92,0x00571A92
--fpu-accurate-muldiv-range=0x00571AB4,0x00571AB4
--fpu-accurate-muldiv-range=0x00571BE0,0x00571BE0
--fpu-accurate-muldiv-range=0x00571C08,0x00571C08
#Gfx fix
--vif1-instant-xfer=0
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
</pre>
</pre>


====Ice Age 2 Meltdown====
'''LUA'''
'''''LUA file'''''
<br>SCES-51719 only
<br>Company logo freeze Fix
<pre>
<br>'''Use Forbidden Siren v2 Emu'''
--gametitle=Gran Turismo 4 [SCES-51719] (E)
--emu=siren v2
 
apiRequest(0.1)


<br>SLUS_213.07
local eeObj    = getEEObject()
<pre>apiRequest(0.1)
local emuObj = getEmuObject()
local gsObj    = getGsObject()


eeInsnReplace(0x2feb80, 0x27bdff70, 0x27bdfee0)
local widescreen = function()
eeInsnReplace(0x2febbc, 0x27bd0090, 0x27bd0120)
</pre>
<br>SLES_539.84
<pre>apiRequest(0.1)


eeInsnReplace(0x2ff3f0, 0x27bdff70, 0x27bdfee0)
-- force progressive scan
eeInsnReplace(0x2ff42c, 0x27bd0090, 0x27bd0120)
eeObj.WriteMem32(0x20A57E70,0x00000001)
</pre>
eeObj.WriteMem32(0x201074A0,0x24050003) --8E050004
<br>SLPM_664.97
eeObj.WriteMem32(0x2061868C,0x00000001) --00000000
<pre>apiRequest(0.1)
eeObj.WriteMem32(0x20618694,0x00000000) --00000001


eeInsnReplace(0x2e91e8, 0x27bdff70, 0x27bdfee0)
-- Autoboot in 480p
eeInsnReplace(0x2e9224, 0x27bd0090, 0x27bd0120)
eeObj.WriteMem32(0x20436820,0xAE0516B0) --AE0010E8
</pre>
eeObj.WriteMem16(0x20436910,0x10E8) --


====Jackie Chan Adventures====
--Field of View
'''''CLI'''''


<br>SCES_524.12
-- Screen Width  (mm)
eeObj.WriteMem32(0x20A567F0,0x446E0000) -- 952mm in my case


<pre>
-- Screen Height (mm)
#Fix For Jackie chan falling forever near The Ox Talisman Glitch
eeObj.WriteMem32(0x20A567F4,0x4405C000) -- 535mm in my case
--fpu-accurate-addsub-range=0x22F2B0,0x22F468
#Fixes For Slowdowns
--vu1-di-bits=0
--vu1-const-prop=1
--ee-cycle-scalar=1.2
#RECVX
</pre>


====Jaws Unleashed====
-- Eye Distance to Screen (mm)
<br>'''''LUA file'''''
eeObj.WriteMem32(0x20A567EC,0x44610000) -- 900mm in my case


<pre>
-- Zoom Level (-2.0 to 2.0)
eeObj.WriteMem32(0x20A567E8,0x3f800000) -- 1.0, we already have the right FoV Better don't touch this


apiRequest(1.0)
local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()
eeObj.WriteMem32(0x006758a8,0x03e42000)
eeObj.WriteMem32(0x006758b8,0x800026fc)
end
emuObj.AddVsyncHook(patcher)


#fix for loading screen hang.
--Aspect Ratio
</pre>


====Juiced====
--  Single Screen Aspect Ratios
'''CLI'''
--    1 x 16:9  3f800000
<br>All versions
--    1 x 21:9  3FAAAAAB
--    1 x 32:9  40000000


<pre>
--   Triple Screen Aspect Ratios
#Fix for graphical glitches
--   3 x 16:9  40400000
--gs-kernel-cl-up="up2x2simple"
#Speedhacks
--vu1-di-bits=0
--vu1-mpg-cycles=800
--ee-cycle-scalar=1.2
</pre>


====Killer7====
eeObj.WriteMem32(0x20A567F8,0x3f800000) -- 16:9 in my case
'''''CLI'''''


<br>All versions
-- disable colour correction channel shuffle effect
eeObj.WriteMem32(0x0033F8B8,0x1000000B) --5440000B


<pre>--vu0-no-clamping=0
-- disable rendering of light sources
--vu0-clamp-operands=1
eeObj.WriteMem32(0x0033F6B0,0x10000031) --10400031
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-clamp-operands=1
--vu1-clamp-results=1


#fix for flickering polygons.</pre>
-- Fix shadows
eeObj.WriteMem32(0x001D6598,0x00000000) --0C075A6A


====Kim Possible: What's the Switch====
-- Added GT4 First Preview camera mode (far chase camera)
'''''CLI'''''
eeObj.WriteMem32(0x2037AFAC,0x84E30000)
eeObj.WriteMem16(0x2037AFB0,0x0002)
eeObj.WriteMem16(0x2037AFC0,0x0004)
eeObj.WriteMem32(0x2037AFD0,0x84E30000)


<br>PAL
eeObj.WriteMem16(0x2037AFE0,0x0004)
<pre>--vu1-mpg-cycles=950
eeObj.WriteMem8(0x0037AFF8,0x40)
eeObj.WriteMem16(0x2037B00A,0x8442)


#fix lag during cutscenes
eeObj.WriteMem32(0x206211E8,0x00010000)
</pre>
eeObj.WriteMem32(0x206211EC,0x00060014)


====Klonoa 2====
end
'''''CLI'''''


<br>All versions
emuObj.AddVsyncHook(widescreen)
</pre>


<pre>
====Gran Turismo 4 - Prologue====
#Fix for Misplaced objects
<br>PBPX-95524
--fpu-no-clamping=1
<br>LUA
#Potential fix for Graphics
<pre>
--vu1-no-clamping=0
local gpr = require("ee-gpr-alias")
--vu0-no-clamping=0
 
apiRequest(0.1)
 
local eeObj = getEEObject()
local emuObj = getEmuObject()
 
local patcher = function()
 
--fix IPU DMA
eeObj.WriteMem32(0x166814,0x0)
eeObj.WriteMem32(0x3a36b8,0x0)
eeObj.WriteMem32(0x3a36f4,0x0)
 
emuObj.ThrottleMax()
end


#still require fix for texturing problems. Require Rogue Galaxy emu</pre>
emuObj.AddVsyncHook(patcher)
</pre>


====Kuon====
====Grand Theft Auto: Vice City Stories====
SLUS_215.90
<br>CLI
<br>CLI
<br>All Versions
<pre>
<pre>
--vif1-ignore-cmd-ints=1
--gs-uprender=2x2
--vif-ignore-invalid-cmd=0
--gs-upscale=edgesmooth
--vif1-instant-xfer=0
--gs-kernel-cl="h2lpool"
#Fix the freezing problem in the opening scene of 《阴の章》
--gs-kernel-cl-up="h2lpool2x2"
 
--host-display-mode=16:9
#emu used=psychonauts v2
</pre>
</pre>
 
<br>LUA
<br>NTSC Version ONLY CLI
<pre>
<pre>
--vif1-ignore-cmd-ints=1
-- emu used=psychonauts v2
--vif-ignore-invalid-cmd=0
local gpr = require("ee-gpr-alias")
--vif1-instant-xfer=0
#Sugoroku Fix
--fpu-accurate-addsub=0x104124
</pre>


====Time Crisis 2====
apiRequest(1.0)
'''LUA'''
<br>SLUS_202.19
<pre>
-- Time Crisis 2 SLUS_202.19
-- Widescreen Hack
-- fix by Kozarovv
-- emu used=jakx v2


apiRequest(0.1)
local eeObj = getEEObject()
 
local iopObj = getIOPObject()
local emuObj = getEmuObject()
local emuObj = getEmuObject()
local eeObj  = getEEObject()
local FireWithoutWire = function()
  --16:9
  eeObj.WriteMem32(0x003cd7fc,0x3f400000)
  --Infinite Credits by InterAct
  --eeObj.WriteMem32(0x00482410,0x00090009)
  -- Fix cdvd issue which cause ieee1394 error
  iopObj.WriteMem32(0xACD40,0)
 
  -- Audio desync fix (probably useless, or even harmful on ps4 due to different "cyclerate")
  -- eeObj.WriteMem32(0x154954,0x10000009)
  emuObj.ThrottleMax()
end
emuObj.AddVsyncHook(FireWithoutWire)
</pre>


====Time Crisis 3====
local patcher = function()
'''LUA'''
<br>SLUS_206.45
<pre>
-- Time Crisis 3 SLUS_206.45
-- Widescreen Hack
-- Fix by Kozarovv
-- emu used=aofa


apiRequest(0.1)
--widescreen fix
eeObj.WriteMem32(0x002653d8,0x3c013f9d)
eeObj.WriteMem32(0x002653dc,0x44810000)
eeObj.WriteMem32(0x002653e0,0x46006302)
eeObj.WriteMem32(0x002653e4,0x3c020048)
eeObj.WriteMem32(0x002653e8,0x03e00008)
eeObj.WriteMem32(0x002653ec,0xe44c7484)


local iopObj = getIOPObject()
eeObj.WriteMem32(0x0037add4,0x0c0994f6)
local emuObj = getEmuObject()
eeObj.WriteMem32(0x003b9d14,0x0c0994f9)
local eeObj  = getEEObject()
eeObj.WriteMem32(0x003ba1b0,0x0c0994f9)
 
local FireWithoutWire = function()
eeObj.WriteMem32(0x20370314,0x10820019)--60fps
  --16:9
  eeObj.WriteMem32(0x0033976c,0x3f400000)
  --Infinite Credits by InterAct
  --eeObj.WriteMem32(0x00482410,0x00090009)
  -- Fix cdvd issue which cause ieee1394 error
  iopObj.WriteMem32(0xA0840,0)
 
  -- Audio desync fix (probably useless, or even harmful on ps4 due to different "cyclerate")
  -- eeObj.WriteMem32(0x154954,0x10000009)
  emuObj.ThrottleMax()
end
emuObj.AddVsyncHook(FireWithoutWire)
</pre>


====Tomb Raider: The Angel of Darkness====
--eeObj.WriteMem32(0x20447EDC,0x00000000)--no interlace
<br>'''SLUS20467'''
<br> Skip the first fmv to prevent freezing!
<br>'''LUA'''
<pre>
local gpr = require("ee-gpr-alias")


apiRequest(0.1)
end


local eeObj = getEEObject()
emuObj.AddVsyncHook(patcher)
local emuObj = getEmuObject()


local patcher = function()
-- Bug#9174 -
emuObj.SetGsTitleFix( "ignoreSubBuffCov", "reserved", { } )


-- Black screen fix
-- Bug#9240 (Light maps uprender)
eeObj.WriteMem32(0x00207B24, 0x0) -- 1040FFFA
-- Copy z-buffer for future use with light maps. psm = SCE_GS_PSMZ24 (49)
eeObj.WriteMem32(0x00207B4C, 0x0) -- 1040FFFA
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", {tw=9, th=9, psm=49, zmsk=1 } )


end
-- Apply light maps texMode=2 (bilinear)  psm= SCE_GS_PSMCT32 (0)
emuObj.AddVsyncHook(patcher)
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", {tw=8, th=8, psm=0, ztst=1, texMode=2 } )
</pre>
</pre>


<br>'''SLES51227'''
====Grand Theft Auto: Liberty City Stories====
<br>Skip the first fmv to prevent freezing!
SLUS_214.23
<br>'''LUA'''
<br>CLI
<pre>
<pre>
local gpr = require("ee-gpr-alias")
--gs-uprender=2x2
--gs-upscale=edgesmooth
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
--gs-h2l-list-opt=1
--gs-h2l-accurate-hash=1
--gs-adaptive-frameskip=1


apiRequest(0.1)
--vu0-mpg-cycles=600
--vu1-mpg-cycles=600


local eeObj = getEEObject()
--ee-cycle-scalar=1.3
local emuObj = getEmuObject()
</pre>


local patcher = function()
====God Hand====
'''''CLI'''''


-- Black screen fix
<pre>--vu0-no-clamping=0
eeObj.WriteMem32(0x00209D9C, 0x0) -- 1040FFFA
--vu1-no-clamping=0
eeObj.WriteMem32(0x00209DC4, 0x0) -- 1040FFFA
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1


end
#fix for graphical glitches, specially the missing ground.
emuObj.AddVsyncHook(patcher)
</pre>
</pre>


====Largo Winch====
==== God Of War ====
<br>SLES-51093
<br>'''EU'''
<br>'''''CLI'''''
'''''CLI'''''
<pre>--gs-uprender=2x2
--gs-upscale=EdgeSmooth
--host-display-mode=16:9
--cdvd-sector-read-cycles=5000
#emu used=rotk v1
</pre>
'''''LUA file'''''
<pre>
<pre>
-- Largo Winch - Empire Under Threat (E)(SLES-51093)
--vu1-di-bits=0
-- Widescreen hack by Arapapa
--vu1-mpg-cycles=800
-- Fix by Kozarovv
--vu1-jr-cache-policy=newprog
-- ported to PS4 lua by Stayhye
--vu1-jalr-cache-policy=newprog
-- emu used=rotk v1
--ee-block-validation=PageProt
--ee-cycle-scalar=1.2
--ee-hook=0x0017A2DC,AdvanceClock,,45
#Fix for upscaling glitches
--gs-kernel-cl-up="up2x2simple"
#Fix for audio re-starting
--iop-cycle-scalar=0.1
--cdvd-sector-seek-cycles=0.1
--cdvd-sector-read-cycles=4500
</pre>
<br>'''US'''
<pre>
--gs-uprender=2x2
--gs-upscale=EdgeSmooth
--gs-adaptive-frameskip=1
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
--gs-progressive=1
 
--ee-cycle-scalar=2.0
 
--vu1-mpg-cycles=2000
--vu1-di-bits=0
--vu1=trans
#Cdvd timing
--iop-cycle-scalar=0.20
--cdvd-sector-read-cycles=4000</pre>


local gpr = require("ee-gpr-alias")
'''''LUA file'''''
<pre>-- God Of War EU & US


apiRequest(0.1)
-- 01 Music sound problem: music restarts every time there are many sounds to play
-- 02 Latest emu removes a lot of game lag, anyway the game still suffer of shuttering in the next levels
-- 03 Corrupted green lines around the objects, uprendering problem
-- Slowdowns and performances patched in cli.conf file
apiRequest(2.2)


local eeObj = getEEObject()
local emuObj = getEmuObject()
local emuObj = getEmuObject()
local gsObj = getGsObject()


local WS2 = function()
-- 03 removes corrupted lines around the objects when use --gs-uprender
--16:9
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )
--Zoom
eeObj.WriteMem32(0x0028029c,0x3c013f2f) --3c013f80
--Y-Fov
eeObj.WriteMem32(0x001abc40,0x08030000)


eeObj.WriteMem32(0x000c0000,0x46070a02)
-- Disable internal field shift compensation, part of post-process removal feature.
eeObj.WriteMem32(0x000c0004,0x3c013fa6)
gsObj.SetDeinterlaceShift(0)
eeObj.WriteMem32(0x000c0008,0x4481f000)
eeObj.WriteMem32(0x000c000c,0x461e4202)
eeObj.WriteMem32(0x000c0010,0x0806af11)
----------------------------
--X-Fov (Needs render fix)
--eeObj.WriteMem32(0x001abb98,0x08030000)
--eeObj.WriteMem32(0x000c0000,0x24420050)
--eeObj.WriteMem32(0x000c0004,0x3c013f40)
--eeObj.WriteMem32(0x000c0008,0x4481f000)
--eeObj.WriteMem32(0x000c000c,0x461e4202)
--eeObj.WriteMem32(0x000c0010,0x0806aee7)
--Start microprograms manually instead of rely on timings.
--0x48c83000 >> ctc2 t0, $vi6
--eeObj.WriteMem32(0x00116d4c,0x4a0000b8)
eeObj.WriteMem32(0x00116e04,0x4a0000b8)
eeObj.WriteMem32(0x00116fe0,0x4a0000b8)
eeObj.WriteMem32(0x00117054,0x4a000938)
eeObj.WriteMem32(0x001170a4,0x4a000938)
eeObj.WriteMem32(0x001172ac,0x4a000938)
eeObj.WriteMem32(0x001172e4,0x4a000938)
eeObj.WriteMem32(0x00117470,0x4a000938)
eeObj.WriteMem32(0x001174ac,0x4a000938)
eeObj.WriteMem32(0x00117540,0x4a000938)
-- No need to loop here, just e-bit and wait for vcallms from EE.
eeObj.WriteMem32(0x00298f70,0x8000033c) -- 500607ff
eeObj.WriteMem32(0x00298f74,0x400002ff)
eeObj.WriteMem32(0x002990a0,0x8000033c)
eeObj.WriteMem32(0x002990a4,0x400002ff)
--Remove xgkick responsible for shadow packet.
eeObj.WriteMem32(0x2B1810,0x8000033c)
 
--pros. Fix bug, allow upscalling cons. No shadow.
 
emuObj.ThrottleMax()
end
 
emuObj.AddVsyncHook(WS2)
</pre>
</pre>


====Legacy of Kain - Blood Omen 2====
====God of War 2====
<br>'''SLUS-20024'''
'''''CLI'''''
<br>'''LUA'''
<pre>--gs-uprender=2x2
<pre>
--gs-upscale=edgesmooth
-- The Legacy of Kain - Blood Omen 2
--gs-adaptive-frameskip=1
-- Boot fix by Kozarovv
--ee-cycle-scalar=0.62
-- ported to PS4 lua by stayhye
--iop-cycle-scalar=0.10
-- PS3 mipmapping fix converted
--vu1-mpg-cycles=1985
-- emu used=kof2000 v2
--vu1-jr-cache-policy=newprog
--vu1-jalr-cache-policy=newprog
--cdvd-sector-read-cycles=4000
--host-audio-latency=1.6
--host-display-mode=16:9


local gpr = require("ee-gpr-alias")
*Jakx Emu used*</pre>


apiRequest(0.1)
'''''LUA File'''''
<pre>-- God of War II 
-- ported to PS4


local eeObj = getEEObject()
apiRequest(2.2)
local emuObj = getEmuObject()


--emuObj.SetFormattedCard("blood.card")
local gpr    = require("ee-gpr-alias")
local cpr    = require("ee-cpr0-alias")
local hwaddr    = require("ee-hwaddr")
 
local emuObj = getEmuObject()
local eeObj = getEEObject()
local gsObj = getGsObject()
local eeOverlay = eeObj.getOverlayObject()
local iopObj        = getIOPObject()
   
emuObj.SetDisplayAspectWide()
gsObj.SetDeinterlaceShift(1)  


local patcher = function()
local patcher = function()
eeObj.WriteMem32(0x002f4350,0x10000006)
--Widescreen
eeObj.WriteMem32(0x00312b08,0x3C013FE3)
eeObj.WriteMem32(0x00312b0c,0x34218E38)
--Black Borders Fix
eeObj.WriteMem32(0x002d443c,0x00000000)
--FMV Fix
eeObj.WriteMem32(0x002eb280,0x240575e0) --y-position
eeObj.WriteMem32(0x002eb298,0x240a1440) --y-scaling
-- Completely skip ridiculous debugger hook.
eeObj.WriteMem32(0x297DA8, 0x10000006)
eeObj.WriteMem32(0x297DA0, 0x00000000)


--skip renShadowClient::Prep
--eeObj.WriteMem32(0x001706E0,0x03e00008)
--eeObj.WriteMem32(0x001706E4,0x00000000)
--skip renPrimMaster::RenderStencilLayer
eeObj.WriteMem32(0x0016E720,0x03e00008)
eeObj.WriteMem32(0x0016E724,0x00000000)
--skip fxBloom::Client::Run
eeObj.WriteMem32(0x00126EB0,0x03e00008)
eeObj.WriteMem32(0x00126EB4,0x00000000)
--default to progressive at first run
eeObj.WriteMem32(0x0025a608,0xa04986dc)
eeObj.WriteMem32(0x001E45D4,0x24020001)
--default to ws at first run
eeObj.WriteMem32(0x001E45B4,0x24040001)
eeObj.WriteMem32(0x001E45B8,0x00000000)
eeObj.WriteMem32(0x0027894C,0x3c013fe3)
eeObj.WriteMem32(0x00278950,0x34218e39)
--allow mpeg skip by pressing x
eeObj.WriteMem32(0x001DD8C8,0x00000000)
emuObj.ThrottleMax()
end
end


emuObj.AddVsyncHook(patcher)
emuObj.AddVsyncHook(patcher)
</pre>


====Legacy of Kain: Defiance====
emuObj.SetGsTitleFix( "SetSelfRender", "reserved", { fbmask= 0x00FFFFFF , renderSelf=1 , zmsk=1 , alpha=0 , texMode=1 } )
SLUS_207.73
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1  } )
<br>LUA
<pre>apiRequest(0.1)   -- request version 0.1 API. Calling apiRequest() is mandatory.
 
-- Texture Flickering fix
 
eeInsnReplace(0x188F50, 0x10600020, 0x10000020)
</pre>
</pre>


SLES_521.50
====Gradius V====
<br>LUA
'''''CLI'''''
<pre>apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.
<pre>--vu1=jit-sync


-- Texture Flickering fix
#fix for blackscreen after PS2 Logo.
 
eeInsnReplace(0x189340, 0x10600020, 0x10000020)
</pre>
</pre>


====Legacy of Kain: Soul Reaver 2====
====Grandia III====
SLES_501.96
'''LUA'''
<br>Lua
<br>NTSC
<pre>
<pre>
apiRequest(0.1)   -- request version 0.1 API. Calling apiRequest() is mandatory.
apiRequest(0.1)


-- Turn off mipmapping in game engine. Completely fix flickering, and bad texturing. Don't require "gs-kernel-cl=mipmap"
local eeObj = getEEObject()
-- SLES_501.96 only!
local emuObj = getEmuObject()


eeInsnReplace(0x2A1F80, 0x00000001, 0x00000000)</pre>
local patcher = function()


====Mafia====
eeObj.WriteMem32(0x0014586C, 0x0)
'''''CLI'''''


<br>All versions
end
emuObj.AddVsyncHook(patcher)
</pre>


<pre>--host-display-mode=16:9
====Harry Potter and The Prisoner of Azkaban====
--framelimit-mode=normal
'''CLI'''
--cdvd-sector-read-cycles=6000
<br>Emu: Jakv2
--ee-cycle-scalar=2.1
<pre>
#Fix for graphical issues
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
#Fix for random freezing even after the EE memory patch
--vif1-instant-xfer=0
--vif1-instant-xfer=0
#Fix.</pre>
</pre>
'''''LUA file'''''
'''LUA'''
<pre>-- emu used=kinetica v2
<br>SLUS20926
<pre>
apiRequest(0.1)
 
-- Full credits to Kozarovv
local eeObj = getEEObject()
local emuObj = getEmuObject()


apiRequest(1.0)  
local patcher = function()
--clear interrupts in handler


local gpr = require("ee-gpr-alias")
eeObj.WriteMem32(0x000fff00, 0x3c191000)
eeObj.WriteMem32(0x000fff04, 0x24180c00)
eeObj.WriteMem32(0x000fff08, 0x081137e0)
eeObj.WriteMem32(0x000fff0c, 0xaf380010)
eeObj.WriteMem32(0x0016fb7c, 0x0c03ffc0)
end
emuObj.AddVsyncHook(patcher)
</pre>


local eeObj  = getEEObject()
====Hunter the Reckoning Wayward====
local emuObj = getEmuObject()
'''''CLI'''''


local patcher = function()
<br>All Versions


--avoid hang before molotov party
<pre>--gs-uprender=2x2
eeObj.WriteMem32(0x003E2BB4,0x00000000) --00000000
--gs-upscale=EdgeSmooth


--fix crash in The priest mission
--host-display-mode=16:9
eeObj.WriteMem32(0x0016F04C,0x1000000D) --1000000D


emuObj.ThrottleMax()
--vu1-no-clamping=0


end


emuObj.AddVsyncHook(patcher)
#fix for graphical glitches.
</pre>
</pre>


====Manhunt 2====
====Ice Age 2 Meltdown====
'''''CLI'''''
'''''LUA file'''''
<pre>
<br>Company logo freeze Fix
--ee-kernel-hle=1
<br>'''Use Forbidden Siren v2 Emu'''
--ee-injection-kernel=1
 
--ee-injection-title=1
<br>SLUS_213.07
--ee-block-validation=PageProt
<pre>apiRequest(0.1)
--vu1-opt-flags=2
--vu1-jr-cache-policy=newprog
--vu1-jalr-cache-policy=newprog
--vu1-mpg-cycles=900
--gs-frontend-opt-mode=2
--gs-adaptive-frameskip=1
--gs-optimize-30fps=1
--framelimit-fps=2.0
--ee-cycle-scalar=0.8
--gs-uprender=none


# Fixed framerate dip issue using Jak v2 emulator (NOTE: disabling uprender fixes fps drop to some extent and corrupted lines on shadows, however in NTSC Version, there will be a black screen glitch in cutscenes only!!).
eeInsnReplace(0x2feb80, 0x27bdff70, 0x27bdfee0)
eeInsnReplace(0x2febbc, 0x27bd0090, 0x27bd0120)
</pre>
</pre>
<br>SLES_539.84
<pre>apiRequest(0.1)


'''''LUA file'''''
eeInsnReplace(0x2ff3f0, 0x27bdff70, 0x27bdfee0)
<pre>
eeInsnReplace(0x2ff42c, 0x27bd0090, 0x27bd0120)
apiRequest(0.1)
</pre>
<br>SLPM_664.97
<pre>apiRequest(0.1)


-- Fix lags and slowdowns
eeInsnReplace(0x2e91e8, 0x27bdff70, 0x27bdfee0)
eeInsnReplace(0x2e9224, 0x27bd0090, 0x27bd0120)
</pre>


eeInsnReplace(0x370DA8, 0x00000000, 0x24020001)
====Jackie Chan Adventures====
'''''CLI'''''


# Minor framerate issue exists in NTSC version. PAL version works fine with no pain.
<br>SCES_524.12
</pre>


====Marc Ecko's Getting Up - Contents Under Pressure™ NTSC====
<pre>
'''''CLI'''''
#Fix For Jackie chan falling forever near The Ox Talisman Glitch
<pre>--gs-adaptive-frameskip=1
--fpu-accurate-addsub-range=0x22F2B0,0x22F468
--gs-kernel-cl="h2lpool"
#Fixes For Slowdowns
--gs-kernel-cl-up="h2lpool2x2"
--gs-h2l-list-opt=1
--gs-h2l-accurate-hash=1
--gs-check-trans-rejection=1
 
--vu1-mpg-cycles=400
--vu1-di-bits=0
--vu1-di-bits=0
--vu1-const-prop=1
--ee-cycle-scalar=1.2
#RECVX
</pre>


--vif1-instant-xfer=0
====Jaws Unleashed====
--vif-ignore-invalid-cmd=1
<br>'''''LUA file'''''
--vif1-ignore-cmd-ints=1
--fpu-rsqrt-fast-estimate=1
--ee-cycle-scalar=1.3
--vu1-no-clamping=0
--gs-ignore-rect-correction=1
--gs-dirty-page-policy=1


#emu used=jakx v2
</pre>
'''''LUA'''''
<pre>
<pre>
--
-- ported to PS4
apiRequest(2.2)
local gpr      = require("ee-gpr-alias")
local cpr      = require("ee-cpr0-alias")
local hwaddr    = require("ee-hwaddr")
local emuObj      = getEmuObject()
local eeObj      = getEEObject()
local gsObj      = getGsObject()
local eeOverlay    = eeObj.getOverlayObject()
local iopObj  = getIOPObject()
local thresholdArea = 0
emuObj.SetDisplayAspectWide()
gsObj.SetDeinterlaceShift(1)
--------------------------------------------------------


apiRequest(1.0)
local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()
local patcher = function()
eeObj.WriteMem32(0x0056764c,0x3c023f40)
eeObj.WriteMem32(0x006758a8,0x03e42000)
emuObj.ThrottleMax()
eeObj.WriteMem32(0x006758b8,0x800026fc)
end
end
emuObj.AddVsyncHook(patcher)
emuObj.AddVsyncHook(patcher)


local ApplyVifCycleSettings = function()
#fix for loading screen hang.
</pre>


eeObj.Vu1MpgCycles(math.floor(175))
====Juiced====
    eeObj.SetVifDataCycleScalar(1, 2.6)
'''CLI'''
eeObj.SchedulerDelayEvent("vif1.dma", 0x6500)
<br>All versions
end


ApplyVifCycleSettings()
<pre>
#Fix for graphical glitches
--gs-kernel-cl-up="up2x2simple"
#Speedhacks
--vu1-di-bits=0
--vu1-mpg-cycles=800
--ee-cycle-scalar=1.2
</pre>


local frameskip = {}
====Killer7====
'''''CLI'''''


frameskip.DeterministicMode = 0    -- set 0 for native (non-deterministic) behavior, see function frameskip.GetFramesInQueue()
<br>All versions


-- constants:
<pre>--vu0-no-clamping=0
local CLOCK_EE          = 294912000.0
--vu0-clamp-operands=1
local CLOCK_EE_60hz      = 294912000.0 / 60
--vu0-clamp-results=1
local AdvanceCycleChunkSize = 16000
--vu1-no-clamping=0
local ChunksPerFrame      = (CLOCK_EE_60hz / AdvanceCycleChunkSize)
--vu1-clamp-operands=1
local TaperHoldBaseline    = ChunksPerFrame / 30        -- frames to hold even the smallest taper values
--vu1-clamp-results=1
local TaperRatePerFrame    = ChunksPerFrame / 180        -- frames to taper away 1.0 worth of dog-ratio
local TaperHoldPerChunk    = 15.0 / ChunksPerFrame        -- hold for 15 frames per one frame of delay
local EnableTapering    = true


local MaxChunkCounter      = math.floor(ChunksPerFrame * 2.50) -- warning: jaks can't frameskip past 2.0, they clamp ratio and slow down instead.
#fix for flickering polygons.</pre>


-- globals:
====Kim Possible: What's the Switch====
local isFrameDone        = false
'''''CLI'''''
local m_counter        = 0
local m_prev_framecount    = 0
local m_taper_peak    = 0
local m_taper_hold      = 0


-- Vars For diagnostic:
<br>PAL
local d_truelog        = false
<pre>--vu1-mpg-cycles=950
local d_numframes        = 0


frameskip.GetFramesInQueue = function()
#fix lag during cutscenes
  if frameskip.DeterministicMode == 0 then
</pre>
    return gsObj.GetFramesInQueue()


  elseif frameskip.DeterministicMode == 1 then
====Klonoa 2====
    -- five regular frames, four slow frames
'''''CLI'''''
    local modulo = (eeObj.GetClock() // CLOCK_EE_60hz) % 9
    if modulo < 5 then
      return 0
    else
      return 3
    end


  elseif frameskip.DeterministicMode == 2 then
<br>All versions
    -- nice slow cyclic test!
    local modulo = (eeObj.GetClock() // CLOCK_EE_60hz) % 240
    if modulo < 200 then
      return 0
    else
      return 3
    end


  elseif frameskip.DeterministicMode == 3 then
<pre>
    -- slow cycle from 0 to 3 and back to 0, across about 10 seconds...
#Fix for Misplaced objects
    local modulo = (eeObj.GetClock() // CLOCK_EE_60hz) % 600
--fpu-no-clamping=1
    if modulo < 100 then
#Potential fix for Graphics
      return 0
--vu1-no-clamping=0
    elseif modulo < 200 then
--vu0-no-clamping=0
      return 1
    elseif modulo < 300 then
      return 2
    elseif modulo < 300 then
      return 3
    elseif modulo < 400 then
      return 2
    elseif modulo < 500 then
      return 1
    else
      return 0
    end
  end


  return gsObj.GetFramesInQueue()
#still require fix for texturing problems. Require Rogue Galaxy emu</pre>
end


frameskip.onFrameFinishedHook = function()
====Kuon====
  emuObj.CountFrameOnPS2()  -- updates FRAPS/Actual FPS reading in olympus
<br>CLI
<br>All Versions
<pre>
--vif1-ignore-cmd-ints=1
--vif-ignore-invalid-cmd=0
--vif1-instant-xfer=0
#Fix the freezing problem in the opening scene of 《阴の章》
</pre>


  -- local cyl_data, cyl_mpg = eeObj.GetVif1Cycles()
<br>NTSC Version ONLY CLI
  -- print (string.format("data=%6d  mpg=%6d", cyl_data, cyl_mpg))
<pre>
--vif1-ignore-cmd-ints=1
  local frameCount    = frameskip.GetFramesInQueue()
--vif-ignore-invalid-cmd=0
--vif1-instant-xfer=0
  m_counter  = 0
#Sugoroku Fix
  if frameCount ~= 0 or m_prev_framecount ~= 0 then
--fpu-accurate-addsub=0x104124
    -- Keep in mind here that the incurred cycle delay will be appended after the standard
</pre>
    -- VIF/VU cycle delays.  Standard delays can be read using eeObj.GetVif1Cycles() as shown
    -- in a print snippet above.
    local fcnew  = frameCount
    local fcold  = m_prev_framecount


    -- first frame being a bit slow is often a red herring, because of how the deferred
====Time Crisis 2====
    -- EE/GS pipeline works. So weight it very lightly here (if either fcold or fcnew is
'''LUA'''
    -- 0 then it'll go negative and help offset remaining 1.0)
<br>SLUS_202.19
 
<pre>
    if fcnew < 1.2 then fcnew = fcnew - 0.6 end
-- Time Crisis 2 SLUS_202.19
 
-- Widescreen Hack
    -- Delta from prev to new frame is used to indicate vectoring toward poor perf.
-- fix by Kozarovv
    -- eg. if prev was 1 and new is 3 then ramp up frameskip in a hurry (+2)
-- emu used=jakx v2


    local fcdelta = fcnew - fcold
apiRequest(0.1)
    fcdelta = (fcdelta >= 0) and (fcdelta / 2.0) or 0


    m_counter      = m_counter + (ChunksPerFrame /  7.5) * (fcnew + fcold + fcdelta)    -- baseline
local iopObj = getIOPObject()
 
local emuObj = getEmuObject()
    -- fcold and fcnew are squared and so to scale back the curve a bit we subtract some
local eeObj  = getEEObject()
    -- amount from them here:
 
    fcnew = fcnew - 0.25
    fcold = fcold - 0.40
 
    m_counter      = m_counter + (ChunksPerFrame / 15.0) * (fcold * fcold)          -- weighted prev slowness
    m_counter      = m_counter + (ChunksPerFrame /  9.0) * (fcnew * (fcnew+fcdelta))     -- weighted current slowness
   
   
    -- Boundscheck the counter.  Keep in mind that a counter delay of 2 frames will run at ~20fps.
local FireWithoutWire = function()
    m_counter  = math.floor(m_counter)
  --16:9
    if m_counter > MaxChunkCounter then m_counter = MaxChunkCounter end
  eeObj.WriteMem32(0x003cd7fc,0x3f400000)
  --Infinite Credits by InterAct
  --eeObj.WriteMem32(0x00482410,0x00090009)
   
   
    if EnableTapering and m_taper_peak < m_counter then
  -- Fix cdvd issue which cause ieee1394 error
      m_taper_hold = TaperHoldBaseline + (m_counter * TaperHoldPerChunk)
  iopObj.WriteMem32(0xACD40,0)
      m_taper_peak = m_counter
 
    end
  -- Audio desync fix (probably useless, or even harmful on ps4 due to different "cyclerate")
  end
  -- eeObj.WriteMem32(0x154954,0x10000009)
 
  -- Tapering kind of helps reduce the game's built-in jutter problem... but not really to the
  -- extent that I would like. -- jstine
 
  local m_origc = m_counter
  if m_counter < m_taper_peak then
    m_counter = math.floor(m_taper_peak)
  end
   
   
   --print (string.format("onFrameFinished! numFrames=%d,%d counter=%3d taper_hold=%5.1f taper_peak=%5.1f delayInFrames=%5.3f",
   emuObj.ThrottleMax()
  --  m_prev_framecount, frameCount, m_origc, m_taper_hold, m_taper_peak, m_counter / ChunksPerFrame
  --));
 
  if m_taper_peak > 0 then
    if m_taper_hold > 0 then
      m_taper_hold = m_taper_hold - 1
    elseif m_origc <= 25 then
      -- TODO make these constants?
      m_taper_peak = m_taper_peak - (m_taper_peak > 112 and TaperRatePerFrame or 0.75)
    end
 
    -- when taper is a large value, slide it back quickly regardless of hold state
    if m_taper_peak > 450 and m_taper_peak > m_origc then
      m_taper_peak = m_taper_peak * 0.90
    end
  end
 
  m_prev_framecount = frameCount
  isFrameDone = true    -- enables SpinWaitDelayHook
end
end
frameskip.SpinWaitDelayHook = function(hookpc, gprv, writeon)
  if not isFrameDone then
    return
  end
  local numFrames = frameskip.GetFramesInQueue()
  local isSkipping = false
   
   
  --local numFrames = frameskip.GetFramesInQueue()
emuObj.AddVsyncHook(FireWithoutWire)
  --print (string.format("HOOKED @ 0x%02x - counter=%d numFrames=%d", hookpc, m_counter, numFrames))
</pre>
  if m_counter > 0 then
    --if not d_truelog then
    --  print ( string.format("HOOKED! - numFrames=%d", numFrames))
    --  d_numframes = numFrames
    --end
    --d_truelog = true


    -- SetFrameSkipping call removed because it causes severe frame loss, due to internal scanout
====Time Crisis 3====
    -- not aligning to when this hook is invoked. The call was only implemented in order to solve
'''LUA'''
    -- interlace jitter problems on Jak TPL anyway, and isn't needed here... --jstine
<br>SLUS_206.45
    --gsObj.SetFrameSkipping(true)
<pre>
-- Time Crisis 3 SLUS_206.45
-- Widescreen Hack
-- Fix by Kozarovv
-- emu used=aofa


    isSkipping = true
apiRequest(0.1)
  end
  if isSkipping then
    --local v0 = eeObj.GetGpr(gprv)
    eeObj.SetGpr(gprv, writeon)
    eeObj.AdvanceClock(AdvanceCycleChunkSize)
    m_counter = m_counter - 1
    -- print ( string.format("SKIPP! - numFrames=%d", numFrames))
  else
    isFrameDone = false
    --gsObj.SetFrameSkipping(false)
    m_counter = 0


    --if d_truelog then
local iopObj = getIOPObject()
    --  print "BUSY ENDED, RESUMIMG..."
local emuObj = getEmuObject()
    --end
local eeObj  = getEEObject()
    --d_truelog = false
   end
local FireWithoutWire = function()
  --16:9
  eeObj.WriteMem32(0x0033976c,0x3f400000)
  --Infinite Credits by InterAct
  --eeObj.WriteMem32(0x00482410,0x00090009)
   -- Fix cdvd issue which cause ieee1394 error
  iopObj.WriteMem32(0xA0840,0)
 
  -- Audio desync fix (probably useless, or even harmful on ps4 due to different "cyclerate")
  -- eeObj.WriteMem32(0x154954,0x10000009)
   emuObj.ThrottleMax()
end
emuObj.AddVsyncHook(FireWithoutWire)
</pre>


  --if d_numframes ~= numFrames then
====Tomb Raider: The Angel of Darkness====
  --  print ( string.format("Frame Queue Changed - numFrames=%d", numFrames))
<br>'''SLUS20467'''
  --  d_numframes = numFrames
<br> Skip the first fmv to prevent freezing!
  --end
<br>'''LUA'''
end
<pre>
local gpr = require("ee-gpr-alias")


-- Performace fix (bug #9785 )
apiRequest(0.1)
emuObj.SetGsTitleFix( "globalSet",  "reserved", { waveThreshold = 90000} )
emuObj.SetGsTitleFix( "ignoreAreaUpdate", 0, { } )
</pre>


==== Max Payne 2 ====
local eeObj = getEEObject()
local emuObj = getEmuObject()


'''''CLI'''''
local patcher = function()
<pre>
--vu0-no-clamping=0
--vu1-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1
# Fixed green, blue and red graphical issues. The game works better.
</pre>


====Metal Gear Solid 2 - Sons of Liberty====
-- Black screen fix
'''CLI'''
eeObj.WriteMem32(0x00207B24, 0x0) -- 1040FFFA
<br>All versions
eeObj.WriteMem32(0x00207B4C, 0x0) -- 1040FFFA
<br>Jakv2 used
<pre>
#Speedhacks
--vu1-di-bits=0
#Gamefixes for freeze, Not tested much but once i used it. the freezes were gone
--vif-ignore-invalid-cmd=1
--vif1-ignore-cmd-ints=1
</pre>


====Metal Gear Solid 2: Substance====
end
'''CLI'''
emuObj.AddVsyncHook(patcher)
<br>All versions
<br>Use jakv2. Untested on substance, please test it and share your result on the wiki
<pre>
#Speedhacks
--vu1-di-bits=0
--vu1-mpg-cycles=700
#Gamefixes for freeze, Not tested much but once i used it. the freezes were gone
--vif-ignore-invalid-cmd=1
--vif1-ignore-cmd-ints=1
</pre>
</pre>


====Metal Gear Solid 3 Subsistence====
<br>'''SLES51227'''
'''''CLI'''''
<br>Skip the first fmv to prevent freezing!
 
<br>'''LUA'''
<br>All versions
 
<pre>
<pre>
--ee-context-switch-cycles=2700
#Highly Overclocking the EE in order for the game to start.
--ee-cycle-scalar=0.1
#Probably an overdone command, Might not be necessary, Only overclocks iop
--iop-cycle-scalar=0.1
#Performance Boost
--vu1-mpg-cycles=700
--vu1-di-bits=0
--framelimiter=1
--framelimit-fps=15.0
--framelimit-scalar=2.1
#Star Ocean v2 Used
</pre>
'''''LUA file'''''
<br>SLUS_213.59
<pre>
-- Metal Gear Solid 3 - Subsistence (SLUS_21359)
-- Widescreen hack by No.47
-- 30 FPS/Speed Fix by applepiejr @PCSX2 Forums
-- ported to PS4 LUA by Stayhye
-- emu used=star ocean v2
local gpr = require("ee-gpr-alias")
local gpr = require("ee-gpr-alias")


apiRequest(1.3)
apiRequest(0.1)


local eeObj = getEEObject()
local eeObj = getEEObject()
Line 5,104: Line 4,993:


local patcher = function()
local patcher = function()
-- Force 30 FPS
eeObj.WriteMem32(0x001D5AD8,0x00000040) -- 40=30fps / 00=60fps / 20=15 or20fps? <camera>
eeObj.WriteMem32(0x001D6DB8,0x00000002) -- 01=60fps / 02=30fps / 3=20fps / 4=16.67fps? <cut-scenes/fmv>
eeObj.WriteMem32(0x001D6DBC,0x00000001) -- 0=double speed / 1=normal speed <gameplay>
-- 480p 512x448
eeObj.WriteMem32(0x201741F4,0x3C050000)
eeObj.WriteMem32(0x201741F8,0xFFB20020)
eeObj.WriteMem32(0x201741FC,0x3C060050)
eeObj.WriteMem32(0x20174200,0xFFB10010)
eeObj.WriteMem32(0x20174204,0x3C070001)
-- REMOVES MOST OF THEM, BUT SOME ARE NOW RED?
-- Remove Black Bars
local code_check = eeObj.ReadMem16(0x25E1CC)
if code_check == 0x0000 then
eeObj.WriteMem32(0x2025E6A4,0x00000000)
end
local code_check = eeObj.ReadMem16(0x20B3FC)
if code_check == 0x0001 then
eeObj.WriteMem32(0x2025E6A4,0x00000000)
end
local code_check = eeObj.ReadMem16(0x214D80)
if code_check == 0x0001 then
eeObj.WriteMem32(0x2025E6A4,0x00000000)
end
local code_check = eeObj.ReadMem16(0x214D70)
if code_check == 0x0001 then
eeObj.WriteMem32(0x2025E6A4,0x00000000)
end
----16:9---//Widescreen water fix
eeObj.WriteMem32(0x202050AC,0x3F400000)


local code_check = eeObj.ReadMem16(0x4CCD42)
-- Black screen fix
if code_check == 0x3F80 then
eeObj.WriteMem32(0x00209D9C, 0x0) -- 1040FFFA
eeObj.WriteMem32(0x204CCD40,0x3FAB0000)
eeObj.WriteMem32(0x00209DC4, 0x0) -- 1040FFFA
eeObj.WriteMem32(0x204CCD44,0x3F400000)
eeObj.WriteMem32(0x204CCD4C,0xBFAB0000)
end
local code_check = eeObj.ReadMem16(0x580CE2)
if code_check == 0x3F80 then
eeObj.WriteMem32(0x20580CE0,0x3FAB0000)
eeObj.WriteMem32(0x20580CE4,0x3F400000)
eeObj.WriteMem32(0x20580CEC,0xBFAB0000)
end
local code_check = eeObj.ReadMem16(0x591C72)
if code_check == 0x3F80 then
eeObj.WriteMem32(0x20591C70,0x3FAB0000)
eeObj.WriteMem32(0x20591C74,0x3F400000)
eeObj.WriteMem32(0x20591C7C,0xBFAB0000)
end
local code_check = eeObj.ReadMem16(0x599C12)
if code_check == 0x3F80 then
eeObj.WriteMem32(0x20599C10,0x3FAB0000)
eeObj.WriteMem32(0x20599C14,0x3F400000)
eeObj.WriteMem32(0x20599C1C,0xBFAB0000)
end
local code_check = eeObj.ReadMem16(0x4A14D2)
if code_check == 0x3F80 then
eeObj.WriteMem32(0x204A14D0,0x3FAB0000)
eeObj.WriteMem32(0x204A14D4,0x3F400000)
eeObj.WriteMem32(0x204A14DC,0xBFAB0000)
end
local code_check = eeObj.ReadMem16(0x557CFA)
if code_check == 0x3F80 then
eeObj.WriteMem32(0x20557CF8,0x3FAB0000)
eeObj.WriteMem32(0x20557CFC,0x3F400000)
eeObj.WriteMem32(0x20557D04,0xBFAB0000)
end
local code_check = eeObj.ReadMem16(0x4B7082)
if code_check == 0x3F80 then
eeObj.WriteMem32(0x204B7080,0x3FAB0000)
eeObj.WriteMem32(0x204B7084,0x3F400000)
eeObj.WriteMem32(0x204B708C,0xBFAB0000)
end


end
end
emuObj.AddVsyncHook(patcher)
emuObj.AddVsyncHook(patcher)
emuObj.SetDisplayAspectWide()
-- Fix shadow
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1  } )
</pre>
</pre>


<br>
====Largo Winch - Empire Under Threat====
 
<br>SLES-51093
====Metal Saga====
<br>'''''CLI'''''
All versions
<pre>--gs-uprender=2x2
<br>CLI
--gs-upscale=EdgeSmooth
<pre>--vif1-ignore-cmd-ints=1
--host-display-mode=16:9
 
--cdvd-sector-read-cycles=5000
#Fix for black-screen on SatCom/Equip menus. Game still unplayable due to immediate freeze during combat.</pre>
#emu used=rotk v1
 
====Mojib-Ribbon====
'''CLI'''
<br>Works on kof98
<pre>
--vif-ignore-invalid-cmd=1
--vif1-ignore-cmd-ints=1
--vif1-instant-xfer=0
--vu1=jit-sync
</pre>
</pre>
 
'''''LUA file'''''
====Mortal Kombat - Shaolin Monks====
'''''CLI'''''
 
<br>All versions
 
<pre>
<pre>
--gs-uprender=2x2
-- Largo Winch - Empire Under Threat (E)(SLES-51093)
--gs-upscale=edgesmooth
-- Widescreen hack by Arapapa
--gs-override-small-tri-area=1
-- Fix by Kozarovv
--vif1-instant-xfer=0
-- ported to PS4 lua by Stayhye
-- emu used=rotk v1


--ee-cycle-scalar=1.8
local gpr = require("ee-gpr-alias")
--iop-cycle-scalar=0.8


--vu1-di-bits=0
apiRequest(0.1)
--vu-t-bit=1  


#Fix for graphical glitches, menu speed and audio.</pre>
local eeObj = getEEObject()
local emuObj = getEmuObject()


'''''LUA file'''''
local WS2 = function()
<pre>
--16:9
apiRequest(2.3)
--Zoom
eeObj.WriteMem32(0x0028029c,0x3c013f2f) --3c013f80
--Y-Fov
eeObj.WriteMem32(0x001abc40,0x08030000)


local gpr  = require("ee-gpr-alias")
eeObj.WriteMem32(0x000c0000,0x46070a02)
local emuObj = getEmuObject()
eeObj.WriteMem32(0x000c0004,0x3c013fa6)
local eeObj = getEEObject()
eeObj.WriteMem32(0x000c0008,0x4481f000)
local gsObj = getGsObject()
eeObj.WriteMem32(0x000c000c,0x461e4202)
local eeOverlay  = eeObj.getOverlayObject()
eeObj.WriteMem32(0x000c0010,0x0806af11)
local iopObj        = getIOPObject()
----------------------------
--X-Fov (Needs render fix)
--eeObj.WriteMem32(0x001abb98,0x08030000)
--eeObj.WriteMem32(0x000c0000,0x24420050)
--eeObj.WriteMem32(0x000c0004,0x3c013f40)
--eeObj.WriteMem32(0x000c0008,0x4481f000)
--eeObj.WriteMem32(0x000c000c,0x461e4202)
--eeObj.WriteMem32(0x000c0010,0x0806aee7)
--Start microprograms manually instead of rely on timings.
--0x48c83000 >> ctc2 t0, $vi6
--eeObj.WriteMem32(0x00116d4c,0x4a0000b8)
eeObj.WriteMem32(0x00116e04,0x4a0000b8)
eeObj.WriteMem32(0x00116fe0,0x4a0000b8)
eeObj.WriteMem32(0x00117054,0x4a000938)
eeObj.WriteMem32(0x001170a4,0x4a000938)
eeObj.WriteMem32(0x001172ac,0x4a000938)
eeObj.WriteMem32(0x001172e4,0x4a000938)
eeObj.WriteMem32(0x00117470,0x4a000938)
eeObj.WriteMem32(0x001174ac,0x4a000938)
eeObj.WriteMem32(0x00117540,0x4a000938)
-- No need to loop here, just e-bit and wait for vcallms from EE.
eeObj.WriteMem32(0x00298f70,0x8000033c) -- 500607ff
eeObj.WriteMem32(0x00298f74,0x400002ff)
eeObj.WriteMem32(0x002990a0,0x8000033c)
eeObj.WriteMem32(0x002990a4,0x400002ff)
--Remove xgkick responsible for shadow packet.
eeObj.WriteMem32(0x2B1810,0x8000033c)


local thresholdArea = 600
--pros. Fix bug, allow upscalling cons. No shadow.


emuObj.SetDisplayAspectWide()
emuObj.ThrottleMax()
gsObj.SetDeinterlaceShift(1)
end


-- Small triangle rejection. Works in conjunction with CLI setting  --gs-override-small-tri-area=1
emuObj.AddVsyncHook(WS2)
-- keep default area for texture 256x256 ( no blend)  
</pre>
emuObj.SetGsTitleFix( "setRejectionArea", 500,{twIsNot=8, thIsNot=8 } )


</pre>


====Midnight Club 3: DUB Edition / Remix====
====The Legacy of Kain - Blood Omen 2====  
'''CLI'''
'''LUA'''
<br>All versions
<br>Note: VU1 clamping will cause the cars to not load properly, please don't use it on this game.
<pre>
<pre>
#Speedhacks
-- Boot fix by Kozarovv                          --
--ee-cycle-scalar=1.2
-- ported to PS4 lua by JSimesen                  --
--vu1-mpg-cycles=350
-- PS3 mipmapping fix converted                  --
--vu1-injection=1
-- Specal Thanks to: Kozarovv, Stayhye, Scalerize --
--vu1-di-bits=0
-- emu used=KOF2000                              --
--vu1-const-prop=1
                                                                                           
</pre>
apiRequest(1.0)                                 


====MTV's Celebrity Deathmatch====
local eeObj = getEEObject()
'''''CLI'''''
local emuObj = getEmuObject()


<br>All versions
local CheckInputs = function()


<pre>
local pad_bits = emuObj.GetPad()
#Disables MTVU
--vu1=jit-sync


#Fix for black-screen after ps2 logo.</pre>
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


====Need for Speed Carbon====
if (R2 ~= 0 and UP ~= 0) then
'''''CLI'''''


<br>SLES_543.22
emuObj.SetFormattedCard("blood.card")
end


<pre> 
end
#Fix loading freeze
--fpu-accurate-range=0x162800,0x162900
#Speedhacks
--ee-cycle-scalar=1.35
--vu1-mpg-cycles=900
--vu1-const-prop=1
--vu1-di-bits=0


</pre>
emuObj.AddVsyncHook(CheckInputs)


====Need for Speed Underground 2====
emuObj.SetDisplayAspectWide()
'''''LUA'''''


<br>SLUS-21065


<pre>apiRequest(1.0)
local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()
local patcher = function()
eeObj.WriteMem32(0x001D77C8,0x100000B4)
end
emuObj.AddVsyncHook(patcher)


--Speed Fix</pre>
eeObj.WriteMem32(0x002f4350,0x10000006)
 
-- No Widescreen
-- eeObj.WriteMem32(0x00312b08,0x3C013FE3)
-- eeObj.WriteMem32(0x00312b0c,0x34218E38)


====NBA Street Vol.2====
-- No Black Borders Fix
'''''CLI'''''
-- eeObj.WriteMem32(0x002d443c,0x00000000) -- causes kain to not re-appear after dying/loading


<br>All versions
-- No Fix FMV
-- eeObj.WriteMem32(0x002eb280,0x240575e0) --y-position
-- eeObj.WriteMem32(0x002eb298,0x240a1440) --y-scaling


<pre>
end
#Fix for Graphical glitches
--vu1-no-clamping=0
#Jakv2 emu Used</pre>


====Okami====
emuObj.AddVsyncHook(patcher)
'''''CLI'''''


<br>All versions
local fix = function()


<pre>
-- Completely skip ridiculous debugger hook.
--gs-use-mipmap=1
eeObj.WriteMem32(0x297DA8, 0x10000006)
--gs-force-bilinear=1
eeObj.WriteMem32(0x297DA0, 0x00000000)
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--vu0-no-clamping=0
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-clamp-results=1
--cop2-clamp-results=1
--cop2-no-clamping=0
#Fixes for slowdowns
--vu1-const-prop=1
--vu1-di-bits=0
--ee-cycle-scalar=1.2
--vu1-injection=1
#RECVX EMU Fixes Crash Near Orochi boss fight</pre>


'''''LUA file'''''
end
<br>All Versions
<pre>
apiRequest(0.4)


local emuObj = getEmuObject()
emuObj.AddEntryPointHook(fix)


emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )</pre>
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", {psm=0} )
emuObj.SetGsTitleFix( "fetchFromCurrBuff", "reserved", {psm=0} )
</pre>


====Oni====
====Legacy of Kain: Defiance====
'''''LUA'''''
SLUS_207.73
<br>LUA
<pre>apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.


<br>SLES_501.34
-- Texture Flickering fix
<br>SLES_501.76
<br>SLES_501.77
<br>SLES_501.78
<br>SLES_501.79


<pre>apiRequest(0.1)
eeInsnReplace(0x188F50, 0x10600020, 0x10000020)
</pre>


-- Fix for hang at loading screen
SLES_521.50
<br>LUA
<pre>apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.


eeInsnReplace(0x1CEF7C, 0x4100FFFF, 0x00000000)</pre>
-- Texture Flickering fix
'''''LUA'''''


<br>SLUS_200.64
eeInsnReplace(0x189340, 0x10600020, 0x10000020)
</pre>


<pre>apiRequest(0.1)
====Legacy of Kain: Soul Reaver 2====
SLES_501.96
<br>Lua
<pre>
apiRequest(0.1)   -- request version 0.1 API. Calling apiRequest() is mandatory.


-- Fix for hang at loading screen
-- Turn off mipmapping in game engine. Completely fix flickering, and bad texturing. Don't require "gs-kernel-cl=mipmap"
-- SLES_501.96 only!


eeInsnReplace(0x1CF3CC, 0x4100FFFF, 0x00000000)</pre>
eeInsnReplace(0x2A1F80, 0x00000001, 0x00000000)</pre>


====Pac Man World 3====
====Mafia====
'''''CLI'''''
'''''CLI'''''
<br>SLES-53959
<pre>
--gs-uprender=2x2
--gs-upscale=edgesmooth
--cdvd-sector-read-cycles=2000
--host-display-mode=16:9
#Fix for fmvs showing black screen with subtitles
--fpu-accurate-range=0x3f3068,0x3f32bc


#emu used=fatal fury battle archives vol2
<br>All versions
</pre>
 
'''''LUA'''''
<pre>--host-display-mode=16:9
<br>SLES-53959
--framelimit-mode=normal
<pre>
--cdvd-sector-read-cycles=6000
-- Pac-Man World 3 (PAL-M5)(SLES-53959)
--ee-cycle-scalar=2.1
-- Widescreen Hack by ICUP321
--vif1-instant-xfer=0
-- emu used=fatal fury battle archives vol2
#Fix.</pre>
-- Ported to ps4 by Stayhye
'''''LUA file'''''
 
SLUS-20671 (NTSC)
<pre>-- emu used=kinetica v2
 
apiRequest(1.0) 
 
local gpr = require("ee-gpr-alias")
local gpr = require("ee-gpr-alias")


apiRequest(0.1)
local eeObj = getEEObject()
 
local eeObj = getEEObject()
local emuObj = getEmuObject()
local emuObj = getEmuObject()


local patcher = function()
local patcher = function()
--Widescreen hack 16:9
 
eeObj.WriteMem32(0x003f30c4,0x3c013f40)
-- Widescreen + Render fix
eeObj.WriteMem32(0x003f30c8,0x4481f000)
eeObj.WriteMem32(0x20FF8D60,0x3f3fffff)
eeObj.WriteMem32(0x003f30d0,0x461eb582)
 
--Render fix
--Rendering distance (Optional)
eeObj.WriteMem32(0x00439184,0x3c013f2b)
--eeObj.WriteMem32(0x20FF8DB8,0x44000000)
 
--avoid hang before molotov party
eeObj.WriteMem32(0x003E2BB4,0x00000000) --00000000
 
--fix crash in The priest mission
eeObj.WriteMem32(0x0016F04C,0x1000000D) --1000000D


emuObj.ThrottleMax()
emuObj.ThrottleMax()
end
end


Line 5,411: Line 5,229:
</pre>
</pre>


====Pac-Man World Rally====
====Manhunt 2====
<br>SLUS-21328
'''''CLI'''''
<br>CLI
<pre>
<pre>
--vu1-no-clamping=1
--ee-kernel-hle=1
--vu0-no-clamping=1
--ee-injection-kernel=1
--ee-injection-title=1
--ee-block-validation=PageProt
--vu1-opt-flags=2
--vu1-jr-cache-policy=newprog
--vu1-jalr-cache-policy=newprog
--vu1-mpg-cycles=900
--gs-frontend-opt-mode=2
--gs-adaptive-frameskip=1
--gs-optimize-30fps=1
--framelimit-fps=2.0
--ee-cycle-scalar=0.8
--gs-uprender=none
 
# Fixed framerate dip issue using Jak v2 emulator (NOTE: disabling uprender fixes fps drop to some extent and corrupted lines on shadows, however in NTSC Version, there will be a black screen glitch in cutscenes only!!).
</pre>
</pre>
SLUS-21328
 
<br>LUA
'''''LUA file'''''
<pre>
<pre>
local gpr = require("ee-gpr-alias")
apiRequest(0.1)
apiRequest(0.1)


local eeObj = getEEObject()
-- Fix lags and slowdowns
local emuObj = getEmuObject()


local patcher = function()
eeInsnReplace(0x370DA8, 0x00000000, 0x24020001)
eeObj.WriteMem32(0x0016DDE4,0x4A80AADC)
eeObj.WriteMem32(0x0016DDEC,0x4B7103BC)
eeObj.WriteMem32(0x0016DDD0,0x4B00A29C)
eeObj.WriteMem32(0x0016DDD8,0x4AF103BC)


end
# Minor framerate issue exists in NTSC version. PAL version works fine with no pain.
</pre>


emuObj.AddVsyncHook(patcher)
==== Max Payne 2 ====
</pre>


====Phantasy Star Universe====
'''''CLI'''''
'''''CLI'''''
<pre>
--vu0-no-clamping=0
--vu1-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1
# Fixed green, blue and red graphical issues. The game works better.
</pre>


All Versions
====Metal Gear Solid 2 - Sons of Liberty====
'''CLI'''
<br>All versions
<br>Jakv2 used
<pre>
#Speedhacks
--vu1-di-bits=0
#Gamefixes for freeze, Not tested much but once i used it. the freezes were gone
--vif-ignore-invalid-cmd=1
--vif1-ignore-cmd-ints=1
</pre>


<pre>--gs-use-clut-merge=1
====Metal Gear Solid 2: Substance====
--gs-kernel-cl="clutmerge"
'''CLI'''
--gs-kernel-cl-up="clutmerge2x2"
<br>All versions
<br>Use jakv2. Untested.
<pre>
#Speedhacks
--vu1-di-bits=0
--vu1-mpg-cycles=700
#Gamefixes for freeze, Not tested much but once i used it. the freezes were gone
--vif-ignore-invalid-cmd=1
--vif1-ignore-cmd-ints=1
</pre>


#Fix for flickering textures and geometry</pre>
====Mojib-Ribbon====
 
'''CLI'''
====PK - Out of the Shadows====
<br>Works on kof98
<br>NTSC
<br>LUA
<pre>
<pre>
-- Disney's PK - Out of the Shadows
--vif-ignore-invalid-cmd=1
-- boot fix by kozarovv
--vif1-ignore-cmd-ints=1
-- Widescreen Hack by Arapapa
--vif1-instant-xfer=0
-- emu used=rotk v1
--vu1=jit-sync
</pre>
 
====Midnight Club 3: DUB Edition / Remix====
'''CLI'''
<br>All versions
<br>Note: VU1 clamping will cause the cars to not load properly, please don't use it on this game.
<pre>
#Speedhacks
--ee-cycle-scalar=1.2
--vu1-mpg-cycles=350
--vu1-injection=1
--vu1-di-bits=0
--vu1-const-prop=1
</pre>
 
====MTV's Celebrity Deathmatch====
'''''CLI'''''
 
<br>All versions


local gpr = require("ee-gpr-alias")
<pre>
#Disables MTVU
--vu1=jit-sync


#Fix for black-screen after ps2 logo.</pre>
====Musashi Samurai Legend====
'''LUA'''
<br>NTSC
<pre>
apiRequest(0.1)
apiRequest(0.1)


local eeObj = getEEObject()
local gpr      = require("ee-gpr-alias")
local emuObj = getEmuObject()
 
local emuObj      = getEmuObject()
local eeObj       = getEEObject()
 
local patcher = function()
eeObj.WriteMem32(0x203DD108,0x3F19999A) --3F4CCCCD


local WS2 = function()
--SPS FiX
--16:9
eeObj.WriteMem32(0x001476A4,0x10000047) --10600047
eeObj.WriteMem32(0x003324b0,0xbf400000) --0x3f800000
eeObj.WriteMem32(0x002E8D78,0x8000033C) --80005EFC
--0x48c83000 >> ctc2 t0, $vi6
end
eeObj.WriteMem32(0x001dfa8c,0x4a0000b8)
 
eeObj.WriteMem32(0x001dfc24,0x4a0000b8)
emuObj.AddVsyncHook(patcher)
eeObj.WriteMem32(0x001dfcac,0x4a0000b8)
</pre>
eeObj.WriteMem32(0x001dfd00,0x4a000938)
eeObj.WriteMem32(0x001dffdc,0x4a000938)
eeObj.WriteMem32(0x001e003c,0x4a000938)
eeObj.WriteMem32(0x001e022c,0x4a000938)
eeObj.WriteMem32(0x001e028c,0x4a000938)
eeObj.WriteMem32(0x001e0348,0x4a000938)
-- No need to loop here, just e-bit and wait for vcallms from EE.
eeObj.WriteMem32(0x00324a90,0x8000033c) -- 500607ff
eeObj.WriteMem32(0x00324a94,0x400002ff)
eeObj.WriteMem32(0x00324bc0,0x8000033c)
eeObj.WriteMem32(0x00324bc4,0x400002ff)
-- skip videos
--eeObj.WriteMem32(0x0010ae80,0x24020001)


emuObj.ThrottleMax()
====Need for Speed Carbon====
end
'''''CLI'''''


emuObj.AddVsyncHook(WS2)
<br>SLES_543.22


-- Fix vertical lines
<pre> 
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1  } )
#Fix loading freeze
</pre>
--fpu-accurate-range=0x162800,0x162900


====Powerpuff Girls - Relish Rampage====
--ee-cycle-scalar=1.35
<br>All versions
--vu1-mpg-cycles=900
<br>CLI
--vu1-const-prop=1
<pre>
#Fixes hangs in certain locations like building under construction.
--fpu-no-clamping=1
</pre>
==== Prince of Persia - The Two Thrones ====
'''''CLI'''''
<br>All versions
<br>'''Jakv2'''
<pre>
#Performance Fixes
--vu1-mpg-cycles=600
--vu1-di-bits=0
--vu1-di-bits=0
#Might help with glitches
 
--fpu-no-clamping=1
#Fix For Graphical Glitches
--vu1-no-clamping=0
</pre>
</pre>
====Need for Speed Underground 2====
'''''LUA'''''
'''''LUA'''''
<pre>
apiRequest(0.4)


local emuObj = getEmuObject()
<br>SLUS-21065


emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=2 } )
<pre>apiRequest(1.0)
</pre>


==== Psi-Ops: The Mindgate Conspiracy ====
local eeObj = getEEObject()
local emuObj = getEmuObject()


local patcher = function()
--Speed Fix
eeObj.WriteMem32(0x001D77C8,0x100000B4)
end
emuObj.AddVsyncHook(patcher)
</pre>
====NBA Street Vol.2====
'''''CLI'''''
'''''CLI'''''
<br>All versions
<pre>
<pre>
--ee-cycle-scalar=1.6
#Fix for Graphical glitches
--vu1-mpg-cycles=1000
# Fixed low framerate. Jakv2
</pre>
==== Ratatouille ====
<br>SLUS_215.41
<pre>
#Graphics fix, game doesn't like upscaling.
--gs-kernel-cl-up="up2x2simple"
#Clamping
--vu1-no-clamping=0
--vu1-no-clamping=0
#Speedhacks
#Jakv2 emu Used</pre>
--ee-hook=0x004E3560,AdvanceClock,,200
 
--vu1-di-bits=0
====Okami====
--ee-cycle-scalar=1.2
'''''CLI'''''
--vu1-mpg-cycles=400
</pre>


====Ratchet and clank size matters====
'''CLI'''
<br>All versions
<br>All versions
<pre>
#Fix for audio looping at first level
--iop-cycle-scalar=0.1
--cdvd-sector-read-cycles=14000
</pre>


==== Rayman 3: Hoodlum havoc====
<br>'''CLI'''
<br>'''SLUS_206.01'''
<br>Note: Use Kof2000 to prevent missing 3d models
<pre>
<pre>
#Gamefix, change 1000 into 500 if you encounter gfx bugs
--gs-use-mipmap=1
--ee-hook=0x0028A578,AdvanceClock,,1000
--gs-force-bilinear=1
#Necessary Clamping
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--vu0-no-clamping=0
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-no-clamping=0
--vu0-no-clamping=0
--vu1-clamp-results=1
#Optional Clamping
--cop2-clamp-results=1
--fpu-no-clamping=0
--cop2-no-clamping=0
#Speedup
#Fixes for slowdowns
--vu1-const-prop=1
--vu1-di-bits=0
--vu1-di-bits=0
#underclocking the animation offsets
--ee-cycle-scalar=1.2
--ee-hook=0x0028A808,AdvanceClock,,500
--vu1-injection=1
--ee-hook=0x0028A574,AdvanceClock,,500
#RECVX EMU Fixes Crash Near Orochi boss fight</pre>
--ee-hook=0x0028A4F4,AdvanceClock,,500
 
--ee-hook=0x0028A4E4,AdvanceClock,,500
'''''LUA file'''''
--ee-hook=0x0028A6EC,AdvanceClock,,500
<br>All Versions
--ee-hook=0x0028A460,AdvanceClock,,500
--ee-hook=0x0028A278,AdvanceClock,,500
--ee-hook=0x0028A410,AdvanceClock,,500
--ee-hook=0x0028A288,AdvanceClock,,500
--ee-hook=0x0028A294,AdvanceClock,,500
--ee-hook=0x0028A4A0,AdvanceClock,,500
--ee-hook=0x0028A36C,AdvanceClock,,500
--ee-hook=0x0028A6BC,AdvanceClock,,500
--ee-hook=0x0028A488,AdvanceClock,,500
--ee-hook=0x0028A65C,AdvanceClock,,500
--ee-hook=0x0028A68C,AdvanceClock,,500
--ee-hook=0x0028A6D4,AdvanceClock,,500
--ee-hook=0x0028A6A4,AdvanceClock,,500
--ee-hook=0x0028A5D4,AdvanceClock,,500
</pre><br>'''LUA'''
<pre>
<pre>
-- Rayman 3 Hoodlum Havoc (NTSC)
apiRequest(0.4)
-- emu used=KOF 2000


apiRequest(1.0)  
local emuObj = getEmuObject()


local gpr = require("ee-gpr-alias")
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )</pre>


local eeObj = getEEObject()
====Oni====
local emuObj = getEmuObject()
'''''LUA'''''


-- Fix for thin vertical lines that separate screen picture, misallignment/tearing of screen during upscaling
<br>SLES_501.34
-- psm= SCE_GS_PSMCT32 (0)
<br>SLES_501.76
emuObj.SetGsTitleFix( "forceSimpleFetch",  "reserved", {psm=0} )
<br>SLES_501.77
emuObj.SetGsTitleFix( "fetchFromCurrBuff", "reserved", {psm=0} )
<br>SLES_501.78
<br>SLES_501.79


local patcher = function()
<pre>apiRequest(0.1)


--Max Score/Unlock Bonuses
-- Fix for hang at loading screen
eeObj.WriteMem32(0x211E7744,0x000F423F)
 
eeInsnReplace(0x1CEF7C, 0x4100FFFF, 0x00000000)</pre>
'''''LUA'''''
 
<br>SLUS_200.64
 
<pre>apiRequest(0.1)
 
-- Fix for hang at loading screen


end
eeInsnReplace(0x1CF3CC, 0x4100FFFF, 0x00000000)</pre>
 
====Pac Man World 3====
'''''CLI'''''
<br>SLES-53959
<pre>
--gs-uprender=2x2
--gs-upscale=edgesmooth
--cdvd-sector-read-cycles=2000
--host-display-mode=16:9
#Fix for fmvs showing black screen with subtitles
--fpu-accurate-range=0x3f3068,0x3f32bc


emuObj.AddVsyncHook(patcher)
#emu used=fatal fury battle archives vol2
</pre>
</pre>
<br>'''SLES-51222'''
'''''LUA'''''
<br>'''CLI'''
<br>SLES-53959
<pre>
<pre>
--gs-kernel-cl-up="up2x2skipinterp"
-- Pac-Man World 3 (PAL-M5)(SLES-53959)
-- Widescreen Hack by ICUP321
-- emu used=fatal fury battle archives vol2
-- Ported to ps4 by Stayhye
local gpr = require("ee-gpr-alias")


--vu0-no-clamping=0
apiRequest(0.1)
--vu1-no-clamping=0


--ee-hook=0x0028A408,AdvanceClock,,500
local eeObj = getEEObject()
local emuObj = getEmuObject()


--ee-hook=0x0028A588,AdvanceClock,,500
local patcher = function()
--ee-hook=0x0028A584,AdvanceClock,,500
--Widescreen hack 16:9
--ee-hook=0x0028A57C,AdvanceClock,,500
eeObj.WriteMem32(0x003f30c4,0x3c013f40)
--ee-hook=0x0028A558,AdvanceClock,,500
eeObj.WriteMem32(0x003f30c8,0x4481f000)
--ee-hook=0x0028A554,AdvanceClock,,500
eeObj.WriteMem32(0x003f30d0,0x461eb582)
--ee-hook=0x0028A54C,AdvanceClock,,500
--Render fix
--ee-hook=0x0028A528,AdvanceClock,,500
eeObj.WriteMem32(0x00439184,0x3c013f2b)
--ee-hook=0x0028A524,AdvanceClock,,500
 
--ee-hook=0x0028A51C,AdvanceClock,,500
emuObj.ThrottleMax()
--ee-hook=0x0028A4F8,AdvanceClock,,500
end
--ee-hook=0x0028A4F4,AdvanceClock,,500
 
--ee-hook=0x0028A4EC,AdvanceClock,,500
emuObj.AddVsyncHook(patcher)
--ee-hook=0x0028A4A8,AdvanceClock,,500
--ee-hook=0x0028A49C,AdvanceClock,,500
--ee-hook=0x0028A494,AdvanceClock,,500
--ee-hook=0x0028A48C,AdvanceClock,,500
--ee-hook=0x0028A47C,AdvanceClock,,500
--ee-hook=0x0028A478,AdvanceClock,,500
--ee-hook=0x0028A474,AdvanceClock,,500
--ee-hook=0x0028A230,AdvanceClock,,500
--ee-hook=0x0028A228,AdvanceClock,,500
--ee-hook=0x0028A220,AdvanceClock,,500
--ee-hook=0x0028A218,AdvanceClock,,500
--ee-hook=0x0028A210,AdvanceClock,,500
--ee-hook=0x0028A20C,AdvanceClock,,500
--ee-hook=0x0028A208,AdvanceClock,,500
--ee-hook=0x0028A1FC,AdvanceClock,,500
--ee-hook=0x0028A194,AdvanceClock,,500
--ee-hook=0x0028A160,AdvanceClock,,500
--ee-hook=0x0028A130,AdvanceClock,,500
--ee-hook=0x0028A124,AdvanceClock,,500
--ee-hook=0x0028A120,AdvanceClock,,500
--ee-hook=0x0028A118,AdvanceClock,,500
--ee-hook=0x0028A108,AdvanceClock,,500
--ee-hook=0x0028A0AC,AdvanceClock,,500
--ee-hook=0x0028A098,AdvanceClock,,500
--ee-hook=0x0028A084,AdvanceClock,,500
--ee-hook=0x0028A080,AdvanceClock,,500
--ee-hook=0x0028A078,AdvanceClock,,500
--ee-hook=0x00289F6C,AdvanceClock,,500
--ee-hook=0x00289F68,AdvanceClock,,500
--ee-hook=0x00289F64,AdvanceClock,,500
--ee-hook=0x00289F54,AdvanceClock,,500
--ee-hook=0x00289F4C,AdvanceClock,,500
--ee-hook=0x00289F30,AdvanceClock,,500
</pre>
</pre>


====Rayman M (Arena)====
====Pac-Man World Rally====
<br>'''SLES-50457'''
<br>SLUS-21328
<br>'''CLI'''
<br>CLI
<pre>
<pre>
--vu1-no-clamping=0
--vu1-no-clamping=1
--vu0-no-clamping=0
--vu0-no-clamping=1
--vif1-instant-xfer=0
--mtap1=always
</pre>
</pre>
<br>'''LUA'''
SLUS-21328
<br>Pal
<br>LUA
<pre>
<pre>
-- Rayman M (SLES-50457)
-- Fix by Kozarovv
-- ported to PS4 lua by Stayhye
-- emu used=rotk v1
--[[ useful information
This fix should work for other games using this engine.  Like Largo Winch, and Disney's PK - Out of the Shadows.
....and what's more important that patch is by kozarovv
--]]
local gpr = require("ee-gpr-alias")
local gpr = require("ee-gpr-alias")


Line 5,704: Line 5,516:
local emuObj = getEmuObject()
local emuObj = getEmuObject()


local Fix = function()
local patcher = function()
--Start microprograms manually instead of rely on timings.
eeObj.WriteMem32(0x0016DDE4,0x4A80AADC)
eeObj.WriteMem32(0x001c997c,0x4a0000b8)
eeObj.WriteMem32(0x0016DDEC,0x4B7103BC)
eeObj.WriteMem32(0x001c9b64,0x4a0000b8)
eeObj.WriteMem32(0x0016DDD0,0x4B00A29C)
eeObj.WriteMem32(0x001c9bd4,0x4a0000b8)
eeObj.WriteMem32(0x0016DDD8,0x4AF103BC)
eeObj.WriteMem32(0x001c9c24,0x4a000938)
 
eeObj.WriteMem32(0x001c9e7c,0x4a000938)
eeObj.WriteMem32(0x001c9ec4,0x4a000938)
eeObj.WriteMem32(0x001ca044,0x4a000938)
eeObj.WriteMem32(0x001ca08c,0x4a000938)
-- No need to loop here, just e-bit and wait for vcallms from EE.
eeObj.WriteMem32(0x002fc910,0x8000033c)
eeObj.WriteMem32(0x002fc914,0x400002ff)
eeObj.WriteMem32(0x002fca40,0x8000033c)
eeObj.WriteMem32(0x002fca44,0x400002ff)
end
end


emuObj.AddVsyncHook(Fix)
emuObj.AddVsyncHook(patcher)
</pre>
</pre>
NTSC (Arena)
<pre>
-- Rayman Arena
-- fix method for game engine by kozarovv
-- ported to PS4
-- emu used=jakx v2


local gpr = require("ee-gpr-alias")
====Phantasy Star Universe====
'''''CLI'''''


apiRequest(0.1)
All Versions


local eeObj = getEEObject()
<pre>
local emuObj = getEmuObject()
#Fix for flickering textures and geometry
--gs-use-clut-merge=1
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"


local patcher = function()
--gs-adaptive-frameskip=1
--Start microprograms manually instead of rely on timings.
--cdvd-sector-read-cycles=4000
--0x48c83000 >> ctc2 t0, $vi6
--eeObj.WriteMem32(0x001de8e4,0x4a0000b8)
eeObj.WriteMem32(0x001de9b0,0x4a0000b8)
eeObj.WriteMem32(0x001deb94,0x4a0000b8)
eeObj.WriteMem32(0x001dec00,0x4a000938)
eeObj.WriteMem32(0x001dec54,0x4a000938)
eeObj.WriteMem32(0x001deea0,0x4a000938)
eeObj.WriteMem32(0x001deedc,0x4a000938)
eeObj.WriteMem32(0x001df078,0x4a000938)
eeObj.WriteMem32(0x001df0b4,0x4a000938)
eeObj.WriteMem32(0x001df154,0x4a000938)
-- No need to loop here, just e-bit and wait for vcallms from EE.
eeObj.WriteMem32(0x0031ba90,0x8000033c) -- 500607ff
eeObj.WriteMem32(0x0031ba94,0x400002ff)
eeObj.WriteMem32(0x0031bbc0,0x8000033c)
eeObj.WriteMem32(0x0031bbc4,0x400002ff)


#fix for Enemies dont move bug
--fpu-accurate-mul-fast=1
--fpu-accurate-range=0x48cce0,0x49cce0


emuObj.ThrottleMax()
#emu used=jakx v2
end
 
emuObj.AddVsyncHook(patcher)
</pre>
</pre>


====R-Racing Revolution====
====PK - Out of the Shadows====
'''''LUA'''''
<br>NTSC
<br>LUA
<pre>
-- Disney's PK - Out of the Shadows
-- boot fix by kozarovv
-- Widescreen Hack by Arapapa
-- emu used=rotk v1


<br>SLUS_207.21
local gpr = require("ee-gpr-alias")


<pre>apiRequest(0.1)   -- request version 0.1 API. Calling apiRequest() is mandatory.
apiRequest(0.1)


-- Divide $v0 value by 8 before copying it to CMSAR0
local eeObj = getEEObject()
-- sra $v0, 3, this time we are losing one nop on cop2. Can be important.
local emuObj = getEmuObject()


eeInsnReplace(0x2DDB4C, 0x48C2D801, 0x000210C3)
local WS2 = function()
eeInsnReplace(0x2DDB50, 0x4A0002FF, 0x48C2D801)
--16:9
eeInsnReplace(0x2DDBC4, 0x48C2D801, 0x000210C3)
eeObj.WriteMem32(0x003324b0,0xbf400000) --0x3f800000
eeInsnReplace(0x2DDBC8, 0x4A0002FF, 0x48C2D801)
--0x48c83000 >> ctc2 t0, $vi6
eeInsnReplace(0x313C30, 0x48C2D801, 0x000210C3)
eeObj.WriteMem32(0x001dfa8c,0x4a0000b8)
eeInsnReplace(0x313C34, 0x4A0002FF, 0x48C2D801)
eeObj.WriteMem32(0x001dfc24,0x4a0000b8)
eeInsnReplace(0x3144FC, 0x48C2D801, 0x000210C3)
eeObj.WriteMem32(0x001dfcac,0x4a0000b8)
eeInsnReplace(0x314500, 0x4A0002FF, 0x48C2D801)
eeObj.WriteMem32(0x001dfd00,0x4a000938)
eeInsnReplace(0x314E04, 0x48C2D801, 0x000210C3)
eeObj.WriteMem32(0x001dffdc,0x4a000938)
eeInsnReplace(0x314E08, 0x4A0002FF, 0x48C2D801)
eeObj.WriteMem32(0x001e003c,0x4a000938)
eeInsnReplace(0x31570C, 0x48C2D801, 0x000210C3)
eeObj.WriteMem32(0x001e022c,0x4a000938)
eeInsnReplace(0x315710, 0x4A0002FF, 0x48C2D801)
eeObj.WriteMem32(0x001e028c,0x4a000938)
eeInsnReplace(0x315FFC, 0x48C2D801, 0x000210C3)
eeObj.WriteMem32(0x001e0348,0x4a000938)
eeInsnReplace(0x316000, 0x4A0002FF, 0x48C2D801)
-- No need to loop here, just e-bit and wait for vcallms from EE.
eeInsnReplace(0x3168EC, 0x48C2D801, 0x000210C3)
eeObj.WriteMem32(0x00324a90,0x8000033c) -- 500607ff
eeInsnReplace(0x3168F0, 0x4A0002FF, 0x48C2D801)
eeObj.WriteMem32(0x00324a94,0x400002ff)
eeInsnReplace(0x31724C, 0x48C2D801, 0x000210C3)
eeObj.WriteMem32(0x00324bc0,0x8000033c)
eeInsnReplace(0x317250, 0x4A0002FF, 0x48C2D801)
eeObj.WriteMem32(0x00324bc4,0x400002ff)
eeInsnReplace(0x317B74, 0x48C2D801, 0x000210C3)
-- skip videos
eeInsnReplace(0x317B78, 0x4A0002FF, 0x48C2D801)
--eeObj.WriteMem32(0x0010ae80,0x24020001)
eeInsnReplace(0x318430, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x318434, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x318D54, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x318D58, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x319AA0, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x319AA4, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x31A8D4, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x31A8D8, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x31B7A4, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x31B7A8, 0x4A0002FF, 0x48C2D801)


-- fix graphical issues</pre>
emuObj.ThrottleMax()
end


====Radiata Stories====
emuObj.AddVsyncHook(WS2)
'''''CLI'''''
 
-- Fix vertical lines
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1  } )
</pre>


====Powerpuff Girls - Relish Rampage====
<br>All versions
<br>All versions
<br>CLI
<pre>
#Fixes hangs in certain locations like building under construction.
--fpu-no-clamping=1
</pre>
==== Psi-Ops: The Mindgate Conspiracy ====


<pre>--vu-hack-triace=1
'''''CLI'''''
--gs-use-mipmap=1
<pre>
--gs-kernel-cl="mipmap"
--ee-cycle-scalar=1.6
--gs-kernel-cl-up="mipmap2x2"
--vu1-mpg-cycles=1000
# Fixed low framerate. Jakv2
</pre>
====Ratchet And Clank Size Matters====
'''CLI'''
<br>All versions
<pre>
#Fix for audio looping at first level
--iop-cycle-scalar=0.1
--cdvd-sector-read-cycles=14000
</pre>


#Mandatory triace fix for boot crash and fix for uncommon glitches like outlines in Jack's face during specific cutscenes.</pre>
==== Rayman 3: Hoodlum havoc====
 
'''CLI'''
====Raw Danger! / Zettai Zetsumei Toshi 2 - Itetsuita Kiokutachi====
<br>'''SLUS_206.01'''
 
<br>Note: Use Kof2000 to prevent missing 3d models
SLUS_215.01
<pre>
<br>LUA
#Gamefix, change 1000 into 500 if you encounter gfx bugs
<pre>apiRequest(0.1)
--ee-hook=0x0028A578,AdvanceClock,,1000
 
#Necessary Clamping
-- SLUS-21501 speedhack
--vu1-no-clamping=0
 
--vu0-no-clamping=0
eeInsnReplace(0x11e104, 0x0c066a5c, 0x00000000)
#Optional Clamping
eeInsnReplace(0x11e10c, 0x0c08a8ec, 0x00000000)</pre>
--fpu-no-clamping=0
 
#Speedup
SLES_545.87
--vu1-di-bits=0
<br>LUA
#underclocking the animation offsets
<pre>apiRequest(0.1)
--ee-hook=0x0028A808,AdvanceClock,,500
--ee-hook=0x0028A574,AdvanceClock,,500
--ee-hook=0x0028A4F4,AdvanceClock,,500
--ee-hook=0x0028A4E4,AdvanceClock,,500
--ee-hook=0x0028A6EC,AdvanceClock,,500
--ee-hook=0x0028A460,AdvanceClock,,500
--ee-hook=0x0028A278,AdvanceClock,,500
--ee-hook=0x0028A410,AdvanceClock,,500
--ee-hook=0x0028A288,AdvanceClock,,500
--ee-hook=0x0028A294,AdvanceClock,,500
--ee-hook=0x0028A4A0,AdvanceClock,,500
--ee-hook=0x0028A36C,AdvanceClock,,500
--ee-hook=0x0028A6BC,AdvanceClock,,500
--ee-hook=0x0028A488,AdvanceClock,,500
--ee-hook=0x0028A65C,AdvanceClock,,500
--ee-hook=0x0028A68C,AdvanceClock,,500
--ee-hook=0x0028A6D4,AdvanceClock,,500
--ee-hook=0x0028A6A4,AdvanceClock,,500
--ee-hook=0x0028A5D4,AdvanceClock,,500
</pre><br>'''LUA'''
<pre>
-- Rayman 3 Hoodlum Havoc (NTSC)
-- emu used=KOF 2000


-- SLES-54587 speedhack
apiRequest(1.0) 


eeInsnReplace(0x11e0f4, 0x0c066a40, 0x00000000)
local gpr = require("ee-gpr-alias")
eeInsnReplace(0x11e0fc, 0x0c08a8d0, 0x00000000)</pre>


SLPS_256.06
local eeObj = getEEObject()
<br>LUA
local emuObj = getEmuObject()
<pre>apiRequest(0.1)


-- SLPS-25606 speedhack
-- Fix for thin vertical lines that separate screen picture, misallignment/tearing of screen during upscaling
-- psm= SCE_GS_PSMCT32 (0)
emuObj.SetGsTitleFix( "forceSimpleFetch",  "reserved", {psm=0} )
emuObj.SetGsTitleFix( "fetchFromCurrBuff", "reserved", {psm=0} )


eeInsnReplace(0x11e094, 0x0c066804, 0x00000000)
local patcher = function()
eeInsnReplace(0x11e09c, 0x0c08a654, 0x00000000)</pre>


====Rygar: The Legendary Adventure====
--Max Score/Unlock Bonuses
'''''CLI'''''
eeObj.WriteMem32(0x211E7744,0x000F423F)


<br>SLUS_204.71
end


<pre>--fpu-accurate-range=0x147CC0,0x147EA0
emuObj.AddVsyncHook(patcher)
 
#Fix for freeze after leaving the first area.</pre>
 
<br>SCAJ_200.16
 
<pre>--fpu-accurate-range=0x1485C4,0x148724
 
#Fix </pre>
 
====Samurai Shodown VI====
'''''CLI'''''
 
<br>All versions
 
<pre>--gs-upscale=point
--gs-uprender=2x2
--gs-motion-factor=25
--host-audio-latency=0.01
--gs-ignore-dirty-page-border=1
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
--gs-h2l-list-opt=1
--gs-h2l-accurate-hash=1
 
#same as Anthology, which VI is a patched-out section of; substantial slowdown during combat has been mitigated.</pre>
 
====Samurai Warriors 2 Xtreme Legends====
'''CLI'''
<br>'''Jakv2'''
<br>All versions
<pre>
#To prevent disc reset upon import game-data
--switch-disc-reset=0
#Speedhacks
--ee-cycle-scalar=1.1
--vu1-di-bits=0
#Could help with AI not being able to move in some suguroko challenges.
--fpu-no-clamping=1
</pre>
</pre>
 
<br>'''SLES-51222'''
====Scaler====
<br>'''CLI'''
<br>'''CLI'''
<br>'''JAKv2'''
<br>All Versions
<pre>
<pre>
#Upscaling fix
--gs-kernel-cl-up="up2x2skipinterp"
--gs-kernel-cl-up="up2x2simple"
#Speedhacks
--ee-cycle-scalar=1.2
--vu1-mpg-cycles=1600
--vu1-injection=1
--vu1-di-bits=0
</pre>


====Scarface====
--vu0-no-clamping=0
'''LUA'''
--vu1-no-clamping=0
<br>SLES 542.71
<pre>
-- Scarface SLES 542.71
-- speed fix by Agrippa & Kozarovv
-- graphical issues fix by kozarovv (port version NTSC)
-- ported to PS4 (port version NTSC - by Stayhye )
-- emu used=star ocean v2


apiRequest(0.1)
--ee-hook=0x0028A408,AdvanceClock,,500
local cpr      = require("ee-cpr0-alias")
local emuObj      = getEmuObject()
local eeObj      = getEEObject()


--PS3 config(speed up)
--ee-hook=0x0028A588,AdvanceClock,,500
eeInsnReplace(0x00643e70, 0xc4810020, 0x03e00008)
--ee-hook=0x0028A584,AdvanceClock,,500
eeInsnReplace(0x00643e74, 0x3c033f80, 0x00000000)
--ee-hook=0x0028A57C,AdvanceClock,,500
eeInsnReplace(0x0064300c, 0x45010012, 0x10000012)
--ee-hook=0x0028A558,AdvanceClock,,500
eeInsnReplace(0x00510290, 0x3c034320, 0x3c034220)
--ee-hook=0x0028A554,AdvanceClock,,500
eeInsnReplace(0x00510240, 0x3c033f80, 0x3c033f00)
--ee-hook=0x0028A54C,AdvanceClock,,500
--ee-hook=0x0028A528,AdvanceClock,,500
--ee-hook=0x0028A524,AdvanceClock,,500
--ee-hook=0x0028A51C,AdvanceClock,,500
--ee-hook=0x0028A4F8,AdvanceClock,,500
--ee-hook=0x0028A4F4,AdvanceClock,,500
--ee-hook=0x0028A4EC,AdvanceClock,,500
--ee-hook=0x0028A4A8,AdvanceClock,,500
--ee-hook=0x0028A49C,AdvanceClock,,500
--ee-hook=0x0028A494,AdvanceClock,,500
--ee-hook=0x0028A48C,AdvanceClock,,500
--ee-hook=0x0028A47C,AdvanceClock,,500
--ee-hook=0x0028A478,AdvanceClock,,500
--ee-hook=0x0028A474,AdvanceClock,,500
--ee-hook=0x0028A230,AdvanceClock,,500
--ee-hook=0x0028A228,AdvanceClock,,500
--ee-hook=0x0028A220,AdvanceClock,,500
--ee-hook=0x0028A218,AdvanceClock,,500
--ee-hook=0x0028A210,AdvanceClock,,500
--ee-hook=0x0028A20C,AdvanceClock,,500
--ee-hook=0x0028A208,AdvanceClock,,500
--ee-hook=0x0028A1FC,AdvanceClock,,500
--ee-hook=0x0028A194,AdvanceClock,,500
--ee-hook=0x0028A160,AdvanceClock,,500
--ee-hook=0x0028A130,AdvanceClock,,500
--ee-hook=0x0028A124,AdvanceClock,,500
--ee-hook=0x0028A120,AdvanceClock,,500
--ee-hook=0x0028A118,AdvanceClock,,500
--ee-hook=0x0028A108,AdvanceClock,,500
--ee-hook=0x0028A0AC,AdvanceClock,,500
--ee-hook=0x0028A098,AdvanceClock,,500
--ee-hook=0x0028A084,AdvanceClock,,500
--ee-hook=0x0028A080,AdvanceClock,,500
--ee-hook=0x0028A078,AdvanceClock,,500
--ee-hook=0x00289F6C,AdvanceClock,,500
--ee-hook=0x00289F68,AdvanceClock,,500
--ee-hook=0x00289F64,AdvanceClock,,500
--ee-hook=0x00289F54,AdvanceClock,,500
--ee-hook=0x00289F4C,AdvanceClock,,500
--ee-hook=0x00289F30,AdvanceClock,,500
</pre>


local gfx_fix = function()
====Rayman M (Arena)====
eeObj.WriteMem32(0x004ee128,0x10000003) --14400003
<br>'''SLES-50457'''
eeObj.WriteMem32(0x004f5224,0x00000000)  --14c00003
<br>'''CLI'''
eeObj.WriteMem32(0x004f5248,0x10000007)  --14650007
<pre>
 
--vu1-no-clamping=0
eeObj.Vu1MpgCycles(375)
--vu0-no-clamping=0
end
--vif1-instant-xfer=0
emuObj.AddVsyncHook(gfx_fix)
--mtap1=always
 
-- Uprender/Upscale fix
emuObj.SetGsTitleFix( "globalSet",  "reserved", { waveThreshold = 90000} )
emuObj.SetGsTitleFix( "ignoreAreaUpdate", 0, { } )
emuObj.SetGsTitleFix( "forceSimpleFetch",  "reserved", {psm=0} )
emuObj.SetGsTitleFix( "fetchFromCurrBuff", "reserved", {psm=0} )
</pre>
</pre>
<br>'''LUA'''
<br>Pal
<pre>
-- Rayman M (SLES-50457)
-- Fix by Kozarovv
-- ported to PS4 lua by Stayhye
-- emu used=rotk v1


====Scooby-Doo! First Frights™====
--[[ useful information
SLES_554.76 Only!
<br>CLI
<pre>--ee-hook=0x00163984,FastForwardClock
--ee-hook=0x00163998,FastForwardClock
#Fix for distorted audio</pre>


====Scooby-Doo! and the Spooky Swamp™====
This fix should work for other games using this engine.  Like Largo Winch, and Disney's PK - Out of the Shadows.
SLES_556.09 Only!
....and what's more important that patch is by kozarovv
<br>CLI
<pre>--ee-hook=0x001480F4,FastForwardClock
--ee-hook=0x00148108,FastForwardClock
#Fix for distorted audio</pre>


====SEGA Sports Tennis/ Virtua Tennis 2====
--]]
<br>SLUS-20480
<pre>
-- fix by kozarovv
-- emu used=psychonauts v2


local gpr = require("ee-gpr-alias")
local gpr = require("ee-gpr-alias")
Line 5,972: Line 5,766:
local emuObj = getEmuObject()
local emuObj = getEmuObject()


local patcher = function()
local Fix = function()
-- First unpack, then run program you silly.
--Start microprograms manually instead of rely on timings.
eeObj.WriteMem8(0x283774, 0x30)
eeObj.WriteMem32(0x001c997c,0x4a0000b8)
eeObj.WriteMem8(0x283780, 0x20)
eeObj.WriteMem32(0x001c9b64,0x4a0000b8)
end
eeObj.WriteMem32(0x001c9bd4,0x4a0000b8)
eeObj.WriteMem32(0x001c9c24,0x4a000938)
eeObj.WriteMem32(0x001c9e7c,0x4a000938)
eeObj.WriteMem32(0x001c9ec4,0x4a000938)
eeObj.WriteMem32(0x001ca044,0x4a000938)
eeObj.WriteMem32(0x001ca08c,0x4a000938)
-- No need to loop here, just e-bit and wait for vcallms from EE.
eeObj.WriteMem32(0x002fc910,0x8000033c)
eeObj.WriteMem32(0x002fc914,0x400002ff)
eeObj.WriteMem32(0x002fca40,0x8000033c)
eeObj.WriteMem32(0x002fca44,0x400002ff)
end


emuObj.AddVsyncHook(patcher)
emuObj.AddVsyncHook(Fix)
</pre>
</pre>
<br>SLES-51232
NTSC (Arena)
<pre>
<pre>
-- Rayman Arena
-- fix method for game engine by kozarovv
-- ported to PS4
-- emu used=jakx v2
local gpr = require("ee-gpr-alias")
local gpr = require("ee-gpr-alias")


Line 5,990: Line 5,800:


local patcher = function()
local patcher = function()
-- First unpack, then run program you silly.
--Start microprograms manually instead of rely on timings.
eeObj.WriteMem8(0x289914, 0x30)
--0x48c83000 >> ctc2 t0, $vi6
eeObj.WriteMem8(0x289920, 0x20)
--eeObj.WriteMem32(0x001de8e4,0x4a0000b8)
eeObj.WriteMem32(0x001de9b0,0x4a0000b8)
eeObj.WriteMem32(0x001deb94,0x4a0000b8)
eeObj.WriteMem32(0x001dec00,0x4a000938)
eeObj.WriteMem32(0x001dec54,0x4a000938)
eeObj.WriteMem32(0x001deea0,0x4a000938)
eeObj.WriteMem32(0x001deedc,0x4a000938)
eeObj.WriteMem32(0x001df078,0x4a000938)
eeObj.WriteMem32(0x001df0b4,0x4a000938)
eeObj.WriteMem32(0x001df154,0x4a000938)
-- No need to loop here, just e-bit and wait for vcallms from EE.
eeObj.WriteMem32(0x0031ba90,0x8000033c) -- 500607ff
eeObj.WriteMem32(0x0031ba94,0x400002ff)
eeObj.WriteMem32(0x0031bbc0,0x8000033c)
eeObj.WriteMem32(0x0031bbc4,0x400002ff)
 
 
emuObj.ThrottleMax()
end
end


Line 5,998: Line 5,825:
</pre>
</pre>


====Shadow of the Colossus====
====R-Racing Revolution====
'''CLI'''
'''''LUA'''''
<br>All versions
<pre>
#Speedhacks for performance
--ee-cycle-scalar=1.2
--vu1-di-bits=0
--vu1-mpg-cycles=600
#Game hates mtvu, It also hates jit-sync as it causes graphical problems
#Therefore jit is good enough to improve performance and keep graphics stable
--vu1=jit
</pre>


====Shin Megami Tensei: Persona 3 FES====
<br>SLUS_207.21


<br>'''NTSC'''
<pre>apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.
<br>'''CLI'''
<pre>
#Speedhacks
--vu1-di-bits=0
--vu1-const-prop=1
--vu1-mpg-cycles=400
#Clamping
--vu1-no-clamping=0
#Mipmap
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--gs-use-mipmap=1
#Jakv2
</pre>


====Shin Megami Tensei: Persona 4====
-- Divide $v0 value by 8 before copying it to CMSAR0
'''''CLI'''''
-- sra $v0, 3, this time we are losing one nop on cop2. Can be important.


All Versions
eeInsnReplace(0x2DDB4C, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x2DDB50, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x2DDBC4, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x2DDBC8, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x313C30, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x313C34, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x3144FC, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x314500, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x314E04, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x314E08, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x31570C, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x315710, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x315FFC, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x316000, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x3168EC, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x3168F0, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x31724C, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x317250, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x317B74, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x317B78, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x318430, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x318434, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x318D54, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x318D58, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x319AA0, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x319AA4, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x31A8D4, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x31A8D8, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x31B7A4, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x31B7A8, 0x4A0002FF, 0x48C2D801)


<pre>
-- fix graphical issues</pre>
#Graphical glitches fixes, Vu Clamp mode 2
--vu1-no-clamping=0
#Performance fixes
--vu1-const-prop=1
--vu1-di-bits=0
--ee-cycle-scalar=1.3


#Jakv2 Emu Used
====Radiata Stories====
'''''CLI'''''


#Fix for Slowdowns in Battles And flickering textures When fusing Personas</pre>
<br>All versions


<br>'''LUA'''
<pre>--vu-hack-triace=1
<br>NTSC
--gs-use-mipmap=1
<pre>
--gs-kernel-cl="mipmap"
-- Persona 4 NTSC Fix for bottom left text not appearing
--gs-kernel-cl-up="mipmap2x2"


local gpr = require("ee-gpr-alias")
#Mandatory triace fix for boot crash and fix for uncommon glitches like outlines in Jack's face during specific cutscenes.</pre>


apiRequest(0.1)
====Raw Danger! / Zettai Zetsumei Toshi 2 - Itetsuita Kiokutachi====


local eeObj = getEEObject()
SLUS_215.01
local emuObj = getEmuObject()
<br>LUA
<pre>apiRequest(0.1)


local patcher = function()
-- SLUS-21501 speedhack


eeObj.WriteMem32(0x00189c60,0x3c023f7f)
eeInsnReplace(0x11e104, 0x0c066a5c, 0x00000000)
eeInsnReplace(0x11e10c, 0x0c08a8ec, 0x00000000)</pre>


end
SLES_545.87
<br>LUA
<pre>apiRequest(0.1)


emuObj.AddVsyncHook(patcher)
-- SLES-54587 speedhack
</pre>


====Shinobido: Way of the Ninja====
eeInsnReplace(0x11e0f4, 0x0c066a40, 0x00000000)
<br>All versions
eeInsnReplace(0x11e0fc, 0x0c08a8d0, 0x00000000)</pre>
<pre>
# Fixes hang going in to the gardens.
--fpu-no-clamping=1
</pre>


====Sly Cooper 1====
SLPS_256.06
'''CLI'''
<br>LUA
<br>All versions
<pre>apiRequest(0.1)
<pre>
 
#Fix for upscaling corruptions
-- SLPS-25606 speedhack
--gs-kernel-cl-up="up2x2simple"
 
#Speedhacks
eeInsnReplace(0x11e094, 0x0c066804, 0x00000000)
--ee-cycle-scalar=1.2
eeInsnReplace(0x11e09c, 0x0c08a654, 0x00000000)</pre>
--vu1-di-bits=0
</pre>


====Second Sight====
====Rygar: The Legendary Adventure====
'''''CLI'''''
'''''CLI'''''


<br>All Versions
<br>SLUS_204.71
 
<pre>--fpu-accurate-range=0x147CC0,0x147EA0


<pre>--vu1=jit-sync
#Fix for freeze after leaving the first area.</pre>
--vif1-instant-xfer=0


#Fix for black screen after ps2 logo and graphical glitches.</pre>
<br>SCAJ_200.16


====Silent Hill 2====
<pre>--fpu-accurate-range=0x1485C4,0x148724
'''''CLI'''''
<br>(SLUS-20228)
<pre>
#Fix For Slowdowns
--vu1-mpg-cycles=1000
--vu1-di-bits=0
--vu1-const-prop=1
</pre>


'''''LUA'''''
#Fix </pre>
<br>(SLUS-20228)
<pre>apiRequest(1.0)


local eeObj = getEEObject()
====Samurai Shodown VI====
local emuObj = getEmuObject()
'''''CLI'''''
local patcher = function()


--Enable custom progressive scan mode and enhanced mode to fix double-layer screen display errors
<br>All versions
eeObj.WriteMem32(0x1A68e4,0x24050000)
eeObj.WriteMem32(0x1A68e8,0x24060050)
eeObj.WriteMem32(0x1A68ec,0x24070001)
eeObj.WriteMem32(0x2a7968,0x34030002)
eeObj.WriteMem32(0x1961f8,0x28670000)
eeObj.WriteMem32(0x27fe74,0x00000000)
eeObj.WriteMem32(0x27fac4,0x00000000)


local code_check1 = eeObj.ReadMem16(0x1221C4E)
<pre>--gs-upscale=point
if code_check1 == 0x001F then
--gs-uprender=2x2
eeObj.WriteMem8(0x1221c4e,0x1b)
--gs-motion-factor=25
eeObj.WriteMem8(0x1221c76,0x1b)
--host-audio-latency=0.01
end
--gs-ignore-dirty-page-border=1
end
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
--gs-h2l-list-opt=1
--gs-h2l-accurate-hash=1


emuObj.AddVsyncHook(patcher)
#same as Anthology, which VI is a patched-out section of; substantial slowdown during combat has been mitigated.</pre>
</pre>


====Silent Hill 2: Director's Cut====
====Samurai Warriors 2 Xtreme Legends====
<br>
'''LUA'''
'''''CLI'''''
<br>'''Jakv2'''
<br>SLES_511.56
<br>NTSC
<pre>
<pre>
#Performance boost.
apiRequest(0.1)
--ee-cycle-scalar=1.8
## Force PAL game to 30 fps with Progressive scan (but '--force-pal-60hz=1' does the audio and video unsync )
#--force-pal-60hz=1
--gs-progressive=1


## I need to test more, but it looks good.
local eeObj = getEEObject()
</pre>
local emuObj = getEmuObject()


====SNK vs Capcom: SVC Chaos====
local patcher = function()
'''''CLI'''''
--Load merge menus
eeObj.WriteMem32(0x00397E80, 0x00000001)
--Merge's Data
eeObj.WriteMem32(0x005C1E28, 0x65300000)
eeObj.WriteMem32(0x005C1E58, 0x65300000)
eeObj.WriteMem32(0x005EC270, 0x05030100)
eeObj.WriteMem32(0x005EC2A0, 0x04030100)
eeObj.WriteMem32(0x005EC2D0, 0x04030100)
eeObj.WriteMem32(0x005EC300, 0x05030100)
eeObj.WriteMem32(0x00614320, 0x05030100)
eeObj.WriteMem32(0x00614350, 0x05030100)
eeObj.WriteMem32(0x00614380, 0x05030100)
eeObj.WriteMem32(0x006143B0, 0x04030100)
eeObj.WriteMem32(0x00584DB0, 0x00000010)
eeObj.WriteMem32(0x00584DB4, 0x06010000)
eeObj.WriteMem32(0x00584DC0, 0x00000010)
eeObj.WriteMem32(0x00584DC4, 0x06010000)
eeObj.WriteMem32(0x00584DD0, 0x00000010)
eeObj.WriteMem32(0x00584DD4, 0x06010000)
eeObj.WriteMem32(0x00584DD8, 0x00000010)
eeObj.WriteMem32(0x00584DDC, 0x06010000)
eeObj.WriteMem32(0x00584DE0, 0x00000010)
eeObj.WriteMem32(0x00584DE4, 0x06010000)
eeObj.WriteMem32(0x00584DE8, 0x00000010)
eeObj.WriteMem32(0x00584DEC, 0x06010000)
eeObj.WriteMem32(0x00584DF0, 0x00000010)
eeObj.WriteMem32(0x00584DF4, 0x06010000)
eeObj.WriteMem32(0x00584E00, 0x00000010)
eeObj.WriteMem32(0x00584E04, 0x06010000)
eeObj.WriteMem32(0x00584E10, 0x00000010)
eeObj.WriteMem32(0x00584E14, 0x06010000)
eeObj.WriteMem32(0x00584E20, 0x00000010)
eeObj.WriteMem32(0x00584E24, 0x06010000)
eeObj.WriteMem32(0x00584E28, 0x00000010)
eeObj.WriteMem32(0x00584E2C, 0x06010000)
eeObj.WriteMem32(0x00584E30, 0x00000010)
eeObj.WriteMem32(0x00584E34, 0x06010000)
eeObj.WriteMem32(0x00584E38, 0x00000010)
eeObj.WriteMem32(0x00584E3C, 0x06010000)
eeObj.WriteMem32(0x00584E40, 0x00000010)
eeObj.WriteMem32(0x00584E44, 0x06010000)
eeObj.WriteMem32(0x00584E50, 0x00000010)
eeObj.WriteMem32(0x00584E54, 0x06010000)
eeObj.WriteMem32(0x00584E60, 0x00000010)
eeObj.WriteMem32(0x00584E64, 0x06010000)
eeObj.WriteMem32(0x00584E70, 0x00000010)
eeObj.WriteMem32(0x00584E74, 0x06010000)
eeObj.WriteMem32(0x00584E80, 0x00000010)
eeObj.WriteMem32(0x00584E84, 0x06010000)
eeObj.WriteMem32(0x00584E90, 0x00000010)
eeObj.WriteMem32(0x00584E94, 0x06010000)
eeObj.WriteMem32(0x00584Ea0, 0x00000010)
eeObj.WriteMem32(0x00584Ea4, 0x06010000)
eeObj.WriteMem32(0x00584Ea8, 0x00000010)
eeObj.WriteMem32(0x00584Eac, 0x06010000)
eeObj.WriteMem32(0x00584Eb0, 0x00000010)
eeObj.WriteMem32(0x00584Eb4, 0x06010000)
eeObj.WriteMem32(0x00584Eb8, 0x00000010)
eeObj.WriteMem32(0x00584Ebc, 0x06010000)
eeObj.WriteMem32(0x00584EC0, 0x00000010)
eeObj.WriteMem32(0x00584EC4, 0x06010000)
eeObj.WriteMem32(0x00584EC8, 0x00000010)
eeObj.WriteMem32(0x00584ECC, 0x06010000)
eeObj.WriteMem32(0x00584ED0, 0x00000010)
eeObj.WriteMem32(0x00584ED4, 0x06010000)
eeObj.WriteMem32(0x00584EE0, 0x00000010)
eeObj.WriteMem32(0x00584EE4, 0x06010000)
eeObj.WriteMem32(0x00584EF0, 0x00000010)
eeObj.WriteMem32(0x00584EF4, 0x06010000)
eeObj.WriteMem32(0x00584EF8, 0x00000010)
eeObj.WriteMem32(0x00584EFC, 0x06010000)
--Sugoroku glitch patch
eeObj.WriteMem32(0x00102230,0x00000000)
--No interlacing
eeObj.WriteMem32(0x00102298,0x30420000)


<br>All Versions
end
--Fix for upscaling glitches
emuObj.SetGsTitleFix( "forceSimpleFetch",  "reserved", {psm=0} )
emuObj.SetGsTitleFix( "fetchFromCurrBuff", "reserved", {psm=0} )


<pre>--gs-use-clut-merge=1
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1  } )
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"


#Fixes missing hud/UI elements.</pre>
emuObj.AddVsyncHook(patcher)
</pre>


====Soul Calibur 2====
====Scaler====
ALL
<br>'''CLI'''
<br>CLI
<br>'''JAKv2'''
<pre>--vif1-instant-xfer=0
<br>All Versions
--gs-progressive=1
<pre>
#Upscaling fix
--gs-kernel-cl-up="up2x2simple"
#Speedhacks
--vu1-jr-cache-policy=sameprog
--vu1-jalr-cache-policy=sameprog
--vu1-mpg-cycles=600
--vu1-di-bits=0
--ee-cycle-scalar=1.1
</pre>


#Fixes missing characters due to the game requiring better VIF1 sync.</pre>
<br>'''LUA'''
<br>'''JAKv2'''
<br>PAL
<pre>


====Soul Calibur 3====
apiRequest(0.1)
ALL
<br>CLI
<pre>--vif1-instant-xfer=0
--ee-cycle-scalar=1.4
--iop-cycle-scalar=2.1
--vu1-mpg-cycles=190
--framelimiter=1
--framelimit-fps=60.0
--framelimit-scalar=2
--host-vsync=1


#Fixes missing characters, corrupted graphics and speed correction. vu1-mpg-cycles=190 causes crashes on certain stages and create a soul mode.</pre>
local eeObj = getEEObject()
local emuObj = getEmuObject()


====Spider-Man 3 ====
local patcher = function()
ALL
<br>CLI
<pre>--vu0-di-bits=0
--vu1-di-bits=0


--ee-cycle-scalar=1.7
eeObj.WriteMem32(0x0021E5AC, 0x8F8288C0)
--iop-cycle-scalar=0.8
eeObj.WriteMem32(0x0021E218, 0x8F8288C0)
eeObj.WriteMem32(0x0021E598, 0x8F8288C0)
eeObj.WriteMem32(0x0021DDA4, 0x8F8288C0)
eeObj.WriteMem32(0x0021DDC8, 0x0)
eeObj.WriteMem32(0x001DDC3C, 0x0)
end
emuObj.AddVsyncHook(patcher)
</pre>


--vu1-mpg-cycles=600
====Scooby-Doo! First Frights™====
SLES_554.76 Only!
<br>CLI
<pre>--ee-hook=0x00163984,FastForwardClock
--ee-hook=0x00163998,FastForwardClock
#Fix for distorted audio</pre>


--host-audio-latency=2.21
====Scooby-Doo! and the Spooky Swamp™====
SLES_556.09 Only!
<br>CLI
<pre>--ee-hook=0x001480F4,FastForwardClock
--ee-hook=0x00148108,FastForwardClock
#Fix for distorted audio</pre>


#Fix for slowdown and micro-freezes</pre>
====SEGA Sports Tennis/ Virtua Tennis 2====
<br>SLUS-20480
<pre>
-- fix by kozarovv
-- emu used=psychonauts v2


====SpongeBob SquarePants: Battle for Bikini Bottom====
local gpr = require("ee-gpr-alias")
ALL
<br>'''''CLI'''''
<pre>
#Fix for Graphical issues
--vu1-no-clamping=0
#Rest might be unnecessary
--vu0-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1
</pre>


====Spyro: Enter The Dragonfly====
apiRequest(0.1)
<br>'''SLES-510.43'''
<br>'''CLI'''
<pre>
#underclocking these offsets for performance
--ee-hook=0x00127850,AdvanceClock,,400
--ee-hook=0x00127C00,AdvanceClock,,400
--ee-hook=0x0012E210,AdvanceClock,,400
--ee-hook=0x0012A540,AdvanceClock,,400
--ee-hook=0x0014B970,AdvanceClock,,400
--ee-hook=0x0014BFA0,AdvanceClock,,400
--ee-hook=0x001498A0,AdvanceClock,,400
--ee-hook=0x00182FA0,AdvanceClock,,400
--ee-hook=0x001831D0,AdvanceClock,,400
#Speedhack
--vu1-di-bits=0
</pre>
<br>'''All versions'''
<br>'''''CLI'''''
<pre>
#Speedhacks + Clamping
--vu1-di-bits=0
--vu1-const-prop=1
--vu1-mpg-cycles=500
--ee-cycle-scalar=1.2
--vu1-no-clamping=1
--vu0-no-clamping=1
#Jakv2 Emu Used
</pre>


<br> NTSC LUA
local eeObj = getEEObject()
<pre>
local emuObj = getEmuObject()
-- Fix For Freeze at game start


local patcher = function()
-- First unpack, then run program you silly.
eeObj.WriteMem8(0x283774, 0x30)
eeObj.WriteMem8(0x283780, 0x20)
end


emuObj.AddVsyncHook(patcher)
</pre>
<br>SLES-51232
<pre>
local gpr = require("ee-gpr-alias")
local gpr = require("ee-gpr-alias")


apiRequest(0.5)
apiRequest(0.1)
 
local eeObj = getEEObject()
local eeObj = getEEObject()
local emuObj = getEmuObject()
local emuObj = getEmuObject()
local patcher = function()
local patcher = function()
eeObj.WriteMem32(0x001E71DC,0x24020001)
-- First unpack, then run program you silly.
emuObj.ThrottleMax()
eeObj.WriteMem8(0x289914, 0x30)
eeObj.WriteMem8(0x289920, 0x20)
end
end


emuObj.AddVsyncHook(patcher)</pre>
emuObj.AddVsyncHook(patcher)
</pre>


====Spy hunter====
====Shadow of the Colossus====
'''CLI'''
<br>All versions
<br>All versions
<br>CLI
<pre>
<pre>
# Fixes loading hang.
#Speedhacks for performance
--vif1-instant-xfer=0
--ee-cycle-scalar=1.2
--vu1-di-bits=0
--vu1-mpg-cycles=600
</pre>
</pre>


====SSX====
'''LUA'''
<br>'''''CLI'''''
<br>
<br>All versions
<pre>
<pre>
--iop-cycle-scalar=1.8
-- Shadow of the Colossus
--host-audio-latency=1.1
-- ported to PS4 by Stayhye
-- emu used=kof98um
 
apiRequest(0.1)
 
local gpr      = require("ee-gpr-alias")


#Use JakX v2 emu</pre>
local emuObj      = getEmuObject()
local eeObj      = getEEObject()
local gsObj      = getGsObject()


====Star Wars - Episode 3 - Die Rache der Sith====


'''''LUA file'''''
emuObj.PadSetLightBar(0, 45,65,55)
<pre>
emuObj.SetDeinterlace(true)
-- Star Wars - Episode III - Die Rache der Sith (PAL) SLES-53157
emuObj.SetDisplayAspectWide()
-- Widescreen Hack by ElHecht
-- ported to PS4
-- emu used=Star Wars Racer's Revenge v1


apiRequest(0.4)
--stutter fix
eeObj.AddHook(0x00125838,0x00041878,function() -- dsll v1, a0, 1
        eeObj.AdvanceClock(8000)
        eeObj.Vu1MpgCycles(450)
end)      


local gpr      = require("ee-gpr-alias")
local emuObj      = getEmuObject()
local eeObj      = getEEObject()
local widescreen = function()


-- 16:9
local WS = function()
eeObj.WriteMem32(0x004dbd44,0x3c023f40)
--
eeObj.WriteMem32(0x0051bca0,0x3c013f40)
--eeObj.WriteMem32(0x0012584c,0x1000fffa)
eeObj.WriteMem32(0x0051bcac,0x4481f000)
eeObj.WriteMem32(0x0051bcf0,0x461e4a42)


emuObj.ThrottleMax()
emuObj.ThrottleMax()
end
end


emuObj.AddVsyncHook(widescreen)
emuObj.AddVsyncHook(WS)
</pre>


====Street Fighter Alpha Anthology====
emuObj.SetGsTitleFix( "globalSet",  "reserved", { workLoadThreshold = 100000} )
ALL
emuObj.SetGsTitleFix( "globalSet""reserved", { waveThreshold = 90000} )
<br>CLI
emuObj.SetGsTitleFix( "ignoreAreaUpdate", 0, { } )
<pre>
#Graphical glitches fix
--gs-motion-factor=50
--host-audio-latency=0.01
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
--gs-h2l-list-opt=1
--gs-h2l-accurate-hash=1
#Speehacks
--vu0-di-bits=0
--vu1-di-bits=0
--vu0-const-prop=1
--vu1-const-prop=1
--ee-cycle-scalar=1.5
--gs-adaptive-frameskip=1
--vu1-injection=1
</pre>
</pre>


====Steambot Chronicles====
====Shin Megami Tensei: Persona 3 FES====
'''''CLI'''''
 
<br>All Versions


<br>'''NTSC'''
<br>'''CLI'''
<pre>
<pre>
--vu1-no-clamping=0
# Misc
--gs-kernel-cl-up="up2x2skipinterp"
--host-display-mode=full
#Fix for graphical glitches.</pre>
--force-frame-blend=0
 
--gs-progressive=1
====Suikoden III====
--ee-cycle-scalar=0.62
'''''CLI'''''
--host-audio-latency=0.05
<pre>--gs-uprender=2x2
# Mipmapping
--gs-upscale=EdgeSmooth
--gs-use-mipmap=1
 
--gs-kernel-cl="mipmap"
--host-display-mode=16:9
--gs-kernel-cl-up="mipmap2x2"
 
# VU Speedhacks
--vu1-no-clamping=0
 
--vu0-const-prop=1
--vu0-const-prop=1
--vu1-const-prop=1
--vu1-const-prop=1
#emu used=psychonauts v2
--vu1-di-bits=0
</pre>
--vu0-di-bits=0
'''''LUA file'''''
--vu1-opt-vf00=2
<pre>
--vu0-opt-vf00=2
-- Suikoden III (SLUS-20387)
--vu1-mpg-cycles=1400
-- Widescreen hack by nemesis2000 (pnach by nemesis2000)
--vu-custom-min-max=0
-- emu used=psychonauts v2
# IOP Speedhacks
--iop-const-folding=All
--iop-cycle-scalar=0.1
--cdvd-sector-seek-cycles=0.1
--cdvd-sector-read-cycles=0.1
# Default Optimizations
--fpu-no-clamping=0
--fpu-clamp-operands=1
--fpu-clamp-results=1
--vu0-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1
--vu0-opt-flags=1
--vu1-opt-flags=1
--cop2-opt-flags=1
--vu1-jr-cache-policy=newprog
--vu1-jalr-cache-policy=newprog
--vu0-jr-cache-policy=newprog
--vu0-jalr-cache-policy=newprog
 
#User Emu = kof98um
</pre>
 
* Config and icons [https://www.psx-place.com/threads/research-ps2-emulator-configuration-on-ps4.16131/page-243 Download]
 
====Shin Megami Tensei: Persona 4====
'''''CLI'''''
 
All Versions
 
<pre>
#Graphical glitches fixes, Vu Clamp mode 2
--vu1-no-clamping=0
#Performance fixes
--vu1-const-prop=1
--vu1-di-bits=0
--ee-cycle-scalar=1.3
 
#Jakv2 Emu Used
 
#Fix for Slowdowns in Battles And flickering textures When fusing Personas</pre>
 
<br>'''LUA'''
<br>NTSC
<pre>
-- Persona 4 NTSC Fix for bottom left text not appearing


local gpr = require("ee-gpr-alias")
local gpr = require("ee-gpr-alias")
Line 6,361: Line 6,264:


local patcher = function()
local patcher = function()
--16:9
 
eeObj.WriteMem32(0x016c21c0,0x460d6502)
eeObj.WriteMem32(0x00189c60,0x3c023f7f)
eeObj.WriteMem32(0x016c21bc,0x460d6d42)


end
end
Line 6,369: Line 6,271:
emuObj.AddVsyncHook(patcher)
emuObj.AddVsyncHook(patcher)
</pre>
</pre>
====Sword of etheria====
 
'''CLI'''
====Shinobido: Way of the Ninja====
<br>All versions
<br>All versions
<pre>
<pre>
#Fix for game's graphics being missing And game crashing
# Fixes hang going in to the gardens.
--vu-custom-min-max=0
--fpu-no-clamping=1
#Jakv2 emu used
</pre>
</pre>


====Syberia====
====Simpsons Hit and Run====
'''CLI'''
<br>NTSC
<br>All versions
<br>'''CLI'''
<pre>
<pre>
#Fix for crash, MTVU sensitive
--Fixes the slowdowns
--vu1=jit-sync
--ee-cycle-scalar=3.5
#Speedhacks
--vu1-di-bits=0
--vu1-mpg-cycles=400
--ee-cycle-scalar=1.2
</pre>
</pre>


====Syphon Filter - The Omega Strain====
'''CLI'''
<br>All versions
<br>Note: these configs are not tested yet, they are straight from pcsx2 gameindex
<br>Jakv2 emu
<pre>
#Gfx fix ??
--gs-flush-ad-xyz=safe
--gs-kernel-cl-up="up2x2simple"
#Sps fix ??
--vu-custom-min-max=0
--vu1-no-clamping=1
--vu0-no-clamping=1
--vu-xgkick-delay=0
</pre>
'''LUA'''
'''LUA'''
<br>SCES-52033
<pre>
<pre>
apiRequest(1.0)
#Fixes the freeze on Jakv2
apiRequest(0.1)


local eeObj = getEEObject()
local eeObj = getEEObject()
local emuObj = getEmuObject()
local emuObj = getEmuObject()
local patcher = function()
local patcher = function()
 
eeObj.WriteMem32(0x0036CA5C,0x0)
-- Cop2 problems.
eeObj.WriteMem32(0x3953F8,0x48438000)
eeObj.WriteMem32(0x3735FC,0x4B06521B)
-- Pal speed fix
eeObj.WriteMem32(0x175E1C,0x24020019)
 
end
end
emuObj.AddVsyncHook(patcher)
emuObj.AddVsyncHook(patcher)
</pre>
</pre>


'''LUA'''
====Sly Cooper 1====
<br>SCUS-97264
'''CLI'''
<br>All versions
<pre>
<pre>
apiRequest(1.0)
#Fix for upscaling corruptions
--gs-kernel-cl-up="up2x2simple"
#Speedhacks
--ee-cycle-scalar=1.2
--vu1-di-bits=0
</pre>


local eeObj = getEEObject()
====Second Sight====
local emuObj = getEmuObject()
'''''CLI'''''
local patcher = function()


-- Cop2 problems.
<br>All Versions
eeObj.WriteMem32(0x3735F8,0x48438000)
eeObj.WriteMem32(0x3735FC,0x4B06521B)


end
<pre>--vu1=jit-sync
--vif1-instant-xfer=0


emuObj.AddVsyncHook(patcher)
#Fix for black screen after ps2 logo and graphical glitches.</pre>
</pre>
 
====Tales of Destiny: Directors Cut====
<br>'''SLPS-25842'''</br>


====Silent Hill 2====
'''''CLI'''''
'''''CLI'''''
 
<br>(SLUS-20228)
<pre>
<pre>
#Glitch Fix
#Fix For Slowdowns
--fpu-accurate-range=0x1C7B50,0x1C7C00
--vu1-mpg-cycles=1000
#unnecessary command
--vu1-di-bits=0
--fpu-accurate-mul-fast=1
--vu1-const-prop=1
#Performance Fix
</pre>
--ee-cycle-scalar=1.74
#Graphical Glitches fixes
--gs-use-clut-merge=1  
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"
#Fix for menu UI interlacing shake
--force-frame-blend=1</pre>


'''''LUA file'''''
'''''LUA'''''
<pre>
<br>(SLUS-20228)
-- Emu used=Jak v2
<pre>apiRequest(1.0)
-- SLPS-25842 FPUMULHACK (fix for getting stuck in the room before Irene in Helraios)
local gpr = require("ee-gpr-alias")
 
apiRequest(0.1)


local eeObj = getEEObject()
local eeObj = getEEObject()
local emuObj = getEmuObject()
local emuObj = getEmuObject()
local patcher = function()
--Enable custom progressive scan mode and enhanced mode to fix double-layer screen display errors
eeObj.WriteMem32(0x1A68e4,0x24050000)
eeObj.WriteMem32(0x1A68e8,0x24060050)
eeObj.WriteMem32(0x1A68ec,0x24070001)
eeObj.WriteMem32(0x2a7968,0x34030002)
eeObj.WriteMem32(0x1961f8,0x28670000)
eeObj.WriteMem32(0x27fe74,0x00000000)
eeObj.WriteMem32(0x27fac4,0x00000000)


local goathack = function()
local code_check1 = eeObj.ReadMem16(0x1221C4E)
local db_check = eeObj.ReadMem8(0x3EECC4)
if code_check1 == 0x001F then
if db_check == 0xDB then
eeObj.WriteMem8(0x1221c4e,0x1b)
eeObj.WriteMem8(0x3EECC4,0xDA)
eeObj.WriteMem8(0x1221c76,0x1b)
end
end
end
end


emuObj.AddVsyncHook(goathack)
emuObj.AddVsyncHook(patcher)
</pre>
</pre>


====Tales of The Abyss====
====Silent Hill 2: Director's Cut====
<br>
'''''CLI'''''
'''''CLI'''''
<br>SLES_511.56
<pre>
<pre>
#choral castle soft lock fix
#Performance boost.
--fpu-accurate-range=0x27FFFC,0x27FFFF
--ee-cycle-scalar=1.8
--fpu-accurate-range=0x2921F4,0x2921F8
## Force PAL game to 30 fps with Progressive scan (but '--force-pal-60hz=1' does the audio and video unsync )
#Seems to fix not rendering characters in cutscenes
#--force-pal-60hz=1
--vu0-no-clamping=0
--gs-progressive=1
--vu1-no-clamping=0
--cop2-no-clamping=0
</pre>
'''''LUA file'''''
<pre>
-- Tales Of The Abyss (NTSC-U) (SLUS-21386)
-- emu used=psychonauts v2


local gpr = require("ee-gpr-alias")
## I need to test more, but it looks good.
 
apiRequest(0.1)
local emuObj = getEmuObject()
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )
</pre>
</pre>


====Tekken 5====
====SNK vs Capcom: SVC Chaos====
'''CLI'''
<br>All versions
<br>Use war of the monsters v1 emu with the config.
<pre>
#Upscaling glitches fix
--gs-kernel-cl-up="up2x2simple"
#Game needs progressive scan
--gs-progressive=1
#Speedhacks
--vu1-di-bits=0
</pre>
 
====The Getaway====
'''''CLI'''''
'''''CLI'''''


<br>PAL Versions
<br>All Versions


<pre>--vu1-mpg-cycles=950
<pre>--gs-use-clut-merge=1
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"


#fix lag during cutscenes
#Fixes missing hud/UI elements.</pre>
</pre>


====The Getaway: Black Monday====
====Soul Calibur 3====
'''''CLI'''''
ALL
<br>CLI
<pre>--gs-uprender=2x2
--gs-upscale=edgesmooth
--gs-kernel-cl-up="up2x2skipinterp"


<br>SCES-52758 ONLY!
--vif1-instant-xfer=0


--ee-cycle-scalar=1.82
--ee-regalloc-preserve-scalar=LoadStore
--iop-cycle-scalar=2.10


<pre>--ee-kernel-hle=1
--vu0-mpg-cycles=1
--ee-injection-kernel=1
--vu1-mpg-cycles=1
--ee-injection-title=1
--ee-block-validation=PageProt
--ee-cycle-scalar=0.4
--vu1-opt-flags=2
--vu1-jr-cache-policy=newprog
--vu1-jalr-cache-policy=newprog
--vu1-mpg-cycles=2050
--gs-frontend-opt-mode=2
--gs-adaptive-frameskip=1
--fpu-accurate-range=0x28C154,0x28C5B0


#"fpu-accurate-range"Fixes the crash on Chapter 5 in the ambush.
#emu used=jakx v2
#Fix By Vitt0xLar
#JAK V2 emulator used.</pre>
====The Godfather====
'''CLI'''
<br>All versions
<br>SW racer revenge v1 emu used
<pre>
#Fix for upscaling graphical glitches
--gs-kernel-cl-up="up2x2simple"
#Fix for intro stutter
--iop-cycle-scalar=0.80
--cdvd-sector-read-cycles=5000
</pre>
</pre>
====The Legend of Spyro A New Beginning====
PAL only!
<br>LUA
<br>LUA
<pre>apiRequest(0.4)
<pre>-- Soul Calibur III (SLUS-21216)
-- ported to PS4 lua
-- emu used=jakx v2


-- The Legend of Spyro: A New Beginning
apiRequest(2.3)


local eeObj = getEEObject()
local gpr    = require("ee-gpr-alias")
local emuObj = getEmuObject()
local emuObj = getEmuObject()
local eeObj = getEEObject()
local gsObj = getGsObject()
 
emuObj.PadSetLightBar(0, 10,176,4)
emuObj.SetDisplayAspectWide()  


eeInsnReplace(0x1849b8, 0x44840800, 0x00000000) -- Fixes HUD and menu display.
local WS = function()
-- 16:9
eeObj.WriteMem32(0x0012a118,0x3c013f40)
eeObj.WriteMem32(0x0012a11c,0x34210000)


-- Graphic improvement: removes corrupted lines on screen with uprender enabled, for PAL version
eeObj.Vu1MpgCycles(1)
eeObj.SetVifDataCycleScalar(1, 0.80)


emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } ) --texMode=1 ?
emuObj.ThrottleMax()
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=2 } ) --texMode=2 is BILINEAR</pre>
end


====The Legend of Spyro: The Eternal Night====
emuObj.AddVsyncHook(WS)
PAL only!
</pre>
<br>LUA
<pre>apiRequest(0.4)


-- The Legend of Spyro: The Eternal Night
====Spider-Man 3 ====
 
ALL
local eeObj = getEEObject()
<br>CLI
local emuObj = getEmuObject()
<pre>--vu0-di-bits=0
--vu1-di-bits=0


eeInsnReplace(0x173c38, 0x44840800, 0x00000000) -- Fixes HUD and menu display.
--ee-cycle-scalar=1.7
--iop-cycle-scalar=0.8


--vu1-mpg-cycles=600


-- Graphic improvement: removes corrupted lines on screen with uprender enabled, for PAL version
--host-audio-latency=2.21


emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } ) --texMode=1 ?
#Fix for slowdown and micro-freezes</pre>
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=2 } ) --texMode=2 is BILINEAR</pre>


====The Operative: No One Lives Forever====
====SpongeBob SquarePants: Battle for Bikini Bottom====
'''CLI'''
<br>All versions
<pre>
#Fix for Graphical issues
--vu1-no-clamping=0
#Rest might be unnecessary
--vu0-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1
</pre>


'''''CLI'''''
====Spyro: Enter The Dragonfly====
<br>'''All versions'''
<br>'''''CLI'''''
<pre>
<pre>
 
#Speedhacks + Clamping
#Fix for "The Operative - No One Lives Forever"
--vu1-di-bits=0
 
--vu1-const-prop=1
For US version
--vu1-mpg-cycles=800
 
--ee-cycle-scalar=1.2
--fpu-accurate-addsub-range=0x104204,0x1042B8
#Jakv2 Emu Used
 
For EU version:
 
--fpu-accurate-addsub-range=0x103F28,0x104074
 
Use Jak v2 emulator
</pre>
</pre>


==== The Shield ====
====Spy hunter====
'''''CLI'''''
'''CLI'''
<br>All versions
<pre>
<pre>
--fpu-accurate-addsub-range=0x100008,0x700000
#Fixes loading hang.
--vif1-instant-xfer=0
</pre>


#Fix for game over error on level '''2354 Casitas Dr'''.
====SSX====
#JAK V2 emulator used.
<br>'''''CLI'''''
</pre>
<br>All versions
<pre>
--iop-cycle-scalar=1.8
--host-audio-latency=1.1


====The Simpsons - Hit & Run (NTSC-U)====
#Use JakX v2 emu</pre>
'''''CLI'''''


<br>All Versions
====Star Wars - Episode 3 - Die Rache der Sith====


'''''CLI file'''''
<pre>
<pre>
#Speedhacks
#for none PS4 Pro users
--ee-cycle-scalar=1.6
--ee-cycle-scalar=1.75
--vu1-mpg-cycles=1000
--iop-cycle-scalar=1.75
--vu1-mpg-cycles=1480
--vu0-mpg-cycles=1480
--vu0-di-bits=0
--vu1-di-bits=0
--vu1-di-bits=0
#Graphical fix
--gs-progressive=1


#Note that this is a very old config.
#emu used=Star Wars Racer's Revenge v1
#<use kinetica v2 emu></pre>
</pre>


==== The Suffering 2: Ties that Bind ====
'''''LUA file'''''
'''''CLI'''''
<pre>
<pre>
--ee-kernel-hle=1
-- Star Wars - Episode III - Die Rache der Sith (PAL) SLES-53157
--ee-injection-kernel=1
-- Widescreen Hack by ElHecht
--ee-injection-title=1
-- ported to PS4
--ee-cycle-scalar=1.5
-- emu used=Star Wars Racer's Revenge v1
--safe-area-min=1.0
--vu0-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1
#Lags are patched using Jak v2 emulator, still minor black patches on character models, rest works fine.
</pre>


====Timesplitters====
apiRequest(0.4)
'''''CLI'''''


<br>All Versions
local gpr      = require("ee-gpr-alias")
 
local emuObj      = getEmuObject()
<pre>
local eeObj      = getEEObject()
#Fix For game crash due to not being compatible with MTVU
local widescreen = function()
—vu1=jit-sync
</pre>


====Tomb Raider: Anniversary====
-- 16:9
'''''LUA'''''
eeObj.WriteMem32(0x004dbd44,0x3c023f40)
eeObj.WriteMem32(0x0051bca0,0x3c013f40)
eeObj.WriteMem32(0x0051bcac,0x4481f000)
eeObj.WriteMem32(0x0051bcf0,0x461e4a42)


<br>SLUS_215.55
emuObj.ThrottleMax()
end


<pre>apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.
emuObj.AddVsyncHook(widescreen)
</pre>


-- Texture Flickering fix
====Street Fighter Alpha Anthology====
ALL
<br>CLI
<pre>
#Graphical glitches fix
--gs-motion-factor=50
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
--gs-h2l-list-opt=1
--gs-h2l-accurate-hash=1
#Speehacks
--vu0-di-bits=0
--vu1-di-bits=0
--vu0-const-prop=1
--vu1-const-prop=1
--ee-cycle-scalar=1.5
--gs-adaptive-frameskip=1
--vu1-injection=1
#Misc
--host-audio-latency=0.01


eeInsnReplace(0x1297C0, 0x10600022, 0x10000022)
#PS4 Pro required for full speed
</pre>
</pre>


<br>SLES_539.08
====Steambot Chronicles====
'''''CLI'''''


<pre>apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.
<br>All Versions


-- Texture Flickering fix
eeInsnReplace(0x1273E8, 0x10600022, 0x10000022)</pre>
====Tomb Raider - Legend====
CLI
<br>All Regions
<pre>
<pre>
--gs-progressive=1
--vu1-no-clamping=0
--gs-kernel-cl-up="up2x2skipinterp"
--gs-kernel-cl-up="up2x2skipinterp"
--gs-use-mipmap=1
#Fix for graphical glitches.</pre>
--gs-kernel-cl="mipmap"
</pre>


'''SLUS_212.03'''
====Sword of etheria====
<br>LUA
'''CLI'''
<pre>apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.
<br>All versions
 
<pre>
-- Texture Flickering fix
#Fix for game's graphics being missing And game crashing
 
--vu-custom-min-max=0
eeInsnReplace(0x127390, 0x10600022, 0x10000022)
#Jakv2 emu used
</pre>
</pre>


'''SLES_546.74'''
====Syberia====
<br>LUA
'''CLI'''
<pre>apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.
<br>All versions
 
<pre>
-- Texture Flickering fix
#Fix for graphical glitches
eeInsnReplace(0x129800, 0x10600022, 0x10000022)
--vu1=jit-sync
#Speedhacks
--vu1-di-bits=0
--vu1-mpg-cycles=400
--ee-cycle-scalar=1.2
</pre>
</pre>


Additional LUA fix
====Tales of Destiny: Directors Cut====
<br>All Regions
<br>'''SLPS-25842'''</br>
<pre>
-- Fix for thin vertical lines that separate screen picture, misallignment/tearing of screen during upscaling (was used in official PSN Red Dead Revolver)
apiRequest(1.0)
local emuObj = getEmuObject()
-- psm= SCE_GS_PSMCT32 (0)
emuObj.SetGsTitleFix( "forceSimpleFetch",  "reserved", {psm=0} )
emuObj.SetGsTitleFix( "fetchFromCurrBuff", "reserved", {psm=0} )
</pre>


====Tony Hawk Pro Skater 3====
'''''CLI'''''
'''''CLI'''''


<br>All Versions
<pre>
 
#Glitch Fix
<pre>--vu0-no-clamping=0
--fpu-accurate-range=0x1C7B50,0x1C7C00
--vu1-no-clamping=0
#unnecessary command
--vu0-clamp-results=1
--fpu-accurate-mul-fast=1
--vu1-clamp-results=1
#Performance Fix
--fpu-no-clamping=0
--ee-cycle-scalar=1.74
--cop2-no-clamping=0
#Graphical Glitches fixes
--fpu-clamp-results=1
--gs-use-clut-merge=1  
--cop2-clamp-results=1
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"
#Fix for menu UI interlacing shake
--force-frame-blend=1</pre>


#SPS Fix</pre>
'''''LUA file'''''
<pre>
-- Emu used=Jak v2
-- SLPS-25842 FPUMULHACK (fix for getting stuck in the room before Irene in Helraios)
local gpr = require("ee-gpr-alias")


====Tony hawk's underground 2====
'''CLI'''
<br>SLUS20965
<br>Redfaction emu used
<pre>
#sps fix
--vu1-mpg-cycles=1
</pre>
'''LUA'''
<br>SLUS20965
<pre>
apiRequest(0.1)
apiRequest(0.1)


Line 6,761: Line 6,618:
local emuObj = getEmuObject()
local emuObj = getEmuObject()


local patcher = function()
local goathack = function()
--loop skip to prevent freezing
local db_check = eeObj.ReadMem8(0x3EECC4)
eeObj.WriteMem32(0x001958A0, 0x10000086)
if db_check == 0xDB then
--rounding to remove sps
eeObj.WriteMem8(0x3EECC4,0xDA)
eeObj.WriteMem32(0x003F0FE8, 0xD3400000)
end
--Giving it the value it wants in order to branch
eeObj.WriteMem32(0x001AF5FC, 0x24060000)
end
end
emuObj.AddVsyncHook(patcher)
 
--mtvu patch
emuObj.AddVsyncHook(goathack)
eeInsnReplace(0x00194918, 0x0, 0x0803fff0)
</pre>
eeInsnReplace(0x000fffc4, 0x0, 0x24186000)
 
eeInsnReplace(0x000fffc8, 0x0, 0x3c191200)
====Tales of The Abyss====
eeInsnReplace(0x000fffcc, 0x0, 0x37391010)
'''''CLI'''''
eeInsnReplace(0x000fffd0, 0x0, 0x2718ffff)
<pre>
eeInsnReplace(0x000fffd4, 0x0, 0x1418fffe)
--gs-uprender=2x2
eeInsnReplace(0x000fffdc, 0x0, 0x08065248)
--gs-upscale=EdgeSmooth
eeInsnReplace(0x000fffe0, 0x0, 0xaf200000)
 
--fpu-accurate-range=0x27FFFC,0x27FFFF
--fpu-accurate-range=0x2921F4,0x2921F8
 
--vu0-no-clamping=0
--vu1-no-clamping=0
--cop2-no-clamping=0
 
--host-display-mode=16:9
</pre>
</pre>
'''''LUA file'''''
<pre>
-- Tales Of The Abyss (NTSC-U) (SLUS-21386)
-- emu used=psychonauts v2


====True Crime: Streets of LA====
local gpr = require("ee-gpr-alias")
<br>cli.conf
<br>All Versions
<pre>--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
#Fix for missing enemies in the gyms</pre>
<br> cli.conf
<br>SLES_517.54 only!
<pre>--vu1-mpg-cycles=2350
--vu1-opt-flags=2
--vu1-opt-vf00=2
--gs-optimize-30fps=1
--ee-kernel-hle=1
--ee-block-validation=PageProt
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
#Performance fix and fix for missing enemies in the gyms</pre>
 
<br>'''SLUS_205.50'''
<br>'''SLES_517.53'''
<br>LUA
<br>They use the same offsets.
<pre>local gpr = require("ee-gpr-alias")


apiRequest(0.1)
apiRequest(0.1)
local eeObj = getEEObject()
local emuObj = getEmuObject()
local emuObj = getEmuObject()
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )
</pre>


local patcher = function()
====Tekken 5====
eeObj.WriteMem32(0x480640, 0x10000000) --Fix for title screen freeze
'''CLI'''
 
<br>All versions
end
<br>
<pre>
#Upscaling glitches fix
--gs-kernel-cl-up="up2x2simple"
#Game needs progressive scan
--gs-progressive=1
#Speedhacks
--vu1-di-bits=0


emuObj.AddVsyncHook(patcher)
#Side note: game is best played using War of the monsters v1 emu as it removes a graphical glitch from some levels.
#side note2: "--gs-kernel-cl-up="up2x2simple" doing this will make graphics look worse than actual ps2
</pre>
</pre>
<br>'''LUA'''
<br>NTSC only
<pre>-- Tekken 5 NTSC
-- Widescreen and No interlace
-- emu used=rogue v1 or wotm v1 or 2


<br>'''SLES_517.54''' LUA
apiRequest(0.1)
<pre>local gpr = require("ee-gpr-alias")


apiRequest(0.1)
local gpr    = require("ee-gpr-alias")


local eeObj = getEEObject()
local emuObj = getEmuObject()
local emuObj = getEmuObject()
local eeObj = getEEObject()


local patcher = function()
local patcher = function()
eeObj.WriteMem32(0x480DB0, 0x10000000) --Fix for title screen freeze
 
eeObj.WriteMem32(0x0032b448,0x3c013f40) -- both fov+
--applies both fov+ only for widescreen mode
eeObj.WriteMem32(0x0032b478,0x3c010015)
eeObj.WriteMem32(0x0032b47c,0xc62dd11c)
eeObj.WriteMem32(0x0032b49c,0x46016b42)
eeObj.WriteMem32(0x0032b4a0,0x46010843)
eeObj.WriteMem32(0x0032b4b8,0x460d1083)
eeObj.WriteMem32(0x0032b4bC,0x460d0843)
--effects fix
eeObj.WriteMem32(0x00257434,0x46161083)
eeObj.WriteMem32(0x00257488,0x46160843)
eeObj.WriteMem32(0x002574e0,0x46160843)
eeObj.WriteMem32(0x00257538,0x46160843)
 
local code_check1 = eeObj.ReadMem16(0x15D11C)
if code_check1 == 0x8e38 then
eeObj.WriteMem32(0x20257764,0x10000008)
end
local code_check2 = eeObj.ReadMem16(0x15D11C)
if code_check2 == 0xaaaa then
eeObj.WriteMem32(0x20257764,0x45020008)
end
--render fix
eeObj.WriteMem32(0x00222484,0x3c013f2b)
eeObj.WriteMem32(0x00222494,0x44810000)
eeObj.WriteMem32(0x00222498,0x46006302)
--Devil Within Mode by Arapapa
local code_check3 = eeObj.ReadMem16(0x100000)
if code_check3 == 0xfff0 then
eeObj.WriteMem32(0x2041E82C,0x3f400000) --Zoom
eeObj.WriteMem32(0x202ACED8,0x3FDDA51A) --Y-Fov
end
--no interlace for starblade
local code_check4 = eeObj.ReadMem16(0x2F5BD0)
if code_check4 == 0x0104 then
eeObj.WriteMem32(0x202F5BD0,0x34070003)
local code_check5 = eeObj.ReadMem16(0x187FB0)
if code_check5 == 0x0008 then
eeObj.WriteMem32(0x20187FB0,0x34030001)
eeObj.WriteMem32(0x20187FC4,0x34021078)
end
end
--[[
--Workaround
eeObj.WriteMem32(0x2010207C,0x3c050000)
eeObj.WriteMem32(0x20102084,0x3c060050)
eeObj.WriteMem32(0x2010208C,0x3c070001)
eeObj.WriteMem32(0x20102EAC,0x3C0701E0)
--]]
--Intro Mini Game
local code_check6 = eeObj.ReadMem16(0xFFECF4)
if code_check6 == 0x0001 then
eeObj.WriteMem32(0x2010230C,0x34029078)
end
--Framebuffer - Progressive - No interleacing - No black lines HW mode
local code_check7 = eeObj.ReadMem16(0xFFEF20)
if code_check7 == 0x8870 then
eeObj.WriteMem32(0x2010230C,0x34029400)
eeObj.WriteMem32(0x203EF450,0x00000001) -- Official Progressive mode
end
-- Devil W. Game
local code_check8 = eeObj.ReadMem16(0xFFEF20)
if code_check8 == 0x2c70 then
eeObj.WriteMem32(0x2026033C,0x34029400)
end
-- Tek 1 sdtv mode 240p
local code_check9 = eeObj.ReadMem16(0xFFEF20)
if code_check9 == 0x3df0 then
eeObj.WriteMem32(0x2014F454,0x3c050000)
eeObj.WriteMem32(0x2014F45C,0x3C060050)
eeObj.WriteMem32(0x2014F464,0x3c070001)
end
-- Tek 2 sdtv mode 240p
local code_check10 = eeObj.ReadMem16(0xFFEF20)
if code_check10 == 0x6570 then
eeObj.WriteMem32(0x2015E494,0x3c050000)
eeObj.WriteMem32(0x2015E49C,0x3C060050)
eeObj.WriteMem32(0x2015E4A4,0x3c070001)
end
-- Tek 3 sdtv mode 480p extended
local code_check11 = eeObj.ReadMem16(0xFFEF20)
if code_check11 == 0xF370 then
eeObj.WriteMem32(0x201E4F54,0x3c050000)
eeObj.WriteMem32(0x201E4F5C,0x3C060050)
eeObj.WriteMem32(0x201E4F64,0x3c070001)
end


end
end


emuObj.AddVsyncHook(patcher)
emuObj.AddVsyncHook(patcher)
--Fix lines appearing in some areas
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=2  } ) -- also makes graphics look like crap
</pre>
</pre>


====Twisted Metal: Head-On====
====The Godfather====
'''CLI'''
'''CLI'''
<br>All versions
<br>All versions
<br>SW racer revenge v1 emu used
<pre>
<pre>
#Speedhacks
#Fix for upscaling graphical glitches
--vu1-mpg-cycles=400
--gs-kernel-cl-up="up2x2simple"
--ee-cycle-scalar=1.2
#Fix for intro stutter
--vu1-di-bits=0
--iop-cycle-scalar=0.80
--cdvd-sector-read-cycles=5000
</pre>
</pre>


====Urban Reign====
====The Legend of Spyro A New Beginning====
'''''CLI'''''
PAL only!
<br>LUA
<pre>apiRequest(0.4)


<br>All Versions
-- The Legend of Spyro: A New Beginning


<pre>
local eeObj = getEEObject()
#Character-Select Freeze fix
local emuObj = getEmuObject()
--vif1-instant-xfer=0
#Others just in case
--vif1-ignore-cmd-ints=1
--vif-ignore-invalid-cmd=0
--vu1=jit-sync
#Jakv2 emu used
</pre>


====Valkyrie Profile 2: Silmeria====
eeInsnReplace(0x1849b8, 0x44840800, 0x00000000) -- Fixes HUD and menu display.
'''''CLI'''''


<br>All versions
-- Graphic improvement: removes corrupted lines on screen with uprender enabled, for PAL version


<pre>
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } ) --texMode=1 ?
#emu used Star Ocean 3 for black screen upon leaving town and corrupted world map
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=2 } ) --texMode=2 is BILINEAR</pre>
--gs-progressive=1
--vu-hack-triace=1
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
</pre>


'''''LUA file'''''
====The Legend of Spyro: The Eternal Night====
<br>SLUS_21452
PAL only!
<pre>--Proper Widescreen and No ghosting
<br>LUA
--Valkyrie Profile 2 - Silmeria (USA) SLUS_214.52
<pre>apiRequest(0.4)
apiRequest(1.0)
local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()


local code_check = eeObj.ReadMem16(0x37984C)
-- The Legend of Spyro: The Eternal Night
if code_check == 0x0800 then
eeObj.WriteMem32(0x37984C,0x0803FC00)
end


eeObj.WriteMem32(0x000FF000, 0x3C043F40)
local eeObj = getEEObject()
eeObj.WriteMem32(0x000FF004, 0x44840800)
local emuObj = getEmuObject()
eeObj.WriteMem32(0x000FF008, 0x46000802)
eeObj.WriteMem32(0x000FF00C, 0x080DE615)
eeObj.WriteMem32(0x000FF010, 0xC66100C8)
--No ghosting in battle
eeObj.WriteMem32(0x0035FA38, 0x46001030)
end
emuObj.AddVsyncHook(patcher)
</pre>


====Vampire: Darkstalkers Collection====
eeInsnReplace(0x173c38, 0x44840800, 0x00000000) -- Fixes HUD and menu display.
ALL
<br>CLI
<pre>--gs-motion-factor=50
--host-audio-latency=0.01
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
--gs-h2l-list-opt=1
--gs-h2l-accurate-hash=1
#Fix for performance issues. PS4 Pro required for full speed.</pre>


====Van Helsing====
ALL
<br>CLI
<pre>
--vu1-mpg-cycles=700
--vu1-di-bits=0
--ee-cycle-scalar=1.3
#Fix for performance issues.</pre>


====Whiplash====
-- Graphic improvement: removes corrupted lines on screen with uprender enabled, for PAL version
All versions
<br>CLI
<pre>--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--gs-use-mipmap=1
#Fix for texture glitches</pre>


====WinBack: Covert Operations====
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } ) --texMode=1 ?
All versions
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=2 } ) --texMode=2 is BILINEAR</pre>
<br>CLI
<pre>--vu0-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1


#Fix for texture glitches</pre>
====The Operative: No One Lives Forever====


====X-Files - Resist or Serve====
'''''CLI'''''
NTSC/U
<pre>
<br>CLI
 
<pre>--vu0-no-clamping=0
#Fix for "The Operative - No One Lives Forever"
--vu0-clamp-results=1
 
--vu1-no-clamping=0
For US version
--vu1-clamp-results=1
 
--cop2-no-clamping=0
--fpu-accurate-addsub-range=0x104204,0x1042B8
--cop2-clamp-results=1
 
For EU version:


#fix for missing character models
--fpu-accurate-addsub-range=0x103F28,0x104074
#Jak Emu used</pre>


==== X-Men Legends====
Use Jak v2 emulator
'''CLI'''
<br>All versions
<pre>
#Speedhacks
--vu1-di-bits=0
--vu1=jit-sync
--vu1-mpg-cycles=800
--ee-cycle-scalar=1.3
</pre>
</pre>


==== X-Men Legends II====
==== The Shield ====
'''CLI'''
'''''CLI'''''
<br>All versions
<pre>
<pre>
#Speedhacks
--fpu-accurate-addsub-range=0x100008,0x700000
--vu1-di-bits=0
 
--vu1=jit-sync
#Fix for game over error on level '''2354 Casitas Dr'''.
--vu1-mpg-cycles=800
#JAK V2 emulator used.
--ee-cycle-scalar=1.3
</pre>
</pre>


==== Yu-Gi-Oh! Capsule Monsters Colosseum====
====Timesplitters™====
All
'''''CLI'''''
<br>CLI
<pre>--vu1=jit-sync


#MTVU Incompatibilty, Fix for Black Screen, RECVX Emu Needed
<br>All Versions
</pre>


====Zatch Bell! Mamodo Battles™====
<pre>
NTSC/U
<br>CLI
<pre>
#Graphical glitches fix
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--gs-use-mipmap=1
#Clamping, also for graphics
--vu0-no-clamping=0
--vu1-no-clamping=0
#Most likely unnecessary overdone clamping commands
--vu0-clamp-results=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-results=1
--fpu-no-clamping=0
--fpu-clamp-results=1


*Jak Emu used*</pre>
—vu1=jit-sync
</pre>


====Zombie Hunters 2====
====Tomb Raider: Anniversary====
'''CLI'''
'''''LUA'''''
<br>All versions
<pre>
#Speedhacks
--vu1-di-bits=0
--ee-cycle-scalar=1.2
--vu1-mpg-cycles=150
#Graphics clean up
--gs-use-clut-merge=1
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"
--vu1-no-clamping=0
</pre>


====Zombie Zone====
<br>SLUS_215.55
'''CLI'''
<br>All versions
<pre>
#Speedhacks
--vu1-di-bits=0
--ee-cycle-scalar=1.2
--vu1-mpg-cycles=150
#Graphics clean up
--gs-use-clut-merge=1
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"
</pre>
==Incomplete configurations==
<pre>This is a list of configurations that were unsuccessful or were never completed. or information that might help people in the future.
a place for research and sharing useful info and sometimes a placeholder for //todo list</pre>


<pre>apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.


====Dragon ball z budokai tenkaichi====
-- Texture Flickering fix
'''LUA'''
<br>NTSC
<pre>
apiRequest(0.1)


--untested
eeInsnReplace(0x1297C0, 0x10600022, 0x10000022)
local eeObj = getEEObject()
local emuObj = getEmuObject()
 
local patcher = function()
eeObj.WriteMem32(0x0011A54C, 0x24020000)
eeObj.WriteMem32(0x0018D944, 0x24020000)
eeObj.WriteMem32(0x0018D4CC, 0x24020000)
end
emuObj.AddVsyncHook(patcher)
</pre>
</pre>


====Batman begins====
<br>SLES_539.08
NTSC
<pre>
apiRequest(0.1)


local eeObj = getEEObject()
<pre>apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.
local emuObj = getEmuObject()


local patcher = function()
-- Texture Flickering fix


eeObj.WriteMem32(0x0032C0F4, 0x10000006)
eeInsnReplace(0x1273E8, 0x10600022, 0x10000022)</pre>
end
emuObj.AddVsyncHook(patcher)
</pre>


====Harry Potter and The Prisoner of Azkaban====
====Tomb Raider - Legend====
<br>Seems to be having a mixture of VIF1 and GIF issues
CLI
<br>'''SLUS20926'''
<br>All Regions
<pre>
<pre>
local gpr = require("ee-gpr-alias")
--gs-progressive=1
--gs-kernel-cl-up="up2x2skipinterp"
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
</pre>


apiRequest(0.1)
'''SLUS_212.03'''
<br>LUA
<pre>apiRequest(0.1)   -- request version 0.1 API. Calling apiRequest() is mandatory.


local eeObj = getEEObject()
-- Texture Flickering fix
local emuObj = getEmuObject()


local patcher = function()
eeInsnReplace(0x127390, 0x10600022, 0x10000022)
-- This patch will help you skip the crash, but won't get you far into the game
</pre>
-- jakv2


--eeObj.WriteMem32(0x0013C884, 0x0) --1440FFFA, This one caused the crash.
'''SLES_546.74'''
eeObj.WriteMem32(0x0013C1CC, 0x0) --5440FFFA, After nopping the first one, pc got stuck here.
<br>LUA
eeObj.WriteMem32(0x0013CD64, 0x0) --1440FFFA, After nopping the second one, pc got stuck here
<pre>apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.
eeObj.WriteMem32(0x0016CF8C, 0x0) --1440FFFA, After nopping this one along with the others, the game
--plays normally but without any video output, therefore it's best to keep the first one commented out for now


end
-- Texture Flickering fix
emuObj.AddVsyncHook(patcher)
eeInsnReplace(0x129800, 0x10600022, 0x10000022)
</pre>
</pre>
Additional LUA fix
<br>All Regions
<pre>
<pre>
affected offsets:
-- Fix for thin vertical lines that separate screen picture, misallignment/tearing of screen during upscaling (was used in official PSN Red Dead Revolver)
0013DE40
apiRequest(1.0)
0013CC4C
local emuObj = getEmuObject()
-- psm= SCE_GS_PSMCT32 (0)
emuObj.SetGsTitleFix( "forceSimpleFetch",  "reserved", {psm=0} )
emuObj.SetGsTitleFix( "fetchFromCurrBuff", "reserved", {psm=0} )
</pre>
</pre>


====Tenchu - Fatal Shadows====
====Tony Hawk Pro Skater 3====
<br>NTSC
'''''CLI'''''
<pre>
 
once it reaches here
<br>All Versions
0013E310
 
game goes here
<pre>--vu0-no-clamping=0
0010FD24
--vu1-no-clamping=0
</pre>
--vu0-clamp-results=1
--vu1-clamp-results=1
--fpu-no-clamping=0
--cop2-no-clamping=0
--fpu-clamp-results=1
--cop2-clamp-results=1


====Marvel nemesis====
#SPS Fix</pre>


====Tony Hawk's Underground 2====
'''CLI'''
<br>SLUS20965
<br>Redfaction emu used
<pre>
<pre>
00363D7C ??
#sps fix
--vu1-mpg-cycles=1
</pre>
</pre>
 
'''LUA'''
====Stuntman====
<br>SLUS20965
<br>'''FPU Research'''
<br>'''Mrjaredbeta'''
<br>'''US'''
<pre>
<pre>
0x100000-0x1c5e68 - no change
apiRequest(0.1)


0x1c5e6c - improvement in ApplyTyreForces5WheelR3CarffG4MAv3N24R4MAm4Rf
local eeObj = getEEObject()
  vadd.xyzw vf01, vf01, vf02
local emuObj = getEmuObject()
0x1c7128 - improvement in Update5WheelR3CarR4MAm4R4MAv3T3
  vadd.xyzw vf01, vf01, vf02
0x1c727c - imrpovement in Update5WheelR3CarR4MAm4R4MAv3T3
  vadd.xyzw vf01, vf01, vf02
    - both of the above with the others make most accurate path
    - vm insts 0x1c6e78-0x1c6ecc basically negate this additional accuracy?


0x1c769c-0x211f04 - nothing
local patcher = function()
 
--loop skip to prevent freezing
0x211f08 - improvement in _dyForwardDynamicsFP10DYdynamicsf
eeObj.WriteMem32(0x001958A0, 0x10000086)
  vadd.xyzw vf02, vf02, vf01
--rounding to remove sps
0x211f94 - improvement in dyStepRunge1FP10DYdynamicsf
eeObj.WriteMem32(0x003F0FE8, 0xD3400000)
  vadd.xyzw vf04, vf04, vf01
--Giving it the value it wants in order to branch
 
eeObj.WriteMem32(0x001AF5FC, 0x24060000)
0x2140b0-0x215118 - no change
end
emuObj.AddVsyncHook(patcher)
--mtvu patch
eeInsnReplace(0x00194918, 0x0, 0x0803fff0)
eeInsnReplace(0x000fffc4, 0x0, 0x24186000)
eeInsnReplace(0x000fffc8, 0x0, 0x3c191200)
eeInsnReplace(0x000fffcc, 0x0, 0x37391010)
eeInsnReplace(0x000fffd0, 0x0, 0x2718ffff)
eeInsnReplace(0x000fffd4, 0x0, 0x1418fffe)
eeInsnReplace(0x000fffdc, 0x0, 0x08065248)
eeInsnReplace(0x000fffe0, 0x0, 0xaf200000)
</pre>


0x215118 - obUpdateTransMatrixFP8OBobject
====True Crime: Streets of LA====
    - negates additional accuracy of Update__5WheelR3CarR4MAm4R4MAv3T3?
<br>cli.conf
<br>All Versions
<pre>--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
#Fix for missing enemies in the gyms</pre>
<br> cli.conf
<br>SLES_517.54 only!
<pre>--vu1-mpg-cycles=2350
--vu1-opt-flags=2
--vu1-opt-vf00=2
--gs-optimize-30fps=1
--ee-kernel-hle=1
--ee-block-validation=PageProt
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
#Performance fix and fix for missing enemies in the gyms</pre>
 
<br>'''SLUS_205.50'''
<br>'''SLES_517.53'''
<br>LUA
<br>They use the same offsets.
<pre>local gpr = require("ee-gpr-alias")
 
apiRequest(0.1)
 
local eeObj = getEEObject()
local emuObj = getEmuObject()
 
local patcher = function()
eeObj.WriteMem32(0x480640, 0x10000000) --Fix for title screen freeze
 
end
 
emuObj.AddVsyncHook(patcher)
</pre>
</pre>
<br>'''SLES_517.54''' LUA
<pre>local gpr = require("ee-gpr-alias")
apiRequest(0.1)
local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()
eeObj.WriteMem32(0x480DB0, 0x10000000) --Fix for title screen freeze
end
emuObj.AddVsyncHook(patcher)
</pre>
====Twisted Metal: Head-On====
'''CLI'''
<br>All versions
<pre>
#Speedhacks
--vu1-mpg-cycles=400
--ee-cycle-scalar=1.2
--vu1-di-bits=0
</pre>
====Urban Reign====
'''''CLI'''''
<br>All Versions
<pre>
--gs-uprender=2x2
--gs-upscale=EdgeSmooth
--force-frame-blend=1
--vif-ignore-invalid-cmd=0
--vif1-ignore-cmd-ints=1
--vif1-instant-xfer=0
--vu1=jit-sync
--mtap1=Always
</pre>
'''''LUA'''''
<br>NTSC
<pre>
-- Urban Reign NTSC (SLUS-21209)
-- Multitap fix by Kozarovv
-- Cheats from GameHacking.org
-- ported to PS4 by Stayhye
-- emu used=kof98um
apiRequest(0.1)
local gpr    = require("ee-gpr-alias")
local emuObj = getEmuObject()
local eeObj = getEEObject()
local gsObj = getGsObject()
emuObj.PadSetLightBar(0, 45,65,55)
emuObj.SetDeinterlace(true)
emuObj.SetDisplayAspectWide()
local WS = function()
--Unlock Free Mode by MadCatz
eeObj.WriteMem32(0x00946634,0x00010001)
-- Init first mtap
eeObj.WriteMem32(0x12BA88,0x24040000)
-- Read data from 1B port when 2A is requested
eeObj.WriteMem32(0x0ffc00,0x10040005)
eeObj.WriteMem32(0x0ffc04,0x00000000)
eeObj.WriteMem32(0x0ffc08,0x14050003)
eeObj.WriteMem32(0x0ffc10,0x24040000)
eeObj.WriteMem32(0x0ffc14,0x24050001)
eeObj.WriteMem32(0x0ffc18,0x080c5cbd)
eeObj.WriteMem32(0x0ffc1c,0x24030070)
eeObj.WriteMem32(0x3172ec,0x0803ff00)
--Unlock Challenge Mode by MadCatz
eeObj.WriteMem32(0x00946636,0x00010001)
--Unlock All Weapons by MadCatz
eeObj.WriteMem32(0x20274774,0x24030001)
eeObj.WriteMem32(0x2027477C,0xA443000E)
--Brad Hawk by Code Master
eeObj.WriteMem32(0x0094668E,0x00010001)
--Glen by Code Master
eeObj.WriteMem32(0x00946694,0x00010001)
--Torque by Code Master
eeObj.WriteMem32(0x00946696,0x00010001)
--Rod by Code Master
eeObj.WriteMem32(0x00946698,0x00010001)
--Seth by Code Master
eeObj.WriteMem32(0x0094669A,0x00010001)
--Nas-Tiii by Code Master
eeObj.WriteMem32(0x0094669C,0x00010001)
--Em Cee by Code Master
eeObj.WriteMem32(0x0094669E,0x00010001)
--Real Deal by Code Master
eeObj.WriteMem32(0x009466A0,0x00010001)
--Ty by Code Master
eeObj.WriteMem32(0x009466A2,0x00010001)
--Miguel by Code Master
eeObj.WriteMem32(0x009466A4,0x00010001)
--Ramon by Code Master
eeObj.WriteMem32(0x009466A6,0x00010001)
--Jose by Code Master
eeObj.WriteMem32(0x009466A8,0x00010001)
--Emilio by Code Master
eeObj.WriteMem32(0x009466AA,0x00010001)
--Kadonashi by Code Master
eeObj.WriteMem32(0x009466AC,0x00010001)
--Reggie by Code Master
eeObj.WriteMem32(0x009466AE,0x00010001)
--Zach by Code Master
eeObj.WriteMem32(0x009466B0,0x00010001)
--Colin by Code Master
eeObj.WriteMem32(0x009466B2,0x00010001)
--Jake by Code Master
eeObj.WriteMem32(0x009466B4,0x00010001)
--Tong Yoon by Code Master
eeObj.WriteMem32(0x009466B6,0x00010001)
--Grimm by Code Master
eeObj.WriteMem32(0x009466B8,0x00010001)
--BK by Code Master
eeObj.WriteMem32(0x009466BA,0x00010001)
--Grave Digga' by Code Master
eeObj.WriteMem32(0x009466BC,0x00010001)
--Bones by Code Master
eeObj.WriteMem32(0x009466BE,0x00010001)
--Booma by Code Master
eeObj.WriteMem32(0x009466C0,0x00010001)
--Busta by Code Master
eeObj.WriteMem32(0x009466C2,0x00010001)
--Spider by Code Master
eeObj.WriteMem32(0x009466C4,0x00010001)
--Pain Killah by Code Master
eeObj.WriteMem32(0x009466C6,0x00010001)
--Dwayne by Code Master
eeObj.WriteMem32(0x009466C8,0x00010001)
--Dwayne 2? by Code Master
eeObj.WriteMem32(0x009466CA,0x00010001)
--Shun Ying Lee by Code Master
eeObj.WriteMem32(0x009466CC,0x00010001)
--GD-05 by Code Master
eeObj.WriteMem32(0x009466CE,0x00010001)
--DR-88 by Code Master
eeObj.WriteMem32(0x009466D0,0x00010001)
--FK-71 by Code Master
eeObj.WriteMem32(0x009466D2,0x00010001)
--PT-22 by Code Master
eeObj.WriteMem32(0x009466D4,0x00010001)
--Bain by Code Master
eeObj.WriteMem32(0x009466D6,0x00010001)
--Cooper by Code Master
eeObj.WriteMem32(0x009466D8,0x00010001)
--Anderson by Code Master
eeObj.WriteMem32(0x009466DA,0x00010001)
--Taylor by Code Master
eeObj.WriteMem32(0x009466DC,0x00010001)
--Chris by Code Master
eeObj.WriteMem32(0x009466DE,0x00010001)
--Park by Code Master
eeObj.WriteMem32(0x009466E0,0x00010001)
--Alex by Code Master
eeObj.WriteMem32(0x009466E2,0x00010001)
--McKinzie by Code Master
eeObj.WriteMem32(0x009466E4,0x00010001)
--Napalm 99 by Code Master
eeObj.WriteMem32(0x009466E6,0x00010001)
--Golem by Code Master
eeObj.WriteMem32(0x009466E8,0x00010001)
--Riki by Code Master
eeObj.WriteMem32(0x009466EA,0x00010001)
--Masa by Code Master
eeObj.WriteMem32(0x009466EC,0x00010001)
--Hiro by Code Master
eeObj.WriteMem32(0x009466EE,0x00010001)
--Ryuji by Code Master
eeObj.WriteMem32(0x009466F0,0x00010001)
--Ye Wei by Code Master
eeObj.WriteMem32(0x009466F2,0x00010001)
--Sha Ying by Code Master
eeObj.WriteMem32(0x009466F4,0x00010001)
--Yan Jun by Code Master
eeObj.WriteMem32(0x009466F6,0x00010001)
--Shinkai by Code Master
eeObj.WriteMem32(0x009466F8,0x00010001)
--Lin Fong Lee by Code Master
eeObj.WriteMem32(0x009466FA,0x00010001)
--Bordin by Code Master
eeObj.WriteMem32(0x009466FC,0x00010001)
--Lilian by Code Master
eeObj.WriteMem32(0x009466FE,0x00010001)
--Kelly by Code Master
eeObj.WriteMem32(0x00946700,0x00010001)
--Vera Ross by Code Master
eeObj.WriteMem32(0x00946702,0x00010001)
--Paul Phoenix by Code Master
eeObj.WriteMem32(0x00946704,0x00010001)
--Marshall Law by Code Master
eeObj.WriteMem32(0x00946706,0x00010001)
--KG by Code Master
eeObj.WriteMem32(0x00946718,0x00010001)
emuObj.ThrottleMax()
end
emuObj.AddVsyncHook(WS)
emuObj.SetGsTitleFix( "globalSet",  "reserved", { workLoadThreshold = 100000} )
emuObj.SetGsTitleFix( "globalSet",  "reserved", { waveThreshold = 90000} )
emuObj.SetGsTitleFix( "ignoreAreaUpdate", 0, { } )
</pre>
====Valkyrie Profile 2: Silmeria====
'''''CLI'''''
<br>All versions
<pre>
#emu used Star Ocean 3 for black screen upon leaving town and corrupted world map
--gs-progressive=1
--vu-hack-triace=1
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
</pre>
'''''LUA file'''''
<br>SLUS_21452
<pre>--Proper Widescreen and No ghosting
--Valkyrie Profile 2 - Silmeria (USA) SLUS_214.52
apiRequest(1.0)
local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()
local code_check = eeObj.ReadMem16(0x37984C)
if code_check == 0x0800 then
eeObj.WriteMem32(0x37984C,0x0803FC00)
end
eeObj.WriteMem32(0x000FF000, 0x3C043F40)
eeObj.WriteMem32(0x000FF004, 0x44840800)
eeObj.WriteMem32(0x000FF008, 0x46000802)
eeObj.WriteMem32(0x000FF00C, 0x080DE615)
eeObj.WriteMem32(0x000FF010, 0xC66100C8)
--No ghosting in battle
eeObj.WriteMem32(0x0035FA38, 0x46001030)
end
emuObj.AddVsyncHook(patcher)
</pre>
====Vampire: Darkstalkers Collection====
ALL
<br>CLI
<pre>--gs-motion-factor=50
--host-audio-latency=0.01
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
--gs-h2l-list-opt=1
--gs-h2l-accurate-hash=1
#Fix for performance issues. PS4 Pro required for full speed.</pre>
====Van Helsing====
ALL
<br>CLI
<pre>
--gs-uprender=2x2
--gs-upscale=edgesmooth
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
--gs-adaptive-frameskip=1
--cdvd-sector-read-cycles=2000
--gs-progressive=1
#--vu0-di-bits=0
#--vu1-di-bits=0
--vu1-mpg-cycles=358
--ee-cycle-scalar=2.8
--iop-cycle-scalar=0.9
--vif1-instant-xfer=0</pre>
<br>'''LUA'''
<pre>
-- Van Helsing (SLUS-20738)
-- Wide screen patch 16:9 by paul_met
-- ported to PS4 Lua by Stayhye
-- emu used=jakx v2
apiRequest(2.2)
local gpr    = require("ee-gpr-alias")
local emuObj = getEmuObject()
local eeObj = getEEObject()
local gsObj = getGsObject()
local eeOverlay = eeObj.getOverlayObject()
local iopObj        = getIOPObject()
   
emuObj.SetDisplayAspectWide()
gsObj.SetDeinterlaceShift(1)
local WS = function()
--16:9
eeObj.WriteMem32(0x002E7FA0,0x3FE38E38)
--Access All Cheats by GameMasterZer0
eeObj.WriteMem32(0x2019FFB0,0x24100001)
emuObj.ThrottleMax()
end
emuObj.AddVsyncHook(WS)
</pre>
====Wallace & Gromit in Project Zoo====
'''CLI'''
<br>All Versions
<pre>
--gs-uprender=2x2
--gs-upscale=EdgeSmooth
--gs-progressive=1
--gs-force-bilinear=1
--cdvd-sector-read-cycles=2000
--force-frame-blend=1
--vif1-instant-xfer=0
--vu0-di-bits=0
--vu1-di-bits=0
--vu1-mpg-cycles=800
--ee-cycle-scalar=1.5
</pre>
====Whiplash====
All versions
<br>CLI
<pre>--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--gs-use-mipmap=1
#Fix for texture glitches</pre>
====WinBack: Covert Operations====
All versions
<br>CLI
<pre>--vu0-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1
#Fix for texture glitches</pre>
====X-Files - Resist or Serve====
<br>'''''CLI'''''
<pre>--gs-uprender=2x2
--gs-upscale=EdgeSmooth
--gs-adaptive-frameskip=1
--vu0-no-clamping=0
--vu1-no-clamping=0
--cdvd-sector-read-cycles=3000
#emu used=jak tpl v1
</pre>
==== X-Men Legends====
'''CLI'''
<br>All versions
<pre>
--gs-uprender=2x2
--gs-upscale=motionvector
--gs-optimize-30fps=1
--cdvd-sector-read-cycles=2000
--vu-custom-min-max=0
--vu1-di-bits=0
--vu0-di-bits=0
--vu1-opt-vf00=2
--vu0-opt-vf00=2
--vu1-injection=1
--vu1=jit-sync
--vu1-jr-cache-policy=newprog
--vu1-jalr-cache-policy=newprog
--vu0-jr-cache-policy=newprog
--vu0-jalr-cache-policy=newprog
--ee-cycle-scalar=1.5
</pre>
'''LUA'''
<br>NTSC only
<pre>
-- X-Men™ Legends®
-- ported to PS4 Lua by Stayhye
-- emu used=jakx v2
apiRequest(2.2)
local gpr      = require("ee-gpr-alias")
local emuObj      = getEmuObject()
local eeObj      = getEEObject()
local gsObj      = getGsObject()
local eeOverlay    = eeObj.getOverlayObject()
local iopObj  = getIOPObject()
emuObj.PadSetLightBar(0, 10,50,145)
emuObj.SetDisplayAspectWide()
gsObj.SetDeinterlaceShift(0)
local WS = function()
--eeObj.WriteMem32(0x005cc888,0x3c023f34)
eeObj.WriteMem32(0x20720920,0x3FE147AE)  --In-game width widescreen 16:9
eeObj.WriteMem32(0x2072094c,0x3F000000)  --Fonts Width
eeObj.WriteMem32(0x20720950,0x3F000000)  --Fonts Height
eeObj.WriteMem32(0x20720958,0x3F8CCCCD)  --HUD & Menu Height
--eeObj.WriteMem32(0x20720954,0x3FA00000)  --HUD & Menu Width
eeObj.WriteMem32(0x20D85448,0x3F666666)  --HUD Height
eeObj.WriteMem32(0x20D85430,0x3F59999A)  --HUD Width
eeObj.Vu1MpgCycles(3450)
emuObj.ThrottleMax()
end
emuObj.AddVsyncHook(WS)
emuObj.SetGsTitleFix( "globalSet",  "reserved", { workLoadThreshold = 100000} )
emuObj.SetGsTitleFix( "globalSet",  "reserved", { waveThreshold = 90000} )
emuObj.SetGsTitleFix( "ignoreAreaUpdate", 0, { } )
</pre>
==== Yu-Gi-Oh! Capsule Monsters Colosseum====
All
<br>CLI
<pre>--vu1=jit-sync
#MTVU Incompatibilty, Fix for Black Screen, RECVX Emu Needed
</pre>
====Zatch Bell! Mamodo Battles™====
NTSC/U
<br>CLI
<pre>
#Graphical glitches fix
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--gs-use-mipmap=1
#Clamping, also for graphics
--vu0-no-clamping=0
--vu1-no-clamping=0
#likely unnecessary commands
--vu0-clamp-results=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-results=1
--fpu-no-clamping=0
--fpu-clamp-results=1
#Jak Emu used*</pre>
====Zombie Hunters 2====
'''CLI'''
<br>All versions
<pre>
#Speedhacks
--vu1-di-bits=0
--ee-cycle-scalar=1.2
--vu1-mpg-cycles=150
#Graphics clean up
--gs-use-clut-merge=1
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"
--vu1-no-clamping=0
</pre>
====Zombie Zone====
'''CLI'''
<br>All versions
<pre>
#Speedhacks
--vu1-di-bits=0
--ee-cycle-scalar=1.2
--vu1-mpg-cycles=150
#Graphics clean up
--gs-use-clut-merge=1
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"
</pre>
====Coraline====
'''CLI'''
<br>All versions
<pre>
--gs-uprender=2x2
--gs-upscale=EdgeSmooth
--gs-use-mipmap=1
--gs-kernel-cl-up="mipmap2x2"
--gs-scanout-offsetx=27
--gs-scanout-offsety=27
--safe-area-min=0.9
--cdvd-sector-read-cycles=2000
</pre>
'''LUA'''
<br>PAL
<pre>
-- Coraline
-- emu used=KOF 98
apiRequest(1.0) 
local gpr = require("ee-gpr-alias")
local eeObj  = getEEObject()
local emuObj = getEmuObject()
local patcher = function()
--Widescreen hack
--Gameplay 16:9
--eeObj.WriteMem32(0x0026432C,0x3C014440) --3C014480 (Increases hor. axis)
--Render fix
eeObj.WriteMem32(0x001A6548,0x3C013C2E) --3C013C0E
--Get rid of black bar
eeObj.WriteMem32(0x00225ea8,0x3c014000) --3c014299
eeObj.WriteMem32(0x00225eac,0x00000000) --3421999a
eeObj.WriteMem32(0x002644ec,0x3c014440) -- hor fov
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 (R1 ~= 0 and LEFT ~= 0) then --L3 Normal Screen
  eeObj.WriteMem32(0x0026432C,0x3C014480) -- original value
end
if (R1 ~= 0 and RIGHT ~= 0) then --R3 Widescreen Screen
  eeObj.WriteMem32(0x0026432C,0x3C014440) --3C014480 (Increases hor. axis)
end
emuObj.ThrottleMax()
end
emuObj.AddVsyncHook(patcher)
</pre>
====Total Overdose====
'''CLI'''
<br>All versions
<pre>
--host-display-mode=16:9
--host-vsync=1
--gs-optimize=60fps
--cdvd-sector-read-cycles=2000
--ps2-lang=system
--gs-progressive=1
--gs-motion-factor=50
--vu0-no-clamping=0
--vu1-no-clamping=0
--gs-ignore-rect-correction=1
#ADK Damashii Emu used
</pre>
'''LUA'''
<br>PAL - SLES53492
<pre>
-- Total Overdose (E)(SLES-53492)
-- emu used=ADK
apiRequest(1.0)
local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()
--Widescreen hack 16:9
--00 00 80 3F 83 F9 22 3F DB 0F C9 3F 00 00 00 BF
eeObj.WriteMem32(0x20692A2C,0x3F47AE14) -- Zoom
--00 00 80 3F 00 00 00 00 00 00 00 00 2F 00 00 00
eeObj.WriteMem32(0x206C64C4,0x3F400000) -- Vert fov
end
emuObj.AddVsyncHook(patcher)
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=2 } )
emuObj.SetGsTitleFix( "forceSimpleFetch",  "reserved", {psm=0} )
emuObj.SetGsTitleFix( "fetchFromCurrBuff", "reserved", {psm=0} )
</pre>
====Dark Summit====
'''CLI'''
<br>All versions
<pre>
--host-display-mode=16:9
--force-pal-60hz=1
# Fahrenheit Emu used
</pre>
'''LUA'''
<br>PAL - SLES50575
<pre>
-- Dark Summit (PAL)
-- emu used=Fahrenheit
apiRequest(1.2)    -- request version 0.1 API. Calling apiRequest() is mandatory.
local emuObj = getEmuObject()
local eeObj  = getEEObject()
local WS = function()
--Widescreen hack 16:9
--X-Fov
--02000446 280100ae 42080546
eeObj.WriteMem32(0x003d37d0,0x08030000)
eeObj.WriteMem32(0x000c0000,0x46040002)
eeObj.WriteMem32(0x000c0004,0x3c013f40)
eeObj.WriteMem32(0x000c0008,0x00000000)
eeObj.WriteMem32(0x000c000c,0x4481f000)
eeObj.WriteMem32(0x000c0010,0x461e0002)
eeObj.WriteMem32(0x000c0014,0x080f4df5)
--Render fix
--003f013c 00a88144 0000b07f
eeObj.WriteMem32(0x0036444c,0x3c013f2b) --3c013f00
emuObj.ThrottleMax()
end
emuObj.AddVsyncHook(WS)
</pre>
====Nightshade====
'''CLI'''
<P>
ALL versions
<pre>
--host-display-mode=16:9
--gs-vert-precision=8
--force-frame-blend=1
</pre>
'''LUA'''
<br>NTSC - SLUS20810
<pre>
-- Nightshade (SLUS-20810)
-- Total Repair by nifengyuexia
-- emu used=jak v2
apiRequest(1.0)
local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()
--Disable the fade-in effect to fix framerate drops caused by excessive enemies
eeObj.WriteMem32(0x1d1048,0x1000000f)
--Disable shadows to fix square bugs around characters
eeObj.WriteMem32(0x322060,0x03e00008)
eeObj.WriteMem32(0x322064,0x00000000)
--Disable haze effect to fix charged attack frame rate drop
eeObj.WriteMem32(0x30f3f4,0x00000000)
end
emuObj.AddVsyncHook(patcher)
</pre>
'''LUA'''
<br>PAL - SLES52238
<pre>
-- Nightshade(SLES-52238)
-- Total Repair by nifengyuexia
-- emu used=jak v2
apiRequest(1.0)
local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()
--Disable the fade-in effect to fix framerate drops caused by excessive enemies
eeObj.WriteMem32(0x1d1f38,0x1000000f)
--Disable shadows to fix square bugs around characters
eeObj.WriteMem32(0x326370,0x03e00008)
eeObj.WriteMem32(0x326374,0x00000000)
--Disable haze effect to fix charged attack frame rate drop
eeObj.WriteMem32(0x3135f4,0x00000000)
end
emuObj.AddVsyncHook(patcher)
</pre>
'''LUA'''
<br>Kunoichi
<br>NTSC-J SLAJ-25031
<pre>
-- Kunoichi(SLAJ-25031)
-- Total Repair by nifengyuexia
-- emu used=jak v2
apiRequest(1.0)
local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()
--Disable the fade-in effect to fix framerate drops caused by excessive enemies
eeObj.WriteMem32(0x1d10f8,0x1000000f)
--Disable shadows to fix square bugs around characters
eeObj.WriteMem32(0x324450,0x03e00008)
eeObj.WriteMem32(0x324454,0x00000000)
--Disable haze effect to fix charged attack frame rate drop
eeObj.WriteMem32(0x3117f4,0x00000000)
end
emuObj.AddVsyncHook(patcher)
</pre>
'''LUA'''
<br>NTSC-J SLPM-65447
<pre>
-- Kunoichi(SLPM-65447)
-- Total Repair by nifengyuexia
-- emu used=jak v2
apiRequest(1.0)
local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()
--Disable the fade-in effect to fix framerate drops caused by excessive enemies
eeObj.WriteMem32(0x1d1058,0x1000000f)
--Disable shadows to fix square bugs around characters
eeObj.WriteMem32(0x321c70,0x03e00008)
eeObj.WriteMem32(0x321c74,0x00000000)
--Disable haze effect to fix charged attack frame rate drop
eeObj.WriteMem32(0x30f004,0x00000000)
end
emuObj.AddVsyncHook(patcher)
</pre>
====Jak and Daxter: The Lost Frontier====
'''CLI'''
<P>
ALL versions
<pre>
--vu1-di-bits=0
--vu0-di-bits=1
--gs-optimize=60fps
# Emu used = Red Dead Revolver
</pre>
====Sled Storm====
<P>
ALL versions
<pre>
--cdvd-sector-read-cycles=2000
--vu0-no-clamping=0
--vu1-no-clamping=0
--host-gamepads=2
# Emu used = Rogue v1
</pre>
==Incomplete configurations==
<pre>This is a list of configurations that were unsuccessful or were never completed, or information that might help people in the future.
A place for research and sharing useful info.</pre>
====Dragon ball z budokai tenkaichi====
'''LUA'''
<br>NTSC
Things go wrong somewhere around 0x001137A8
<pre>
apiRequest(0.1)
--untested
local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()
eeObj.WriteMem32(0x0011A54C, 0x24020000)
eeObj.WriteMem32(0x0018D944, 0x24020000)
eeObj.WriteMem32(0x0018D4CC, 0x24020000)
end
emuObj.AddVsyncHook(patcher)
</pre>
====Dynasty Warriors 5 - Empires====
<br>PAL
<pre>
001428CC
-00142910
</pre>
====Batman begins====
NTSC
<pre>
00409BF8 0000001E
</pre>
====Genji dawn of the samurai====
<br>NTSC
<pre>
002F876C
</pre>
====Bee movie====
NTSC
<br>CLI
<br>NTSC
<br>Redfaction
<pre>
--ee-context-switch-cycles=16000
--assert-path1-ad=1
--gs-kernel-cl-up="up2x2simple"
</pre>
====Hitman - Blood Money====
NTSC
<br>LUA
<pre>
apiRequest(0.1)
local eeObj = getEEObject()
local emuObj = getEmuObject()
--Exhibits a strange DMA issue
local patcher = function()
eeObj.WriteMem32(0x0028B554, 0x240F0000)
eeObj.WriteMem32(0x0028B4B0, 0x240F0000)
end
emuObj.AddVsyncHook(patcher)
</pre>
====Tenchu - Fatal Shadows====
<br>NTSC
<br>Destroy all humans v1
<pre>
#Removes most elements of graphical corruption
--vif1-instant-xfer=0
</pre>
<pre>
apiRequest(0.1)
-- Not the best solution, but it works.
eeInsnReplace(0x001023E0, 0xAE020000, 0x0)
-- The graphical issues start somewhere in this function 0x00134B10
</pre>
====Ratchet and Clank: Up Your Arsenal====
<br>SCUS97353
<pre>
-- 23.07.2023 Added debug stuff that should print in klog.
-- This should help us figure out why patch fail.
apiRequest(1.0)
local em  = getEmuObject()
local ee  = getEEObject()
local patcher = function()
   
    print("CONFIG: Entering patcher!")
    local base = -1
    local addr = -1
    --local spmp = -1
   
    -- Check for SP/MP, not working yet. Only SP supported.
    --spmp = ee.ReadMem32(0x13B3D8)
    --if spmp == 0x0000202d then
    --    addr = 0x13B3D8
    --else
    --    addr = 0x13B3D8
    --end
    -- Search for base.
    addr = 0x13B3D8
    while addr < 0x1000000
    do
        if ee.ReadMem32(addr) == 0x8c810014 then
            if ee.ReadMem32(addr + 4) == 0x3c067000 then
                if ee.ReadMem32(addr + 8) == 0x7cdf1ff0 then
                    base = addr
                    break
                else
                    addr = addr + 4
                end
            else
                addr = addr + 4
            end
        else
            addr = addr + 4
        end
    end
   
    -- Shouldn't be the case.
    if base == -1 then
        print("CONFIG: Base not found!")
        return
    end
    print(string.format("CONFIG: Base = %08x", base))
    -- Patch ctc2 instances.
    ee.WriteMem32(base + 0x490, 0x0C03FF0C) -- ctc2        $zero, vi2
    ee.WriteMem32(base + 0x5e0, 0x0C03FF0C) -- ctc2        $zero, vi2
    ee.WriteMem32(base + 0x728, 0x0C03FF0C) -- ctc2        $zero, vi2
    ee.WriteMem32(base + 0x878, 0x0C03FF0C) -- ctc2        $zero, vi2
    ee.WriteMem32(base + 0x9c0, 0x0C03FF0C) -- ctc2        $zero, vi2
    ee.WriteMem32(base + 0xb18, 0x0C03FF0C) -- ctc2        $zero, vi2
    ee.WriteMem32(base + 0x3f0, 0x0C03FF00) -- ctc2        $zero, vi1
    ee.WriteMem32(base + 0x530, 0x0C03FF00) -- ctc2        $zero, vi1
    ee.WriteMem32(base + 0x688, 0x0C03FF00) -- ctc2        $zero, vi1
    ee.WriteMem32(base + 0x7c8, 0x0C03FF00) -- ctc2        $zero, vi1
    ee.WriteMem32(base + 0x920, 0x0C03FF00) -- ctc2        $zero, vi1
    ee.WriteMem32(base + 0xa60, 0x0C03FF00) -- ctc2        $zero, vi1
    -- preserve ra
    ee.WriteMem32(base + 0x22c, 0xACDF1FF4)
    -- restore ra
    ee.WriteMem32(base + 0xcac, 0x8CDF1FF4)
    -- lq --> lw
    ee.WriteMem32(base + 0xd6c, 0x8c3f1ff0)
    -- delay vcall by few cycles
    ee.WriteMem32(base + 0x33c, 0x241C0020) -- modify to burn ee cycles after vcallms
    ee.WriteMem32(base + 0x340, 0x141CFFFF)
    ee.WriteMem32(base + 0x344, 0x279CFFFF)
    print("CONFIG: Dynamic patches applied!")
end
local delayer = function()
   
    local check = ee.ReadMem32(0x000ffc00)
    if check ~= 0xfcd91ff8 then
        print("CONFIG: Applying static patches!")
    end
   
    -- loop vi1
    ee.WriteMem32(0x000ffc00, 0xfcd91ff8)
    ee.WriteMem32(0x000ffc04, 0x24190080) -- modify to burn ee cycles before ctc2
    ee.WriteMem32(0x000ffc08, 0x1419ffff)
    ee.WriteMem32(0x000ffc0c, 0x2739ffff)
    ee.WriteMem32(0x000ffc10, 0x48c00800)
    ee.WriteMem32(0x000ffc14, 0x24190020) -- modify to burn ee cycles after ctc2
    ee.WriteMem32(0x000ffc18, 0x1419ffff)
    ee.WriteMem32(0x000ffc1c, 0x2739ffff)
    ee.WriteMem32(0x000ffc20, 0x03e00008)
    ee.WriteMem32(0x000ffc24, 0xdcd91ff8)
   
    -- loop vi2
    ee.WriteMem32(0x000ffc30, 0xfcd91ff8)
    ee.WriteMem32(0x000ffc34, 0x24190080) -- modify to burn ee cycles before ctc2
    ee.WriteMem32(0x000ffc38, 0x1419ffff)
    ee.WriteMem32(0x000ffc3c, 0x2739ffff)
    ee.WriteMem32(0x000ffc40, 0x48c01000)
    ee.WriteMem32(0x000ffc44, 0x24190020) -- modify to burn ee cycles after ctc2
    ee.WriteMem32(0x000ffc48, 0x1419ffff)
    ee.WriteMem32(0x000ffc4c, 0x2739ffff)
    ee.WriteMem32(0x000ffc50, 0x03e00008)
    ee.WriteMem32(0x000ffc54, 0xdcd91ff8)
   
    -- This static patch is required because game don't use level loader to load main menu.
    local new_game = ee.ReadMem32(0x3D58B8)
    local check2  = ee.ReadMem32(0x3D5D48)
    if new_game == 0x8c810014 and check2 ~= 0x0C03FF0C then
        print("CONFIG: Applying static patch for new game!")
        ee.WriteMem32(0x3D5D48, 0x0C03FF0C) -- ctc2        $zero, vi2
        ee.WriteMem32(0x3D5E98, 0x0C03FF0C) -- ctc2        $zero, vi2
        ee.WriteMem32(0x3D5FE0, 0x0C03FF0C) -- ctc2        $zero, vi2
        ee.WriteMem32(0x3D6130, 0x0C03FF0C) -- ctc2        $zero, vi2
        ee.WriteMem32(0x3D6278, 0x0C03FF0C) -- ctc2        $zero, vi2
        ee.WriteMem32(0x3D63D0, 0x0C03FF0C) -- ctc2        $zero, vi2
        ee.WriteMem32(0x3D5CA8, 0x0C03FF00) -- ctc2        $zero, vi1
        ee.WriteMem32(0x3D5DE8, 0x0C03FF00) -- ctc2        $zero, vi1
        ee.WriteMem32(0x3D5F40, 0x0C03FF00) -- ctc2        $zero, vi1
        ee.WriteMem32(0x3D6080, 0x0C03FF00) -- ctc2        $zero, vi1
        ee.WriteMem32(0x3D61D8, 0x0C03FF00) -- ctc2        $zero, vi1
        ee.WriteMem32(0x3D6318, 0x0C03FF00) -- ctc2        $zero, vi1
       
        -- preserve ra
        ee.WriteMem32(0x3D5AE4, 0xACDF1FF4)
        -- restore ra
        ee.WriteMem32(0x3D6564, 0x8CDF1FF4)
        -- lq --> lw
        ee.WriteMem32(0x3D6624, 0x8c3f1ff0)
        -- vcall
        ee.WriteMem32(0x3D5BF4, 0x241C0020) -- modify to burn ee cycles after vcallms
        ee.WriteMem32(0x3D5BF8, 0x141CFFFF)
        ee.WriteMem32(0x3D5BFC, 0x279CFFFF)
    end
end
-- hook right after level loader, ideally this should be hook inside loader...
ee.AddHook(0x13B3D8, 0x0000202D, patcher)
em.AddVsyncHook(delayer)
</pre>
I'm following this approach but it isn't working and I do not know why. --[[User:Scalerize|Scalerize]] ([[User talk:Scalerize|talk]]) 21:55, 28 August 2023 (CEST)
<pre>
apiRequest(0.1)
local eeObj = getEEObject()
eeObj.AddHook(0x0013B3C8, 0x0200F809, function()
local pointer =  eeObj.GetGpr(gpr.s0)
end)
--vcallms before
eeObj.AddHook(pointer+0x5496C, 0x7120CDA8, function()
          eeObj.AdvanceClock(500)
end)
--vcallms after
eeObj.AddHook(pointer+0x54974, 0x00000000, function()
          eeObj.AdvanceClock(500)
end)
--vi01 before 1
eeObj.AddHook(pointer+0x54A24, 0x00000000, function()
          eeObj.AdvanceClock(500)
end)
--vi01 before 2
eeObj.AddHook(pointer+0x54B64, 0x7019CC3F, function()
          eeObj.AdvanceClock(500)
end)
--vi01 before 3
eeObj.AddHook(pointer+0x54CBC, 0x00000000, function()
          eeObj.AdvanceClock(500)
end)
--vi01 before 4
eeObj.AddHook(pointer+0x54DFC, 0x7019CC3F, function()
          eeObj.AdvanceClock(500)
end)
--vi01 before 5
eeObj.AddHook(pointer+0x54F54, 0x0019C900, function()
          eeObj.AdvanceClock(500)
end)
--vi01 before 6
eeObj.AddHook(pointer+0x55094, 0x7017BEC8, function()
          eeObj.AdvanceClock(500)
end)
--vi01 after 1
eeObj.AddHook(pointer+0x54A2C, 0x00000000, function()
          eeObj.AdvanceClock(500)
end)
--vi01 after 2
eeObj.AddHook(pointer+0x54B6C, 0x00000000, function()
          eeObj.AdvanceClock(500)
end)
--vi01 after 3
eeObj.AddHook(pointer+0x54CC4, 0x00000000, function()
          eeObj.AdvanceClock(500)
end)
--vi01 after 4
eeObj.AddHook(pointer+0x54E04, 0x00000000, function()
          eeObj.AdvanceClock(500)
end)
--vi01 after 5
eeObj.AddHook(pointer+0x54F5C, 0x000F7880, function()
          eeObj.AdvanceClock(500)
end)
--vi01 after 6
eeObj.AddHook(pointer+0x5509C, 0x71D18D88, function()
          eeObj.AdvanceClock(500)
end)
--vi02 before 1
eeObj.AddHook(pointer+0x54AC4, 0x701188FC, function()
          eeObj.AdvanceClock(500)
end)
--vi02 before 2
eeObj.AddHook(pointer+0x54C14, 0x7120CDA8, function()
          eeObj.AdvanceClock(500)
end)
--vi02 before 3
eeObj.AddHook(pointer+0x54D5C, 0x701188FC, function()
          eeObj.AdvanceClock(500)
end)
--vi02 before 4
eeObj.AddHook(pointer+0x54EAC, 0x7120CDA8, function()
          eeObj.AdvanceClock(500)
end)
--vi02 before 5
eeObj.AddHook(pointer+0x54FF4, 0x0019C900, function()
          eeObj.AdvanceClock(500)
end)
--vi02 before 6
eeObj.AddHook(pointer+0x5514C, 0x00000000, function()
          eeObj.AdvanceClock(500)
end)
--vi02 after 1
eeObj.AddHook(pointer+0x54ACC, 0x70E0CDA8, function()
          eeObj.AdvanceClock(500)
end)
--vi02 after 2
eeObj.AddHook(pointer+0x54C1C, 0x7009E688, function()
          eeObj.AdvanceClock(500)
end)
--vi02 after 3
eeObj.AddHook(pointer+0x54D64, 0x70E0CDA8, function()
          eeObj.AdvanceClock(500)
end)
--vi02 after 4
eeObj.AddHook(pointer+0x54EB4, 0x7009E688, function()
          eeObj.AdvanceClock(500)
end)
--vi02 after 5
eeObj.AddHook(pointer+0x54FFC, 0x22310006, function()
          eeObj.AdvanceClock(500)
end)
--vi02 after 6
eeObj.AddHook(pointer+0x55154, 0x00000000, function()
          eeObj.AdvanceClock(500)
end)
</pre>
You need to define pointer as a global variable or define it inside more advanced function, otherwise it is deleted/undefined when you exit first hook. Additionally your code use aliases without importing required file. This can be fixed by importing it or by using 16 instead of gpr.s0. Next thing is that all those hooks imo should be mounted from single function to ensure that all new hooks are added when game step on first hook. Keep in mind that the way you are obtaining ctc addresses can fail for next stages. Finally, when leaving stage you need to remove those hooks. Because they stay there forever, and that address can already hold different code after stage change. This is because hook check for original opcode is done only when mounting it there, not when running code itself. On top of that game overlay loader which you should use to grab pointer IS NOT used to load main menu screen, so you need to patch it manually or at least with another hook. I don't have ratchet elf now here, but make sure that your initial hook is added in place where new level code is already there, because now it seems that your initial hook is before level loader is even launched. --[[User:Kozarovv|Kozarovv]] ([[User talk:Kozarovv|talk]]) 12:06, 29 August 2023 (CEST)
====Shadow Man - 2econd Coming====
<br>SLUS204.13
<pre>
apiRequest(0.1)
local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()
--Once it reaches to the TEQ, the game crashes.
eeObj.WriteMem32(0x00231AF0, 0x0808C6AF)
end
emuObj.AddVsyncHook(patcher)
</pre>
====Forbidden Siren 2====
'''CLI'''
<br>NTSC
<pre>
--vu-xgkick-delay=9
</pre>
===sceTtyPrint===
This should print some debug info in emulog/klog, pcsx2 a like. Pattern based on Smugglers Run 2 and Spiderman 3. So first test should be done with those games. Spiderman should print something like "Legal screen is 512 x 256." first. Smugglers Run 2 "Timezone=60". Assuming it work, this can give some valuable info about VIF1/GIF hangs, which are 50% of issues in those crappy emus.
--sceTtyWrite take:
--a0 = string ptr
--a1 = size (we need to overwrite str_ptr + size with 0 to make it 0 terminated)
-- best tty pattern for now = "0A 00 07 24 0D 00 05 24 0C 00 C4 24"
apiRequest(1.0)
eeObj  = getEEObject()
emuObj = getEmuObject()
local printerino = function()
    local str_ptr  = eeObj.GetGpr(4) -- a0
    local str_size = eeObj.GetGpr(5) -- a1
   
    -- Add zero terminator, not sure if we need it...
    -- But i don't see any way to pass how long string should be.
    -- So just 0 terminate it just in case.
    -- Note: PS2 pass newline as last character, maybe we don't need it.
    -- if it break anything, or looks weird, then remove +1 from below write.
    eeObj.WriteMem8(str_ptr + str_size + 1, 0)
   
    local str = eeObj.ReadMemStr(str_ptr)
    print(string.format("PS2 DEBUG: %s", str))
end
local addr  = 0x100008
local ttySearch = function()
print("PS2 DEBUG: Entering ttySearch.")
    while(addr < 0x1000000 )
    do
        if eeObj.ReadMem32(addr) == 0x2407000A then
            if eeObj.ReadMem32(addr + 4) == 0x2405000D then
                if eeObj.ReadMem32(addr + 8) == 0x24C4000C then
-- I'm sorry...
local check = 0
local full_op = 0
while(check ~= 0x27BD and addr ~= 0x100008)
do
    addr = addr - 4
full_op = eeObj.ReadMem32(addr)
check = full_op >> 16
end
                    break -- first loop
                else
                    addr = addr + 4
                end
            else
                addr = addr + 4
            end
        else
            addr = addr + 4
        end
    end
if addr < 0x1000000 and not addr < 0x100008 then
    print(string.format("Found sceTtyWrite function at: 0x%X", addr))
eeObj.AddHook(addr, full_op, printerino)
else
    print("sceTtyWrite function not found!")
    end
end
emuObj.AddEntryPointHook(ttySearch)

Latest revision as of 20:27, 18 April 2024

General

As of February 2022, there are two apps created by the community: 'PS2 Classics GUI' and 'PS2-FPKG'. Some games works with one but not with the other, and it would be nice if you guys begin adding this info while filling this page.

Global Configurations

Configurations that are made for more than one game for a specific purpose

SkipMpegHack (FMV skip)

LUA file
All games using standard sceMpeg decoder will have their fmvs disabled by this patch.

apiRequest(1.0)
eeObj  = getEEObject()
emuObj = getEmuObject()

local addr   = 0x100008
local skipMpeg = function()
    while(addr < 0x1000000)
    do
        if eeObj.ReadMem32(addr) == 0x8c830040 then
            if eeObj.ReadMem32(addr + 4) == 0x03e00008 then
                if eeObj.ReadMem32(addr + 8) == 0x8c620000 then
                    eeObj.WriteMem32(addr + 8, 0x24020001)
                    break
                else
                    addr = addr + 4
                end
            else
                addr = addr + 4
            end
        else
            addr = addr + 4
        end
    end
end

emuObj.AddEntryPointHook(skipMpeg)
--We should remove that hook, but we never really hit entry point again.
--emuObj.RemoveEntryPointHook(skipMpeg)

Official PS2emu Configuration Files

Here are configuration files extracted from official packages to improve PS2 emulator compatibility on PS4. Most of them require also emulator/recompiler files from extracted pkg to work correctly.

ADK Damashii

CLI
SLPS-25906

--gs-uprender=none
--gs-upscale=point
--force-frame-blend=1

Arc the Lad: Twilight of the Spirits™

SCUS 972.31
Cli

--gs-force-bilinear=1
--gs-kernel-cl-up="up2x2Simple"
--lopnor-config=1

SCUS 972.31
lua

require("ee-gpr-alias")
apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.

eeObj = getEEObject()

-- Bug#8359 (see bugzilla for the detail)
-- Skip FadeSet call if map is 'Scrappe Plateau' and the latest loaded script file is 'evt03B_07_0.moc'.
-- This game seems to have a problem (sensitive) with frame count on the script engine.
-- On our emulator, frame counting is slightly different from the original.
-- therefore it reads out 'overun' script command, which is 'cmd_fade' to fade-in.
-- At here, we will skip FADE-IN command if the situation meets the requirement.
skip_fade_flag = { map_name = false, file_name = false }

-- fade skip Bug#8359. skip FadeSet if skip_fade_flag meets the requirement.
eeObj.AddHook(  0x13c464,	0x8e0500c0, function()
				   -- print(skip_fade_flag.map_name)
				   -- print(skip_fade_flag.file_name)
				   if skip_fade_flag.map_name and skip_fade_flag.file_name then
					  -- print("SKIP FADE")
					  eeObj.SetPc(0x13c470)
					  skip_fade_flag.map_name = false
					  skip_fade_flag.file_name = false
				   end
end)

-- cmd_read_file(const char* filename)
eeObj.AddHook(0x13dad0, 0x27bdffc0, function()
				 local filename = eeObj.ReadMemStr(eeObj.GetGpr(gpr.a0))
				 -- print(string.format("cmd_read_file %s", filename))
				 if "chara/evt_camera/evt03B_07_0.moc" == filename then
					-- print("skip_fade!")
					skip_fade_flag.file_name = true
				 else
					skip_fade_flag.file_name = false
				 end
end)

-- cmd_map_name(const char* mapname)
eeObj.AddHook(0x13f138,	0x0080282d, function()
				 local mapname = eeObj.ReadMemStr(eeObj.GetGpr(gpr.a0))
				 -- print(string.format("cmd_map_name %s", mapname))
				 if "Scrappe Plateau" == mapname then
					-- print("skip_fade!")
					skip_fade_flag.map_name = true
				 else
					skip_fade_flag.map_name = false
				 end
end)

Canis Canem Edit (Bully)


CLI

--fpu-accurate-mul-fast=1
--fpu-muldiv-range=0x3fa5c0,0x3fa5c0
--gs-flush-ad-xyz=SafeZWrite
--vu1-opt-vf00=2
--vu1-di-bits=0
--ee-hook=0x001f3ef4,FastForwardClock
--gs-use-deferred-l2h=0
--vu1-injection=1
--vu1-mpg-cycles=2500
--fpu-rsqrt-fast-estimate=0
--safe-area-min=1.0

SLES 535.61
LUA

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  } )


SLUS-21269
SLUS-21269_features.lua

This is a substantial file. Over 150 lines with an extensive performance fix. I'm sharing the file itself as a download link.

https://drive.google.com/file/d/12gt2fONqMP1rmEB9UMw3rIpEYbz1dQq8/view

#Official widescreen support.

Destroy All Humans

SLUS_209.45
CLI

--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--gs-ignore-dirty-page-border=1
--fpu-accurate-addsub-range=0x28bf00,0x28c100
#Fix for graphical glitches.

SLUS_209.45
SLUS-20945_features.lua

-- Lua 5.3
-- Title:   Destroy All Humans! PS2 - SLUS-20945 (USA)
-- Author:  Ernesto Corvi, Adam McInnis

-- Changelog:

apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.

local eeObj		= getEEObject()
local emuObj	= getEmuObject()
local gpr = require( "ee-gpr-alias" ) -- you can access EE GPR by alias (gpr.a0 / gpr["a0"])

-- Widescreen
eeObj.AddHook(0x308270, 0x3c0336c5, function() -- Graphics::Script::SetScreenRatio
	local mode = eeObj.GetGpr(gpr.v0)
	
--	print(string.format("mode: %08x", mode))
	
	if mode == 0x36c59d2b then -- widescreen
		emuObj.SetDisplayAspectWide()
	elseif mode == 0x855a87ef then -- standard
		emuObj.SetDisplayAspectNormal()
	end
end)

eeObj.AddHook(0x3078F4, 0xae0000f4, function() -- Graphics::Renderer::Renderer
	local renderer = eeObj.GetGpr(gpr.s0)
	eeObj.WriteMemFloat(renderer+0x200, 1.3333333)
	eeObj.WriteMemFloat(renderer+0x204, 1.7777777)
	eeObj.WriteMem32(renderer+0x208, 2)
end)

emuObj.SetDisplayAspectWide()

-- CRC "settings.display.widescreen" = 0xbcf14d81
-- $s2 = SaveType (1 = new save)

local overlay = InsnOverlay({
	0x27bdffe0, -- addiu $sp, -0x20
	0xffbf0010, -- sd $ra, 0x10($sp)
	0x0c0d49d8, -- jal Core::Memset(void *,int,uint)
	0x00000000, -- nop
	0x24030001, -- li $v1, 1
	0x1472000b, -- bne $s2, $v1, +11
	0x00000000, -- nop
	0x0c09dacc, -- jal UFO::Progress::Get(void)
	0x00000000, -- nop
	0x3c01bcf1, -- lui $at, 0xbcf1
	0x34214d81, -- ori $at, $at, 0x4d81
	0xafa10000, -- sw $at, 0($sp)
	0x24030001, -- li $v1, 1
	0xa3a30004, -- sb $v1, 4($sp)
	0x03a0282d, -- move $a1, $sp
	0x0c09dd4c, -- jal UFO::Progress::Record::AddKey(UFO::Progress::Content const&)
	0x0040202d, -- move $a0, $v0
	0xdfbf0010, -- ld $ra, 0x10($sp)
	0x03e00008, -- jr $ra
	0x27bd0020  -- addiu $sp, 0x20
})
local call_overlay = 0x0c000000 | (overlay >> 2)
eeInsnReplace(0x2789F8, 0x0c0d49d8, call_overlay) -- UFO::Progress::Storage::PrepareWrite
#Official widescreen support.

Destroy All Humans 2

SLUS_214.39
CLI

--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
#Fix for graphical glitches.

SLUS_214.39
SLUS-21439_features.lua

-- Lua 5.3
-- Title:   Destroy All Humans! 2 PS2 - SLUS-21439 (USA)
-- Author:  Ernesto Corvi, Adam McInnis

-- Changelog:

apiRequest(0.7)	-- request version 0.1 API. Calling apiRequest() is mandatory.

local eeObj		= getEEObject()
local emuObj	= getEmuObject()
local gpr = require( "ee-gpr-alias" ) -- you can access EE GPR by alias (gpr.a0 / gpr["a0"])

-- Widescreen
eeObj.AddHook(0x33ca98, 0x3c0436c5, function() -- Graphics::Script::SetScreenRatio
	local mode = eeObj.GetGpr(gpr.v0)
	
--	print(string.format("mode: %08x", mode))
	
	if mode == 0x36c59d2b then -- widescreen
		emuObj.SetDisplayAspectWide()
	elseif mode == 0x855a87ef then -- standard
		emuObj.SetDisplayAspectNormal()
	end
end)

eeObj.AddHook(0x33afac, 0x0000282d, function() -- Graphics::Renderer::Renderer
	eeObj.SetGpr(gpr.a1, 2)
end)

emuObj.SetDisplayAspectWide()

-- CRC "settings.display.anamorphic" = 0x8b36afe9
-- $s2 = SaveType (1 = new save)

local overlay = InsnOverlay({
	0x27bdffe0, -- addiu $sp, -0x20
	0xffbf0010, -- sd $ra, 0x10($sp)
	0x0c059d02, -- memset
	0x00000000, -- nop
	0x24030001, -- li $v1, 1
	0x1472000b, -- bne $s2, $v1, +11
	0x00000000, -- nop
	0x0c09b400, -- jal UFO::Progress::Get(void)
	0x00000000, -- nop
	0x3c01bcf1, -- lui $at, 0x8b36
	0x34214d81, -- ori $at, $at, 0xafe9
	0xafa10000, -- sw $at, 0($sp)
	0x24030001, -- li $v1, 1
	0xa3a30004, -- sb $v1, 4($sp)
	0x03a0282d, -- move $a1, $sp
	0x0c09dd4c, -- jal UFO::Progress::Record::AddKey(UFO::Progress::Content const&)
	0x0040202d, -- move $a0, $v0
	0xdfbf0010, -- ld $ra, 0x10($sp)
	0x03e00008, -- jr $ra
	0x27bd0020  -- addiu $sp, 0x20
})
local call_overlay = 0x0c000000 | (overlay >> 2)
eeInsnReplace(0x271AD0, 0x0c059d02, call_overlay) -- UFO::Progress::Storage::PrepareWrite

-- Disable Progressive Scan and Adjust Screen Position

local overlay2 = 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
})
local call_overlay2 = 0x0c000000 | (overlay2 >> 2)
eeInsnReplace(0x2e5a14, 0x0c0dba4c, call_overlay2) -- Sim::Manager::ProcessScript near Sim::Manager::SetPauseFlag

eeObj.AddHook(0x2e5a10, 0x0240202d, function() -- Sim::Manager::ProcessScript near Sim::Manager::SetPauseFlag
	local luaString = [[
-- disable progressive scan and adjust screen
gui.i.SMOptionsDisplay.table.slots[3] = nil
gui.i.SMOptionsDisplay.table.slots[4] = nil
]]
	eeObj.WriteMemStrZ(0xf7000, luaString)
end)
#Official widescreen support.

Eternal ring

CLI

--pad-analog-to-digital=0
--gs-use-deferred-l2h=1
--host-display-mode=16:9

LUA

local gpr = require("ee-gpr-alias")
local PadStick = require("PadStick")

apiRequest(1.5)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

--X-Fov - ELF hack
--803f013c 00a88144 0045013c
eeObj.WriteMem32(0x00100fcc,0x3c013f40) --3c013f80

--Memory hack
--eeObj.WriteMem32(0x201FF100,0x43c00000)

end

emuObj.AddVsyncHook(patcher)

if 1 then
	-- bug#10361 (intro slowdown) & bug#9823 (conveyor belt effect)
	-- Use Deferred L2H except for conveyor belt effect.

	-- Unsure if other convery or similar effects are present, so use permissive match for bypassing deferral.
	L2H_SetNonDeferred({TRXREG=0x0000000900000080})		-- match any TRXPOS or BITBLTBUF

	-- Full specification of conveyor belt effect.
	-- L2H_SetNonDeferred({BITBLTBUF=0x0000000013023240,TRXPOS=0x0000000000770000,TRXREG=0x0000000900000080})
end


local PadStickRemap_EternalRing_Default = {
	LR=PadStick.AxisRX_Pos,
	LL=PadStick.AxisRX_Neg,
	LU=PadStick.AxisLY_Neg,
	LD=PadStick.AxisLY_Pos,

	L1=PadStick.AxisLX_Neg,
	R1=PadStick.AxisLX_Pos,
	L2=PadStick.AxisRY_Neg,
	R2=PadStick.AxisRY_Pos,
}

local PadStickRemap_EternalRing_InvertY = {
	L2=PadStick.AxisRY_Pos,
	R2=PadStick.AxisRY_Neg,
}

emuObj.PadPressureStickRemap(0, PadStickRemap_EternalRing_Default)

-- Supporting Inverted Y Axis requires smoe menu changes, and should be done via features.lua
--emuObj.PadPressureStickRemap(0, PadStickRemap_EternalRing_InvertY) 

Everybody's Tennis/Hot Shots Tennis

SCES_545.35
CLI

--gs-use-deferred-l2h=0
--l2h-2d-params=0x0000000800000010,0x00000000300a1400,256
--gs-motion-factor=50
--mtap1=always
--gs-opt-frbuff-switch=1
--gs-ignore-dirty-page-border=1
--gs-ignore-rect-correction=1
--ee-native-function=memcpy,0x11e328
--ee-native-function=memset,0x11e4e0
#performance and visual fix(?)

SCES_545.35
LUA

local gpr = require("ee-gpr-alias")
require( "ee-hwaddr" )
apiRequest(1.4)

local eeObj = getEEObject()

-- function dump(addr)
--    print(string.format("=== dump %x ===", addr))
--    for i=0,0x1e do
-- 	  print(string.format("   %08x : %08x %08x %08x %08x",
-- 						  addr + i*16,
-- 						  eeObj.ReadMem32(addr + i*16 + 0),
-- 						  eeObj.ReadMem32(addr + i*16 + 4),
-- 						  eeObj.ReadMem32(addr + i*16 + 8),
-- 						  eeObj.ReadMem32(addr + i*16 +12)))
--    end
-- end

-- Bug#8285
-- This patch changes the color of background on :
--		- Language selection
--		- Company logo
--		- Start screen
--		- Some menu
-- which are in menu.bin overlay. Nothing affected in the actual game.
eeObj.DmaAddHook( 1, function()
					 if eeObj.ReadMem32(vif1_hw.TADR) == 0x1fd1c0 then
						-- On language select
						if eeObj.ReadMem32(0x4c8ef0) == 0x00ff9090 then
						   eeObj.WriteMem32(0x4c8ef0, 0)
						end
						if eeObj.ReadMem32(0x548f30) == 0x00ff9090 then
						   eeObj.WriteMem32(0x548f30, 0)
						end
						-- On company logo
						if eeObj.ReadMem32(0x4c6d70) == 0x00ff9090 then
						   eeObj.WriteMem32(0x4c6d70, 0)
						end
						if eeObj.ReadMem32(0x546db0) == 0x00ff9090 then
						   eeObj.WriteMem32(0x546db0, 0)
						end
					 end
end)


eeInsnReplace(0x103d58, 0x27bdffc0, 0x03e00008)                 -- <SyncDCache>
eeInsnReplace(0x103d5c, 0xffb20020, 0x00000000)
eeNativeHook (0x103d58, 0x03e00008,'AdvanceClock',0x600)
eeInsnReplace(0x103dd8, 0x3c02ffff, 0x03e00008)                 -- <iSyncDCache>
eeInsnReplace(0x103ddc, 0x3442ffc0, 0x00000000)
eeNativeHook (0x103dd8, 0x03e00008,'AdvanceClock',0x600)
eeInsnReplace(0x103e98, 0x27bdffc0, 0x03e00008)                 -- <InvalidDCache>
eeInsnReplace(0x103e9c, 0xffb20020, 0x00000000)
eeNativeHook (0x103e98, 0x03e00008,'AdvanceClock',0x600)
eeInsnReplace(0x103f18, 0x3c02ffff, 0x03e00008)                 -- <iInvalidDCache>
eeInsnReplace(0x103f1c, 0x3442ffc0, 0x00000000)
eeNativeHook (0x103f18, 0x03e00008,'AdvanceClock',0x600)
eeInsnReplace(0x106970, 0x3c19ffff, 0x03e00008)                 -- <sceSifWriteBackDCache>
eeInsnReplace(0x106974, 0x3739ffc0, 0x00000000)
eeNativeHook (0x106970, 0x03e00008,'AdvanceClock',0x1700)

Fahrenheit/Indigo Prophecy

SLES_535.39
CLI

--ee-hook=0x002097d0,FastForwardClock,0x8c6261fc
--ee-hook=0x1a5570,AdvanceClock,,500000
--ee-hook=0x00223c48,AdvanceClock,0x0080382d,8000
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
#Performance fix.

SLES_535.39
LUA

This is a substantial file. Over 20,000 lines with an extensive performance fix. I'm sharing the file itself as a download link.

https://drive.google.com/file/d/1L2YxondID65KIAybKVCBH9KgFegqqOeQ/view

-- Performace fix (bug #9785 )
-- bug#8571
-- ignore 'no wait vsync' case.
-- unsyncv causes major slowness on loading screen, because the game pushes LOTS of identical frame data to GS.

SLES_535.39
SLES-53539_features.lua

-- Lua 5.3
-- Title:   Fahrenheit PS2 - SLES-53539 (EUR)
-- Author:  Ernesto Corvi, Adam McInnis

-- Changelog:

require( "ee-gpr-alias" ) -- you can access EE GPR by alias (gpr.a0 / gpr["a0"])
require( "ee-cpr0-alias" ) -- for EE CPR

apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.

local eeObj		= getEEObject()
local emuObj	= getEmuObject()

local L1 = function() -- QDT::SINT::SCRIPT_LOADING_SCREEN::EM::Run
	emuObj.ThrottleMax()
end
	
local L2 = function() -- QDT::SINT::SCRIPT_LOADING_SCREEN::EM::Stop
	emuObj.ThrottleNorm()
end
	
local load1 = eeObj.AddHook(0x387040, 0x3c02004b, L1) -- QDT::SINT::SCRIPT_LOADING_SCREEN::Run
local load2 = eeObj.AddHook(0x387090, 0x3c02004b, L2) -- QDT::SINT::SCRIPT_LOADING_SCREEN::Stop

-- Widescreen
eeInsnReplace(0x20a7c0, 0x3c013faa, 0x3c013fe3)
eeInsnReplace(0x20a7c4, 0x3421aaab, 0x34218e39)
emuObj.SetDisplayAspectWide()

-- Skip video mode options
local videomenuVM = { 0x04, 0x01, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00,
					  0x3B, 0x0D, 0x00, 0x00, 0x3B, 0x0B, 0x00, 0x00,
					  0x3B, 0x26, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 }
					  
local visualmenuVM = { 0x04, 0x01, 0x00, 0x00, 0xA2, 0x00, 0x00, 0x00,
					   0x3B, 0x19, 0x00, 0x00, 0x3B, 0x18, 0x00, 0x00 }

-- locates src chunk on (dst,cnt). -1 if not found, offset if found
local locateChunk = function(src, dst, count)
	local offs = -1
	
	for x = 0, count - #src do
		if eeObj.ReadMem8(dst+x) == src[1] then
			local found = true
			for y = 1, #src do
				if eeObj.ReadMem8(dst+x+y-1) ~= src[y] then
					found = false
					break
				end
			end
				
			if found == true then
				offs = x
				break
			end
		end
	end
	
	return offs
end

eeObj.AddHook(0x2812b0, 0x27bdfff0, function() -- QDT::VM::BYTE_CODE::BYTE_CODE
	local obj = eeObj.GetGpr(gpr.a1)
	local bytecode = eeObj.ReadMem32(obj+0x18)
	local count = eeObj.ReadMem32(obj+0x20)
	
	if count > #videomenuVM then
		local offs = locateChunk(videomenuVM, bytecode, count)
		if offs >= 0 then
			print("Skipping video mode menu")
			eeObj.WriteMem8(bytecode+offs+4, 8) -- beq 0x44 -> beq 0x8
		end
	end
	
	if count > #visualmenuVM then
		local offs = locateChunk(visualmenuVM, bytecode, count)
		if offs >= 0 then
			print("Skipping visual mode video menu")
			eeObj.WriteMem8(bytecode+offs+1, 2) -- beq 0xa2 -> bne 0xa2
		end
	end
end)

-- Force 60hz
eeInsnReplace(0x207ae0, 0x00a0802d, 0x24100001) -- move $s0, $a1 -> li $s0, 1

-- Fix for bug 9716, which is a bug in the game.
-- Trying to retrieve a COM handle in the game will cause an infinite
-- loop if the handle has been deallocated and the debug server is not
-- connected. There's apparently a small race condition in the Asylum
-- level that sometimes can trigger the bug.
-- The fix involves getting out of the loop.
-- It causes a small visual glitch but otherwise the game continues to work fine.

eeInsnReplace(0x1c5958, 0x10400005, 0) -- QDT::KCOM::COM_SERVICE::RetrieveComHandle
eeInsnReplace(0x1c5b6c, 0x10400005, 0) -- QDT::KCOM::COM_SERVICE::RetrieveComHandle
eeInsnReplace(0x1c5d24, 0x10400005, 0) -- QDT::KCOM::COM_SERVICE::RetrieveComHandle
#Official widescreen support, forced 60Hz/NTSC, along with a game crash bug fix.

Fantavision

CLI
SCES-50002

--gs-kernel-cl-up="fantavision"
--gs-motion-factor=1

LUA
SCES-50002

require("ee-gpr-alias")
require( "ee-hwaddr" )
apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.

eeObj = getEEObject()

--
-- Bug#93709 (JP Bugzilla)
-- Same as Parappa the Rapper 2, it's VIF1 vs GIF xfer timing issue.
-- The game expects PATH3 happens before VU1 xgkick, but actually Olympus doesn't do like that.
--	Game kicks  : PATH3(Context1) PATH1(Rendering using Context1&2) PATH3(Context2)
--	Game expects: PATH3(Context1) PATH3(Context2) PATH1(Rendering using Context1&2)
-- Hence VIF1 DMA needs to be delayed.
eeObj.AddHook(0x1b1468,	0xae020000, function()
				 local ee = eeObj
				 local s0 = ee.GetGpr(gpr.s0)

				 if s0 == vif1_hw.CHCR then
					local chcr = ee.GetGpr(gpr.v0)
					if (chcr & 0x05) == 0x05 then
					   local tadr = ee.ReadMem32(vif1_hw.TADR)
					   if tadr == 0x8883e0 or tadr == 0x9f6b60 then
						  ee.SchedulerDelayEvent("vif1.dma", 0x5000)
					   end
					end
				 end
end)


-- Performace fix
local emuObj = getEmuObject()	
-- twIsLess=5 - texture width is less or eq. than 32
emuObj.SetGsTitleFix( "forcePointSampling", "reserved", {alpha = 0x80000048, twIsLess=5, thIsLess=5 } )

Fatal Fury: Battle Archives volume 2

ALL
CLI

--gs-uprender=none
--gs-upscale=point
--host-audio-latency=0.010
--force-frame-blend=1
#Graphical fix.

SLUS_217.23
SLUS-21723_features.lua

This is a substantial file. Over 500 lines with additional controller/fightstick support and various shader/bezel files. I'm sharing the file itself as a download link.

https://drive.google.com/file/d/1FPPPJiHOazTXaD-H6K3kLACYDSdDeAE1/view

#official widescreen support in the form of screen bezels, along with expanded fightstick support and scanline shaders.

Fu'un Super Combo!!!

SLPS_257.81
CLI

--gs-uprender=2x2
--gs-upscale=point
--host-audio-latency=0.3
--ee-hook=0x127050,AdvanceClock,0x2403002b,0x4000
--ee-hook=0x106734,FastForwardClock,0x0c04149c
--ee-native-function=memcpy,0x11fa9c,0x0080402d
--force-frame-blend=1
--vif1-ignore-cmd-ints=1
#Graphical and performance fixes.

SLPS_257.81
LUA

apiRequest(1.4)

eeNativeFunction(0x11fa9c, 0x0080402d, 'memcpy')
eeNativeFunction(0x11fb48, 0x2cc20008, 'memset')

eeInsnReplace(0x1279d0, 0x27bdffc0, 0x03e00008)                 -- <SyncDCache>
eeInsnReplace(0x1279d4, 0xffb20020, 0x00000000)
eeNativeHook (0x1279d0, 0x03e00008,'AdvanceClock',0xa00)
eeInsnReplace(0x127b00, 0x27bdffc0, 0x03e00008)                 -- <InvalidDCache>
eeInsnReplace(0x127b04, 0xffb20020, 0x00000000)
eeNativeHook (0x127b00, 0x03e00008,'AdvanceClock',0xa00)
eeInsnReplace(0x12a258, 0x3c19ffff, 0x03e00008)                 -- <sceSifWriteBackDCache>
eeInsnReplace(0x12a25c, 0x3739ffc0, 0x00000000)
eeNativeHook (0x12a258, 0x03e00008,'AdvanceClock',0x1700)

require("ee-gpr-alias")

local eeObj = getEEObject()
local emuObj = getEmuObject()

-- *** viBufBeginPut (1)
--eeInsnReplace(0x105628, 0x0c049c78, 0) -- 	jal	1271e0 <WaitSema>
eeInsnReplace(0x1056c8, 0x0c049c70, 0) -- 	jal	1271c0 <SignalSema>
-- *** viBufEndPut (1)
eeInsnReplace(0x105708, 0x0c049c78, 0) -- 	jal	1271e0 <WaitSema>
--eeInsnReplace(0x105730, 0x0c049c70, 0) -- 	jal	1271c0 <SignalSema>
-- *** viBufFlush (1)
--eeInsnReplace(0x105a88, 0x0c049c78, 0) -- 	jal	1271e0 <WaitSema>
--eeInsnReplace(0x105ab8, 0x0c049c70, 0) -- 	jal	1271c0 <SignalSema>
-- *** viBufPutTs (1)
eeInsnReplace(0x105c10, 0x0c049c78, 0) -- 	jal	1271e0 <WaitSema>
eeInsnReplace(0x105cf4, 0x0c049c70, 0) -- 	jal	1271c0 <SignalSema>

-- it's redundant calling of _waitIpuIdle in libmpeg... not so huge impact tho.
eeInsnReplace(0x118620,	0x0c04672a, 0) -- 	jal	119ca8 <_waitIpuIdle>

-- bug# 9972
local emuObj = getEmuObject()
emuObj.SetGsTitleFix( "ignoreSubBuffCov", "reserved", { } )
#Crash/stall fixes.

Grand Theft Auto III

SLUS_200.62
CLI

--vu1-no-clamping=0
--gs-check-trans-rejection=1
--gs-kernel-cl-up="up2x2tc"
--gs-optimize-30fps=1
--ee-hook=0x27cea8,FastForwardClock
#Performance and graphical fix.

SLUS_200.62
LUA

apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.

-- Performace fix
local emuObj = getEmuObject()	
local thresholdArea = 600
emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , {alpha=0x80008068 , zmsk=1 } )


-- Bug#9133
-- workaround ... -16020(gp) value is something wrong. the value comes from CCamera::Process().
--                unfortunately accurate math or any other flags don't help for this problem,
--				  even though it should be calculation error issue.
--				  for here, it's just given 0 radian for CSprite::RenderBufferedOneXLUSprite_Rotate_Dimension()
--				  actually the cloud is a billboard, so it should have 0 degree in view-space.
--				  so given 0 degree must be OK.... but could cause some corruption (wrong perspective or something)
eeInsnReplace(0x318344,	0xc792c16c, 0x44809000) -- 	lwc1	$f18,-16020(gp)
#Performance fix.

SLUS_200.62
SLUS-20062_features.lua

-- Lua 5.3
-- Title:  Grand Theft Auto III PS2 - SLUS-20062 (USA) v1.40
-- Author: Nicola Salmoria
-- Date:   November 3, 2015


require( "ee-gpr-alias" ) -- you can access EE GPR by alias (gpr.a0 / gpr["a0"])

apiRequest(0.7)	-- need widescreen support

local eeObj		= getEEObject()
local emuObj	= getEmuObject()


local USEWIDESCREEN_ADDRESS = 0x416748

local H1 =	-- start of main()
	function()
		eeObj.WriteMem8(USEWIDESCREEN_ADDRESS, 1)	-- enable widescreen
	end

local H2 =	-- change widescreen flag
	function()
		local isWidescreen = eeObj.GetGpr(gpr.v0)
		
		if isWidescreen == 0 then
			emuObj.SetDisplayAspectNormal()
		else
			emuObj.SetDisplayAspectWide()
		end
	end

local hook1 = eeObj.AddHook(0x27ed04, 0x7fbf0000, H1)	-- <main>:
local hook2 = eeObj.AddHook(0x270e50, 0xa382b8d8, H2)	-- <CMenuManager::AnaliseMenuContents(void)>:
#Official widescreen support.

Grand Theft Auto: San Andreas

SLUS_209.46
CLI

--gs-optimize-30fps=1
--ee-hook=0x34dee8,FastForwardClock
--ee-hook=0x00245ee0,FastForwardClock
--cop2-no-clamping=1
--gs-flush-ad-xyz=safe
--vu1-clamp-range=0x04a,0x069
--gs-use-deferred-l2h=0
#Performance optimisation/fix.

SLUS_209.46
LUA

apiRequest(0.6)	-- request version 0.1 API. Calling apiRequest() is mandatory.

-- bug#8979
-- The game bugged.
-- CStreaming::StreamPedsIntoRandomSlots(int*) expects 8 integers arrray to process,
-- but CCheat::LoveConquersAllCheat() function copies just only 6 integers to the stack.
-- it seems the table of the source is correct, so using lq/sq instead of ld/sd to copy
-- the contents of the table correctly.
eeInsnReplace(0x59fbb0,	0xdca20010, 0x78a20010) -- 	ld	v0,16(a1) => lq
eeInsnReplace(0x59fbb8,	0xfc820010, 0x7c820010) -- 	sd	v0,16(a0) => sq

-- bug#8979, actually different one
-- the game has another bug... see https://pss.usrd.scea.com/bugzilla/show_bug.cgi?id=8979
eeInsnReplace(0x1abdd8,	0x102000d9, 0x102000cf) -- 	beqz	at,1ac140 <CPopulation::AddPed(ePedType, unsigned int, CVector const &, bool)+0x3a0>

-- Performace fix
local emuObj = getEmuObject()	
local thresholdArea = 700
emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , {alpha=0x80000044 , zmsk=1 } )
#Performance and rendering fixes.

SLUS_209.46
SLUS-20946_features.lua

-- Lua 5.3
-- Title: Grand Theft Auto: San Andreas - SLUS-20946 (USA) v3.00
-- Author: Nicola Salmoria
-- Date:   November 5, 2015


require( "ee-gpr-alias" ) -- you can access EE GPR by alias (gpr.a0 / gpr["a0"])

apiRequest(0.7)	-- need widescreen support

local eeObj		= getEEObject()
local emuObj	= getEmuObject()


local USEWIDESCREEN_ADDRESS = 0x7004ef

local H1 =	-- init widescreen flag
	function()
		eeObj.WriteMem8(USEWIDESCREEN_ADDRESS, 1)	-- enable widescreen
	end

local H2 =	-- main game loop
	function()
		local isWidescreen = eeObj.ReadMem8(USEWIDESCREEN_ADDRESS)
		
		if isWidescreen == 0 then
			emuObj.SetDisplayAspectNormal()
		else
			emuObj.SetDisplayAspectWide()
		end
	end


local hook1 = eeObj.AddHook(0x233584, 0xa200004f, H1)	-- <CMenuManager::__ct(void)>:
local hook2 = eeObj.AddHook(0x246750, 0x24040012, H2)	-- <TheGame(void)>:
#Official widescreen support.

Grand Theft Auto: Vice City

SLUS_205.52
CLI

--gs-check-trans-rejection=1
--gs-kernel-cl-up="up2x2tc"
--gs-optimize-30fps=1
--ee-hook=0x277b88,FastForwardClock
--ee-hook=0x279a18,FastForwardClock
#Performance fix.

SLUS_205.52
LUA

apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.


-- Performance fix
local emuObj = getEmuObject()	
local thresholdArea = 600
emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , {alpha=0x80008068 , zmsk=1 } )


-- Bug#9147
-- workaround ... -2104(gp) value is something wrong. the value comes from CCamera::Process().
--                unfortunately accurate math or any other flags don't help for this problem,
--				  even though it should be calculation error issue.
--				  for here, it's just given 0 radian for CSprite::RenderBufferedOneXLUSprite_Rotate_Dimension()
--				  actually the cloud is a billboard, so it should have 0 degree in view-space.
--				  so given 0 degree must be OK.... but could cause some corruption (wrong perspective or something)
eeInsnReplace(0x334d64,	0xc792f7c8, 0x44809000) -- 	lwc1	$f18,-2104(gp)
#Performance fix.

SLUS_205.52
SLUS-20552_features.lua

-- Lua 5.3
-- Title: Grand Theft Auto: Vice City - SLUS-20552 (USA) v3.00
-- Author: Nicola Salmoria
-- Date:   November 4, 2015


require( "ee-gpr-alias" ) -- you can access EE GPR by alias (gpr.a0 / gpr["a0"])

apiRequest(0.7)	-- need widescreen support

local eeObj		= getEEObject()
local emuObj	= getEmuObject()


local USEWIDESCREEN_ADDRESS = 0x4ba7bc

local H1 =	-- start of main()
	function()
		eeObj.WriteMem8(USEWIDESCREEN_ADDRESS, 1)	-- enable widescreen
	end

local H2 =	-- main game loop
	function()
		local isWidescreen = eeObj.ReadMem8(USEWIDESCREEN_ADDRESS)
		
		if isWidescreen == 0 then
			emuObj.SetDisplayAspectNormal()
		else
			emuObj.SetDisplayAspectWide()
		end
	end


local hook1 = eeObj.AddHook(0x279384, 0xffbf0000, H1)	-- <main>:
local hook2 = eeObj.AddHook(0x277784, 0x00000000, H2)	-- <TheGame(void)>:


-- Fix for bug #9161. The 'flying cars' cheat causes crashes when attempting to
-- fly an helicopter. We avoid that by disabling recognition of the cheat altogether.
-- The SLPM version comes with the cheat disabled out of the box.
eeInsnReplace(0x27db2c, 0x14400015, 0x10000015)	-- bnez -> b
#Official widescreen support and removal of "flying cars" cheat due to game crash.

SCES_503.61
LUA

-- Jak EU
apiRequest(2.2)

local gpr    		= require("ee-gpr-alias")
local emuObj 		= getEmuObject()vi
local eeObj			= getEEObject()
local gsObj			= getGsObject()
local eeOverlay 	= eeObj.getOverlayObject()

-- Disable internal field shift compensation, part of post-process removal feature.
gsObj.SetDeinterlaceShift(0)

-- 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
-- update: removed due to occasional regression (bug#10608).  post-processing is now skipped in the EE via 'depth-cue'
-- emuObj.SetGsTitleFix( "ignoreSprite", "reserved", {  texType=1 , tw=5 , th=8, zmsk=1 , alpha=0x80000044  } )

-- ------------------------- OVERLAY MANAGER --------------------------
g_OnOverlayRegistered = function(filename, start, size)
	-- global function provided for adding per-overlay callback handlers.
end

local DH8 = function()
	local s0 = eeObj.GetGpr(gpr.s0)
	local linkblock = eeObj.ReadMem32(s0+0x5c)
	
	--print( string.format("--> PRELOAD %08x %08x",s0, linkblock) )
	
	local linkblock_allocate_length 		= eeObj.ReadMem32 (linkblock + 0x00)
	local linkblock_allocate_version 		= eeObj.ReadMem32 (linkblock + 0x04)
	local linkblock_allocate_segment_count 	= eeObj.ReadMem32 (linkblock + 0x08)
	local linkblock_allocate_name 			= eeObj.ReadMemStr(linkblock + 0x0c)
	
	local linkblock_allocate_seg1_linkptr 	= eeObj.ReadMem32 (linkblock + 0x4C)
	local linkblock_allocate_seg1_dataptr 	= eeObj.ReadMem32 (linkblock + 0x50)
	local linkblock_allocate_seg1_size 		= eeObj.ReadMem32 (linkblock + 0x54)
	local linkblock_allocate_seg1_flags 	= eeObj.ReadMem32 (linkblock + 0x58)
                                                              
	local linkblock_allocate_seg2_linkptr 	= eeObj.ReadMem32 (linkblock + 0x5C)
	local linkblock_allocate_seg2_dataptr 	= eeObj.ReadMem32 (linkblock + 0x60)
	local linkblock_allocate_seg2_size 		= eeObj.ReadMem32 (linkblock + 0x64)
	local linkblock_allocate_seg2_flags 	= eeObj.ReadMem32 (linkblock + 0x68)
                                                              
	local linkblock_allocate_seg3_linkptr 	= eeObj.ReadMem32 (linkblock + 0x6C)
	local linkblock_allocate_seg3_dataptr 	= eeObj.ReadMem32 (linkblock + 0x70)
	local linkblock_allocate_seg3_size 		= eeObj.ReadMem32 (linkblock + 0x74)
	local linkblock_allocate_seg3_flags 	= eeObj.ReadMem32 (linkblock + 0x78)
	
	-- seg1 is equiv to main in Jak3
	-- seg3 is equiv to top  in Jak3
	-- seg2 appears to be unused ... ?   --jstine

	if emuObj.IsToolingVerbose() then
		print( string.format("--> LOADED SEGMENT alloc_len %08x ver %08x segcount %08x  name:\"%s\"", linkblock_allocate_length, linkblock_allocate_version, linkblock_allocate_segment_count, linkblock_allocate_name) )
		print( string.format("    seg1linkptr %08x seg1dataptr %08x seg1size %08x seg1flags %08x", linkblock_allocate_seg1_linkptr, linkblock_allocate_seg1_dataptr, linkblock_allocate_seg1_size, linkblock_allocate_seg1_flags) )
		print( string.format("    seg2linkptr %08x seg2dataptr %08x seg2size %08x seg2flags %08x", linkblock_allocate_seg2_linkptr, linkblock_allocate_seg2_dataptr, linkblock_allocate_seg2_size, linkblock_allocate_seg2_flags) )
		print( string.format("    seg3linkptr %08x seg3dataptr %08x seg3size %08x seg3flags %08x", linkblock_allocate_seg3_linkptr, linkblock_allocate_seg3_dataptr, linkblock_allocate_seg3_size, linkblock_allocate_seg3_flags) )
	end

	if linkblock_allocate_seg1_size ~= 0 then eeOverlay.Register(linkblock_allocate_name .. ".seg1",  linkblock_allocate_seg1_dataptr, linkblock_allocate_seg1_size, false) end
	if linkblock_allocate_seg3_size ~= 0 then eeOverlay.Register(linkblock_allocate_name .. ".seg3",  linkblock_allocate_seg3_dataptr, linkblock_allocate_seg3_size, true)  end

	if (g_OnOverlayRegistered ~= nil) then
		-- Make sure to execute any previously registered OnOverlay handler
		if linkblock_allocate_seg1_size ~= 0 then g_OnOverlayRegistered(linkblock_allocate_name .. ".seg1", linkblock_allocate_seg1_dataptr, linkblock_allocate_seg1_size)	end
		if linkblock_allocate_seg1_size ~= 0 then g_OnOverlayRegistered(linkblock_allocate_name .. ".seg3", linkblock_allocate_seg3_dataptr, linkblock_allocate_seg3_size)	end
	end
end

assert(g_OnOverlayRegistered ~= nil)
local prev_OnOverlayRegistered = g_OnOverlayRegistered

g_OnOverlayRegistered = function(filename, start, size)
	
	if filename == "depth-cue.seg1" then
		-- Disable full-screen post process via depth-cue.
		-- This also removes half-pixel shift during interlacing.
		-- <depth-cue.seg1+00039c>
		-- 00701DFC:67BDFFF0                daddiu       $sp,$sp,-0x10 (0xfffffff0)		-> 	03E00008                jr           $ra
		-- 00701E00:FFBE0008                sd           $fp,8($sp)                     -> 	00000000				nop

		eeObj.WriteMem32(start + 0x39c, 0x03E00008)
		eeObj.WriteMem32(start + 0x3a0, 0x00000000)
		eeObj.WriteMem32(start + 0x004, 0x03E00008)
		eeObj.WriteMem32(start + 0x008, 0x00000000)
	end

	if (prev_OnOverlayRegistered ~= nil) then
		-- Make sure to execute any previously registered OnOverlay handler
		prev_OnOverlayRegistered(filename, start, size)
	end
end

-- hooked in link_control::finish(void)>:
eeObj.AddHook(0x0010ACF8, 0x040C825, DH8)  -- this is address US:0010abe0 JP:0010abd8 EU:0010ACF8
#Graphical fix, removal of intensive post process effects.

SCES-50361
SCES-50361_features.lua

This is a substantial file. Over 700 lines with an extensive graphical and control fix. I'm sharing the file itself as a download link.

https://drive.google.com/file/d/1KppgZpiK5bgESrpSRKo6kKPTysZ-NAC9/view

#Shadows fix, control scheme changes, forced 60Hz/NTSC/Widescreen.

Harvest Moon®: A Wonderful Life Special Edition

CUSA06584
CLI

--ee-cycle-scalar=0.78

CUSA06584
LUA

apiRequest (1.7)

local eeObj = getEEObject()
local gpr = require("ee-gpr-alias")

-- 00107be0 <syncV>: idle loop on vsync
eeNativeHook (0x107c14, 0x3c03005d,"FastForwardClock", 0)

eeNativeFunction(0x44f3f8, 0x27bdffd0, 'ieee754_acosf')
eeNativeFunction(0x44f820, 0x27bdffd0, 'ieee754_asinf')
eeNativeFunction(0x450930, 0x44036000, 'ieee754_sqrtf')
eeNativeFunction(0x452848, 0x0080102d, 'fabs')
eeNativeFunction(0x453080, 0x27bdffd0, 'cosf')
eeNativeFunction(0x453158, 0x27bdfff0, 'fabsf')
eeNativeFunction(0x453320, 0x27bdffd0, 'sinf')
eeNativeFunction(0x4534b0, 0x27bdfff0, 'acosf')
eeNativeFunction(0x4534c8, 0x27bdfff0, 'asinf')
eeNativeFunction(0x453510, 0x27bdfff0, 'sqrtf')
eeNativeFunction(0x4552d8, 0x27bdffd0, 'fptoui')
eeNativeFunction(0x455298, 0x27bdffd0, 'fptodp')
eeNativeFunction(0x455d48, 0x27bdffd0, 'litodp')
eeNativeFunction(0x455e00, 0x27bdffc0, 'dptoli')
eeNativeFunction(0x455ed0, 0x27bdffc0, 'dptofp')
eeNativeFunction(0x45d580, 0x0080402d, 'memcpy')
eeNativeFunction(0x45d738, 0x2cc20008, 'memset')
eeNativeFunction(0x45fde8, 0x30820007, 'strlen')

eeInsnReplace(0x4443e0, 0x24030064, 0x03e00008)                 -- <FlushCache>
eeInsnReplace(0x4443e4, 0x0000000c, 0x00000000)
eeNativeHook (0x4443e0, 0x03e00008,'AdvanceClock',0x800)
eeInsnReplace(0x444410, 0x2403ff98, 0x03e00008)                 -- <iFlushCache>
eeInsnReplace(0x444414, 0x0000000c, 0x00000000)
eeNativeHook (0x444410, 0x03e00008,'AdvanceClock',0x800)
eeInsnReplace(0x444a58, 0x27bdffc0, 0x03e00008)                 -- <SyncDCache>
eeInsnReplace(0x444a5c, 0xffb20020, 0x00000000)
eeNativeHook (0x444a58, 0x03e00008,'AdvanceClock',0x800)
eeInsnReplace(0x444b98, 0x27bdffc0, 0x03e00008)                 -- <InvalidDCache>
eeInsnReplace(0x444b9c, 0xffb20020, 0x00000000)
eeNativeHook (0x444b98, 0x03e00008,'AdvanceClock',0x800)

-- bug#10318 : workaround...
eeObj.AddHook(0x3ce0fc,	0x0200202d, function()
				 local sign = (eeObj.GetGpr(gpr.v1) >> 31) & 1
				 if sign then
					eeObj.SetPc(0x3ce118)
				 end
end)


Jak 3

LUA
SCUS-97330

apiRequest(2.3)

local gpr    	= require("ee-gpr-alias")
local emuObj 	= getEmuObject()	
local eeObj	 	= getEEObject()
local gsObj		= getGsObject()
local eeOverlay = eeObj.getOverlayObject()

-- 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  } )

-- Disabled due to embossing effect problem --jstine
--emuObj.SetGsTitleFix( "trianglesAsParticles", "reserved", { hasClut=1,zmsk=1 } )


-- All JAK titles have a silly way of obtaining the PS2 Timestamp Counter. A binary code snippet is written
-- into a NON-CONST array, like so:  static u32 getTSC[] = { 0x40024800, 0x03E00008 }; and then that snippet is
-- called via:  ((u32 (*)())getTSC)()
--
-- Actual disasm of snippet:
--    129780:40024800     mfc0         $v0,$count
--    129784:03E00008     jr           $ra
--
-- Because the code is right next to data in the .data section of the process, the emulator's page fault protection
-- gets tripped up constantly and the code must be re-validated on every invocation.  Interesting aside: had the devs
-- marked the array as 'const' and thus had it placed in .ro_data, there wouldn't be a perf issue in the emu since
-- page invalidations only occur on writes.
--
-- Solution: rewrite the code which calls this function to simply execute mfc0 inline instead.  Typical pattern which
-- invokes the PS2 TSC read:
--    108c80:8c629790 	lw	v0,-26736(v1)
--    108c84:0040f809 	jalr	v0

-- Replace four separate instances:
eeInsnReplace(0x108a78, 0x8c629790, 0x40024800)			--  lw	    v0,-26736(v1)	-> mfc0      $v0,$count
eeInsnReplace(0x108a7c, 0x0040f809, 0x00000000)			--  jalr	v0           	-> jr        $ra
eeInsnReplace(0x108c80, 0x8c629790, 0x40024800)			--  lw	    v0,-26736(v1)	-> mfc0      $v0,$count
eeInsnReplace(0x108c84, 0x0040f809, 0x00000000)			--  jalr	v0           	-> jr        $ra
eeInsnReplace(0x108ea4, 0x8c629790, 0x40024800)			--  lw	    v0,-26736(v1)	-> mfc0      $v0,$count
eeInsnReplace(0x108ea8, 0x0040f809, 0x00000000)			--  jalr	v0           	-> jr        $ra
eeInsnReplace(0x10902c, 0x8c629790, 0x40024800)			--  lw	    v0,-26736(v1)	-> mfc0      $v0,$count
eeInsnReplace(0x109030, 0x0040f809, 0x00000000)			--  jalr	v0           	-> jr        $ra

-- ------------------------- OVERLAY MANAGER --------------------------
g_OnOverlayRegistered = function(filename, start, size)
	-- global function provided for adding per-overlay callback handlers.
end

local DH8 = function()
	local s1 		= eeObj.GetGpr    (gpr.s1)
	local filename 	= eeObj.ReadMemStr(s1 + 17)
	local segment 	= eeObj.ReadMem32 (s1 +  8)
	local main 		= eeObj.ReadMem32 (segment +  4)
	local mainSize 	= eeObj.ReadMem32 (segment +  8)
	local top 		= eeObj.ReadMem32 (segment + 36)
	local topSize 	= eeObj.ReadMem32 (segment + 40)

	if emuObj.IsToolingVerbose() then
		print( string.format("--> LOADED SEGMENT \"%s\" MAIN %08x size %x TOP %08x size %x", filename, main, mainSize, top, topSize) )
	end

	eeOverlay.Register(filename .. ".main", main, mainSize, false)
	eeOverlay.Register(filename .. ".top",  top,  topSize,  true )

	--local debugObj	= getDebugObject()
	--debugObj.eDumpDisasmToFile ("./DisasmGoal/Jak3/" .. filename .. ".main.dasm", main, mainSize, 0)
	--debugObj.eDumpDisasmToFile ("./DisasmGoal/Jak3/" .. filename .. ".top.dasm",  top,  topSize,  0)
	--debugObj.eDumpAotToFile    ("./DisasmGoal/Jak3/" .. filename .. ".main.aot",  main, mainSize, 0)
	--debugObj.eDumpAotToFile    ("./DisasmGoal/Jak3/" .. filename .. ".top.aot",   top,  topSize,  0)

	if (g_OnOverlayRegistered ~= nil) then
		-- Make sure to execute any previously registered OnOverlay handler
		g_OnOverlayRegistered(filename .. ".main", main, mainSize)
		g_OnOverlayRegistered(filename .. ".top",  top,  topSize )
	end

end

eeObj.AddHook(0x1091d4, 0x0080c825, DH8)    --     <ndi::link_control::finish(void)>:

-- --------------------------------------------------------------------
assert(g_OnOverlayRegistered ~= nil)
local prev_OnOverlayRegistered = g_OnOverlayRegistered

g_OnOverlayRegistered = function(filename, start, size)
	if (prev_OnOverlayRegistered ~= nil) then
		-- Make sure to execute any previously registered OnOverlay handler
		prev_OnOverlayRegistered(filename, start, size)
	end

	if filename == "sparticle-launcher.main" then
		-- this RNG-sqrt instance is removed for performance.  Additionally, not corrupting the RNG seed with
		-- bad sqrt math is always a good thing in my book --jstine

		assert(eeObj.ReadMem32(start + 0x005de4) == 0x4be1043d)		--	vrget.wxyz   vf01,r
		assert(eeObj.ReadMem32(start + 0x005de8) == 0x4a0103bd)		--	vsqrt        q,vf01x
		assert(eeObj.ReadMem32(start + 0x005df0) == 0x4b0000a0)		--	vaddq.x      vf02,vf00,q

		assert(eeObj.ReadMem32(start + 0x005e4c) == 0x4a00143f)		--	vrxor        r,vf02x
		assert(eeObj.ReadMem32(start + 0x005ef8) == 0x4a00143f)		--	vrxor        r,vf02x
		assert(eeObj.ReadMem32(start + 0x005f80) == 0x4a00143f)		--	vrxor        r,vf02x
		assert(eeObj.ReadMem32(start + 0x006018) == 0x4a00143f)		--	vrxor        r,vf02x

		eeObj.WriteMem32(start + 0x005de4, 0x00000000)
		eeObj.WriteMem32(start + 0x005de8, 0x00000000)
		eeObj.WriteMem32(start + 0x005df0, 0x00000000)

		eeObj.WriteMem32(start + 0x005e4c, 0x00000000)
		eeObj.WriteMem32(start + 0x005ef8, 0x00000000)		
		eeObj.WriteMem32(start + 0x005f80, 0x00000000)		
		eeObj.WriteMem32(start + 0x006018, 0x00000000)		
	end
end

-- --------------------------------------------------------------------------------------
-- diagnostic for checking the Jak engine's internal frame skipping mechanism.
-- $fp30 contains a ratio of time-taken-to-16ms to render the scene, eg. 18 ms is approx 1.15.
-- The engine will proceed to make a series of logical decisions according to this value.
-- The value read out here will be affected by both EE cycle rates and adaptive GS penalties.
-- I tried modifiying this value directly but it gives somewhat unsatisfactory results.

-- eeOverlay.AddPreHook("drawable.main",0x208+8, 0x461E0034, function()
-- 	local v1 = eeObj.GetGpr(gpr.v1)
-- 	print(string.format("fpuCompare fpr0=%f fpr30=%f", eeObj.GetFpr(0), eeObj.GetFpr(30)))
-- end)
-- --------------------------------------------------------------------------------------

Jak 2

CLI
SCUS-97265

--ee-jit-pagefault-threshold=20
--gs-frontend-opt-mode=1
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--cop2-no-clamping=1
--cop2-clamp-range=0x2A18,0x2a20,joint.seg1
--vu1-mpg-cycles=250

LUA
SCUS-97265

apiRequest(2.2)

local gpr    		= require("ee-gpr-alias")
local emuObj 		= getEmuObject()
local eeObj			= getEEObject()
local eeOverlay 	= eeObj.getOverlayObject()
local iopObj     	= getIOPObject()
local gsObj			= getGsObject()


-- 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  } )

---------------------------------------------------------------------------------
-- Basic Block breakers for EE AOT Injection
eeOverlay.AddPreHook("traffic-engine.seg1", 0x004474, 0x0080e025, "nop" )
eeOverlay.AddPreHook("spatial-hash.seg1", 	0x004474, 0x0080e025, "nop" )

---------------------------------------------------------------------------------

-- ------------------------- OVERLAY MANAGER --------------------------
g_OnOverlayRegistered = function(filename, start, size)
	-- global function provided for adding per-overlay callback handlers.
end

local DH8 = function()
	local s0 = eeObj.GetGpr(gpr.s0)
	
	local linkblock = eeObj.ReadMem32(s0+0x60) -- was 0x5c on Jak1
	
	--print( string.format("--> PRELOAD %08x %08x",s0, linkblock) )
	
	local linkblock_allocate_length 		= eeObj.ReadMem32 (linkblock + 0x00)
	local linkblock_allocate_version 		= eeObj.ReadMem32 (linkblock + 0x04)
	local linkblock_allocate_segment_count 	= eeObj.ReadMem32 (linkblock + 0x08)
	local linkblock_allocate_name 			= eeObj.ReadMemStr(linkblock + 0x0c)
	
	local linkblock_allocate_seg1_linkptr 	= eeObj.ReadMem32 (linkblock + 0x4C)
	local linkblock_allocate_seg1_dataptr 	= eeObj.ReadMem32 (linkblock + 0x50)
	local linkblock_allocate_seg1_size 		= eeObj.ReadMem32 (linkblock + 0x54)
	local linkblock_allocate_seg1_flags 	= eeObj.ReadMem32 (linkblock + 0x58)
                                                              
	local linkblock_allocate_seg2_linkptr 	= eeObj.ReadMem32 (linkblock + 0x5C)
	local linkblock_allocate_seg2_dataptr 	= eeObj.ReadMem32 (linkblock + 0x60)
	local linkblock_allocate_seg2_size 		= eeObj.ReadMem32 (linkblock + 0x64)
	local linkblock_allocate_seg2_flags 	= eeObj.ReadMem32 (linkblock + 0x68)
                                                              
	local linkblock_allocate_seg3_linkptr 	= eeObj.ReadMem32 (linkblock + 0x6C)
	local linkblock_allocate_seg3_dataptr 	= eeObj.ReadMem32 (linkblock + 0x70)
	local linkblock_allocate_seg3_size 		= eeObj.ReadMem32 (linkblock + 0x74)
	local linkblock_allocate_seg3_flags 	= eeObj.ReadMem32 (linkblock + 0x78)
	
	-- seg1 is equiv to main in Jak3
	-- seg3 is equiv to top  in Jak3
	-- seg2 appears to be unused ... ?   --jstine (it's a debug segment, so likely unused on retail) DH

	if emuObj.IsToolingVerbose() then
		print( string.format("--> LOADED SEGMENT alloc_len %08x ver %08x segcount %08x  name:\"%s\"", linkblock_allocate_length, linkblock_allocate_version, linkblock_allocate_segment_count, linkblock_allocate_name) )
		print( string.format("    seg1linkptr %08x seg1dataptr %08x seg1size %08x seg1flags %08x", linkblock_allocate_seg1_linkptr, linkblock_allocate_seg1_dataptr, linkblock_allocate_seg1_size, linkblock_allocate_seg1_flags) )
		print( string.format("    seg2linkptr %08x seg2dataptr %08x seg2size %08x seg2flags %08x", linkblock_allocate_seg2_linkptr, linkblock_allocate_seg2_dataptr, linkblock_allocate_seg2_size, linkblock_allocate_seg2_flags) )
		print( string.format("    seg3linkptr %08x seg3dataptr %08x seg3size %08x seg3flags %08x", linkblock_allocate_seg3_linkptr, linkblock_allocate_seg3_dataptr, linkblock_allocate_seg3_size, linkblock_allocate_seg3_flags) )
	end

--	local debugObj	= getDebugObject()
--	debugObj.eDumpDisasmToFile("./DisasmGoal/JakII/" .. linkblock_allocate_name .. ".seg1.dasm", linkblock_allocate_seg1_dataptr, linkblock_allocate_seg1_size, 0)
--	debugObj.eDumpDisasmToFile("./DisasmGoal/JakII/" .. linkblock_allocate_name .. ".seg3.dasm", linkblock_allocate_seg3_dataptr, linkblock_allocate_seg3_size, 0)
--	debugObj.eDumpAotToFile   ("./DisasmGoal/JakII/" .. linkblock_allocate_name .. ".seg1.aot",  linkblock_allocate_seg1_dataptr, linkblock_allocate_seg1_size, 0)
--	debugObj.eDumpAotToFile   ("./DisasmGoal/JakII/" .. linkblock_allocate_name .. ".seg3.aot",  linkblock_allocate_seg3_dataptr, linkblock_allocate_seg3_size, 0)

	if linkblock_allocate_seg1_size ~= 0 then eeOverlay.Register(linkblock_allocate_name .. ".seg1",  linkblock_allocate_seg1_dataptr, linkblock_allocate_seg1_size, false) end
	if linkblock_allocate_seg3_size ~= 0 then eeOverlay.Register(linkblock_allocate_name .. ".seg3",  linkblock_allocate_seg3_dataptr, linkblock_allocate_seg3_size, true)  end

	if (g_OnOverlayRegistered ~= nil) then
		-- Make sure to execute any previously registered OnOverlay handler
		if linkblock_allocate_seg1_size ~= 0 then g_OnOverlayRegistered(linkblock_allocate_name .. ".seg1", linkblock_allocate_seg1_dataptr, linkblock_allocate_seg1_size)	end
		if linkblock_allocate_seg1_size ~= 0 then g_OnOverlayRegistered(linkblock_allocate_name .. ".seg3", linkblock_allocate_seg3_dataptr, linkblock_allocate_seg3_size) end
	end
end

assert(g_OnOverlayRegistered ~= nil)
local prev_OnOverlayRegistered = g_OnOverlayRegistered

g_OnOverlayRegistered = function(filename, start, size)
	if (prev_OnOverlayRegistered ~= nil) then
		-- Make sure to execute any previously registered OnOverlay handler
		prev_OnOverlayRegistered(filename, start, size)
	end

	if filename == "sparticle-launcher.seg1" then
		-- this RNG-sqrt instance is removed for performance.  Additionally, not corrupting the RNG seed with
		-- bad sqrt math is always a good thing in my book --jstine

		assert(eeObj.ReadMem32(start + 0x0044ec) == 0x4be1043d)		--	vrget.wxyz   vf01,r
		assert(eeObj.ReadMem32(start + 0x0044f0) == 0x4a0103bd)		--	vsqrt        q,vf01x
		assert(eeObj.ReadMem32(start + 0x0044f8) == 0x4b0000a0)		--	vaddq.x      vf02,vf00,q

		assert(eeObj.ReadMem32(start + 0x00454c) == 0x4a00143f)		--	vrxor        r,vf02x
		assert(eeObj.ReadMem32(start + 0x0045f8) == 0x4a00143f)		--	vrxor        r,vf02x
		assert(eeObj.ReadMem32(start + 0x004680) == 0x4a00143f)		--	vrxor        r,vf02x
		assert(eeObj.ReadMem32(start + 0x004718) == 0x4a00143f)		--	vrxor        r,vf02x

		eeObj.WriteMem32(start + 0x0044ec, 0x00000000)
		eeObj.WriteMem32(start + 0x0044f0, 0x00000000)
		eeObj.WriteMem32(start + 0x0044f8, 0x00000000)

		eeObj.WriteMem32(start + 0x00454c, 0x00000000)
		eeObj.WriteMem32(start + 0x0045f8, 0x00000000)		
		eeObj.WriteMem32(start + 0x004680, 0x00000000)		
		eeObj.WriteMem32(start + 0x004718, 0x00000000)		
	end
end

-- hooked in link_control::finish(void)>:
function install_c_hooks(offset)
	eeObj.AddHook(0x1085a0 + offset , 0x0080c825, DH8) 
end


local Ready = 0

local DetectFunc = function()
	if Ready == 0 then
	
		local discID = eeObj.ReadMemStr(0x0012fc8)
	
		if (discID ~= "") then
		
			if (discID == "cdrom0:\\SCUS_972.65;1") or (discID == "cdrom0:\\SCPS_150.57;1") then
				-- US or Japan Disc
				Ready = 1
				install_c_hooks(0)
				
				print( string.format("********************* DETECTED USA, JAPAN DISC ********************" ) )
			
			elseif (discID == "cdrom0:\\SCKA_200.10;1") then
				Ready = 1
				install_c_hooks(0x08)
				print( string.format("********************* KOREA DISC ********************" ) )
			
			elseif (discID == "cdrom0:\\SCES_516.08;1") then
				-- European Disc
				Ready = 1
				install_c_hooks(0xb8)
				
				print( string.format("********************* DETECTED EUROPE DISC (SCES-51608) ********************" ) )			
			
			
			elseif (discID == "rom0:PS2LOGO") then
				-- loading PS2 logo
			elseif (discID == "EELOAD") then
				-- loading?
			elseif (discID == "rom0:OSDSYS") then
				-- loading initial boot
			else
				print( string.format("--> DISC ID \"%s\"", discID ) )
			end
		
		end
		
	end	
end

emuObj.AddVsyncHook(DetectFunc)

Kinetica

CLI
SCUS-97132

--vu1-clamp-range=0x386,0x386
--vu1-clamp-range=0x5e0,0x5f0	# another gritches
--gs-kernel-cl-up="up2x2skipinterp"
--vu1-injection=1
--vu1-jr-cache-policy=sameprog
--vu1-jalr-cache-policy=sameprog
--vu1-mpg-cycles=900
--host-audio-latency=0.10
--cdvd-sector-read-cycles=40000

LUA
SCUS-97132

local gpr = require("ee-gpr-alias")
apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.

local emuObj  		= getEmuObject()
local eeObj         = getEEObject()

-- require("debughooks")
-- local iopObj = getIOPObject()
-- iopObj.AddHook(0x000135ac, 0x27bdffe0, DebugHooks.h_IOP_ioman_write)

-- bug#8123
-- Skip resetting VAG stream which happens on an error.
iopInsnReplace(0x00090028, 0x16220009, 0x08024014)	-- bne $s1,$v0,0x00090050 => j 0x00090050

-- bug#9405 - advance EE clock according to spinning-loop SIF activity.
 
local skip_syncDCache = function()
	-- Original value when actually processing syncDCache was 3300
	-- Boosting to 8000 helps reduce bottleneck
	eeObj.AdvanceClock(8000)
end

eeInsnReplace(0x1ca9e0, 0x27bdffe0, 0x03e00008)
eeInsnReplace(0x1ca9e4, 0x0080302d, 0x00000000)
eeObj.AddHookJT(0x1ca9e0, 0x03e00008, skip_syncDCache)

-- gametime to be from realtim....
-- # this causes the time elapses even while in pause. so bugged
-- # also maybe this causes 'negative' race time as well.
-- we should be OK even without this because skipping frame works (mostly).
-- 
-- local prevtime = 0.0
-- eeObj.AddHook(0x12350c,	0x27bdfec0, function()
-- 				 local curtime = os.clock()
-- 				 if prevtime ~= 0.0 then
-- 					eeObj.WriteMemFloat(eeObj.GetGpr(gpr.gp)-31776, curtime - prevtime)
-- 				 end
-- 				 prevtime = curtime
-- end)

-- to work skipping frame mechanism correctly...
-- the game checks a flag set by INTC GS whether GS still does his job or not to
-- determine whether it should skip a frame or not.
-- Unfortunately we don't have the actual timing of GS FINISH signal.
-- Instead of that, we check EE clock to determine to skip or not.

local ee_frequency = 294912000
local vsync_frequency = 59.94	-- use interlace freq. 

local one_vsync_clock_on_ntsc = math.floor(ee_frequency / vsync_frequency)


-- Kinetica has some inconsistency among frames -- some frames take unusually long, possibly due
-- to AI updates.  In these cases, it is necessary to skip multiple frames to catch the game's
-- clock back up to realtime.  To do so, we track 'expected_clock' over time, so that especially
-- slow frames are compensated for over time.

local prev_clock = 0
local expected_clock = 0

eeObj.AddHook(0x181f7c,	0x8f82bf54, function()
				-- It hits here when it skips a frame.
				--local diff = eeObj.GetClock() - prev_clock
				
				local clock = eeObj.GetClock()
				--local diff  = clock - expected_clock
				--print(string.format("SKIP FRAME: diff=%7d", diff))

				--prev_clock     = eeObj.GetClock()		-- just update the clock.
				expected_clock = expected_clock + one_vsync_clock_on_ntsc
end)
eeObj.AddHook(0x18202c, 0x8f84bf54, function()
				local clock = eeObj.GetClock()
				--local diff = clock - prev_clock
				--print(string.format("diff=%d vsync_term=%f %s", diff, one_vsync_clock_on_ntsc, diff > one_vsync_clock_on_ntsc and "SKIP" or ""))
				
				local diff = clock - expected_clock
				
				-- Sanity correction -- to handle cases where expected_clock contents is
				-- zero or out-dated.
				if (math.abs(diff) > (one_vsync_clock_on_ntsc * 6)) then
					expected_clock = clock
				end
				 
				-- print(string.format("diff=%7d %s", diff, diff > 17000 and "SKIP" or ""))
                
				if diff > 17000 then
					eeObj.SetGpr(gpr.a0, 1)
				end
                
				-- update clock
				--prev_clock     = clock
				expected_clock = expected_clock + one_vsync_clock_on_ntsc
end)


-- Applies a cycle rate hack to what I presume is the game logic pipeline, for roughly per-frame updates.

local mpgCycles_default	= 900
local currentMpgCycles = mpgCycles_default

local checkNeedsSpeedHack = function()
	local stageId    = eeObj.ReadMem32(0x01fce8c)
	local numPlayers = eeObj.ReadMem32(0x01ffd78)		-- 0x01ffd7c seems to always match this one...

	-- print(string.format("stageId = %d, numPlayers = %d", stageId, numPlayers))
	
	-- 3 = Electrica
	-- 7 = Electrica II
	-- 8 = Cliffhanger
	
	local newMpgCycles = mpgCycles_default
	if (stageId == 3 or stageId == 7 or stageId == 8) then

		-- note: this will also apply to demo loops (0 players)
		newMpgCycles = newMpgCycles + 120
		
		if stageId == 7 then
			-- Electrica 2 is extra-special slow in some areas.
			-- (and 2-player mode on this map runs enough mpgs that extra penalty isn't needed)
			if numPlayers == 2 then
				newMpgCycles = newMpgCycles - 100
			else
				newMpgCycles = newMpgCycles + 275
			end
		elseif numPlayers == 2 then
			-- increment is not so big here because two player mode already runs many more VU programs.
			newMpgCycles = newMpgCycles + 100
		end

	end

	if currentMpgCycles ~= newMpgCycles then
		-- print ( string.format("################### Setting mpg-cycles = %d", newMpgCycles) )
		eeObj.Vu1MpgCycles(newMpgCycles)
		currentMpgCycles = newMpgCycles
	end
end

eeObj.AddHookJT(0x15ca2c,0x27bdff20,checkNeedsSpeedHack)

King of Fighters 98 Ultimate Match

ALL
CLI

--force-frame-blend=1
--gs-use-deferred-l2h=0
#Graphical fix.

SLES_552.80
SLES-55280_features.lua

This is a substantial file. Over 800 lines with additional controller/fightstick support and various shader/bezel files. I'm sharing the file itself as a download link.

https://drive.google.com/file/d/1-lArL1Yqe079Ni3G-ZtHr8hqNPUsjQJy/view

#More stick support, shaders, bezels, widescreen fix.

King of Fighters 2000

ALL
CLI

--gs-uprender=none
--gs-upscale=point
--host-audio-latency=0.01
--hid-pad=1
#graphical fixes and support for further fightsticks.

SLUS_208.34
LUA

-- The King of Fighters 2000

apiRequest(1.1)


local emuObj 	= getEmuObject()
--will fix sprite rendering artifact
ndx = 28
val = 0x86
-- spriteCorrectionTab[ndx] = val
emuObj.SetGsTitleFix( "globalSet",  "reserved", { fixSpriteDivTab = val | ( ndx<<16) })
#graphical fixes.

SLUS_208.34
SLUS-20834_features.lua

This is a substantial file. Over 700 lines with additional controller/fightstick support and various shader/bezel files. I'm sharing the file itself as a download link.

https://drive.google.com/file/d/1FsPnuxgEa0ymnGdU6w2tdy-eamRN6l3e/view

#More stick support, shaders, bezels, widescreen fix.

Manhunt

SLUS_208.27
CLI

--ee-hook=0x4329e0,FastForwardClock,0x1600fff1
--gs-uv-shift-pointsampling=1
--ee-hook=0x1d1d60,AdvanceClock,0x27bdffb0,225
--ee-hook=0x1d71e0,AdvanceClock,0x0c09a4d0,100
#Fix crane issue, and probably fixing lightsourcing.

SLUS_208.27
Lua

-- Manhunt [US]

local gpr = require('ee-gpr-alias')

apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.

local emuObj = getEmuObject()	
local eeObj  = getEEObject()

-- Bug #9413
-- 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} )

-- Bug#9277
-- Shorten the timeout period for some particular execution command(s).
-- When entering the crane, some instruction is executed with a wait period of 0x7333.
-- Shortening the wait period to 0x4000 it.  Note that 0x5000 is enough to fix entering the
-- crane once, but a more aggressive value was needed for subsequent entry into the crane.

local FixBug9277 = function()
	local s0 = eeObj.GetGpr(gpr.s0)
	--local v0 = eeObj.GetGpr(gpr.v0)
	--print( string.format("-------- v0=0x%08x s0=0x%08x", v0, s0) )
	if s0 == 0x7333 then 
		eeObj.SetGpr(gpr.s0, 0x5800)
	end
end

-- No longer seems necessary, when FastForwardClock is applied here instead (see _cli.conf)
eeObj.AddHookJT(0x1d71f8, 0x10000036, FixBug9277)
#Further bug fixes as well as fixing bloom/overglare from lightsources.

Max Payne

SLES_503.26
CLI

--gs-use-clut-merge=1
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"
--vu1-no-clamping=1
--vu0-no-clamping=1
--fpu-no-clamping=1
--force-pal-60hz=1
--vu1-mpg-cycles=1000
--safe-area-min=1.0
--fpu-accurate-mul-fast=1
--fpu-accurate-muldiv-range=0x2acce0,0x2acce0

#Graphics clean-up

SLES_503.26
Features Lua

-- Max Payne [US]

-- Lua 5.3
-- Title: Max Payne - SLES-50326 (Europe FIGS) v1.00


require( "ee-gpr-alias" ) -- you can access EE GPR by alias (gpr.a0 / gpr["a0"])

apiRequest(0.2)	-- request version 0.2 API for throttling control.

local eeObj		= getEEObject()
local emuObj	= getEmuObject()



local TH1A =	-- start of main()
	function()
		emuObj.ThrottleMax()
	end

local TH1B =	-- init loading screen
	function()
		local mode = eeObj.GetGpr(gpr.a0)

		if mode ~= 4 then	-- not sure what mode 4 is, but doesn't precede a real loading
			emuObj.ThrottleMax()
		end
	end

local TH1C =	-- advance progress bar
	function()
		local pct = eeObj.GetFpr(2)

		if pct >= 1.0 then
			emuObj.ThrottleNorm()
		end
	end



-- register hooks

local registeredHooks = {}

maxpayne_features_unregisterHooks = function()	-- global function (called by trophy_data)
	for _, hook in pairs(registeredHooks) do
		eeObj.RemoveHook(hook)
	end
	
	registeredHooks = {}
end

maxpayne_features_registerHooks = function()	-- global function (called by trophy_data)
	registeredHooks = {
		eeObj.AddHook(0x133dc8, 0x24030001, TH1A),	-- <main>:
		eeObj.AddHook(0x15ed7c, 0x24030003, TH1B),	-- <MaxPayne_GameMode::initLoadingScreen(void)>:
		eeObj.AddHook(0x133078, 0xc4a20000, TH1C),	-- <UpdateProgressBarKH(void)>:
	}
end

Metal Slug Anthology

ALL
CLI

--host-audio-latency=0.010
--gs-upscale=point
--gs-uprender=none
#fix for graphical glitches.

SLUS_215.50
LUA

-- Metal Slug Anthology PS2 - SLUS-21550 (USA)

apiRequest(1.2)	-- request version 0.1 API. Calling apiRequest() is mandatory.

local eeObj		= getEEObject()
local emuObj	= getEmuObject()

-- Fix for black screen booting an elf. This is a game bug.
-- The v1.0 of the game suffered from an intermittent bug on the real PS2
-- where sometimes it would hang on a black screen trying to launch a new elf.
-- This is apparently due to a bad IOP state, which caused sceCdInit to hang.
-- Later versions of the game (1.1, 1.2) attempted to fix this in different ways.
-- On Olympus, v1.0 (USA) hangs always, while v1.2 (EUR/JPN) works always.
-- The fix implemented here replaces a call to FlushCache() to loadImageAndReboot(),
-- which is a function that reboots the IOP and resolves the hang.

eeInsnReplace(0x189c24, 0x0c08f7f8, 0x0c061dd2) -- FlushCache() -> loadImageAndReboot()
eeInsnReplace(0x117804, 0x0c0c1e08, 0x0c045e20) -- FlushCache() -> loadImageAndReboot()

Okage

TXT
SCUS-97129

--vu1-mpg-cycles=50
--vu1-mpg-cycles=850,$037,$7b3
--vu1-mpg-cycles=150,$2b4,$7c4

LUA
SCUS-97129

require("ee-gpr-alias")
require("ps2")
apiRequest(0.6)	-- request version 0.1 API. Calling apiRequest() is mandatory.

local eeObj = getEEObject()

-- bug#8740
-- SPSetDirect(addr, char-pos, char-pos, x-coord, y-coord, width, height)
-- reduce width just 1 pix.
local Replace_1a1fb0 = InsnOverlay( {
	0x0806720a, --        j       0x19c828
	0x2529ffff, --        addiu   t1,t1,-1
})
eeInsnReplace(0x1a1fb0,	0x0c06720a, 0x0c000000 | (Replace_1a1fb0>>2)) -- 	jal	19c828 <SPSetDirect>

Parappa the Rapper 2

ALL
CLI

--host-audio-latency=0.01

#fix for audio off sync.

SCUS_971.67
LUA


-- Parappa the Rapper 2  [SCUS-97167]


apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.

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

local eeObj = getEEObject()

-- ================================================================================================
-- Title issues racy combination of VIF1 and GIF transfers.  It expects GIF to finish ahead of VU
-- XGKICK (via VIF1), which is atypical among PS2 titles (XGKICK has HW priority over GIF, and so
-- GIF can only finish ahead of XGKICK in certain extreme cases).
--
-- Fixed by delaying the specific VIF1 transfer (identified by MADR) for a long time to ensure GIF
-- gains arbitration and finishes ahead of XGKICKs.
--
local fix01_dma_vif1 = 
	function()
		local ee		= eeObj
		local tgtaddr	= ee.GetGpr(gpr.s0)

		-- print( string.format("success pt.1 : %x %x", vif1_hw.CHCR, tgtaddr ) )

		if tgtaddr == vif1_hw.CHCR then

			-- expected:
			--  # DIR==1 and MOD==1  (chain)
			--  # TADR==0x01C76AA0

			local chcr = ee.GetGPR(gpr.v0)

			if (chcr & 0x05) == 0x05 then
				local tadr = ee.ReadMem32(vif1_hw.TADR);
				if tadr == 0x01C76AA0 then
					-- 0x6000 works fine, 0x6500 adds a little extra cushion.
					ee.SchedulerDelayEvent("vif1.dma", 0x6500)
					-- print( "Parappa fix applied!" )
				end
			end
		end
	end
-- ================================================================================================

eeObj.AddHook(0x0015A008, 0xAE020000, fix01_dma_vif1)

-- ================================================================================================
-- Our emulator has accuracy problems on so many places. In this title, we have problems on VU.
-- To be accurate on VU is quite painful (we won't be able to get reasonable performance with it)
-- So as workaround, we just disable bilinear textures on Render-To-Texture drawing.
-- Bug#8122
eeInsnReplace(0x118084, 0xde260008, 0x24060000) -- 	ld	a2,8(s1)
eeInsnReplace(0x118798,	0xde260008, 0x24060000) -- 	ld	a2,8(s1)
eeInsnReplace(0x118868,	0xde660008, 0x24060000) -- 	ld	a2,8(s3)
eeInsnReplace(0x119d18,	0xdc460008, 0x24060000) -- 	ld	a2,8(v0)
eeInsnReplace(0x119d18,	0xdc460008, 0x24060000) -- 	ld	a2,8(v0)

Primal

CLI

--vu1-mul0fix-range=0x22f,0x22f
--vu1-mul0fix-range=0x298,0x29c
--vu1-native-patch=1
--ee-hook=0x2f76c0,FastForwardClock,0x1200ffbf
--vu1-mpg-cycles=700
--gs-kernel-cl-up="up2x2Simple"
--cop2-no-clamp-range=0x37bd78,0x37c514     ;; CMatrix functions           
--cop2-no-clamp-range=0x38c0e0,0x38c174     ;; CModel::CalcSkinningMatrices
--cop2-no-clamp-range=0x391cf0,0x392084     ;; CSkelton::Update            

LUA

-- Primal  [EU]

apiRequest(1.1)

local eeObj 	= getEEObject()
local emuObj 	= getEmuObject()

-- Bug 9094 - Title exhibits poor performance due to VU0 spin loops.
-- The spin loops are meant to be an optimizaion on PS2 and the best way of handling them is
-- to remove them from the original code.  This can be done since the VF09 register is unsed by
-- the first portion of the VU0 mpg.
--
-- Insn replacements Summarized:
--   1. NOP the spin loop from VU0.
--   2. NOP the setup code for VI05, which is the reg tested by the VU0 spin loop
--   3. Reorder the vcallms and qmtc2.


-- [$167:520507ff] IBNE vi05, vi00, [$167]
-- [$167:000002ff] NOP
local orig = (0x000002ff << 32) | 0x520507ff

vuInsnReplace(0, 0x167, orig, 0x8000033c | (0x000002ff << 32))		-- NOP / NOP2
vuInsnReplace(0, 0x172, orig, 0x8000033c | (0x000002ff << 32))		-- NOP / NOP2

local region_base = 0x399c5c

eeInsnReplace(region_base + 0x000,	0x24040001, 0x00000000)   	--	li	a0,1			-> NOP
eeInsnReplace(region_base + 0x010,	0x48c42800, 0x00000000)   	--	ctc2.ni	a0,$5       -> NOP
eeInsnReplace(region_base + 0x090,	0x24040001, 0x00000000)   	--	li	a0,1            -> NOP
eeInsnReplace(region_base + 0x0a0,	0x48c42800, 0x00000000)   	--	ctc2.ni	a0,$5       -> NOP

eeInsnReplace(region_base + 0x05c,	0x48c02800, 0x00000000)		-- ctc2.ni	zero,$5		-> NOP
eeInsnReplace(region_base + 0x114,	0x48c02800, 0x00000000)		-- ctc2.ni	zero,$5		-> NOP

eeInsnReplace(region_base + 0x054,  0x4a00d839, 0x48a44800) 	-- vcallmsr	vi27		-> qmtc2	a0,vf9
eeInsnReplace(region_base + 0x058,  0x48a44800, 0x4a00d839) 	-- qmtc2	a0,vf9		-> vcallmsr	vi27
eeInsnReplace(region_base + 0x10c,	0x4a00d839, 0x48a44800)		-- vcallmsr	vi27		-> qmtc2	a0,vf9
eeInsnReplace(region_base + 0x110,	0x48a44800, 0x4a00d839)		-- qmtc2	a0,vf9		-> vcallmsr	vi27

-- remove heat haze distortion ( for performance reason Bug#8827 )
--  reg = 0x42  packedFlags = 3( iip, tme, fst)   packedPrim  = 5(SCE_GS_PRIM_TRIFAN)
emuObj.SetGsTitleFix( "globalSet",  "reserved", { packedRegsLo = 0x42,packedRegsHi = 0, packedRegsNum = 2, packedFlags = 3, packedPrim = 5})
emuObj.SetGsTitleFix( "skipPacked", "reserved", { alpha = 0x80000044, tbp = 0x3a4000 , zmsk=1 })
emuObj.SetGsTitleFix( "skipPacked", "reserved", { alpha = 0x80000044, tbp = 0x348000 , zmsk=1 })


-- NOP out cacheline prefetch instructions.
-- Prefetch might have been a good idea on PS2, but it is entirely unhelpful on the PS4 target.
if 1 then 
	eeInsnReplace(0x381e60, 0x78400040, 0x00000000)		-- 	lq	zero,64(v0)
	eeInsnReplace(0x3822c0, 0x78400040, 0x00000000)		-- 	lq	zero,64(v0)
	eeInsnReplace(0x38ec7c, 0x78800040, 0x00000000)		-- 	lq	zero,64(a0)
	eeInsnReplace(0x38ed78, 0x78600040, 0x00000000)		-- 	lq	zero,64(v1)
	eeInsnReplace(0x38eec0, 0x78a00040, 0x00000000)		-- 	lq	zero,64(a1)
	eeInsnReplace(0x38fe28, 0x7a600040, 0x00000000)		-- 	lq	zero,64(s3)
	eeInsnReplace(0x38fea4, 0x78800040, 0x00000000)		-- 	lq	zero,64(a0)
	eeInsnReplace(0x390da8, 0x78400040, 0x00000000)		-- 	lq	zero,64(v0)
	eeInsnReplace(0x391020, 0x78400040, 0x00000000)		-- 	lq	zero,64(v0)
	eeInsnReplace(0x391174, 0x78a00040, 0x00000000)		-- 	lq	zero,64(a1)
	eeInsnReplace(0x3912b0, 0x78a00040, 0x00000000)		-- 	lq	zero,64(a1)
	eeInsnReplace(0x398790, 0x7a000040, 0x00000000)		-- 	lq	zero,64(s0)
	eeInsnReplace(0x399e60, 0x78400050, 0x00000000)		-- 	lq	zero,80(v0)
	eeInsnReplace(0x399ee8, 0x78400050, 0x00000000)		-- 	lq	zero,80(v0)
end

-- NOP out an idle loop meant to flush some cache lines...
if 1 then
	eeInsnReplace(0x331038, 0x18a00009, 0x00000000)		--  blez	a1,331060 <CDMAStreamIterator::AllocateBlock(unsigned int)+0x110>
	eeInsnReplace(0x33103c, 0x00d41821, 0x00000000)		--  addu	v1,a2,s4
	eeInsnReplace(0x331040, 0xbc5a0000, 0x00000000)		--  cache	0x1a,0(v0)
	eeInsnReplace(0x331044, 0x24a5ffff, 0x00000000)		--  addiu	a1,a1,-1
	eeInsnReplace(0x331054, 0x1ca0fffa, 0x00000000)		--  bgtz	a1,331040 <CDMAStreamIterator::AllocateBlock(unsigned int)+0xf0>
	eeInsnReplace(0x331058, 0x24420040, 0x00000000)		--  addiu	v0,v0,64
end
  
-- perf. fix bug 9094
emuObj.SetGsTitleFix( "globalSet", "reserved", {ignoreUpRenderTimeout=2} )
emuObj.SetGsTitleFix( "ignoreUpRender",  230, {} )
emuObj.SetGsTitleFix( "ignoreAreaUpdate", 0, { alpha=0x00000000 } )
emuObj.SetGsTitleFix( "ignoreAreaUpdate", 0, { alpha=0x80000048 } )

Red Dead Revolver


SLUS-20500
CLI

--gs-kernel-cl-up="up2x2skipInterp"
--fpu-rsqrt-fast-estimate=0
--mtap1=Always
--vif1-ignore-cmd-ints=1
--iop-cycle-scalar=0.80
--iop-hook=0x0086ac,FastForwardClock
--ee-sif0-cycle-scalar=2.0
--ee-sif1-cycle-scalar=2.0
--iop-sif1-cycle-scalar=5.0
--iop-sif0-cycle-scalar=5.0
--iop-tight-slice-count=12
--cdvd-sector-read-cycles=5000
--ee-hook=0x352dd0,AdvanceClock,0x0c0ef9a2,4500
--ee-hook=0x3b5068,FastForwardClock,0x00481024
--ee-hook=0x46fb68,FastForwardClock,0x8ca30000
--ee-hook=0x46fb38,FastForwardClock,0x8c620000
--ee-hook=0x46fb68,MfifoDrain,0x8ca30000
--ee-hook=0x46fb38,MfifoDrain,0x8c620000
--mfifo-manual-drain=0.30
--mfifo-chunk-drain-cycles=210000


SLUS-20500
LUA

-- red_dead_revolver
local gpr = require("ee-gpr-alias")

apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.

-- Bug 9309
local emuObj = getEmuObject()	
-- psm= SCE_GS_PSMCT32 (0)
emuObj.SetGsTitleFix( "forceSimpleFetch",  "reserved", {psm=0} )
emuObj.SetGsTitleFix( "fetchFromCurrBuff", "reserved", {psm=0} )

-- bug#9490 - Disable post-processing effect - <imgImageryDeriver<fxDistort>::Draw(void)>
eeInsnReplace(0x4c4b78, 0x27bdfff0,	0x03e00008)		-- JR $ra
eeInsnReplace(0x4c4b7c, 0xffbf0000,	0x00000000)		-- NOP

-- gfxState class writes bytes and then reads them back as words later on.
-- This replaces most of the word readbacks with lbu equivalents to avoid STLF.
-- 003c0950 <gfxState::Update_TEST(void)>:
eeInsnReplace(0x3c0970, 0x8ce6efd8, 0x90e6efd8) 	-- lw	a2,-4136(a3)
eeInsnReplace(0x3c09a0, 0x8ce3f37c, 0x90e3f37c) 	-- lw	v1,-3204(a3)

-- 0032aa70 <fxFloatPropGrid::Get(Vector2 const &) const>:
--   The original  compiler couldn't assume that Vector2 was an aligned object, so it generated
--    ldr/sdr instructions to access it.  The lack of assumption seems to have also caused it to
--    spill FPU registers to memory needlessly.

if true then
	eeInsnReplace(0x32aa74, 0x68a20007, 0x00000000)
	eeInsnReplace(0x32aa78, 0x6ca20000, 0x00000000)
	eeInsnReplace(0x32aa7c, 0xb3a20017, 0xc4a00000)		-- lwc1		$f0,0(a1)
	eeInsnReplace(0x32aa80, 0xb7a20010, 0xc4a10004)		-- lwc1		$f1,4(a1)

	eeInsnReplace(0x32aa8c,	0xc7a00010,	0x00000000)		-- nop
	eeInsnReplace(0x32aa9c,	0xc7a10014,	0x00000000)		-- nop

	eeInsnReplace(0x32aaa8,	0xe7a00010, 0x00000000)		-- nop
	eeInsnReplace(0x32aaac,	0x46020082, 0x46020002) 	-- mul.s	$f0,$f0,$f2   
	eeInsnReplace(0x32aab0,	0x3c014480, 0x3c014480) 	-- lui		at,0x4480
	eeInsnReplace(0x32aab4,	0x34211000, 0x34211000) 	-- ori		at,at,0x1000
	eeInsnReplace(0x32aab8,	0x44812000, 0x44812000) 	-- mtc1	at,$f4
	eeInsnReplace(0x32aabc,	0xe7a10014, 0x00000000) 	-- nop
	eeInsnReplace(0x32aac0,	0x460308c2, 0x46030842) 	-- mul.s	$f1,$f1,$f3
	eeInsnReplace(0x32aac4,	0xe7a20010, 0xe7a00000) 	-- swc1	$f0,0(sp)
	eeInsnReplace(0x32aac8,	0x90a4001c, 0x90a4001c) 	-- lbu	$a0,28($a1)
	eeInsnReplace(0x32aacc,	0xe7a30014, 0xe7a10004) 	-- swc1	$f1,4(sp)

	eeInsnReplace(0x32aad0,	0x6baa0017, 0x00000000) 	-- nop
	eeInsnReplace(0x32aad4,	0x6faa0010, 0x00000000) 	-- nop
	eeInsnReplace(0x32aad8,	0xb3aa0007, 0x00000000) 	-- nop
	eeInsnReplace(0x32aadc,	0xb7aa0000, 0x00000000) 	-- nop
	eeInsnReplace(0x32aae0,	0xc7a00000, 0x00000000) 	-- nop
	eeInsnReplace(0x32aae4,	0xc7a10004, 0x00000000) 	-- nop
end


Features.lua
SLUS-20500
Even though it's features.lua, it's still a very good example for learning

-- Lua 5.3
-- Title: Red Dead Revolver - SLUS-20500 (USA) v1.03
-- Author:  Nicola Salmoria
-- Date: March 23, 2016


require( "ee-gpr-alias" ) -- you can access EE GPR by alias (gpr.a0 / gpr["a0"])

apiRequest(0.7)	-- need widescreen support

local eeObj		= getEEObject()
local emuObj	= getEmuObject()


local GFXPIPELINE_16BY9_ADDRESS 	= 0x79eeec
local GLOBALS_UNIVERSALDATA_ADDRESS	= 0x742120


local TH1A =	-- start loading screen
	function()
		emuObj.ThrottleMax()
	end

local TH1B =	-- switch to threaded loading (over cutscene etc.)
	function()
		emuObj.ThrottleNorm()
	end


local TH2A =	-- start flashing loading message
	function()
		emuObj.ThrottleMax()
	end

local TH2B =	-- pause loading message
	function()
		emuObj.ThrottleNorm()
	end

local TH2C =	-- unpause loading message
	function()
		emuObj.ThrottleMax()
	end

local TH2D =	-- end loading message
	function()
		emuObj.ThrottleNorm()
	end



local showdownLoading = false

local TH3A =	-- draw "Loading" on Showdown info screen
	function()
		if showdownLoading == false then
			emuObj.ThrottleMax()
			showdownLoading = true
		end
	end

local TH3B =	-- draw "Press START" on Showdown info screen
	function()
		if showdownLoading == true then
			emuObj.ThrottleNorm()
			showdownLoading = false
		end
	end


local WH1 =	-- update 16:9 flag
	function()
		local isWidescreen = eeObj.GetGpr(gpr.a0)
		
		if isWidescreen == 0 then
			emuObj.SetDisplayAspectNormal()
		else
			emuObj.SetDisplayAspectWide()
		end
	end

local WH2 =	-- init universal data
	function()
		local v1 = eeObj.GetGpr(gpr.v1)
		eeObj.SetGpr(gpr.v1, v1 | 1)	-- enable widescreen
	end

local WH3 =	-- end of boot up sequence
	function()
		local universalData = eeObj.ReadMem32(GLOBALS_UNIVERSALDATA_ADDRESS)
		local isWidescreen = eeObj.ReadMem32(universalData + 92) & 1

		eeObj.WriteMem8(GFXPIPELINE_16BY9_ADDRESS, isWidescreen)

		if isWidescreen == 0 then
			emuObj.SetDisplayAspectNormal()
		else
			emuObj.SetDisplayAspectWide()
		end
	end



-- unthrottle loading screens
local thr1a = eeObj.AddHook(0x21e02c, 0x0080982d, TH1A)	-- <staNewLoadShow::Enter(void)>:
local thr1b = eeObj.AddHook(0x220100, 0x27bdfff0, TH1B)	-- <staNewLoadShow::DoThreadedLoadShow(void)>:
local thr2a = eeObj.AddHook(0x233970, 0x27bdfff0, TH2A)	-- <ThreadedLoadingMessage::Start(void)>:
local thr2b = eeObj.AddHook(0x233a30, 0x27bdfff0, TH2B)	-- <ThreadedLoadingMessage::Pause(void)>:
local thr2c = eeObj.AddHook(0x233a80, 0x3c02004f, TH2C)	-- <ThreadedLoadingMessage::Unpause(void)>:
local thr2d = eeObj.AddHook(0x2339d8, 0x27bdfff0, TH2D)	-- <ThreadedLoadingMessage::Stop(void)>:
local thr3a = eeObj.AddHook(0x226110, 0x8e850008, TH3A)	-- <staNewLoadShow::DrawMultiplayerInfo(void)>:
local thr3b = eeObj.AddHook(0x226058, 0x8e650008, TH3B)	-- <staNewLoadShow::DrawMultiplayerInfo(void)>:

-- widescreen support
local wide1 = eeObj.AddHook(0x3b9050, 0x46010003, WH1)	-- <gfxPipeline::Set16By9(bool)>:
local wide2 = eeObj.AddHook(0x180f90, 0x00641824, WH2)	-- <swcSaveUniversalData::swcSaveUniversalData(void)>:
local wide3 = eeObj.AddHook(0x102b70, 0x24040003, WH3)	-- <gmGame::DoBootUpSequence(void)>:

Psychonauts

SLUS_211.20
CLI

--vu1-jr-cache-policy=sameprog
--vu1-jalr-cache-policy=sameprog
--ee-hook=0x101fc0,FastForwardClock,0x3c0f0036
--ee-hook=0x110390,FastForwardClock,0x8d8f0000
--ee-hook=0x101c10,FastForwardClock,0x51cf0052
--gs-vert-precision=8
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
--gs-render-tile-threshold=300000
--vu-custom-min-max=0
--vu1-di-bits=0
--vu0-di-bits=0
--vu1-opt-vf00=2
--vu0-opt-vf00=2
--vu1-injection=1
--vu1-mpg-cycles=666
--vu1-mpg-cycles=1166,$000
--vu1-mpg-cycles=950,0xffffffff
--vu0-mpg-cycles=300,0xfc
--ee-hook=0x127630,AdvanceClock,0x27bdffd0,2100
--cdvd-sector-read-cycles=4000
--iop-cycle-scalar=1.6
#Seems like substantial performance fixes

SLUS_211.20
LUA

-- psychonauts_slus21120
local gpr    = require("ee-gpr-alias")
local emuObj = getEmuObject()	

apiRequest(1.0)	-- request version 0.1 API. Calling apiRequest() is mandatory.

-- 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 } )

-- Bug#9176
--
-- This bug seems GPUGS interpolation problem.
-- The game draws clouds as undiscovered area on the map, but
-- Z value is unstable --- sometimes 0x320, sometimes 0x321.
-- On drawing 'Highlight' object (which is missing one), it uses z=0x320 with
-- ZTST=GEQUAL. Therefore if the cloud renders with z=0x321, this highlighted object
-- doesn't appear. But it's OK on the real PS2 because of no-drawing right edge,
-- z=0x321 won't be available on the packet (interpolation differences between
-- the real PS2 and our gs)
-- it gives some values (50.0f) to get +1 on Z value for the highlighted object.
-- this value will be used later to create the packet in _sprite_ps2_push_data(ESprite*).
--
-- This old one causes a problem on some other scenes.
-- local eeObj = getEEObject()
-- eeObj.AddHook(0x1b276c,	0xe4400024, function() 
-- 				 local v0 = eeObj.GetGpr(gpr.v0)
-- 				 local z  = eeObj.ReadMemFloat(v0+32)
-- 				 eeObj.WriteMemFloat(v0+32, z+50.0)
-- end)
-- New one by Ernesto :
-- The idea is to apply the offset only on the marker.
local eeObj = getEEObject()
local adjustMapZHook = function() -- EMapRenderWindow::drawHighlightSprites
    eeObj.SetFpr(14, eeObj.GetFpr(14) + 50.0)
end
eeObj.AddHook(0x25d654, 0x8de40068, adjustMapZHook) -- \/
eeObj.AddHook(0x25d714, 0xe7b500cc, adjustMapZHook) -- /\
eeObj.AddHook(0x25d7d0, 0xe7b500cc, adjustMapZHook) -- <
eeObj.AddHook(0x25d894, 0x46000386, adjustMapZHook) -- >


-- bug#9423 - menus render 20+ times over again, causing very low fps.
-- The whole game in general has no concept of pacing and will re-draw frames multiple times
-- between vsync refreshes.  Hook placed on GameApp::EndFrame() measures time between frames and
-- if it's too short, the EE clock is advanced significantly to compensate.

local last_time = 0
local last_diff = 0
local advanceClockForAny = function()
	local thistime = eeObj.GetClock()
	local diff = thistime - last_time
	local adv  = 0

	if diff <= 0 then
		-- sanity check, mostly for snapshot restore.
		last_diff = diff
		last_time = thistime
		return
	end
	
	-- EE @ 30fps == roughly 10 million cycles
	-- bug#9555 - We need to make a reasonable tally of VIF cycles across game display swaps.
	--   Use a combination heuristic of EE and VIF1 cycles to gues at whether the title should
	--   lock to 45fps, 30fps, or something worse.
	
	local fastminEE		= 1600000		-- less than this it's safe to run > 30 fps
	local fastminVIF_30	= 2200000		-- VU1 total that merits 30hz throttle
	local fastminVIF_45	= 1700000		-- VU1 total that merit 45hz throttle.
	local baremin_wo_vif= 6100000		-- EE values below this get promoted to this value  (~50hz)
	local forced30hz	= 9330000
	local forced45hz	= 7820000
	
	local vif1_cycles = eeObj.GetVif1Cycles()
	if (vif1_cycles > forced30hz) then
		vif1_cycles = forced30hz
	end

	local diff_vif = diff + vif1_cycles
	adv = adv + vif1_cycles

	-- Lock anything that seems like "Real Work" to either 30 or 45 FPS:
	
	if diff_vif < fastminEE then
		adv = adv + (fastminEE*2 - diff_vif)
	elseif vif1_cycles > fastminVIF_30 and (diff+(fastminVIF_30)//2) < forced30hz then
		adv = adv + (forced30hz  		- diff - (fastminVIF_30)//2)
	elseif vif1_cycles > fastminVIF_45 and (diff+(fastminVIF_45)//2) < forced45hz then
		adv = adv + (forced45hz  		- diff - (fastminVIF_45)//2)
	elseif diff < baremin_wo_vif then
		adv = adv + (baremin_wo_vif  	- diff)
	end

	-- print (string.format("DELTA: %d  ADV: %d  VIF1: %d", diff, adv, vif1_cycles))

	if adv ~= 0 then
		eeObj.AdvanceClock(adv)
	end

	-- Ensure next frame's delta time takes into consideration this frame's advancement.
	-- Otherwise each fraem delta time would get progressively worse.

	thistime = thistime + adv
	last_time = thistime
	last_diff = diff
end

local advanceClockForGame = function() advanceClockForAny(5300000, 2700000) end
eeObj.AddHookJT(0x207cf8, 0x27bdfff0, advanceClockForGame) 	  -- <GameApp::EndFrame()>:
#Performance and optimisations

Red Faction

SLUS_200.73
CLI

--gs-use-deferred-l2h=1
--l2h-2d-params=0x0000000800000001,0x000000003a0a2300,512,2
--vu1=jit-sync
--ee-cycle-scalar=1.02
--ee-hook=0x00213370,FastForwardClock,0x8F8293A8
--ee-hook=0x24ce30,AdvanceClock,0x8c620000,20000
--ee-hook=0x272b44,FastForwardClock,0x3c0201ee
--ee-hook=0x272bc4,FastForwardClock,0x3c0201ee
--ee-hook=0x21b354,AdvanceClock,0x3c031000,0x1240
#performance fixes.

SLUS_200.73
LUA

-- Red Faction [US]

apiRequest(1.6)
local gpr = require("ee-gpr-alias")

-- title uses memcpy() to write to VU1 memory, so some instances will be hotfixed to
-- use slowpath_memcpy() at runtime.

eeNativeFunction(0x259820, 0x0080402d, 'memcpy')
eeNativeFunction(0x2599d8, 0x2cc20008, 'memset')

eeNativeFunction(0x253870, 0x27bdffd0, 'ieee754_acosf')
eeNativeFunction(0x254620, 0x44026000, 'ieee754_sqrtf')
eeNativeFunction(0x255a50, 0x44026000, 'cosf')
eeNativeFunction(0x255df0, 0x44026000, 'sinf')
eeNativeFunction(0x256318, 0x27bdffa0, 'acosf')

eeInsnReplace(0x24d7e0, 0x24030064, 0x03e00008)                 -- <FlushCache>
eeInsnReplace(0x24d7e4, 0x0000000c, 0x00000000)
eeNativeHook (0x24d7e0, 0x03e00008,'AdvanceClock',0xa00)
eeInsnReplace(0x24d810, 0x2403ff98, 0x03e00008)                 -- <iFlushCache>
eeInsnReplace(0x24d814, 0x0000000c, 0x00000000)
eeNativeHook (0x24d810, 0x03e00008,'AdvanceClock',0xa00)

eeInsnReplace(0x24de20, 0x27bdffe0, 0x03e00008)                 -- <SyncDCache>
eeInsnReplace(0x24de24, 0x0080302d, 0x00000000)
eeNativeHook (0x24de20, 0x03e00008,'AdvanceClock',0x600)
eeInsnReplace(0x24de98, 0x3c02ffff, 0x03e00008)                 -- <iSyncDCache>
eeInsnReplace(0x24de9c, 0x3442ffc0, 0x00000000)
eeNativeHook (0x24de98, 0x03e00008,'AdvanceClock',0x600)
eeInsnReplace(0x24df58, 0x27bdffe0, 0x03e00008)                 -- <InvalidDCache>
eeInsnReplace(0x24df5c, 0x0080302d, 0x00000000)
eeNativeHook (0x24df58, 0x03e00008,'AdvanceClock',0x600)
eeInsnReplace(0x24dfd0, 0x3c02ffff, 0x03e00008)                 -- <iInvalidDCache>
eeInsnReplace(0x24dfd4, 0x3442ffc0, 0x00000000)
eeNativeHook (0x24dfd0, 0x03e00008,'AdvanceClock',0x600)

local emuObj = getEmuObject()
local eeObj = getEEObject()

-- bug#10159 workaround
-- slowdown the jeep speed....

local jeepObj = 0
eeObj.AddHook(0x1376f0,	0xc6600174, function()
				 jeepObj = eeObj.GetGpr(gpr.s1)
end)
eeObj.AddHook(0x137a48,	0xc7ac00bc, function()
				 local s1 = eeObj.GetGpr(gpr.s1)
				 if s1 == jeepObj then
					eeObj.SetFpr(12, eeObj.GetFpr(12)*0.90)
				 end
end)

-- bug#10249 workaround
-- forcibly calculate the jeep's suspension.
eeObj.AddHook(0x19ee08,	0x8ec2120c, function()
				 if jeepObj - 624 == eeObj.GetGpr(gpr.s6) then
					eeObj.SetGpr(gpr.v0, 1)
				 end
end)

-- debug code for jeep movment target.
-- local px = 0.0
-- local pz = 0.0
-- eeObj.AddHook(0x1375bc,	0x26650174, function()
-- 				 local s1 = eeObj.GetGpr(gpr.s1)
-- 				 if s1 == jeepObj then
-- 					local s3 = eeObj.GetGpr(gpr.s3)
-- 					px = eeObj.ReadMemFloat(s3 + 372)
-- 					pz = eeObj.ReadMemFloat(s3 + 380)
-- 				 end
-- end)
-- eeObj.AddHook(0x1375c8, 0xa2620170, function()
-- 				 local s1 = eeObj.GetGpr(gpr.s1)
-- 				 if s1 == 0x19a7a00 then
-- 					local s3 = eeObj.GetGpr(gpr.s3)
-- 					local x = eeObj.ReadMemFloat(s3 + 372)
-- 					local z = eeObj.ReadMemFloat(s3 + 380)
-- 					if px ~= x or pz ~= z then
-- 					   print(string.format("[%f %f] => [%f %f] v0=%d",
-- 										   px, pz, x, z, eeObj.GetGpr(gpr.v0)))
-- 					end
--  				 end
-- end)
#physics calculations and performance fix.

SLUS_200.73
SLUS-20073_features.lua

-- Lua 5.3
-- Title:   Red Faction PS2 - SLUS-20073 (USA)
-- Author:  Ernesto Corvi, Adam McInnis

-- Changelog:

apiRequest(1.1)	-- request version 1.1 API. Calling apiRequest() is mandatory.

local eeObj		= getEEObject()
local emuObj	= getEmuObject()

local L1 =  -- main
	function()
		emuObj.ThrottleMax()
	end
	
local L2 =  -- main
	function()
		emuObj.ThrottleNorm()
	end
	
local load1 = eeObj.AddHook(0x165590, 0x27bdffb0, L1) -- game_load_level
local load2 = eeObj.AddHook(0x16578C, 0x7bb10010, L2) -- game_load_level

-- Widescreen support --
eeInsnReplace(0x2071c4, 0x00000000, 0x3c013f40) -- gr_setup_3d
eeInsnReplace(0x2071d0, 0x00000000, 0x4481f000) -- gr_setup_3d
eeInsnReplace(0x2072e0, 0x00000000, 0x461ea502) -- gr_setup_3d
eeInsnReplace(0x2072e8, 0x00000000, 0x461ead43) -- gr_setup_3d
eeInsnReplace(0x23a34c, 0x44826000, 0x461e0303) -- shadow_ngps_render_and_copy
eeInsnReplace(0x23a444, 0x3c024334, 0x3c024309) -- shadow_ngps_render_and_copy
emuObj.SetDisplayAspectWide()
#Official widescreen support.

Red faction II

CUSA06356
CLI

--gs-use-deferred-l2h=0
--l2h-2d-params=0x0000000800000001,0x000000003a083000,612,2
--mtap1=disabled
--mtap2=disabled

Resident Evil Code: Veronica X

ALL
CLI

--ee-jit-pagefault-threshold=30
#crash fix.

ALL
LUA

-- VeronicaX
apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.

-- Bug# 9976
local emuObj = getEmuObject()	
emuObj.SetGsTitleFix( "clipScissors", "reserved", {alpha = 0 , frameW = 4 , psm = 0} )
#graphical fix.

Rogue Galaxy

ALL
CLI

--gs-kernel-cl-up="up2x2skipinterp"
--gs-optimize-30fps=1
#visual fixes and performance optimisation.

SCUS_974_90
LUA

require("ee-gpr-alias")
apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.

-- Bug#8404 WORKAROUND
-- See https://pss.usrd.scea.com/bugzilla/show_bug.cgi?id=8404
eeInsnReplace(0x124898, 0x3442ffff, 0x3442fffe) -- 	ori	v0,v0,0xffff
#unsure what this fixes.

Rise of the Kasai

CLI
SCUS-97416

--gs-kernel-cl-up="up2x2skipinterp"
--cdvd-sector-read-cycles=31000
--iop-cycle-scalar=0.7


LUA
SCUS-97416

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

apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.


local emuObj = getEmuObject()
local eeObj  = getEEObject()

-- bug #9037. 
-- Force point sampling when max mip map > 0 and min filter is set to nearest( 0).   
-- This is done generically when mipmaping is On , however  we prefer to disable mip maps for this title.
emuObj.SetGsTitleFix( "forcePoint", "reserved", {mipIsGt=0,  mmin=0} )

-- bug#9241
-- SwapMemCard to Mark of Kri
-- bug#136347 (SCEI bugzilla)
-- we re-use US image for Rise of Kasai EU package and want to let use be able to have Mark of Kri completion bonus.
-- unfortunately we don't have any ways to distinguish which PS4 package we are working on.
-- instead of US => EU reading out modification, let the game retry EU saved data when it fails.
--
-- NOTE: you can write down the filepath directly(onto strptr) at boot time if we can distinguish the differences of the packages.
local first_attempt = true
local buffer = -1
local strptr = -1
local write_str = function (ptr, str)
   for i=1,string.len(str) do
	  eeObj.WriteMem8(ptr + i - 1, string.byte(str, i, i))
   end
end
eeObj.AddHook(0x1aa904,	0x0040382d, function()
				 strptr = eeObj.GetGpr(gpr.a2)
				 local fname = eeObj.ReadMemStr(strptr)
				 -- print(string.format("%s", fname))
				 if fname == "BASCUS-97140/BASCUS-97140" then
					if first_attempt then
					   buffer = eeObj.GetGpr(gpr.a3)
					   --print("Trying to read out SCUS-97140 Mark of Kri US saved data");
					   --print(string.format("%x:ReadFile(%x, %x, %x)", eeObj.GetGpr(gpr.a0), 0, eeObj.GetGpr(gpr.a2), eeObj.GetGpr(gpr.a3)))
					   emuObj.SwapMemCard(0, 0, "SCUS-97140")	-- 2nd argument, user-id isn't used in the current implementation.
					else
					   -- this is the case of re-trying : reading out EU mark of kri
					   --print("Trying to read out SCES-51164 Mark of Kri EU saved data");
					   write_str(strptr, "BESCES-51164/BESCES-51164")
					   eeObj.SetGpr(gpr.a3, buffer);
					   --print(string.format("%x:ReadFile(%x, %x, %x)", eeObj.GetGpr(gpr.a0), 0, eeObj.GetGpr(gpr.a2), eeObj.GetGpr(gpr.a3)))
					   emuObj.SwapMemCard(0, 0, "SCES-51164")
					end
				 end
end)
eeInsnReplace(0x1aa910,	0x10400020, 0x00000000)
eeObj.AddHook(0x1aa910, 0x00000000, function()
				 local v0 = eeObj.GetGpr(gpr.v0)
				 if v0 == 0 then	-- failed
					--print("File Load Failed")
					if first_attempt then
					   first_attempt = false
					   eeObj.SetPc(0x1aa8fc)
					else
					   first_attempt = true
					   eeObj.SetPc(0x1aa994)
					end
				 end
end)
-- SwapMemCard to Rise of Kasai
eeObj.AddHook(0x1aa9e8,	0xdfbf0000, function()
				 emuObj.SwapMemCard(0, 0, "SCUS-97416")
				 write_str(strptr, "BASCUS-97140/BASCUS-97140")	-- write back the original string to the place.
				 strptr = -1
				 buffer = -1
end)

Samurai Shodown Anthology

SLUS_216.29
CLI

--gs-upscale=point
--gs-uprender=2x2
--gs-motion-factor=25
--host-audio-latency=0.01
--gs-ignore-dirty-page-border=1
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
--gs-h2l-list-opt=1
--gs-h2l-accurate-hash=1
#fix for substantial slowdown during combat.

Star Wars Bounty Hunter

ALL
CLI

--gs-kernel-cl-up="OptRightTri"
--gs-vert-precision=8

Star Wars: Jedi Starfighter

SLES_503.71
CLI

--gs-check-trans-rejection68=1
--gs-dirty-page-policy=1

SLES_503.71
Lua

-- Star Wars: Jedi Starfighter [SLES-50371] [EU]

require("ee-gpr-alias")
require("pad-and-key")
apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.

local eeObj = getEEObject()
local emuObj = getEmuObject()

-- Bug#9013 - title calls PS2::Exit() at the end of a bonus stage.
eeInsnReplace(0x323398, 0x0c116bb4, 0x00000000) --   jal     Stop__12CTaskManagerFv
 
-- Bug#8905
-- The game sets a little bit big DH values for GS Display Register.
-- mimic overscan cropping (generic crop happens in GsScanoutArea::Populate)
local dump_display = function()
   local a5 = eeObj.GetGpr(gpr.t1)
   local ds1_h = eeObj.ReadMem32(a5+892)
   local ds2_h = eeObj.ReadMem32(a5+908)
   local dh1   = (ds1_h>>(44-32))&0x7ff
   local dh2   = (ds2_h>>(44-32))&0x7ff
   if dh1 >= 574 then
	  dh1 = 558 -- 574-16
	  ds1_h = (ds1_h & 0xfff) | (dh1 << (44-32))
	  eeObj.WriteMem32(a5+892, ds1_h)
   end
   if dh2 >= 575 then
	  dh2 = 559 -- 575-16
	  ds2_h = (ds2_h & 0xfff) | (dh2 << (44-32))
	  eeObj.WriteMem32(a5+908, ds2_h)
   end
end
eeObj.AddHook(0x4fc33c,	0x02084821, dump_display)
eeObj.AddHook(0x4fc068,	0x02084821, dump_display)

-- Bug#8944
-- The game doesn't clear the framebuffer on movie-startup and movie-display.
-- call clear functions at the appropriate points by using Replacement.
local Replace_CVideoDecoder_Draw = InsnOverlay( {
	0x27bdfff0, -- 	addiu	sp,sp,-16
	0xffbf0000, -- 	sd	ra,0(sp)

	-- swap
	0x0c13f044, -- 	jal	0x4fc110
	0x00000000, -- 	nop
	-- clear
	0x0c13f228, -- 	jal	0x4fc8a0
	0x24044000, -- 	li	a0,16384

	0xdfbf0000, -- 	ld	ra,0(sp)
	0x03e00008, -- 	jr	ra
	0x27bd0010, -- 	addiu	sp,sp,16
})
eeInsnReplace(0x427fe0,	0x0c13f044,0x0c000000 | (Replace_CVideoDecoder_Draw>>2))
local Replace_CPS2MpegPlayer_Open = InsnOverlay( {
	0x27bdfff0, -- 	addiu	sp,sp,-16
	0xffbf0000, -- 	sd	ra,0(sp)

	-- clear color
	0x44806000, -- 	mtc1	zero,$f12
	0x46006346, -- 	mov.s	$f13,$f12
	0x0c13f1d8, -- 	jal	0x4fc760
	0x46006386, -- 	mov.s	$f14,$f12
	-- clear
	0x0c13f228, -- 	jal	0x4fc8a0
	0x24044000, --  li	a0,16384
	-- swap
	0x0c13f044, --  jal	4fc110 <glSwapBuffersPSX2>	
	0x00000000, --  nop

	-- restore some registers
	0x0220302d, -- 	move	a2,s1
	0x0200382d, -- 	move	a3,s0

	0xdfbf0000, -- 	ld	ra,0(sp)
	0x03e00008, -- 	jr	ra
	0x27bd0010, -- 	addiu	sp,sp,16
})
eeInsnReplace(0x423c3c,	0x0220302d, 0x0c000000 | (Replace_CPS2MpegPlayer_Open>>2))

--
-- Bug#8981 / Bug#9006
--
local std_string_c_str = function(ptr)
   return eeObj.ReadMemStr(eeObj.ReadMem32(eeObj.ReadMem32(ptr) + 12))
end
local player_obj_found_flag = 0
local player_obj = 0
eeObj.AddHook(0x464530,	0x27bdff90, function()
				 if std_string_c_str(eeObj.GetGpr(gpr.a1)) == "_player" then
					--print(string.format("LookupGameObject %s", std_string_c_str(eeObj.GetGpr(gpr.a1))))
					player_obj_found_flag = 1
				 end
end)
eeObj.AddHook(0x464720,	0x7bb10010, function()
				 if player_obj_found_flag == 1 then
					player_obj = eeObj.ReadMem32(eeObj.GetGpr(gpr.v0)+92)
					--print(string.format("    obj    = %x", eeObj.GetGpr(gpr.v0)))
					--print(string.format("    92(v0) = %x", player_obj))
					--print(string.format("    [%f, %f, %f]", eeObj.ReadMemFloat(player_obj+116), eeObj.ReadMemFloat(player_obj+120), eeObj.ReadMemFloat(player_obj+124)))
					--print(string.format("    [%f, %f, %f]", eeObj.ReadMemFloat(player_obj+52), eeObj.ReadMemFloat(player_obj+56), eeObj.ReadMemFloat(player_obj+60)))
					player_obj_found_flag = 0
				 end
end)

eeObj.AddHook(0x147444,	0x0040282d, function()
				 local strptr = eeObj.GetGpr(gpr.v0)
				 local str    = std_string_c_str(strptr)
				 if string.match(str, "ExplosionFire")
					-- or string.match(str, "ExplosionSpark")
				 then
					local explosion_object = eeObj.ReadMem32(eeObj.GetGpr(gpr.s0)+92)
					local eo_x = eeObj.ReadMemFloat(explosion_object+116)
					local eo_y = eeObj.ReadMemFloat(explosion_object+120)
					local eo_z = eeObj.ReadMemFloat(explosion_object+124)
					-- print(string.format("exp obj : %x", explosion_object))
					-- print(string.format("        [%f, %f, %f]", eo_x, eo_y, eo_z))
					-- print(string.format("        [%f, %f, %f]", eeObj.ReadMemFloat(explosion_object+52), eeObj.ReadMemFloat(explosion_object+56), eeObj.ReadMemFloat(explosion_object+60)))

					local pl_x = eeObj.ReadMemFloat(player_obj+116)
					local pl_y = eeObj.ReadMemFloat(player_obj+120)
					local pl_z = eeObj.ReadMemFloat(player_obj+124)
					-- print(string.format("pl  obj : %x", player_obj))
					-- print(string.format("        [%f, %f, %f]", pl_x, pl_y, pl_z));

					local len = (eo_x-pl_x)*(eo_x-pl_x) + (eo_y-pl_y)*(eo_y-pl_y) + (eo_z-pl_z)*(eo_z-pl_z)
					-- print(string.format("lengh^2 = %f", len))

					-- print(string.format("str : %s", std_string_c_str(strptr)))

					if len < 960000.0 then
					   -- print("    REMOVED")
					   eeObj.SetPc(0x1474b0)
					end
				 end
end)

local overlay_addr = InsnOverlay( {
 0x8c700008, --  lw      $s0, 8($v1)
 0x8e040000, --  lw      $a0, 0($s0)
 0x8c840000, --  lw      $a0, 0($a0)
 0x3c05006c, --  lui     $a1,0x6c
 0x34a5ce28, --  ori     $a1,$a1,0xce28
 0x14850002, --  bne     $a0, $a1, <ret>
 0x00000000, --  nop
 0xac600004, --  sw      zero, 4($v1)
 0x03e00008, -- ret: jr      $ra
 0x8c630004, --  lw      $v1, 4($v1) 
} )
local call_insn = (overlay_addr >> 2) | 0x0c000000
eeInsnReplace( 0x267f84, 0x8c700008, call_insn ) -- lw $s0, 8($v1) -> jal overlay_addr
eeInsnReplace( 0x267f88, 0x8c630004, 0x00000000 ) -- lw $v1, 4($v1) -> nop

-- The game has a bug when you replay the last campaign mission in coop mode ("The Jedi Master").
-- Upon completing the mission successfully, the game asks to "Continue" or "Quit".
-- Selecting "Continue" causes the game to hang, as there's nothing to continue to (it's the last mission)
-- The following patch fixes this problem by changing to prompt to "Retry" or "Quit", as it behaves in 1p mode
 
eeObj.AddHook(0x39debc, 0x0220202d, function()
     local strptr = eeObj.GetGpr(gpr.v0)
     local str    = std_string_c_str(strptr)
     if string.match(str, "m16_fleet") then
     eeObj.SetGpr(gpr.s0, 1)
     end
end)
 
-- fix for a node corruption.
-- here's what happens (from Ernesto)
--
-- Well, I was finally able to track down the issue. It's actually difficult to explain and the actual trigger is still unknown to me, as it seems to be timing related somehow.
-- But, I found a way to reliably detect it and work around it. Basically, when the bug happens, CSGNode::AddChild will try to add a child node that's already a children of a different root node.
-- That causes all sorts of havok and it's what ends up causing the node child list to eventually be deallocated and the render to crash.
eeObj.AddHook(0x266A70, 0x27bdffc0, function()
--   local obj = eeObj.GetGpr(gpr.a0)
    local node = eeObj.GetGpr(gpr.a1)
    local parent = eeObj.ReadMem32(node+0x10)
--   local caller = eeObj.GetGpr(gpr.ra)

    if parent ~= 0 then
--      print(string.format("Node %08x already has a parent (%08x, caller: %08x)", node, parent, caller))
       eeObj.SetPC(0x266B80)
    end
end)

Star Wars Racer Revenge

SLES_503.66
CLI

--ee-hook=0x0025b3b0,FastForwardClock
--ee-hook=0x0025b188,FastForwardClock
--ee-hook=0x00243274,FastForwardClock
--gs-vert-precision=8
--idec-cycles-per-qwc=768
--host-audio-latency=0.60
--fpu-no-clamping=1
--cop2-no-clamping=1
--vu1-di-bits=0
--gs-override-small-tri-area=1
--assert-path1-ad=0
--ee-ignore-segfault=Read

SLES_503.66
Lua

require( "ee-gpr-alias" ) -- you can access EE GPR by alias (gpr.a0 / gpr["a0"])
apiRequest(0.4)

-- Star Wars: Racer Revenge (SLES-50366) [US]

local eeObj		= getEEObject()
local emuObj   	= getEmuObject()	

eeInsnReplace(0x13d7f0, 0x1000ffff, 0x0804f45d)	-- retry FREAD() for fix #9025,

-- Track#
-- The Grand Reefs 			: 6 
-- Ruins of Carnuss Gorgull : 9
eeObj.AddHook(0x187330,	0x3c010001, function()
				 local track = eeObj.GetGpr(gpr.a1)
				 print(string.format("Track : %d", track))
				 if track == 6 or track == 9 then
					eeObj.Vu1MpgCycles(1000)	-- makes it be 30fps.
				 else
					eeObj.Vu1MpgCycles(100)		-- default value.
				 end
end)

-- 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 } )

SLES_503.66
Lua Features
Seems to also include some game fix

-- Lua 5.3
-- Title:   Star Wars Racer Revenge PS2 - SLES-50366 (EUR)
-- Author:  Ernesto Corvi

-- Changelog:

apiRequest(0.2)	-- request version 0.2 API. Calling apiRequest() is mandatory.

local eeObj		= getEEObject()
local emuObj	= getEmuObject()

local L1 =  -- PodUILoadingPage::PodUILoadingPage
	function()
		emuObj.ThrottleMax()
	end
	
local L2 =  -- PodUILoadingPage::~PodUILoadingPage
	function()
		emuObj.ThrottleNorm()
	end
	
local load1 = eeObj.AddHook(0x1caa30, 0x27bdffe0, L1)	-- PodUILoadingPage::PodUILoadingPage
local load2 = eeObj.AddHook(0x1caa70, 0x27bdffd0, L2)	-- PodUILoadingPage::~PodUILoadingPage



-- BUG 9244 - This title exhibits memory allocation problems as described on the
-- PS2 tech note titled "malloc() Issues". Overlay the FullAllocAndFree() and hook it to main()

local overlay_addr = InsnOverlay( {
	0x27bdfff0, --		addiu $sp, -0x10
	0x7fbf0000, --		sq $ra, 0($sp)
	0x0c0c1710, --  	jal malloc
	0x3c0401e0, --  	lui $a0, 0x01e0
	0x0c0c171a, --  	jal free
	0x70402628, --  	paddub $a0, $v0, 0
	0x7bbf0000, --  	lq	$ra, 0($sp)
	0x03e00008, --  	jr $ra
	0x27bd0010  --  	addiu   $sp, 0x10
} )
local call_insn = (overlay_addr >> 2) | 0x0c000000
eeInsnReplace(0x23a020, 0x0c0be0a2, call_insn) -- jal scePrintf

-- BUG 9244 - move stack down to 0x01f80000 to free up an extra 512KB
eeInsnReplace(0x100038, 0x3c0501f0, 0x3c0501f8)

Twisted Metal Black

ALL
CLI

--mtap1=always
--gs-use-deferred-l2h=0
--l2h-2d-params=0x0000000400000004,0x00000000300a0000,240
--vu1-di-bits=0
--vu1-opt-vf00=2
#performance fix.

SCUS_971.01
LUA

require("ee-gpr-alias")
apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.

-- This game uses an old kernel which has a bug on _TerminateThread.
-- It is necessary to check the target thread is already in readyqueue or not.

iopObj = getIOPObject()
iopInsnReplace(0x0000C5C0, 0x0C004430, 0) -- jal         0x000110C0				// unlink_element (in TerminateThread)
iopInsnReplace(0x0000C6EC, 0x0C004430, 0) -- jal         0x000110C0				// unlink_element (in iTerminateThread)
local fix_TerminateThread = function()
   local TCB = iopObj.GetGpr(gpr.s0)
   local TCB_status = iopObj.ReadMem8(TCB + 0xc)
   local TCB_h_l = TCB
   if TCB_status == 0x2 then
	  -- the target thread is on ready.
	  local TCB_h_l_prev = iopObj.ReadMem32(TCB_h_l + 0)
	  local TCB_h_l_next = iopObj.ReadMem32(TCB_h_l + 4)
	  if TCB_h_l_prev == TCB_h_l_next then		-- last_one_element(&tcb->h.l)
		 -- we need to maintain threadManCB.readymap.
		 -- print("WE NEED TO MAINTAIN threadManCB.readymap!")
		 local s0 = iopObj.ReadMem16(TCB + 0xe)	-- prio
		 local s1 = TCB
		 local a0 = s0 >> 5
		 a0 = a0 << 2
		 local v1 = s0 & 0x1f
		 local v0 = 1 << v1
		 v1 = 0x10000 + a0
		 v1 = iopObj.ReadMem32(v1 + 0x1a08)
		 v0 = ~v0
		 v1 = v1 & v0
		 local at = 0x10000+a0
		 iopObj.WriteMem32(at+0x1a08, v1)

-- 0000B798   00102142 srl         a0,s0,5
-- 0000B79C   00042080 sll         a0,a0,2
-- 0000B7A0   3203001F andi        v1,s0,0x1F
-- 0000B7A4   24020001 li          v0,0x1
-- 0000B7A8   00621004 sllv        v0,v0,v1
-- 0000B7AC   3C030001 lui         v1,0x1
-- 0000B7B0   00641821 addu        v1,v1,a0
-- 0000B7B4   8C631A08 lw          v1,0x1A08(v1)
-- 0000B7B8   00021027 nor         v0,zero,v0
-- 0000B7BC   00621824 and         v1,v1,v0
-- 0000B7C0   3C010001 lui         at,0x1
-- 0000B7C4   00240821 addu        at,at,a0
-- 0000B7C8   AC231A08 sw          v1,0x1A08(at)

	  end
   end
   -- do unlink_element
   local v1 = iopObj.ReadMem32(TCB_h_l+0)	-- element->prev
   local v0 = iopObj.ReadMem32(TCB_h_l+4)	-- element->next
   iopObj.WriteMem32(v1 + 4, v0)			-- element->prev->next = element->next
   iopObj.WriteMem32(v0 + 0, v1)
end
iopObj.AddHook(0x0000C5C4, 0x02002021, fix_TerminateThread) -- move        a0,s0
iopObj.AddHook(0x0000C6F0, 0x02002021, fix_TerminateThread) -- move       a0,s0

-- _waitIpuIdle64 spin perf down problem. Bug#8289
-- NOTE: new libarary also loops just 500dec around. 0x1389 is too much.
eeInsnReplace(0x0020CF80, 0x28421389, 0x28420200) -- slti        v0,v0,0x1389
#Performance and stall fixes.


The Mark of Kri


CLI
SCES-51164

--gs-scanout-offsetx=27

The Warriors

ALL
CLI

--vu1-injection=1
--vu1-mpg-cycles=2300
--vu1-mpg-cycles=2600,-1
--vu1-clamp-range=0x028,0x060
--ee-hook=0x48c660,FastForwardClock,0x1620ffe3
--force-pal-60hz=1

?
LUA

-- Lua 5.3
-- Title: The Warriors (USA)    SLUS-21215 ( 1.04 NTSC )
--        The Warriors (Europe) SLES-53443 ( 1.01 PAL )
-- Features version: 1.00
-- Author: David Haywood
-- Date: November 15th 2015



require( "ee-gpr-alias" ) -- you can access EE GPR by alias (gpr.a0 / gpr["a0"])

apiRequest(0.7)	-- request version 0.7 API. Calling apiRequest() is mandatory.	-- request version 0.7 API. Calling apiRequest() is mandatory. (0.7 is needed for Widescreen switching)

-- obtain necessary objects.
local eeObj			= getEEObject()
local emuObj		= getEmuObject()
local trophyObj		= getTrophyObject()
local dmaObj		= getDmaObject()

-- load configuration if exist
local SaveData		= emuObj.LoadConfig(0)


local firstCall = 0


--[[

this is the 'setWideScreen' function of the gfx devices
from studying the code it seems that the content of 'a1' that
gets passed in determines if the requested mode is widescreen.

DevRWGraphicsDevice::setWideScreenMode(void)
00194E28   27BDFFD0 addiu       sp,sp,-0x30
00194E2C   7FB00010 sq          s0,0x0010(sp)
00194E30   E7B50028 swc1        f21,0x0028(sp)
00194E34   0080802D dmove       s0,a0
00194E38   FFBF0000 sd          ra,0x0000(sp)
00194E3C   E7B40020 swc1        f20,0x0020(sp)
00194E40   4480A800 mtc1        zero,f21
00194E44   C600044C lwc1        f0,0x044C(s0)
00194E48   46150032 c.eq.s      f0,f21
00194E4C   00000000 nop
00194E50   45010053 bc1t        0x00194FA0
00194E54   AE05045C sw          a1,0x045C(s0)
--]]

local WidesrceenFunction = function()	
	local a1 = eeObj.GetGPR(gpr.a1)
	
	a1 = a1 & 1
	
	-- force to widescreen on boot, ensures new profiles get created in widescreen mode by default etc.
	-- has some unwanted side-effects tho, so don't do it
	if firstCall == 1 then
		a1 = 1
		eeObj.SetGPR(gpr.a1, a1)
		firstCall = 0
	end
	
	
	
	if a1 == 1 then
		print( string.format("********* Request WIDE SCREEN mode **************" ) )
		emuObj.SetDisplayAspectWide()		
	else
		print( string.format("********* Request 4:3 mode **************" ) )
		emuObj.SetDisplayAspectNormal()	
	end
	
end




-- this hook address actually differs between Europe / US.
WidescreenHook = eeObj.AddHook(0x194e18,0x27BDFFD0,WidesrceenFunction)

#official widescreen patch for The Warrior's emulator. The typos are apparently deliberate.

Wild ARMS 3

ALL
CLI

--gs-motion-factor=50
--ee-static-block-links=JAL,COP2
#graphical fixes.

SCUS_972.03
LUA

require("ee-gpr-alias")
apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.

local emuObj		= getEmuObject()	
-- fix vision logo (Wild Arms 3)
local thresholdArea = 0 -- ignore alls items : fix #112276
emuObj.SetGsTitleFix( "ignoreUpRender", thresholdArea , {  texType = 3, cbp = 0x2390, tbp = 0x288000} )


-- fix bug #9072
-- this is caused by a wrong string, which we patch directly on the disc.
emuMediaPatch(0x438a, 12 + 0x174, { 0x6e5c2535 }, { 0x11202535 })

-- Bug#8907. accuracy-muldiv is too slow to use, so here added some value to get correct value.
local eeObj = getEEObject()
eeObj.AddHook(0x001ef6ec, 0x00000000, function()
				 eeObj.SetFpr(0, eeObj.GetFpr(0) + 0.00001)
end)
#Graphical glitches and stall fix.

Custom PS2emu Configuration Files

Configuration files created by users, to improve PS2 emulator compatibility on PS4.
Describing what Your configuration is doing is recommended.
On cli you can do it with #
and on a lua you can do it with --

18 Wheeler - American Pro Trucker


NTSC
LUA

-- boot fix by Kozarovv
-- widescreen by Stayhye(ported from PAL version by El_Patas)
-- ported to PS4 lua
-- emu used=psycho v2

local gpr = require("ee-gpr-alias")

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()
--16:9
eeObj.WriteMem32(0x001d4c3c, 0x3c013f40) -- 0x3c013f80
-- Skip debugger hook.
eeObj.WriteMem32(0x001EB2A0, 0x00000000)
eeObj.WriteMem32(0x001EB2A8, 0x10000003)

emuObj.ThrottleMax()
end

emuObj.AddVsyncHook(patcher)

--math.random() + math.random(1, 99)

24 The Game

CLI

--gs-uprender=2x2
--gs-upscale=edgesmooth

--host-display-mode=16:9

--ee-kernel-hle=1
--ee-injection-kernel=1
--ee-injection-title=1
--ee-cycle-scalar=1.9
--safe-area-min=1.0
--vu0-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1


# Fixed lags issue.
# <emu used=psychonauts v2>


LUA
SLUS_212.68

-- 24 The Game NTSC
-- performace fix by kozarovv
-- ported to PS4
-- emu used=psychonauts v2

local gpr = require("ee-gpr-alias")

apiRequest(1.0)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

--Widescreen hack 16:9

--Force turn on the native widescreen
eeObj.WriteMem32(0x205FBD2C,0x00000001)

--Zoom Fix
--6000023c 2cbd428c 
eeObj.WriteMem32(0x002fbea0,0x3c020000)  --3c020060
eeObj.WriteMem32(0x002fbea4,0x34420000)

eeObj.WriteMem32(0x00139e2c,0x3c020000) --3c020060
eeObj.WriteMem32(0x00139e30,0x34420000) --8c42bd2c

--X-Fov (4:3)
--aa3f013c a8aa2134
--2a8e2134 e33f013c
--eeObj.WriteMem32(0x00460364,0x3c013fe3) --3c013faa
--eeObj.WriteMem32(0x00460368,0x34218e2a) --3421aaa8

--Fix slow and choppy gameplay
eeObj.WriteMem32(0x004155a8,0x48a44800)
eeObj.WriteMem32(0x004155ac,0x48c02800)
eeObj.WriteMem32(0x004155b0,0x4a00d839)

eeObj.WriteMem32(0x00415660,0x48a44800)
eeObj.WriteMem32(0x00415664,0x48c02800)
eeObj.WriteMem32(0x00415668,0x4a00d839)

end

emuObj.AddVsyncHook(patcher)

10000 Bullets

CLI

--vu1=jit-sync

# Fixes Blackscreen after PS2 Logo.
# Jak v1 used

Ace Combat 4

CLI

--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--gs-use-mipmap=1

#Fix for terrain textures

Ace Combat 5

CLI


All versions

--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--gs-use-mipmap=1

#Same fix for terrain textures


LUA file


SLUS_208.51

apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.

-- Collision detection fix for Stage 3 onwards // Rearranging COP2 instructions that use old results

eeInsnReplace(0x1A3B94, 0x4B00682C, 0x48498800)
eeInsnReplace(0x1A3B98, 0x4B0C682C, 0x4B00682C)
eeInsnReplace(0x1A3BA4, 0x48498800, 0x484A8800)
eeInsnReplace(0x1A3BA8, 0x484A8800, 0x4B0C682C)


LUA file


SCES_504.10

apiRequest(2.2)	-- request version 0.1 API. Calling apiRequest() is mandatory.

-- Wrong sky shader

local emuObj 	= getEmuObject()

-- Fix for wrong sky shader

emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=2 } )

Ace Combat Zero: The Belkan War

CLI
All Versions

--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--gs-use-mipmap=1
#Once again, same fix for terrain textures.


LUA file


SLUS_213.46

apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.

-- Collision detection fix.

eeInsnReplace(0x131EBC, 0x4B00682C, 0x48498800)
eeInsnReplace(0x131EC0, 0x4B0C682C, 0x4B00682C)
eeInsnReplace(0x131ECC, 0x48498800, 0x484A8800)
eeInsnReplace(0x131ED0, 0x484A8800, 0x4B0C682C)


LUA file


SCES_540.41

apiRequest(2.2)	-- request version 0.1 API. Calling apiRequest() is mandatory.

-- Wrong sky shader

local emuObj 	= getEmuObject()

-- Fix for wrong sky shader

emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=2 } )

-- Collision detection fix.

eeInsnReplace(0x131EB8, 0x4B00682C, 0x48498800)
eeInsnReplace(0x131EC8, 0x4B0C682C, 0x4B00682C)
eeInsnReplace(0x131FB8, 0x48498800, 0x484A8800)
eeInsnReplace(0x131EC4, 0x484A8800, 0x4B0C682C)

AirBlade

CLI


All versions

--vu0-no-clamping=0
--vu1-no-clamping=0

#emu used=GTA 3 v1
#Fix for flickering models and textures

Ape Escape 2

CLI


All versions

--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"

#Fix for flickering textures

Ape Escape: Pumped & Primed

CLI


All versions

--ee-jit-pagefault-threshold=30
--gs-frontend-opt-mode=1
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--cop2-no-clamping=1
--vu1-mpg-cycles=250
#Fix for flickering textures

LUA

--emu used=jakx v2
apiRequest(1.0)
local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()

--Fix game frame rate
eeObj.WriteMem32(0x3816e0,0x10000025) -- NTSC ONLY!!
end

emuObj.AddVsyncHook(patcher)

Avatar The last airbender


All Versions
LUA

-- emu used=psychonauts v2, Fix For Freeze when starting new game

local gpr = require("ee-gpr-alias")

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

eeObj.SchedulerDelayEvent("vif1.dma", 0x6500) -- "--vif1-instant-xfer=0" replacement
emuObj.ThrottleMax()
end

emuObj.AddVsyncHook(patcher)

Battle Engine Aquila

#Graphical corruption fix
--vu1-no-clamping=1
#Performance boost
--ee-cycle-scalar=1.5
--vu1-mpg-cycles=1000
--vu1-di-bits=0
--vu1-const-prop=1
--gs-adaptive-frameskip=1
#Jakv2

Baldur's Gate: Dark Alliance II

CLI
All Versions

--gs-uprender=2x2
--gs-upscale=EdgeSmooth

--host-display-mode=16:9

--vif1-instant-xfer=0

--vu0-no-clamping=0
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-clamp-results=1

Bard's tale, the

CLI
All versions
War of the monsters v1 fixes the crash.

#Speedhacks
--ee-cycle-scalar=1.1
--vu1-di-bits=0
#Missing graphics fix
--vif1-instant-xfer=0
--vu1-no-clamping=0

Bloody Roar 4

CLI


All Versions

--vu0-no-clamping=0
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-results=1

#SPS Fix

Burnout 2: POI


LUA file


SLES_510.44 / SLES_529.68

apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.

-- SLES-51044 / SLES-52968 - Fix white parts
-- Major thanks to Maori-Jigglypuff for reversing that

eeInsnReplace(0x2485B8, 0xC6800D18, 0x3C014316)
eeInsnReplace(0x2485CC, 0xE4400000, 0xAC410000)
eeInsnReplace(0x262604, 0xC7809780, 0x3C014316)
eeInsnReplace(0x262618, 0xE4400000, 0xAC410000)
eeInsnReplace(0x2564B8, 0x8F829764, 0x24020000)


LUA file


SLUS_204.97

apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.

-- SLUS_204.97 - Fix white parts
-- Major thanks to Maori-Jigglypuff for reversing that

eeInsnReplace(0x2485A8, 0xC6800D18, 0x3C014316)
eeInsnReplace(0x2485BC, 0xE4400000, 0xAC410000)
eeInsnReplace(0x2625F4, 0xC7809780, 0x3C014316)
eeInsnReplace(0x262608, 0xE4400000, 0xAC410000)
eeInsnReplace(0x2564A8, 0x8F829764, 0x24020000)

Castlevania: Curse of Darkness


SLUS-21168
LUA

-- Widescreen hack by nemesis2000
-- new graphics fix by kozarovv
-- emu used=

local gpr = require("ee-gpr-alias")

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()
--gameplay
eeObj.WriteMem32(0x00751384,0x3c013f40) --hor value
eeObj.WriteMem32(0x00751388,0x44810000)
eeObj.WriteMem32(0x00751390,0x4600c602)

--FMV's fix
eeObj.WriteMem32(0x00443eb8,0x00000000)
eeObj.WriteMem32(0x00775398,0x24056e40)
eeObj.WriteMem32(0x007753a4,0x24072380)

-- Clamp value manually. Clamping from emulator change value to FLT_MIN
-- While we need correct lower bits + 1 due to x86 rounding...
eeObj.WriteMem32(0x92FD50, 0xFF7F8001)

emuObj.ThrottleMax()
end

emuObj.AddVsyncHook(patcher)

LUA
SLES_537.55

-- Widescreen hack by nemesis2000
-- new graphics fix by kozarovv
-- emu used=

local gpr = require("ee-gpr-alias")

apiRequest(0.1)

local eeObj  = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

--Widescreen
--gameplay
eeObj.WriteMem32(0x007526fc,0x3c013f40) --hor value
eeObj.WriteMem32(0x00752700,0x44810000)
eeObj.WriteMem32(0x00752708,0x4600c602)

--FMV's fix
eeObj.WriteMem32(0x004448d0,0x00000000)
eeObj.WriteMem32(0x00776718,0x24056d80)
eeObj.WriteMem32(0x00776724,0x24072380)

-- Clamp value manually. Clamping from emulator change value to FLT_MIN
-- While we need correct lower bits + 1 due to x86 rounding...
eeObj.WriteMem32(0x00931280, 0xFF7F8001)

emuObj.ThrottleMax()

end

emuObj.AddVsyncHook(patcher)

Call of Duty: World at War - Final Fronts

--ee-kernel-hle=1
--ee-injection-kernel=1
--ee-injection-title=1
--ee-cycle-scalar=1.9
--safe-area-min=1.0
--vu0-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1
# Fixed low framrate issue, !!!JAK EMULATOR Used!!!

Cold Winter

CLI


All Versions

--vu0-no-clamping=0
--vu1-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-clamp-operands=1
--vu1-clamp-results=1

# fix graphic and physics, there are still issue with fmv, and minor stering issue.

Crash Bandicoot - Wrath of Cortex

CLI
SLUS20238 SLUS-20238_cli.conf

--host-display-mode=16:9
--force-frame-blend=1
--gs-kernel-cl="h2lpool"  
--gs-kernel-cl-up="h2lpool2x2"
#Speedhacks
--vu1-di-bits=0

SLUS-20238_config.lua

-- Crash Bandicoot The Wrath of Cortex [SLUS-20238] (U)
-- emu used=KOF 98

apiRequest(1.0)   

local gpr = require("ee-gpr-alias")

local eeObj  = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

--16:9 hack
eeObj.WriteMem32(0x001138B8,0x3c013f11) --vertical fov
eeObj.WriteMem32(0x001127A0,0x3c013f2a) --zoom value
eeObj.WriteMem32(0x0011287C,0x3c013f2a) --render value

--No interlace
eeObj.WriteMem32(0x2016A048,0xAF80E750) 
eeObj.WriteMem32(0x2016A054,0xAF80E750)

--Underwater FX Fix
eeObj.WriteMem32(0x202438AC,0x0000182D) 

--Mech FX Fix
eeObj.WriteMem32(0x20257CF0,0x0000182D) 

--Cortex Vortex FX Fix
eeObj.WriteMem32(0x20242894,0x100000BC) 

--Disable Dark Effect
eeObj.WriteMem32(0x20258588,0x44801000) 

emuObj.ThrottleMax()
end

emuObj.AddVsyncHook(patcher)

emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } ) --texMode=1


SLES50386 SLES-50386_cli.conf

--host-display-mode=16:9
--gs-progressive=1

SLES-50386_config.lua

-- Crash Bandicoot The Wrath of Cortex [SLES-50386] (E)
-- emu used=KOF 2000

apiRequest(1.0)   

local gpr = require("ee-gpr-alias")

local eeObj  = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

--16:9 hack
eeObj.WriteMem32(0x21D43044,0x3F100000) --3F400000

emuObj.ThrottleMax()
end

emuObj.AddVsyncHook(patcher)

emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } ) --texMode=1

Crash Bandicoot 4: Sakuretsu! Majin Power クラッシュ・バンディクー4 ~さくれつ!魔神・パワー~
SLPM62114 SLPM-62114_cli.conf

--gs-uprender=2x2
--gs-upscale=edgesmooth
--host-display-mode=16:9
--force-frame-blend=1
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
#Speedhacks
--vu1-di-bits=0

#emu used=KOF 98

SLPM-62114_config.lua

-- Crash Bandicoot 4: Sakuretsu! Majin Power [SLPM-62114] (NTSC-J)
-- emu used=KOF 98

apiRequest(1.0)

local gpr = require("ee-gpr-alias")
local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

--16:9 hack
eeObj.WriteMem32(0x00113990,0x3C013F11) --vertical fov
eeObj.WriteMem32(0x0011250C,0x3C013F2A) --zoom value
eeObj.WriteMem32(0x00112958,0x3C013F2A) --render value

--No interlace
eeObj.WriteMem32(0x2016A2F8,0xAF80E750)
eeObj.WriteMem32(0x2016A304,0xAF80E750)

--Underwater FX Fix
eeObj.WriteMem32(0x2024D534,0x0000182D)

--Mech FX Fix
eeObj.WriteMem32(0x20261D78,0x0000182D)

--Cortex Vortex FX Fix
eeObj.WriteMem32(0x2024CBA4,0x100000BC)

--Disable Dark Effect
eeObj.WriteMem32(0x20262658,0x44801000)

emuObj.ThrottleMax()
end

emuObj.AddVsyncHook(patcher)

emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } ) --texMode=1

Crash Tag Team Racing

CLI
Pal

#Fix For Extreme slowdowns, 
#This game is known for being EXTREMELY VU1 hungry.
--vu1-mpg-cycles=1200
--vu1-di-bits=0
--vu1-const-prop=1
--ee-cycle-scalar=1.3

CLI
SLUS_211.91 only

--vu1-di-bits=0
--vu1-mpg-cycles=250
--ee-cycle-scalar=1.2
--ee-hook=0x0034C098,AdvanceClock,,500
#This will cause stuttering during car transformation animation
#But it is better than having slowdowns
--ee-hook=0x003547C8,AdvanceClock,,9000

LUA
SLUS_211.91 only

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

--Author: MrJaredBeta
--Fixes: Stuttering during coin animations
eeObj.WriteMem32(0x0022e3e4, 0x1000000c)

end
emuObj.AddVsyncHook(patcher)

Crash Twinsanity

CLI

KOF2000 EMU USED
All Versions

#Speedhacks
--ee-cycle-scalar=1.6
--vu1-mpg-cycles=400
--vu1-di-bits=0
#Graphical glitches fixes
--vu-xgkick-delay=5
--gs-use-clut-merge=1
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"

LUA
SLES-52568

apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.

-- Fix random crashes
eeInsnReplace(0x1923E8,0x5440FFFB,0x00000000)
eeInsnReplace(0x1923EC,0x0071182F,0x00000000)
eeInsnReplace(0x1923F0,0x0223102F,0x00000000)

-- Eliminate color scan lines
local emuObj = getEmuObject()

emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )

LUA
SLUS-20909

apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.

-- Fix random crashes
eeInsnReplace(0x191C58,0x5440FFFB,0x00000000)
eeInsnReplace(0x191C5C,0x0071182F,0x00000000)
eeInsnReplace(0x191C60,0x0223102F,0x00000000)

-- Eliminate color scan lines
local emuObj = getEmuObject()

emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )

Crash Nitro Kart


All Versions
CLI

--gs-uprender=2x2
--gs-upscale=edgesmooth
--gs-adaptive-frameskip=1
--force-frame-blend=1

--vu0-no-clamping=0
--vu1-no-clamping=0
--vu1-di-bits=0
--vu1=jit-sync

--vu1-mpg-cycles=2200
--vu1-jalr-cache-policy=newprog
--vu0-jr-cache-policy=sameprog

--ee-hook=0x005dbc38,AdvanceClock,,21000


LUA (NTSC ONLY!)

-- Crash Nitro Kart NTSC
-- Widescreen by Stayhye
-- ported to PS4 by Stayhye
-- emu used=jakx v2

local gpr = require("ee-gpr-alias")

apiRequest(2.0)

local emuObj 		= getEmuObject()
local eeObj			= getEEObject()
local gsObj			= getGsObject()
local eeOverlay 	= eeObj.getOverlayObject()
local iopObj        = getIOPObject()

emuObj.PadSetLightBar(0, 255,0,255)
emuObj.SetDisplayAspectWide()
gsObj.SetDeinterlaceShift(1) 
gsObj.SetUprenderMode(1) -- 0=none <> 1=2x2
emuObj.SetDeinterlace(true)

local patcher = function()
--freeze fix
eeObj.WriteMem32(0x003e8170,0)
--16:9
eeObj.WriteMem32(0x0058bcf8,0x3c023f40) -- 0x3c023f00 - hor. axis
eeObj.WriteMem32(0x0058bd0c,0x3c023f40) -- 0x3c023f00 -- zoom

--eeObj.WriteMem32(0x005dbc18,0x24030001)
eeObj.SchedulerDelayEvent("vif1.dma",0x5000)
emuObj.ThrottleMax() -- No negative.  
end

emuObj.AddVsyncHook(patcher)

Dead or Alive 2: Hardcore


LUA file


SLUS_200.71

apiRequest(0.1)

-- Fix hang, fix music, and sounds effects

emuMediaPatch(0x186A71, 12 + 0x7e4, { 0x2404002b }, { 0x27c40010 })
emuMediaPatch(0x186A71, 12 + 0x7e8, { 0x0c0032b3 }, { 0x0c0032b7 })
emuMediaPatch(0x186A71, 12 + 0x7ec, { 0x27c50010 }, { 0x00000000 })
emuMediaPatch(0x186A71, 12 + 0x5e8, { 0x27bdfff0 }, { 0x03e00008 })
emuMediaPatch(0x186A71, 12 + 0x5ec, { 0xafbe0008 }, { 0x00000000 })
emuMediaPatch(0x186A7B, 12 + 0x6fc, { 0x27bdfff0 }, { 0x03e00008 })
emuMediaPatch(0x186A7B, 12 + 0x700, { 0xafbe0008 }, { 0x00000000 })
emuMediaPatch(0x186A85, 12 + 0x164, { 0x27bdfff0 }, { 0x03e00008 })
emuMediaPatch(0x186A85, 12 + 0x168, { 0xafbe0008 }, { 0x00000000 })
emuMediaPatch(0x186A85, 12 + 0x10c, { 0x27bdfff0 }, { 0x03e00008 })
emuMediaPatch(0x186A85, 12 + 0x110, { 0xafbe0008 }, { 0x00000000 })
emuMediaPatch(0x186A85, 12 + 0x1bc, { 0x27bdfff0 }, { 0x03e00008 })
emuMediaPatch(0x186A85, 12 + 0x1c0, { 0xafbe0008 }, { 0x00000000 })
emuMediaPatch(0x186A86, 12 + 0x7f0, { 0x27bdfff0 }, { 0x03e00008 })
emuMediaPatch(0x186A86, 12 + 0x7f4, { 0xafbe0008 }, { 0x00000000 })
emuMediaPatch(0x186C38, 12 + 0x6ec, { 0x24060001 }, { 0x24060000 })

For the Japanese version (SLPS-25026) you can also use config files from PS3's PS2 emu with

--lopnor-config=1

in config.

Place config file named as "SLPS-25026_lopnor.cfgbin" in /patches/SLPS-25026/


*Alternate fix Jak emus


LUA file


--DOA 2 Hardcore NTSC US

apiRequest(2.2)

local gpr       = require("ee-gpr-alias")
local emuObj      = getEmuObject()
local eeObj       = getEEObject()
local gsObj       = getGsObject()
local eeOverlay    = eeObj.getOverlayObject()
local iopObj  = getIOPObject()

local patcher = function()

eeObj.WriteMem32(0x0021b63c,0x3c014534) -- Widescreen
eeObj.WriteMem32(0x002b06ec,0x24060000) -- Fixes game hanging on boot.
 
iopObj.WriteMem32(0x001D77E4,0x27C40010) --fixes music/sound effects
iopObj.WriteMem32(0x001D77E8,0x0C0032B7) --fixes music/sound effects  
iopObj.WriteMem32(0x001D77EC,0x00000000) --fixes music/sound effects 

end

emuObj.AddVsyncHook(patcher)

emuObj.PadSetLightBar(0,255,200,250)
emuObj.SetDisplayAspectWide()

Devil Kings

All versions
CLI

#Fix For Graphical Glitches (SPS)
--vu1-no-clamping=0

Disgaea 2: Cursed Memories

CLI


SLUS-21397

#Fix for lines in terrain textures and flickering textures
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--gs-use-mipmap=1

Digimon Rumble Arena 2

CLI


ALL

#Fix for game being stuck at main menu with selections moving very fast
--fpu-no-clamping=1
#Speedhack
--vu1-di-bits=0

Digimon World 4

CLI


All Versions

#Fixes slowdowns in The game
--vu1-di-bits=0
--vu1-const-prop=1
--vu1-mpg-cycles=700
--ee-cycle-scalar=1.2
#Fixes black screen caused by MTVU
--vu1=jit-sync
#Jakv2

Disney Golf

CLI


All Versions

#Fixes graphical glitches
--gs-use-clut-merge=1
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"
--force-frame-blend=1
#Other
--cdvd-sector-read-cycles=5000
#Speedhacks
--vu1-mpg-cycles=1000
--vu1-jr-cache-policy=newprog

#aofa

Dokapon Kingdom

CLI
All Versions

#Fixes black screen freeze.
--vu1=jit-sync

Dragon Ball Z: Budokai Tenkaichi 2

CLI


All Versions

#Fix for missing life bars and other UI elements.
--gs-use-clut-merge=1
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"

Dragon Ball Z: Budokai Tenkaichi 3

CLI


All Versions

#Fix for missing life bars and other UI elements
--gs-use-clut-merge=1
#Fix for mis-aligned glow caused by upscaling
--gs-kernel-cl-up="up2x2simple"
#Fix for Performance
--vu1-mpg-cycles=200
--vu1-di-bits=0
--ee-cycle-scalar=1.2

Dragon Quest VIII: Journey of the Cursed King

CLI


All Versions

--gs-kernel-cl-up="up2x2skipinterp"
--gs-optimize-30fps=1

#Fix lines in shadows

Dragon Quest V: Tenkuu no Hanayome

CLI

#Speedhacks
--ee-cycle-scalar=1.2
--vu1-di-bits=0
#Fix for being stuck in Faerie land.
--fpu-accurate-range=0x00693f88,0x00693f88

Dreamworks: Shrek the third


All Versions
CLI

#Slowdown fixes
--vu1-di-bits=0
--vu1-mpg-cycles=600
--ee-cycle-scalar=1.2

#Disable try to fix graphics if creating using ps2fpkg v0.6

DreamWorks Madagascar

CLI
All versions

#Game hates upscaling, so this will be enough to fix all upscaling problems.
--gs-kernel-cl-up="up2x2simple"
#Speedhacks
--vu1-mpg-cycles=300
--ee-cycle-scalar=1.2
--vu1-di-bits=0

LUA
SLES-53225
This patch fixes this issue

apiRequest(0.1)

--Fix for graphical problems, Game needs vu1 nearest rounding.
--Credit goes to Goatman13, Untested on ps4.
--Add one bit in LOI 8388609.0

local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()
eeobj.writemem8(0x0034BA40,0x01)
eeobj.writemem8(0x0034BDE0,0x01)
eeobj.writemem8(0x0034C100,0x01)
eeobj.writemem8(0x0034C490,0x01)
eeobj.writemem8(0x0034C810,0x01)
end
emuObj.AddVsyncHook(patcher)

DreamWorks Bee Movie Game

CLI
All versions

--ee-cycle-scalar=4.0 #fix pass fmv 
--vu0-di-bits=0
--vu1-di-bits=0
--vu1-jr-cache-policy=newprog #fix random crash?
--gs-uprender=1
--gs-upscale=edgesmooth
--host-display-mode=full

# Emu used = Primal

Ephemeral Fantasia™

CLI


All Versions

--gs-uprender=2x2
--gs-upscale=EdgeSmooth

--host-display-mode=16:9
--framelimit-mode=normal
#Fix for missing character/world parts
--vu1-no-clamping=0

Everblue 2

LUA file


SLES_513.81

apiRequest(0.1)

eeInsnReplace(0x230b68, 0x4be503bc, 0x4b0c211c)
eeInsnReplace(0x230b6c, 0x4b0c211c, 0x4be503bc)
eeInsnReplace(0x230b84, 0x4be603bc, 0x4bc0295c)
eeInsnReplace(0x230b88, 0x4bc0295c, 0x4be603bc)
eeInsnReplace(0x230ba0, 0x4be703bc, 0x4bc0319c)
eeInsnReplace(0x230ba4, 0x4bc0319c, 0x4be703bc)
eeInsnReplace(0x230bbc, 0x4be803bc, 0x4bc039dc)
eeInsnReplace(0x230bc0, 0x4bc039dc, 0x4be803bc)
eeInsnReplace(0x230bd8, 0x4be903bc, 0x4bc0421c)
eeInsnReplace(0x230bdc, 0x4bc0421c, 0x4be903bc)
eeInsnReplace(0x230bf4, 0x4bea03bc, 0x4bc04a5c)
eeInsnReplace(0x230bf8, 0x4bc04a5c, 0x4bea03bc)
eeInsnReplace(0x230c10, 0x4beb03bc, 0x4bc0529c)
eeInsnReplace(0x230c14, 0x4bc0529c, 0x4beb03bc)

#Missing textures fix

Fire Pro Wrestling Z™®

LUA

-- Fire Pro Wrestling Z™® (English v0.5b)
-- boot fix
-- needs graphics fix
-- emu used=aofa

local gpr = require("ee-gpr-alias")

apiRequest(0.1)

local eeObj  = getEEObject()
local emuObj  = getEmuObject()

local patcher = function()
-- black screen after spike logo fix
eeObj.WriteMem32(0x001eaa14,0x0) --0x1440fffa >> bne v0, zero, $001eaa00
emuObj.ThrottleMax()
end

emuObj.AddVsyncHook(patcher)

Flatout 2

LUA
SLUS212.51

apiRequest(0.1)
local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

----Disable graphics overlay to fix all slowdown + widescreen code
eeObj.WriteMem32(0x3a0498,0x3c013f14)
eeObj.WriteMem32(0x2d4b40,0x3c014010)
eeObj.WriteMem32(0x22e768,0x3C013F8A)
eeObj.WriteMem32(0x2d5B30,0x00000000)
end

emuObj.AddVsyncHook(patcher)

LUA
SLES540.02

apiRequest(0.1)
local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

--Disable graphics overlay to fix all slowdown + widescreen code
eeObj.WriteMem32(0x3A1F28,0x3c013f14)
eeObj.WriteMem32(0x2D6650,0x3c014010)
eeObj.WriteMem32(0x234F18,0x3C013F8A)
eeObj.WriteMem32(0x2d7640,0x00000000)
end

emuObj.AddVsyncHook(patcher)

Frogger: Ancient Shadow

CLI


SLUS_210.98

#This one might be the only one you need
--vu1-no-clamping=0
#use the rest just in case
--vu0-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1 
#Fixes disappearing models during cutscenes and during gameplay

Galactic Wrestling Featuring Ultimate Muscle

NTSC/U
CLI

--fpu-no-clamping=0
--fpu-clamp-results=1
--vu0-no-clamping=0
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-results=1
#fix for missing character models
--vu-xgkick-delay=0.58
#KOF98Emu used

Galarians: Ash

CLI

--gs-uprender=2x2
--gs-upscale=EdgeSmooth
--gs-adaptive-frameskip=1

--vif-ignore-invalid-cmd=0
--vif1-ignore-cmd-ints=1
--vif1-instant-xfer=0

--ee-jit-pagefault-threshold=30

--lopnor-config=1 #found here http://ps3.aldostools.org/ps2config.html

--ee-cycle-scalar=2.0

LUA file

-- Galarians Ash NTSC
-- emu used=jakx v2

local gpr = require("ee-gpr-alias")

apiRequest(2.2)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

eeObj.WriteMem32(0x001e0100,0x3c013f40) -- 16:9
emuObj.ThrottleMax() -- Drastically reduces loading screens duration on most games

end

emuObj.AddVsyncHook(patcher)

Ghost in the Shell: Stand Alone Complex


LUA file


SLES_530.20

apiRequest(0.1) -- request version 0.1 API. Calling apiRequest() is mandatory.

eeInsnReplace(0x10BC88, 0x4BEC682C, 0x48468800)
eeInsnReplace(0x10BC8C, 0x4B8D617D, 0x4bec682c)
eeInsnReplace(0x10BC90, 0x4A6D617C, 0x4b8d617d)
eeInsnReplace(0x10BC98, 0x48468800, 0x4a6d617c)
eeInsnReplace(0x12B2CC, 0x4BEC682C, 0x48468800)
eeInsnReplace(0x12B2D0, 0x4B8D617D, 0x4bec682c)
eeInsnReplace(0x12B2D4, 0x4A6D617C, 0x4b8d617d)
eeInsnReplace(0x12B2DC, 0x48468800, 0x4a6d617c)
eeInsnReplace(0x12B5F4, 0x4BEC682C, 0x48468800)
eeInsnReplace(0x12B5F8, 0x4B8D617D, 0x4bec682c)
eeInsnReplace(0x12B5FC, 0x4A6D617C, 0x4b8d617d)
eeInsnReplace(0x12B604, 0x48468800, 0x4a6d617c)
eeInsnReplace(0x1B0B58, 0x4BEC682C, 0x48468800)
eeInsnReplace(0x1B0B5C, 0x4BED617D, 0x4bec682c)
eeInsnReplace(0x1B0B68, 0x48468800, 0x4b8d617d)
eeInsnReplace(0x1BF5FC, 0x4A0002FF, 0x48588800)
eeInsnReplace(0x1BF60C, 0x48588800, 0x4a0002ff)
eeInsnReplace(0x1BFBB8, 0x4A0002FF, 0x48588800)
eeInsnReplace(0x1BFBC8, 0x48588800, 0x4a0002ff)
eeInsnReplace(0x1BF818, 0x4A0002FF, 0x48588800)
eeInsnReplace(0x1BF828, 0x48588800, 0x4a0002ff)
eeInsnReplace(0x1C017C, 0x4A0002FF, 0x48588800)
eeInsnReplace(0x1C018C, 0x48588800, 0x4a0002ff)

-- Potential fix for broken interactive door // Rearranging COP2 ops so as to avoid macflag bad stuff

Gran turismo 4

CLI
All
Forbidden siren v2 emu only

#Fix incomplete letters in menu
--vu0-no-clamping=0
--vu1-no-clamping=0
#Speedhacks
--ee-cycle-scalar=1.2
--vu1-di-bits=0
--vu1-mpg-cycles=700
#Fix video anticipated race license
--fpu-accurate-muldiv-range=0x00579EB8,0x00579EB8
--fpu-accurate-muldiv-range=0x00579EDC,0x00579EDC
--fpu-accurate-muldiv-range=0x0057A008,0x0057A008
--fpu-accurate-muldiv-range=0x0057A030,0x0057A030
#Gfx fix
--vif1-instant-xfer=0
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"

CLI
SCPS-17001
Forbidden siren v2 emu only

#Fix incomplete letters in menu
--vu0-no-clamping=0
--vu1-no-clamping=0
#Speedhacks
--ee-cycle-scalar=1.2
--vu1-di-bits=0
--vu1-mpg-cycles=700
#Fix video anticipated race license
--fpu-accurate-muldiv-range=0x00571A92,0x00571A92
--fpu-accurate-muldiv-range=0x00571AB4,0x00571AB4
--fpu-accurate-muldiv-range=0x00571BE0,0x00571BE0
--fpu-accurate-muldiv-range=0x00571C08,0x00571C08
#Gfx fix
--vif1-instant-xfer=0
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"

LUA
SCES-51719 only

--gametitle=Gran Turismo 4 [SCES-51719] (E)
--emu=siren v2

apiRequest(0.1)

local eeObj     = getEEObject()
local emuObj = getEmuObject()
local gsObj     = getGsObject()

local widescreen = function()

-- force progressive scan
eeObj.WriteMem32(0x20A57E70,0x00000001)
eeObj.WriteMem32(0x201074A0,0x24050003) --8E050004
eeObj.WriteMem32(0x2061868C,0x00000001) --00000000
eeObj.WriteMem32(0x20618694,0x00000000) --00000001

-- Autoboot in 480p
eeObj.WriteMem32(0x20436820,0xAE0516B0) --AE0010E8
eeObj.WriteMem16(0x20436910,0x10E8) --

--Field of View

-- Screen Width   (mm)
eeObj.WriteMem32(0x20A567F0,0x446E0000) -- 952mm in my case

-- Screen Height (mm)
eeObj.WriteMem32(0x20A567F4,0x4405C000) -- 535mm in my case

-- Eye Distance to Screen (mm)
eeObj.WriteMem32(0x20A567EC,0x44610000) -- 900mm in my case

-- Zoom Level (-2.0 to 2.0)
eeObj.WriteMem32(0x20A567E8,0x3f800000) -- 1.0, we already have the right FoV Better don't touch this


--Aspect Ratio

--   Single Screen Aspect Ratios
--    1 x 16:9  3f800000
--    1 x 21:9  3FAAAAAB
--    1 x 32:9  40000000

--   Triple Screen Aspect Ratios
--    3 x 16:9  40400000

eeObj.WriteMem32(0x20A567F8,0x3f800000) -- 16:9 in my case

-- disable colour correction channel shuffle effect
eeObj.WriteMem32(0x0033F8B8,0x1000000B) --5440000B

-- disable rendering of light sources
eeObj.WriteMem32(0x0033F6B0,0x10000031) --10400031

-- Fix shadows
eeObj.WriteMem32(0x001D6598,0x00000000) --0C075A6A

-- Added GT4 First Preview camera mode (far chase camera)
eeObj.WriteMem32(0x2037AFAC,0x84E30000)
eeObj.WriteMem16(0x2037AFB0,0x0002)
eeObj.WriteMem16(0x2037AFC0,0x0004)
eeObj.WriteMem32(0x2037AFD0,0x84E30000)

eeObj.WriteMem16(0x2037AFE0,0x0004)
eeObj.WriteMem8(0x0037AFF8,0x40)
eeObj.WriteMem16(0x2037B00A,0x8442)

eeObj.WriteMem32(0x206211E8,0x00010000)
eeObj.WriteMem32(0x206211EC,0x00060014)

end

emuObj.AddVsyncHook(widescreen)

Gran Turismo 4 - Prologue


PBPX-95524
LUA

local gpr = require("ee-gpr-alias")

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

--fix IPU DMA 
eeObj.WriteMem32(0x166814,0x0)
eeObj.WriteMem32(0x3a36b8,0x0)
eeObj.WriteMem32(0x3a36f4,0x0)

emuObj.ThrottleMax()
end

emuObj.AddVsyncHook(patcher)

Grand Theft Auto: Vice City Stories

SLUS_215.90
CLI

--gs-uprender=2x2
--gs-upscale=edgesmooth
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"

--host-display-mode=16:9
#emu used=psychonauts v2


LUA

-- emu used=psychonauts v2
local gpr = require("ee-gpr-alias")

apiRequest(1.0)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

--widescreen fix
eeObj.WriteMem32(0x002653d8,0x3c013f9d)
eeObj.WriteMem32(0x002653dc,0x44810000)
eeObj.WriteMem32(0x002653e0,0x46006302)
eeObj.WriteMem32(0x002653e4,0x3c020048)
eeObj.WriteMem32(0x002653e8,0x03e00008)
eeObj.WriteMem32(0x002653ec,0xe44c7484)

eeObj.WriteMem32(0x0037add4,0x0c0994f6)
eeObj.WriteMem32(0x003b9d14,0x0c0994f9)
eeObj.WriteMem32(0x003ba1b0,0x0c0994f9)

eeObj.WriteMem32(0x20370314,0x10820019)--60fps

--eeObj.WriteMem32(0x20447EDC,0x00000000)--no interlace

end

emuObj.AddVsyncHook(patcher)

-- 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 } )

Grand Theft Auto: Liberty City Stories

SLUS_214.23
CLI

--gs-uprender=2x2
--gs-upscale=edgesmooth
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
--gs-h2l-list-opt=1
--gs-h2l-accurate-hash=1
--gs-adaptive-frameskip=1

--vu0-mpg-cycles=600
--vu1-mpg-cycles=600

--ee-cycle-scalar=1.3

God Hand

CLI

--vu0-no-clamping=0
--vu1-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1

#fix for graphical glitches, specially the missing ground.

God Of War


EU CLI

--vu1-di-bits=0
--vu1-mpg-cycles=800
--vu1-jr-cache-policy=newprog
--vu1-jalr-cache-policy=newprog
--ee-block-validation=PageProt
--ee-cycle-scalar=1.2
--ee-hook=0x0017A2DC,AdvanceClock,,45
#Fix for upscaling glitches
--gs-kernel-cl-up="up2x2simple"
#Fix for audio re-starting
--iop-cycle-scalar=0.1
--cdvd-sector-seek-cycles=0.1
--cdvd-sector-read-cycles=4500


US

--gs-uprender=2x2
--gs-upscale=EdgeSmooth
--gs-adaptive-frameskip=1
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
--gs-progressive=1

--ee-cycle-scalar=2.0

--vu1-mpg-cycles=2000
--vu1-di-bits=0
--vu1=trans
#Cdvd timing
--iop-cycle-scalar=0.20
--cdvd-sector-read-cycles=4000

LUA file

-- God Of War EU & US

-- 01 Music sound problem: music restarts every time there are many sounds to play
-- 02 Latest emu removes a lot of game lag, anyway the game still suffer of shuttering in the next levels
-- 03 Corrupted green lines around the objects, uprendering problem
-- Slowdowns and performances patched in cli.conf file
apiRequest(2.2)

local emuObj 		= getEmuObject()
local gsObj		= getGsObject()

-- 03 removes corrupted lines around the objects when use --gs-uprender
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )

-- Disable internal field shift compensation, part of post-process removal feature.
gsObj.SetDeinterlaceShift(0)

God of War 2

CLI

--gs-uprender=2x2
--gs-upscale=edgesmooth
--gs-adaptive-frameskip=1
--ee-cycle-scalar=0.62
--iop-cycle-scalar=0.10
--vu1-mpg-cycles=1985
--vu1-jr-cache-policy=newprog
--vu1-jalr-cache-policy=newprog
--cdvd-sector-read-cycles=4000
--host-audio-latency=1.6
--host-display-mode=16:9

*Jakx Emu used*

LUA File

-- God of War II  
-- ported to PS4 

apiRequest(2.2)

local gpr    		= require("ee-gpr-alias")
local cpr    		= require("ee-cpr0-alias")
local hwaddr    	= require("ee-hwaddr")

local emuObj 		= getEmuObject()
local eeObj			= getEEObject()
local gsObj			= getGsObject()
local eeOverlay 	= eeObj.getOverlayObject()
local iopObj        = getIOPObject()
     
emuObj.SetDisplayAspectWide()
gsObj.SetDeinterlaceShift(1) 

local patcher = function()

--skip renShadowClient::Prep
--eeObj.WriteMem32(0x001706E0,0x03e00008)
--eeObj.WriteMem32(0x001706E4,0x00000000)
--skip renPrimMaster::RenderStencilLayer
eeObj.WriteMem32(0x0016E720,0x03e00008)
eeObj.WriteMem32(0x0016E724,0x00000000)
--skip fxBloom::Client::Run
eeObj.WriteMem32(0x00126EB0,0x03e00008)
eeObj.WriteMem32(0x00126EB4,0x00000000)
--default to progressive at first run
eeObj.WriteMem32(0x0025a608,0xa04986dc)
eeObj.WriteMem32(0x001E45D4,0x24020001)
--default to ws at first run
eeObj.WriteMem32(0x001E45B4,0x24040001)
eeObj.WriteMem32(0x001E45B8,0x00000000)
eeObj.WriteMem32(0x0027894C,0x3c013fe3)
eeObj.WriteMem32(0x00278950,0x34218e39)
--allow mpeg skip by pressing x
eeObj.WriteMem32(0x001DD8C8,0x00000000)


emuObj.ThrottleMax()
end

emuObj.AddVsyncHook(patcher)

emuObj.SetGsTitleFix( "SetSelfRender", "reserved", { fbmask= 0x00FFFFFF , renderSelf=1 , zmsk=1 , alpha=0 , texMode=1  } )
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1  } )

Gradius V

CLI

--vu1=jit-sync

#fix for blackscreen after PS2 Logo.

Grandia III

LUA
NTSC

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

eeObj.WriteMem32(0x0014586C, 0x0)

end
emuObj.AddVsyncHook(patcher)

Harry Potter and The Prisoner of Azkaban

CLI
Emu: Jakv2

#Fix for graphical issues
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
#Fix for random freezing even after the EE memory patch
--vif1-instant-xfer=0

LUA
SLUS20926

apiRequest(0.1)

-- Full credits to Kozarovv
local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()
--clear interrupts in handler

eeObj.WriteMem32(0x000fff00, 0x3c191000)
eeObj.WriteMem32(0x000fff04, 0x24180c00)
eeObj.WriteMem32(0x000fff08, 0x081137e0)
eeObj.WriteMem32(0x000fff0c, 0xaf380010)
eeObj.WriteMem32(0x0016fb7c, 0x0c03ffc0)
end
emuObj.AddVsyncHook(patcher)

Hunter the Reckoning Wayward

CLI


All Versions

--gs-uprender=2x2
--gs-upscale=EdgeSmooth

--host-display-mode=16:9

--vu1-no-clamping=0


#fix for graphical glitches.

Ice Age 2 Meltdown

LUA file
Company logo freeze Fix
Use Forbidden Siren v2 Emu


SLUS_213.07

apiRequest(0.1)

eeInsnReplace(0x2feb80, 0x27bdff70, 0x27bdfee0)
eeInsnReplace(0x2febbc, 0x27bd0090, 0x27bd0120)


SLES_539.84

apiRequest(0.1)

eeInsnReplace(0x2ff3f0, 0x27bdff70, 0x27bdfee0)
eeInsnReplace(0x2ff42c, 0x27bd0090, 0x27bd0120)


SLPM_664.97

apiRequest(0.1)

eeInsnReplace(0x2e91e8, 0x27bdff70, 0x27bdfee0)
eeInsnReplace(0x2e9224, 0x27bd0090, 0x27bd0120)

Jackie Chan Adventures

CLI


SCES_524.12

#Fix For Jackie chan falling forever near The Ox Talisman Glitch
--fpu-accurate-addsub-range=0x22F2B0,0x22F468
#Fixes For Slowdowns
--vu1-di-bits=0
--vu1-const-prop=1
--ee-cycle-scalar=1.2
#RECVX

Jaws Unleashed


LUA file


apiRequest(1.0)
local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()
eeObj.WriteMem32(0x006758a8,0x03e42000)
eeObj.WriteMem32(0x006758b8,0x800026fc)
end
emuObj.AddVsyncHook(patcher)

#fix for loading screen hang. 

Juiced

CLI
All versions

#Fix for graphical glitches
--gs-kernel-cl-up="up2x2simple"
#Speedhacks
--vu1-di-bits=0
--vu1-mpg-cycles=800
--ee-cycle-scalar=1.2

Killer7

CLI


All versions

--vu0-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-clamp-operands=1
--vu1-clamp-results=1

#fix for flickering polygons.

Kim Possible: What's the Switch

CLI


PAL

--vu1-mpg-cycles=950

#fix lag during cutscenes

Klonoa 2

CLI


All versions

#Fix for Misplaced objects
--fpu-no-clamping=1
#Potential fix for Graphics
--vu1-no-clamping=0
--vu0-no-clamping=0

#still require fix for texturing problems. Require Rogue Galaxy emu

Kuon


CLI
All Versions

--vif1-ignore-cmd-ints=1
--vif-ignore-invalid-cmd=0
--vif1-instant-xfer=0
#Fix the freezing problem in the opening scene of 《阴の章》


NTSC Version ONLY CLI

--vif1-ignore-cmd-ints=1
--vif-ignore-invalid-cmd=0
--vif1-instant-xfer=0
#Sugoroku Fix
--fpu-accurate-addsub=0x104124

Time Crisis 2

LUA
SLUS_202.19

-- Time Crisis 2 SLUS_202.19
-- Widescreen Hack
-- fix by Kozarovv
-- emu used=jakx v2

apiRequest(0.1)

local iopObj = getIOPObject()
local emuObj = getEmuObject()
local eeObj  = getEEObject()
 
local FireWithoutWire = function()
   --16:9
   eeObj.WriteMem32(0x003cd7fc,0x3f400000)
   --Infinite Credits by InterAct
   --eeObj.WriteMem32(0x00482410,0x00090009)
 
  -- Fix cdvd issue which cause ieee1394 error
  iopObj.WriteMem32(0xACD40,0)
  
  -- Audio desync fix (probably useless, or even harmful on ps4 due to different "cyclerate")
  -- eeObj.WriteMem32(0x154954,0x10000009)
 
   emuObj.ThrottleMax()
end
 
emuObj.AddVsyncHook(FireWithoutWire)

Time Crisis 3

LUA
SLUS_206.45

-- Time Crisis 3 SLUS_206.45
-- Widescreen Hack
-- Fix by Kozarovv
-- emu used=aofa

apiRequest(0.1)

local iopObj = getIOPObject()
local emuObj = getEmuObject()
local eeObj  = getEEObject()
 
local FireWithoutWire = function()
   --16:9
   eeObj.WriteMem32(0x0033976c,0x3f400000)
   --Infinite Credits by InterAct
   --eeObj.WriteMem32(0x00482410,0x00090009)
 
  -- Fix cdvd issue which cause ieee1394 error
  iopObj.WriteMem32(0xA0840,0)
  
  -- Audio desync fix (probably useless, or even harmful on ps4 due to different "cyclerate")
  -- eeObj.WriteMem32(0x154954,0x10000009)
 
   emuObj.ThrottleMax()
end
 
emuObj.AddVsyncHook(FireWithoutWire)

Tomb Raider: The Angel of Darkness


SLUS20467
Skip the first fmv to prevent freezing!
LUA

local gpr = require("ee-gpr-alias")

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

-- Black screen fix
eeObj.WriteMem32(0x00207B24, 0x0) -- 1040FFFA
eeObj.WriteMem32(0x00207B4C, 0x0) -- 1040FFFA

end
emuObj.AddVsyncHook(patcher)


SLES51227
Skip the first fmv to prevent freezing!
LUA

local gpr = require("ee-gpr-alias")

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

-- Black screen fix
eeObj.WriteMem32(0x00209D9C, 0x0) -- 1040FFFA
eeObj.WriteMem32(0x00209DC4, 0x0) -- 1040FFFA

end
emuObj.AddVsyncHook(patcher)

Largo Winch - Empire Under Threat


SLES-51093
CLI

--gs-uprender=2x2
--gs-upscale=EdgeSmooth
--host-display-mode=16:9
--cdvd-sector-read-cycles=5000
#emu used=rotk v1

LUA file

-- Largo Winch - Empire Under Threat (E)(SLES-51093)
-- Widescreen hack by Arapapa
-- Fix by Kozarovv
-- ported to PS4 lua by Stayhye
-- emu used=rotk v1

local gpr = require("ee-gpr-alias")

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local WS2 = function()
--16:9
--Zoom
eeObj.WriteMem32(0x0028029c,0x3c013f2f) --3c013f80
--Y-Fov
eeObj.WriteMem32(0x001abc40,0x08030000)

eeObj.WriteMem32(0x000c0000,0x46070a02)
eeObj.WriteMem32(0x000c0004,0x3c013fa6)
eeObj.WriteMem32(0x000c0008,0x4481f000)
eeObj.WriteMem32(0x000c000c,0x461e4202)
eeObj.WriteMem32(0x000c0010,0x0806af11)
----------------------------
--X-Fov (Needs render fix)
--eeObj.WriteMem32(0x001abb98,0x08030000)
--eeObj.WriteMem32(0x000c0000,0x24420050)
--eeObj.WriteMem32(0x000c0004,0x3c013f40)
--eeObj.WriteMem32(0x000c0008,0x4481f000)
--eeObj.WriteMem32(0x000c000c,0x461e4202)
--eeObj.WriteMem32(0x000c0010,0x0806aee7)
--Start microprograms manually instead of rely on timings.
--0x48c83000 >> ctc2 t0, $vi6
--eeObj.WriteMem32(0x00116d4c,0x4a0000b8)
eeObj.WriteMem32(0x00116e04,0x4a0000b8)
eeObj.WriteMem32(0x00116fe0,0x4a0000b8)
eeObj.WriteMem32(0x00117054,0x4a000938)
eeObj.WriteMem32(0x001170a4,0x4a000938)
eeObj.WriteMem32(0x001172ac,0x4a000938)
eeObj.WriteMem32(0x001172e4,0x4a000938)
eeObj.WriteMem32(0x00117470,0x4a000938)
eeObj.WriteMem32(0x001174ac,0x4a000938)
eeObj.WriteMem32(0x00117540,0x4a000938)
-- No need to loop here, just e-bit and wait for vcallms from EE.
eeObj.WriteMem32(0x00298f70,0x8000033c) -- 500607ff
eeObj.WriteMem32(0x00298f74,0x400002ff)
eeObj.WriteMem32(0x002990a0,0x8000033c)
eeObj.WriteMem32(0x002990a4,0x400002ff)
--Remove xgkick responsible for shadow packet.
eeObj.WriteMem32(0x2B1810,0x8000033c)

--pros. Fix bug, allow upscalling cons. No shadow.

emuObj.ThrottleMax()
end

emuObj.AddVsyncHook(WS2)


The Legacy of Kain - Blood Omen 2

LUA

-- Boot fix by Kozarovv                           --
-- ported to PS4 lua by JSimesen                  --
-- PS3 mipmapping fix converted                   --
-- Specal Thanks to: Kozarovv, Stayhye, Scalerize --
-- emu used=KOF2000                               --
                                                                                             
apiRequest(1.0)                                   

local eeObj = getEEObject() 
local emuObj = getEmuObject()

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 (R2 ~= 0 and UP ~= 0) then

emuObj.SetFormattedCard("blood.card")
end

end

emuObj.AddVsyncHook(CheckInputs)

emuObj.SetDisplayAspectWide()


local patcher = function()

eeObj.WriteMem32(0x002f4350,0x10000006)

-- No Widescreen
-- eeObj.WriteMem32(0x00312b08,0x3C013FE3)
-- eeObj.WriteMem32(0x00312b0c,0x34218E38)

-- No Black Borders Fix
-- eeObj.WriteMem32(0x002d443c,0x00000000) -- causes kain to not re-appear after dying/loading

-- No Fix FMV
-- eeObj.WriteMem32(0x002eb280,0x240575e0) --y-position
-- eeObj.WriteMem32(0x002eb298,0x240a1440) --y-scaling

end

emuObj.AddVsyncHook(patcher)

local fix = function()

-- Completely skip ridiculous debugger hook.
eeObj.WriteMem32(0x297DA8, 0x10000006)
eeObj.WriteMem32(0x297DA0, 0x00000000)

end

emuObj.AddEntryPointHook(fix)

emuObj.SetGsTitleFix( "forceSimpleFetch",  "reserved", {psm=0} )
emuObj.SetGsTitleFix( "fetchFromCurrBuff", "reserved", {psm=0} )

Legacy of Kain: Defiance

SLUS_207.73
LUA

apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.

-- Texture Flickering fix

eeInsnReplace(0x188F50, 0x10600020, 0x10000020)

SLES_521.50
LUA

apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.

-- Texture Flickering fix

eeInsnReplace(0x189340, 0x10600020, 0x10000020)

Legacy of Kain: Soul Reaver 2

SLES_501.96
Lua

apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.

-- Turn off mipmapping in game engine. Completely fix flickering, and bad texturing. Don't require "gs-kernel-cl=mipmap"
-- SLES_501.96 only!

eeInsnReplace(0x2A1F80, 0x00000001, 0x00000000)

Mafia

CLI


All versions

--host-display-mode=16:9
--framelimit-mode=normal
--cdvd-sector-read-cycles=6000
--ee-cycle-scalar=2.1
--vif1-instant-xfer=0
#Fix.

LUA file

SLUS-20671 (NTSC)

-- emu used=kinetica v2

apiRequest(1.0)   

local gpr = require("ee-gpr-alias")

local eeObj  = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

-- Widescreen + Render fix
eeObj.WriteMem32(0x20FF8D60,0x3f3fffff)

--Rendering distance (Optional)
--eeObj.WriteMem32(0x20FF8DB8,0x44000000)

--avoid hang before molotov party
eeObj.WriteMem32(0x003E2BB4,0x00000000) --00000000

--fix crash in The priest mission
eeObj.WriteMem32(0x0016F04C,0x1000000D) --1000000D

emuObj.ThrottleMax()

end

emuObj.AddVsyncHook(patcher)

Manhunt 2

CLI

--ee-kernel-hle=1
--ee-injection-kernel=1
--ee-injection-title=1
--ee-block-validation=PageProt
--vu1-opt-flags=2
--vu1-jr-cache-policy=newprog
--vu1-jalr-cache-policy=newprog
--vu1-mpg-cycles=900
--gs-frontend-opt-mode=2
--gs-adaptive-frameskip=1
--gs-optimize-30fps=1
--framelimit-fps=2.0
--ee-cycle-scalar=0.8
--gs-uprender=none

# Fixed framerate dip issue using Jak v2 emulator (NOTE: disabling uprender fixes fps drop to some extent and corrupted lines on shadows, however in NTSC Version, there will be a black screen glitch in cutscenes only!!).

LUA file

apiRequest(0.1)

-- Fix lags and slowdowns

eeInsnReplace(0x370DA8, 0x00000000, 0x24020001)

# Minor framerate issue exists in NTSC version. PAL version works fine with no pain.

Max Payne 2

CLI

--vu0-no-clamping=0
--vu1-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1
# Fixed green, blue and red graphical issues. The game works better.

Metal Gear Solid 2 - Sons of Liberty

CLI
All versions
Jakv2 used

#Speedhacks
--vu1-di-bits=0
#Gamefixes for freeze, Not tested much but once i used it. the freezes were gone
--vif-ignore-invalid-cmd=1
--vif1-ignore-cmd-ints=1

Metal Gear Solid 2: Substance

CLI
All versions
Use jakv2. Untested.

#Speedhacks
--vu1-di-bits=0
--vu1-mpg-cycles=700
#Gamefixes for freeze, Not tested much but once i used it. the freezes were gone
--vif-ignore-invalid-cmd=1
--vif1-ignore-cmd-ints=1

Mojib-Ribbon

CLI
Works on kof98

--vif-ignore-invalid-cmd=1
--vif1-ignore-cmd-ints=1
--vif1-instant-xfer=0
--vu1=jit-sync

Midnight Club 3: DUB Edition / Remix

CLI
All versions
Note: VU1 clamping will cause the cars to not load properly, please don't use it on this game.

#Speedhacks
--ee-cycle-scalar=1.2
--vu1-mpg-cycles=350
--vu1-injection=1
--vu1-di-bits=0
--vu1-const-prop=1

MTV's Celebrity Deathmatch

CLI


All versions

#Disables MTVU
--vu1=jit-sync

#Fix for black-screen after ps2 logo.

Musashi Samurai Legend

LUA
NTSC

apiRequest(0.1)

local gpr       = require("ee-gpr-alias")

local emuObj      = getEmuObject()
local eeObj       = getEEObject()

local patcher = function()
eeObj.WriteMem32(0x203DD108,0x3F19999A) --3F4CCCCD

--SPS FiX
eeObj.WriteMem32(0x001476A4,0x10000047) --10600047
eeObj.WriteMem32(0x002E8D78,0x8000033C) --80005EFC
end

emuObj.AddVsyncHook(patcher)

Need for Speed Carbon

CLI


SLES_543.22

  
#Fix loading freeze
--fpu-accurate-range=0x162800,0x162900

--ee-cycle-scalar=1.35
--vu1-mpg-cycles=900
--vu1-const-prop=1
--vu1-di-bits=0

Need for Speed Underground 2

LUA


SLUS-21065

apiRequest(1.0)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()
--Speed Fix
eeObj.WriteMem32(0x001D77C8,0x100000B4)
end

emuObj.AddVsyncHook(patcher)

NBA Street Vol.2

CLI


All versions

#Fix for Graphical glitches
--vu1-no-clamping=0
#Jakv2 emu Used

Okami

CLI


All versions

--gs-use-mipmap=1
--gs-force-bilinear=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--vu0-no-clamping=0
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-clamp-results=1
--cop2-clamp-results=1
--cop2-no-clamping=0
#Fixes for slowdowns
--vu1-const-prop=1
--vu1-di-bits=0
--ee-cycle-scalar=1.2		
--vu1-injection=1
#RECVX EMU Fixes Crash Near Orochi boss fight

LUA file
All Versions

apiRequest(0.4)

local emuObj = getEmuObject()

emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )

Oni

LUA


SLES_501.34
SLES_501.76
SLES_501.77
SLES_501.78
SLES_501.79

apiRequest(0.1)

-- Fix for hang at loading screen

eeInsnReplace(0x1CEF7C, 0x4100FFFF, 0x00000000)

LUA


SLUS_200.64

apiRequest(0.1)

-- Fix for hang at loading screen

eeInsnReplace(0x1CF3CC, 0x4100FFFF, 0x00000000)

Pac Man World 3

CLI
SLES-53959

--gs-uprender=2x2
--gs-upscale=edgesmooth
--cdvd-sector-read-cycles=2000
--host-display-mode=16:9
#Fix for fmvs showing black screen with subtitles
--fpu-accurate-range=0x3f3068,0x3f32bc

#emu used=fatal fury battle archives vol2

LUA
SLES-53959

-- Pac-Man World 3 (PAL-M5)(SLES-53959)
-- Widescreen Hack by ICUP321
-- emu used=fatal fury battle archives vol2
-- Ported to ps4 by Stayhye
local gpr = require("ee-gpr-alias")

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()
--Widescreen hack 16:9
eeObj.WriteMem32(0x003f30c4,0x3c013f40)
eeObj.WriteMem32(0x003f30c8,0x4481f000)
eeObj.WriteMem32(0x003f30d0,0x461eb582)
--Render fix
eeObj.WriteMem32(0x00439184,0x3c013f2b)

emuObj.ThrottleMax()
end

emuObj.AddVsyncHook(patcher)

Pac-Man World Rally


SLUS-21328
CLI

--vu1-no-clamping=1
--vu0-no-clamping=1

SLUS-21328
LUA

local gpr = require("ee-gpr-alias")

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()
eeObj.WriteMem32(0x0016DDE4,0x4A80AADC)
eeObj.WriteMem32(0x0016DDEC,0x4B7103BC)
eeObj.WriteMem32(0x0016DDD0,0x4B00A29C)
eeObj.WriteMem32(0x0016DDD8,0x4AF103BC)

end

emuObj.AddVsyncHook(patcher)

Phantasy Star Universe

CLI

All Versions

#Fix for flickering textures and geometry
--gs-use-clut-merge=1
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"

--gs-adaptive-frameskip=1
--cdvd-sector-read-cycles=4000

#fix for Enemies dont move bug
--fpu-accurate-mul-fast=1
--fpu-accurate-range=0x48cce0,0x49cce0

#emu used=jakx v2

PK - Out of the Shadows


NTSC
LUA

-- Disney's PK - Out of the Shadows
-- boot fix by kozarovv
-- Widescreen Hack by Arapapa
-- emu used=rotk v1

local gpr = require("ee-gpr-alias")

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local WS2 = function()
--16:9
eeObj.WriteMem32(0x003324b0,0xbf400000) --0x3f800000
--0x48c83000 >> ctc2 t0, $vi6
eeObj.WriteMem32(0x001dfa8c,0x4a0000b8)
eeObj.WriteMem32(0x001dfc24,0x4a0000b8)
eeObj.WriteMem32(0x001dfcac,0x4a0000b8)
eeObj.WriteMem32(0x001dfd00,0x4a000938)
eeObj.WriteMem32(0x001dffdc,0x4a000938)
eeObj.WriteMem32(0x001e003c,0x4a000938)
eeObj.WriteMem32(0x001e022c,0x4a000938)
eeObj.WriteMem32(0x001e028c,0x4a000938)
eeObj.WriteMem32(0x001e0348,0x4a000938)
-- No need to loop here, just e-bit and wait for vcallms from EE.
eeObj.WriteMem32(0x00324a90,0x8000033c) -- 500607ff
eeObj.WriteMem32(0x00324a94,0x400002ff)
eeObj.WriteMem32(0x00324bc0,0x8000033c)
eeObj.WriteMem32(0x00324bc4,0x400002ff)
-- skip videos
--eeObj.WriteMem32(0x0010ae80,0x24020001)

emuObj.ThrottleMax()
end

emuObj.AddVsyncHook(WS2)

-- Fix vertical lines
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1  } )

Powerpuff Girls - Relish Rampage


All versions
CLI

#Fixes hangs in certain locations like building under construction.
--fpu-no-clamping=1

Psi-Ops: The Mindgate Conspiracy

CLI

--ee-cycle-scalar=1.6
--vu1-mpg-cycles=1000
# Fixed low framerate. Jakv2

Ratchet And Clank Size Matters

CLI
All versions

#Fix for audio looping at first level
--iop-cycle-scalar=0.1
--cdvd-sector-read-cycles=14000

Rayman 3: Hoodlum havoc

CLI
SLUS_206.01
Note: Use Kof2000 to prevent missing 3d models

#Gamefix, change 1000 into 500 if you encounter gfx bugs
--ee-hook=0x0028A578,AdvanceClock,,1000
#Necessary Clamping
--vu1-no-clamping=0
--vu0-no-clamping=0
#Optional Clamping
--fpu-no-clamping=0
#Speedup
--vu1-di-bits=0
#underclocking the animation offsets
--ee-hook=0x0028A808,AdvanceClock,,500
--ee-hook=0x0028A574,AdvanceClock,,500
--ee-hook=0x0028A4F4,AdvanceClock,,500
--ee-hook=0x0028A4E4,AdvanceClock,,500
--ee-hook=0x0028A6EC,AdvanceClock,,500
--ee-hook=0x0028A460,AdvanceClock,,500
--ee-hook=0x0028A278,AdvanceClock,,500
--ee-hook=0x0028A410,AdvanceClock,,500
--ee-hook=0x0028A288,AdvanceClock,,500
--ee-hook=0x0028A294,AdvanceClock,,500
--ee-hook=0x0028A4A0,AdvanceClock,,500
--ee-hook=0x0028A36C,AdvanceClock,,500
--ee-hook=0x0028A6BC,AdvanceClock,,500
--ee-hook=0x0028A488,AdvanceClock,,500
--ee-hook=0x0028A65C,AdvanceClock,,500
--ee-hook=0x0028A68C,AdvanceClock,,500
--ee-hook=0x0028A6D4,AdvanceClock,,500
--ee-hook=0x0028A6A4,AdvanceClock,,500
--ee-hook=0x0028A5D4,AdvanceClock,,500


LUA

-- Rayman 3 Hoodlum Havoc (NTSC)
-- emu used=KOF 2000

apiRequest(1.0)   

local gpr = require("ee-gpr-alias")

local eeObj = getEEObject()
local emuObj = getEmuObject()

-- Fix for thin vertical lines that separate screen picture, misallignment/tearing of screen during upscaling
-- psm= SCE_GS_PSMCT32 (0)
emuObj.SetGsTitleFix( "forceSimpleFetch",  "reserved", {psm=0} )
emuObj.SetGsTitleFix( "fetchFromCurrBuff", "reserved", {psm=0} )

local patcher = function()

--Max Score/Unlock Bonuses
eeObj.WriteMem32(0x211E7744,0x000F423F)

end

emuObj.AddVsyncHook(patcher)


SLES-51222
CLI

--gs-kernel-cl-up="up2x2skipinterp"

--vu0-no-clamping=0
--vu1-no-clamping=0

--ee-hook=0x0028A408,AdvanceClock,,500

--ee-hook=0x0028A588,AdvanceClock,,500
--ee-hook=0x0028A584,AdvanceClock,,500
--ee-hook=0x0028A57C,AdvanceClock,,500
--ee-hook=0x0028A558,AdvanceClock,,500
--ee-hook=0x0028A554,AdvanceClock,,500
--ee-hook=0x0028A54C,AdvanceClock,,500
--ee-hook=0x0028A528,AdvanceClock,,500
--ee-hook=0x0028A524,AdvanceClock,,500
--ee-hook=0x0028A51C,AdvanceClock,,500
--ee-hook=0x0028A4F8,AdvanceClock,,500
--ee-hook=0x0028A4F4,AdvanceClock,,500
--ee-hook=0x0028A4EC,AdvanceClock,,500
--ee-hook=0x0028A4A8,AdvanceClock,,500
--ee-hook=0x0028A49C,AdvanceClock,,500
--ee-hook=0x0028A494,AdvanceClock,,500
--ee-hook=0x0028A48C,AdvanceClock,,500
--ee-hook=0x0028A47C,AdvanceClock,,500
--ee-hook=0x0028A478,AdvanceClock,,500
--ee-hook=0x0028A474,AdvanceClock,,500
--ee-hook=0x0028A230,AdvanceClock,,500
--ee-hook=0x0028A228,AdvanceClock,,500
--ee-hook=0x0028A220,AdvanceClock,,500
--ee-hook=0x0028A218,AdvanceClock,,500
--ee-hook=0x0028A210,AdvanceClock,,500
--ee-hook=0x0028A20C,AdvanceClock,,500
--ee-hook=0x0028A208,AdvanceClock,,500
--ee-hook=0x0028A1FC,AdvanceClock,,500
--ee-hook=0x0028A194,AdvanceClock,,500
--ee-hook=0x0028A160,AdvanceClock,,500
--ee-hook=0x0028A130,AdvanceClock,,500
--ee-hook=0x0028A124,AdvanceClock,,500
--ee-hook=0x0028A120,AdvanceClock,,500
--ee-hook=0x0028A118,AdvanceClock,,500
--ee-hook=0x0028A108,AdvanceClock,,500
--ee-hook=0x0028A0AC,AdvanceClock,,500
--ee-hook=0x0028A098,AdvanceClock,,500
--ee-hook=0x0028A084,AdvanceClock,,500
--ee-hook=0x0028A080,AdvanceClock,,500
--ee-hook=0x0028A078,AdvanceClock,,500
--ee-hook=0x00289F6C,AdvanceClock,,500
--ee-hook=0x00289F68,AdvanceClock,,500
--ee-hook=0x00289F64,AdvanceClock,,500
--ee-hook=0x00289F54,AdvanceClock,,500
--ee-hook=0x00289F4C,AdvanceClock,,500
--ee-hook=0x00289F30,AdvanceClock,,500

Rayman M (Arena)


SLES-50457
CLI

--vu1-no-clamping=0
--vu0-no-clamping=0
--vif1-instant-xfer=0
--mtap1=always


LUA
Pal

-- Rayman M (SLES-50457)
-- Fix by Kozarovv
-- ported to PS4 lua by Stayhye
-- emu used=rotk v1

--[[ useful information

This fix should work for other games using this engine.  Like Largo Winch, and Disney's PK - Out of the Shadows.
....and what's more important that patch is by kozarovv

--]]

local gpr = require("ee-gpr-alias")

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local Fix = function()
--Start microprograms manually instead of rely on timings.
eeObj.WriteMem32(0x001c997c,0x4a0000b8)
eeObj.WriteMem32(0x001c9b64,0x4a0000b8)
eeObj.WriteMem32(0x001c9bd4,0x4a0000b8)
eeObj.WriteMem32(0x001c9c24,0x4a000938)
eeObj.WriteMem32(0x001c9e7c,0x4a000938)
eeObj.WriteMem32(0x001c9ec4,0x4a000938)
eeObj.WriteMem32(0x001ca044,0x4a000938)
eeObj.WriteMem32(0x001ca08c,0x4a000938)
-- No need to loop here, just e-bit and wait for vcallms from EE.
eeObj.WriteMem32(0x002fc910,0x8000033c)
eeObj.WriteMem32(0x002fc914,0x400002ff)
eeObj.WriteMem32(0x002fca40,0x8000033c)
eeObj.WriteMem32(0x002fca44,0x400002ff)
end

emuObj.AddVsyncHook(Fix)

NTSC (Arena)

-- Rayman Arena
-- fix method for game engine by kozarovv
-- ported to PS4
-- emu used=jakx v2

local gpr = require("ee-gpr-alias")

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()
--Start microprograms manually instead of rely on timings.
--0x48c83000 >> ctc2 t0, $vi6
--eeObj.WriteMem32(0x001de8e4,0x4a0000b8)
eeObj.WriteMem32(0x001de9b0,0x4a0000b8)
eeObj.WriteMem32(0x001deb94,0x4a0000b8)
eeObj.WriteMem32(0x001dec00,0x4a000938)
eeObj.WriteMem32(0x001dec54,0x4a000938)
eeObj.WriteMem32(0x001deea0,0x4a000938)
eeObj.WriteMem32(0x001deedc,0x4a000938)
eeObj.WriteMem32(0x001df078,0x4a000938)
eeObj.WriteMem32(0x001df0b4,0x4a000938)
eeObj.WriteMem32(0x001df154,0x4a000938)
-- No need to loop here, just e-bit and wait for vcallms from EE.
eeObj.WriteMem32(0x0031ba90,0x8000033c) -- 500607ff
eeObj.WriteMem32(0x0031ba94,0x400002ff)
eeObj.WriteMem32(0x0031bbc0,0x8000033c)
eeObj.WriteMem32(0x0031bbc4,0x400002ff)


emuObj.ThrottleMax()
end

emuObj.AddVsyncHook(patcher)

R-Racing Revolution

LUA


SLUS_207.21

apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.

-- Divide $v0 value by 8 before copying it to CMSAR0
-- sra $v0, 3, this time we are losing one nop on cop2. Can be important.

eeInsnReplace(0x2DDB4C, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x2DDB50, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x2DDBC4, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x2DDBC8, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x313C30, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x313C34, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x3144FC, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x314500, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x314E04, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x314E08, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x31570C, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x315710, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x315FFC, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x316000, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x3168EC, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x3168F0, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x31724C, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x317250, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x317B74, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x317B78, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x318430, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x318434, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x318D54, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x318D58, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x319AA0, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x319AA4, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x31A8D4, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x31A8D8, 0x4A0002FF, 0x48C2D801)
eeInsnReplace(0x31B7A4, 0x48C2D801, 0x000210C3)
eeInsnReplace(0x31B7A8, 0x4A0002FF, 0x48C2D801)

-- fix graphical issues

Radiata Stories

CLI


All versions

--vu-hack-triace=1
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"

#Mandatory triace fix for boot crash and fix for uncommon glitches like outlines in Jack's face during specific cutscenes.

Raw Danger! / Zettai Zetsumei Toshi 2 - Itetsuita Kiokutachi

SLUS_215.01
LUA

apiRequest(0.1)

-- SLUS-21501 speedhack

eeInsnReplace(0x11e104, 0x0c066a5c, 0x00000000)
eeInsnReplace(0x11e10c, 0x0c08a8ec, 0x00000000)

SLES_545.87
LUA

apiRequest(0.1)

-- SLES-54587 speedhack

eeInsnReplace(0x11e0f4, 0x0c066a40, 0x00000000)
eeInsnReplace(0x11e0fc, 0x0c08a8d0, 0x00000000)

SLPS_256.06
LUA

apiRequest(0.1)

-- SLPS-25606 speedhack

eeInsnReplace(0x11e094, 0x0c066804, 0x00000000)
eeInsnReplace(0x11e09c, 0x0c08a654, 0x00000000)

Rygar: The Legendary Adventure

CLI


SLUS_204.71

--fpu-accurate-range=0x147CC0,0x147EA0

#Fix for freeze after leaving the first area.


SCAJ_200.16

--fpu-accurate-range=0x1485C4,0x148724

#Fix 

Samurai Shodown VI

CLI


All versions

--gs-upscale=point
--gs-uprender=2x2
--gs-motion-factor=25
--host-audio-latency=0.01
--gs-ignore-dirty-page-border=1
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
--gs-h2l-list-opt=1
--gs-h2l-accurate-hash=1

#same as Anthology, which VI is a patched-out section of; substantial slowdown during combat has been mitigated.

Samurai Warriors 2 Xtreme Legends

LUA
Jakv2
NTSC

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()
--Load merge menus
eeObj.WriteMem32(0x00397E80, 0x00000001)
--Merge's Data
eeObj.WriteMem32(0x005C1E28, 0x65300000)
eeObj.WriteMem32(0x005C1E58, 0x65300000)
eeObj.WriteMem32(0x005EC270, 0x05030100)
eeObj.WriteMem32(0x005EC2A0, 0x04030100)
eeObj.WriteMem32(0x005EC2D0, 0x04030100)
eeObj.WriteMem32(0x005EC300, 0x05030100)
eeObj.WriteMem32(0x00614320, 0x05030100)
eeObj.WriteMem32(0x00614350, 0x05030100)
eeObj.WriteMem32(0x00614380, 0x05030100)
eeObj.WriteMem32(0x006143B0, 0x04030100)
eeObj.WriteMem32(0x00584DB0, 0x00000010)
eeObj.WriteMem32(0x00584DB4, 0x06010000)
eeObj.WriteMem32(0x00584DC0, 0x00000010)
eeObj.WriteMem32(0x00584DC4, 0x06010000)
eeObj.WriteMem32(0x00584DD0, 0x00000010)
eeObj.WriteMem32(0x00584DD4, 0x06010000)
eeObj.WriteMem32(0x00584DD8, 0x00000010)
eeObj.WriteMem32(0x00584DDC, 0x06010000)
eeObj.WriteMem32(0x00584DE0, 0x00000010)
eeObj.WriteMem32(0x00584DE4, 0x06010000)
eeObj.WriteMem32(0x00584DE8, 0x00000010)
eeObj.WriteMem32(0x00584DEC, 0x06010000)
eeObj.WriteMem32(0x00584DF0, 0x00000010)
eeObj.WriteMem32(0x00584DF4, 0x06010000)
eeObj.WriteMem32(0x00584E00, 0x00000010)
eeObj.WriteMem32(0x00584E04, 0x06010000)
eeObj.WriteMem32(0x00584E10, 0x00000010)
eeObj.WriteMem32(0x00584E14, 0x06010000)
eeObj.WriteMem32(0x00584E20, 0x00000010)
eeObj.WriteMem32(0x00584E24, 0x06010000)
eeObj.WriteMem32(0x00584E28, 0x00000010)
eeObj.WriteMem32(0x00584E2C, 0x06010000)
eeObj.WriteMem32(0x00584E30, 0x00000010)
eeObj.WriteMem32(0x00584E34, 0x06010000)
eeObj.WriteMem32(0x00584E38, 0x00000010)
eeObj.WriteMem32(0x00584E3C, 0x06010000)
eeObj.WriteMem32(0x00584E40, 0x00000010)
eeObj.WriteMem32(0x00584E44, 0x06010000)
eeObj.WriteMem32(0x00584E50, 0x00000010)
eeObj.WriteMem32(0x00584E54, 0x06010000)
eeObj.WriteMem32(0x00584E60, 0x00000010)
eeObj.WriteMem32(0x00584E64, 0x06010000)
eeObj.WriteMem32(0x00584E70, 0x00000010)
eeObj.WriteMem32(0x00584E74, 0x06010000)
eeObj.WriteMem32(0x00584E80, 0x00000010)
eeObj.WriteMem32(0x00584E84, 0x06010000)
eeObj.WriteMem32(0x00584E90, 0x00000010)
eeObj.WriteMem32(0x00584E94, 0x06010000)
eeObj.WriteMem32(0x00584Ea0, 0x00000010)
eeObj.WriteMem32(0x00584Ea4, 0x06010000)
eeObj.WriteMem32(0x00584Ea8, 0x00000010)
eeObj.WriteMem32(0x00584Eac, 0x06010000)
eeObj.WriteMem32(0x00584Eb0, 0x00000010)
eeObj.WriteMem32(0x00584Eb4, 0x06010000)
eeObj.WriteMem32(0x00584Eb8, 0x00000010)
eeObj.WriteMem32(0x00584Ebc, 0x06010000)
eeObj.WriteMem32(0x00584EC0, 0x00000010)
eeObj.WriteMem32(0x00584EC4, 0x06010000)
eeObj.WriteMem32(0x00584EC8, 0x00000010)
eeObj.WriteMem32(0x00584ECC, 0x06010000)
eeObj.WriteMem32(0x00584ED0, 0x00000010)
eeObj.WriteMem32(0x00584ED4, 0x06010000)
eeObj.WriteMem32(0x00584EE0, 0x00000010)
eeObj.WriteMem32(0x00584EE4, 0x06010000)
eeObj.WriteMem32(0x00584EF0, 0x00000010)
eeObj.WriteMem32(0x00584EF4, 0x06010000)
eeObj.WriteMem32(0x00584EF8, 0x00000010)
eeObj.WriteMem32(0x00584EFC, 0x06010000)
--Sugoroku glitch patch
eeObj.WriteMem32(0x00102230,0x00000000)
--No interlacing
eeObj.WriteMem32(0x00102298,0x30420000)

end
--Fix for upscaling glitches
emuObj.SetGsTitleFix( "forceSimpleFetch",  "reserved", {psm=0} )
emuObj.SetGsTitleFix( "fetchFromCurrBuff", "reserved", {psm=0} )

emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1  } )

emuObj.AddVsyncHook(patcher)

Scaler


CLI
JAKv2
All Versions

#Upscaling fix
--gs-kernel-cl-up="up2x2simple"
#Speedhacks
--vu1-jr-cache-policy=sameprog
--vu1-jalr-cache-policy=sameprog
--vu1-mpg-cycles=600
--vu1-di-bits=0
--ee-cycle-scalar=1.1


LUA
JAKv2
PAL


apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

eeObj.WriteMem32(0x0021E5AC, 0x8F8288C0)
eeObj.WriteMem32(0x0021E218, 0x8F8288C0)
eeObj.WriteMem32(0x0021E598, 0x8F8288C0)
eeObj.WriteMem32(0x0021DDA4, 0x8F8288C0)
eeObj.WriteMem32(0x0021DDC8, 0x0)
eeObj.WriteMem32(0x001DDC3C, 0x0)
end
emuObj.AddVsyncHook(patcher)

Scooby-Doo! First Frights™

SLES_554.76 Only!
CLI

--ee-hook=0x00163984,FastForwardClock
--ee-hook=0x00163998,FastForwardClock
#Fix for distorted audio

Scooby-Doo! and the Spooky Swamp™

SLES_556.09 Only!
CLI

--ee-hook=0x001480F4,FastForwardClock
--ee-hook=0x00148108,FastForwardClock
#Fix for distorted audio

SEGA Sports Tennis/ Virtua Tennis 2


SLUS-20480

-- fix by kozarovv
-- emu used=psychonauts v2

local gpr = require("ee-gpr-alias")

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()
-- First unpack, then run program you silly.
eeObj.WriteMem8(0x283774, 0x30)
eeObj.WriteMem8(0x283780, 0x20)
end

emuObj.AddVsyncHook(patcher)


SLES-51232

local gpr = require("ee-gpr-alias")

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()
-- First unpack, then run program you silly.
eeObj.WriteMem8(0x289914, 0x30)
eeObj.WriteMem8(0x289920, 0x20)
end

emuObj.AddVsyncHook(patcher)

Shadow of the Colossus

CLI
All versions

#Speedhacks for performance
--ee-cycle-scalar=1.2
--vu1-di-bits=0
--vu1-mpg-cycles=600

LUA

-- Shadow of the Colossus
-- ported to PS4 by Stayhye
-- emu used=kof98um

apiRequest(0.1)

local gpr       = require("ee-gpr-alias")

local emuObj      = getEmuObject()
local eeObj       = getEEObject()
local gsObj       = getGsObject()


emuObj.PadSetLightBar(0, 45,65,55)
emuObj.SetDeinterlace(true)
emuObj.SetDisplayAspectWide()

--stutter fix
eeObj.AddHook(0x00125838,0x00041878,function() -- dsll v1, a0, 1
         eeObj.AdvanceClock(8000)
         eeObj.Vu1MpgCycles(450)
end)        


local WS = function()
--
--eeObj.WriteMem32(0x0012584c,0x1000fffa)

emuObj.ThrottleMax()
end

emuObj.AddVsyncHook(WS)

emuObj.SetGsTitleFix( "globalSet",  "reserved", { workLoadThreshold = 100000} )
emuObj.SetGsTitleFix( "globalSet",  "reserved", { waveThreshold = 90000} )
emuObj.SetGsTitleFix( "ignoreAreaUpdate", 0, { } )

Shin Megami Tensei: Persona 3 FES


NTSC
CLI

# Misc
--host-display-mode=full
--force-frame-blend=0
--gs-progressive=1
--ee-cycle-scalar=0.62
--host-audio-latency=0.05
# Mipmapping
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
# VU Speedhacks
--vu0-const-prop=1
--vu1-const-prop=1
--vu1-di-bits=0
--vu0-di-bits=0
--vu1-opt-vf00=2
--vu0-opt-vf00=2
--vu1-mpg-cycles=1400
--vu-custom-min-max=0
# IOP Speedhacks
--iop-const-folding=All
--iop-cycle-scalar=0.1
--cdvd-sector-seek-cycles=0.1
--cdvd-sector-read-cycles=0.1
# Default Optimizations
--fpu-no-clamping=0
--fpu-clamp-operands=1
--fpu-clamp-results=1
--vu0-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1
--vu0-opt-flags=1
--vu1-opt-flags=1
--cop2-opt-flags=1
--vu1-jr-cache-policy=newprog
--vu1-jalr-cache-policy=newprog
--vu0-jr-cache-policy=newprog
--vu0-jalr-cache-policy=newprog

#User Emu = kof98um

Shin Megami Tensei: Persona 4

CLI

All Versions

#Graphical glitches fixes, Vu Clamp mode 2
--vu1-no-clamping=0
#Performance fixes
--vu1-const-prop=1
--vu1-di-bits=0
--ee-cycle-scalar=1.3

#Jakv2 Emu Used

#Fix for Slowdowns in Battles And flickering textures When fusing Personas


LUA
NTSC

-- Persona 4 NTSC Fix for bottom left text not appearing

local gpr = require("ee-gpr-alias")

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

eeObj.WriteMem32(0x00189c60,0x3c023f7f)

end

emuObj.AddVsyncHook(patcher)

Shinobido: Way of the Ninja


All versions

# Fixes hang going in to the gardens.
--fpu-no-clamping=1

Simpsons Hit and Run


NTSC
CLI

--Fixes the slowdowns
--ee-cycle-scalar=3.5

LUA

#Fixes the freeze on Jakv2
apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()
eeObj.WriteMem32(0x0036CA5C,0x0)
end
emuObj.AddVsyncHook(patcher)

Sly Cooper 1

CLI
All versions

#Fix for upscaling corruptions
--gs-kernel-cl-up="up2x2simple"
#Speedhacks
--ee-cycle-scalar=1.2
--vu1-di-bits=0

Second Sight

CLI


All Versions

--vu1=jit-sync
--vif1-instant-xfer=0

#Fix for black screen after ps2 logo and graphical glitches.

Silent Hill 2

CLI
(SLUS-20228)

#Fix For Slowdowns
--vu1-mpg-cycles=1000
--vu1-di-bits=0
--vu1-const-prop=1

LUA
(SLUS-20228)

apiRequest(1.0)

local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()

--Enable custom progressive scan mode and enhanced mode to fix double-layer screen display errors
eeObj.WriteMem32(0x1A68e4,0x24050000)
eeObj.WriteMem32(0x1A68e8,0x24060050)
eeObj.WriteMem32(0x1A68ec,0x24070001)
eeObj.WriteMem32(0x2a7968,0x34030002)
eeObj.WriteMem32(0x1961f8,0x28670000)
eeObj.WriteMem32(0x27fe74,0x00000000)
eeObj.WriteMem32(0x27fac4,0x00000000)

local code_check1 = eeObj.ReadMem16(0x1221C4E)
if code_check1 == 0x001F then
eeObj.WriteMem8(0x1221c4e,0x1b)
eeObj.WriteMem8(0x1221c76,0x1b)
end
end

emuObj.AddVsyncHook(patcher)

Silent Hill 2: Director's Cut


CLI
SLES_511.56

#Performance boost.
--ee-cycle-scalar=1.8
## Force PAL game to 30 fps with Progressive scan (but '--force-pal-60hz=1' does the audio and video unsync )
#--force-pal-60hz=1
--gs-progressive=1

## I need to test more, but it looks good.

SNK vs Capcom: SVC Chaos

CLI


All Versions

--gs-use-clut-merge=1
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"

#Fixes missing hud/UI elements.

Soul Calibur 3

ALL
CLI

--gs-uprender=2x2
--gs-upscale=edgesmooth
--gs-kernel-cl-up="up2x2skipinterp"

--vif1-instant-xfer=0

--ee-cycle-scalar=1.82
--ee-regalloc-preserve-scalar=LoadStore
--iop-cycle-scalar=2.10

--vu0-mpg-cycles=1
--vu1-mpg-cycles=1

#emu used=jakx v2


LUA

-- Soul Calibur III (SLUS-21216)
-- ported to PS4 lua
-- emu used=jakx v2

apiRequest(2.3)

local gpr    		= require("ee-gpr-alias")
local emuObj 		= getEmuObject()
local eeObj			= getEEObject()
local gsObj			= getGsObject()
   
emuObj.PadSetLightBar(0, 10,176,4)
emuObj.SetDisplayAspectWide() 

local WS = function()
-- 16:9
eeObj.WriteMem32(0x0012a118,0x3c013f40)
eeObj.WriteMem32(0x0012a11c,0x34210000)

eeObj.Vu1MpgCycles(1)
eeObj.SetVifDataCycleScalar(1, 0.80)

emuObj.ThrottleMax()
end

emuObj.AddVsyncHook(WS)

Spider-Man 3

ALL
CLI

--vu0-di-bits=0
--vu1-di-bits=0

--ee-cycle-scalar=1.7 
--iop-cycle-scalar=0.8

--vu1-mpg-cycles=600

--host-audio-latency=2.21

#Fix for slowdown and micro-freezes

SpongeBob SquarePants: Battle for Bikini Bottom

CLI
All versions

#Fix for Graphical issues
--vu1-no-clamping=0
#Rest might be unnecessary
--vu0-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1

Spyro: Enter The Dragonfly


All versions
CLI

#Speedhacks + Clamping
--vu1-di-bits=0
--vu1-const-prop=1
--vu1-mpg-cycles=800
--ee-cycle-scalar=1.2
#Jakv2 Emu Used

Spy hunter

CLI
All versions

#Fixes loading hang.
--vif1-instant-xfer=0

SSX


CLI
All versions

--iop-cycle-scalar=1.8
--host-audio-latency=1.1

#Use JakX v2 emu

Star Wars - Episode 3 - Die Rache der Sith

CLI file

#for none PS4 Pro users
--ee-cycle-scalar=1.75
--iop-cycle-scalar=1.75
--vu1-mpg-cycles=1480
--vu0-mpg-cycles=1480
--vu0-di-bits=0
--vu1-di-bits=0

#emu used=Star Wars Racer's Revenge v1

LUA file

-- Star Wars - Episode III - Die Rache der Sith (PAL) SLES-53157
-- Widescreen Hack by ElHecht
-- ported to PS4
-- emu used=Star Wars Racer's Revenge v1

apiRequest(0.4)

local gpr       = require("ee-gpr-alias")
local emuObj      = getEmuObject()
local eeObj       = getEEObject()
local widescreen = function()

-- 16:9
eeObj.WriteMem32(0x004dbd44,0x3c023f40)
eeObj.WriteMem32(0x0051bca0,0x3c013f40)
eeObj.WriteMem32(0x0051bcac,0x4481f000)
eeObj.WriteMem32(0x0051bcf0,0x461e4a42)

emuObj.ThrottleMax()
end

emuObj.AddVsyncHook(widescreen)

Street Fighter Alpha Anthology

ALL
CLI

#Graphical glitches fix
--gs-motion-factor=50
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
--gs-h2l-list-opt=1
--gs-h2l-accurate-hash=1
#Speehacks
--vu0-di-bits=0
--vu1-di-bits=0
--vu0-const-prop=1
--vu1-const-prop=1
--ee-cycle-scalar=1.5
--gs-adaptive-frameskip=1
--vu1-injection=1
#Misc
--host-audio-latency=0.01

#PS4 Pro required for full speed

Steambot Chronicles

CLI


All Versions

--vu1-no-clamping=0
--gs-kernel-cl-up="up2x2skipinterp"
#Fix for graphical glitches.

Sword of etheria

CLI
All versions

#Fix for game's graphics being missing And game crashing
--vu-custom-min-max=0
#Jakv2 emu used

Syberia

CLI
All versions

#Fix for graphical glitches
--vu1=jit-sync
#Speedhacks
--vu1-di-bits=0
--vu1-mpg-cycles=400
--ee-cycle-scalar=1.2

Tales of Destiny: Directors Cut


SLPS-25842

CLI

#Glitch Fix
--fpu-accurate-range=0x1C7B50,0x1C7C00
#unnecessary command
--fpu-accurate-mul-fast=1
#Performance Fix
--ee-cycle-scalar=1.74
#Graphical Glitches fixes
--gs-use-clut-merge=1 
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"
#Fix for menu UI interlacing shake
--force-frame-blend=1

LUA file

-- Emu used=Jak v2
-- SLPS-25842 FPUMULHACK (fix for getting stuck in the room before Irene in Helraios)
local gpr = require("ee-gpr-alias")

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local goathack = function()
local db_check = eeObj.ReadMem8(0x3EECC4)
if db_check == 0xDB then
eeObj.WriteMem8(0x3EECC4,0xDA)
end
end

emuObj.AddVsyncHook(goathack)

Tales of The Abyss

CLI

--gs-uprender=2x2
--gs-upscale=EdgeSmooth

--fpu-accurate-range=0x27FFFC,0x27FFFF
--fpu-accurate-range=0x2921F4,0x2921F8

--vu0-no-clamping=0
--vu1-no-clamping=0
--cop2-no-clamping=0

--host-display-mode=16:9

LUA file

-- Tales Of The Abyss (NTSC-U) (SLUS-21386)
-- emu used=psychonauts v2

local gpr = require("ee-gpr-alias")

apiRequest(0.1)
local emuObj = getEmuObject()
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )

Tekken 5

CLI
All versions

#Upscaling glitches fix
--gs-kernel-cl-up="up2x2simple"
#Game needs progressive scan
--gs-progressive=1
#Speedhacks
--vu1-di-bits=0

#Side note: game is best played using War of the monsters v1 emu as it removes a graphical glitch from some levels.
#side note2: "--gs-kernel-cl-up="up2x2simple" doing this will make graphics look worse than actual ps2


LUA
NTSC only

-- Tekken 5 NTSC
-- Widescreen and No interlace
-- emu used=rogue v1 or wotm v1 or 2

apiRequest(0.1)

local gpr    		= require("ee-gpr-alias")

local emuObj 		= getEmuObject()
local eeObj			= getEEObject()

local patcher = function()

eeObj.WriteMem32(0x0032b448,0x3c013f40) -- both fov+
--applies both fov+ only for widescreen mode
eeObj.WriteMem32(0x0032b478,0x3c010015)
eeObj.WriteMem32(0x0032b47c,0xc62dd11c)
eeObj.WriteMem32(0x0032b49c,0x46016b42)
eeObj.WriteMem32(0x0032b4a0,0x46010843)
eeObj.WriteMem32(0x0032b4b8,0x460d1083)
eeObj.WriteMem32(0x0032b4bC,0x460d0843)
--effects fix
eeObj.WriteMem32(0x00257434,0x46161083)
eeObj.WriteMem32(0x00257488,0x46160843)
eeObj.WriteMem32(0x002574e0,0x46160843)
eeObj.WriteMem32(0x00257538,0x46160843)

local code_check1 = eeObj.ReadMem16(0x15D11C)
if code_check1 == 0x8e38 then
eeObj.WriteMem32(0x20257764,0x10000008)
end
local code_check2 = eeObj.ReadMem16(0x15D11C)
if code_check2 == 0xaaaa then
eeObj.WriteMem32(0x20257764,0x45020008)
end
--render fix
eeObj.WriteMem32(0x00222484,0x3c013f2b)
eeObj.WriteMem32(0x00222494,0x44810000)
eeObj.WriteMem32(0x00222498,0x46006302)
--Devil Within Mode by Arapapa
local code_check3 = eeObj.ReadMem16(0x100000)
if code_check3 == 0xfff0 then
eeObj.WriteMem32(0x2041E82C,0x3f400000) --Zoom
eeObj.WriteMem32(0x202ACED8,0x3FDDA51A) --Y-Fov
end
--no interlace for starblade
local code_check4 = eeObj.ReadMem16(0x2F5BD0)
if code_check4 == 0x0104 then
eeObj.WriteMem32(0x202F5BD0,0x34070003)
local code_check5 = eeObj.ReadMem16(0x187FB0)
if code_check5 == 0x0008 then
eeObj.WriteMem32(0x20187FB0,0x34030001)
eeObj.WriteMem32(0x20187FC4,0x34021078)
end
end
--[[
--Workaround
eeObj.WriteMem32(0x2010207C,0x3c050000)
eeObj.WriteMem32(0x20102084,0x3c060050)
eeObj.WriteMem32(0x2010208C,0x3c070001)
eeObj.WriteMem32(0x20102EAC,0x3C0701E0)
--]]
--Intro Mini Game
local code_check6 = eeObj.ReadMem16(0xFFECF4)
if code_check6 == 0x0001 then
eeObj.WriteMem32(0x2010230C,0x34029078)
end
--Framebuffer - Progressive - No interleacing - No black lines HW mode
local code_check7 = eeObj.ReadMem16(0xFFEF20)
if code_check7 == 0x8870 then
eeObj.WriteMem32(0x2010230C,0x34029400)
eeObj.WriteMem32(0x203EF450,0x00000001) -- Official Progressive mode
end
-- Devil W. Game
local code_check8 = eeObj.ReadMem16(0xFFEF20)
if code_check8 == 0x2c70 then
eeObj.WriteMem32(0x2026033C,0x34029400)
end
-- Tek 1 sdtv mode 240p
local code_check9 = eeObj.ReadMem16(0xFFEF20)
if code_check9 == 0x3df0 then
eeObj.WriteMem32(0x2014F454,0x3c050000)
eeObj.WriteMem32(0x2014F45C,0x3C060050)
eeObj.WriteMem32(0x2014F464,0x3c070001)
end
-- Tek 2 sdtv mode 240p
local code_check10 = eeObj.ReadMem16(0xFFEF20)
if code_check10 == 0x6570 then
eeObj.WriteMem32(0x2015E494,0x3c050000)
eeObj.WriteMem32(0x2015E49C,0x3C060050)
eeObj.WriteMem32(0x2015E4A4,0x3c070001)
end
-- Tek 3 sdtv mode 480p extended
local code_check11 = eeObj.ReadMem16(0xFFEF20)
if code_check11 == 0xF370 then
eeObj.WriteMem32(0x201E4F54,0x3c050000)
eeObj.WriteMem32(0x201E4F5C,0x3C060050)
eeObj.WriteMem32(0x201E4F64,0x3c070001)
end

end

emuObj.AddVsyncHook(patcher)
--Fix lines appearing in some areas
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=2  } ) -- also makes graphics look like crap

The Godfather

CLI
All versions
SW racer revenge v1 emu used

#Fix for upscaling graphical glitches
--gs-kernel-cl-up="up2x2simple"
#Fix for intro stutter
--iop-cycle-scalar=0.80
--cdvd-sector-read-cycles=5000

The Legend of Spyro A New Beginning

PAL only!
LUA

apiRequest(0.4)

-- The Legend of Spyro: A New Beginning

local eeObj	= getEEObject()
local emuObj	= getEmuObject()

eeInsnReplace(0x1849b8, 0x44840800, 0x00000000)	-- Fixes HUD and menu display.

-- Graphic improvement: removes corrupted lines on screen with uprender enabled, for PAL version

emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } ) --texMode=1 ?
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=2 } ) --texMode=2 is BILINEAR

The Legend of Spyro: The Eternal Night

PAL only!
LUA

apiRequest(0.4)

-- The Legend of Spyro: The Eternal Night

local eeObj	= getEEObject()
local emuObj	= getEmuObject()

eeInsnReplace(0x173c38, 0x44840800, 0x00000000)	-- Fixes HUD and menu display.


-- Graphic improvement: removes corrupted lines on screen with uprender enabled, for PAL version

emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } ) --texMode=1 ?
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=2 } ) --texMode=2 is BILINEAR

The Operative: No One Lives Forever

CLI


#Fix for "The Operative - No One Lives Forever"

For US version

--fpu-accurate-addsub-range=0x104204,0x1042B8

For EU version:

--fpu-accurate-addsub-range=0x103F28,0x104074

Use Jak v2 emulator

The Shield

CLI

--fpu-accurate-addsub-range=0x100008,0x700000

#Fix for game over error on level '''2354 Casitas Dr'''.
#JAK V2 emulator used.

Timesplitters™

CLI


All Versions


—vu1=jit-sync 

Tomb Raider: Anniversary

LUA


SLUS_215.55

apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.

-- Texture Flickering fix

eeInsnReplace(0x1297C0, 0x10600022, 0x10000022)


SLES_539.08

apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.

-- Texture Flickering fix

eeInsnReplace(0x1273E8, 0x10600022, 0x10000022)

Tomb Raider - Legend

CLI
All Regions

--gs-progressive=1
--gs-kernel-cl-up="up2x2skipinterp"
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"

SLUS_212.03
LUA

apiRequest(0.1)    -- request version 0.1 API. Calling apiRequest() is mandatory.

-- Texture Flickering fix

eeInsnReplace(0x127390, 0x10600022, 0x10000022)

SLES_546.74
LUA

apiRequest(0.1)	-- request version 0.1 API. Calling apiRequest() is mandatory.

-- Texture Flickering fix
eeInsnReplace(0x129800, 0x10600022, 0x10000022)

Additional LUA fix
All Regions

-- Fix for thin vertical lines that separate screen picture, misallignment/tearing of screen during upscaling (was used in official PSN Red Dead Revolver)
apiRequest(1.0)
local emuObj = getEmuObject()
-- psm= SCE_GS_PSMCT32 (0)
emuObj.SetGsTitleFix( "forceSimpleFetch",  "reserved", {psm=0} )
emuObj.SetGsTitleFix( "fetchFromCurrBuff", "reserved", {psm=0} )

Tony Hawk Pro Skater 3

CLI


All Versions

--vu0-no-clamping=0
--vu1-no-clamping=0
--vu0-clamp-results=1
--vu1-clamp-results=1
--fpu-no-clamping=0
--cop2-no-clamping=0
--fpu-clamp-results=1
--cop2-clamp-results=1

#SPS Fix

Tony Hawk's Underground 2

CLI
SLUS20965
Redfaction emu used

#sps fix
--vu1-mpg-cycles=1

LUA
SLUS20965

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()
--loop skip to prevent freezing
eeObj.WriteMem32(0x001958A0, 0x10000086)
--rounding to remove sps
eeObj.WriteMem32(0x003F0FE8, 0xD3400000)
--Giving it the value it wants in order to branch
eeObj.WriteMem32(0x001AF5FC, 0x24060000)
end
emuObj.AddVsyncHook(patcher)
--mtvu patch
eeInsnReplace(0x00194918, 0x0, 0x0803fff0)
eeInsnReplace(0x000fffc4, 0x0, 0x24186000)
eeInsnReplace(0x000fffc8, 0x0, 0x3c191200)
eeInsnReplace(0x000fffcc, 0x0, 0x37391010)
eeInsnReplace(0x000fffd0, 0x0, 0x2718ffff)
eeInsnReplace(0x000fffd4, 0x0, 0x1418fffe)
eeInsnReplace(0x000fffdc, 0x0, 0x08065248)
eeInsnReplace(0x000fffe0, 0x0, 0xaf200000)

True Crime: Streets of LA


cli.conf
All Versions

--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
#Fix for missing enemies in the gyms


cli.conf
SLES_517.54 only!

--vu1-mpg-cycles=2350
--vu1-opt-flags=2
--vu1-opt-vf00=2
--gs-optimize-30fps=1
--ee-kernel-hle=1
--ee-block-validation=PageProt
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
#Performance fix and fix for missing enemies in the gyms


SLUS_205.50
SLES_517.53
LUA
They use the same offsets.

local gpr = require("ee-gpr-alias")

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()
eeObj.WriteMem32(0x480640, 0x10000000) --Fix for title screen freeze

end

emuObj.AddVsyncHook(patcher)


SLES_517.54 LUA

local gpr = require("ee-gpr-alias")

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()
eeObj.WriteMem32(0x480DB0, 0x10000000) --Fix for title screen freeze

end

emuObj.AddVsyncHook(patcher)

Twisted Metal: Head-On

CLI
All versions

#Speedhacks
--vu1-mpg-cycles=400
--ee-cycle-scalar=1.2
--vu1-di-bits=0

Urban Reign

CLI


All Versions

--gs-uprender=2x2
--gs-upscale=EdgeSmooth

--force-frame-blend=1
--vif-ignore-invalid-cmd=0
--vif1-ignore-cmd-ints=1
--vif1-instant-xfer=0
--vu1=jit-sync
--mtap1=Always

LUA
NTSC

-- Urban Reign NTSC (SLUS-21209) 
-- Multitap fix by Kozarovv
-- Cheats from GameHacking.org
-- ported to PS4 by Stayhye
-- emu used=kof98um

apiRequest(0.1)

local gpr    		= require("ee-gpr-alias")

local emuObj 		= getEmuObject()
local eeObj			= getEEObject()
local gsObj			= getGsObject()


emuObj.PadSetLightBar(0, 45,65,55)
emuObj.SetDeinterlace(true)
emuObj.SetDisplayAspectWide()


local WS = function()
--Unlock Free Mode by MadCatz
eeObj.WriteMem32(0x00946634,0x00010001)
-- Init first mtap
eeObj.WriteMem32(0x12BA88,0x24040000)
-- Read data from 1B port when 2A is requested
eeObj.WriteMem32(0x0ffc00,0x10040005)
eeObj.WriteMem32(0x0ffc04,0x00000000)
eeObj.WriteMem32(0x0ffc08,0x14050003)
eeObj.WriteMem32(0x0ffc10,0x24040000)
eeObj.WriteMem32(0x0ffc14,0x24050001)
eeObj.WriteMem32(0x0ffc18,0x080c5cbd)
eeObj.WriteMem32(0x0ffc1c,0x24030070)
eeObj.WriteMem32(0x3172ec,0x0803ff00)
--Unlock Challenge Mode by MadCatz
eeObj.WriteMem32(0x00946636,0x00010001)

--Unlock All Weapons by MadCatz
eeObj.WriteMem32(0x20274774,0x24030001)
eeObj.WriteMem32(0x2027477C,0xA443000E)
--Brad Hawk by Code Master
eeObj.WriteMem32(0x0094668E,0x00010001)

--Glen by Code Master
eeObj.WriteMem32(0x00946694,0x00010001)

--Torque by Code Master
eeObj.WriteMem32(0x00946696,0x00010001)

--Rod by Code Master
eeObj.WriteMem32(0x00946698,0x00010001)

--Seth by Code Master
eeObj.WriteMem32(0x0094669A,0x00010001)

--Nas-Tiii by Code Master
eeObj.WriteMem32(0x0094669C,0x00010001)

--Em Cee by Code Master
eeObj.WriteMem32(0x0094669E,0x00010001)

--Real Deal by Code Master
eeObj.WriteMem32(0x009466A0,0x00010001)

--Ty by Code Master
eeObj.WriteMem32(0x009466A2,0x00010001)

--Miguel by Code Master
eeObj.WriteMem32(0x009466A4,0x00010001)

--Ramon by Code Master
eeObj.WriteMem32(0x009466A6,0x00010001)

--Jose by Code Master
eeObj.WriteMem32(0x009466A8,0x00010001)

--Emilio by Code Master
eeObj.WriteMem32(0x009466AA,0x00010001)

--Kadonashi by Code Master
eeObj.WriteMem32(0x009466AC,0x00010001)

--Reggie by Code Master
eeObj.WriteMem32(0x009466AE,0x00010001)

--Zach by Code Master
eeObj.WriteMem32(0x009466B0,0x00010001)

--Colin by Code Master
eeObj.WriteMem32(0x009466B2,0x00010001)

--Jake by Code Master
eeObj.WriteMem32(0x009466B4,0x00010001)

--Tong Yoon by Code Master
eeObj.WriteMem32(0x009466B6,0x00010001)

--Grimm by Code Master
eeObj.WriteMem32(0x009466B8,0x00010001)

--BK by Code Master
eeObj.WriteMem32(0x009466BA,0x00010001)

--Grave Digga' by Code Master
eeObj.WriteMem32(0x009466BC,0x00010001)

--Bones by Code Master
eeObj.WriteMem32(0x009466BE,0x00010001)

--Booma by Code Master
eeObj.WriteMem32(0x009466C0,0x00010001)

--Busta by Code Master
eeObj.WriteMem32(0x009466C2,0x00010001)

--Spider by Code Master
eeObj.WriteMem32(0x009466C4,0x00010001)

--Pain Killah by Code Master
eeObj.WriteMem32(0x009466C6,0x00010001)

--Dwayne by Code Master
eeObj.WriteMem32(0x009466C8,0x00010001)

--Dwayne 2? by Code Master
eeObj.WriteMem32(0x009466CA,0x00010001)

--Shun Ying Lee by Code Master
eeObj.WriteMem32(0x009466CC,0x00010001)

--GD-05 by Code Master
eeObj.WriteMem32(0x009466CE,0x00010001)

--DR-88 by Code Master
eeObj.WriteMem32(0x009466D0,0x00010001)

--FK-71 by Code Master
eeObj.WriteMem32(0x009466D2,0x00010001)

--PT-22 by Code Master
eeObj.WriteMem32(0x009466D4,0x00010001)

--Bain by Code Master
eeObj.WriteMem32(0x009466D6,0x00010001)

--Cooper by Code Master
eeObj.WriteMem32(0x009466D8,0x00010001)

--Anderson by Code Master
eeObj.WriteMem32(0x009466DA,0x00010001)

--Taylor by Code Master
eeObj.WriteMem32(0x009466DC,0x00010001)

--Chris by Code Master
eeObj.WriteMem32(0x009466DE,0x00010001)

--Park by Code Master
eeObj.WriteMem32(0x009466E0,0x00010001)

--Alex by Code Master
eeObj.WriteMem32(0x009466E2,0x00010001)

--McKinzie by Code Master
eeObj.WriteMem32(0x009466E4,0x00010001)

--Napalm 99 by Code Master
eeObj.WriteMem32(0x009466E6,0x00010001)

--Golem by Code Master
eeObj.WriteMem32(0x009466E8,0x00010001)

--Riki by Code Master
eeObj.WriteMem32(0x009466EA,0x00010001)

--Masa by Code Master
eeObj.WriteMem32(0x009466EC,0x00010001)

--Hiro by Code Master
eeObj.WriteMem32(0x009466EE,0x00010001)

--Ryuji by Code Master
eeObj.WriteMem32(0x009466F0,0x00010001)

--Ye Wei by Code Master
eeObj.WriteMem32(0x009466F2,0x00010001)

--Sha Ying by Code Master
eeObj.WriteMem32(0x009466F4,0x00010001)

--Yan Jun by Code Master
eeObj.WriteMem32(0x009466F6,0x00010001)

--Shinkai by Code Master
eeObj.WriteMem32(0x009466F8,0x00010001)

--Lin Fong Lee by Code Master
eeObj.WriteMem32(0x009466FA,0x00010001)

--Bordin by Code Master
eeObj.WriteMem32(0x009466FC,0x00010001)

--Lilian by Code Master
eeObj.WriteMem32(0x009466FE,0x00010001)

--Kelly by Code Master
eeObj.WriteMem32(0x00946700,0x00010001)

--Vera Ross by Code Master
eeObj.WriteMem32(0x00946702,0x00010001)

--Paul Phoenix by Code Master
eeObj.WriteMem32(0x00946704,0x00010001)

--Marshall Law by Code Master
eeObj.WriteMem32(0x00946706,0x00010001)

--KG by Code Master
eeObj.WriteMem32(0x00946718,0x00010001)

emuObj.ThrottleMax()
end

emuObj.AddVsyncHook(WS)

emuObj.SetGsTitleFix( "globalSet",  "reserved", { workLoadThreshold = 100000} )
emuObj.SetGsTitleFix( "globalSet",  "reserved", { waveThreshold = 90000} )
emuObj.SetGsTitleFix( "ignoreAreaUpdate", 0, { } )

Valkyrie Profile 2: Silmeria

CLI


All versions

#emu used Star Ocean 3 for black screen upon leaving town and corrupted world map
--gs-progressive=1
--vu-hack-triace=1
--gs-use-mipmap=1
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"

LUA file
SLUS_21452

--Proper Widescreen and No ghosting
--Valkyrie Profile 2 - Silmeria (USA) SLUS_214.52
apiRequest(1.0)
local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()

local code_check = eeObj.ReadMem16(0x37984C)
if code_check == 0x0800 then
eeObj.WriteMem32(0x37984C,0x0803FC00)
end

eeObj.WriteMem32(0x000FF000, 0x3C043F40)
eeObj.WriteMem32(0x000FF004, 0x44840800)
eeObj.WriteMem32(0x000FF008, 0x46000802)
eeObj.WriteMem32(0x000FF00C, 0x080DE615)
eeObj.WriteMem32(0x000FF010, 0xC66100C8)
--No ghosting in battle
eeObj.WriteMem32(0x0035FA38, 0x46001030)
end
emuObj.AddVsyncHook(patcher)

Vampire: Darkstalkers Collection

ALL
CLI

--gs-motion-factor=50
--host-audio-latency=0.01
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
--gs-h2l-list-opt=1
--gs-h2l-accurate-hash=1
#Fix for performance issues. PS4 Pro required for full speed.

Van Helsing

ALL
CLI

--gs-uprender=2x2
--gs-upscale=edgesmooth
--gs-kernel-cl="h2lpool"
--gs-kernel-cl-up="h2lpool2x2"
--gs-adaptive-frameskip=1
--cdvd-sector-read-cycles=2000
--gs-progressive=1

#--vu0-di-bits=0
#--vu1-di-bits=0

--vu1-mpg-cycles=358

--ee-cycle-scalar=2.8 
--iop-cycle-scalar=0.9

--vif1-instant-xfer=0


LUA

-- Van Helsing (SLUS-20738)
-- Wide screen patch 16:9 by paul_met
-- ported to PS4 Lua by Stayhye
-- emu used=jakx v2

apiRequest(2.2)

local gpr    		= require("ee-gpr-alias")

local emuObj 		= getEmuObject()
local eeObj			= getEEObject()
local gsObj			= getGsObject()
local eeOverlay 	= eeObj.getOverlayObject()
local iopObj        = getIOPObject()
    

emuObj.SetDisplayAspectWide()
gsObj.SetDeinterlaceShift(1) 

local WS = function()
--16:9
eeObj.WriteMem32(0x002E7FA0,0x3FE38E38) 
--Access All Cheats by GameMasterZer0
eeObj.WriteMem32(0x2019FFB0,0x24100001)



emuObj.ThrottleMax()
end

emuObj.AddVsyncHook(WS)

Wallace & Gromit in Project Zoo

CLI
All Versions

--gs-uprender=2x2
--gs-upscale=EdgeSmooth
--gs-progressive=1
--gs-force-bilinear=1
--cdvd-sector-read-cycles=2000
--force-frame-blend=1
--vif1-instant-xfer=0
--vu0-di-bits=0
--vu1-di-bits=0
--vu1-mpg-cycles=800
--ee-cycle-scalar=1.5

Whiplash

All versions
CLI

--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--gs-use-mipmap=1
#Fix for texture glitches

WinBack: Covert Operations

All versions
CLI

--vu0-no-clamping=0
--vu0-clamp-operands=1
--vu0-clamp-results=1
--vu1-no-clamping=0
--vu1-clamp-operands=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-operands=1
--cop2-clamp-results=1

#Fix for texture glitches

X-Files - Resist or Serve


CLI

--gs-uprender=2x2
--gs-upscale=EdgeSmooth
--gs-adaptive-frameskip=1

--vu0-no-clamping=0
--vu1-no-clamping=0

--cdvd-sector-read-cycles=3000

#emu used=jak tpl v1

X-Men Legends

CLI
All versions

--gs-uprender=2x2
--gs-upscale=motionvector
--gs-optimize-30fps=1
--cdvd-sector-read-cycles=2000
--vu-custom-min-max=0
--vu1-di-bits=0
--vu0-di-bits=0
--vu1-opt-vf00=2
--vu0-opt-vf00=2
--vu1-injection=1
--vu1=jit-sync
--vu1-jr-cache-policy=newprog
--vu1-jalr-cache-policy=newprog
--vu0-jr-cache-policy=newprog
--vu0-jalr-cache-policy=newprog


--ee-cycle-scalar=1.5

LUA
NTSC only

-- X-Men™ Legends®
-- ported to PS4 Lua by Stayhye
-- emu used=jakx v2

apiRequest(2.2)

local gpr       = require("ee-gpr-alias")
local emuObj      = getEmuObject()
local eeObj       = getEEObject()
local gsObj       = getGsObject()
local eeOverlay    = eeObj.getOverlayObject()
local iopObj  = getIOPObject()
 

emuObj.PadSetLightBar(0, 10,50,145)
emuObj.SetDisplayAspectWide()
gsObj.SetDeinterlaceShift(0)

local WS = function()
--eeObj.WriteMem32(0x005cc888,0x3c023f34)
eeObj.WriteMem32(0x20720920,0x3FE147AE)  --In-game width widescreen 16:9
eeObj.WriteMem32(0x2072094c,0x3F000000)  --Fonts Width
eeObj.WriteMem32(0x20720950,0x3F000000)  --Fonts Height
eeObj.WriteMem32(0x20720958,0x3F8CCCCD)  --HUD & Menu Height
--eeObj.WriteMem32(0x20720954,0x3FA00000)  --HUD & Menu Width
eeObj.WriteMem32(0x20D85448,0x3F666666)  --HUD Height
eeObj.WriteMem32(0x20D85430,0x3F59999A)  --HUD Width

eeObj.Vu1MpgCycles(3450)
emuObj.ThrottleMax()
end

emuObj.AddVsyncHook(WS)

emuObj.SetGsTitleFix( "globalSet",  "reserved", { workLoadThreshold = 100000} )
emuObj.SetGsTitleFix( "globalSet",  "reserved", { waveThreshold = 90000} )
emuObj.SetGsTitleFix( "ignoreAreaUpdate", 0, { } )

Yu-Gi-Oh! Capsule Monsters Colosseum

All
CLI

--vu1=jit-sync

#MTVU Incompatibilty, Fix for Black Screen, RECVX Emu Needed

Zatch Bell! Mamodo Battles™

NTSC/U
CLI

#Graphical glitches fix
--gs-kernel-cl="mipmap"
--gs-kernel-cl-up="mipmap2x2"
--gs-use-mipmap=1
#Clamping, also for graphics
--vu0-no-clamping=0
--vu1-no-clamping=0
#likely unnecessary commands
--vu0-clamp-results=1
--vu1-clamp-results=1
--cop2-no-clamping=0
--cop2-clamp-results=1
--fpu-no-clamping=0
--fpu-clamp-results=1

#Jak Emu used*

Zombie Hunters 2

CLI
All versions

#Speedhacks
--vu1-di-bits=0
--ee-cycle-scalar=1.2
--vu1-mpg-cycles=150
#Graphics clean up
--gs-use-clut-merge=1
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"
--vu1-no-clamping=0

Zombie Zone

CLI
All versions

#Speedhacks
--vu1-di-bits=0
--ee-cycle-scalar=1.2
--vu1-mpg-cycles=150
#Graphics clean up
--gs-use-clut-merge=1
--gs-kernel-cl="clutmerge"
--gs-kernel-cl-up="clutmerge2x2"

Coraline

CLI
All versions

--gs-uprender=2x2
--gs-upscale=EdgeSmooth
--gs-use-mipmap=1
--gs-kernel-cl-up="mipmap2x2"
--gs-scanout-offsetx=27
--gs-scanout-offsety=27
--safe-area-min=0.9
--cdvd-sector-read-cycles=2000

LUA
PAL

-- Coraline
-- emu used=KOF 98

apiRequest(1.0)   

local gpr = require("ee-gpr-alias")

local eeObj  = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

--Widescreen hack 
--Gameplay 16:9
--eeObj.WriteMem32(0x0026432C,0x3C014440) --3C014480 (Increases hor. axis)

--Render fix
eeObj.WriteMem32(0x001A6548,0x3C013C2E) --3C013C0E

--Get rid of black bar
eeObj.WriteMem32(0x00225ea8,0x3c014000) --3c014299
eeObj.WriteMem32(0x00225eac,0x00000000) --3421999a

eeObj.WriteMem32(0x002644ec,0x3c014440) -- hor fov

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 (R1 ~= 0 and LEFT ~= 0) then --L3 Normal Screen
   eeObj.WriteMem32(0x0026432C,0x3C014480) -- original value
end

if (R1 ~= 0 and RIGHT ~= 0) then --R3 Widescreen Screen
   eeObj.WriteMem32(0x0026432C,0x3C014440) --3C014480 (Increases hor. axis)
end

emuObj.ThrottleMax()

end

emuObj.AddVsyncHook(patcher)

Total Overdose

CLI
All versions

--host-display-mode=16:9
--host-vsync=1
--gs-optimize=60fps
--cdvd-sector-read-cycles=2000
--ps2-lang=system

--gs-progressive=1
--gs-motion-factor=50

--vu0-no-clamping=0
--vu1-no-clamping=0

--gs-ignore-rect-correction=1

#ADK Damashii Emu used

LUA
PAL - SLES53492

-- Total Overdose (E)(SLES-53492)
-- emu used=ADK

apiRequest(1.0)
local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()
--Widescreen hack 16:9

--00 00 80 3F 83 F9 22 3F DB 0F C9 3F 00 00 00 BF
eeObj.WriteMem32(0x20692A2C,0x3F47AE14) -- Zoom

--00 00 80 3F 00 00 00 00 00 00 00 00 2F 00 00 00
eeObj.WriteMem32(0x206C64C4,0x3F400000) -- Vert fov
end

emuObj.AddVsyncHook(patcher)

emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=1 } )
emuObj.SetGsTitleFix( "forceSimpleFetch", "reserved", { texMode=2 } )

emuObj.SetGsTitleFix( "forceSimpleFetch",  "reserved", {psm=0} )
emuObj.SetGsTitleFix( "fetchFromCurrBuff", "reserved", {psm=0} )

Dark Summit

CLI
All versions

--host-display-mode=16:9
--force-pal-60hz=1

# Fahrenheit Emu used

LUA
PAL - SLES50575

-- Dark Summit (PAL)
-- emu used=Fahrenheit
apiRequest(1.2)    -- request version 0.1 API. Calling apiRequest() is mandatory.

local emuObj = getEmuObject()
local eeObj  = getEEObject()

local WS = function()

--Widescreen hack 16:9

--X-Fov
--02000446 280100ae 42080546
eeObj.WriteMem32(0x003d37d0,0x08030000)

eeObj.WriteMem32(0x000c0000,0x46040002)
eeObj.WriteMem32(0x000c0004,0x3c013f40)
eeObj.WriteMem32(0x000c0008,0x00000000)
eeObj.WriteMem32(0x000c000c,0x4481f000)
eeObj.WriteMem32(0x000c0010,0x461e0002)
eeObj.WriteMem32(0x000c0014,0x080f4df5)

--Render fix
--003f013c 00a88144 0000b07f
eeObj.WriteMem32(0x0036444c,0x3c013f2b) --3c013f00

emuObj.ThrottleMax()

end

emuObj.AddVsyncHook(WS)

Nightshade

CLI

ALL versions

--host-display-mode=16:9
--gs-vert-precision=8
--force-frame-blend=1

LUA
NTSC - SLUS20810

-- Nightshade (SLUS-20810)
-- Total Repair by nifengyuexia
-- emu used=jak v2

apiRequest(1.0)

local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()

--Disable the fade-in effect to fix framerate drops caused by excessive enemies
eeObj.WriteMem32(0x1d1048,0x1000000f)

--Disable shadows to fix square bugs around characters
eeObj.WriteMem32(0x322060,0x03e00008)
eeObj.WriteMem32(0x322064,0x00000000)

--Disable haze effect to fix charged attack frame rate drop
eeObj.WriteMem32(0x30f3f4,0x00000000)

end
emuObj.AddVsyncHook(patcher)

LUA
PAL - SLES52238

-- Nightshade(SLES-52238)
-- Total Repair by nifengyuexia
-- emu used=jak v2

apiRequest(1.0)

local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()

--Disable the fade-in effect to fix framerate drops caused by excessive enemies
eeObj.WriteMem32(0x1d1f38,0x1000000f)

--Disable shadows to fix square bugs around characters
eeObj.WriteMem32(0x326370,0x03e00008)
eeObj.WriteMem32(0x326374,0x00000000)

--Disable haze effect to fix charged attack frame rate drop
eeObj.WriteMem32(0x3135f4,0x00000000)

end
emuObj.AddVsyncHook(patcher)

LUA
Kunoichi
NTSC-J SLAJ-25031

-- Kunoichi(SLAJ-25031)
-- Total Repair by nifengyuexia
-- emu used=jak v2

apiRequest(1.0)

local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()

--Disable the fade-in effect to fix framerate drops caused by excessive enemies
eeObj.WriteMem32(0x1d10f8,0x1000000f)

--Disable shadows to fix square bugs around characters
eeObj.WriteMem32(0x324450,0x03e00008)
eeObj.WriteMem32(0x324454,0x00000000)

--Disable haze effect to fix charged attack frame rate drop
eeObj.WriteMem32(0x3117f4,0x00000000)

end
emuObj.AddVsyncHook(patcher)

LUA
NTSC-J SLPM-65447

-- Kunoichi(SLPM-65447)
-- Total Repair by nifengyuexia
-- emu used=jak v2

apiRequest(1.0)

local eeObj = getEEObject()
local emuObj = getEmuObject()
local patcher = function()

--Disable the fade-in effect to fix framerate drops caused by excessive enemies
eeObj.WriteMem32(0x1d1058,0x1000000f)

--Disable shadows to fix square bugs around characters
eeObj.WriteMem32(0x321c70,0x03e00008)
eeObj.WriteMem32(0x321c74,0x00000000)

--Disable haze effect to fix charged attack frame rate drop
eeObj.WriteMem32(0x30f004,0x00000000)
end
emuObj.AddVsyncHook(patcher)

Jak and Daxter: The Lost Frontier

CLI

ALL versions

--vu1-di-bits=0
--vu0-di-bits=1
--gs-optimize=60fps

# Emu used = Red Dead Revolver

Sled Storm

ALL versions

--cdvd-sector-read-cycles=2000
--vu0-no-clamping=0
--vu1-no-clamping=0
--host-gamepads=2

# Emu used = Rogue v1

Incomplete configurations

This is a list of configurations that were unsuccessful or were never completed, or information that might help people in the future.
A place for research and sharing useful info.


Dragon ball z budokai tenkaichi

LUA
NTSC

Things go wrong somewhere around 0x001137A8

apiRequest(0.1)

--untested
local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()
eeObj.WriteMem32(0x0011A54C, 0x24020000)
eeObj.WriteMem32(0x0018D944, 0x24020000)
eeObj.WriteMem32(0x0018D4CC, 0x24020000)
end
emuObj.AddVsyncHook(patcher)

Dynasty Warriors 5 - Empires


PAL

001428CC

-00142910

Batman begins

NTSC

00409BF8 0000001E

Genji dawn of the samurai


NTSC

002F876C

Bee movie

NTSC
CLI
NTSC
Redfaction

--ee-context-switch-cycles=16000
--assert-path1-ad=1
--gs-kernel-cl-up="up2x2simple"

Hitman - Blood Money

NTSC
LUA

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()
--Exhibits a strange DMA issue
local patcher = function()
eeObj.WriteMem32(0x0028B554, 0x240F0000)
eeObj.WriteMem32(0x0028B4B0, 0x240F0000)
end
emuObj.AddVsyncHook(patcher)

Tenchu - Fatal Shadows


NTSC
Destroy all humans v1

#Removes most elements of graphical corruption
--vif1-instant-xfer=0
apiRequest(0.1)
-- Not the best solution, but it works.
eeInsnReplace(0x001023E0, 0xAE020000, 0x0)
-- The graphical issues start somewhere in this function 0x00134B10

Ratchet and Clank: Up Your Arsenal


SCUS97353

-- 23.07.2023 Added debug stuff that should print in klog.
-- This should help us figure out why patch fail. 

apiRequest(1.0)
 
local em  = getEmuObject()
local ee  = getEEObject()
 
local patcher = function()
    
    print("CONFIG: Entering patcher!")
    local base = -1
    local addr = -1
    --local spmp = -1
    
    -- Check for SP/MP, not working yet. Only SP supported.
    --spmp = ee.ReadMem32(0x13B3D8)
    --if spmp == 0x0000202d then
    --    addr = 0x13B3D8
    --else
    --    addr = 0x13B3D8
    --end
 
    -- Search for base.
    addr = 0x13B3D8
    while addr < 0x1000000
    do
        if ee.ReadMem32(addr) == 0x8c810014 then
            if ee.ReadMem32(addr + 4) == 0x3c067000 then
                if ee.ReadMem32(addr + 8) == 0x7cdf1ff0 then
                    base = addr
                    break
                else
                    addr = addr + 4
                end
            else
                addr = addr + 4
            end
        else
            addr = addr + 4
        end
    end
    
    -- Shouldn't be the case.
    if base == -1 then
        print("CONFIG: Base not found!")
        return
    end
    print(string.format("CONFIG: Base = %08x", base))
    -- Patch ctc2 instances.
    ee.WriteMem32(base + 0x490, 0x0C03FF0C) -- ctc2         $zero, vi2
    ee.WriteMem32(base + 0x5e0, 0x0C03FF0C) -- ctc2         $zero, vi2
    ee.WriteMem32(base + 0x728, 0x0C03FF0C) -- ctc2         $zero, vi2
    ee.WriteMem32(base + 0x878, 0x0C03FF0C) -- ctc2         $zero, vi2
    ee.WriteMem32(base + 0x9c0, 0x0C03FF0C) -- ctc2         $zero, vi2
    ee.WriteMem32(base + 0xb18, 0x0C03FF0C) -- ctc2         $zero, vi2
 
    ee.WriteMem32(base + 0x3f0, 0x0C03FF00) -- ctc2         $zero, vi1
    ee.WriteMem32(base + 0x530, 0x0C03FF00) -- ctc2         $zero, vi1
    ee.WriteMem32(base + 0x688, 0x0C03FF00) -- ctc2         $zero, vi1
    ee.WriteMem32(base + 0x7c8, 0x0C03FF00) -- ctc2         $zero, vi1
    ee.WriteMem32(base + 0x920, 0x0C03FF00) -- ctc2         $zero, vi1
    ee.WriteMem32(base + 0xa60, 0x0C03FF00) -- ctc2         $zero, vi1
 
    -- preserve ra
    ee.WriteMem32(base + 0x22c, 0xACDF1FF4)
    -- restore ra 
    ee.WriteMem32(base + 0xcac, 0x8CDF1FF4)
    -- lq --> lw
    ee.WriteMem32(base + 0xd6c, 0x8c3f1ff0)
    -- delay vcall by few cycles
    ee.WriteMem32(base + 0x33c, 0x241C0020) -- modify to burn ee cycles after vcallms
    ee.WriteMem32(base + 0x340, 0x141CFFFF)
    ee.WriteMem32(base + 0x344, 0x279CFFFF)
    print("CONFIG: Dynamic patches applied!")
end
 
local delayer = function()
    
    local check = ee.ReadMem32(0x000ffc00)
    if check ~= 0xfcd91ff8 then
        print("CONFIG: Applying static patches!")
    end
    
    -- loop vi1
    ee.WriteMem32(0x000ffc00, 0xfcd91ff8)
    ee.WriteMem32(0x000ffc04, 0x24190080) -- modify to burn ee cycles before ctc2
    ee.WriteMem32(0x000ffc08, 0x1419ffff)
    ee.WriteMem32(0x000ffc0c, 0x2739ffff)
    ee.WriteMem32(0x000ffc10, 0x48c00800)
    ee.WriteMem32(0x000ffc14, 0x24190020) -- modify to burn ee cycles after ctc2
    ee.WriteMem32(0x000ffc18, 0x1419ffff)
    ee.WriteMem32(0x000ffc1c, 0x2739ffff)
    ee.WriteMem32(0x000ffc20, 0x03e00008)
    ee.WriteMem32(0x000ffc24, 0xdcd91ff8)
    
    -- loop vi2
    ee.WriteMem32(0x000ffc30, 0xfcd91ff8)
    ee.WriteMem32(0x000ffc34, 0x24190080) -- modify to burn ee cycles before ctc2
    ee.WriteMem32(0x000ffc38, 0x1419ffff)
    ee.WriteMem32(0x000ffc3c, 0x2739ffff)
    ee.WriteMem32(0x000ffc40, 0x48c01000)
    ee.WriteMem32(0x000ffc44, 0x24190020) -- modify to burn ee cycles after ctc2
    ee.WriteMem32(0x000ffc48, 0x1419ffff)
    ee.WriteMem32(0x000ffc4c, 0x2739ffff)
    ee.WriteMem32(0x000ffc50, 0x03e00008)
    ee.WriteMem32(0x000ffc54, 0xdcd91ff8)
    
    -- This static patch is required because game don't use level loader to load main menu.
    local new_game = ee.ReadMem32(0x3D58B8)
    local check2   = ee.ReadMem32(0x3D5D48)
    if new_game == 0x8c810014 and check2 ~= 0x0C03FF0C then
        print("CONFIG: Applying static patch for new game!")
        ee.WriteMem32(0x3D5D48, 0x0C03FF0C) -- ctc2         $zero, vi2
        ee.WriteMem32(0x3D5E98, 0x0C03FF0C) -- ctc2         $zero, vi2
        ee.WriteMem32(0x3D5FE0, 0x0C03FF0C) -- ctc2         $zero, vi2
        ee.WriteMem32(0x3D6130, 0x0C03FF0C) -- ctc2         $zero, vi2
        ee.WriteMem32(0x3D6278, 0x0C03FF0C) -- ctc2         $zero, vi2
        ee.WriteMem32(0x3D63D0, 0x0C03FF0C) -- ctc2         $zero, vi2
 
        ee.WriteMem32(0x3D5CA8, 0x0C03FF00) -- ctc2         $zero, vi1
        ee.WriteMem32(0x3D5DE8, 0x0C03FF00) -- ctc2         $zero, vi1
        ee.WriteMem32(0x3D5F40, 0x0C03FF00) -- ctc2         $zero, vi1
        ee.WriteMem32(0x3D6080, 0x0C03FF00) -- ctc2         $zero, vi1
        ee.WriteMem32(0x3D61D8, 0x0C03FF00) -- ctc2         $zero, vi1
        ee.WriteMem32(0x3D6318, 0x0C03FF00) -- ctc2         $zero, vi1
        
        -- preserve ra
        ee.WriteMem32(0x3D5AE4, 0xACDF1FF4)
        -- restore ra 
        ee.WriteMem32(0x3D6564, 0x8CDF1FF4)
        -- lq --> lw
        ee.WriteMem32(0x3D6624, 0x8c3f1ff0)
        -- vcall
        ee.WriteMem32(0x3D5BF4, 0x241C0020) -- modify to burn ee cycles after vcallms
        ee.WriteMem32(0x3D5BF8, 0x141CFFFF)
        ee.WriteMem32(0x3D5BFC, 0x279CFFFF)
    end
end
 
-- hook right after level loader, ideally this should be hook inside loader...
ee.AddHook(0x13B3D8, 0x0000202D, patcher)
em.AddVsyncHook(delayer)

I'm following this approach but it isn't working and I do not know why. --Scalerize (talk) 21:55, 28 August 2023 (CEST)

apiRequest(0.1)

local eeObj = getEEObject()


eeObj.AddHook(0x0013B3C8, 0x0200F809, function() 
local pointer =  eeObj.GetGpr(gpr.s0)
end)


--vcallms before
eeObj.AddHook(pointer+0x5496C, 0x7120CDA8, function()
          eeObj.AdvanceClock(500)
end)

--vcallms after
eeObj.AddHook(pointer+0x54974, 0x00000000, function()
          eeObj.AdvanceClock(500)
end)

--vi01 before 1
eeObj.AddHook(pointer+0x54A24, 0x00000000, function()
          eeObj.AdvanceClock(500)
end)

--vi01 before 2
eeObj.AddHook(pointer+0x54B64, 0x7019CC3F, function()
          eeObj.AdvanceClock(500)
end)

--vi01 before 3
eeObj.AddHook(pointer+0x54CBC, 0x00000000, function()
          eeObj.AdvanceClock(500)
end)

--vi01 before 4
eeObj.AddHook(pointer+0x54DFC, 0x7019CC3F, function()
          eeObj.AdvanceClock(500)
end)

--vi01 before 5
eeObj.AddHook(pointer+0x54F54, 0x0019C900, function()
          eeObj.AdvanceClock(500)
end)

--vi01 before 6
eeObj.AddHook(pointer+0x55094, 0x7017BEC8, function()
          eeObj.AdvanceClock(500)
end)

--vi01 after 1
eeObj.AddHook(pointer+0x54A2C, 0x00000000, function()
          eeObj.AdvanceClock(500)
end)

--vi01 after 2
eeObj.AddHook(pointer+0x54B6C, 0x00000000, function()
          eeObj.AdvanceClock(500)
end)

--vi01 after 3
eeObj.AddHook(pointer+0x54CC4, 0x00000000, function()
          eeObj.AdvanceClock(500)
end)

--vi01 after 4
eeObj.AddHook(pointer+0x54E04, 0x00000000, function()
          eeObj.AdvanceClock(500)
end)

--vi01 after 5
eeObj.AddHook(pointer+0x54F5C, 0x000F7880, function()
          eeObj.AdvanceClock(500)
end)

--vi01 after 6
eeObj.AddHook(pointer+0x5509C, 0x71D18D88, function()
          eeObj.AdvanceClock(500)
end)

--vi02 before 1
eeObj.AddHook(pointer+0x54AC4, 0x701188FC, function()
          eeObj.AdvanceClock(500)
end)

--vi02 before 2
eeObj.AddHook(pointer+0x54C14, 0x7120CDA8, function()
          eeObj.AdvanceClock(500)
end)

--vi02 before 3
eeObj.AddHook(pointer+0x54D5C, 0x701188FC, function()
          eeObj.AdvanceClock(500)
end)

--vi02 before 4
eeObj.AddHook(pointer+0x54EAC, 0x7120CDA8, function()
          eeObj.AdvanceClock(500)
end)

--vi02 before 5
eeObj.AddHook(pointer+0x54FF4, 0x0019C900, function()
          eeObj.AdvanceClock(500)
end)

--vi02 before 6
eeObj.AddHook(pointer+0x5514C, 0x00000000, function()
          eeObj.AdvanceClock(500)
end)

--vi02 after 1
eeObj.AddHook(pointer+0x54ACC, 0x70E0CDA8, function()
          eeObj.AdvanceClock(500)
end)

--vi02 after 2
eeObj.AddHook(pointer+0x54C1C, 0x7009E688, function()
          eeObj.AdvanceClock(500)
end)

--vi02 after 3
eeObj.AddHook(pointer+0x54D64, 0x70E0CDA8, function()
          eeObj.AdvanceClock(500)
end)

--vi02 after 4
eeObj.AddHook(pointer+0x54EB4, 0x7009E688, function()
          eeObj.AdvanceClock(500)
end)

--vi02 after 5
eeObj.AddHook(pointer+0x54FFC, 0x22310006, function()
          eeObj.AdvanceClock(500)
end)

--vi02 after 6
eeObj.AddHook(pointer+0x55154, 0x00000000, function()
          eeObj.AdvanceClock(500)
end)

You need to define pointer as a global variable or define it inside more advanced function, otherwise it is deleted/undefined when you exit first hook. Additionally your code use aliases without importing required file. This can be fixed by importing it or by using 16 instead of gpr.s0. Next thing is that all those hooks imo should be mounted from single function to ensure that all new hooks are added when game step on first hook. Keep in mind that the way you are obtaining ctc addresses can fail for next stages. Finally, when leaving stage you need to remove those hooks. Because they stay there forever, and that address can already hold different code after stage change. This is because hook check for original opcode is done only when mounting it there, not when running code itself. On top of that game overlay loader which you should use to grab pointer IS NOT used to load main menu screen, so you need to patch it manually or at least with another hook. I don't have ratchet elf now here, but make sure that your initial hook is added in place where new level code is already there, because now it seems that your initial hook is before level loader is even launched. --Kozarovv (talk) 12:06, 29 August 2023 (CEST)

Shadow Man - 2econd Coming


SLUS204.13

apiRequest(0.1)

local eeObj = getEEObject()
local emuObj = getEmuObject()

local patcher = function()

--Once it reaches to the TEQ, the game crashes.
eeObj.WriteMem32(0x00231AF0, 0x0808C6AF)

end
emuObj.AddVsyncHook(patcher)

Forbidden Siren 2

CLI
NTSC

--vu-xgkick-delay=9

sceTtyPrint

This should print some debug info in emulog/klog, pcsx2 a like. Pattern based on Smugglers Run 2 and Spiderman 3. So first test should be done with those games. Spiderman should print something like "Legal screen is 512 x 256." first. Smugglers Run 2 "Timezone=60". Assuming it work, this can give some valuable info about VIF1/GIF hangs, which are 50% of issues in those crappy emus.

--sceTtyWrite take:
--a0 = string ptr
--a1 = size (we need to overwrite str_ptr + size with 0 to make it 0 terminated)

-- best tty pattern for now = "0A 00 07 24 0D 00 05 24 0C 00 C4 24"

apiRequest(1.0)

eeObj  = getEEObject()
emuObj = getEmuObject()

local printerino = function() 
    local str_ptr  = eeObj.GetGpr(4) -- a0
    local str_size = eeObj.GetGpr(5) -- a1
    
    -- Add zero terminator, not sure if we need it...
    -- But i don't see any way to pass how long string should be.
    -- So just 0 terminate it just in case.
    -- Note: PS2 pass newline as last character, maybe we don't need it.
    -- if it break anything, or looks weird, then remove +1 from below write. 
    eeObj.WriteMem8(str_ptr + str_size + 1, 0)
    
    local str = eeObj.ReadMemStr(str_ptr)
    print(string.format("PS2 DEBUG: %s", str))
end


local addr   = 0x100008
local ttySearch = function()
	print("PS2 DEBUG: Entering ttySearch.")
    while(addr < 0x1000000 )
    do
        if eeObj.ReadMem32(addr) == 0x2407000A then
            if eeObj.ReadMem32(addr + 4) == 0x2405000D then
                if eeObj.ReadMem32(addr + 8) == 0x24C4000C then
					-- I'm sorry...
					local check = 0
					local full_op = 0
					while(check ~= 0x27BD and addr ~= 0x100008)
					do
					    addr = addr - 4
						full_op = eeObj.ReadMem32(addr)
						check = full_op >> 16
					end
                    break -- first loop
                else
                    addr = addr + 4
                end
            else
                addr = addr + 4
            end
        else
            addr = addr + 4
        end
    end
	if addr < 0x1000000 and not addr < 0x100008 then
	    print(string.format("Found sceTtyWrite function at: 0x%X", addr))
		eeObj.AddHook(addr, full_op, printerino)
	else
	    print("sceTtyWrite function not found!")
    end
end

emuObj.AddEntryPointHook(ttySearch)