Cytlan
New Member
So I've been playing around with reverse engineering various formats used in The Sims, specifically the Arry formats found in the Housexx.iff files, in the hopes of being able to create a house renderer in Javascript.
I got a little side tracked and ended up working on a decompiler for SimAntics.
While it's far from finished (it's barely even usable, and the decompiled output cannot even be recompiled yet), I thought I'd share a little bit of what I've been working on so far and maybe get some feedback.
As we all know, SimAntics is a visual scripting language based on a tree structure. This doesn't easily translate into text-based code without some serious decompiler-fu. I am however able to generate the following output for 4100.BHAV from the base game (which I believe is found in all Userxxxxx.iff files) with my decompiler in its current state:
The code above might not be the easiest to follow, but I'm hoping that I'll be able to make my decompiler produce something like this:
It should be fairly easy to understand what this BHAV does from the code above:
my.person[temp.0] writes to the person data fields from 46 to 56, which we can see from Behavior.iff are the interest fields.
It randomizes the interests for a sim, with 3 interests being more than 7, 3 interests being between 7 and 4 (inclusive), 3 interests being lower than 4, and 1 interest being 0.
We can also see that it also writes to the two person data fields labeled "Unused & Do NOT Use" after the interest fields (which suggests that these two fields used to be additional interests that was removed from the base game)
I don't know of any other projects like this, so I thought it'd be of interest (pun intended).
What do you guys think? Is this a worthwhile cause, anything you'd like to see, or should I just make an Edith clone in JS instead?
Personally I prefer text-based scripting, instead of the visual scripting done with Edith, which is what encouraged me to carry on with this project.
I got a little side tracked and ended up working on a decompiler for SimAntics.
While it's far from finished (it's barely even usable, and the decompiled output cannot even be recompiled yet), I thought I'd share a little bit of what I've been working on so far and maybe get some feedback.
As we all know, SimAntics is a visual scripting language based on a tree structure. This doesn't easily translate into text-based code without some serious decompiler-fu. I am however able to generate the following output for 4100.BHAV from the base game (which I believe is found in all Userxxxxx.iff files) with my decompiler in its current state:
Code:
# Binary Path:#/Branch Code
00 - 00 02 01 FD 14 00 05 00 00 05 12 07 | 0:0 : my.person.20 = 5
01 - 00 02 02 FD 00 00 03 00 00 05 19 07 | 0:1 : local.0 = 3
02 - 00 02 03 FD 01 00 03 00 00 05 19 07 | 0:2 : local.1 = 3
03 - 00 02 04 FD 02 00 03 00 00 05 19 07 | 0:3 : local.2 = 3
04 - 00 02 05 FD 03 00 01 00 00 05 19 07 | 0:4 : local.3 = 1
05 - 00 02 06 FD 00 00 2E 00 00 05 08 07 | 0:5 : temp.0 = 46
06 - 00 08 07 FD 00 00 09 00 0B 00 07 00 | 0:6 : param.0 = rand(11)
07 - 00 02 08 09 00 00 00 00 00 02 09 07 | 0:7 / 1:0 : if(param.0 != 0) goto 1:0
08 - 00 02 0B 06 03 00 01 00 00 02 19 07 | 0:8 / 0:6 : if(local.3 != 1) goto 0:6
0B - 00 02 12 FD 03 00 00 00 00 05 19 07 | 0:9 : local.3 = 0
12 - 00 02 13 FD 00 00 00 00 00 05 1E 09 | 0:10 : my.person[temp.0] = param.0
13 - 00 02 14 FD 00 00 01 00 00 03 08 07 | 0:11 : temp.0 += 1
14 - 00 02 FE 06 00 00 38 00 00 02 08 07 | 0:12 / true : if(temp.0 == 56) goto true
: goto 0:6
# Binary Path:#/Branch Code
09 - 00 02 0C 0A 00 00 04 00 00 01 09 07 | 1:0 / 2:0 : if(param.0 < 4) goto 2:0
0A - 00 02 0D 0E 00 00 07 00 00 01 09 07 | 1:1 / 3:0 : if(param.0 > 7) goto 3:0
0D - 00 02 10 06 01 00 00 00 00 00 19 07 | 1:2 / 0:6 : if(local.1 < 0) goto 0:6
10 - 00 02 12 FD 01 00 01 00 00 04 19 07 | 1:3 : local.1 -= 1
: goto 0:10
# Binary Path:#/Branch Code
0C - 00 02 0F 06 02 00 00 00 00 00 19 07 | 2:0 / 0:6 : if(local.2 < 0) goto 0:6
0F - 00 02 12 FD 02 00 01 00 00 04 19 07 | 2:1 : local.2 -= 1
: goto 0:10
# Binary Path:#/Branch Code
0E - 00 02 11 06 00 00 00 00 00 00 19 07 | 3:0 / 0:6 : if(local.0 < 0) goto 0:6
11 - 00 02 12 FD 00 00 01 00 00 04 19 07 | 3:1 : local.0 -= 1
: goto 0:10
The code above might not be the easiest to follow, but I'm hoping that I'll be able to make my decompiler produce something like this:
Code:
my.person.20 = 5
local.0 = 3
local.1 = 3
local.2 = 3
local.3 = 1
temp.0 = 46
while(temp.0 != 56)
{
param.0 = rand(11)
if(param.0 == 0)
{
if(local.3 != 1) continue
local.3 = 0
}
if(param.0 < 4)
{
if(local.2 < 0) continue
local.2 -= 1
}
else if(param.0 > 7)
{
if(local.0 < 0) continue
local.0 -= 1
}
else
{
if(local.1 < 0) continue
local.1 -= 1
}
my.person[temp.0] = param.0
temp.0 += 1
}
return true
It should be fairly easy to understand what this BHAV does from the code above:
my.person[temp.0] writes to the person data fields from 46 to 56, which we can see from Behavior.iff are the interest fields.
It randomizes the interests for a sim, with 3 interests being more than 7, 3 interests being between 7 and 4 (inclusive), 3 interests being lower than 4, and 1 interest being 0.
We can also see that it also writes to the two person data fields labeled "Unused & Do NOT Use" after the interest fields (which suggests that these two fields used to be additional interests that was removed from the base game)
I don't know of any other projects like this, so I thought it'd be of interest (pun intended).
What do you guys think? Is this a worthwhile cause, anything you'd like to see, or should I just make an Edith clone in JS instead?
Personally I prefer text-based scripting, instead of the visual scripting done with Edith, which is what encouraged me to carry on with this project.