Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Decompiled using luadec 2.2 rev: 895d923 for Lua 5.1 from https://github.com/viruscamp/luadec
- -- Command line: 06_Unzse0.727.lua
- -- params : ...
- -- function num : 0
- HookFunc_AfterInst = function(addr, instr)
- -- function num : 0_0
- -- EffectSs_Spawn
- if addr == 0x800B054C and instr == 0xC040B22 then
- -- change a0 when calling ZeldaArena_MallocR to a large number so the malloc fails
- n64GPRWrite32(4, 0x800000)
- else if addr == 0x800B0554 and instr == 0x8FA30028 then
- -- read vramStart instead of loadedRamAddr when checking for early return
- -- change the malloc destination to vram instead of ram
- local v1 = n64GPRRead32(3)
- local vramStart = n64MemRead32(v1 + 8)
- n64GPRWrite32(2, vramStart)
- else
- do
- -- Actor_LoadOverlay, hook on load allocType
- if addr == 0x800BAD20 and instr == 0x9462001C then
- -- these first two lines are doing nothing as far as I can tell
- local v1 = n64GPRRead32(3)
- n64MemRead16(v1 + 0x1C, 2)
- -- make every actor load as ALLOCTYPE_PERMANENT
- n64GPRWrite32(v0, 2)
- else
- do
- -- ZeldaArena_MallocR call in the ALLOCTYPE_PERMANENT block
- -- change alloc size to be too large for it to work
- if addr == 0x800BAD7C and instr == 0xC040B22 then
- n64GPRWrite32(4, 0x800000)
- else
- -- change the malloc destination to vram instead of ram
- if addr == 0x800BAD84 and instr == 0x8FA30024 then
- local v1 = n64GPRRead32(3)
- local vramStart = n64MemRead32(v1 + 8)
- n64GPRWrite32(2, vramStart)
- else
- do
- -- anti-epilepsy freeze flash when killing enemies
- if addr == 0x80167AE0 and instr == 0x304B0001 then
- local l_1_7 = n64GPRRead32(2)
- local l_1_8 = (bit.band)(l_1_7, 3)
- n64GPRWrite32(11, l_1_8)
- else
- do
- -- equivalent of oot's `Environment_GetPixelDepth`
- -- could be motion blur related
- -- i dont know what n64WaitGTaskDone does
- if addr == 0x80178A54 and instr == 0x3C0F8020 then
- n64WaitGTaskDone()
- end
- return
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- BeforGTask = function()
- -- function num : 0_1
- n64ResetParameter("FramesPerGTask")
- -- check address of graphics context (??????????)
- -- this should always be the same
- -- guess they thought it was an identifier for the current gamestate
- if n64MemRead32(0x803E6B20) == 0x801F9CB8 then
- local frameRate = 0
- local gamestateMain = n64MemRead32(0x803E6B20 + 4)
- -- check if main is Play_Main
- if gamestateMain == 0x80168F64 then
- frameRate = 2
- local pauseState = n64MemRead16(0x803E6B20 + 0x16F1C)
- if pauseState ~= 0 then
- -- set 60 fps if pause/game over is not open (i think???)
- frameRate = 0
- end
- local csCtx = 0x803E6B20 + 0x1F24
- local sceneCsCount = n64MemRead32(csCtx)
- if sceneCsCount == 0x05(000000) then
- local csSegment = n64MemRead32(csCtx + 4)
- local numCommands = n64MemRead32(csSegment)
- local csLength = n64MemRead32(csSegment + 4)
- local cmd1 = n64MemRead32(csSegment + 8)
- local cmd1_data = n64MemRead32(csSegment + 12)
- -- checking for cutscene 0 in termina field: giants cutscene
- -- lag toward the end of the cutscene to sync with music
- if numCommands == 12 and csLength == 1626 and cmd1 == 90 and cmd1_data == 5684 then
- local frameNum = n64MemRead16(csCtx + 16)
- if frameNum >= 1120 and frameNum <= 1616 then
- frameRate = 3
- end
- end
- end
- end
- do
- do
- do
- n64SetParameter("FramesPerGTask", frameRate)
- -- this is combination of scene number and scene config
- -- scene 0x2D, scene config 1
- -- MrCheeze found this has to do with manipulating dlists in an object
- -- while in termina field during the telescope scene. Not gonna look into this much further
- if n64MemRead32(0x803E6BC4) == 0x002D0100 and n64MemRead16(0x803FE93C) == 402 then
- local l_2_13 = {}
- while 1 do
- if l_2_13 ~= nil then
- if l_2_13 ~= addr_hi_lo[i * 3 + 2] or l_2_13 ~= addr_hi_lo[i * 3 + 3] then
- break
- end
- end
- end
- while 1 do
- if l_2_13 == 1 and l_2_13 ~= nil then
- do
- l_2_13(addr_hi_lo[i * 3 + 1], 0xE0000000)
- l_2_13(addr_hi_lo[i * 3 + 1] + 8, 0xE0000000)
- end
- end
- end
- end
- -- WARNING: undefined locals caused missing assignments!
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement