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

Author Topic: Help rebuilding PSX ISO with cd-tool  (Read 1011 times)

theflyingzamboni

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Help rebuilding PSX ISO with cd-tool
« on: January 31, 2018, 02:51:41 pm »
So I'm working on a text hack, but after inserting some of my script, the file that contains all the text has exceeded the original file size, so CDMage won't work. From what I've read, the best way to deal with this is using cd-tool to rebuild a new ISO.

I've read the documentation that comes with the program, but I'm not finding the explanations particularly clear. There also isn't a practical example of a script for the ISO rebuilding process, and I can't find anything like that anywhere.

Is there anyone with experience using cd-tool who can help me out? A more in-depth explanation of how to use the program, or ideally, a working lua script that someone has used for a game so I could see how it works?
ROM wasn't hacked in a day.

mz

  • Sr. Member
  • ****
  • Posts: 400
  • Whore
    • View Profile
Re: Help rebuilding PSX ISO with cd-tool
« Reply #1 on: January 31, 2018, 03:55:26 pm »
Have you already tried PSX-MODE2? I believe its author mentioned that it supported adding bigger files, but I've never tried inserting one!
There has to be a better life.

theflyingzamboni

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Help rebuilding PSX ISO with cd-tool
« Reply #2 on: January 31, 2018, 05:39:41 pm »
Have you already tried PSX-MODE2? I believe its author mentioned that it supported adding bigger files, but I've never tried inserting one!

Wow, you are a lifesaver! PSX-MODE2 didn't come up in any of the threads I found discussing inserting larger files. Waaaaaay easier to use than cd-tool.  :laugh:

I tried it, and it seems like it works. I quickly zipped through the first bit of the game, and nothing broke. Intro FMV's played, sound was fine, areas loaded normally, and the changes I made appeared as expected. Or at least the ones I could get to.

Turns out all of those save states I carefully made for testing purposes are completely useless now. I was hoping it wouldn't matter to the emulator, but nope. When it doesn't simply crash upon leaving the area I took the save state in, it has all kinds of weird effects. That's going to make testing difficult, needing new save states any time I change the size of the ISO.

Still, utility worked as advertised, so thanks!
ROM wasn't hacked in a day.

weissvulf

  • Sr. Member
  • ****
  • Posts: 324
  • Good news! An anomaly solved the enigma.
    • View Profile
Re: Help rebuilding PSX ISO with cd-tool
« Reply #3 on: February 01, 2018, 06:48:22 pm »
I'm curious what else you've had to hack to account for the moved files. When I've done stuff similar to this in the past, it was quite a pain to get the expanded data to work properly. Did you have to hack a bunch of internal values?

Also, a side question, did you ever find a pointer editor that supports bit shifting? I ran into the same thing- a game with a 6-bit tag tacked onto each pointer. After the tag is extracted, there's a couple more bit-shifts to make everything 32bit aligned. I'm trying to decide the best way to deal with editing these.  :banghead:

theflyingzamboni

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Help rebuilding PSX ISO with cd-tool
« Reply #4 on: February 02, 2018, 12:00:12 pm »
I'm curious what else you've had to hack to account for the moved files. When I've done stuff similar to this in the past, it was quite a pain to get the expanded data to work properly. Did you have to hack a bunch of internal values?

Also, a side question, did you ever find a pointer editor that supports bit shifting? I ran into the same thing- a game with a 6-bit tag tacked onto each pointer. After the tag is extracted, there's a couple more bit-shifts to make everything 32bit aligned. I'm trying to decide the best way to deal with editing these.  :banghead:

I'm not completely sure what you mean, as this is the first time I've exceeded a sector boundary and had to deal with adding an enlarged file to an ISO. PSX-MODE2 handled whatever was needed for the image to account for that. Of course, the new image is still not fully tested, so I'm not positive everything will work.

Unless you mean like the subfiles that make up the the .BIN file that I extracted from the disc? In that case, the answer is the same as for the pointer editor: I brushed up on my Python and created a toolset. ;D So I do have to hack a bunch of internal values, but the tool that I wrote to reconstruct files from their component files updates the file address/size table automatically. So if the size of one of those files changes, the game still knows where to find the files after it, just like normal.

The script dumper and inserter I wrote deal with the pointers in a similar fashion. I just give them the location range of the pointer table(s), and it bit shifts each value as it's read/written. I dump the script to a text file for editing, then insert it back in. When the inserter writes a text block to the file, the pointer is recalculated from its new position before bit shifting and writing it. That way the pointer values are properly updated. My pointers didn't have tags, though, so I don't know what to do about that. Are they actually tags of some sort, or just 0x00's padding out the 32-bit word?
« Last Edit: February 02, 2018, 12:09:42 pm by theflyingzamboni »
ROM wasn't hacked in a day.

weissvulf

  • Sr. Member
  • ****
  • Posts: 324
  • Good news! An anomaly solved the enigma.
    • View Profile
Re: Help rebuilding PSX ISO with cd-tool
« Reply #5 on: February 02, 2018, 06:52:32 pm »
Quote
I'm not completely sure what you mean
It sounds like you dealt with the sort of thing I meant. A game I was working on had multiple data blocks that loaded to RAM as needed. The blocks contained executable code, text etc. I needed more room for text in some of these files so I considered enlarging some of the 'blocks'. The game didn't use the CD tale of contents, but a custom loader routine. If I had enlarged one block, it would have displaced all the blocks 'downstream' and I would have had to find all the areas where the load-routine was called and alter the values passed to it. Also, the RAM area after where the blocks were loaded was in use and that caused issues.

I tend to 'miss the obvious' sometimes, so I just wondered if I was doing something stupid.

Quote
The script dumper and inserter I wrote...
Ah, a custom editor - cool.

Quote
Are they actually tags of some sort, or just 0x00's padding out the 32-bit word?
It is a tag. The text routine loads it with the pointer, extracts the 6bit tag, tests it against about 10 values to determine where to direct the draw routine, then finally shifts the pointer right 6 to erase the tag, then left 2 to get to the final value. I'm thinking that if I extract the tags when the text is dumped, ARMIPS can handle the math when reinserting. Maybe ARMIPS supports bitshift operations natively? Not really sure. :P