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

Incorrect memory readings on SEGA Genesis emulator #86

Open
Jujstme opened this issue Jan 11, 2024 · 0 comments · May be fixed by #89
Open

Incorrect memory readings on SEGA Genesis emulator #86

Jujstme opened this issue Jan 11, 2024 · 0 comments · May be fixed by #89

Comments

@Jujstme
Copy link
Contributor

Jujstme commented Jan 11, 2024

This issue specifically affects emulators using a byte-swapped memory layout.

For historical reasons, most of the current emulators for the SEGA Genesis swap odd and even bytes in the emulated memory, effectively swapping an internal big endian memory layout to a little endian one. The crate currently deals with this with an internal enum that reports whether the emulator is using an original, big endian, or a byte swapped layout.

This allows for easily reading single u8 and u16 values from memory, as well as [u16; N] arrays, but breaks completely when dealing with [u8; N] due to the fact no additional abstraction is performed other than checking the original memory address to start reading from.

The solution, which I plan on implementing eventually, is to swap odd and even bytes from the [u8; N] array after reading it and before returning it to the calling function. This would require a bit of unsafe but would be safely wrapped inside the read() function anyway.

Jujstme added a commit to Jujstme/asr that referenced this issue Jan 21, 2024
@Jujstme Jujstme linked a pull request Jan 22, 2024 that will close this issue
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 a pull request may close this issue.

1 participant