Coding Questions and other Quandaries
Btw Hackwiz, for making a C2 code on a address where its instruction value can change (due to module loading), you can throw a simple conditional on top of the C2 code like this..

#Example, you want to hook a C2 code @ 0x8045678C whenever its instruction is 0x901E0000.
2045678C 901E0000
C245678C 000000xx
E0000000 80008000

This should work even if a new module load rewrites in a new different instruction at your Hook. Because once the Code Handler gets executed again after that, it will *not* apply the C2 code because the instruction no longer equals 0x901E0000
That's what I was working on last night. It works... to an extent.
There are two addresses involved in modding characters. One in MEM1 and the other in MEM2.
The character values aren't a straight up simple 0x0 -> 0x11 for both of these addresses:


Mario 0x0/0x0
Luigi 0x1/0x1
Peach 0x2/0x2
Daisy 0x3/0x3
Wario 0x5/0x4
Waluigi 0x6/0x5
Yoshi 0x4/0x6
Koopa Troopa 0xB/0x7
Donkey Kong 0x7/0x8
Diddy Kong 0x9/0x9
Boo 0xC/0xA
Shy Guy 0xA/0xB
Bowzer 0x8/0xC
Bowzer Jr. 0xD/0xD
Fly Guy 0xE/0XE
Paratroopa 0xF/0xF
Wiggler 0x10/0x10
Petey Piranha 0x11/0x11

I used the character value rotator (minus the Mii value) used in Mario Sports Mix. (See Above)
Added another C0 code to pick up on the value from that address which is constantly cycling 0x0 -> 0x11
and correct as necessary to store in the MEM1 address:

lis r11, 0x8000
lhz r12, 976(r11) #ASM This is loading the 0x0 -> 0x11 character value rotator from EVA; this value to be stored in MEM2
cmpwi r12, 0x4 #ASM Comparing that value with ones that have different values in MEM1
addi r5, r12, 0x1 #ASM Make the proper adjustment needed and hold in r5
beq- change_it #ASM If it is one of the odd ball values, branch to change_it
cmpwi r12, 0x5
addi r5, r12, 0x1
beq- change_it
cmpwi r12, 0x6
subi r5, r12, 0x2
beq- change_it
cmpwi r12, 0x7
addi r5, r12, 0x4
beq- change_it
cmpwi r12, 0x8
subi r5, r12, 0x1
beq- change_it
cmpwi r12, 0xA
addi r5, r12, 0x2
beq- change_it
cmpwi r12, 0xB
subi r5, r12, 0x1
beq- change_it
cmpwi r12, 0xC
subi r5, r12, 0x4
bne- store_it

mr r12, r5

stw r12, 980(r11)

This works fine as it is, although I want to add it to the first C0 code and hopefully lessen the length.

Made a simple button activator. Press C + Z after selecting a player. The character name changes as the character values change (no transformation though).
Release the buttons when the one you want is displayed then move on tho the next Player/Com.

Works great until you decide to quit a match and return to the main screen. The next time you enter the character selection screen, the pointer for the MEM2 address
does not update, (MEM1 is correct). Could be the module moved (?????)

Neat challenge.
I'm not sure what exactly you are doing with your code, but anyway....

Because the lefthand (MEM1) byte values that you've listed don't increase in perfect order, you can place those in a lookup table and use the righthand (MEM2) byte values as a loading offset in reference to the able

Adjust source so you can add the other things your code is suppose to do ofc

#Set EVA Upper
lis r11, 0x8000

#EVA Notes
#800003D0 = Byte for MEM1
#800003D1 = Byte for MEM2

#Load MEM2 char integer byte value
#Increment, check if its beyond max (0x11)
lbz r12, 0x3D1 (r11)
addi r12, r12, 1
cmplwi r12, 0x11
ble+ create_table

#Reset MEM1 and MEM2 bytes to Mario, then Store and end C0
li r10, 0
li r12, 0
b store_bytes

#Create the Table, but first backup C0 LR
mflr r5

bl table
.byte 0x00 #Mario #Still needed in table for spacing so all other offset values will work in the lbzx instruction
.byte 0x01 #Luigi
.byte 0x02 #Peach
.byte 0x03 #Daisy
.byte 0x05 #Wario
.byte 0x06 #Waluigi
.byte 0x04 #Yoshi
.byte 0x0B #Koopa
.byte 0x07 #Donkey kong
.byte 0x09 #Diddy
.byte 0x0C #Boo
.byte 0x0A #Shy Guy
.byte 0x08 #Bowser
.byte 0x0D #BowserJr
.byte 0x0E #Fly Guy
.byte 0x0F #Para
.byte 0x10 #Wiggler
.byte 0x11 #Piranha
.align 2
mflr r9

#Now based on newly incremented MEM2 value, load up byte value for MEM1
lbzx r10, r9, r12

#Restore LR
mtlr r5

#Store MEM1 and MEM2 bytes to EVA
stb r10, 0x3D0 (r11)
stb r12, 0x3D1 (r11)

#End C0

For compiled length comparisons here is my vs your source
C0000000 0000000B
3D608000 898B03D1
398C0001 280C0011
40A10010 39400000
39800000 4800002C
7CA802A6 48000019
00010203 0506040B
07090C0A 080D0E0F
10110000 7D2802A6
7D4960AE 7CA803A6
994B03D0 998B03D1
4E800020 00000000

C0000000 0000000F
3D608000 A18B03D0
2C0C0004 38AC0001
41820058 2C0C0005
38AC0001 4182004C
2C0C0006 38ACFFFE
41820040 2C0C0007
38AC0004 41820034
2C0C0008 38ACFFFF
41820028 2C0C000A
38AC0002 4182001C
41820010 2C0C000C
38ACFFFC 40820008
7CAC2B78 918B03D4
4E800020 00000000

Forum Jump:

Users browsing this thread: 1 Guest(s)