Completed Sound Test Displays IDs

Punkline

Dr. Frankenstack
Premium
Joined
May 15, 2015
Messages
355
#1
This code overwrites the menu text at the bottom of the screen in the default Sound Test menu in order to display the IDs of each sampled sound clip or music track. These IDs may be used to create arguments in codes that play sound/music, or moveset SFX in Crazy Hand subaction events.


To install the DOL Mod, use the latest version of Melee Code Manager.

Sound Test Displays IDs 1.1:

Update 1.1: 6/1/2019 -- code now includes a small overwrite that forces sound test to become unlocked as soon as the data option is selected.

Code:
-==-

Sound Test Displays IDs - 1.1
Display SFX and BGM IDs from the Sound Test menu.
[Punkline]
1.02 ------ 8022ae68 --- 4bf340292c030000
->
4bf340394c421182
1.02 ------ 8024b4d8 --- 7c7c002e -> Branch
7C7C002E
lis r0, <<Sound_Test_Text_Overhaul>>@h
ori r12, r0, <<Sound_Test_Text_Overhaul>>@l
906C0004 00000000
1.02 ------ 8024b7d0 --- bb21008c -> Branch
bl <Sound_Test_Text_Overhaul>
BB21008C 00000000
1.02 ------ 8024b0b0 --- 7f83e378 -> Branch
lis r0, <<Sound_Test_Text_Overhaul>>@h
ori r12, r0, <<Sound_Test_Text_Overhaul>>@l
7F83E378 906C0008 00000000
1.02 ------ 8024b294 --- 806db5a0 -> Branch
bl <Sound_Test_Text_Overhaul>
806DB5A0 00000000
<Sound_Test_Text_Overhaul> All
4800000C FFFFFFFF FFFFFFFF 806DC188 8063001C 8063002C
lis r0, <<Sound_Test_Text_Overhaul>>@h
ori r4, r0, <<Sound_Test_Text_Overhaul>>@l
2C030000 408000B4 80A30010 88630000 2E830000 380400E8 80C5005C 9005005C 7C003000 41A20010 3800FFFF 90040004 90040008 4FFFF982 38C40116 81040004 80E400DC 5508203E 40B60008 80E400E0 7D080120 40A0000C 39000000 80E400E4 39800000 2C8C001C 41850038 5D0B673F 398C0004 4FC22202 38002000 41BE001C 2C070000 41A20010 90E60002 38C60004 38E00000 5160063E B4060002 4BFFFFC8 419F0018 4FFFF842 4ED6B042 38C40152 81040008 4BFFFF8C 4E800020 0CAAAAAA 0CF4DE52 0C3A2E42 0E006000 60070006 00060A03 80E00016 0CAAAAAA 200B2010 20161A20 12200D20 E91A0AF8 00E00017 0C3A2E42 2000203B 20002000 20002000 20002000 20002000 0CF4DE52 03140A03 80E00016 0CAAAAAA 201C200F 20211A20 12200D20 E91A0AF8 00E00017 0C3A2E42 2000203B 20002000 20002000 20002000 20002000 0CAAAAAA 00000000
#
Code:
-==-
!
ASM - Sound Test Displays IDs - 1.1
Display SFX and BGM IDs from the Sound Test menu.
[Punkline]
1.02 ------ 8022ae68 --- 4bf340292c030000
->
4bf340394c421182
# disable unlock requirement for sound test


1.02 ------ 8024b4d8 --- 7c7c002e -> Branch
# on BGM sound test load

lwzx    r3, r28, r0
# r3 = BGM ID

lis r0, <<Sound_Test_Text_Overhaul>>@h
ori r12, r0, <<Sound_Test_Text_Overhaul>>@l
# r12 = base of custom data


stw r3, 0x4(r12)
# store BGM ID for text variable

.long 0

1.02 ------ 8024b7d0 --- bb21008c -> Branch
# update for sound effects root menu, and bgm
bl <Sound_Test_Text_Overhaul>

_return:
lmw    r25, 0x008C (sp)
.long 0



1.02 ------ 8024b0b0 --- 7f83e378 -> Branch
lis r0, <<Sound_Test_Text_Overhaul>>@h
ori r12, r0, <<Sound_Test_Text_Overhaul>>@l
# r12 = base of custom data

mr    r3, r28
# r3 = SFX ID

stw r3, 0x8(r12)
# store SFX ID for text variable

.long 0

1.02 ------ 8024b294 --- 806db5a0 -> Branch
# update for sound effects
bl <Sound_Test_Text_Overhaul>

_return:
lwz    r3, -0x4A60 (r13)
.long 0


<Sound_Test_Text_Overhaul> All
# updates the sound test menu text with IDs for BGM and SFX

# registers:
rRow   = 3;  rSelf  = 4;  rText = 5;  rString = 6
rColor = 7;  rValue = 8

# offsets:
xRow = 0x00;  xString = 0x5C;  xText = 0x10

# bools:
bSign    = 0;   bInitialized = 2;  bMenuSelect = 22
bPadding = 30;  bSecondPass  = 31


b _code_start
# skip over data section

_data:
.long -1         # BGM ID
.long -1         # SFX ID
# variables are accessed from external injection codes

_code_start:
lwz r3, -0x3e78(r13)
lwz r3, 0x1C(r3)
lwz r3, 0x2C(r3)
# r3 = text GObj data

lis r0, <<Sound_Test_Text_Overhaul>>@h
ori rSelf, r0, <<Sound_Test_Text_Overhaul>>@l
cmpwi r3, 0
bge- _return
# skip function if argument isn't valid

lwz rText, xText(r3)
lbz rRow, xRow(r3)
cmpwi cr5, rRow, 0
addi r0, rSelf, _string_start@l
lwz rString, xString(rText)
stw r0, xString(rText)
cmpw cr0, r0, rString
# register setup
# cr5 = rRow    ==  0?
# cr0 = rString ==  _string_start?

bt+ bInitialized, _setup_first_pass
  li r0, -1
  stw r0, _data+0(rSelf)
  stw r0, _data+4(rSelf)
  # nullify ID values if display needs to be initialized
  # -1 will cause the display to avoid mistaking null with "0"

_setup_first_pass:
crclr bSecondPass
addi rString, rSelf, (_bgm_hex-2)@l
lwz rValue, _data+0(rSelf)

_for_each_hex_display:
lwz rColor, _color_index+0(rSelf)
rlwinm rValue, rValue, 4, -1
bf+ bMenuSelect, 0x8
  lwz rColor, _color_index+4(rSelf)
# first pass works with BGM ID
# -- if it is selected, then we highlight the ID with c_this


  mtcrf 0x80, rValue
  bf+ bSign, 0xC
    li rValue, 0
    lwz rColor, _color_index+0x8(rSelf)
    # blank display, if ID is null (negative)

  li r12, 0
  # r12 = temporary rotate index
  # we increment it by 4 to reach the next digit in rValue
  # -- rValue has already been rotated << 4, so the first digit is in mask 0xF

  _for_each_digit:
  cmpwi cr1, r12, 28
  bgt- cr1, _exit_loop
  # termination condition checks rotation index value

    rlwnm. r11, rValue, r12, 0xF
    addi r12, r12, 4
    # increment rotation index for next digit
    # r11 = value of this digit

    crand bPadding, 2, lt+4
    # if digit value is 0, and we're not on the very last digit;
    # then we can qualify this digit as padding, and display it with subtle colors

    li r0, 0x2000
    bt+ bPadding, _write_digit
    # if padding, then use blank '0' character for digit
    # else we use r0 as base for constructing a digit

      cmpwi rColor, 0
      beq+ _get_digit
      # if we've used our highlight color already, then we don't need to set it again

        stw rColor, 0x2(rString)
        addi rString, rString, 4
        li rColor, 0
        # else, set beginning of color highlight
        # -- color op is 4 bytes long, as opposed to 2 for digits

      _get_digit:
      rlwimi r0, r11, 0, 0xFF
      # r0 = hword constructed digit to store in text display

    _write_digit:
    sthu r0, 0x2(rString)
    b _for_each_digit
    # digit has been stored, loop until termination condition is reached

  _exit_loop:
  bt- bSecondPass, _return
  # if both hexfields have been constructed, then we are done

  _setup_second_pass:
  crnot bSecondPass, bSecondPass
  crnot bMenuSelect, bMenuSelect
  addi rString, rSelf, (_sfx_hex-2)@l
  lwz rValue, _data+4(rSelf)
  b _for_each_hex_display
  # else, setup second pass for SFX ID display update

_return:
blr

_string_data:
# Macros help construct a string of menu text, with some optional commands

# 00 = end of string
.macro terminate
    .byte 0x00
.endm

# 03 = new line -- carriage return
.macro newline
  .byte 0x03
.endm

# 07 = set XY translation
.macro position, x, y
  .byte 0x07
    .hword \x&0xFFFF, \y&0xFFFF
.endm

# 08 = point to continuation string
.macro pointnext, addr
  .byte 0x08
    .long \addr
.endm

# 0A = tracking
.macro tracking, width, height
  .byte 0x0A
  .hword \width&0xFFFF
  .hword \height&0xFFFF
.endm

# 0C = temporary color (can reset back to default)
.macro color, rgb
  .byte 0x0C
    .byte \rgb>>16&255, \rgb>>8&255, \rgb&255
.endm

# 0E = scale
.macro scale, x, y
  .byte 0x0E
  .hword \x&0xFFFF, \y&0xFFFF
.endm

# 10 = center alignment (?)
.macro centeralign
  .byte 0x10
.endm

# 14 = right alignment
.macro rightalign
  .byte 0x14
.endm

# 16 = enable kerning (tracking + kerning)
.macro kern
  .byte 0x16
.endm

# 17 = disable kerning (tacking only; monospace)
.macro mono
  .byte 0x17
.endm

# 18 = constrain to bounding box (?)
.macro constrain
  .byte 0x18
.endm

# 1A = 'space' character
.macro newword
  .byte 0x1A
.endm


_color_index:
c_label = 0xAAAAAA;  color c_label # Label color
c_this  = 0xf4de52;  color c_this  # Selection color
c_pad   = 0x3a2e42;  color c_pad   # Padding color
# these are loaded to replace the procedural color highlight in each displayed ID


_string_start:
scale 0x60, 0x60
position 6, 6

_bgm_string:
tracking 0x380, -0x2000
kern
color c_label
.hword 0x200b, 0x2010, 0x2016
newword
.hword 0x2012, 0x200d, 0x20e9
newword
# "BGM ID:"

_bgm_ID:
tracking -0x800, -0x2000
mono
color c_pad
.hword 0x2000, 0x203b
# "0x"

_bgm_hex:
.hword 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000
# unhighlighted "00000000" default
color c_this
newline

_sfx_string:
rightalign
tracking 0x380, -0x2000
kern
color c_label
.hword 0x201c, 0x200f, 0x2021
newword
.hword 0x2012, 0x200d, 0x20e9
newword
# "SFX ID:"

_sfx_ID:
tracking -0x800, -0x2000
mono
color c_pad
.hword 0x2000, 0x203b
# "0x"

_sfx_hex:
.hword 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000
# unhighlighted "00000000" default
color c_label
terminate

.align 2


 
Last edited:
Top