Okay I attempted making the "stasis unlimited objects" code, but it did not work. I think I have a pretty decent understanding of how it works now, I just can't seem to get it right.
I made an example out of javascript to help me better understand how I should make the code, here it is:
Code:
var storedValue = "43856CE8"; // 11020001
"43856CE8" = "FFFFFFFF"; // re-enable stasis by replacing object's OG value with FFFFFFFF
if (DpadDown) {
// Different object or value is FFFFFFFF
if (storedValue != "43856CE8") {
storedValue++; // increment by 1 (11020002)
storedValue = "43856CE8"; // create & store value within 11020002
}
// Same object was chosen
if (storedValue == "43856CE8") {
"43856CE8" = storedValue; // restore it's tangibility
}
}
Breakdown of how I think something like this would work:
First object was stasis'd. The value of the address (43856CE8) is then set to FFFFFFFF to allow other objects to be stasis'd. A second object is then stasis'd, whatever variable the first object is using to store it's tangibility (storedValue) should not be affected, instead, add a new variable to hold the second object's value ("add" new variable by incrementing storedValue (11020001) by 1), then add the value of the second object to the new variable (a.k.a 11020002). If the first frozen object is selected to be un-frozn, check if the variable used to store it's value (storedValue) contains the same value as the first frozen object. And if it is, replace the object's value with the one within storedValue to make it un-freezable again.
I then tried porting it over to cafe code based off of different cafe code types:
Code:
11020001 43856CE8
00020000 43856CE8
FFFFFFFF 00000000
03010000 102F48AA
00000100 00000000
04020000 11020001
43856CE8 00000000
14040X00 00000001
00020000 11020001
43856CE8 00000000
03020000 11020001
43856CE8 00000000
00020000 43856CE8
11020001 00000000
D0000000 DEADCAFE
Here's a breakdown of how I did it:
Code:
// var storedValue = "43856CE8";
11020001 43856CE8
// "43856CE8" = "FFFFFFFF"
00020000 43856CE8
FFFFFFFF 00000000
// if (DpadDown)
03010000 102F48AA
00000100 00000000
// if (storedValue != "43856CE8")
04020000 11020001
43856CE8 00000000
// storedValue++;
14040R00 00000001 <-- Don't know what I was doing there
// storedValue = "43856CE8";
00020000 11020001
43856CE8 00000000
// if (storedValue == "43856CE8")
03020000 11020001
43856CE8 00000000
// "43856CE8" = storedValue;
00020000 43856CE8
11020001 00000000
But there are many things wrong with it, and I have so many questions :/
- How do I store two if-statements within one if statement (DpadDown) using cafe code?
- How do I increment an address by 1? For example, incrementing storedValue (11020001) by 1 or 00000001 to get 11020002. The regular integer operations confuse the hell outta me :/
- Where should I insert breakpoints? I know that you are supposed to use D0000000 DEADCAFE after an if statement, but where exactly should I place it in this scenario? Since there are two if statements nested within one (DpadDown).
- Are there any more errors or possible bugs/etc with my code or what im trying to do in general I should know about?
Tbh, i do not understand your thought process lol.
I could be very wrong, but
@CosmoCortney can correct me if i am.
i would recommend doing this in assembly since custom branches/"else if's" are not possible with any code type. The D0000000 DEADCAFE is effectively the "End If" statement, or like the closing curly brace "}" in C/C++. When the tested condition is false, the handler branches to the D0000000 DEADCAFE line.
To increment an address by One, you'd use a Load Register operation, then followed by a Math operation on the same register.
ie:
10000000 43856CE8 //Load R0 with value inside of that address.
14040000 00000001 //Direct Value operation of Adding 1 to R0
11000000 43856CE8 //Store contents of R0, into that address.
as for your First bullet point, and your third bullet point, as i was saying, you cant create "truly" nested if statements, but you can test multiple conditions in a row.
in pseudo code, this is the difference..:
In C/C++ (or really any other language)
if (condition1)
{
if (condition2)
{
}
if (condition3)
{
}
}
We know that this means, test the first condition.. if False, skip everything.
if condition1 = True, test condition2 and test condtion3.
in Cafe Code type it would look like:
03020000 COND1
03020000 COND2
D0000000 DEADCAFE
03020000 COND3
D0000000 DEADCAFE
D0000000 DEADCAFE
HOWEVER, this would not functionally work the same way.. The way the handler operates (again CosmoCortney can correct me) is that when the first condition is false, it branches to the first D00000000 DEADCAFE, and therefore would end up at the end of condtion2
which isnt what we want.
You'd have to do assembly to branch to specific locations:
for example
cmpwi Rx, Condition1
bne- END // Jump to Label "End" if false
cmpwi Rx, Condition2
bne- EndOfCond2 // jump to label "EndOfCond2" if false
//if true, do this
EndOfCond2: cmpwi Rx, Condition3
bne- EndOfCond3
//if true, do this
EndOfCond3: nop
END: nop
Also... i feel like there is an easier way to do it. Since the ID of the object can be found in its structure (i forget the offset), and since i found the address that points to your stasis object (and also your magnesis target) you could just test for a Button press while targetting a frozen object, and then go grab the objects ID and place it back into 43856CE8
plus i also found the "This Object is Currently Stasis'd" boolean within its class, and ive already made a code that stasis's as many enemies/objects you want.
so the way i would make the code using your way, would be something like:
Is the player targetting an object?
if so, is it stasis'd?
is the player pressing the button to release this object?
if Yes, go to objects Structure, Grab ID, place it inside 43856CE8
if No, Write FFFFFFFF to 43856CE8 to allow stasis to be used again.
EDIT: nvm. i think it would be better to just always write FFFFFFFF to 43856CE8, unless the player is targeting an enemy, then if a button is pressed, put the ID back into 43856CE8 to allow it to be unfrozen.
apologies for my bad explanations... id just make the code if i wasnt busy with finals
EDIT2: I also dont know how you got placing the ID back into 43856CE8 to allow you to use stasis again.. if you stasis another object while leaving the other object frozen, putting its ID back doesnt do anything for me. Were you doing something different?