Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function GameBegin()
- --this memory is write by a unknown rsp task in trueboot, the task set some memory value
- --without this, fishing in the game will very difficult
- n64MemWrite32(0x802fb1f4, 0xad090010);
- n64MemWrite32(0x802fe1c0, 0xad170014);
- return
- end
- function FrameBegin()
- --menu speed up
- n64MemWrite8(0x801DAE8B, 0x02)
- n64DarkSwitchOff()
- return
- end
- function BeforeVIFrameEnd()
- local addr_game = 0x801c8d60;
- local addr_demo_play = 0x801caac4;
- local addr_game_info_mode = 0x8011BFDC;
- local gameinfo_mode = n64MemRead32(addr_game_info_mode);
- local func_exec = n64MemRead32(addr_game + 4);
- --NN_LOG(string.format("BeforGTask %d 0x%x\n", gameinfo_mode, func_exec));
- n64ResetParameter("VISync");
- if (gameinfo_mode == 0 --0 normal game
- and func_exec == 0x8009d1b8 --this is gameplay
- ) then
- n64SetParameter("VISync", 1);
- end
- return
- end
- function BeforGTask()
- --NN_LOG("before g Task\n");
- --in ending_demo scene switch will have gtask per frame begin first 2frames
- --this will cause lag
- --set 3frames per g task will avoid that
- n64ResetParameter("FramesPerGTask");
- local addr_game = 0x801c8d60;
- local addr_demo_play = 0x801caac4;
- local addr_game_info_mode = 0x8011BFDC;
- local gameinfo_mode = n64MemRead32(addr_game_info_mode);
- local func_exec = n64MemRead32(addr_game + 4);
- --NN_LOG(string.format("BeforGTask %d 0x%x\n", gameinfo_mode, func_exec));
- if (gameinfo_mode == 3 --3 is ending staff
- and func_exec == 0x8009d1b8 --this is gameplay
- ) then
- --NN_LOG("this is ending staff\n");
- local demoplay_framecnt = n64MemRead16(addr_demo_play + 0x10);
- local addr_demo_data = n64MemRead32(addr_demo_play + 0x4);
- local addr_xx = addr_demo_data + 8;
- while(true) do
- local flag = n64MemRead32(addr_xx);
- --NN_LOG(string.format("flag is 0x%x\n", flag));
- if(flag == 0x000003e8) then
- break;
- elseif(flag == 0x00000001 or flag == 0x00000002) then
- addr_xx = addr_xx + 0xC;
- while(true) do
- local test_value = n64MemRead8(addr_xx);
- addr_xx = addr_xx + 0x10;
- if(test_value == 0xFF) then
- break;
- end
- end
- elseif(flag == 0x0000002D) then
- addr_xx = addr_xx + 0x10;
- elseif(flag >= 0x00000004 and flag <= 0x000003E7) then
- local num = n64MemRead32(addr_xx + 4);
- addr_xx = addr_xx + 0x8 + num *0x30;
- else
- --NN_LOG(string.format("flag is 0x%x\n", flag));
- break;
- end
- end
- addr_xx = addr_xx + 0x8;
- local some_no = n64MemRead16(addr_xx);
- local maxframe = n64MemRead16(addr_xx + 2);
- --NN_LOG(string.format("gameinfomode 0x%x func_exec 0x%x\n", gameinfo_mode, func_exec));
- --NN_LOG(string.format("staff 0x%x 0x%x 0x%x\n", some_no, maxframe, demoplay_framecnt));
- local framepertask = 2;
- if(some_no == 0x37) then
- if(maxframe == 0xC3) then
- n64MemWrite16(addr_xx+2, 0xC3 + 0x6);
- end
- elseif(some_no == 0x38) then
- if(maxframe == 0xDC) then
- n64MemWrite16(addr_xx+2, 0xDC + 0x7);
- end
- elseif(some_no == 0x39) then
- if(maxframe == 0xF0) then
- n64MemWrite16(addr_xx+2, 0xF0 + 0x7);
- end
- elseif(some_no == 0x3A) then
- if(maxframe == 0x118) then
- n64MemWrite16(addr_xx+2, 0x118 + 0x8);
- end
- elseif(some_no == 0x3B) then
- if(maxframe == 0x118) then
- n64MemWrite16(addr_xx+2, 0x118 + 0x8);
- end
- elseif(some_no == 0x3D) then
- if(maxframe == 0x140) then
- n64MemWrite16(addr_xx+2, 0x140 + 0x8);
- end
- elseif(some_no == 0x3F) then
- if(maxframe == 0x104) then
- n64MemWrite16(addr_xx+2, 0x104 + 0x8);
- end
- elseif(some_no == 0x40) then
- if(maxframe == 0xDC) then
- n64MemWrite16(addr_xx+2, 0xDC + 0x8);
- end
- elseif(some_no == 0x4a) then
- if(maxframe == 0xFF) then
- n64MemWrite16(addr_xx+2, 0xFF + 0x8);
- end
- elseif(some_no == 0x4b) then
- if(demoplay_framecnt < 0x18) then
- framepertask = 3;
- else
- framepertask = 4;
- end
- if(maxframe == 0x98) then
- n64MemWrite16(addr_xx+2, 0x98 + 0x9);
- end
- elseif(some_no == 0x4C) then
- if(demoplay_framecnt < 0xA) then
- framepertask = 5;
- elseif(demoplay_framecnt < 0x1F) then
- framepertask = 4;
- elseif(demoplay_framecnt < 0x7A) then
- framepertask = 3;
- elseif(demoplay_framecnt < 0xE0) then
- local b = bit.band(demoplay_framecnt, 0x1)
- if(b == 0) then
- framepertask = 3;
- else
- framepertask = 2;
- end
- else
- local b = bit.band(demoplay_framecnt, 0x1)
- if(b == 0) then
- framepertask = 3;
- else
- framepertask = 2;
- end
- end
- elseif(some_no == 0x4E) then
- local b = math.modf(demoplay_framecnt, 5);
- if(b < 3) then
- framepertask = 3;
- else
- framepertask = 2;
- end
- if(maxframe == 0x9D) then
- n64MemWrite16(addr_xx+2, 0x9D + 0x10);
- end
- elseif(some_no == 0x4D) then
- if(demoplay_framecnt < 0xB0) then
- framepertask = 2;
- else
- framepertask = 3;
- end
- if(maxframe == 0x127) then
- n64MemWrite16(addr_xx+2, 0x127 + 0x8);
- end
- elseif(some_no == 0x46) then
- if(maxframe == 0x237) then
- n64MemWrite16(addr_xx+2, 0x237 + 0x10);
- end
- end
- n64SetParameter("FramesPerGTask", framepertask);
- end
- return
- end
- function HookFunc_AfterInst(pc, inst)
- if(pc == 0x8009bbb0 and inst ==0x8fa40040) then
- if( n64GPRRead32(9) == 0x2873e0) then
- ------nPc=0x8009bbb0 , nInst=0x8fa40040
- --NN_LOG("m34 ride in fire-------------------------\n")
- --n64DarkSwitchOn(116,800)
- end
- end
- if(pc == 0x801ea304 and inst ==0x8fbf0014) then
- ------- nPc=0x801ea304 , nInst=0x8fbf0014
- --NN_LOG("m39 white flashs while attacking---------------\n")
- --n64DarkSwitchOn(86,50)
- end
- if(pc == 0x8004fa0c and inst ==0x8caf0018) then
- ----nPc=0x8004fa0c , nInst=0x8caf0018
- --NN_LOG("m40 white flashs while attacking---------------\n")
- --n64DarkSwitchOn(87,40)
- end
- if(pc == 0x8009c3b0 and inst ==0x3c010001) then
- --NN_LOG("m57 m56 white flashs---------------\n")
- --n64DarkSwitchOn(21,8)
- end
- if(pc == 0x802126e0 and inst ==0xafa40000) then
- --NN_LOG("m53 bomb---------------\n")
- --n64DarkSwitchOn(21,80)
- end
- if(pc == 0x8009c3a4 and inst == 0x304f0001) then
- ---000a0142h: 1C 24 31 C2 00 FF 18 40 00 0D 30 4F 00 01 the last instruct is ANDI 0x01.
- NN_LOG("m39 white flashs while attacking----------the last instruct is ANDI 0x01. -----\n")
- local t2 = n64GPRRead32(2)
- local t15 = bit.band(t2, 0x03)
- n64GPRWrite32(15, t15)
- end
- --dynamic code hack
- if(pc == 0x8001BB20 and inst ==0x0C019CBE) then
- --NN_LOG("effect malloc\n")
- --set big memory size to let malloc fail
- n64GPRWrite32(0x04, 0x800000)
- elseif(pc == 0x8001BB28 and inst ==0x8FA30028) then
- --NN_LOG("after effect malloc\n")
- --set a malloc return value to segment start
- local v1 = n64GPRRead32(0x03)
- local addr = n64MemRead32(v1 + 8)
- n64GPRWrite32(0x2, addr)
- elseif(pc == 0x800257C4 and inst ==0x9602001C) then
- --NN_LOG("actor load flags\n")
- --set all actor flag to 2(not free after dead)
- n64GPRWrite32(0x02, 0x2)
- end
- return
- end
- function HookFunc_BeforeInst(pc, inst)
- if(pc == 0x8002580C and inst ==0x0C019CBE) then
- --NN_LOG("actor malloc\n")
- --set big memory size to let malloc fail
- n64GPRWrite32(0x07, 0x800000)
- elseif(pc == 0x80025814 and inst ==0x10000004) then
- --NN_LOG("after actor malloc\n")
- --set a malloc return value to segment start
- local s0 = n64GPRRead32(0x10)
- local addr = n64MemRead32(s0 + 8)
- n64GPRWrite32(0x2, addr)
- end
- return
- end
- function RomPatch()
- --BTS MCat bug No.221
- n64RomWrite8(0x175c39b, 0x3e)
- return
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement