-
Notifications
You must be signed in to change notification settings - Fork 71
Perfect Dark does not detect expansion pak #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I started digging into what different games use for expansion pak detection. This problem seems unique to PD. It might be a difference of reading global At least a dozen other titles successfully detect the presence of an expansion pak under cen64 (build 30ce1c9) |
I have identified the root cause of PD thinking the expansions pak isn't present, but am currently unsure how to fix it. The issue seems to be that IPL3 thinks the cold reset is an NMI and the game's code takes a different logic path based on this. There is some code early on in the game around 0x700016C8 (TLB mapped, unsure where this is in physical RAM or ROM) that looks like: if (reset_type == NMI) { // *0x80000308 == 1
mem_size = saved_mem_size; // *0x8008dcb4 = *0x803f50b8;
} else { // cold reset
mem_size = ipl3_mem_size; // *0x8008dcb4 = *0x80000318;
} Unfortunately, under cen64, reset_type is identified by IPL3 as NMI during a cold reset, so the game tries to use its saved value of mem_size from 803f50b8, which is 0. It compares this mem_size 0x400001: if less than sets a "is_4mb" byte flag at 0x80090af0 = 1, else sets 0. I've checked other games under cen64 and the word at 0x80000308 always appears to be 1 (reset_type = NMI) at the game entry point. |
Interesting. I am not sure why this would be. I verified that Status.SR = 0 at CPU boot. |
I asked for clarification over on #n64dev and got a lot of good information. Long description below, but the problem is that the word in PIF RAM offset 0x24 contains status bits in addition to the CIC seed values. Specifically, bit 17 is the reset type (1 = NMI, 0 = cold reset).
Therefore, I think the CIC seeds in si/cic.c should be updated as below and if NMI needs to be generated, 0x00020000 should be set. I've only tested this with Perfect Dark so far. #define CIC_SEED_NUS_5101 0x0000AC00U
#define CIC_SEED_NUS_6101 0x00043F3FU
#define CIC_SEED_NUS_6102 0x00003F3FU
#define CIC_SEED_NUS_6103 0x0000783FU
#define CIC_SEED_NUS_6105 0x0000913FU
#define CIC_SEED_NUS_6106 0x0000853FU
#define CIC_SEED_NUS_8303 0x0000DD00U For completeness, here is a summary of the N64 boot.
Thanks to _Happy_, marshallh, Zoinkity for explaining this info. |
Looks good, and thanks for the info. Free free to make a PR... you've done all the hard work! |
Some CIC seed values had bit 0x20000 set which is the reset type indicated from PIF (1 = NMI, 0 = Cold Reset). Some games follow different initialization paths for NMIs which can cause some unexpected boot behavior during a cold reset. Fixes n64dev#58 Expansion Pak detection in Perfect Dark
Using NTSC USA 8.7 final ROM. Perfect Dark does not detect the expansion pak, and thus the single-player campaign is missing.
This is a known bug.
The text was updated successfully, but these errors were encountered: