/Sega-CD-Snatcher-Language-Patcher

Sega CD Snatcher Language Patcher

Primary LanguagePHPGNU General Public License v3.0GPL-3.0

Sega-CD-Snatcher-Language-Patcher

##############
#   INTRO    #
##############

This is a CakePHP project to modify the texts from the great videogame Snatcher from Hideo Kojima for Sega/Mega CD.

You can read about this work in EOL post: http://www.elotrolado.net/hilo_proyecto-snatcher-en-espanol_1790142

################
#   CONTENT    #
################

- Console/spatcher.php: Script to patch sega cd ISO
- Controller/Component/BinaryComponent.php: Component class from CakePHP to generate translated binary files with the data from a file game.
- Controller/Component/QuicksaveComponent.php: Component class from CakePHP to patch quicksaves from Kega Fusion and include translated binary files. Usefull if you want to try a binary file from a Game directly without patch the ISO and use a save game.

################
# REQUIREMENTS # 
################

- CakePHP 2.4.8 or later
- jQuery 1.10 or later
- PHP 5.2 or later
- Web Server and MySQL database

###########
# INSTALL #
###########

- Download CakePHP (www.cakephp.org) and create a new project with cake bake script (I will call "app" here).
- Copy the folders from this project and paste into the new project.
- Use the sql file from Config/Schema/snatcher.sql to create database schema in MySQL.
- Copy data from Config/readme to the end of your core CakePHP file in app/Config/core.php (and change "esp" and "es" to your new language for translation).
- Copy app in your localhost directory from your web server and set user, groups and necesary permissions (app/tmp and app/File needs write permissions).
- To access web, first time you need create an user administrator:
	- Open Controller/UsersController.php with any text editor
	- Uncomment the line 26:
		$this->Auth->allowedActions = array('admin_index', 'admin_add', 'admin_changePassword');
	- Go to http://localhost/app/admin/users/
	- Click at "New User" and create a new user with the role "Admin" selected.
	- Comment the line 26 from Controller/UsersController.php file.
	- Go to http://localhost/app/ and sign in.

#############
# PATCH ISO #
#############

There is a spatcher.php CLI script in app/Console path for patch your ISO. Only needs specify the path from Snatcher Sega CD ISO and a folder where you stored the new binary files.

###############
# DESCRIPTION #
###############

Binary->wirteFile returns the new filesize. There is a limit for this files: 55296 bytes

Instrucctions for use:

1) For use add to your Controller from CakePHP:

	public $components = array('Binary');

2) Add in your method:

	$filesize = $this->Binary->writeFile(
			$path_ori_files . $filename,
			$path_new_files . $filename,
			$data);

$path_ori_files is the path where store original files from Sega CD Snatcher (f.e /app/Files/snatcher/)

$path_new_files is the patch where you can store new files pathed.

$filename is the name to patch (f. e. SP06.BIN)

$data is a array with this structure:

- characher_id: identify the character id necesary for patch offset for each character from the Game. You can find her names in SUBCODE.BIN
- position: It is the integer position from 0x3800, then first text in binary files has the integer position 0 (each word is one position)
- new_text: It is the translation text. It is important data array has all translations in order acording binary file you want patch.
- nchars: The number of characters from old original texts. I use it for avoid calculate the length in the "foreach" original texts loop.

An example:

array(
	(int) 0 => array(
		'character_id' => '1',
		'position' => '0',
		'new_text' => 'CONTINUAR',
		'nchars' => '13'
	),
	(int) 1 => array(
		'character_id' => '1',
		'position' => '14',
		'new_text' => 'TERMINAR',
		'nchars' => '6'
	),
	(int) 2 => array(
		'character_id' => '3',
		'position' => '21',
		'new_text' => '¡Oh no! ¡No hay suficiente <8>memoria<11> para guardar m¡s  datos! Tendrás que <8>sobrescribir<11> los datos existentes para guardar.',
		'nchars' => '143'
	),

	...

	(int) n => array(
		'character_id' => '3',
		'position' => '165',
		'new_text' => '¡Guardado!',
		'nchars' => '15',

)

3) You must convert special chars of the game into a <{number}> wildcard. The special chars are converted with array special_chars_orig:

		/** 
		 * WARNING!!! NO CHANGE THE ORDER OF special_chars 
		 * */ 
		$this->special_chars_orig = array(
				$this->new_line,   pack("H*" , "ec"), $this->new_page, // <0>, <1>, <2>
				pack("H*" , "ee"), pack("H*" , "f0"), pack("H*" , "fe"), // <3>, <4>, <5>
				pack("H*" , "f4"), pack("H*" , "fa"), pack("H*", "fb"), // <6>, <7>, <8>
				pack("H*", "fc"),  pack("H*" , "fd"), pack("H*" , "f9"), // <9>, <10>, <11>
				pack("H*" , "f7"), pack("H*" , "f8")  // <12>, <13>
		);


When the script tranlates your new texts, it replaces the wildcard <{number}> with his special char defined in special_chars_orig.

##########
# Thanks #
##########

- Joxer for create and manage the translate project for Snatcher from EOL.
- Mairtrus for his technical knowledge and helpful with romhacking and for explain me how to modify the binary files and iso.
- m4x1m0, jam007, Tolvatar, djnox, Manveru Ainu, livekraft, tonycc, Drasglaf, randam_hajile for their helpful translating the texts and review.
 
###########
# License #
###########

The source code for the web project is licensed under the GPL version 3 or later
(see LICENSE).