More Advanced Guides?

Started by leeharris100, July 30, 2008, 07:16:20 AM

Previous topic - Next topic

leeharris100

Hello all,

I just jumped into the USB Gecko scene, and although the tutorials by dexter are nice and detailed, I'd like to learn more. Unfortunately, the technical documents such as this one: http://www.usbgecko.com/codetypes.htm seem to have been written more as a reference guide than any kind of explanation.

Even things such as simple conditionals are hard for me to understand in the reference.

I have many years experience in programming, I own a business where I often am involved in development, and I'm about to graduate with a CS degree. I promise I'm not hard to teach :)

So, if there are no guides or threads out there, could anyone give me a quick run through on how conditionals work? I would basically like to check the value of an address, compare it to something, and change a value elsewhere if it is equal.

Thanks a lot!

James0x57

Form Switch C+Z+(L/R = Link/Wolf) [James0x57]
2844BB66 00006002  -1
00492946 00000001  -2
2844BB67 00006001  -3
00492946 00000000 -4
E0000000 80008000 -5

1: "28" is 16 bit if equal, the address it is checking is "8044BB66", The value at that address is compaired to NOT 0000 AND 6002 (so it's comairing that the 16 bits there are strictly equal to 6002) If equal, execute all codes until end if.
2: "00" is write 8 bits (the 01 at the end of the code) to the address "80492946"
3: Same as #1 but the address is "misaligned" as a sub-codetype. This means End If then do everything it normally would (exact same as #1 but compare to 6001).
4: Same as #2 but write 00 instead of 01
5: Full terminator (ends any open ifs and sets Pointer Address and base address to 80000000)


leeharris100

Awesome, thanks. Is there an 8 bit if equal? I can't find one in the reference.

James0x57

8 bit if equal is the same as 16 only you ignore part of the 16 bits.
So for the upper 8 bits (XX) you'd do something like this:

2844BB68 00FFXX00 << means NOT 00FF AND XX00- so strictly equal to XX(and any value)
some code to activate
E0000000 80008000

Lower would be
2844BB68 FF0000XX

:)


leeharris100

#4
Ok, so I have run into a problem already.

There is a code to modify which character each player is using. It is this one (this is the Metaknight example):

4A000000 90180F20
10000098 00000018
E0000000 80008000

From what I can tell, it loads the pointer at address 0x90180F20, goes to the 98 offset, and then writes "18" into an 8 bit location.

So I created a conditional for the damage modifier code based off everything that I'm pretty sure I screwed up on ;) This should, but doesn't, change the damage modifier if the player is Metaknight.

38180FB8 FF000018
4A000000 90180F20
140000CC 3E800000
E0000000 80008000

Either I'm way off or I'm missing something simple. I learn best by observing and understanding what has been done. Unfortunately, I need a little help!

Thanks again for all the help so far, James.

**EDIT**

I think I figured it out. I didn't realize how the PO system worked. I'm going to try it with the PO set to the 90 range and report back!

James0x57

Absolutely no problem! Glad to help. ^_^

You were very close! However, the default for the pointer address is 80000000, therefore you must change it so it starts at 90000000 for this code to work:

4A000000 90000000 <-- Sets the pointer value to start of memory 2
38180FB8 FF000018 <-- uses that pointer value, adds 180FB8 to it to compare
4A000000 90180F20 <-- changes the pointer value
140000CC 3E800000 <-- uses new pointer value, adds CC to it to write 32 bits.
E0000000 80008000  <-- restores pointer address and base address to default 80000000

You can shorten this code like so:
4A000000 90180F20
38000098 FF000018
140000CC 3E800000
E0000000 80008000
I'm sure you can see what I've done to shorten it but just ask if you need clarity! :)


leeharris100

Thanks a lot for the help. I tried your example and it didn't work. I tried re-writing it like this:

4A000000 90180FB4
38000004 00000018
14000038 3E800000
E0000000 80008000

And it still didn't work. Am I doing something wrong in the logic?

James0x57

Oh, yes there is. I just blindly copied it. lol

if the 8 bits at 90180FB8 is 18, we want to execute some code. What we were checking is if the 8 bits at 90180FB9 is 18. This should fix it:

4A000000 90180F20
38000098 00FF1800  <-- now checks 90180FB8 and ignores 90180FB9
140000CC 3E800000
E0000000 80008000


leeharris100

It worked! Thanks a bunch, this will help with all of the next tweaks :)

I was also curious, how many codes can be used for a single game? For this project I'd like to get into 1000-2000, but I read somewhere that the limit is most likely around 300 or so. Is there any way to increase this limit?