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

SA-1 RAM write protection (Contra SA-1) #351

Open
paulb-nl opened this issue Nov 6, 2022 · 2 comments
Open

SA-1 RAM write protection (Contra SA-1) #351

paulb-nl opened this issue Nov 6, 2022 · 2 comments

Comments

@paulb-nl
Copy link
Contributor

paulb-nl commented Nov 6, 2022

Contra III SA-1 v1.1 does not boot on a real SA-1 cart because RAM write protection is enabled by default. This version does work on the SNES core but IMO it should behave like a real cart.

Contra III SA-1 v1.2 fixes this by disabling write protection:
https://github.com/VitorVilela7/SA1-Root/releases/tag/v1.8
VitorVilela7/SA1-Root@8ec85aa
VitorVilela7/SA1-Root@b67c8cc

This version fixes an issue regarding on how I-RAM (SA-1 internal RAM) is set up on boot code. At boot time, the I-RAM write stays disabled and you must enable it before making writes. However, my boot time attempts setting up the data bank register (DBR) that requires a stack operation (PHA - PLB) and the PHA opcode requires writing to I-RAM. Because write is disabled, the write is ignored and the DBR receives an undefined value instead (likely static randomic), which made some games not boot up at all. Contra III in particular never booted up on hardware because it requires the DBR to be 0x05 since the beginning, while Gradius III and Super R-Type had mixed results on hardware.

Now that the root cause has been found and fixed, Contra III, Gradius III and Super R-Type should work as expected on real hardware.

The SA-1 documentation in book2.pdf states that all RAM write protection is enabled by default: SBWE, CBWE, BWPA, SIWP & CIWP.

@paulb-nl
Copy link
Contributor Author

paulb-nl commented Oct 8, 2024

@srg320 Thanks for working on this!

Here is more information about BW-RAM protection and Kirby Dreamland:
ares-emulator/ares@70f3610

Apparently both SNES and SA-1 write enable registers need to be 0 for BW-RAM protection to work. So because it sets SWEN to 1 both SNES CPU and SA-1 can write to BW-RAM.

Protection Test ROM:
https://github.com/absindx/SNES-TestRoms/tree/main/SA1RamProtectionTest

@srg320
Copy link
Collaborator

srg320 commented Oct 8, 2024

Here is more information about BW-RAM protection and Kirby Dreamland: ares-emulator/ares@70f3610

Apparently both SNES and SA-1 write enable registers need to be 0 for BW-RAM protection to work. So because it sets SWEN to 1 both SNES CPU and SA-1 can write to BW-RAM.

Protection Test ROM: https://github.com/absindx/SNES-TestRoms/tree/main/SA1RamProtectionTest

Thank you, this information is very helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants