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

Author Topic: Adding files to PSX ISO?  (Read 3025 times)

Edward_Tohr

  • Newbie
  • *
  • Posts: 2
    • View Profile
Adding files to PSX ISO?
« on: October 27, 2014, 12:20:48 pm »
Hey, everyone.

I'd like to go poking around in Grandia. Per TCRF, one of the ways to do so is to create a new file inside the ISO. While the Gameshark code listed there does work, it has a few side-effects that make recording footage more difficult.

I've gotten the files extracted and the new one added, but I can't seem to get the modified ISO to play properly.

Any pointers?

Pyriel

  • Jr. Member
  • **
  • Posts: 23
    • View Profile
Re: Adding files to PSX ISO?
« Reply #1 on: October 28, 2014, 08:16:13 pm »
Well, they provide very little detail about how the file actually needs to be inserted.  Did your tool update the table of contents when you added the file?  Where did you add the file in the BIN directory?

If the tool you used to insert the file keeps the table of contents up to date, there are a couple of possibilities I can think of:
  • The intent is that DEBUG.BIN be the last file on the disc.  Looking at the ISO, it appears that the BIN directory is fairly early, so you might have to manipulate the tool a bit to get a file inserted at the tail-end of the image.
  • The usual reason for the ISO not working is that the game looks up files using a listing stored in the executable(s) somewhere.  Adding a file will force everything out of agreement with the listing.  You can probably find it by search the main executable for the LBA of one or two files from the original.  In the cases I have seen, the listing is a 32-bit LBA followed by a 32-bit file size.  The pattern repeats for each file, but not necessarily in perfect ascending order.  I mention this because you may be able to narrow the search a bit by looking for two contiguous files, but if you get no results it might only mean that the listing is in some wonky order.

Hopefully the first one isn't what you already tried.  If it is, the instructions on TCRF probably omit a few annoying steps.

BlackDog61

  • Hero Member
  • *****
  • Posts: 784
    • View Profile
    • Super Robot Wars A Portable translation thread
Re: Adding files to PSX ISO?
« Reply #2 on: October 29, 2014, 04:41:20 pm »
The usual reason for the ISO not working is that the game looks up files using a listing stored in the executable(s) somewhere.  Adding a file will force everything out of agreement with the listing.  You can probably find it by search the main executable for the LBA of one or two files from the original.  In the cases I have seen, the listing is a 32-bit LBA followed by a 32-bit file size.  The pattern repeats for each file, but not necessarily in perfect ascending order.  I mention this because you may be able to narrow the search a bit by looking for two contiguous files, but if you get no results it might only mean that the listing is in some wonky order.

Quick note: a game I've looked into has size before LBA offset (in case you are including size in the search). The size was in sectors.
Oh - and beware of little endianness, of course. ;)

Gemini

  • Hero Member
  • *****
  • Posts: 2025
  • 時を越えよう、そして彼女の元に戻ろう
    • View Profile
    • Apple of Eden
Re: Adding files to PSX ISO?
« Reply #3 on: October 30, 2014, 09:55:34 am »
That page mentions an AR code which seems to alter the exe area in order to avoid the need of DEBUG.BIN placed somewhere. You could easily locate the same data in the exe (usually you need to subtract 80010000 or 8000F800 from the address), change it like in the AR code, replace the exe with CDMage, and you're ready to go.
I am the lord, you all know my name, now. I got it all: cash, money, and fame.

Edward_Tohr

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Adding files to PSX ISO?
« Reply #4 on: November 23, 2014, 08:56:36 pm »
Whoops, forgot I asked here.

Well, they provide very little detail about how the file actually needs to be inserted.  Did your tool update the table of contents when you added the file?  Where did you add the file in the BIN directory?

I extracted the ISO to a directory, created the file, then created a new ISO from that. I figured that whatever sort of copy protection would stop that from working on an actual Playstation wouldn't trigger with an emulator.

I still have a lot to learn about PSX hacking.

Quick note: a game I've looked into has size before LBA offset (in case you are including size in the search). The size was in sectors.
Oh - and beware of little endianness, of course. ;)

Yeah, the game does things little endian-ly, at least as far as character stats and spell power and whatnot is concerned.

Would this LBA/Size list be in TITLE.EXE, or am I misunderstanding what "main executable" refers to?

That page mentions an AR code which seems to alter the exe area in order to avoid the need of DEBUG.BIN placed somewhere. You could easily locate the same data in the exe (usually you need to subtract 80010000 or 8000F800 from the address), change it like in the AR code, replace the exe with CDMage, and you're ready to go.

Shouldn't be too hard to locate; the default values for the debug access in RAM are 48 48 48 48, or "0000" as an ASCII string.

How would I go about replacing the exe, though? I've given CDMage a whirl and can't seem to figure out how to replace files. Or non-damaged sectors in general. EDIT: Ignore that, wasn't using the latest version.

Thanks for the help so far. Having even these questions is a good jumping-off point for actually learning what it is I need to do.
« Last Edit: November 23, 2014, 09:23:14 pm by Edward_Tohr »

Pyriel

  • Jr. Member
  • **
  • Posts: 23
    • View Profile
Re: Adding files to PSX ISO?
« Reply #5 on: December 02, 2014, 12:12:52 am »
Whoops, forgot I asked here.

I extracted the ISO to a directory, created the file, then created a new ISO from that. I figured that whatever sort of copy protection would stop that from working on an actual Playstation wouldn't trigger with an emulator.
That may or may not work depending on how you built the disc image.  If the whole thing was built in strictly Mode 1 or something, a good bit of the data will probably be trash from the hardware's or emulator's perspective.  If you're looking at this as a learning experience, I suggest using the opportunity to learn how to use PSX CD-Tool, or the LUA Interface kit that grew out of it.  Using those, it's fairly easy to extract the contents of the entire disc, and rebuild it while maintaining correct formats, and inserting files however you wish and in whatever order you like.

Would this LBA/Size list be in TITLE.EXE, or am I misunderstanding what "main executable" refers to?
Typically the main executable is named with the Sony-issued serial number, e.g., SLUS_000.00 in the root of the disc.  However, open up SYSTEM.CNF in a hex or text editor.  That will tell you what executable loads when the PSX starts up the game.  If there are multiple executables, that may not be the "main" one, though.  For instance, TITLE.EXE may load immediately to display company logos and such, and then it hands off to the main executable when you press start or choose an option from the title menu.

That said, any PSX executable file will most likely have the file listing inside it, assuming one exists, and it may be in other files.  In order for the game to function, you will probably have to apply any required corrections to all copies anyway.  So find it once, and then search for it elsewhere.  One game I've worked with has hundreds of files that contain executable code (but only one proper EXE), and something like 60-70 of them contain an LBA+size listing for the entire disc.  Every time I rebuild an image of it with new changes, the listing must be updated in all of them.