--Dynasty Warriors 2 + 3 + Xtreme Legends Combined (U)(SLUS-20079)(SLUS-20277)(SLUS-20617)
--Widescreen Hack (16:9) by ElHecht (NTSC-U by Arapapa)
--FOV hack and other codes by Michael from DW discord
--Fixes by mrjaredbeta and Scalerize
--Combined into one pkg for PS4 by Drobovik
--emu used=jakX v2
apiRequest(2.3)
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 ThrottleOn = 3
local lightDef = {0,0,255}
local lightThr = {255,0,0}
emuObj.PadSetLightBar(0, lightDef[1], lightDef[2], lightDef[3])
local WSpatchDW2 = function()
--Increase max units rendered on screen (22 -> 28) DW3
eeObj.WriteMem32(0x003e1cfc,0x0000001c)
--Increased draw distance DW2 (Either 11000/10000 or 8500/7500)
eeObj.WriteMem32(0x002bbcdc,0x00000000)
eeObj.WriteMem32(0x002bbce0,0x00000000)
eeObj.WriteMem32(0x002bbd10,0x00000000)
eeObj.WriteMem32(0x002543ac,0x00000000)
eeObj.WriteMem32(0x002bbcc4,0x00000000)
eeObj.WriteMem32(0x002bbcc0,0x00000000)
--eeObj.WriteMem32(0x003503cc,0x462be000)-- 11000
--eeObj.WriteMem32(0x003503c8,0x461c4000)-- 10000
eeObj.WriteMem32(0x003503cc,0x4604D000) -- 8500
eeObj.WriteMem32(0x003503c8,0x45EA6000) -- 7500
-- Widescreen Selector
local pad_bits = emuObj.GetPad()
local L1 = pad_bits & 0x0400
local L3 = pad_bits & 0x0002
local R1 = pad_bits & 0x0800
local R3 = pad_bits & 0x0004
local Select = pad_bits & 0x0001
local Start = pad_bits & 0x0008
if (Select ~= 0 and L3 ~= 0) then
--Widescreen hack 16:9 (modified fov values) OLD
eeObj.WriteMem32(0x202FA696,0x3FAAAAAB)
--eeObj.WriteMem32(0x202FB4EC,0x3c013fab)--3c013f80 (broken ab value) hor fov real-time intro
eeObj.WriteMem32(0x203320CC,0x3FAAAAAB)
eeObj.WriteMem32(0x203321E8,0x3FAAAAAB)
eeObj.WriteMem32(0x203321F4,0x3FAAAAAB)--3f800000 ver fov
eeObj.WriteMem32(0x20332208,0x3FAAAAAB)
eeObj.WriteMem32(0x20332214,0x3FAAAAAB)
eeObj.WriteMem32(0x2033226C,0x3FAAAAAB)
eeObj.WriteMem32(0x2033236C,0x3FAAAAAB)
eeObj.WriteMem32(0x2033B18C,0x3FAAAAAB)
eeObj.WriteMem32(0x2033B190,0x3FAAAAAB)
eeObj.WriteMem32(0x2033B194,0x3FAAAAAB)
eeObj.WriteMem32(0x0020263c,0x00000000)
eeObj.WriteMem32(0x00202640,0x00000000)
eeObj.WriteMem32(0x00202650,0x46000306)
--Render fix (fix by Arapapa)
--003F013C 00608144 DC9C94C7
eeObj.WriteMem32(0x00253d24,0x3c013f40) --3c013f00
emuObj.SetDisplayAspectWide()
end
if (Select ~= 0 and R3 ~= 0) then
--From regular Widescreen hack
eeObj.WriteMem32(0x202FA696,0x3FAAAAAB)
--eeObj.WriteMem32(0x202FB4EC,0x3c013fab)--3c013f80 broken (ab) hor fov real-time intro
eeObj.WriteMem32(0x203320CC,0x3FAAAAAB)
eeObj.WriteMem32(0x203321E8,0x3FAAAAAB)
eeObj.WriteMem32(0x203321F4,0x3FAAAAAB)--3f800000 ver fov
eeObj.WriteMem32(0x20332208,0x3FAAAAAB)
eeObj.WriteMem32(0x20332214,0x3FAAAAAB)
eeObj.WriteMem32(0x2033226C,0x3FAAAAAB)
eeObj.WriteMem32(0x2033236C,0x3FAAAAAB)
eeObj.WriteMem32(0x2033B18C,0x3FAAAAAB)
eeObj.WriteMem32(0x2033B190,0x3FAAAAAB)
eeObj.WriteMem32(0x2033B194,0x3FAAAAAB)
--FOV and camera mods 16x9
eeObj.WriteMem32(0x0020263c,0x3c013f40) --fov
eeObj.WriteMem32(0x00202640,0x4481f000) -- needed for fov
eeObj.WriteMem32(0x00202650,0x461e0003) -- needed for fov
eeObj.WriteMem32(0x00253d24,0x3c013f80) -- render fix
eeObj.WriteMem32(0x00208610,0x3c01c348)-- slight change to cam pos
eeObj.WriteMem32(0x0022E794,0x00000000)-- disable pan down after L1 -alt 0022E79C
-- camera view values
--eeObj.WriteMem32(0x00208610,0x3c01c35c)-- 3c01c35c=-220 3c01c334=-180 (looks more like dw3/4/5 cam view)
--eeObj.WriteMem32(0x00208618,0x3c0143fa)-- 3c0143fa=500
--eeObj.WriteMem32(0x00208620,0x3c01442f)-- 3c01442f=700
--eeObj.WriteMem32(0x00208628,0x3c014140)-- 3c014140=12
-- camera view values horse
--eeObj.WriteMem32(0x00208668,0x3c01c348)--Y 3c01c35c=-220
--eeObj.WriteMem32(0x00208670,0x3c0141a0)-- 3c01442f=700
--eeObj.WriteMem32(0x00208678,0x3c0143fa)--Z 3c014461=900
--eeObj.WriteMem32(0x00208680,0x3c0141a0)-- 3c0141a0=20
emuObj.SetDisplayAspectWide()
end
if (Select ~= 0 and R3 ~= 0 and L3 ~= 0) then
--From regular Widescreen hack
eeObj.WriteMem32(0x202FA696,0x3f800000)
--eeObj.WriteMem32(0x202FB4EC,0x3c013fab)--3c013f80 broken (ab) hor fov real-time intro
eeObj.WriteMem32(0x203320CC,0x3f800000)
eeObj.WriteMem32(0x203321E8,0x3f800000)
eeObj.WriteMem32(0x203321F4,0x3f800000) --3f800000 ver fov
eeObj.WriteMem32(0x20332208,0x3f800000)
eeObj.WriteMem32(0x20332214,0x3f800000)
eeObj.WriteMem32(0x2033226C,0x3f800000)
eeObj.WriteMem32(0x2033236C,0x3f800000)
eeObj.WriteMem32(0x2033B18C,0x3f800000)
eeObj.WriteMem32(0x2033B190,0x3f800000)
eeObj.WriteMem32(0x2033B194,0x3f800000)
--Normal 4x3
eeObj.WriteMem32(0x0020263c,0x00000000) --00000000 zoom
eeObj.WriteMem32(0x00202640,0x00000000) --00000000
eeObj.WriteMem32(0x00202650,0x00000000) --00000000
eeObj.WriteMem32(0x00253d24,0x3c013f00) --3c013f00 renderfix
eeObj.WriteMem32(0x00208610,0x3c01c35c)-- slight change to cam pos (Like DW3)
eeObj.WriteMem32(0x0022E794,0x2c420001)-- disable pan down after L1 -alt 0022E79C
emuObj.SetDisplayAspectNormal()
end
--Reduce Loading Time
--Note: May cause audio bugs during pre-battle screen. (Doesn't affect gameplay)
--eeObj.WriteMem32(0x0020d724,0x00000000)
--eeObj.WriteMem32(0x0020d784,0x00000000)
--eeObj.WriteMem32(0x0020d6a0,0x00000000)
--eeObj.WriteMem32(0x0020d6a8,0x00000000)
--eeObj.WriteMem32(0x0020d6ac,0x00000000)
--eeObj.WriteMem32(0x0020d73c,0x00000000)
--eeObj.WriteMem32(0x0020d744,0x00000000)
--Stage screen corruption fix
eeObj.WriteMem32(0x00200e98,0x240c0062)
--Army advance
--Makes forces be more offensive and advance to fight the enemy rather than waiting at 1 spot.
eeObj.WriteMem32(0x0023cfe8,0x00000000)
--this one allows to turn when charge attacking
--Possibly not playing well with disable Auto lock code,so pick one or the other
--eeObj.WriteMem32(0x0022E74C,0x0C0821A8)
--disable charge attack camera zoom effect (Doesnt work with allows to turn when charge attacking enabled)
eeObj.WriteMem32(0x0022E570,0x00000000)
--camera doesn't reset after blocking (L1)
--eeObj.WriteMem32(0x00205378,0x00000000)
--camera straight ahead view
--eeObj.WriteMem32(0x002033F4,0x00000000)
-- camera turns when you turn
--eeObj.WriteMem32(0x0022E7E4,0x0C0821A8)
--Disable Musou pause
--eeObj.WriteMem32(0x0020fbb8,0x24020001)
--Names and Healthbars always on (Always on L2 button)
--eeObj.WriteMem32(0x003e2818,0x00000001)
--Disable "PUSH START" text in Demo mode
eeObj.WriteMem32(0x0020e8dc,0x00000000)
--Disable Auto Lock
eeObj.WriteMem32(0x0023f604,0x00000000)
--Able to pick up items on horse
eeObj.WriteMem32(0x00287F70,0x3C01433e)
end
local WSpatchDW3 = function()
--Increase max units rendered onscreen (22 -> 28) DW3
eeObj.WriteMem32(0x00115160,0x2406001c)
--DOES NOT WORK as LUA, needed to patch ISO (I picked 11k-10k)
--Increased draw distance DW3 (Choose only 1 group of 3 codes below)
--eeObj.WriteMem32(0x0020D800,0x00000000)
--eeObj.WriteMem32(0x0020AD08,0x00000000)
--eeObj.WriteMem32(0x0020D42C,0x00000000)
--eeObj.WriteMem32(0x00209B14,0x00000000)
--eeObj.WriteMem32(0x00209B18,0x00000000)
--eeObj.WriteMem32(0x00209B88,0x00000000)
--eeObj.WriteMem32(0x00209B8C,0x00000000)
--eeObj.WriteMem32(0x00209CB0,0x00000000)
--eeObj.WriteMem32(0x00209CB4,0x00000000)
--eeObj.WriteMem32(0x00209D24,0x00000000)
--eeObj.WriteMem32(0x0020D7FC,0x00000000)
--eeObj.WriteMem32(0x0020AC78,0x00000000)
--eeObj.WriteMem32(0x0020D424,0x00000000)
--eeObj.WriteMem32(0x002097A4,0x00000000)
--eeObj.WriteMem32(0x002097A8,0x00000000)
--eeObj.WriteMem32(0x00209818,0x00000000)
--eeObj.WriteMem32(0x0020981C,0x00000000)
--eeObj.WriteMem32(0x00209940,0x00000000)
--eeObj.WriteMem32(0x00209944,0x00000000)
--eeObj.WriteMem32(0x002099B4,0x00000000)
--eeObj.WriteMem32(0x0059506c,0x462BE000)--11k P1
--eeObj.WriteMem32(0x00595068,0x461C4000)--10k P1
--eeObj.WriteMem32(0x00595088,0x462BE000)--P2
--eeObj.WriteMem32(0x00595084,0x461C4000)--P2
--eeObj.WriteMem32(0x0059506c,0x466a6000)--15k P1
--eeObj.WriteMem32(0x00595068,0x465ac000)--14k P1
--eeObj.WriteMem32(0x00595088,0x466a6000)--P2
--eeObj.WriteMem32(0x00595084,0x465ac000)--P2
--eeObj.WriteMem32(0x0059506c,0x468ca000)--18k P1
--eeObj.WriteMem32(0x00595068,0x4684d000)--17k P1
--eeObj.WriteMem32(0x00595088,0x468ca000)--P2
--eeObj.WriteMem32(0x00595084,0x4684d000)--P2
--Disable "PUSH START" text in Demo mode
eeObj.WriteMem32(0x001433A8,0x00000000)
--Disable Auto Lock
eeObj.WriteMem32(0x00103284,0x00000000)
--Disable C5 Auto Lock
eeObj.WriteMem32(0x0013BF50,0x00000000)
--Able to pick up items on horse
eeObj.WriteMem32(0x0014d1f8,0x3C03433e)
--Names and Health bars always on
--eeObj.WriteMem32(0x004FE880,0x00000001)
--eeObj.WriteMem32(0x00507490,0x00000001)
--COP2 flag instance patch by refraction (SPS gfx fix for the opening in-game intro)
--A mac flag check after running another vsub op which is irrelivant, rearranging
eeObj.WriteMem32(0x00273230,0x48438800)
eeObj.WriteMem32(0x0027323c,0x4BE521AC)
--Experimental fix for Wan Castle crash, most likely FPU related. WORKS but crashes game after the stage.
--Causes falling thru maps
--eeObj.WriteMem32(0x0013B5E0,0x00000000)--0c04eb0c
--eeObj.WriteMem32(0x0013B5E4,0x00000000)--72002628
--Code below causes crash after loading Wan Castle stage if quit
--eeObj.WriteMem32(0x0013AC30,0x03E00008) --27bdff10
-- Widescreen and other selectors
local pad_bits = emuObj.GetPad()
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
--Experimental fix for Wan Castle crash, most likely FPU related. WORKS but...
--Causes falling thru maps. Use selector below to turn off the patch after playing Wan Castle
if (R1 ~= 0 and L3 ~= 0) then --ON
eeObj.WriteMem32(0x0013B5E0,0x00000000)--0c04eb0c
eeObj.WriteMem32(0x0013B5E4,0x00000000)--72002628
end
if (R1 ~= 0 and R3 ~= 0) then --OFF
eeObj.WriteMem32(0x0013B5E0,0x0c04eb0c)--0c04eb0c
eeObj.WriteMem32(0x0013B5E4,0x72002628)--72002628
end
if (Select ~= 0 and L3 ~= 0) then
-- Widescreen hack 16:9
eeObj.WriteMem32(0x002fa708,0x3fa00000)--3f800000 camera zoom
eeObj.WriteMem32(0x002FA714,0x3FAAAAAB)-- 3f800000 ver fov
eeObj.WriteMem32(0x0025dd14,0x3c023f40)-- 3c023f80 hor fov real-time intro
eeObj.WriteMem32(0x00176580,0x3c023f35)-- 3c023f00 renderfix
emuObj.SetDisplayAspectWide()
end
if (Select ~= 0 and R3 ~= 0) then
-- wider FOV (Field of view)
eeObj.WriteMem32(0x0025dd14,0x3c023f40)-- 3c023f80 hor fov real-time intro
eeObj.WriteMem32(0x002FA714,0x3FAAAAAB)-- 3f800000 ver fov
eeObj.WriteMem32(0x002fa708,0x3fc00000)--3f800000 camera zoom
eeObj.WriteMem32(0x00176580,0x3c023f80)--3c023f00 renderfix
emuObj.SetDisplayAspectWide()
end
end
local WSpatchDW3XL = function()
--Increase max units rendered onscreen (22 -> 28) DW3XL
eeObj.WriteMem32(0x001164d8,0x2406001c)
--Increased draw distance DW3XL
eeObj.WriteMem32(0x001F8B30,0x00000000)
eeObj.WriteMem32(0x001F8B34,0x00000000)
eeObj.WriteMem32(0x001F8BA0,0x00000000)
eeObj.WriteMem32(0x001F8BA4,0x00000000)
eeObj.WriteMem32(0x001F8CAC,0x00000000)
eeObj.WriteMem32(0x001F8CB0,0x00000000)
eeObj.WriteMem32(0x001F8D1C,0x00000000)
eeObj.WriteMem32(0x001F8980,0x00000000)
eeObj.WriteMem32(0x001F8984,0x00000000)
eeObj.WriteMem32(0x001F89E8,0x00000000)
eeObj.WriteMem32(0x001F880C,0x00000000)
eeObj.WriteMem32(0x001F8810,0x00000000)
eeObj.WriteMem32(0x001F8874,0x00000000)
eeObj.WriteMem32(0x001F8878,0x00000000)
eeObj.WriteMem32(0x0053a67c,0x462BE000)--11k
eeObj.WriteMem32(0x0053a678,0x461C4000)
eeObj.WriteMem32(0x0053a698,0x462BE000)
eeObj.WriteMem32(0x0053a694,0x461C4000)
--eeObj.WriteMem32(0x0053a67c,0x466a6000)--15k
--eeObj.WriteMem32(0x0053a678,0x465ac000)
--eeObj.WriteMem32(0x0053a698,0x466a6000)
--eeObj.WriteMem32(0x0053a694,0x465ac000)
--eeObj.WriteMem32(0x0053a67c,0x468ca000)--18k
--eeObj.WriteMem32(0x0053a678,0x4684d000)
--eeObj.WriteMem32(0x0053a698,0x468ca000)
--eeObj.WriteMem32(0x0053a694,0x4684d000)
--< These codes below were added through ISO patching since I'm using combined DW3XL ISO
--And both elf files have the same offsets to patch, I picked only SLUS-20617
--Disable "PUSH START" text in Demo mode
--patch=1,EE,001476c0,word,00000000
--eeObj.WriteMem32(0x001476c0,0x00000000)
--Disable Auto Lock
--patch=1,EE,00103518,word,00000000
--eeObj.WriteMem32(0x00103518,0x00000000)
--Disable C5 Auto Lock
--patch=1,EE,0013f6d4,word,00000000
--patch=1,EE,0013f6ec,word,00000000
--eeObj.WriteMem32(0x0013f6d4,0x00000000)
--eeObj.WriteMem32(0x0013f6ec,0x00000000)
--Able to pick up items on horse
--patch=1,EE,00151978,word,3C03433e
--eeObj.WriteMem32(0x00151978,0x3C03433e)
-->
--Experimental Wan Castle crash fix for DW3XL
--Code below doesn't crash like in DW3 after loading Wan Castle stage and quit or reset to main menu by Touchpad Left+Right
--eeObj.WriteMem32(0x0013e310,0x03E00008) --27bdff00
-- Widescreen and other selectors
local pad_bits = emuObj.GetPad()
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
--Experimental fix for Wan Castle crash, most likely FPU related. WORKS but...
--Causes falling thru maps. Use selector below to turn off the patch after playing Wan Castle
if (R1 ~= 0 and L3 ~= 0) then
eeObj.WriteMem32(0x0013e310,0x03E00008) --27bdff00
end
if (R1 ~= 0 and R3 ~= 0) then
eeObj.WriteMem32(0x0013e310,0x27bdff00) --27bdff00
end
if (Select ~= 0 and L3 ~= 0) then
--16:9
eeObj.WriteMem32(0x00282f58,0x3faaaaab)
eeObj.WriteMem32(0x00282f64,0x3faaaaab)
--Render fix
eeObj.WriteMem32(0x0017f9b0,0x3c023f60) --3c023f60 for 2x2 PS4 uprender
emuObj.SetDisplayAspectWide()
end
if (Select ~= 0 and R3 ~= 0) then
--FOV (Field of view)
eeObj.WriteMem32(0x00282f58,0x3fcc0000)--3f800000
eeObj.WriteMem32(0x00282f64,0x3faaaaab)
eeObj.WriteMem32(0x0017f9b0,0x3c023fa0)--3c023f00 renderfix
emuObj.SetDisplayAspectWide()
end
end
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
local Nothing = 1
local onBtn1 = L3
local onBtn2 = R3
local onBtn3 = Nothing
local offBtn1 = L3
local offBtn2 = Select
local offBtn3 = Nothing
if (onBtn1 ~= 0) and (onBtn2 ~= 0) and (onBtn3 ~= 0) and (ThrottleOn == 0) then
emuObj.ThrottleMax()
emuObj.PadSetLightBar(0, lightThr[1], lightThr[2], lightThr[3])
ThrottleOn = 1
elseif (offBtn1 ~= 0) and (offBtn2 ~= 0) and (offBtn3 ~= 0) and (ThrottleOn == 1) then
emuObj.ThrottleNorm()
emuObj.PadSetLightBar(0, lightDef[1], lightDef[2], lightDef[3])
ThrottleOn = 0
end
if (ThrottleOn == 3) then
if (onBtn1 ~= 0) and (onBtn2 ~= 0) and (onBtn3 ~= 0) then
emuObj.ThrottleMax()
emuObj.PadSetLightBar(0, lightThr[1], lightThr[2], lightThr[3])
else
emuObj.ThrottleNorm()
emuObj.PadSetLightBar(0, lightDef[1], lightDef[2], lightDef[3])
end
end
end
local titleid = emuObj.GetDiscTitleId() -- returns string as read from iso img SYSTEM.CNF
if titleid == 'SLUS-20079' then
emuObj.AddVsyncHook(WSpatchDW2)
end
if titleid == 'SLUS-20277' then
emuObj.AddVsyncHook(WSpatchDW3)
end
if titleid == 'SLUS-20617' then
emuObj.AddVsyncHook(WSpatchDW3XL)
end
emuObj.AddVsyncHook(CheckInputs)