Question about codetypes CT1 CST4-7 (Ifs)

Started by Almas, December 27, 2008, 08:53:00 PM

Previous topic - Next topic

Almas

Could someone explain exactly how these codetypes work? The wording in the code type document is somewhat hard to understand. Specifically, what are ZZZZ and YYYY supposed to denote?

Also, the Endif/If codes have a 1 at the end of the first line where the address is supposed to slot in. How does this work? Does one character of the desired address have to be dropped, and if so, off which side? What if I want to do a normal If code but my address ends with a 1?

You'll have to forgive my immense ignorance. Thanks for any help I get.

Romaap

If you read Links post from this topic you'll be able to understand.
Quote from: Link on July 26, 2008, 10:37:06 PM
Note: I also added interesting tidbits for advanced members but I'll start out the easy way!

doing button combinations not too hard:

first of all you need to know button values:

GCN Wii Clasic
L 0001 L 0001 U+ 0001
R 0002 R 0002 L+ 0002
D 0004 D 0004 Zr 0004
U 0008 U 0008 X  0008
Z 0010 + 0010 A  0010
R 0020 2 0100 Y  0020
L 0040 1 0200 B  0040
A 0100 B 0400 Zl 0080
B 0200 A 0800 R  0200
X 0400 - 1000 +  0400
Y 0800 Z 2000 -  1000
S 1000 C 4000 L  2000
D+ 4000
R+ 8000


(copied from an old thread)..
now I'll use an example:

Form Switch C+Z+R = Wolf (code minorly modified for understanding!)
2844BB66 00006002
00492946 00000001
E0000000 80008000


The actual key is: 2844BB66.. this means: "Read the 16 bit value at the address 8044BB66. Now we know - we're using Wii buttons.. and we want.. C, Z and R to be pressed: look up in the table: C is 4000, Z is 2000 and R is 0002 - so.. we'll go for:

C+Z+R=4000+2000+0002=6002

2844BB66 00006002 therefore checks:
is the value at address 8044BB66 6002 - if it is: then this condition is met.. in our case the condition is met when C+Z and R are pressed. Please note: 8044BB66 is game dependent. A possible way to search for these kinda codes is to look in the table.. press no buttons: search for 16 bit 0000.. now press A (ONLY A).. and search for 0800. You'll slowly narrow down addresses.

For advanced members: I highly recommend you to do codes a little more cooler than that one.. this one is: Press C+Z+R and nothing else, it won't work if you press anything. Simply open calc.exe and set it to Scientific mode.. now enable Hex mode.. and type in: 6002 and click on NOT: you'll get FFFFFFFFFFFF9FFD... only take the last 4 digits.. 9FFD.. and rewrite the code above to:

2844BB66 9FFD6002

technically 28 codes parse the following:

28XXXXXX YYYYZZZZ

If [value at base+XXXXXX] AND (NOT YYYY) == ZZZZ

now we have to slowly approach that.. now YYYY is 9FFD.. notting 9FFD is 6002 again.. now imagine I press C+Z+R+A.. this is 6802...
so.. 6802 AND (NOT 9FFD) = 6802 AND 6002 = 6002 (you can verify in calc.exe).. so.. this condition is true.. using that additional data it ignored A... now to verify I am not talking garbage.. what if YYYY=0000.. I press C+Z+A+R = 6802

6802 AND (NOT 0000) = 6802 AND FFFF = 6802
this is not 6002!

So what is
b) 2844BB66 00006002
a) 2844BB66 9FFD6002
Precisely spoken:
a means: Press C+Z+R and nothing else! If you press anything else, nothing will happen!
b means: Press at least C+Z+R - every other button is also allowed but at least these must be pressed!

Of course these code parts are tricky.. you could technically bring this to an even more complicated level.. if people are interested in example.. I'll happily post!



Also if you want to use an Endif you need to add 1 to the address if you need another If, or use E0000000 80008000 (Full Terminator).

Almas

#2
Great, I kinda get what's going on now. Thanks for the help =).

EDIT: Ah, but it does prompt the question: What if I want nested Ifs? How does the code differentiate between an Endif/If and an If? I suppose the only answer is that nested Ifs are impossible? Or am I missing something key?

EDIT (again): Did some reading and musing - it can tell the difference between an endif and an if because no values are stored as 4 bits, so every distinct piece of data is going to be atleast 2 spaces apart in memory, right? If the memory location is 'even', it's an if, otherwise it's an endif/if.

Romaap

if you want an endif just add 1 to the address: 20123456 becomes 20123457