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

DSPHLE: Add Desert Bus libasnd ucode variants #11354

Merged
merged 1 commit into from Dec 20, 2022

Conversation

Pokechu22
Copy link
Contributor

The Desert Bus homebrew uses custom libasnd DSP ucode. Specifically, v1.0.4 and v1.0.5 are modified versions of the ucode that was added to the libogc repo in devkitPro/libogc@b1b8eca (although the binary that was added in that commit does not match the code, and a matching binary only started being used in 2020 - see #10763 for my other notes). That libogc patch is attributed to the author of the homebrew, for what it's worth.

The difference between the libogc code and v1.0.4 is this, which swaps the left and right channels for stereo audio:
diff --git a/dsp_mixer.s b/dsp_mixer_desert_bus_v1.0.4.s
index 3b52614..9de5b84 100644
--- a/dsp_mixer.s
+++ b/dsp_mixer_v1.0.4.s
@@ -834,10 +834,10 @@ stereo_8bits:
        lrri $ACL0, @$AR2
        mrr  $ACM0, $ACL0
        andi $ACM0, #0xff00
-       mrr  $AXH1, $ACM0
+       mrr  $AXH0, $ACM0
        lsl  $ACC0, #8

-       mrr  $AXH0, $ACL0
+       mrr  $AXH1, $ACL0
        jmp     out_samp

 mono_16bits:
@@ -852,8 +852,8 @@ stereo_16bits:

 // 16 bits stereo

-       lrri $AXH1, @$AR2
        lrri $AXH0, @$AR2
+       lrri $AXH1, @$AR2
        jmp     out_samp

 mono_8bits_unsigned:
@@ -892,10 +892,10 @@ stereo_8bits_unsigned:
        xori $ACM0, #0x8080 // convert unsigned->signed
        mrr  $ACL0, $ACM0
        andi $ACM0, #0xff00
-       mrr  $AXH1, $ACM0
+       mrr  $AXH0, $ACM0
        lsl  $ACC0, #8

-       mrr  $AXH0, $ACL0
+       mrr  $AXH1, $ACL0
        jmp     out_samp

 stereo_16bits_le:
@@ -908,8 +908,8 @@ stereo_16bits_le:
        lsl  $ACC1, #8 // byteswap
        lsl  $ACC0, #8

-       mrr  $AXH1, $ACM1
-       mrr  $AXH0, $ACM0
+       mrr  $AXH0, $ACM1
+       mrr  $AXH1, $ACM0
        //jmp   out_samp

 out_samp:
The difference between v1.0.4 and v1.0.5 is this:
diff --git a/dsp_mixer_desert_bus_v1.0.4.s b/dsp_mixer_desert_bus_v1.0.5.s
index 9de5b84..9f5d428 100644
--- a/dsp_mixer_desert_bus_v1.0.4.s
+++ b/dsp_mixer_desert_bus_v1.0.5.s
@@ -190,6 +190,14 @@ MEM_SND:	equ	data_end ; it need 2048 words (4096 bytes)
 	jmp	exception6
 	jmp	exception7
 
+	; decodes as sbclr #0x04
+	; (note that sbclr has unused/ignored bits currently, and the canon version would be 1204)
+	cw 0x1234
+	; decodes as subr'l $ACC0, $AX1.H : $AC1.M, @$AR0
+	cw 0x5678
+	; decodes as bloopi #0x11, 0x2222
+	cw 0x1111
+	cw 0x2222
 	lri     $CONFIG, #0xff
 	lri	$SR,#0
 	s16         

v1.0.0 and v1.0.3 seem to be lost. They would have originally existed at https://wiibrew.org/wiki/Media:Desertbus.zip but this was not archived; both versions were uploaded to this location.

This change does not impact desert bus booting; see #11350 for that. I'm creating a separate PR so that it can be reviewed faster.

Copy link
Member

@lioncash lioncash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor nit, but looks good overall

Source/Core/Core/HW/DSPHLE/UCodes/ASnd.cpp Outdated Show resolved Hide resolved
@AdmiralCurtiss AdmiralCurtiss merged commit d853da3 into dolphin-emu:master Dec 20, 2022
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants