How do PS1 ISO checksums work?

Post a topic about yourself to let others know your skills, hobbies, etc.
Post Reply
RagDas
What is PSXDEV?
What is PSXDEV?
Posts: 3
Joined: Oct 19, 2022

How do PS1 ISO checksums work?

Post by RagDas » April 1st, 2024, 11:34 pm

As in the title, I'm looking to test specific changes using a hex editor (namely making manual changes to TMD files), and was wondering how I could make changes in hex and get the game to run. In my experience on the N64 side of things, the checksum needs to get recalculated to get a modified ROM to run. If the same principle applied to PS1 ISOs, how would one go about doing the same thing? Are there tools fit for this purpose?

User avatar
Squaresoft74
Verified
/// PSXDEV | ELITE ///
/// PSXDEV | ELITE ///
Posts: 309
Joined: Jan 07, 2016
PlayStation Model: SCPH-7502
Location: France
Contact:

Post by Squaresoft74 » April 2nd, 2024, 2:44 am

You may want to check this.

RagDas
What is PSXDEV?
What is PSXDEV?
Posts: 3
Joined: Oct 19, 2022

Post by RagDas » April 2nd, 2024, 11:18 pm

Thanks -- if I may clarify, what am I looking for, or what am I looking at?

User avatar
Squaresoft74
Verified
/// PSXDEV | ELITE ///
/// PSXDEV | ELITE ///
Posts: 309
Joined: Jan 07, 2016
PlayStation Model: SCPH-7502
Location: France
Contact:

Post by Squaresoft74 » April 3rd, 2024, 3:31 am

This is the explanation + source code on how to recompute the checksums for a sector you've modified.
If you just need tools for this, you can try ECCRegen or EDCRE.

User avatar
nocash
Verified
PSX Aficionado
PSX Aficionado
Posts: 555
Joined: Nov 12, 2012
Contact:

Post by nocash » April 3rd, 2024, 7:47 am

RagDas wrote: April 2nd, 2024, 11:18 pm Thanks -- if I may clarify, what am I looking for, or what am I looking at?
Yes, what did you do exactly, and did you run into any specific problems?

As by now, your question is a bit unclear.

ISO is slang that might refer to "the cdrom filesystem" or "the whole disc image" or "those warez downloads" or whatever.
You seem to have extracted the TMD file from the cdrom (?), but it isn't clear if you have plans for injecting it back into the cdrom image, or for recreating the whole image from scrarch up.
There is no such thing as PS1 checksums. But cdroms in general do have ECC and EDC checksums, as mentioned above.

Generally any cdrom tool should work, but there are a few psx-specific things: You need the psx licence/logo sectors at the begin of the disc image, and MODE2/FORM2 support for for XA-ADPCM audio, and support for CD-DA audio tracks (if any).

RagDas
What is PSXDEV?
What is PSXDEV?
Posts: 3
Joined: Oct 19, 2022

Post by RagDas » April 3rd, 2024, 5:02 pm

Alright that's fair! Let me elaborate in that case.

At this point in time, I have a single disc image (an ISO and a CUE file). Using PowerISO, I've been able to go into the ISO file and extract TMD files because they appear to just be sitting there out in the open. I can view these TMD files in Milkshape3D for example, so I can identify what the TMD models are used for.

In this specific instance, the TMD file pertains to a character model. This character model comprises multiple limbs and such (Face, Head, Neck, Chest, etc.). Milkshape3D allows me to remove all the components of the TMD and isolate just a single part of the TMD file (e.g. just the head), and then re-export as a TMD. From what I can tell, if I view the original ISO file in a Hex Editor, and view the same TMD file that I exported (containing just the head) in the Hex Editor, I've been able to find the data for that TMD file in the ISO.

What I'm trying to achieve at this point is replacing individual components of a TMD to modify the existing character model. I'm only using components that were already in the game, so nothing here is custom. It's purely switching one extracted component of a TMD model for another (e.g. swapping one head for another). Understandably, when I do make this change in the Hex Editor and save it, the game will crash when it tries to load up a character that uses the TMD file that I've just changed in the Hex Editor, within the overall ISO. I am assuming that the reason the game crashes is because I have modified a file without adjusting the checksum; this same principle applies in N64 games, so that's where my assumption is coming from.

Based on the above scenario, where it is just TMD modification, how much of what you described towards the end of your explanation would I need to consider? No audio is being replaced in this case, and in the little experimentation I've done, the game still boots up, just crashes at the loading screen when the character is selected. I will double check that I've not misspoken on that front.

User avatar
nocash
Verified
PSX Aficionado
PSX Aficionado
Posts: 555
Joined: Nov 12, 2012
Contact:

Post by nocash » April 3rd, 2024, 7:58 pm

All psx sectors are MODE2 sectors, which are usually 930h bytes tall, and contain only 800h bytes of data (or more for audio sectors). So you need to slice your TMD file into 800h byte snippets, and insert those at the correct location in the 930h byte sectors. And then fix the ECC/EDC in the remaining 130h bytes (although many emulators or disc tools may ignore the ECC or EDC or both, so (if you don't want to release the file to other people) you might get away without fixing them).

Note: 930h is the most common sector size, the exact size of your disc-image sectors is stored in your CUE file, in decimal.

If you replace one head for another, I don't understand how you could do that easily. You would need to take care that the changed TMD file has the exact same size as the old one (aka as specified in the cdrom directory entries). And of course, textures for one head may - at least visually - appear totally wrong for another head.

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests