Mii Tag Name Changer
#2
Q - Would you say I am not quite ready to make a code yet an should reread the ASM tutorials or is it the case that I just need some practice?

A- I say you are ready. When learning any ASM to make codes, you will hit a lot of mental barriers per say. You will get stuck on a specific step for a while, then sort of out of nowhere, you will get a lightbulb-over-your-head moment. Then realize that the step you were on was actually easy. I personally got stuck on so many tasks when Star was teaching me ASM over a year ago.

Here's my attempt to explain each step of the source for you and why certain instructions+values were written. Read through this slowly.

Mii Names are done in ASCII. Look up ASCII to hex/hex to ASCII converter. Example: 0x30 equals 0

However with MKWii (to incorporate Japanese letters, and special symbols), the game uses 16 bit ASCII (halfwords) instead of 8 bit (bytes).

What does this mean? 0x0030 = 0 (Each ASCII Mii name character is a halfword in length)

Source (0123456789 used as the Mii Name):

So the Mii name in hex for the source is this 0030 0031 0032 0033 0034 0035 0036 0037 0038 0039

Each two ASCII characters take one word of space in memory. The whole Mii name is 5 words in length



Here's the source with better notes....

lis r4, 0x0030 #As you can see we first set the very first ASCII character of the name. We set this to the upper 16 bits of the register, because we want to store one word at a time to keep this code efficient instead of storing halfword after halfword

ori r4, r4, 0x0031 #Next we set the next ASCII character in the same register. Now r4 = 00300031
stw r4, 0x2 (r30) #r30 is like our memory pointer, it is in reference to where in dynamic memory we have to store our ASCII characters to, it's r30 due to the default instruction (founded by the Read BP) below. We store 00300031 to dynamic memory.

lis r4, 0x0032 #Now we continue to set the 3rd ASCII character, we can use r4 again because we already stored the previous two characters
ori r4, r4, 0x0033 #For 4th ASCII character
stw r4, 0x6 (r30) #Store 3rd & 4th ASCII characters to dynamic memory. Notice how the offset value in this stw instruction is bumped up to 0x6 instead of being 0x2? That's because we already stored the first word. A word is 4 bytes in length. So we increase the offset by 0x4 everytime we store a new word for the Mii name

lis r4, 0x0034 
ori r4, r4, 0x0035 
stw r4, 0xA (r30) #0x6 + 0x4 = 0xA

lis r4, 0x0036 
ori r4, r4, 0x0037 
stw r4, 0xE (r30) #0xA + 0x4 = 0xE

lis r4, 0x0038 
ori r4, r4, 0x0039 
stw r4, 0x12 (r30)  #0xE + 0x4 = 0x12

lhz r4, 0 (r30) #Default instruction; At this point you are probably confused why the default instruction loads the halfword value with no offset. Well with Mii data, there is a halfword (0x2) of other data that comes before the start of the mii name. In this instruction the game is loading all the Mii data. Thus it starts at the very beginning of the data. 




r30 directly points to that beginning. So the start of the mii name is 0x2 in reference to r30. Hence why the very first stw instruction above is stw r4, 0x2 (r30)

In regards to register safety: we can use r4, because a value is loaded into it anyway by the default instruction at the very end of the source.

Visual example: Launch Dolphin. Go to Options, then Hotkey settings. Under General tab, set an unused key (I use '9') for Toggle Pause. Go to Debugging tab, set an unused key (I use 'M') for Step Into. Save and close window.

You're PAL right? Apply the PAL code in the cheat manager of your dolphin. Launch the game, the moment it launches to the wii remote boot strap screen, pause the emulation (using w/e hotkey you set for Toggle Pause). Set an Instruction BP to 800C6DD8. I can't exactly remember, but I think the address will break after the wii remote screen, or right before you see the licenses.

The game will pause due to the BP. You are at the code's address (but there's a branch instruction instead of the default instruction). Open up Aldelaro5's ram viewer. Make sure you can see the Code View, Registers, and the RAM viewer all at once. Now, press your hotkey for Step-Into. You will branch to an area in memory around 0x800022A0 (can't exactly remember). You are at the subroutine that the gecko code handler has created for the ASM code. Now to step to each next instruction, just press your hotkey again. And watch the registers, plus the RAM viewer while you are stepping. 

This is called step-by-step testing, which is a very good visual aid to debug/analyze an ASM Code.

Hopefully this will help you  Smile And then you can work on the code you described.
Reply


Messages In This Thread
Mii Tag Name Changer - by KartPlayer - 08-04-2019, 09:11 AM
RE: Mii Tag Name Changer - by Vega - 08-04-2019, 01:34 PM
RE: Mii Tag Name Changer - by KartPlayer - 08-04-2019, 02:06 PM
RE: Mii Tag Name Changer - by KartPlayer - 08-08-2019, 06:20 PM
RE: Mii Tag Name Changer - by Vega - 08-08-2019, 06:34 PM
RE: Mii Tag Name Changer - by Dorian - 08-08-2019, 07:07 PM
RE: Mii Tag Name Changer - by Vega - 08-08-2019, 07:20 PM
RE: Mii Tag Name Changer - by KartPlayer - 08-09-2019, 06:26 PM
RE: Mii Tag Name Changer - by Vega - 08-09-2019, 08:03 PM
RE: Mii Tag Name Changer - by KartPlayer - 08-10-2019, 07:13 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)