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

Add its own DMA remap implementation #14

Closed
VitorVilela7 opened this issue Jul 9, 2019 · 3 comments
Closed

Add its own DMA remap implementation #14

VitorVilela7 opened this issue Jul 9, 2019 · 3 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request technical debt
Milestone

Comments

@VitorVilela7
Copy link
Owner

SA-1 Pack uses SNES general-purpose DMA for graphics decompression at WRAM, but it may fail if an interrupt occur during the transfer, invalidating it if another transfer goes on top of it.

Since the newer LM versions, FuSoYa has set all DMA channels to 2. With that:

Channel 0 - Windowing HDMA
Channel 1 - Game-logic DMA
Channel 2 - V-blank DMA
Channel 3-7 - User HDMA

Add a DMA remap implementation that respects this and fix the bug referenced on TheLX5/Powerups#30

@VitorVilela7 VitorVilela7 added bug Something isn't working enhancement New feature or request technical debt labels Jul 9, 2019
VitorVilela7 added a commit that referenced this issue Sep 22, 2019
@VitorVilela7 VitorVilela7 self-assigned this Sep 22, 2019
@VitorVilela7
Copy link
Owner Author

Moving windowing HDMA to channel 0 may leave undefined behavior on upgraded ROMs because most of the third party patches uses channel 0 for DMA.

@VitorVilela7
Copy link
Owner Author

VitorVilela7 commented Sep 22, 2019

The problem on DMA remap was that wiiqwertyuiop either missed some LM hijacks or they were added after its release:

; more LM hijacks
org $0ffa4c
	sta $4312;     [004322] A:ad00 X:0006 Y:00ff S:1fee D:3000 DB:00 NvmXdizc V:184 H:128 F: 8
org $0ffa52
	sta $4315;     [004325] A:0800 X:0006 Y:00ff S:1fee D:3000 DB:00 nvmXdizc V:184 H:153 F: 8
org $0ffa5d
	sta $4310;     [004320] A:1801 X:0080 Y:00ff S:1fee D:3000 DB:00 nvmXdizc V:184 H:179 F: 8
org $0ffa62
	stx $4314;     [004324] A:1801 X:007e Y:00ff S:1fee D:3000 DB:00 nvmXdizc V:184 H:192 F: 8
org $0ffa65
	ldx #$02;               A:1801 X:007e Y:00ff S:1fee D:3000 DB:00 nvmXdizc V:184 H:200 F: 8
	
org $0ffe7b
	sta $4315;     [004325] A:0800 X:5000 Y:ad00 S:1ff1 D:3000 DB:00 nvmxdizc V:  4 H:294 F:57
org $0ffe84
	sta $4310;     [004320] A:1801 X:5000 Y:ad00 S:1ff1 D:3000 DB:00 nvmxdizc V:  4 H:318 F:57
org $0ffe87
	sty $4312;     [004322] A:1801 X:5000 Y:ad00 S:1ff1 D:3000 DB:00 nvmxdizc V:  4 H:327 F:57
org $0ffe8e
	sta $4314;     [004324] A:187e X:5000 Y:ad00 S:1ff1 D:3000 DB:00 nvMxdizc V:  5 H:  5 F:57
org $0ffe96
	lda #$02;               A:1880 X:5000 Y:ad00 S:1ff1 D:3000 DB:00 NvMxdizc V:  5 H: 24 F:57

org $0ffe2d sta $4315 ;change ch 2 -> 1
With Lunar Magic using channel 2 for everything, DMA remap will be included on SA-1 Pack using channel 2 for NMI, channel 1 for game logic and channel 0 for windowing HDMA. Channels 3 to 7 will be free to be used for anyone, with the exception of the game credits.

@VitorVilela7
Copy link
Owner Author

Final DMA remap configuration:
Channel 0 - DMA outside interrupts
Channel 1 - SMW Windowing HDMA
Channel 2 - DMA inside interrupts
Channel 3 to 7 - free HDMA channels

Moved Window HDMA from channel 0 to 1 for better compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request technical debt
Projects
None yet
Development

No branches or pull requests

1 participant