READ THE RULES: Click here

Follow us on Facebook: https://www.facebook.com/xentax/ :)

Lost Chronicles of Zerzura

Need help translating games in other languages? Have your language problems solved here.
Post Reply
djokay
n00b
Posts: 18
Joined: Sat Jun 05, 2010 7:44 am

Lost Chronicles of Zerzura

Post by djokay » Sat Apr 07, 2012 8:12 am

Hi
Does one of you tried or how can extract the dialogues of the game Lost Chronicles of Zerzura.
Apparently the dialogues are in the file loca.bin but I think the file is linked loca.dat2
Currently no tools that I used has succeeded in extracting (Gobread, bin file extractor, etc. ...) :oops:

swuforce
veteran
Posts: 121
Joined: Thu Nov 05, 2009 8:46 pm
Has thanked: 11 times
Been thanked: 105 times

Re: Lost Chronicles of Zerzura

Post by swuforce » Sat Apr 07, 2012 11:49 am

This script can unpack the dat2 file

Code: Select all

idstring "dat2"
getdstring UNK 0x8
get FILES long
get NAMETABLESIZE long
savepos OFF
math NTABLE = FILES
math NTABLE *= 16
math NTABLE += OFF
log MEMORY_FILE NTABLE NAMETABLESIZE
for i = 0 < FILES
get OFFSET long
get ZSIZE long
get SIZE long
get NAMEOFF long
goto NAMEOFF MEMORY_FILE
get NAME string MEMORY_FILE
clog NAME OFFSET ZSIZE SIZE
next i

swuforce
veteran
Posts: 121
Joined: Thu Nov 05, 2009 8:46 pm
Has thanked: 11 times
Been thanked: 105 times

Re: Lost Chronicles of Zerzura

Post by swuforce » Tue Apr 10, 2012 12:25 am

This is a tool for the loca.bin file. http://www.sendspace.com/file/5yg9ba
Last edited by swuforce on Tue Aug 06, 2013 9:50 pm, edited 2 times in total.

djokay
n00b
Posts: 18
Joined: Sat Jun 05, 2010 7:44 am

Re: Lost Chronicles of Zerzura

Post by djokay » Wed Apr 11, 2012 5:48 pm

Thank you for your answers.
I started wanting to translate loca.bin with HexWorkshop but with great difficulty :cry:
I hope that with the tools it will go much better. :mrgreen:

User avatar
Mr.Mouse
Site Admin
Posts: 4041
Joined: Wed Jan 15, 2003 6:45 pm
Location: Dungeons of Doom
Has thanked: 412 times
Been thanked: 561 times
Contact:

Re: Lost Chronicles of Zerzura

Post by Mr.Mouse » Fri Apr 20, 2012 8:28 am

The original post contained links to game files. Removed. The new rules are clear.

merlinsvk
ultra-veteran
ultra-veteran
Posts: 411
Joined: Mon Oct 27, 2008 12:11 am
Location: Slovakia
Has thanked: 35 times
Been thanked: 117 times

Re: Lost Chronicles of Zerzura

Post by merlinsvk » Sat Aug 03, 2013 9:39 pm

So guys, have anybody tried to translate this game?
Importer posted here by swuforce throws me an error while importing non-changed .txt file back to the loca.bin. :-/

EDIT: swuforce updated his exporter/importer, so error is gone. Thank you very much :)

User avatar
XpoZed
veteran
Posts: 144
Joined: Sat Oct 24, 2009 5:08 pm
Location: Bulgaria
Has thanked: 2 times
Been thanked: 45 times
Contact:

Re: Lost Chronicles of Zerzura

Post by XpoZed » Thu Aug 22, 2013 8:39 pm

Now, don't laugh too much, but here's a bin2csv<->csv2bin converter written in PHP:

Code: Select all

<?php

//csv2bin('loca.csv', 'loca.bin');
//bin2csv('loca.bin', 'loca.csv');

function csv2bin($file_input, $file_output) {
	$structure = array(
		'header' => '',
		'entries' => 0,
		'unknown' => 0,
		'header_size' => 0,
		'str_delta' => '',
		'data' => array()
	);

	if ($FHo = fopen($file_output, 'wb+')) {
		$structure['entries'] = 0;
		$size_var = 0;
		$size_val = 0;
		if ($FHi = fopen($file_input, "r")) {
			while (($data = fgetcsv($FHi)) !== FALSE) {
				$size_var += strlen($data[0])+1;
				$size_val += strlen($data[1])+strlen($data[2])+4;
				$structure['data'][] = array('var' => $data[0], 'val' => $data[1], 'more' => $data[2]);
				$structure['entries']++;
			}
			fclose($FHi);
		}
		
		fwrite($FHo, "LOCA");
		putDword($FHo, count($structure['data']));
		putDword($FHo, 1);
		putDword($FHo, 0x18);
		fwrite($FHo, "delta\x00\x00\x00");
		
		$offset_var = (count($structure['data'])*8)+0x18;
		$offset_val = $offset_var+$size_var;

		$data_structure = '';
		$data_variable = '';
		$data_value = '';
		foreach($structure['data'] AS $row) {
			$data_variable .= $row['var']."\x00";
			$data_value .= $row['val']."\x00\x00".$row['more']."\x00\x00";
			putDword($FHo, $offset_var);
			putDword($FHo, $offset_val);
			$offset_var += strlen($row['var'])+1;
			$offset_val += strlen($row['val'])+strlen($row['more'])+4;
		}
		fwrite($FHo, $data_variable);
		fwrite($FHo, $data_value);
		fclose($FHo);
	}
}

function bin2csv($file_input, $file_output) {
	$structure = array(
		'header' => '',
		'entries' => 0,
		'unknown' => 0,
		'header_size' => 0,
		'str_delta' => '',
		'data' => array()
	);

	if ($FHi = fopen($file_input, 'rb')) {
		$file_input_data = '';
		while(!feof($FHi)) {
			$file_input_data .= fread($FHi, 4000);
		}
		fclose($FHi);

		$structure['header'] = getString($file_input_data, 0, 4);
		$structure['entries'] = getDword($file_input_data, 4);
		$structure['unknown'] = getDword($file_input_data, 8);
		$structure['header_size'] = getDword($file_input_data, 12);

		if ($structure['header'] != 'LOCA') {
			echo "Bad header\n";
			exit;
		}
		echo "Header: '".$structure['header']."' - OK!\n";
		echo "Number of entries: ".$structure['entries']."\n";
		echo "Unknown flag: ".$structure['unknown']."\n";
		echo "Size of header: ".$structure['header_size']."\n";
		
		
		$structure['str_delta'] = getString($file_input_data, 16, $structure['header_size']-16);
		if ($structure['str_delta'] != 'delta') {
			echo "Delta is unknown";
		}
		echo "Delta is: '".$structure['str_delta']."' - OK!\n";
		if ($FHo = fopen($file_output, 'wb+')) {	
			for ($i = 0; $i < $structure['entries']; $i++) {
				$offset_var = getDword($file_input_data, $structure['header_size']+(($i*4)*2));
				$offset_val = getDword($file_input_data, $structure['header_size']+((($i*4)*2)+4));

				$str_var = getString($file_input_data, $offset_var);
				$str_val = getString($file_input_data, $offset_val);
				$str_val2 = getString($file_input_data, $offset_val+strlen($str_val)+2);

				fwrite($FHo, $str_var.",\"".$str_val."\",\"".$str_val2."\"\n");
			}

			fclose($FHo);
		}
		
		echo "Done!\n";
	}
}

function putDword($hwnd, $value) {
	fwrite($hwnd, strrev(hex2bin(sprintf("%08X", $value))), 4);
}

function getDword($source, $offset) {
	return hexdec(bin2hex(strrev(substr($source, $offset, 4))));
}

function getString($source, $offset, $size = NULL) {
	if ($size == NULL) {
		return trim(strstr(substr($source, $offset, strlen($source)), "\x00", true));
	}
	return trim(substr($source, $offset, $size));
}

?>
*BOF:EPIC BULLSHIT*
It works just fine as long as you are using a latin alphabet. For some reason, it doesn't work for Cyrillic alphabet (i'm a Bulgarian so f*ck me [roll] ). Also, make sure you are editing the CSV as ANSI encoding, and not UTF-8 for example.
*EOF:EPIC BULLSHIT*

Now, it DOES work with Cyrillic alphabet, and it SHOULD be UTF-8 encoded. Still the original fonts doesn't support Cyrillic alphabet, but oh well... [roll]

About the DAT2 files (loca.dat2, speech.dat2, gui.dat2, scripts.dat2 and sfx.dat2), i've already released an Unpakke module that supports both unpacking and packing.

Good luck! :wink:

-- note to self
Don't drink and post at late hours.

deant
n00b
Posts: 13
Joined: Mon Jul 15, 2013 11:11 am
Has thanked: 1 time

Re: Lost Chronicles of Zerzura

Post by deant » Wed Oct 23, 2013 9:52 pm

oh wow, nice to see another bulgarian here:)

Post Reply