• 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 Rainbow GaW + GaW Costume Dependent Outlines and Colors + Others

UnclePunch

Smash Ace
Joined
Nov 9, 2014
Messages
673
Costume Dependent GaW Outlines and Colors


Code:
$GAW Custom Colors [UnclePunch]
0414a7b4 4e800020
C214A364 0000000C
881F0619 2C000000
4182001C 2C000001
41820020 2C000002
41820024 2C000003
41820028 3C000000
600000FF 48000024
3C00D333 600035FF
48000018 3C009769
6000FFFF 4800000C
3C000086 600003FF
901F2434 901F0614
8001001C 00000000
C20BFBA0 0000000C
81C10024 880E0619
2C000000 4182001C
2C000001 41820020
2C000002 41820024
2C000003 41820028
3C00FFFF 6000FFFF
48000024 3C00FFA0
6000E8FF 48000018
3C0000FF 6000EAFF
4800000C 3C0036FF
600000FF 901F0000
60000000 00000000

$GAW Custom Colors [UnclePunch]
0414a7b4 4e800020 #blr a function that resets dat attributes
C214A364 0000000C #outline colors
881F0619 2C000000
4182001C 2C000001
41820020 2C000002
41820024 2C000003
41820028 3C000000
600000FF 48000024
3C00D333 600035FF
48000018 3C009769
6000FFFF 4800000C
3C000086 600003FF
901F2434 901F0614
8001001C 00000000
C20BFBA0 0000000C #inside colors
81C10024 880E0619
2C000000 4182001C
2C000001 41820020
2C000002 41820024
2C000003 41820028
3C00FFFF 6000FFFF
48000024 3C00FFA0
6000E8FF 48000018
3C0000FF 6000EAFF
4800000C 3C0036FF
600000FF 901F0000
60000000 00000000

Highlighted colors are RRGGBBFF format.

Rainbow GaW
Code:
$Default GaW = Rainbow GaW [UnclePunch,rmn]
C206AB88 0000003D
813E002C 88090007
2C000018 408201D4
88090619 2C000000
408201C8 C029FFC0
480001A1 7C6802A6
C0430010 EC21102A
C042E3CC 4800015D
D029FFC0 FD000890
C1230008 C143000C
C002E694 EC210024
FD600890 C0428048
48000139 C0029D80
FC210028 FC200A10
FC200828 ECE902B2
ED070072 FC200090
FC0B0840 41810014
FC203890 FC404090
C062A1C4 48000080
EC21002A FC0B0840
41810014 FC204090
FC403890 C062A1C4
48000064 EC21002A
FC0B0840 41810014
C022A1C4 FC403890
FC604090 48000048
EC21002A FC0B0840
41810014 C022A1C4
FC404090 FC603890
4800002C EC21002A
FC0B0840 41810014
FC204090 C042A1C4
FC603890 48000010
FC203890 C042A1C4
FC604090 EC0A3828
EC21002A EC42002A
EC63002A C0030014
EC210032 EC630032
EC420032 FC20081E
D821FFF8 81C1FFFC
FC40101E D841FFF8
81E1FFFC FC60181E
D861FFF8 8201FFFC
889F0619 5484103A
38840004 80BF02D4
7C852214 99C40000
99E40001 9A040002
39C000FF 99C40003
7FC3F378 3DC0800B
61CEFB4C 7DC903A6
4E800421 48000054
EC211024 FD800890
C8028B00 FC21002A
FC210028 FC016040
EC2C0828 4081000C
C0029D80 FC20082A
EC2100B2 4E800020
4E800021 C3300000
00000000 3F400000
3F000000 3DCCCCCD
437F0000 427C0000
80010034 00000000
Code:
# Rainbow GaW [UnclePunch,rmn]
# rmn is a god, he wrote and commented all of the color change code
# Hue change speed in degrees per frame, value, and saturation
#  options are found in the data section at the end of the code.

# This code is long and unoptimized. Hasn't been tested
#  extensively so be cautious.
# Inject at 8006ab88
# Original instruction: lwz    r0, 0x0034 (sp)
# By default saves hue to 0x20 of the player entity struct.
#  If you are using that space for something else, change
#  those two lines to point somewhere else. That location
#  defaults to 0, and the code expects a non-negative value
#  value when loading a float from that location so you may
#  have to initialize the memory you choose to use.

# r30 = player entity struct pointer
lwz  r9, 0x2c(r30)  # player data pointer
lwz  r0, 0x4(r9)
cmpwi  r0, 0x18  # check character ID
bne  done
lbz r0,0x619(r9)
cmpwi r0,0x0 #check costume
bne done
# Calculate C and X terms.
# Reference used for HSV->RGB conversion:
#  https://en.wikipedia.org/wiki/HSL_and_HSV#Converting_to_RGB
lfs   f1, -0x40(r9)  # load hue #####################
bl   constants
mflr   r3
lfs   f2, 0x10(r3)  # hue deg/frame
fadds   f1, f1, f2  # increment hue
lfs  f2, -0x1c34(r2) # 360
bl  float_mod  # keep hue in [0, 360]
stfs  f1, -0x40(r9)  # save hue #####################

fmr  f8, f1  # hue
lfs   f9, 8(r3)  # sat
lfs   f10, 0xC(r3)  # value

lfs  f0, -0x196C(r2) # 60
fdivs   f1, f1, f0  # Hue/60deg = H'
fmr  f11, f1

lfs  f2, -0x7fb8(r2) # 2
bl  float_mod  # H' mod 2
lfs  f0, -0x6280(r2) # 1
fsub  f1, f1, f0
fabs  f1, f1  # |H' mod 2  - 1|
fsub  f1, f0, f1  # 1 - |H' mod 2  - 1|

fmuls   f7, f9, f10  # Chroma
fmuls  f8, f7, f1  # X

find_region:  # get R1, G1, B1
fmr  f1, f0
fcmpo  cr0, f11, f1
bgt  gt1
fmr  f1, f7
fmr  f2, f8
lfs  f3, -0x5e3c(r2) # 0
b  region_found
gt1:
fadds  f1, f1, f0
fcmpo  cr0, f11, f1
bgt  gt2
fmr  f1, f8
fmr  f2, f7
lfs  f3, -0x5e3c(r2)
b  region_found
gt2:
fadds  f1, f1, f0
fcmpo  cr0, f11, f1
bgt  gt3
lfs  f1, -0x5e3c(r2)
fmr  f2, f7
fmr  f3, f8
b  region_found
gt3:
fadds  f1, f1, f0
fcmpo  cr0, f11, f1
bgt  gt4
lfs  f1, -0x5e3c(r2)
fmr  f2, f8
fmr  f3, f7
b  region_found
gt4:
fadds  f1, f1, f0
fcmpo  cr0, f11, f1
bgt  gt5
fmr  f1, f8
lfs  f2, -0x5e3c(r2)
fmr  f3, f7
b  region_found
gt5:
fmr  f1, f7
lfs  f2, -0x5e3c(r2)
fmr  f3, f8

region_found:
# Get R, G, B. Will fall in range [0, 1]
fsubs  f0, f10, f7  # m
fadds  f1, f1, f0  # R
fadds  f2, f2, f0  # G
fadds  f3, f3, f0  # B

# RGB565 format:
# R and B will range from 0 to 0x1F, G will range from 0 to 0x3F
lfs  f0, 0x14(r3)
fmuls  f1, f1, f0
fmuls  f3, f3, f0
fmuls  f2, f2, f0

# Convert R, G, B to integers
fctiwz  f1, f1
stfd  f1, -8(r1)
lwz  r14, -4(r1)  # R
fctiwz  f2, f2
stfd  f2, -8(r1)
lwz  r15, -4(r1)  # G
fctiwz  f3, f3
stfd  f3, -8(r1)
lwz  r16, -4(r1)  # B

#store colors to GaW struct
lbz    r4, 0x0619 (r31)            #get costume ID
rlwinm    r4, r4, 2, 0, 29            #multiply to get offset
addi    r4, r4, 4            #add to r4
lwz    r5, 0x02D4 (r31)            #get article floating point address
add    r4, r5, r4            #add offset to address to get GaW color value in r4

stb r14,0x0(r4)                #store Red
stb r15,0x1(r4)                #store Green
stb r16,0x2(r4)                #store Blue
li r14,0xff                #load Alpha
stb r14,0x3(r4)                #store Alpha

mr r3,r30                #get pointer in r3
lis r14,0x800b                #branch to fillGaWColor
ori r14,r14,0xfb4c
mtctr r14
bctrl

b  done

float_mod:
# f1 = f1 mod f2
# r3 = pointer to constants data block
# destroys f12 but that doesn't break anything here
# Expects positive values
fdivs  f1, f1, f2
fmr  f12, f1
lfd  f0, -0x7500(r2) # 43300000 00000000
fadd  f1, f1, f0  # round value in f1 to nearest integer
fsub  f1, f1, f0  # (only for positive values!)
fcmpo  cr0, f1, f12
fsubs  f1, f12, f1  # get remainder
ble  fm_rounded_down
fm_rounded_up:
lfs  f0, -0x6280(r2) # 1
fadd  f1, f0, f1  # correct sign
fm_rounded_down:
fmuls  f1, f1, f2  # get mod
blr

constants:
blrl
.long  0xc3300000 ; constant for fp rounding
.long  0x00000000
.long  0x3F400000 ; saturation = 0.75
.long  0x3F000000 ; value = 0.5
.long  0x3DCCCCCD ; hue degrees per frame = 0.1
.long  0x437F0000 ; 255, constant
.long  0x427C0000 ; 63, constant

done:
lwz    r0, 0x0034 (sp) ;instruction replaced with injection
 
Last edited:
Top Bottom