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 DMA won't transfer to bank 0x41 #309

Closed
Fernap opened this issue Jan 13, 2024 · 5 comments
Closed

SA-1 DMA won't transfer to bank 0x41 #309

Fernap opened this issue Jan 13, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@Fernap
Copy link
Contributor

Fernap commented Jan 13, 2024

Any attempts to use SA-1 side DMA to BWRAM with a destination in bank 0x41 will result in a transfer to the corresponding address at bank 0x40 instead. Changing line 6 in bsnes/sfc/coprocessor/sa1/dma.cpp from a uint16 to a uint24 should fix the problem (the SNES dev manual indicates 18 bits are actually used). This bug was apparently introduced here.

Credit to @VitorVilela7 and @TheLX5 for originally diagnosing the problem, and Vitor for tracking down when the regression was introduced.

@orbea
Copy link
Contributor

orbea commented Jan 13, 2024

Do you happen to have a test case?

@Fernap
Copy link
Contributor Author

Fernap commented Jan 13, 2024

Ultimately, finding this came from some custom code for handling dynamic sprites used in Vitor's SA-1 enhancement patch for SMW. You can see an example of the code used here, among a few other spots; !DSX_BUFFER is a define set to $418000. However, the actual DMA transfers to $408000 instead.

Is that sufficient, or were you looking more for a test ROM of some sort?

@Screwtapello Screwtapello added the bug Something isn't working label Jan 14, 2024
@carmiker
Copy link
Contributor

A test ROM would always be helpful. The only reference I see to anything 18-bit in the manual is related to the Timer Circuit, in Book 2, Page 1-2-2. On the other hand I do see that DDA is a 24-bit register on Page 1-4-22. So I believe using a uint24 here is indeed correct.

@Fernap
Copy link
Contributor Author

Fernap commented Jan 14, 2024

Sorry, the 18 bit size I was getting was from table 1-9-2 on page 1-9-3. Presumably it says 18 bits because that's the maximum possible size of BW-RAM, even if DDA is 24 bits.

@VitorVilela7
Copy link

VitorVilela7 commented Jan 14, 2024 via email

LukeUsher pushed a commit to ares-emulator/ares that referenced this issue Nov 2, 2024
DDA was incorrectly capped at 16 bits instead of 24, making DMAs to
BWRAM banks 0x41-43 be sent to the corresponding spot in 0x40 instead.
See [the corresponding bug in
bsnes](bsnes-emu/bsnes#309) for some more
context.
@Fernap Fernap closed this as completed Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants