Monday, 4 December 2017

So close!

5,284 scripts now compile to correct size :)
Only 1 script left that doesn't!

This one is going to take a lot of work though by the look :/

New version 0.3 available here: Version 0.3 dcotetools.zip

Saturday, 2 December 2017

Almost there

Good progress still being made with 5,267 scripts compiling to the same byte size and only 18 failing now.
These failures are down to bad code in the original source which I need to recreate to get a solid baseline for any changes.

New version 0.2 available here: Version 0.2 dcotetools.zip

Thursday, 30 November 2017

DCoTETools preview release

The tools for scripting are now at a point where they are worth sharing :)
And luckily they work with all versions of the game.

Script wise 4,985 scripts compile to the same size as the original scripts which is a good sign they are probably correct.  There are some complex reasons why a lot are not binary identical but I should be able to work around that later.  There are 300 scripts remaining that won't fully decompile yet but I'm working on that also.

So the bottom line is whilst you can read the extracted script sources, make changes and rebuild them into .bat files you cannot run against those new .bat files ... yet (see note at bottom)!

You can download the tools here dcotetools.zip
Updated version here: Version 0.2 dcotetools.zip

To see them working:

Extract the zip file into the Scripts directory of your install.
This will be something like "C:\Program Files\Bethesda Softworks\Call Of Cthulhu DCoTE\Scripts\"
That directory will contain several .bat files which are the squashed binary script files.

Open a command prompt at that location and then start by executing:
SucUnbatch.exe . bin list
This will extract the individual compiled scripts out into the bin directory and puts the list of which scripts go into which .bat files into the list directory.

Next we need to decompile the binary scripts into source:
SucDecompiler.exe bin src
This will decompile the binary scripts in bin into the src directory.

You can go and look at the scripts in src and maybe try and find some bugs :)

To recompile any changes that you make use:
SucCompiler.exe src newbin
This will recompile the source files into binary files in the newbin directory.

Finally to squash the binary scripts back into .bat files:
SucBatch.exe newbin list newbat
This will use the files in the list directory to squash the correct newly built binaries into the newbat directory.

You should now have a new set of matching .bat files in the newbat directory.

And at some point soon you could replace your original .bat files with these and play with the changes you have made.

Once I've got everything decompiling correctly I'll put together a package using visual studio code and the tools to allow you to change a file, have it compile on save and rebuild your batch files to allow quick testing of code changes.

If you were to change one of the scripts that currently does decompile correctly you could take the newly compiled .bin file from newbin, merge it with the original unbatched .bin files in bin and then use the batch tool to create new .bat files that contained that change.
So, for example, copy the files from bin into testbin, copy your new bin file from newbin into testbin, run:
SucBatch.exe testbin list testbat
That would more than likely work!

Wednesday, 29 November 2017

Decompiler rewrite progress

A move of PCs meant that I stupidly lost a chunk of the work I did on the decompiler a couple of years back so I'm having to rewrite it.

Progress is going well and I've covered most of the 'easier' decompilation now which means that 2/3 of the binary scripts decompile to source and then recompile to the same binary as extracted from the game.

Here's an example of how the decompiled source looks atm.

Compared to the debug source files extracted from the xbox version this obviously doesn't have any of the comments or helpfully named variables.
I'm using the c# Roslyn compiler functionality as the source syntax is near enough c# which should mean I can work out some better variable names once everything decompiles correctly.

I am finding bugs in the binary code which atm I'm working around and recreating in the new source
so that I can get a baseline match. Also there are some scripts only on the PC version and differences  from the xbox code which makes things harder but I can deal with those later.

I've switch from Eclipse as a script platform to visual studio code which I'll put details up about later.

Sunday, 26 November 2017

1.6 with shader changes

As part of the push to get everything shared I've added the shader fixes from Guzz to the patcher and released as version 1.6 here.

More details on the DCoTEPatch page.