Color Cycler Assembly

Started by hetoan2, February 13, 2011, 08:27:21 PM

Previous topic - Next topic

Y.S.

@hetoan2

Your original idea of color cycles was attractive enough for me to write the code for myself.
I just wanted to write all the codes I had in mind while I can, to share what I've learnt in past 10 years.

----

Modified the code a little so that it can be used in C2 codes :-*
You can make a color changing code for any game that uses RGB colors.

[spoiler].macro  lwi   reg, value
lis   \reg, \value@h
ori   \reg, \reg, \value@l
.endm

/*
int --> float conversion using red zone
freg2 holds the constant 0x4330000080000000
*/

.macro fcfid freg1,freg2,reg1

stfd \freg2,-8(r1)
xoris \reg1,\reg1,0x8000
stw \reg1,-4(r1)
lfd \freg1,-8(r1)
fsub \freg1,\freg1,\freg2

.endm


/*
PUSH and POP
*/

.macro  stmfd from, to, offset,reg
  stfd   \from,\offset(\reg)
  .if     \to-\from
  stmfd    "(\from+1)",\to, \offset+8,\reg
  .endif
.endm

.macro  lmfd from, to, offset,reg
  lfd   \from,\offset(\reg)
  .if     \to-\from
  lmfd    "(\from+1)",\to, \offset+8,\reg
  .endif
.endm


/*
Variables for stackframe
*/

.set numGPRs,(31-12+1)
.set numFPRs,(_saveFPRs_end - _saveFPRs_start)/4
.set spaceToSave,((4 + ((4*numGPRs + 7)& ~7) + 8*numFPRs ) +7) & ~7
.set offsetforFPR,8 + ((4*numGPRs + 7) & ~7)


# FPRs
.set PARAM_RATE,4
.set maxcolor,5
.set mincolor,6

.set H,7
.set S,8
.set L,9

.set RED,10
.set GREEN,11
.set BLUE,12

.set tmp1,13
.set tmp2,14

.set temp1,15
.set temp2,16
.set temp3,17

.set color,18

.set CONST_0.0,      19
.set CONST_0.5,      20
.set CONST_1.0,      21
.set CONST_2.0,      22
.set CONST_one_3rd,   23
.set CONST_two_3rds,   24
.set CONST_3.0,      25
.set CONST_4.0,      26
.set CONST_6.0,      27
.set CONST_60.0,   28
.set CONST_255.0,   29
.set CONST_360.0,   30
.set CONST_MAGIC,   31


# GPRs

.set anchor,12

.set red,14
.set green,15
.set blue,16

.set maxcolor_index,17
.set mincolor_index,18

.set datap,19
.set savedLR,20

#indexes
.set color_index_RED,0
.set color_index_GREEN,1
.set color_index_BLUE,2



/*-------------------------------------------------------------------------------*/

_stackframe:
stwu r1,-spaceToSave(r1)
stmw r12,8(r1)

_saveFPRs_start:
stmfd 4,31,offsetforFPR,1
_saveFPRs_end:

mflr   savedLR


/*
Set a pointer to the RGB data
Edit if needed
*/
addi   datap,r27,1392




bl   _const_data_end

_const_data:
.float   0.0
.float   0.5
.float   1.0
.float   2.0
.float   3.0
.float   0.33333333
.float   0.66666666
.float   4.0
.float   6.0
.float   60.0
.float   255.0
.float   360.0
.double   4503601774854144
/*
Color changing rate
Edit if needed
*/
.float   0.125

_const_data_end:

mflr   anchor

lfs   CONST_0.0,0(anchor)
lfs   CONST_0.5,4(anchor)
lfs   CONST_1.0,8(anchor)
lfs   CONST_2.0,12(anchor)
lfs   CONST_3.0,16(anchor)
lfs   CONST_one_3rd,20(anchor)
lfs   CONST_two_3rds,24(anchor)
lfs   CONST_4.0,28(anchor)
lfs   CONST_6.0,32(anchor)
lfs   CONST_60.0,36(anchor)
lfs   CONST_255.0,40(anchor)
lfs   CONST_360.0,44(anchor)
lfd   CONST_MAGIC,48(anchor)
lfs   PARAM_RATE,56(anchor)





# Convert the RBG values to the range 0-1

lbz   red,0(datap)
fcfid   RED,CONST_MAGIC,red
fdiv   RED,RED,CONST_255.0

lbz   green,1(datap)
fcfid   GREEN,CONST_MAGIC,green
fdiv   GREEN,GREEN,CONST_255.0

lbz   blue,2(datap)
fcfid   BLUE,CONST_MAGIC,blue
fdiv   BLUE,BLUE,CONST_255.0


/*-------------------------------------------------------------------------------*/

#RGB - HSL



/*
Find min and max values of R, B, G
*/


fmr   maxcolor,RED
fmr   mincolor,RED
li   maxcolor_index,color_index_RED
li   mincolor_index,color_index_RED

fcmpo   cr0,maxcolor,GREEN
bgt-   0f
fmr   maxcolor,GREEN
li   maxcolor_index,color_index_GREEN
0:

fcmpo   cr0,maxcolor,BLUE
bgt-   0f
fmr   maxcolor,BLUE
li   maxcolor_index,color_index_BLUE
0:

fcmpo   cr0,mincolor,GREEN
blt-   0f
fmr   mincolor,GREEN
li   mincolor_index,color_index_GREEN
0:

fcmpo   cr0,mincolor,BLUE
blt-   0f
fmr   mincolor,BLUE
li   mincolor_index,color_index_BLUE
0:


/*
L = (maxcolor + mincolor)/2
tmp1 = (maxcolor + mincolor)
*/

fadd   tmp1,maxcolor,mincolor
fdiv   L,tmp1,CONST_2.0



/*
If the max and min colors are the same (ie the color is some kind of grey), S is defined to be 0, and H is undefined but in programs usually written as 0
*/


cmpw   maxcolor_index,mincolor_index
bne-   0f
fmr   S,CONST_0.0
fmr   H,CONST_0.0
b   _HSL2RGB
0:


/*
Otherwise, test L.
If L < 0.5, S=(maxcolor-mincolor)/(maxcolor+mincolor)
If L >=0.5, S=(maxcolor-mincolor)/(2.0-maxcolor-mincolor)

tmp1 = (maxcolor - mincolor)
tmp2 = (maxcolor + mincolor) or tmp2 = (2.0 - (maxcolor + mincolor))
*/

fsub   tmp1,maxcolor,mincolor
fadd   tmp2,maxcolor,mincolor

fcmpo   cr0,L,CONST_0.5
blt-   0f
fsub   tmp2,CONST_2.0,tmp2
0:
fdiv   S,tmp1,tmp2



/*
If R=maxcolor, H = (G-B)/(maxcolor-mincolor)
If G=maxcolor, H = 2.0 + (B-R)/(maxcolor-mincolor)
If B=maxcolor, H = 4.0 + (R-G)/(maxcolor-mincolor)

tmp1 = (maxcolor-mincolor)
tmp2 = (X-Y) or (X-Y)/(maxcolor-mincolor)
*/

cmpwi   maxcolor_index,color_index_RED
bne-   0f
fsub   tmp2,GREEN,BLUE
fdiv   H,tmp2,tmp1
b   1f
0:

cmpwi   maxcolor_index,color_index_GREEN
bne-   0f
fsub   tmp2,BLUE,RED
fdiv   tmp2,tmp2,tmp1
fadd   H,CONST_2.0,tmp2
b   1f
0:

_maxcolor_is_BLUE:
fsub   tmp2,RED,GREEN
fdiv   tmp2,tmp2,tmp1
fadd   H,CONST_4.0,tmp2

1:


/*
To use the scaling shown in the video color page, convert L and S back to percentages, and H into an angle in degrees (ie scale it from 0-360). From the computation in step 6, H will range from 0-6. RGB space is a cube, and HSL space is a double hexacone, where L is the principal diagonal of the RGB cube. Thus corners of the RGB cube; red, yellow, green, cyan, blue, and magenta, become the vertices of the HSL hexagon. Then the value 0-6 for H tells you which section of the hexgon you are in. H is most commonly given as in degrees, so to convert
H = H*60.0
*/

fmul   H,H,CONST_60.0
fcmpo   cr0,H,CONST_0.0
bge-   0f
fadd   H,H,CONST_360.0
0:


_update_hue:

fadd   H,H,PARAM_RATE
fcmpo   cr0,H,CONST_360.0
ble-   0f
fmr   H,CONST_0.0
0:

/*---HSL - RGB---*/

_HSL2RGB:

/*
If S=0, define R, G, and B all to L
*/


fcmpo   cr0,S,CONST_0.0
bne-   0f

fmr   RED,L
fmul   RED,color,CONST_255.0
fctiw   RED,RED
stfd   RED,-8(r1)
lwz   red,-4(r1)
stb   red,0(datap)
stb   red,1(datap)
stb   red,2(datap)
b   _return
0:


/*
Otherwise, test L.
If L < 0.5, temp2=L*(1.0+S)
If L >= 0.5, temp2=L+S - L*S

tmp1 = (1.0+S)
tmp1 = (L+S)
tmp2 = (L*S)
*/

fcmpo   cr0,L,CONST_0.5
bge-   0f
fadd   tmp1,S,CONST_1.0
fmul   temp2,L,tmp1
b   1f
0:

fadd   tmp1,L,S
fmul   tmp2,L,S
fsub   temp2,tmp1,tmp2

1:


/*
temp1 = 2.0*L - temp2
*/

fmul   tmp1,CONST_2.0,L
fsub   temp1,tmp1,temp2

/*
Convert H to the range 0-1
For each of R, G, B, compute another temporary value, temp3, as follows:

for R, temp3=H+1.0/3.0
for G, temp3=H
for B, temp3=H-1.0/3.0
*/

fdiv   H,H,CONST_360.0


fadd   temp3,H,CONST_one_3rd
bl   _calculate_color
fmul   RED,color,CONST_255.0
fctiw   RED,RED
stfd   RED,-8(r1)
lwz   red,-4(r1)
stb   red,0(datap)

fmr   temp3,H
bl   _calculate_color
fmul   GREEN,color,CONST_255.0
fctiw   GREEN,GREEN
stfd   GREEN,-8(r1)
lwz   green,-4(r1)
stb   green,1(datap)

fsub   temp3,H,CONST_one_3rd
bl   _calculate_color
fmul   BLUE,color,CONST_255.0
fctiw   BLUE,BLUE
stfd   BLUE,-8(r1)
lwz   blue,-4(r1)
stb   blue,2(datap)


b   _return



/*-----------------------------------------------------------------------------------------------------------*/

_calculate_color:


/*
if temp3 < 0, temp3 = temp3 + 1.0
if temp3 > 1, temp3 = temp3 - 1.0
*/


fcmpo   cr0,temp3,CONST_1.0
ble-   0f
fsub   temp3,temp3,CONST_1.0

0:


fcmpo   cr0,temp3,CONST_0.0
bge-   0f
fadd   temp3,temp3,CONST_1.0

0:




/*
For each of R, G, B, do the following test:

If 6.0*temp3 < 1, color=temp1+(temp2-temp1)*6.0*temp3
tmp1 = 6.0*temp3

tmp1 = (temp2-temp1)
tmp1 = (temp2-temp1)*6.0
tmp1 = (temp2-temp1)*6.0*temp3
*/

fmul   tmp1,temp3,CONST_6.0
fcmpo   cr0,tmp1,CONST_1.0
bge-   0f

fsub   tmp1,temp2,temp1
fmul   tmp1,tmp1,CONST_6.0
fmul   tmp1,tmp1,temp3
fadd   color,temp1,tmp1
blr
0:

/*
Else if 2.0*temp3 < 1, color=temp2
*/

fmul   tmp1,temp3,CONST_2.0
fcmpo   cr0,tmp1,CONST_1.0
bge-   0f
fmr   color,temp2
blr
0:

/*
Else if 3.0*temp3 < 2, color=temp1+(temp2-temp1)*((2.0/3.0)-temp3)*6.0
tmp1 = (temp2-temp1)
tmp2 = (2.0/3.0)-temp3
tmp1 = (temp2-temp1) * ((2.0/3.0)-temp3)
tmp1 = (temp2-temp1) * ((2.0/3.0)-temp3) * 6.0
color = (temp2-temp1) * ((2.0/3.0)-temp3) * 6.0 +temp1
*/

fmul   tmp1,temp3,CONST_3.0
fcmpo   cr0,tmp1,CONST_2.0
bge-   0f
fsub   tmp1,temp2,temp1
fsub   tmp2,CONST_two_3rds,temp3
fmul   tmp1,tmp1,tmp2
fmul   tmp1,tmp1,CONST_6.0
fadd   color,tmp1,temp1
blr
0:

/*
Else color=temp1
*/

fmr   color,temp1

blr

/*-----------------------------------------------------------------------------------------------------------*/

_return:

mtlr   savedLR
lmw   r12,8(r1)
lmfd   4,31,offsetforFPR,1
addi   r1,r1,spaceToSave


# Edit if needed

_original_instruction:
lbz   r0,1392(r27)
[/spoiler]


Pikmin R9IJ01

Color Cycle for all Pikmin
C210F368 0000007B
9421FEC8 BD810008
D8810058 D8A10060
D8C10068 D8E10070
D9010078 D9210080
D9410088 D9610090
D9810098 D9A100A0
D9C100A8 D9E100B0
DA0100B8 DA2100C0
DA4100C8 DA6100D0
DA8100D8 DAA100E0
DAC100E8 DAE100F0
DB0100F8 DB210100
DB410108 DB610110
DB810118 DBA10120
DBC10128 DBE10130
7E8802A6 3A7B0570
48000041 00000000
3F000000 3F800000
40000000 40400000
3EAAAAAB 3F2AAAAB
40800000 40C00000
42700000 437F0000
43B40000 43300000
80000000 3E000000
7D8802A6 C26C0000
C28C0004 C2AC0008
C2CC000C C32C0010
C2EC0014 C30C0018
C34C001C C36C0020
C38C0024 C3AC0028
C3CC002C CBEC0030
C08C0038 89D30000
DBE1FFF8 6DCE8000
91C1FFFC C941FFF8
FD4AF828 FD4AE824
89F30001 DBE1FFF8
6DEF8000 91E1FFFC
C961FFF8 FD6BF828
FD6BE824 8A130002
DBE1FFF8 6E108000
9201FFFC C981FFF8
FD8CF828 FD8CE824
FCA05090 FCC05090
3A200000 3A400000
FC055840 4181000C
FCA05890 3A200001
FC056040 4181000C
FCA06090 3A200002
FC065840 4180000C
FCC05890 3A400001
FC066040 4180000C
FCC06090 3A400002
FDA5302A FD2DB024
7C119000 40820010
FD009890 FCE09890
48000074 FDA53028
FDC5302A FC09A040
41800008 FDD67028
FD0D7024 2C110000
40820010 FDCB6028
FCEE6824 48000028
2C110001 40820014
FDCC5028 FDCE6824
FCF6702A 48000010
FDCA5828 FDCE6824
FCFA702A FCE70732
FC079840 40800008
FCE7F02A FCE7202A
FC07F040 40810008
FCE09890 FC089840
40820028 FD404890
FD520772 FD40501C
D941FFF8 81C1FFFC
99D30000 99D30001
99D30002 48000100
FC09A040 40800010
FDA8A82A FE090372
48000010 FDA9402A
FDC90232 FE0D7028
FDB60272 FDED8028
FCE7F024 FE27B82A
48000055 FD520772
FD40501C D941FFF8
81C1FFFC 99D30000
FE203890 48000039
FD720772 FD60581C
D961FFF8 81E1FFFC
99F30001 FE27B828
4800001D FD920772
FD80601C D981FFF8
8201FFFC 9A130002
4800007C FC11A840
40810008 FE31A828
FC119840 40800008
FE31A82A FDB106F2
FC0DA840 40800018
FDB07828 FDAD06F2
FDAD0472 FE4F682A
4E800020 FDB105B2
FC0DA840 4080000C
FE408090 4E800020
FDB10672 FC0DB040
4080001C FDB07828
FDD88828 FDAD03B2
FDAD06F2 FE4D782A
4E800020 FE407890
4E800020 7E8803A6
B9810008 C8810058
C8A10060 C8C10068
C8E10070 C9010078
C9210080 C9410088
C9610090 C9810098
C9A100A0 C9C100A8
C9E100B0 CA0100B8
CA2100C0 CA4100C8
CA6100D0 CA8100D8
CAA100E0 CAC100E8
CAE100F0 CB0100F8
CB210100 CB410108
CB610110 CB810118
CBA10120 CBC10128
CBE10130 38210138
881B0570 00000000

hetoan2

#16
get a github so i can fork your instructions for use in my own, I kinda feel guilty about posting it there when users really don't know where it came from (even if i credit in the source @_@)

https://github.com/hetoan2/Variable-Scoping/blob/master/variable-scope.asm

also it'd give you a chance to help out my coding w/o me asking :D


Check out my site with codes obviously...
http://hetoan2.com/

and youtube...
http://youtube.com/hetoan2

Y.S.


hetoan2

thanks :D will look forward to see what other stuff you put up ;)


Check out my site with codes obviously...
http://hetoan2.com/

and youtube...
http://youtube.com/hetoan2

Bully@Wiiplaza

#19
http://wiird.l0nk.org/forum/index.php/topic,7879.msg67810.html#msg67810

crashes my game...
I used the read bp hook from the rgb address and put the original instruction at the end of the coding.

Anyways, using WiiRd codestypes, I got something similar to colour flashing:

A8000008 00000010 #counter (flash speed)
80000000 XXXXXXXX # Address
86010000 0000F000 # Add Value
E0000000 80008000 # Terminator
My Wii hacking site...
http://bullywiihacks.com/

My youtube account with a lot of hacking videos...
http://www.youtube.com/user/BullyWiiPlaza

~Bully

Y.S.

Did you modify the following part?

Quote/*
Set a pointer to the RGB data
Edit if needed
*/
addi   datap,r27,1392

Bully@Wiiplaza

Quote from: Y.S. on January 22, 2012, 10:55:43 AM
Did you modify the following part?

Quote/*
Set a pointer to the RGB data
Edit if needed
*/
addi   datap,r27,1392
no, what do I need to change there?

Let´s say, my address is 81123456 and the value is RRGGBBFF.
My hook is lwz r0, 8 (r26) (Address: 80123456).
How would I put it?

Thx man. ;D
My Wii hacking site...
http://bullywiihacks.com/

My youtube account with a lot of hacking videos...
http://www.youtube.com/user/BullyWiiPlaza

~Bully

Y.S.

Then, this will do the tirck;
addi datap,r26,8

This instruction sets the datap so that it points the RRGGBBFF.

Bully@Wiiplaza

#23
still freezes.
[spoiler].macro  lwi   reg, value
lis   \reg, \value@h
ori   \reg, \reg, \value@l
.endm

/*
int --> float conversion using red zone
freg2 holds the constant 0x4330000080000000
*/

.macro fcfid freg1,freg2,reg1

stfd \freg2,-8(r1)
xoris \reg1,\reg1,0x8000
stw \reg1,-4(r1)
lfd \freg1,-8(r1)
fsub \freg1,\freg1,\freg2

.endm


/*
PUSH and POP
*/

.macro  stmfd from, to, offset,reg
 stfd   \from,\offset(\reg)
 .if     \to-\from
 stmfd    "(\from+1)",\to, \offset+8,\reg
 .endif
.endm

.macro  lmfd from, to, offset,reg
 lfd   \from,\offset(\reg)
 .if     \to-\from
 lmfd    "(\from+1)",\to, \offset+8,\reg
 .endif
.endm


/*
Variables for stackframe
*/

.set numGPRs,(31-12+1)
.set numFPRs,(_saveFPRs_end - _saveFPRs_start)/4
.set spaceToSave,((4 + ((4*numGPRs + 7)& ~7) + 8*numFPRs ) +7) & ~7
.set offsetforFPR,8 + ((4*numGPRs + 7) & ~7)


# FPRs
.set PARAM_RATE,4
.set maxcolor,5
.set mincolor,6

.set H,7
.set S,8
.set L,9

.set RED,10
.set GREEN,11
.set BLUE,12

.set tmp1,13
.set tmp2,14

.set temp1,15
.set temp2,16
.set temp3,17

.set color,18

.set CONST_0.0,      19
.set CONST_0.5,      20
.set CONST_1.0,      21
.set CONST_2.0,      22
.set CONST_one_3rd,   23
.set CONST_two_3rds,   24
.set CONST_3.0,      25
.set CONST_4.0,      26
.set CONST_6.0,      27
.set CONST_60.0,   28
.set CONST_255.0,   29
.set CONST_360.0,   30
.set CONST_MAGIC,   31


# GPRs

.set anchor,12

.set red,14
.set green,15
.set blue,16

.set maxcolor_index,17
.set mincolor_index,18

.set datap,19
.set savedLR,20

#indexes
.set color_index_RED,0
.set color_index_GREEN,1
.set color_index_BLUE,2



/*-------------------------------------------------------------------------------*/

_stackframe:
stwu r1,-spaceToSave(r1)
stmw r12,8(r1)

_saveFPRs_start:
stmfd 4,31,offsetforFPR,1
_saveFPRs_end:

mflr   savedLR

lwz r0,8(r3)


/*
Set a pointer to the RGB data
Edit if needed
*/
addi datap,r26,8



bl   _const_data_end

_const_data:
.float   0.0
.float   0.5
.float   1.0
.float   2.0
.float   3.0
.float   0.33333333
.float   0.66666666
.float   4.0
.float   6.0
.float   60.0
.float   255.0
.float   360.0
.double   4503601774854144
/*
Color changing rate
Edit if needed
*/
.float   0.125
_const_data_end:

mflr   anchor

lfs   CONST_0.0,0(anchor)
lfs   CONST_0.5,4(anchor)
lfs   CONST_1.0,8(anchor)
lfs   CONST_2.0,12(anchor)
lfs   CONST_3.0,16(anchor)
lfs   CONST_one_3rd,20(anchor)
lfs   CONST_two_3rds,24(anchor)
lfs   CONST_4.0,28(anchor)
lfs   CONST_6.0,32(anchor)
lfs   CONST_60.0,36(anchor)
lfs   CONST_255.0,40(anchor)
lfs   CONST_360.0,44(anchor)
lfd   CONST_MAGIC,48(anchor)
lfs   PARAM_RATE,56(anchor)





# Convert the RBG values to the range 0-1

lbz   red,0(datap)
fcfid   RED,CONST_MAGIC,red
fdiv   RED,RED,CONST_255.0

lbz   green,1(datap)
fcfid   GREEN,CONST_MAGIC,green
fdiv   GREEN,GREEN,CONST_255.0

lbz   blue,2(datap)
fcfid   BLUE,CONST_MAGIC,blue
fdiv   BLUE,BLUE,CONST_255.0


/*-------------------------------------------------------------------------------*/

#RGB - HSL



/*
Find min and max values of R, B, G
*/


fmr   maxcolor,RED
fmr   mincolor,RED
li   maxcolor_index,color_index_RED
li   mincolor_index,color_index_RED

fcmpo   cr0,maxcolor,GREEN
bgt-   0f
fmr   maxcolor,GREEN
li   maxcolor_index,color_index_GREEN
0:

fcmpo   cr0,maxcolor,BLUE
bgt-   0f
fmr   maxcolor,BLUE
li   maxcolor_index,color_index_BLUE
0:

fcmpo   cr0,mincolor,GREEN
blt-   0f
fmr   mincolor,GREEN
li   mincolor_index,color_index_GREEN
0:

fcmpo   cr0,mincolor,BLUE
blt-   0f
fmr   mincolor,BLUE
li   mincolor_index,color_index_BLUE
0:


/*
L = (maxcolor + mincolor)/2
tmp1 = (maxcolor + mincolor)
*/

fadd   tmp1,maxcolor,mincolor
fdiv   L,tmp1,CONST_2.0



/*
If the max and min colors are the same (ie the color is some kind of grey), S is defined to be 0, and H is undefined but in programs usually written as 0
*/


cmpw   maxcolor_index,mincolor_index
bne-   0f
fmr   S,CONST_0.0
fmr   H,CONST_0.0
b   _HSL2RGB
0:


/*
Otherwise, test L.
If L < 0.5, S=(maxcolor-mincolor)/(maxcolor+mincolor)
If L >=0.5, S=(maxcolor-mincolor)/(2.0-maxcolor-mincolor)

tmp1 = (maxcolor - mincolor)
tmp2 = (maxcolor + mincolor) or tmp2 = (2.0 - (maxcolor + mincolor))
*/

fsub   tmp1,maxcolor,mincolor
fadd   tmp2,maxcolor,mincolor

fcmpo   cr0,L,CONST_0.5
blt-   0f
fsub   tmp2,CONST_2.0,tmp2
0:
fdiv   S,tmp1,tmp2



/*
If R=maxcolor, H = (G-B)/(maxcolor-mincolor)
If G=maxcolor, H = 2.0 + (B-R)/(maxcolor-mincolor)
If B=maxcolor, H = 4.0 + (R-G)/(maxcolor-mincolor)

tmp1 = (maxcolor-mincolor)
tmp2 = (X-Y) or (X-Y)/(maxcolor-mincolor)
*/

cmpwi   maxcolor_index,color_index_RED
bne-   0f
fsub   tmp2,GREEN,BLUE
fdiv   H,tmp2,tmp1
b   1f
0:

cmpwi   maxcolor_index,color_index_GREEN
bne-   0f
fsub   tmp2,BLUE,RED
fdiv   tmp2,tmp2,tmp1
fadd   H,CONST_2.0,tmp2
b   1f
0:

_maxcolor_is_BLUE:
fsub   tmp2,RED,GREEN
fdiv   tmp2,tmp2,tmp1
fadd   H,CONST_4.0,tmp2

1:


/*
To use the scaling shown in the video color page, convert L and S back to percentages, and H into an angle in degrees (ie scale it from 0-360). From the computation in step 6, H will range from 0-6. RGB space is a cube, and HSL space is a double hexacone, where L is the principal diagonal of the RGB cube. Thus corners of the RGB cube; red, yellow, green, cyan, blue, and magenta, become the vertices of the HSL hexagon. Then the value 0-6 for H tells you which section of the hexgon you are in. H is most commonly given as in degrees, so to convert
H = H*60.0
*/

fmul   H,H,CONST_60.0
fcmpo   cr0,H,CONST_0.0
bge-   0f
fadd   H,H,CONST_360.0
0:


_update_hue:

fadd   H,H,PARAM_RATE
fcmpo   cr0,H,CONST_360.0
ble-   0f
fmr   H,CONST_0.0
0:

/*---HSL - RGB---*/

_HSL2RGB:

/*
If S=0, define R, G, and B all to L
*/


fcmpo   cr0,S,CONST_0.0
bne-   0f

fmr   RED,L
fmul   RED,color,CONST_255.0
fctiw   RED,RED
stfd   RED,-8(r1)
lwz   red,-4(r1)
stb   red,0(datap)
stb   red,1(datap)
stb   red,2(datap)
b   _return
0:


/*
Otherwise, test L.
If L < 0.5, temp2=L*(1.0+S)
If L >= 0.5, temp2=L+S - L*S

tmp1 = (1.0+S)
tmp1 = (L+S)
tmp2 = (L*S)
*/

fcmpo   cr0,L,CONST_0.5
bge-   0f
fadd   tmp1,S,CONST_1.0
fmul   temp2,L,tmp1
b   1f
0:

fadd   tmp1,L,S
fmul   tmp2,L,S
fsub   temp2,tmp1,tmp2

1:


/*
temp1 = 2.0*L - temp2
*/

fmul   tmp1,CONST_2.0,L
fsub   temp1,tmp1,temp2

/*
Convert H to the range 0-1
For each of R, G, B, compute another temporary value, temp3, as follows:

for R, temp3=H+1.0/3.0
for G, temp3=H
for B, temp3=H-1.0/3.0
*/

fdiv   H,H,CONST_360.0


fadd   temp3,H,CONST_one_3rd
bl   _calculate_color
fmul   RED,color,CONST_255.0
fctiw   RED,RED
stfd   RED,-8(r1)
lwz   red,-4(r1)
stb   red,0(datap)

fmr   temp3,H
bl   _calculate_color
fmul   GREEN,color,CONST_255.0
fctiw   GREEN,GREEN
stfd   GREEN,-8(r1)
lwz   green,-4(r1)
stb   green,1(datap)

fsub   temp3,H,CONST_one_3rd
bl   _calculate_color
fmul   BLUE,color,CONST_255.0
fctiw   BLUE,BLUE
stfd   BLUE,-8(r1)
lwz   blue,-4(r1)
stb   blue,2(datap)


b   _return



/*-----------------------------------------------------------------------------------------------------------*/

_calculate_color:


/*
if temp3 < 0, temp3 = temp3 + 1.0
if temp3 > 1, temp3 = temp3 - 1.0
*/


fcmpo   cr0,temp3,CONST_1.0
ble-   0f
fsub   temp3,temp3,CONST_1.0

0:


fcmpo   cr0,temp3,CONST_0.0
bge-   0f
fadd   temp3,temp3,CONST_1.0

0:




/*
For each of R, G, B, do the following test:

If 6.0*temp3 < 1, color=temp1+(temp2-temp1)*6.0*temp3
tmp1 = 6.0*temp3

tmp1 = (temp2-temp1)
tmp1 = (temp2-temp1)*6.0
tmp1 = (temp2-temp1)*6.0*temp3
*/

fmul   tmp1,temp3,CONST_6.0
fcmpo   cr0,tmp1,CONST_1.0
bge-   0f

fsub   tmp1,temp2,temp1
fmul   tmp1,tmp1,CONST_6.0
fmul   tmp1,tmp1,temp3
fadd   color,temp1,tmp1
blr
0:

/*
Else if 2.0*temp3 < 1, color=temp2
*/

fmul   tmp1,temp3,CONST_2.0
fcmpo   cr0,tmp1,CONST_1.0
bge-   0f
fmr   color,temp2
blr
0:

/*
Else if 3.0*temp3 < 2, color=temp1+(temp2-temp1)*((2.0/3.0)-temp3)*6.0
tmp1 = (temp2-temp1)
tmp2 = (2.0/3.0)-temp3
tmp1 = (temp2-temp1) * ((2.0/3.0)-temp3)
tmp1 = (temp2-temp1) * ((2.0/3.0)-temp3) * 6.0
color = (temp2-temp1) * ((2.0/3.0)-temp3) * 6.0 +temp1
*/

fmul   tmp1,temp3,CONST_3.0
fcmpo   cr0,tmp1,CONST_2.0
bge-   0f
fsub   tmp1,temp2,temp1
fsub   tmp2,CONST_two_3rds,temp3
fmul   tmp1,tmp1,tmp2
fmul   tmp1,tmp1,CONST_6.0
fadd   color,tmp1,temp1
blr
0:

/*
Else color=temp1
*/

fmr   color,temp1

blr

/*-----------------------------------------------------------------------------------------------------------*/

_return:

mtlr   savedLR
lmw   r12,8(r1)
lmfd   4,31,offsetforFPR,1
addi   r1,r1,spaceToSave


# Edit if needed

_original_instruction:
lwz r0,8(r3)[/spoiler]Well, then I need to do it elsewise, if people can´t provide a working template...

[spoiler]  CR:502409C0  XER:8000E510  CTR:0000000C DSIS:04000000
DAR:FFFF8C49 SRR0:800B26C8 SRR1:00001030   LR:00000000
 r0:00000018   r1:80249C40   r2:80241D00   r3:04000080
 r4:8015F7A0   r5:800B2750   r6:002635C0   r7:80144000
 r8:80944B88   r9:9095161C  r10:00000000  r11:00000002
r12:80944B88  r13:00000001  r14:00000000  r15:9095161C
r16:00000000  r17:00000002  r18:80249DA0  r19:40338000
r20:00000000  r21:00000000  r22:00000000  r23:00000000
r24:00000000  r25:00000000  r26:00000000  r27:00000000
r28:00000000  r29:00000018  r30:801D2338  r31:00000140

800B24A0:  9421FFE0   stwu   r1,-32(r1)
800B24A4:  7C0802A6   mflr   r0
800B24A8:  3C60CC00   lis   r3,-13312
800B24AC:  90010024   stw   r0,36(r1)
800B24B0:  93E1001C   stw   r31,28(r1)
800B24B4:  93C10018   stw   r30,24(r1)
800B24B8:  7C9E2378   mr   r30,r4
800B24BC:  93A10014   stw   r29,20(r1)
800B24C0:  83E33000   lwz   r31,12288(r3)
800B24C4:  80033004   lwz   r0,12292(r3)
800B24C8:  57FF041D   rlwinm.   r31,r31,0,16,14
800B24CC:  4182000C   beq-   0x800b24d8
800B24D0:  7FE00039   and.   r0,r31,r0
800B24D4:  4082000C   bne-   0x800b24e0
800B24D8:  7FC3F378   mr   r3,r30
800B24DC:  4BFFB5C5   bl   0x800adaa0
800B24E0:  57E00631   rlwinm.   r0,r31,0,24,24
800B24E4:  38000000   li   r0,0
800B24E8:  41820048   beq-   0x800b2530
800B24EC:  3C60CC00   lis   r3,-13312
800B24F0:  A083401E   lhz   r4,16414(r3)
800B24F4:  548307FF   rlwinm.   r3,r4,0,31,31
800B24F8:  41820008   beq-   0x800b2500
800B24FC:  64008000   oris   r0,r0,32768
800B2500:  548307BD   rlwinm.   r3,r4,0,30,30
800B2504:  41820008   beq-   0x800b250c
800B2508:  64004000   oris   r0,r0,16384
800B250C:  5483077B   rlwinm.   r3,r4,0,29,29
800B2510:  41820008   beq-   0x800b2518
800B2514:  64002000   oris   r0,r0,8192
800B2518:  54830739   rlwinm.   r3,r4,0,28,28
800B251C:  41820008   beq-   0x800b2524
800B2520:  64001000   oris   r0,r0,4096
800B2524:  548306F7   rlwinm.   r3,r4,0,27,27
800B2528:  41820008   beq-   0x800b2530
800B252C:  64000800   oris   r0,r0,2048
800B2530:  57E30673   rlwinm.   r3,r31,0,25,25
800B2534:  41820030   beq-   0x800b2564
800B2538:  3C60CC00   lis   r3,-13312
800B253C:  A083500A   lhz   r4,20490(r3)
800B2540:  54830739   rlwinm.   r3,r4,0,28,28
800B2544:  41820008   beq-   0x800b254c
800B2548:  64000400   oris   r0,r0,1024
800B254C:  548306B5   rlwinm.   r3,r4,0,26,26
800B2550:  41820008   beq-   0x800b2558
800B2554:  64000200   oris   r0,r0,512
800B2558:  54830631   rlwinm.   r3,r4,0,24,24
800B255C:  41820008   beq-   0x800b2564
800B2560:  64000100   oris   r0,r0,256
800B2564:  57E306B5   rlwinm.   r3,r31,0,26,26
800B2568:  41820018   beq-   0x800b2580
800B256C:  3C60CD00   lis   r3,-13056
800B2570:  80636C00   lwz   r3,27648(r3)
800B2574:  54630739   rlwinm.   r3,r3,0,28,28
800B2578:  41820008   beq-   0x800b2580
800B257C:  64000080   oris   r0,r0,128
800B2580:  57E306F7   rlwinm.   r3,r31,0,27,27
800B2584:  4182007C   beq-   0x800b2600
800B2588:  3C60CD00   lis   r3,-13056
800B258C:  80836800   lwz   r4,26624(r3)
800B2590:  548307BD   rlwinm.   r3,r4,0,30,30
800B2594:  41820008   beq-   0x800b259c
800B2598:  64000040   oris   r0,r0,64
800B259C:  54830739   rlwinm.   r3,r4,0,28,28
800B25A0:  41820008   beq-   0x800b25a8
800B25A4:  64000020   oris   r0,r0,32
800B25A8:  54830529   rlwinm.   r3,r4,0,20,20
800B25AC:  41820008   beq-   0x800b25b4
800B25B0:  64000010   oris   r0,r0,16
800B25B4:  3C60CD00   lis   r3,-13056
800B25B8:  80836814   lwz   r4,26644(r3)
800B25BC:  548307BD   rlwinm.   r3,r4,0,30,30
800B25C0:  41820008   beq-   0x800b25c8
800B25C4:  64000008   oris   r0,r0,8
800B25C8:  54830739   rlwinm.   r3,r4,0,28,28
800B25CC:  41820008   beq-   0x800b25d4
800B25D0:  64000004   oris   r0,r0,4
800B25D4:  54830529   rlwinm.   r3,r4,0,20,20
800B25D8:  41820008   beq-   0x800b25e0
800B25DC:  64000002   oris   r0,r0,2
800B25E0:  3C60CD00   lis   r3,-13056
800B25E4:  80836828   lwz   r4,26664(r3)
800B25E8:  548307BD   rlwinm.   r3,r4,0,30,30
800B25EC:  41820008   beq-   0x800b25f4
800B25F0:  64000001   oris   r0,r0,1
800B25F4:  54830739   rlwinm.   r3,r4,0,28,28
800B25F8:  41820008   beq-   0x800b2600
800B25FC:  60008000   ori   r0,r0,32768
800B2600:  57E304A5   rlwinm.   r3,r31,0,18,18
800B2604:  41820008   beq-   0x800b260c
800B2608:  60000020   ori   r0,r0,32
800B260C:  57E304E7   rlwinm.   r3,r31,0,19,19
800B2610:  41820008   beq-   0x800b2618
800B2614:  60000040   ori   r0,r0,64
800B2618:  57E3056B   rlwinm.   r3,r31,0,21,21
800B261C:  41820008   beq-   0x800b2624
800B2620:  60001000   ori   r0,r0,4096
800B2624:  57E305AD   rlwinm.   r3,r31,0,22,22
800B2628:  41820008   beq-   0x800b2630
800B262C:  60002000   ori   r0,r0,8192
800B2630:  57E305EF   rlwinm.   r3,r31,0,23,23
800B2634:  41820008   beq-   0x800b263c
800B2638:  60000080   ori   r0,r0,128
800B263C:  57E30739   rlwinm.   r3,r31,0,28,28
800B2640:  41820008   beq-   0x800b2648
800B2644:  60000800   ori   r0,r0,2048
800B2648:  57E3077B   rlwinm.   r3,r31,0,29,29
800B264C:  41820008   beq-   0x800b2654
800B2650:  60000400   ori   r0,r0,1024
800B2654:  57E307BD   rlwinm.   r3,r31,0,30,30
800B2658:  41820008   beq-   0x800b2660
800B265C:  60000200   ori   r0,r0,512
800B2660:  57E30529   rlwinm.   r3,r31,0,20,20
800B2664:  41820008   beq-   0x800b266c
800B2668:  60004000   ori   r0,r0,16384
800B266C:  57E307FF   rlwinm.   r3,r31,0,31,31
800B2670:  41820008   beq-   0x800b2678
800B2674:  60000100   ori   r0,r0,256
800B2678:  57E30463   rlwinm.   r3,r31,0,17,17
800B267C:  41820008   beq-   0x800b2684
800B2680:  60000010   ori   r0,r0,16
800B2684:  3C608000   lis   r3,-32768
800B2688:  808300C4   lwz   r4,196(r3)
800B268C:  806300C8   lwz   r3,200(r3)
800B2690:  7C831B78   or   r3,r4,r3
800B2694:  7C031879   andc.   r3,r0,r3
800B2698:  4182008C   beq-   0x800b2724
800B269C:  3C808016   lis   r4,-32746
800B26A0:  3884F790   subi   r4,r4,2160
800B26A4:  60000000   nop   
800B26A8:  80040000   lwz   r0,0(r4)
800B26AC:  7C600039   and.   r0,r3,r0
800B26B0:  41820010   beq-   0x800b26c0
800B26B4:  7C000034   cntlzw   r0,r0
800B26B8:  7C1D0734   extsh   r29,r0
800B26BC:  4800000C   b   0x800b26c8
800B26C0:  38840004   addi   r4,r4,4
800B26C4:  4BFFFFE4   b   0x800b26a8
800B26C8:  806D8C48   lwz   r3,-29624(r13) # Crash
800B26CC:  57A0103A   rlwinm   r0,r29,2,0,29
800B26D0:  7FE3002E   lwzx   r31,r3,r0
800B26D4:  2C1F0000   cmpwi   r31,0
800B26D8:  4182004C   beq-   0x800b2724
800B26DC:  2C1D0004   cmpwi   r29,4
800B26E0:  4081001C   ble-   0x800b26fc
800B26E4:  B3AD8C3C   sth   r29,-29636(r13)
800B26E8:  480051C9   bl   0x800b78b0
800B26EC:  908D8C44   stw   r4,-29628(r13)
800B26F0:  906D8C40   stw   r3,-29632(r13)
800B26F4:  801E0198   lwz   r0,408(r30)
800B26F8:  900D8C38   stw   r0,-29640(r13)
800B26FC:  480034E5   bl   0x800b5be0
800B2700:  7FECFB78   mr   r12,r31
800B2704:  7FA3EB78   mr   r3,r29
800B2708:  7FC4F378   mr   r4,r30
800B270C:  7D8903A6   mtctr   r12
800B2710:  4E800421   bctrl   
800B2714:  4800350D   bl   0x800b5c20
800B2718:  48003A29   bl   0x800b6140
800B271C:  7FC3F378   mr   r3,r30
800B2720:  4BFFB381   bl   0x800adaa0
800B2724:  7FC3F378   mr   r3,r30
800B2728:  4BFFB379   bl   0x800adaa0
800B272C:  80010024   lwz   r0,36(r1)
800B2730:  83E1001C   lwz   r31,28(r1)
800B2734:  83C10018   lwz   r30,24(r1)
800B2738:  83A10014   lwz   r29,20(r1)
800B273C:  7C0803A6   mtlr   r0
800B2740:  38210020   addi   r1,r1,32
800B2744:  4E800020   blr   
[/spoiler]
My Wii hacking site...
http://bullywiihacks.com/

My youtube account with a lot of hacking videos...
http://www.youtube.com/user/BullyWiiPlaza

~Bully

Stuff

I guess this is related. MH3 uses 16 bit color for armor and probably hair and clothes. But the game does this

[spoiler][/spoiler]

I read about 16 bit color and they could be
Quote5 bits for red, 6 bits for green, and 5 bits for blue
It would probably make the most sense, but one bit for alpha might be cool.

It's just that I'm not sure how these colors work, and I want to put a rgb text display that would also allow you to do the rgb thing that MHFU had. You know. Scrolling the rgb colors instead of having this...this.
.make Stuff happen.
Dropbox. If you don't have one, get it NOW! +250MB free if you follow my link :p.

Mod code Generator ~50% complete but very usable:
http://dl.dropbox.com/u/24514984/modcodes/modcodes.htm