News: 11 March 2016 - Forum Rules

Author Topic: how to decompress text in a ps2 game?  (Read 1184 times)

the_taco_shell

  • Jr. Member
  • **
  • Posts: 24
    • View Profile
how to decompress text in a ps2 game?
« on: January 18, 2022, 06:53:57 pm »
I was wondering what is the best way to decompress text in a PS2 game? I can't find a program on it. Thanks.

FAST6191

  • Hero Member
  • *****
  • Posts: 3527
    • View Profile
Re: how to decompress text in a ps2 game?
« Reply #1 on: January 18, 2022, 07:27:51 pm »
There is none.

Unlike some later systems (I don't know if you are coming to us from post N64 Nintendo stuff, or later Microsoft) Sony did not really provide a means in the SDK (poke around in whatever leaked stuff there is if you want but it is not going to do too much for you) or BIOS that devs drifted towards such that you could reasonably have a one size fits basically all program/suite.

Devs were then left to their own devices to create such a thing. There were a few libraries that game dev tool making companies put out, and some of the open source stuff also gets a feature.

Text was not often compressed either -- several gigs of DVD means a few hundred kilobytes (a lot for a game, a lot for a book even) of text is not going to do much for the overall storage, nor is it likely to gobble all your RAM when you have what you want in it. This means compression mostly happened because the dev did it/was used to doing it just because (force of habit as it were*), because they thought it would give them a modicum of protection against people like us or because the smaller size clogged up the read pipe (you are still on the slower side of DVD read speeds, and if this text was somewhere far away from streaming audio/video then... yeah random reads on optical media are second only to tape in terms of latency) for less time.

*things were still quite different between platforms but enough stuff crossed from whatever PC version that if you are hacking a game with a PC version it can pay to have a look at what goes. Certainly I would also be looking at whatever contemporary or covering contemporary PC games documents are around.

My usual "intro to compression" choice of document, while it is named for LZ it does cover the other major classes.
https://ece.uwaterloo.ca/~ece611/LempelZiv.pdf
You are unlikely to find a zip/rar/7z/ace/whatever the Japanese were doing at the time (this was still peak Japan is a separate computing world) in the game, or if you do it is more likely to be something the devs left in as a treat for the curious or as an accident (such developer leftovers being the bread and butter of https://tcrf.net/The_Cutting_Room_Floor ). You might however find the likes of http://zlib.net/ and its contemporaries in there. Any compression used is likely to be on the basic side -- while I noted oodles of RAM earlier you are still quite sharply limited compared to what you might be used to on PC, and you presumably want this game lark to happen in real time so can't really be wasting time on one of those borderline AI and hours to decompress a file things from compression contests.

Poke around http://wiki.xentax.com/index.php/Game_File_Format_Central https://wiki.multimedia.cx/index.php?title=Category:Game_Formats https://multimedia.cx/eggs/category/game-hacking/ as well as they could detail some things and while it will not do you much good then http://www.romhacking.net/?page=utilities&category=&platform=18&game=&author=&os=&level=&perpage=20&title=&desc=&utilsearch=Go for the sake of being complete. http://www.amnoid.de/gc/ is for the gamecube and mostly deals with stuff seen on there but could be worth a look if you want some examples of things.

You can reverse engineer compression effectively without a debugger (usually if you can get a decompressed version, say because it exists in RAM when the game needs it, and a compressed version you can compare the two), though if you can use one then great as it can be quite tedious. You will probably want enough programming skill to write a decompression program or adapt an existing one (LZ is mostly LZ and it can be as simple as a difference in flags and pointer vs read amount split) but decompression at least is quite basic, horrific though to do by hand beyond that what you do to make sure you cracked the code as it were.

You do also have cowboy methods if you wanted -- some of the LZ based stuff will be so many flags, with a flag saying "skip to the next one". Make everything a "skip to the next one" and while you cost some space you have a "compressed" file without the need to figure out how to write a compression algorithm.

Risae

  • Jr. Member
  • **
  • Posts: 86
    • View Profile
Re: how to decompress text in a ps2 game?
« Reply #2 on: January 19, 2022, 09:49:07 am »
I was wondering what is the best way to decompress text in a PS2 game? I can't find a program on it. Thanks.

Are you talking about extracting text from a PS2 game?
For my translation project i'm using "abcde"'s tool called "Atlas" and "Cartographer":

https://www.romhacking.net/forum/index.php?topic=25968.0

HudsonBelcher

  • Jr. Member
  • **
  • Posts: 2
    • View Profile
Re: how to decompress text in a ps2 game?
« Reply #3 on: January 19, 2022, 11:34:03 am »
thanks for the direction to the answer  ::)

the_taco_shell

  • Jr. Member
  • **
  • Posts: 24
    • View Profile
Re: how to decompress text in a ps2 game?
« Reply #4 on: January 19, 2022, 12:31:47 pm »
I should've posted a pic before.

Here is the normal text

https://imgur.com/a/0uq0N1p

And here is another string of text with the messed up code.
https://imgur.com/a/zG6QfcE#9C6Tr0C
« Last Edit: January 19, 2022, 12:45:25 pm by the_taco_shell »

Vehek

  • Full Member
  • ***
  • Posts: 223
    • View Profile
Re: how to decompress text in a ps2 game?
« Reply #5 on: January 19, 2022, 03:14:20 pm »
It's probably not "messed-up code", just data.
Old console games didn't use plain text files. They used files that likely bundled various related data together, including text. Text data, at minimum, usually doesn't stand alone, because the game needs a way (usually pointers) to locate a particular string without running through the whole text all the data.

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 7412
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: how to decompress text in a ps2 game?
« Reply #6 on: January 20, 2022, 12:28:47 pm »
Don't use a text editor to look at data files.
That's why it's not going to make sense.
"My watch says 30 chickens" Google, 2018

the_taco_shell

  • Jr. Member
  • **
  • Posts: 24
    • View Profile
Re: how to decompress text in a ps2 game?
« Reply #7 on: January 20, 2022, 12:57:56 pm »
Don't use a text editor to look at data files.
That's why it's not going to make sense.
What should I use then?

Jorpho

  • Hero Member
  • *****
  • Posts: 5233
  • The cat screams with the voice of a man.
    • View Profile
Re: how to decompress text in a ps2 game?
« Reply #8 on: January 20, 2022, 01:12:22 pm »
You are generally supposed to use a hex editor, since games often use binary code to control how text is organized and formatted; in an ordinary text editor, those binary codes will not display properly (or not display at all). If you opened an old Microsoft Word document in Notepad, it wouldn't display properly either.

Did you read the Getting Started page?
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!