Skip to content
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

Fix Flawed Segmented Addr Check #629

Closed
wants to merge 2 commits into from
Closed

Fix Flawed Segmented Addr Check #629

wants to merge 2 commits into from

Conversation

MegaMech
Copy link
Contributor

@MegaMech MegaMech commented Jun 2, 2024

Not sure if I missed some but essentially:

(0x05000800 & 1) != true

@Kenix3
Copy link
Owner

Kenix3 commented Jun 2, 2024

This change needs to be checked against other ports as it might break them.

To give some history:

On N64, you had addresses that were direct pointers to RAM and addresses that were to segments. There were 16 segments, and the first byte of a four byte address would determine the segment number (00-0F). So for example, a segment address could be `0x02000040`, referencing offset `0x40` on segment `2`. On N64 it is easy to distinguish between segment addresses and regular RAM-addresses because RAM is mapped to `0x80000000` which is too high for segments. But on PC the whole address space is used, so a new solution had to be figured out.

Random figured that no pointers in memory should have odd numbers, that everything was at least 2-byte aligned. So if something isn't, the assumption is that it's a segment pointer and not an address into RAM. I guess under certain conditions those path strings do end up being on odd addresses, hence the need for the alignment macro.

@MegaMech
Copy link
Contributor Author

MegaMech commented Jun 2, 2024

Don't merge this, it's not correct yet.

@MegaMech
Copy link
Contributor Author

MegaMech commented Jun 2, 2024

It appears the issue is that I need to flip the endiannes of my n64 ptr:
0x0000000000080005

@MegaMech
Copy link
Contributor Author

MegaMech commented Jun 2, 2024

Resolved this issue by parsing the data at runtime and converting n64 ptrs to x86.

@MegaMech MegaMech closed this Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants