Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/vc.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ typedef struct Ram {
#endif
} Ram; // size = 0x48

#define SYSTEM_CPU(pSystem) ((void*)(((System*)(pSystem))->apObject[SOT_CPU]))
#define SYSTEM_CPU(pSystem) ((Cpu*)(((System*)(pSystem))->apObject[SOT_CPU]))
#define SYSTEM_ROM(pSystem) ((Rom*)(((System*)(pSystem))->apObject[SOT_ROM]))

// xlObject.h
Expand Down Expand Up @@ -228,7 +228,7 @@ int iosCreateHeap(void* heap, size_t size);
void* iosAllocAligned(int hid, size_t size, size_t page_size);
bool iosFree(int hid, void* ptr);

extern u32 reset_flag; // TODO: use decomp name
extern bool sResetBtnPressed;

#define title_id (*(volatile u32*)0x80003180)

Expand Down
2 changes: 2 additions & 0 deletions lib/hb-D43E.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ OSGetTick = 0x800A1D80;
ganMapGPR = 0x800EC858;
gpSystem = 0x80135DE0;
gnFlagZelda = 0x80135EB8;
cpuExecuteJump_hook_addr_ha = 0x80036914;
cpuExecuteJump_hook_addr_l = 0x80036918;
2 changes: 2 additions & 0 deletions lib/hb-D43J.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ OSGetTick = 0x800A14F8;
ganMapGPR = 0x800ED338;
gpSystem = 0x8018B894;
gnFlagZelda = 0x8018B968;
cpuExecuteJump_hook_addr_ha = 0x80036170;
cpuExecuteJump_hook_addr_l = 0x80036174;
2 changes: 1 addition & 1 deletion lib/hb-NACE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ iosAllocAligned = 0x800B9B50;
iosFree = 0x800B9B54;
ganMapGPR = 0x80170B68;
gpSystem = 0x8025D0E0;
reset_flag = 0x8025D1EC;
sResetBtnPressed = 0x8025D1EC;
2 changes: 1 addition & 1 deletion lib/hb-NACJ.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ iosAllocAligned = 0x800B9B44;
iosFree = 0x800B9B48;
ganMapGPR = 0x80170B68;
gpSystem = 0x8025CFE0;
reset_flag = 0x8025D0EC;
sResetBtnPressed = 0x8025D0EC;
2 changes: 1 addition & 1 deletion lib/hb-NARE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ iosAllocAligned = 0x800C62F8;
iosFree = 0x800C62FC;
ganMapGPR = 0x8014CEB0;
gpSystem = 0x801FB838;
reset_flag = 0x801FBA28;
sResetBtnPressed = 0x801FBA28;
2 changes: 1 addition & 1 deletion lib/hb-NARJ.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ iosAllocAligned = 0x800C693C;
iosFree = 0x800C6940;
ganMapGPR = 0x8014F3F0;
gpSystem = 0x80200638;
reset_flag = 0x80200830;
sResetBtnPressed = 0x80200830;
2 changes: 2 additions & 0 deletions lib/hb-PZLE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ OSGetTick = 0x800A233C;
ganMapGPR = 0x800EE378;
gpSystem = 0x80137B00;
gnFlagZelda = 0x80137BD8;
cpuExecuteJump_hook_addr_ha = 0x80036940;
cpuExecuteJump_hook_addr_l = 0x80036944;
2 changes: 2 additions & 0 deletions lib/hb-PZLJ.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ OSGetTick = 0x800A22C0;
ganMapGPR = 0x800EBE70;
gpSystem = 0x80135600;
gnFlagZelda = 0x801356D8;
cpuExecuteJump_hook_addr_ha = 0x800368C4;
cpuExecuteJump_hook_addr_l = 0x800368C8;
4 changes: 3 additions & 1 deletion src/homeboy.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ static void do_status_update() {
fs_close(fd);
}

reset_flag = 1;
// see
// https://github.com/zeldaret/oot-vc/blob/6fee0769e9e2f0ba7ad20c2b36c5c6063f24a8bd/src/emulator/helpRVL.c#L1170
sResetBtnPressed = 1;
}
#endif

Expand Down
30 changes: 30 additions & 0 deletions src/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ extern u8 romSetCacheSize_hook_addr[];
extern u8 romLoadRange_hook_addr_1[];
extern u8 romLoadRange_hook_addr_2[];
extern u8 mcardWrite_hook_addr[];
extern u8 cpuExecuteJump_hook_addr_ha[];
extern u8 cpuExecuteJump_hook_addr_l[];
#endif

// Change an instruction in memory.
Expand Down Expand Up @@ -197,6 +199,30 @@ bool mcardWrite_hook(MemCard* pMCard, s32 address, s32 size, char* data) {
return mcardWrite(pMCard, address, size, data);
}

s32 cpuExecuteJump_hook(Cpu* pCPU, s32 nCount, s32 nAddressN64, s32 nAddressGCN) {
nCount = OSGetTick();

if (pCPU->nWaitPC != 0) {
pCPU->nMode |= 8;
} else {
pCPU->nMode &= ~8;
}

if (gpSystem->eTypeROM == 4 /* SRT_ZELDA1 */ && nAddressN64 == 0x81000000) {
// do nothing instead of trying to play the movie
} else {
pCPU->nMode |= 4;
pCPU->nPC = nAddressN64;

if (!cpuExecuteUpdate(pCPU, &nAddressGCN, nCount)) {
return 0;
}
}

pCPU->nTickLast = OSGetTick();
return nAddressGCN;
}

#endif

void init_hooks(void) {
Expand Down Expand Up @@ -224,5 +250,9 @@ void init_hooks(void) {

// Hook to mcardWrite to fix gz settings not saving
patch_bl(mcardWrite_hook_addr, mcardWrite_hook);

// Hook to cpuExecuteJump to avoid playing the non-existent credits movie
patch_ha(cpuExecuteJump_hook_addr_ha, cpuExecuteJump_hook);
patch_l(cpuExecuteJump_hook_addr_l, cpuExecuteJump_hook);
#endif
}
Loading