PDA

View Full Version : Enzai script files


landxhp
2009-01-24, 12:21
I'm a former romhacker and I often translate games from english to portuguese, which is my main language.

I recently got the english version of "Enzai" (Falsely Acused) from Jast USA and I've been looking forward to translate the game to portuguese.
Yesterday I managed to find a program that got the "rio.arc" file extracted into various "txt*.scr" files, however, upon opening them into a common hexadecimal program, it won't give me any readable text, it outputs as gibberish for every format I've tried, Shift-Jis, Utf-8, etc...

Has someone already managed to view those .scr files before? Is there any program I can use to read and edit them? Is any programmer willing to write something to help me translate the game?

Enerccio
2009-01-24, 13:27
have you tried anime editing tools?
http://www.dsp2003.narod.ru/animed_i.htm

dsp2003
2009-01-24, 13:30
rio.arc stands for Will Co. Engine. The .scr\.wsc files inside are encrypted by the following simple algorithm:



Note: Pascal programming language.

Encryption (single byte):

Result := (byte shl 2) or (byte shr 6);

Decryption (single byte):

Result := (byte shr 2) or (byte shl 6);



In AnimED, those functions are "Encrypt by circular multiplication" and "Decrypt the circular multiplication".

Note: you cannot edit Will Co. Engine .scr files with my tool, you can only decrypt and crypt back - use an Hex Editor instead (and only at your own risk).

Have a nice day.

landxhp
2009-01-24, 13:35
have you tried anime editing tools?
http://www.dsp2003.narod.ru/animed_i.htm

I used exactly that tool to extract the .scr scripts/scenarios out of the .arc but it don't appear to recognize the .scr files after that.



rio.arc stands for Will Co. Engine. The .scr\.wsc files inside are encrypted by the following simple algorithm:


Note: Pascal programming language.

Encryption (single byte):

Result := (byte shl 2) or (byte shr 6);

Decryption (single byte):

Result := (byte shr 2) or (byte shl 6);


Sorry, I'm no programmer, I don't understand those >_<'''
Could you please do a simple decompiler/recompiler so I can use with those files?

Enerccio
2009-01-24, 14:46
I used exactly that tool to extract the .scr scripts/scenarios out of the .arc but it don't appear to recognize the .scr files after that.





Sorry, I'm no programmer, I don't understand those >_<'''
Could you please do a simple decompiler/recompiler so I can use with those files?
you don' have to
from his words, you just have to run that "Encrypt by circular multiplication" and "Decrypt the circular multiplication" function in AnimeED
You do need to edit the script files with hex editor after decryption though. And pack it back yourself. At least that's how I understood him. :<

landxhp
2009-01-24, 15:03
Editing by hex editors is good enough of a deal, but then... how can I repack the files back to arc format? =/

Starchanchan
2009-01-25, 01:03
I think, but I'm not sure, that before the official English version came out, a group was working on an English patch (which was obviously never finished)... I could be dead wrong, though. Try googling it and see what you come up with.

dsp2003
2009-01-25, 01:35
The .arc format is easy but really ugly at the same time. See this:



{ Will Co. ARC format structural description }
TARCHeader = packed record
ExtRec : longword; // Number of file extensions
end;
TARCExtDir = packed record
Extension : array[1..4] of char; // Extension (max 4 chars)
Filecount : longword; // Number of files for this extension
ExtFOffset : longword; // Offset - position of ARCDir record for applying the extension
end;
TARCDir = packed record
FileName : array[1..8] of char; // Filename WITHOUT the extension
Dummy_0 : byte; // Dummy
Filesize : longword; // File size
Offset : longword; // File offset
end;


Technically, it means that the structure will be:

---------------------------------------
ARCHeader - count of ARCExtDir sections
---------------------------------------
ARCExtDir[1]
ARCExtDir[2]
...
ARCExtDir[n]
---------------------------------------------
ARCDir[1]
ARCDir[2]
...
ARCDir[m]
---------------------------------------------


I was able to write the code which handles the crazy file naming routine and provides extraction of the archive contents without any problems, but the repacking here is really tricky.

First of all, we must sort our filenames by the given extension (easy as pie), get the count of each (not a problem too), create the necessary ridiculous "extensions table", then generate the file allocation table with bare names (i.e. without extensions).

landxhp
2009-01-25, 07:27
I was able to write the code which handles the crazy file naming routine and provides extraction of the archive contents without any problems, but the repacking here is really tricky.

First of all, we must sort our filenames by the given extension (easy as pie), get the count of each (not a problem too), create the necessary ridiculous "extensions table", then generate the file allocation table with bare names (i.e. without extensions). It was done, and the code is written already, but... it fails if there's more than 2-3 extensions or if there's a files without any extension.

That's the reason why you should not use AnimED for repacking - the chance of failure is too high. I'm sorry. T_T

Have you released that version of the code? The Rio.arc file extracts all into .src files so there's only one type there.

I tried converting a file, translating a line, convert back and repack the .arc with the version of AnimED I got here (0.6.5.360), it outputs a file just as the same size, however the game refuses to recognize it at all, it gives me a "File [filename] could not be opened", it happens both with the script file I changed (first script from new game) and other files unchanged (trying to access the options menu also freezes the game).

dsp2003
2009-02-05, 11:17
Well, good news. I've finally solved the problem in Will Co. ARC archive generation algorithm. I'm going to release 0.6.5.365 build in the next 12 hours. Stay tuned. ^_^

Edit: released (http://sl.criminalrussia.ru/dsp2003/animed.php).

Also, if you have a copy of Delphi 7 or higher, you can apply this fix:


AnimED_Archives.pas
================

function SA_WILL_ARC

Line 1748:

for k := 1 to ExtList.Count do begin
FileCount := 0;
for j := 0 to AddedFiles.Count-1 do begin
if ExtractFileExt(AddedFiles.Strings[j]) = ExtList.Strings[k-1] then Filecount := Filecount + 1;
end;
end;


Replace it with:

FileCount := 0;
for j := 0 to AddedFiles.Count-1 do begin
if ExtractFileExt(AddedFiles.Strings[j]) = ExtList.Strings[i-1] then Filecount := Filecount + 1;
end;


Yup, screwed a bit when programmed this piece. ^^'

landxhp
2009-02-06, 07:32
Thanks a lot for your effort in releasing a fixed version, I appreciate it and I believe many other people find it useful ^^

However, after repacking, the game still says "File [filename] could not be opened" and halts the application =/

dsp2003
2009-02-06, 08:43
No way! x_x Tested with Critical Point, Little My Maid and Yume Miru Kusuri -- works perfectly. Are you setting the output format exactly as "[ARC] Will Co."?

Please note: there's two different ARCs - "Will Co." and "Buriko General Interpreter".

P.S. Что-то не срастается с твоей стороны. Попробуй ещё разок. :)

landxhp
2009-02-06, 09:00
Yeah I DO select "[ARC] Will Co." as the repack format but it still won't work. It does pack a file that looks like the same filesize but when I try opening the game with it it just halts like that:
http://i4.photobucket.com/albums/y112/Lanford/Etc/enzai_error.jpg
Even if the file I modified isn't the "cgmain.src" (the file called when I click "option") - it simply renders a file that the game can't find the reference scripts and then closes itself.

dsp2003
2009-02-06, 09:33
Crap. The only thing I can think of is a file order in the archive. You see, AnimED (and any other custom format-compatible tool) packs files in the same order as they're stored at your file system. In other words, the archive will never be 100% byte-identical to the original and that is the most probable cause (especially if there's some kind of "list file" in the archive -- some kind of protection).

So, the next step is going to be the reconstruction of the same file sorting algorithm... *_*

The built-in Object Pascal sorting procedures will probably be useless......

Eh, anyway, I'll see what I can do.

landxhp
2009-02-06, 09:43
Maybe making AnimED repack a new file with the order based on the original file? Is that possible?

I could upload the original rio.arc if you'd like, it's only about 1mb.

dsp2003
2009-02-06, 10:25
Maybe making AnimED repack a new file with the order based on the original file? Is that possible?
Of course! =) A few minutes ago, in order to check my theory and figure out the sorting order, I've added "Generate HTML file list" option in the right-click archiver menu.

I'll add "Generate file order list" option and "Create from list" button right away! Stay tuned. ^_^

Edit: 0.6.5.367 (http://sl.criminalrussia.ru/dsp2003/animed.php)

Here's how it works:

0. Open the original archive, generate list file and save it.
1. Place your .txt into the folder along with the extracted files.
2. Click "Create from list" and select your .txt file.
3. Save new archive under the desired name.

Now it's time for me to sleep. -.- ....zzzzzzZZZZ

landxhp
2009-02-06, 17:54
Rest assured, dsp, it's now working thanks to the fix! =3

Once again, thank you so much for your hard effort at it! You're surely going to be credited and praised up and down on the translation communities over here ^_^

Dovahden
2012-08-08, 15:09
I'm beginning to translate Ijiwaru my Master from Spanish with help from a Japanese--> English translator. However, neither of us has any idea how to hack into the engine at all. I have read this thread multiple times, but I'm not quite understanding. My process has gone something like this:

Open Rio.arc
Pull out scripts
Circular Encrypt scripts
Circular Decrypt scripts
Open with hex editor
Get total gibberish.

Anyway, I've been working on this problem for the past week or so, and was wondering if anyone could tell me what I'm doing wrong. Thanks!