• 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!

Melee Gecko Codes + Guide and Discussion

Absolome

Smash Cadet
Joined
Jan 3, 2014
Messages
68
Location
Asheville, NC
Do any of you have a full list of subaction IDs for each character? (or it might be animation IDs that I need, not sure). Do animation IDs ever overlap between characters?
 

Vegerot

Smash Apprentice
Joined
Nov 3, 2013
Messages
86
Location
Baltimore, Maryland
0x93006000-0x93008000 = cheats path
Nintendont fixes the EXI calls, so the only things that won't work are controller-based and C types.

Code:
_hook_addresscheck:

    cmpwi    cr4,r5,3
    bgt-    cr4,_addresscheck1    #lf sub code type ==6 or 7
    lis    r5,0x4800
    add    r12,r3,r12
    rlwinm    r12,r12,0,0,29        #align address

    bne-    cr4,_hook1        #lf sub code type ==2

_hook2:
    bne-    cr7,_readcodes

    rlwinm    r4,r26,0,0,29        #address &=0x01FFFFFC

    sub    r4,r4,r12        #r4 = to-from
    rlwimi    r5,r4,0,6,29        #r5  = (r4 AND 0x03FFFFFC) OR 0x48000000
    rlwimi    r5,r3,0,31,31        #restore lr bit
    stw    r5,0(r12)        #store opcode
    b    _readcodes
This is a snippet of one of the broken portions. It's caused by the "to - from".
Would injecting codes into the .dol fix this issue?

Last year, Dan Salvato @Dan Salvato said he would release the 20xxTE source code when the 20xxTE memory cards were mailed out; he has yet to do so.

Because of this, I was hoping if people here could provide me with some codes from 20xxTE (hoping these specific codes were taken from elsewhere). Does anybody know the codes for: Toggle Frozen Mode, Unfreeze Game End, and Input Display.

If somebody knows one of these codes, I'd appreciate it. I'm pretty sure Salvato came up with Input Display himself, so I don't except to be given that. Hoping the other two were written publicly by others.
 
Last edited:

SinsOfApathy

Smash Journeyman
Joined
Feb 24, 2015
Messages
474
NNID
Psion312
Would injecting codes into the .dol fix this issue?
Yes.

Last year, Dan Salvato @Dan Salvato said he would release the 20xxTE source code when the 20xxTE memory cards were mailed out; he has yet to do so.

Because of this, I was hoping if people here could provide me with some codes from 20xxTE (hoping these specific codes were taken from elsewhere). Does anybody know the codes for: Toggle Frozen Mode, Unfreeze Game End, and Input Display.

If somebody knows one of these codes, I'd appreciate it. I'm pretty sure Salvato came up with Input Display himself, so I don't except to be given that. Hoping the other two were written publicly by others.
I don't remember Dan saying that. Just that it would be released at some point down the road.

But no, those particular codes are ones he wrote.
 

SinsOfApathy

Smash Journeyman
Joined
Feb 24, 2015
Messages
474
NNID
Psion312
Thanks. And how do I go about injecting the codes into the .dol?
Find empty memory locations using our spreadsheet, insert the codes, then create branches to the codes at the locations of the C2 injection point, then create branches back to the injection point + 4. There's explanations of that at http://smashboards.com/threads/assembly-guides-resources-q-a.397941/ as "DOL Mod Tutorial."

There's obviously more ways, but they'd take time to explain and actually require writing the code.
 

Zeus_Da_master

Smash Journeyman
Joined
Jan 22, 2007
Messages
298
Location
Atlanta Ga
More specifically? Also, there's tons of people here—not just us—that can help!
I have quite a few codes that i'd like, ive been asking around and posting but haven't received any help yet. mainly what i'm looking for right now is for custom sounds that i put in the game to play when "x" happens in a match

and in battlefield, that warping and blurring going on in the backgroud, i'd like to turn that down a little so you can make out more what the background is
 
Last edited:

LuckyCandy7

Smash Apprentice
Joined
Jul 16, 2014
Messages
145
Location
Pittsburgh
NNID
LuckyCandy7
Is there any gecko code for the Costume Dependent Marth Swing Sword Colors that works with Dolphin 5.0? The current code seems to crash Dolphin.
 

SinsOfApathy

Smash Journeyman
Joined
Feb 24, 2015
Messages
474
NNID
Psion312
Is there any gecko code for the Costume Dependent Marth Swing Sword Colors that works with Dolphin 5.0? The current code seems to crash Dolphin.
If it's crashing, it's solely because the Netplay code is active (or a lot of other codes) and it's using up almost all the codespace.

However, that Marth Code is unoptimized. I reduced it by 3 lines just looking at it, and could see at least 5 more just by changing some math. I don't know how much space is available though atm, but if I can look at it later and make the savings for you, I will.

Edit: LuckyCandy7 LuckyCandy7 I rewrote the code and tested it on Dolphin 5.0. It's working fine without Netplay Codes on.

Netplay Community Settings leaves literally 2 lines of code space, which makes it physically impossible to run other codes with it currently.
 
Last edited:

DRGN

Technowizard
Moderator
Joined
Aug 20, 2005
Messages
2,178
Location
Sacramento, CA
Thanks. And how do I go about injecting the codes into the .dol?
Find empty memory locations using our spreadsheet, insert the codes, then create branches to the codes at the locations of the C2 injection point, then create branches back to the injection point + 4. There's explanations of that at http://smashboards.com/threads/assembly-guides-resources-q-a.397941/ as "DOL Mod Tutorial."

There's obviously more ways, but they'd take time to explain and actually require writing the code.
There is also the Melee Code Manager, which handles the branch insertion/calculations, code placement, and more for you. I'm currently working on a big update to it which should make it even more convenient for working on codes.
 

flieskiller

Smash Journeyman
Joined
Jan 3, 2013
Messages
426
Vegerot Vegerot see what i mean? everyone just bypasses me
They skip your requests because they're too specific, or the results are not worth the efforts. Assembly programming has a lot of limits in term of novelty. It's easily possible to modify something, but making somethng new is waaaay harder.

"mainly what i'm looking for right now is for custom sounds that i put in the game to play when "x" happens in a match"

I'm sure almost no one searched how to add new sounds (only replacing existing sounds), and then playing that sound with a function listed here: https://docs.google.com/spreadsheets/d/1JX2w-r2fuvWuNgGb6D3Cs4wHQKLFegZe2jhbBuIhCG8/edit#gid=19 . Adding a sound is surely not just adding a file to the iso and magically playing it in-game at the moment you want.

Both points above make that people tend to focus more on what they can do on the spot or what they really want to create in the game. Sometimes, I create some codes of some requests because I know how to do it based on my experience and it will make someone happy, but I don't feel like learning something that can take dozens of hours to learn for something that I won't even enjoy using after that.

If someone wants to help you for your goals, that's fine, but don't whine if you suspect anything can be done in assembly and no one wants to help you that only you have interest in.
 

Zeus_Da_master

Smash Journeyman
Joined
Jan 22, 2007
Messages
298
Location
Atlanta Ga
They skip your requests because they're too specific, or the results are not worth the efforts. Assembly programming has a lot of limits in term of novelty. It's easily possible to modify something, but making somethng new is waaaay harder.

"mainly what i'm looking for right now is for custom sounds that i put in the game to play when "x" happens in a match"

I'm sure almost no one searched how to add new sounds (only replacing existing sounds), and then playing that sound with a function listed here: https://docs.google.com/spreadsheets/d/1JX2w-r2fuvWuNgGb6D3Cs4wHQKLFegZe2jhbBuIhCG8/edit#gid=19 . Adding a sound is surely not just adding a file to the iso and magically playing it in-game at the moment you want.

Both points above make that people tend to focus more on what they can do on the spot or what they really want to create in the game. Sometimes, I create some codes of some requests because I know how to do it based on my experience and it will make someone happy, but I don't feel like learning something that can take dozens of hours to learn for something that I won't even enjoy using after that.

If someone wants to help you for your goals, that's fine, but don't whine if you suspect anything can be done in assembly and no one wants to help you that only you have interest in.
well thanks for explaining, wasn't whining just wondering why my questions weren't answered... i understand the replacing sounds and all, but you say that you can't add sounds in. didn't achilles do that in 4.05? didn't he add new music?

you say its too specific but they added the sound for when you auto cancel/v-cancel; same as flashing red when you miss an L-cancel. also the "cheer" plays when "x" happens in a match. so wouldn't that mean that part of the code i need is already there?

and trust me, a lot of ppl are going to want these codes, its not something that only i have interest in. i already have a bunch of ppl wanting a copy of my setup but i told them not til its done and i need these codes to finish it.
 

LuckyCandy7

Smash Apprentice
Joined
Jul 16, 2014
Messages
145
Location
Pittsburgh
NNID
LuckyCandy7
If it's crashing, it's solely because the Netplay code is active (or a lot of other codes) and it's using up almost all the codespace.

However, that Marth Code is unoptimized. I reduced it by 3 lines just looking at it, and could see at least 5 more just by changing some math. I don't know how much space is available though atm, but if I can look at it later and make the savings for you, I will.

Edit: LuckyCandy7 LuckyCandy7 I rewrote the code and tested it on Dolphin 5.0. It's working fine without Netplay Codes on.

Netplay Community Settings leaves literally 2 lines of code space, which makes it physically impossible to run other codes with it currently.
Oh, ok. That makes sense. Thanks for the help, though.
 

Brandondorf9999

Smash Cadet
Joined
Mar 6, 2012
Messages
71
Yesterday, I found an offset for the alpha blending functions that is not on the list and it's called "GXSetBlendMode" that hasn't been generated by Dolphin's generate symbol map.

Code:
0x80340c3c - SYS_GXSetBlendMode
 

Kadano

Magical Express
Joined
Feb 26, 2009
Messages
2,160
Location
Vienna, Austria
"Smash Turn" being this mechanic: http://www.meleeitonme.com/back-dashes-smash-turns/

Flash Blue on Missed Smash Turn (v1.00) [Magus]
C20C9790 0000000F
A11E0448 2C084000
40820064 811E23A8
2C080000 41820058
811E23B0 2C080000
4182004C 3CE042C0
3D00437F 39200000
90FE0518 90FE051C
911E0520 913E0528
913E052C 913E0530
3CE0C200 3D00C280
39200091 3D406060
614AFFE0 90FE0524
911E0534 993E0564
915E0514 801F2358
60000000 00000000
Have you (or anyone else) used this code successfully in console?

I just put it on an SD card into /codes/GALE01.gct (using Gecko Cheat Code Manager 1.2 to convert from text to .gct) and when launching the game (edit: with Nintendont), it freezes whenever I start the turn animation. Since it always freezes at exactly the frame where your code should start, it seems to me that the code is incompatible with console?

In Dolphin, it works fine for me (same iso, same code – both 1.00).
 
Last edited:

Achilles1515

Smash Master
Joined
Jun 18, 2007
Messages
3,211
Location
Cincinnati / Columbus OH
Have you (or anyone else) used this code successfully in console?

I just put it on an SD card into /codes/GALE01.gct (using Gecko Cheat Code Manager 1.2 to convert from text to .gct) and when launching the game, it freezes whenever I start the turn animation. Since it always freezes at exactly the frame where your code should start, it seems to me that the code is incompatible with console?

In Dolphin, it works fine for me (same iso, same code – both 1.00).
Dios Mios or Nintendont?
 

Magus420

Smash Master
Joined
Dec 13, 2003
Messages
4,541
Location
Close to Trenton, NJ Posts: 4,071
Older versions of Nintendont likely work if it's the same issue as sending codes through USB gecko. I can test C2 codes in v3.305 but not in v3.371, because the code list is @800027D0 for the former and @93006000 for the latter (too far away to branch C2 hook<->Code list).
 

Kadano

Magical Express
Joined
Feb 26, 2009
Messages
2,160
Location
Vienna, Austria
C2 injection Gecko codes don't work with Nintendont. You'll need to use Dios Mios or inject the code into the ISO.
Thanks, I got it to work with Dios Mios Lite. It would be nice if these codes worked with Nintendont, because DML takes so much longer to load and also has much longer load times in-game (at least when launching games from the SD card) than Nintendont, but as long as I can test smash turns at all, it's fine.

Older versions of Nintendont likely work if it's the same issue as sending codes through USB gecko. I can test C2 codes in v3.305 but not in v3.371, because the code list is @800027D0 for the former and @93006000 for the latter (too far away to branch C2 hook<->Code list).
Thank you, so I can simply put Nintendont v3.305 in /apps/ and it should work? I'll try that.
 
Last edited:

Magus420

Smash Master
Joined
Dec 13, 2003
Messages
4,541
Location
Close to Trenton, NJ Posts: 4,071
I'm unfamiliar with loading codesets with it, but yeah I just keep a 'Nintendont v3.305' folder and a 'Nintendont v3.371' folder in \apps. v3.305 doesn't have read rate limiting or something like that which sometimes causes game music to cut out after a second or 2 so I keep both on there.
 

SinsOfApathy

Smash Journeyman
Joined
Feb 24, 2015
Messages
474
NNID
Psion312
ASM hook support was fixed in Nintendont like 12 commits ago, fyi. Debugging was also addressed, as was PADRead.
 
Last edited:

Kadano

Magical Express
Joined
Feb 26, 2009
Messages
2,160
Location
Vienna, Austria
ASM hook support was fixed in Nintendont like 12 commits ago, fyi. Debugging was also addressed, as was PADRead.
Thanks, I've read that in the patch notes before too and tried to get it to work, but failed for many attempts.

I got it to work now with the newest version of Nintendont from their github page (v4.421). GCT file with Magus' missed smash turn display code set to active is attached to this post. (Just remove the .txt at the end that I added so I could attach it, put it into /codes/ on the SD card and enable Cheats in Nintendont settings.)
 

Attachments

Last edited:

Punkline

Dr. Frankenstack
Joined
May 15, 2015
Messages
423
Do any of you have a full list of subaction IDs for each character? (or it might be animation IDs that I need, not sure). Do animation IDs ever overlap between characters?
I’m assuming you’re talking about internal player data offset 0x14? Right next to the actionstate ID? Sorry if this is too late to be of use (I haven’t been on very much lately)

I don’t have a full list, but a long while back I was looking pretty carefully at B-special action states and their corresponding “animation state” IDs. They both change pretty consistently with action state changes, but animation states sometimes seem to linger between some action states.

They do in fact overlap, and by quite a bit. The index seems to split at a threshold dividing common and uncommon action state IDs at 0x155. For animation state IDs it’s 0x127. Any unique move (like a B-special, or weird stuff like kirby multi-jumps) has an ID assigned beyond this threshold, and varies between character.

I took some notes about these uncommon states, but they’re all by hand so I apologize for any typos.

There are a few I missed in there, but they’re predictable because of the gaps in the index. I also completely skipped Kirby’s transformed B attacks.

---

just wondering why my questions weren't answered...
Just thought I’d throw in that (in my case, anyway) passing up a request is largely a matter of not being able to contribute in a meaningful way.

I’m not an authority on Melee sound effects, and much less on adding custom assets to the game. I can’t even tell you if it’s possible or not without potentially misinforming you; let alone how to do it, and much less if it’d be easy enough to throw together at the snap of a finger.

---

That said, one thing you might consider in order to get this code project off the ground is to try adopting it yourself. Attempting to understand the finer details of what you’re asking might help you better phrase your questions in ways that yield useful answers from the community.

Every code written here is in some form or another designed around exploiting existing mechanics. There’s a lot of discovery involved in trying to get things to do what you want, and it’s usually not as simple as you’d expect it to be unless you have already thoroughly explored what you’re modifying.

I have no idea where to even begin with appending custom sounds. At the moment, I’m still trying to figure out how Melee plays some of its own sounds already on disk.

So my best advice is to think more about how you’re going to eat this elephant. Where do these custom sounds live? How does the code know where they are? How does the code load these sounds? When does it load these sounds? How does the game reference a loaded sound in memory? Is it replacing other SFX IDs? Where/when are you planning on checking “x” conditions for these sounds to play? What exactly are these conditions? Does it all fit together? Are you messing anything else up with this new structure? How big is the resulting code that does all this?
 

Zeus_Da_master

Smash Journeyman
Joined
Jan 22, 2007
Messages
298
Location
Atlanta Ga
I’m assuming you’re talking about internal player data offset 0x14? Right next to the actionstate ID? Sorry if this is too late to be of use (I haven’t been on very much lately)

I don’t have a full list, but a long while back I was looking pretty carefully at B-special action states and their corresponding “animation state” IDs. They both change pretty consistently with action state changes, but animation states sometimes seem to linger between some action states.

They do in fact overlap, and by quite a bit. The index seems to split at a threshold dividing common and uncommon action state IDs at 0x155. For animation state IDs it’s 0x127. Any unique move (like a B-special, or weird stuff like kirby multi-jumps) has an ID assigned beyond this threshold, and varies between character.

I took some notes about these uncommon states, but they’re all by hand so I apologize for any typos.

There are a few I missed in there, but they’re predictable because of the gaps in the index. I also completely skipped Kirby’s transformed B attacks.

---



Just thought I’d throw in that (in my case, anyway) passing up a request is largely a matter of not being able to contribute in a meaningful way.

I’m not an authority on Melee sound effects, and much less on adding custom assets to the game. I can’t even tell you if it’s possible or not without potentially misinforming you; let alone how to do it, and much less if it’d be easy enough to throw together at the snap of a finger.

---

That said, one thing you might consider in order to get this code project off the ground is to try adopting it yourself. Attempting to understand the finer details of what you’re asking might help you better phrase your questions in ways that yield useful answers from the community.

Every code written here is in some form or another designed around exploiting existing mechanics. There’s a lot of discovery involved in trying to get things to do what you want, and it’s usually not as simple as you’d expect it to be unless you have already thoroughly explored what you’re modifying.

I have no idea where to even begin with appending custom sounds. At the moment, I’m still trying to figure out how Melee plays some of its own sounds already on disk.

So my best advice is to think more about how you’re going to eat this elephant. Where do these custom sounds live? How does the code know where they are? How does the code load these sounds? When does it load these sounds? How does the game reference a loaded sound in memory? Is it replacing other SFX IDs? Where/when are you planning on checking “x” conditions for these sounds to play? What exactly are these conditions? Does it all fit together? Are you messing anything else up with this new structure? How big is the resulting code that does all this?
I can write it in English all day long. Heres an example – Suicide audio

(the game already counts and recognizes suicides)
So with that said, add “sound 01” into ifall.xx file (or something like that)
When the game registers a suicide happening, instead of playing death sound, it plays “sound 01” file

… but sht, with all the new sounds I want to add, we can make a whole new ifall_newsounds.xx file. (making space is no problem)

Sound 02 - knee death
(hypothesis) hits and moves have a number or some sort of identification that the game recognizes ( Achilles1515 Achilles1515 what you think?)
Now we know what to edit the coding of, or add to; we’ll call it move23.
Coding= when move23 hits, check does it kill-no- play regular sound… if yes-play sound 02 from ifall_newsounds.xx file. (or for this particular one, we could add the sound to the cap falcon audio file.ssm
 

whims

Smash Apprentice
Joined
Mar 7, 2016
Messages
100
so i just watched dan salvato's coding tutorials, and i'm experimenting on my own with the convenient google doc and several asm tutorials. i successfully wrote a code that changes the menu music (and only the menu music) to load whatever music i chose; for this instance i loaded green greens. i thought the same method could apply to loading random music: if register 3 = 34 (52 in dec), which is the menu music, when the load music function is occurring (at address 80023F28 in game code), i load the rng function code with 42 possibilities. first i compare r3 with 34; if it isn't 34, skip this whole process. if it is, change register 10 (which is an empty register; i use this instead of register 3 which the rng function normally uses since r3 is already occupied) to 66, which should give 42 random possibilities. i put in the rest of the rng function, replacing all instances of r3 with r10. when this function is complete, it should load a random value between 0 and 42 into r10. (there is probably a more efficient way of coding the rest, but i decided to take the simple inefficient route since i'm not totally familiar with asm yet.) i then compare r10 to all values between 0 and 42, skipping each step if it doesn't equal the given value. if it DOES equal the value, change register 3's value to a certain hps id, since r3 is normally where the game looks for the id # of loading hpses.

i've tested and tested and it crashes dolphin every time without me getting a chance to look at the code. can someone check for minor dumb mistakes for me? and if you have some spare time, a quick explanation of mistakes or etc would be great. i appreciate any help

Code:
cmpwi r3,52
bne- 0x1152
li r10,66
lwz r5,-0x570c(r13)
lis r4,0x0003
addi r0,r4,17405
lwz r4,0(r5)
mullw r4,r4,r0
addis r4,r4,39
subi r0,r4,24893
stw r0,0(r5)
lwz r4,-0x570c(r13)
lwz r0,0(r4)
rlwinm r0,r0,16,16,31
mullw r0,r10,r0
srawi r10,r10,16
addze r10,r10
cmpwi r10,0
bne- 0x8
li r3,27
cmpwi r10,1
bne- 0x8
li r3,04
cmpwi r10,2
bne- 0x8
li r3,66
cmpwi r10,3
bne- 0x8
li r3,33
cmpwi r10,4
bne- 0x8
li r3,50
cmpwi r10,5
bne- 0x8
li r3,34
cmpwi r10,6
bne- 0x8
li r3,75
cmpwi r10,7
bne- 0x8
li r3,97
cmpwi r10,8
bne- 0x8
li r3,51
cmpwi r10,9
bne- 0x8
li r3,96
cmpwi r10,10
bne- 0x8
li r3,95
cmpwi r10,11
bne- 0x8
li r3,49
cmpwi r10,12
bne- 0x8
li r3,35
cmpwi r10,13
bne- 0x8
li r3,06
cmpwi r10,14
bne- 0x8
li r3,84
cmpwi r10,15
bne- 0x8
li r3,64
cmpwi r10,16
bne- 0x8
li r3,65
cmpwi r10,17
bne- 0x8
li r3,56
cmpwi r10,18
bne- 0x8
li r3,03
cmpwi r10,19
bne- 0x8
li r3,60
cmpwi r10,20
bne- 0x8
li r3,31
cmpwi r10,21
bne- 0x8
li r3,29
cmpwi r10,22
bne- 0x8
li r3,42
cmpwi r10,23
bne- 0x8
li r3,43
cmpwi r10,24
bne- 0x8
li r3,44
cmpwi r10,25
bne- 0x8
li r3,40
cmpwi r10,26
bne- 0x8
li r3,30
cmpwi r10,27
bne- 0x8
li r3,57
cmpwi r10,28
bne- 0x8
li r3,59
cmpwi r10,29
bne- 0x8
li r3,58
cmpwi r10,30
bne- 0x8
li r3,77
cmpwi r10,31
bne- 0x8
li r3,74
cmpwi r10,32
bne- 0x8
li r3,63
cmpwi r10,33
bne- 0x8
li r3,01
cmpwi r10,34
bne- 0x8
li r3,55
cmpwi r10,35
bne- 0x8
li r3,61
cmpwi r10,36
bne- 0x8
li r3,07
cmpwi r10,37
bne- 0x8
li r3,02
cmpwi r10,38
bne- 0x8
li r3,80
cmpwi r10,39
bne- 0x8
li r3,81
cmpwi r10,40
bne- 0x8
li r3,78
cmpwi r10,41
bne- 0x8
li r3,83
cmpwi r10,42
bne- 0x8
li r3,38
mflr r0
 
Last edited by a moderator:

whims

Smash Apprentice
Joined
Mar 7, 2016
Messages
100
I can write it in English all day long. Heres an example – Suicide audio

(the game already counts and recognizes suicides)
So with that said, add “sound 01” into ifall.xx file (or something like that)
When the game registers a suicide happening, instead of playing death sound, it plays “sound 01” file

… but sht, with all the new sounds I want to add, we can make a whole new ifall_newsounds.xx file. (making space is no problem)

Sound 02 - knee death
(hypothesis) hits and moves have a number or some sort of identification that the game recognizes ( Achilles1515 Achilles1515 what you think?)
Now we know what to edit the coding of, or add to; we’ll call it move23.
Coding= when move23 hits, check does it kill-no- play regular sound… if yes-play sound 02 from ifall_newsounds.xx file. (or for this particular one, we could add the sound to the cap falcon audio file.ssm
stuff like this would be interesting and i'm willing to look into it later, but coding it at my current level is impossible. i'll put it on my list of things to look into, since i need projects to gain experience, but stuff like this requires lots of reverse engineering, coding, and then there's the adding a new sfx file. idk how to do that currently. so if u wanna send me a list of your requests, i'll attempt to get the more feasible ones done sooner or later
 

SinsOfApathy

Smash Journeyman
Joined
Feb 24, 2015
Messages
474
NNID
Psion312
The crash could be any number of things. For one, you're probably using up the available Gecko code space with some other codes active. Next, that looks like an infinite loop at a glance, or rather, you'll end up running for an insane amount of operations until it goes through all the possible r10 values being equal to their compare and then loading the last ID in the list. Because you never branch to the exit if r10 == value.

Lastly, you could drastically simplify the entirety of the code by using the RNG function to do an inclusive value within the 0 - max music ID range. Odds are, they're all used slots, and the list just isn't finished. Alternatively, write the IDs into an unused region using a separate code or find the list in memory, then use the value in r10 to load from the index in the list.
 
Last edited:

Achilles1515

Smash Master
Joined
Jun 18, 2007
Messages
3,211
Location
Cincinnati / Columbus OH
so i just watched dan salvato's coding tutorials, and i'm experimenting on my own with the convenient google doc and several asm tutorials. i successfully wrote a code that changes the menu music (and only the menu music) to load whatever music i chose; for this instance i loaded green greens. i thought the same method could apply to loading random music: if register 3 = 34 (52 in dec), which is the menu music, when the load music function is occurring (at address 80023F28 in game code), i load the rng function code with 42 possibilities. first i compare r3 with 34; if it isn't 34, skip this whole process. if it is, change register 10 (which is an empty register; i use this instead of register 3 which the rng function normally uses since r3 is already occupied) to 66, which should give 42 random possibilities. i put in the rest of the rng function, replacing all instances of r3 with r10. when this function is complete, it should load a random value between 0 and 42 into r10. (there is probably a more efficient way of coding the rest, but i decided to take the simple inefficient route since i'm not totally familiar with asm yet.) i then compare r10 to all values between 0 and 42, skipping each step if it doesn't equal the given value. if it DOES equal the value, change register 3's value to a certain hps id, since r3 is normally where the game looks for the id # of loading hpses.

i've tested and tested and it crashes dolphin every time without me getting a chance to look at the code. can someone check for minor dumb mistakes for me? and if you have some spare time, a quick explanation of mistakes or etc would be great. i appreciate any help

Code:
cmpwi r3,52
bne- 0x1152
li r10,66
lwz r5,-0x570c(r13)
lis r4,0x0003
addi r0,r4,17405
lwz r4,0(r5)
mullw r4,r4,r0
addis r4,r4,39
subi r0,r4,24893
stw r0,0(r5)
lwz r4,-0x570c(r13)
lwz r0,0(r4)
rlwinm r0,r0,16,16,31
mullw r0,r10,r0
srawi r10,r10,16
addze r10,r10
cmpwi r10,0
bne- 0x8
li r3,27
cmpwi r10,1
bne- 0x8
li r3,04
cmpwi r10,2
bne- 0x8
li r3,66
cmpwi r10,3
bne- 0x8
li r3,33
cmpwi r10,4
bne- 0x8
li r3,50
cmpwi r10,5
bne- 0x8
li r3,34
cmpwi r10,6
bne- 0x8
li r3,75
cmpwi r10,7
bne- 0x8
li r3,97
cmpwi r10,8
bne- 0x8
li r3,51
cmpwi r10,9
bne- 0x8
li r3,96
cmpwi r10,10
bne- 0x8
li r3,95
cmpwi r10,11
bne- 0x8
li r3,49
cmpwi r10,12
bne- 0x8
li r3,35
cmpwi r10,13
bne- 0x8
li r3,06
cmpwi r10,14
bne- 0x8
li r3,84
cmpwi r10,15
bne- 0x8
li r3,64
cmpwi r10,16
bne- 0x8
li r3,65
cmpwi r10,17
bne- 0x8
li r3,56
cmpwi r10,18
bne- 0x8
li r3,03
cmpwi r10,19
bne- 0x8
li r3,60
cmpwi r10,20
bne- 0x8
li r3,31
cmpwi r10,21
bne- 0x8
li r3,29
cmpwi r10,22
bne- 0x8
li r3,42
cmpwi r10,23
bne- 0x8
li r3,43
cmpwi r10,24
bne- 0x8
li r3,44
cmpwi r10,25
bne- 0x8
li r3,40
cmpwi r10,26
bne- 0x8
li r3,30
cmpwi r10,27
bne- 0x8
li r3,57
cmpwi r10,28
bne- 0x8
li r3,59
cmpwi r10,29
bne- 0x8
li r3,58
cmpwi r10,30
bne- 0x8
li r3,77
cmpwi r10,31
bne- 0x8
li r3,74
cmpwi r10,32
bne- 0x8
li r3,63
cmpwi r10,33
bne- 0x8
li r3,01
cmpwi r10,34
bne- 0x8
li r3,55
cmpwi r10,35
bne- 0x8
li r3,61
cmpwi r10,36
bne- 0x8
li r3,07
cmpwi r10,37
bne- 0x8
li r3,02
cmpwi r10,38
bne- 0x8
li r3,80
cmpwi r10,39
bne- 0x8
li r3,81
cmpwi r10,40
bne- 0x8
li r3,78
cmpwi r10,41
bne- 0x8
li r3,83
cmpwi r10,42
bne- 0x8
li r3,38
mflr r0
The branch on your second line of code is going into no man's land.

Start writing your code like the following, because everything in the below example can be parsed by the ASM <> WiiRD Converter and you don't have to manually calculate branch values.

Code:
START:
li r10,0x66  # a comment for this line is...
cmpwi r3,0x10  # check for...
bne-  END

li r3,0x30  # music to play is...

END:
stw r3,0x14(r4)

I'm assuming your code is crashing when it is trying to play the first song. You can set a breakpoint in Dolphin, then stop the game. Then restart the game and your breakpoint will still be active.

So for your example, turn your faulty code off and run the game. Set a breakpoint at your injection line then stop the game. Turn code on. Run game, and breakpoint will still be active. The game will freeze at your line of code, then step through it and figure out the problem.
 

whims

Smash Apprentice
Joined
Mar 7, 2016
Messages
100
The crash could be any number of things. For one, you're probably using up the available Gecko code space with some other codes active. Next, that looks like an infinite loop at a glance, or rather, you'll end up running for an insane amount of operations until it goes through all the possible r10 values being equal to their compare and then loading the last ID in the list. Because you never branch to the exit if r10 == value.

Lastly, you could drastically simplify the entirety of the code by using the RNG function to do an inclusive value within the 0 - max music ID range. Odds are, they're all used slots, and the list just isn't finished. Alternatively, write the IDs into an unused region using a separate code or find the list in memory, then use the value in r10 to load from the index in the list.
i don't have any other gecko codes active; i also didn't realize that i could use "bl" to link functions. all the hps slots are used, but i only listed the ones that are actually stage songs. i think there are a couple more menu songs, but at this point i'm more concerned with figuring out how this works, not necessarily the end result of the code working.

The branch on your second line of code is going into no man's land.

Start writing your code like the following, because everything in the below example can be parsed by the ASM <> WiiRD Converter and you don't have to manually calculate branch values.

Code:
START:
li r10,0x66  # a comment for this line is...
cmpwi r3,0x10  # check for...
bne-  END

li r3,0x30  # music to play is...

END:
stw r3,0x14(r4)

I'm assuming your code is crashing when it is trying to play the first song. You can set a breakpoint in Dolphin, then stop the game. Then restart the game and your breakpoint will still be active.

So for your example, turn your faulty code off and run the game. Set a breakpoint at your injection line then stop the game. Turn code on. Run game, and breakpoint will still be active. The game will freeze at your line of code, then step through it and figure out the problem.
the bne- is meant to skip all the values if the menu song (which will be 52, or 0x34, loaded into r3) isn't loaded. obviously this doesn't work as it's crashing my dolphin but did i get a value wrong? does it just not work logically?

thanks for the dolphin breakpoint tip. should have done that earlier lol

still troubleshooting, i really appreciate the pointers
 
Last edited:

SinsOfApathy

Smash Journeyman
Joined
Feb 24, 2015
Messages
474
NNID
Psion312
i don't have any other gecko codes active; i also didn't realize that i could use "bl" to link functions. all the hps slots are used, but i only listed the ones that are actually stage songs. i think there are a couple more menu songs, but at this point i'm more concerned with figuring out how this works, not necessarily the end result of the code working.

still troubleshooting, i really appreciate the pointers
It's quite likely what Achilles pointed out. Your first branch is going off into the sunset, never to be seen again. So the PC is pointing to some garbage address that the console tries to run and subsequently crashes.
 

whims

Smash Apprentice
Joined
Mar 7, 2016
Messages
100
It's quite likely what Achilles pointed out. Your first branch is going off into the sunset, never to be seen again. So the PC is pointing to some garbage address that the console tries to run and subsequently crashes.
wait, ok. i stepped through the code, and what i didn't realize is that the gecko codes are located way down the line. my bne- branches 0x16 down, since the menu music isn't loaded, instead of branching back to the main line of code. i think i need to link it back somehow. awesome glad to have progress
 

Achilles1515

Smash Master
Joined
Jun 18, 2007
Messages
3,211
Location
Cincinnati / Columbus OH
wait, ok. i stepped through the code, and what i didn't realize is that the gecko codes are located way down the line. my bne- branches 0x16 down, since the menu music isn't loaded, instead of branching back to the main line of code. i think i need to link it back somehow. awesome glad to have progress
Gecko C2 codes automatically place a branch back after the last line in the code.
Code:
cmpwi r3,52
bne- 0x1152       # <---- where did you get this branch value?!?!? There is no way this is right.
li r10,66
....
Just change into this:

Code:
cmpwi r3,52
bne- END      
li r10,66
....

END:
mflr r0
 
Last edited:

whims

Smash Apprentice
Joined
Mar 7, 2016
Messages
100
Gecko C2 codes automatically place a branch back after the last line in the code.
Code:
cmpwi r3,52
bne- 0x1152       # <---- where did you get this branch value?!?!? There is no way this is right.
li r10,66
....
Just change into this:

Code:
cmpwi r3,52
bne- END     
li r10,66
....

END:
mflr r0
ok lol here's what happened. i mistakenly thought that if i branched to right after the end of the gecko code, it would resume normal coding, so that's why the bne- branches to 1152 down. (i had that much code that i wanted to skip.)

thanks, though, that helps out a ton
 
Top Bottom