• Welcome to Smashboards, the world's largest Super Smash Brothers community! Over 250,000 Smash Bros. fans from around the world have come to discuss these great games in over 19 million posts!

    You are currently viewing our boards as a visitor. Click here to sign up right now and start on your path in the Smash community!

Completed Music Plays at 20% Volume When All Controllers Are Idle For 1 Minute

UnclePunch

Smash Ace
Joined
Nov 9, 2014
Messages
673

Code:
$Music Plays at 20% Volume When All Controllers Are Idle For 1 Minute [UnclePunch]
C237793C 00000018
7DC802A6 480000A5
7E0802A6 7DC803A6
1E380002 7C600279
40820020 89F00008
2C0F0001 41820094
7DD1822E 39CE0001
7DD1832E 48000038
39C00000 91D00000
91D00004 89D00008
2C0E0001 4082006C
3DC0804D 61CE3884
A1F0000A B1EE0002
39E00000 99F00008
48000050 7DD1822E
2C0E0E10 41800044
89F00008 2C0F0001
41820038 3DC0804D
61CE3884 A1EE0002
B1F0000A 39E00019
B1EE0002 39E00001
99F00008 48000014
4E800021 00000000
00000000 00000000
7C600279 00000000
Code:
inject @ 8037793c (HSD_PadRenewMasterStatus)

.macro load reg, address
lis \reg, \address @h
ori \reg, \reg, \address @l
.endm

getAddress:
mflr r14
bl variables
mflr r16
mtlr r14
mulli r17,r24,0x2

xor.    r0, r3, r0        #original codeline, determine if new button was pressed
bne pressedButton

noUniquePressThatFrame:
incrementTimer:
lbz r15,0x8(r16)            #get music lowered bool
cmpwi r15,0x1            #if music is lowered, do not increment frame counts
beq exit

lhzx r14,r17,r16            #get players frame count half
addi r14,r14,0x1            #increment by 1
sthx r14,r17,r16            #store back to variable
b compareTime

pressedButton:
li r14,0x0
stw r14,0x0(r16)            #zero out all input counters
stw r14,0x4(r16)            #zero out all input counters

lbz r14,0x8(r16)            #get music lowered bool
cmpwi r14,0x1            #if music is playing, do not resume music
bne exit

resumeMusic:
load r14,0x804d3884            #get master volume address
lhz r15,0xA(r16)            #get master volume value when music was lowered
sth r15,0x2(r14)            #store value
li r15,0x0
stb r15,0x8(r16)            #set music lowered bool as 0

b exit

compareTime:
lhzx r14,r17,r16            #get player's frame count
cmpwi r14,0xE10            #exit if 1 minute has not gone by
blt exit

lowerMusic:
lbz r15,0x8(r16)            #check if music is lowered
cmpwi r15,0x1            #exit if it has
beq exit

load r14,0x804d3884            #get master volume address
lhz r15,0x2(r14)            #get master volume value
sth r15,0xA(r16)            #store prev volume
li r15,0x19            #load 20% value
sth r15,0x2(r14)            #lower volume
li r15,0x1            #1 = music is lowered
stb r15,0x8(r16)            #set music lowered bool to 1
b exit

#####################
variables:
blrl

#0x0 = framesSinceP1Input
#0x2 = framesSinceP2Input
.long 0x00000000

#0x0 = framesSinceP3Input
#0x2 = framesSinceP4Input
.long 0x00000000

#0x0 = isMusicMuted
#0x2 = valueBeforeLowered
.long 0x00000000

######################



exit:
xor.    r0, r3, r0

Thanks @Gehis514 for the suggestion! This was much needed.
 
Last edited:

DRGN

Technowizard
Moderator
Joined
Aug 20, 2005
Messages
2,178
Location
Sacramento, CA
Punkline Punkline noticed that when you have your music off or very low, this code will actually turn it back on or may make it louder, since it's a hardcoded reduction value. He suggested instead right shifting the current value to divide it by 4, which solves this nicely.

I'm updating this code for 20XX and thought I'd share it here as well:

Music Volume Reduction on Idle (v1.1)
Music Plays at 25% Volume When All Controllers Are Idle For 1 Minute
<https://smashboards.com/threads/mus...all-controllers-are-idle-for-1-minute.450078/>
[UnclePunch, Punkline]
Revision ---- DOL Offset ---- Hex to Replace ---------- ASM Code -
NTSC 1.02 ---- 0x37451C ----- 7C600279 -> Branch

7DC802A6 480000A5
7E0802A6 7DC803A6
1E380002 7C600279
40820020 89F00008
2C0F0001 41820094
7DD1822E 39CE0001
7DD1832E 48000038
39C00000 91D00000
91D00004 89D00008
2C0E0001 4082006C
3DC0804D 61CE3884
A1F0000A B1EE0002
39E00000 99F00008
48000050 7DD1822E
2C0E0E10 41800044
89F00008 2C0F0001
41820038 3DC0804D
61CE3884 A1EE0002
B1F0000A 55EFF0BE
B1EE0002 39E00001
99F00008 48000014
4E800021 00000000
00000000 00000000
7C600279 48000000
$Music Plays at 25% Volume When All Controllers Are Idle For 1 Minute [UnclePunch, Punkline]
C237793C 00000018
7DC802A6 480000A5
7E0802A6 7DC803A6
1E380002 7C600279
40820020 89F00008
2C0F0001 41820094
7DD1822E 39CE0001
7DD1832E 48000038
39C00000 91D00000
91D00004 89D00008
2C0E0001 4082006C
3DC0804D 61CE3884
A1F0000A B1EE0002
39E00000 99F00008
48000050 7DD1822E
2C0E0E10 41800044
89F00008 2C0F0001
41820038 3DC0804D
61CE3884 A1EE0002
B1F0000A 55EFF0BE
B1EE0002 39E00001
99F00008 48000014
4E800021 00000000
00000000 00000000
7C600279 00000000
# inject @ 8037793c (HSD_PadRenewMasterStatus)
# v1.1 - volume reduction now based on current volume

.macro load reg, address
lis \reg, \address @h
ori \reg, \reg, \address @l
.endm

getAddress:
mflr r14
bl variables
mflr r16
mtlr r14
mulli r17,r24,0x2

xor. r0, r3, r0 #original codeline, determine if new button was pressed
bne pressedButton

noUniquePressThatFrame:
incrementTimer:
lbz r15,0x8(r16) #get music lowered bool
cmpwi r15,0x1 #if music is lowered, do not increment frame counts
beq exit

lhzx r14,r17,r16 #get players frame count half
addi r14,r14,0x1 #increment by 1
sthx r14,r17,r16 #store back to variable
b compareTime

pressedButton:
li r14,0x0
stw r14,0x0(r16) #zero out all input counters
stw r14,0x4(r16) #zero out all input counters

lbz r14,0x8(r16) #get music lowered bool
cmpwi r14,0x1 #if music is playing, do not resume music
bne exit

resumeMusic:
load r14,0x804d3884 #get master volume address
lhz r15,0xA(r16) #get master volume value when music was lowered
sth r15,0x2(r14) #store value
li r15,0x0
stb r15,0x8(r16) #set music lowered bool as 0

b exit

compareTime:
lhzx r14,r17,r16 #get player's frame count
cmpwi r14,0xE10 #exit if 1 minute has not gone by
blt exit

lowerMusic:
lbz r15,0x8(r16) #check if music is lowered
cmpwi r15,0x1 #exit if it has
beq exit

load r14,0x804d3884 #get master volume address
lhz r15,0x2(r14) #get master volume value
sth r15,0xA(r16) #store prev volume
#li r15,0x19 #load 20% value (v1.0 line)
srwi r15, r15, 2 # right shift to quarter volume level (v1.1 line)
sth r15,0x2(r14) #lower volume
li r15,0x1 #1 = music is lowered
stb r15,0x8(r16) #set music lowered bool to 1
b exit


#####################
variables:
blrl

#0x0 = framesSinceP1Input
#0x2 = framesSinceP2Input
.long 0x00000000

#0x0 = framesSinceP3Input
#0x2 = framesSinceP4Input
.long 0x00000000

#0x0 = isMusicMuted
#0x2 = valueBeforeLowered
.long 0x00000000

######################


exit:
xor. r0, r3, r0
b 0
 
Top Bottom