News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: PSX Tools/Scripts for LZSS/ Video game compression (Saga Frontier hacking)  (Read 2896 times)

Zanerus

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
In Saga Frontier the Battle.ARC file is a compressed version of the Battle.OUT. I have recently learned how to find  offsets in Battle.OUT, but I'm not sure how its compressed. The .ARC file is password protected so I was unable to extract it or examine it when I tried to use PeaZip. So instead I tried to compress Battle.OUT and have it in ARC format then importing it into the ISO caused loading any fight caused the game to freeze. I'm reading up on LZSS compression, which is a common type Square used, but was wondering if any pre existing scripts or utilities exist that can do the compression for me.

Below is a link to a Zip Folder containing the Battle.ARC File, an unmodified Battle.OUT file and a modifed BAttle.OUT where the drop rate has been set to 50% for rare drops. I tested the values in the memory so I know they are right. Any help would be useful 

https://www.dropbox.com/s/lhx1sa5lvncp21d/SF%20BattleArc.7z?dl=0

Vehek

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: PSX Tools/Scripts for LZSS/ Video game compression (Saga Frontier hacking)
« Reply #1 on: February 03, 2019, 12:41:21 am »
You're making the common beginner mistake of thinking file extension names are universal. That's not a computer file archive.
Back when creeperton was still active, I went over this. It's the same LZSS they used in FF7/FF8. (Same LZSS parameters). One just needs to split out the compressed section correctly.

Zanerus

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
Re: PSX Tools/Scripts for LZSS/ Video game compression (Saga Frontier hacking)
« Reply #2 on: February 03, 2019, 12:57:28 am »
You're making the common beginner mistake of thinking file extension names are universal. That's not a computer file archive.
Back when creeperton was still active, I went over this. It's the same LZSS they used in FF7/FF8. (Same LZSS parameters). One just needs to split out the compressed section correctly.
Fair point on being a beginner mistake, this is my first psx patch and first solo project.

Can you expand on the LZSS parameters? I know how to edit Battle.OUT but not how to then compress it correctly so it can replace Battle.ARC. if not could you link me to more info.

Also who is/was creeperton?

NERV Agent

  • Restricted Access
  • Sr. Member
  • *
  • Posts: 497
  • Eva Unit 01
    • View Profile
    • Watch my anime shitposts on YouTube! Smell them, too!
Re: PSX Tools/Scripts for LZSS/ Video game compression (Saga Frontier hacking)
« Reply #3 on: February 03, 2019, 01:20:37 am »
Well aren't you in luck. 2 years ago I was struggling to wrap my head around this very thing with FF7. Lemme see what I can recall....

http://forums.qhimm.com/index.php?topic=16930

http://forums.qhimm.com/index.php?topic=17044.0

https://www.youtube.com/watch?v=s_QBELkbaBs

I hope this helps.

The gist of the video tutorial is that we use something called FF7Tools, and we use "unbinlz" to extract the contents of the archive "OPENING.BIN". I was trying to mess around with the title screen.

"unbinlz" extracted the contents, and the title screen was "OPENING_17.data".

So the data in that scenario was that different files are at different offsets, and they were all lumped together in one file: not all the files were compressed. But they were all connected together in the ".bin" file like some sort of human centipede. To add to the confusion, "unbinlz" then decompressed the compressed files at the same time.

So I made my changes to "OPENING_17.data" and and had to compress it with "lzss" (it should generate a new file, that is your compressed file).

In Hex Workshop (or whatever hex editor you prefer), we would go to the offset where "OPENING_17.data" was stored, then select the chunk of data that is the same size as my newly compressed file, and flood that block of data with 0s. Then go back to the offset where "OPENING_17.data" was stored, select the chunk of data that is the same size as my newly compressed file (it turned all into 0s if you recall), and paste into the selection (overwriting all those 0s).

But in my case, the files I would make were either smaller or the same size as the original file. If the file is larger...then it's a much more complicated situation that even goes over my head.

Anyway, we saved the modified "OPENING.BIN" which had the compressed "OPENING_17.bin" pasted into it's appropriate space, used CDMage to reinsert it into the game, and I can see my bullshit title screen hack after that.

« Last Edit: February 03, 2019, 02:18:15 am by NERV Agent »

Vehek

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: PSX Tools/Scripts for LZSS/ Video game compression (Saga Frontier hacking)
« Reply #4 on: February 03, 2019, 01:46:20 am »
creeperton, in short, was the name a major Saga Frontier hacker used here before he wiped out almost every post he ever made on any site. On GameFAQs, he was Mir_Vimes.
You can see what's left of a thread where I guided him through the decompression process using a different LZSS tool here:
http://forums.qhimm.com/index.php?topic=15521

NERV Agent

  • Restricted Access
  • Sr. Member
  • *
  • Posts: 497
  • Eva Unit 01
    • View Profile
    • Watch my anime shitposts on YouTube! Smell them, too!
Re: PSX Tools/Scripts for LZSS/ Video game compression (Saga Frontier hacking)
« Reply #5 on: February 03, 2019, 02:14:57 am »
Zanerus, just to let you know I've updated my previous post with info that makes things less confusing.

Zanerus

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
Re: PSX Tools/Scripts for LZSS/ Video game compression (Saga Frontier hacking)
« Reply #6 on: February 03, 2019, 02:21:22 am »
creeperton, in short, was the name a major Saga Frontier hacker used here before he wiped out almost every post he ever made on any site. On GameFAQs, he was Mir_Vimes.
You can see what's left of a thread where I guided him through the decompression process using a different LZSS tool here:
http://forums.qhimm.com/index.php?topic=15521

I've been using Vimes notes as a jumping off point, so that doesnt suprise me. The fact he dissapeared inspired me to try making my own patch. Even though more than half of it is just finding all his notes across the internet. Ill check the thread in the morning more thoroughly, though it seems a lzs compression tool already exists then. Thank you very much.
« Last Edit: February 03, 2019, 02:28:37 am by Zanerus »

NERV Agent

  • Restricted Access
  • Sr. Member
  • *
  • Posts: 497
  • Eva Unit 01
    • View Profile
    • Watch my anime shitposts on YouTube! Smell them, too!
Re: PSX Tools/Scripts for LZSS/ Video game compression (Saga Frontier hacking)
« Reply #7 on: February 03, 2019, 02:23:51 am »
In your case, it might be as simple as just using "lzss" on your modified "Battle.OUT" and renaming it "Battle.ARC", assuming that password protection in the original ".ARC" file doesn't complicate the situation.

What is even up with password protected files in a ROM? This is the first I've heard of it.

Zanerus

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
Re: PSX Tools/Scripts for LZSS/ Video game compression (Saga Frontier hacking)
« Reply #8 on: February 03, 2019, 02:32:28 am »
In your case, it might be as simple as just using "lzss" on your modified "Battle.OUT" and renaming it "Battle.ARC", assuming that password protection in the original ".ARC" file doesn't complicate the situation.

What is even up with password protected files in a ROM? This is the first I've heard of it.

I can edit Battle.Arc via a hex editor i just cant seem to extract it with the extractor PeaZip which may just be due to a coding error and instead the program thinks its encrypted via a password. Thats my guess after reading the links you guys posted.

Im hoping tommorrow after work it ends up being as simple as you suggested.

Vehek

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: PSX Tools/Scripts for LZSS/ Video game compression (Saga Frontier hacking)
« Reply #9 on: February 03, 2019, 03:09:56 am »
Since I don't know how much is still remembered post-Vimes about Saga Frontier files, I should point out that the compressed data is only one "sub-file" of battle.arc.

Haven't tested this, been a long time. For decompressing (not really necessary):
1.Copy bytes from offset 0x10 to offset 0x3A59C into a new file.
2.Run whatever lzss decompress tool on this new file.

For recompressing, you would either paste over the recompressed data or reconstruct the file (need to adjust offsets in header if recompressed data is bigger probably).

NERV Agent

  • Restricted Access
  • Sr. Member
  • *
  • Posts: 497
  • Eva Unit 01
    • View Profile
    • Watch my anime shitposts on YouTube! Smell them, too!
Re: PSX Tools/Scripts for LZSS/ Video game compression (Saga Frontier hacking)
« Reply #10 on: February 03, 2019, 05:47:02 am »
I can edit Battle.Arc via a hex editor i just cant seem to extract it with the extractor PeaZip which may just be due to a coding error and instead the program thinks its encrypted via a password. Thats my guess after reading the links you guys posted.

Im hoping tommorrow after work it ends up being as simple as you suggested.

These Squaresoft games use a proprietary version of the "lzss" compression format. Your usual decompression tool you would use for a PC file isn't going to work here.

Use "unbinlz" included in FF7Tools.

Zanerus

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
Re: PSX Tools/Scripts for LZSS/ Video game compression (Saga Frontier hacking)
« Reply #11 on: February 03, 2019, 10:39:21 am »
Since I don't know how much is still remembered post-Vimes about Saga Frontier files, I should point out that the compressed data is only one "sub-file" of battle.arc.

Haven't tested this, been a long time. For decompressing (not really necessary):
1.Copy bytes from offset 0x10 to offset 0x3A59C into a new file.
2.Run whatever lzss decompress tool on this new file.

For recompressing, you would either paste over the recompressed data or reconstruct the file (need to adjust offsets in header if recompressed data is bigger probably).

We lost a fair bit of data, myself and a few other gamefaq users have been searching the net for his posts. He had a habbit to  post every question on a different thread. Besides compressing the battle.out, the other big thing we lost was how battle scripts effect boss stats. Certain bosses such as the final bosses will have their stats perodically be swapped as a work around to the 65k hp max.

So ive been using CDMage to import files when i change them, mostly because most data is located in the spc_90 file. My question is if the offset is different will CDmage work or would i need a new tool?

I can't wait to get home and test this.

February 04, 2019, 12:26:09 am - (Auto Merged - Double Posts are not allowed before 7 days.)
So I totally cheated but I got it to work, also a compressed Battle.OUT is 35a80 in size, while the orginal section of battle arc retaining to it is 35A9C I'm not sure if this will cause glitches or not.

Using http://forums.qhimm.com/index.php?topic=15325.0 tool I compressed my modified Battle.OUT and opening up Arc in my hex editor of choice, paste write the compressed .OUT at 0x10 in Arc then reinserted the modifed Arc file into the disk image. I fought the Minotaur in timelord's area around ten times and got power belt 3/4ths of the time when the drop rate was modifed to 01 (normally the drop rate on power belt is 1/64th. Again I'm not sure if this is gonna cause bugs but I'd say its a success.
« Last Edit: February 04, 2019, 12:26:09 am by Zanerus »