Var# upper and lower? What's this?

Status
Not open for further replies.

glaber

Emblem Radar Ready
As you should be able to gather from the title I don't understand the whole thing about var1/2 upper and lower. The reason being I'm useing the Soc editor and the wiki isn't giving me good info. What I'm attempting to do is use a capechase on a spike ball before turning it invisible for the drilla (testing purposes). If someone could help by explaneing the whole var # upper lower thing that will really help.
 
The 'upper' and 'lower' parts of the variables refer to the upper and lower 16 bits. By analogy, we can consider decimal digits instead of binary digits: the number 9437 has 94 in its upper two decimal digits and 37 in its lower two.

With binary digits, the arithmetic isn't so nice, but the same principle holds. 9437 in binary is 10010011011101, which has 100100 in its upper eight bits and 11011101 in its lower eight.

There should probably be something in the Wiki about this, but since I'm not a SOCer, I wouldn't know where to put it. Any ideas?
 
Final number = (Upper*65536) + Lower

(Parentheses added to enforce precedence, despite order of operations. I'm picky like that.)
Or the other way around, I forget.
 
Draykon said:
Final number = (Lower*65536) + Upper

(Parentheses added to enforce precedence, despite order of operations. I'm picky like that.)
Or the other way around, I forget.

Yes, it's the other way around. To remember which way to put it, think back to the decimal analogy: if we want 94 in the upper two digits and 37 in the lower two (so we're shooting for 9437), we take 94 * 100 + 37, because multiplying by 100 in decimal is equivalent to shunting the digits two places to the left.

Then, when you realise that 65536 is 10000000000000000 in binary (that's sixteen zeros), the rest follows.
 
Okie then, fixed in case someone in the future finds it via search, and dosen't think to read the whole topic.

Basically, upper and lower bits are a way of cramming two numbers into one. The final number that you set as the var is equal to the formula I posted a couple posts ago. I can't make it any simpler than that.
 
Ok I think I'm beginning to understand it better now, it sounds like the max position, or max number is 9999. Is this correct?
 
glaber said:
That might explane why it isn't in the wiki yet.

I'll offer a better solution than that.

It's not in the Wiki because so very few people have enough SOC knowledge as it stands, and pretty much none of them bothers to add a comprehensible page for each function & how they work. I realize a lot of what SOCs are is complicated, but what's on the Wiki doesn't qualify as something even remotely informative. It states what the functions do, but not how to use them all. Which doesn't help in the least.

I'd fix that myself, but I'm totally clueless when it comes to SOCs.
 
glaber said:
Ok I think I'm beginning to understand it better now, it sounds like the max position, or max number is 9999. Is this correct?
If we were dealing with 4-decimal-digit numbers, then yes. However, we're working with 32-bit (that's binary digit) numbers, which range from 0 to 4294967295 = 65536^2 = 65535 * 65536 + 65535. So the upper and lower words (16-bit chunks) can range from 0 to 65535.

EDIT: Fixed off-by-one error.
 
Draykon's equation is the simplest way to express it. a441 always expressed Thing bitset heights as Height * 16 + 7 = Bitset to use. Likewise, (UpperVal*65536) + LowerVal = Number to use for var. Just plug in the variables (do you know your Algebra?) and you'll get the number to use.

In A_CapeChase, if Var1's upper value should be 128 and Var1's lower value should be 1, then do (128*65536) + 1. That equals 8388609, and that's what you'd put in the Var1 box.
 
I get it now. :) Thank you Digiku.

quick question, does A_SpawnObjectAbsolute really use Var 2 lower to determine what to spawn and determine the y cordnates of what it just spawned or is the Wiki's info messed up?
Link:http://www.srb2wiki.sepwich.com/wiki/Actions_(SOC)

Yes I know Smilies are disabled. but how else can I express emotion in text?
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top