+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  [PSX CDROM] Instert New Files
Pages: 1 [2]
Author Topic: [PSX CDROM] Instert New Files  (Read 1 times)
Auryn
Guest
« Reply #15 on: September 21, 2010, 05:07:52 pm »

I'm a bit tired and just back from work...i see that u had some success...good.
First of all i confirm what Gemini said about the directory deeps. There are many games that use more than one directory deep...just see the pic of Metal Slug X:


I was just playing around to see if there is an easy way that u can get that extra directory to work and i discovered somethings that maybe can be helping u.
I was remembering there was a tool to build psx cd images so i tried to rip and rebuild VS with that tool but he gave me many times the error that the PSX supports max 30 files/directory (in fact it's wrong because we have many more files in each directory of VS)...umm
Ok, check my friend google and find out that that UltraIso can add directories and file to an ISO...ok, let's try it. just by adding an empty directory to the image of VS make ePSXe crash with error:


I had my Metal Slug X in the drive and decided to make the same with it because it's smaller...suprise... it works even with the XTRA directory and even with more files on that directory.


So, I don't remember exactly where all the differences between the different modes and image types are (longtime i don't fight with them heheh) but I would look what is the form of a TOC in a CD with less than xx files/directories (1350 files??) and the form of the TOC with more files/directories.
I rememeber something about a Secondary Descriptor, with less than xx files/directories u don't need the secondary descriptor ( u are probably modifying this version of TOC) and with more files u have to use it but it change the primary descriptor form too (I'm just remembering something like this). For this u will probably need to forget about the "rules" for the PSX and look on the iso9660 format.
Don't forget that u have 5132 files in 15 directories in VS and all need a place in the TOC (so much for the 45 directories*30files=1350...maybe in a standart PSX CD but not in this one heheh). Metal Slug X has 354 files in 28 directories.

By the way...why u want to add that directory??

I hope I could point to the right direction  Tongue
« Last Edit: September 21, 2010, 05:19:03 pm by Auryn »
Gemini
Guest
« Reply #16 on: September 21, 2010, 07:23:24 pm »

Quote from: Valendian on September 21, 2010, 02:16:42 pm
Thanks Gemini, seem's to be working correctly. Still getting file system errors but I think I can figure that one out with time.
What kind of errors are you still getting? The same as before?

Quote
Anybody got more detailed information regarding the subheader?
All you need to know about subheaders is the third byte, which is 0x08 or 0x89 in most cases of non-XA data sectors (the latter value is used as an EOF recognizer for the last sector of that entry).

By the way, I'm kinda interested in knowing how Vagrant Story manages to read the CD TOC even though Sony's streaming libraries are bugged and prevent the developers from accessing directory records that are longer than one sector (the process will just break when there's nothing more to parse in the first sector). At first I thought it could use a statically defined table with all the LBA/size values pre-stored, but most of the people who have hacked this game in the past told me it actually reads all the information from the TOC. Honestly, I still don't know whether to believe this or not, but if that's true then Square must have developed a replacement for the CdSearchFile() function. :0 Weird, as they never bothered to extensively access the TOC in any of their PlayStation games.

Quote from: Auryn on September 21, 2010, 05:07:52 pm
Ok, check my friend google and find out that that UltraIso can add directories and file to an ISO...ok, let's try it. just by adding an empty directory to the image of VS make ePSXe crash with error:
Nothing really new here. That UltraIso crap is well known for randomly killing ISOs, especially with PlayStation games. It's like the Hitler of ISO management programs.

Quote
So, I don't remember exactly where all the differences between the different modes and image types are (longtime i don't fight with them heheh) but I would look what is the form of a TOC in a CD with less than xx files/directories (1350 files??) and the form of the TOC with more files/directories.
No actual difference, other than the directory tree using more than one sector to store the child record list.

Quote
I rememeber something about a Secondary Descriptor, with less than xx files/directories u don't need the secondary descriptor ( u are probably modifying this version of TOC) and with more files u have to use it but it change the primary descriptor form too (I'm just remembering something like this).
Ok, now you're starting to mix apples with oranges. There's no such a thing as a secondary descriptor for handling longer folders, plus trying and guessing won't help much, other than bringing even more confusion.

Quote
Don't forget that u have 5132 files in 15 directories in VS and all need a place in the TOC (so much for the 45 directories*30files=1350...maybe in a standart PSX CD but not in this one heheh). Metal Slug X has 354 files in 28 directories.
This has nothing to do with adding a new folder. Valendian is talking about additional entries incorrectly parsed by CD-Mage.
Valendian
Guest
« Reply #17 on: September 21, 2010, 08:18:34 pm »

@Auryn: I stand corrected on the depth of the tree structure.

For one thing, This is for a NewGame+ mod for Vagrant Story, I want to rebalance the difficulty for second play through whilst leaving the default files intact for the first playthrough. Lotsa space to work with. And I need to be able to create new files. I also plan to use this feature in future for more complete mods, with new rooms, areas and characters. I thought the hardest part was gonna be patching the executable to use a second LBA table for NewGame+, silly me

@Gemini: Im getting the same error "Data track has errors in the file system, Continue Parsing?"

Vagrant Story uses a mixture of both LBA tables and Path table scanning to locate files. I haven't found it yet but the engine does use LBA tables for the character models, I know this because I nopped out the files, then used TOC Changer to relocate them, The game was hanging at the "Now Loading" screen, I searched all of the executables and RAM dumps for individual LBA's for the characters and found nothing. Other files are accessed via LBA tables such as the ZND (Zone Data) files, and the sound effects. LBA's for the Maps are stored in the ZND files. These LBA's can be located.

There are some files that can be relocated without breaking anything such as the executables (PRG). Or maybe I forgot to zero out those when I tried : P
Auryn
Guest
« Reply #18 on: September 21, 2010, 08:56:04 pm »

Oic...big plans :p

Check out this program...maybe he can tell u where your problem is but u have to email them to get the trial version Sad
From the screenshot it's looking very interesting especially the left pane:
http://www.infinadyne.com/CDStructure.html

Just curious, does your modified version start in an emulator??

Gemini
Guest
« Reply #19 on: September 22, 2010, 05:54:49 am »

Quote from: Valendian on September 21, 2010, 08:18:34 pm
LBA's for the Maps are stored in the ZND files.
So they don't refer to the TOC?
Auryn
Guest
« Reply #20 on: September 22, 2010, 10:46:48 am »

I was looking at the Ecma-119... u copied the file and directory descriptor of the Battle directory. I see that there are "Volume Sequence Number" on it...maybe u need to correct this one.
And there are many sizes in the different descriptors, u corrected all u need??

UltraIso is messing up because he rearrange all the directories and files of the iso.
At the same times i'm writing this, i was thinking that maybe u could use UltraIso to add the folder/files and then replace the executables on the right place (yes, i know that of the ZND files but if u not get your file system to work, u can't continue to work).

I'm still puzzling why UltraIso doesn't mess up Metal Slug.

Another idea is to contact the maker of UMDgen, there are sure parts in the descriptors that are in common.
Skeud
Guest
« Reply #21 on: September 22, 2010, 02:31:58 pm »

Quote from: Rocket Science on September 19, 2010, 08:30:06 pm
Oh, I should mention: the CD-Tool site is long dead and buried. I do have the last known Windows release though, which I should probably upload to here sometime. There were Linux builds as well, but I'm too lazy to go looking for those.
The new version of cd-tool is now calld lua-interface and can be fetched here.
Auryn
Guest
« Reply #22 on: September 22, 2010, 11:08:19 pm »

I'm back again at 6am with some stupid ideas but maybe between the many stupid ideas there are some good :p

I was looking on why UltraIso didn't mess MetalSlug and noticed that it actually it mess it up too. I was thinking that sector 23 is for system.cfg and 24 for the executable and because UltraIso moved this files, VS didn't start but i was wrong (at least the messed up image starts on the emulator).

Why UltraIso bother to rearrange all the files??
I compared the images and found out that UltraIso write the descriptors in different way:

UltraIso                                                       Vagrant Story           
...                                                                 ...
the 3 descriptors that u modified                the 3 descriptors that u modified
the descriptors for all the files on cd           system.cfg
data....                                                        SLUS-01040
                                                                   the tim in the root
                                                                   a descriptor for the files in the battle directory
                                                                   the data of the 3 files in the directory all contiguous to each others
                                                                   the descriptor for the files in the next directory

That the file are contiguous, was strange for me because the most PSx CDs have holes like a swiss cheese so I decided to try to find old document about ISO standarts.
In wiki i found this:
....
Iso Level 3: Files are allowed to be non-contiguous (i.e., fragmented), principally to allow packet writing or incremental CD recording).

U want to see that there is nothing wrong with your changes but u just don't have to use the hole u found (probably a hole between a file descriptor and the actual data) but use the first sector after the last file (i.e. LBA 319'001)?!?!?
I don't know if it matters or not but all first files in a directory start at a round sector (i.e. LBA xxxx00) so u should place your file descriptor at LBA 319'100.


Valendian
Guest
« Reply #23 on: September 22, 2010, 11:18:07 pm »

@Gemini:From what I have seen I believe that Vagrant Story uses LBA tables predominantly (exclusively? haven't been able to verify a case in which the LBA is NOT contained in a record) for its CDROM input. For one reason it's faster to simply suply the sector address than it is to scan a directory record table to find that same info. Also storing the filenames would take up more RAM than simply storing the LBA's.

@Auryn: Yes the image works but requires specifying the LBA's to the newly created files in the relevant ZND files. Also the Volume Sequence number is only used for file systems that span multiple discs. By that I mean a single file systems whos contents will not fit onto a single disc. not the same as a 2 disc game in which each disc posseses a file system which will fit onto a single disc. with each disc having a file system independant of the other discs. Also thanks for the link to CD scanner this tool reports that the only error in the file system is that the XMAP folder has a directory record for its current directory record (".") and its parent record ("..") that do not corrispond to the actual current directory. This has narrowed down the possibilities greatly. Thanks (No really thanks sincerely, you saved me a whole lot of work)

And no it does not matter that the files are ordered sequentially in fact with Vagrant Story this is common practice. nothing is wasted Zone files are directly followed by the Map files that make up the area which are followed by the ZUD (Zone Unit Data ie enemy) files that populate the rooms. all this is kept sequentially for fastest possible CD access with nothing separating one file from the next.

@ Skeud thanks for the link to the tool bro
Gemini
Guest
« Reply #24 on: September 23, 2010, 06:25:25 am »

Quote from: Valendian on September 22, 2010, 11:18:07 pm
@Gemini:From what I have seen I believe that Vagrant Story uses LBA tables predominantly (exclusively? haven't been able to verify a case in which the LBA is NOT contained in a record) for its CDROM input. For one reason it's faster to simply suply the sector address than it is to scan a directory record table to find that same info. Also storing the filenames would take up more RAM than simply storing the LBA's.
Oh, but I do know all the benefits of using a custom file system. Still, I was actually trying to point out one funny workaround: if no LBA is used why would you need to add entries to the TOC? Most PlayStation games don't rely on that at all, in fact you can just inject files anywhere you'd like and leave the TOC as is. All you've got to necessarily do is updating the type bytes in the subheader, but that can be automatically done with a tool specifically programmed for the occasion.
Valendian
Guest
« Reply #25 on: September 23, 2010, 10:50:15 am »

When Im working on Vagrant Story I usually have both pSX and CDMage running with the same image. I do all my edits through UltraEdit which allows me to run batch files. Most of my tools are in the form of commandline apps. But using CDMage to re-insert the files is slowing down the whole process. Also CDMage lacks this feature of creating new files. I need a command line tool that can perform the IO on the image. But at some point I will need to be able to open the image in CDMage to get at the files. So my app will need to conform to the ISO 9660 standards. Im not planning on building a massively complex tool with GUI and full of features, just some direct low level CD manipulation.
Pages: 1 [2]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC