Hi all,
a bit more info about this
From LUA 4.0.1 lopcodes.h file, edited for clearness:
Code:
We assume that instructions are unsigned numbers.
We assume that instructions are unsigned numbers.
All instructions have an opcode in the first 6 bits. Moreover,
an instruction can have 0, 1, or 2 arguments. Instructions can
have the following types:
type 0: no arguments
type 1: 1 unsigned argument in the higher bits (called `U')
type 2: 1 signed argument in the higher bits (`S')
type 3: 1st unsigned argument in the higher bits (`A')
2nd unsigned argument in the middle bits (`B')
A signed argument is represented in excess K; that is, the number
value is the unsigned value minus K. K is exactly the maximum value
for that argument (so that -max is represented by 0, and +max is
represented by 2*max), which is half the maximum for the corresponding
unsigned argument.
The size of each argument is defined in `llimits.h'.
The usual is an instruction with 32 bits,
U arguments with 26 bits (32-6),
A arguments with 17 bits (32-6-9),
B arguments with 9 bits,
For small installations, the instruction size can be 16, so
U has 10 bits, and
A has 5 bits and
B has 5 bits.
We are using a 'small instalation' so the second option applies.
This will result in a Lua instruction (OPCode and optional values) represented bitwise like this (hope I get this one right)
Code:
16 bit Lua instruction
MSB LSB
11111111 11111111 - all bits
00000000 00111111 - OPCode
11111000 00000000 - A argument
00000111 11000000 - B argument
11111111 11000000 - U argument
*1111111 11000000 - S argument (* is the sign)
To decode the instructions properly some bit-shift magic has to happen. The code i'm using currently may or may not be accurate in respect of this issue.
Still a lot unsure of it.
Nevertheless, this explanation about bits is important because either DoubleFine has made some mumbojumbo with the opcodes, effectively making the scripts undecodable, or i'm doing something wrong (most likely option).
I'm publishing the source code i'm working at the moment. This is still far from finished and you'll need some sort of Visual Basic 6, I'm using the Portable version you can find easily by Googling a bit
Please send you comments in, via replies to this post, or private messeges. Either one is fine but please provide feedback.
I can't publish any of the game files for obvious reasons.
I do however provide a compiled script for fast testing (one of the test programs provided with Lua source code).
You can get the source code
here
Have fun!