WiiRd forum

Wii & Gamecube Hacking => Wii Game hacking help => Topic started by: dcx2 on August 15, 2010, 06:53:58 AM

Title: Rainbow Code for all games
Post by: dcx2 on August 15, 2010, 06:53:58 AM
This code is designed to complement a color code for any game.  You should understand how to create an RGBA color value before trying to use this code.

Each color channel (red, green, blue, or alpha) can be independently controlled.  There is a min value and a max value.  The color value will bounce between the two, at a rate defined by a delta value.  When a max or min is reached, the sign is changed.  It stores the generated color in a gecko register.  So you can use multiple color codes by using modified copies of the code that write to additional gr's.  Since it is a C0 code, it will work for any game.

As usual, compile with PyiiASMH.  This particular code uses a min that is a dark purple and a max that is a bright purple.  Alpha and green are not modified.  Red and blue are changed by 5 each frame.  The actual value includes a little bit of green to balance out the brightness.  The code might make more sense if you watch it in Memory Viewer with auto-update.

---


.set GR,2
.set MIN,MIN_OFFSET-DATA_POINTER_BASE
.set MAX,MAX_OFFSET-DATA_POINTER_BASE
.set DELTA,DELTA_OFFSET-DATA_POINTER_BASE
.set VALUE,VALUE_OFFSET-DATA_POINTER_BASE

mflr r12      # back up current LR
bl SKIP_DATA

DATA_POINTER_BASE:
MIN_OFFSET: .long 0x690069FF
MAX_OFFSET: .long 0xFF00FFFF
DELTA_OFFSET: .long 0x05000500
VALUE_OFFSET: .long 0x694069FF

SKIP_DATA:
mflr r3         # data pointer is in r3
mtlr r12      # restore LR

TOP_OF_LOOP:
lbz r12,VALUE(r3)
lbz r11,DELTA(r3)
extsb r11,r11      # sign extend in case delta is negative
add r12,r12,r11   # inc/dec
stb r12,VALUE(r3)
lbz r10,MIN(r3)
cmpw r12,r10   # are we at the min?
beq- CHANGE_DIRECTION   # Note: try changing this to ble-
lbz r10,MAX(r3)
cmpw r12,r10   # are we at the max?
bne- SKIP_CHANGE   # Note: try changing this to blt-
CHANGE_DIRECTION:
neg r11,r11      # change sign of delta
stb r11,DELTA(r3)
SKIP_CHANGE:
addi r3,r3,1      # point to next byte
andi. r10,r3,3      # when we roll over to next word, stop
bne+ TOP_OF_LOOP

lwz r12,VALUE-4(r3)   # account for the changes made to r3 with -4
stw r12,GR*4(r7)      # put color value into GR

---

Here's the assembled code.  Notice that the third and fourth lines correspond to min/max/delta/value.

C0000000 0000000E
7D8802A6 48000015
690069FF FF00FFFF
05000500 694069FF
7C6802A6 7D8803A6
8983000C 89630008
7D6B0774 7D8C5A14
9983000C 89430000
7C0C5000 41820010
89430004 7C0C5000
4082000C 7D6B00D0
99630008 38630001
706A0003 4082FFC4
81830008 91870008
4E800020 00000000
Title: Re: Rainbow Code for all games
Post by: xcoopa on August 19, 2010, 03:36:22 AM
Very Cool