Lameguy64 / mkpsxiso

ISO disc image maker written specifically for PlayStation homebrew development
GNU General Public License v2.0
223 stars 36 forks source link

Cue files might reference bin files incorrectly #20

Closed SeaLiteral closed 3 years ago

SeaLiteral commented 3 years ago

When I tried running a simple font demo in PCSX-Redux, it couldn't find the bin file. Turns out the culprit was here:

<iso_project
    image_name="build/langs.bin"
    cue_sheet="build/langs.cue"
>

I'm keeping source files in a directory/folder and the built files in a subdirectory/subfolder. And the xml file isn't built/generated, so it's in the same directory as the source code, the directory that I'm calling mkpsxiso from (through make).

The langs.bin file in the build directory ends up like this:

FILE "build/langs.bin" BINARY
  TRACK 01 MODE2/2352
    INDEX 01 00:00:00

I think if the cue and bin files are in the same directory, it would make sense for the cue file to just reference the filename of the bin file, like this:

FILE "langs.bin" BINARY
  TRACK 01 MODE2/2352
    INDEX 01 00:00:00

I haven't rebuilt mkpsxiso after the CMake updates to this project and PSn00bSDK, so it's possible that games built with CMake avoid this issue. But I thought I should concentrate on the demo rather than adapting it to using CMake, so I thought I'd at least write somewhere that this can happen, in case others make some game and wonder why it works in some emulators but not others.

Edit: I had posted the same cue file contents twice in the above post. I've fixed that now. I've also looked into what happens if I call mkpsxiso from the target directory, and it works with some tweaks, which I'll put in a comment.

ABelliqueux commented 3 years ago

I've come up with a fix but it means switching to c++17 in order to have access to <filesystem> :

FWIW, the relevant code was here :

https://github.com/Lameguy64/mkpsxiso/blob/master/src/main.cpp#L306-L307

fprintf( cuefp, "FILE \"%s\" BINARY\n",
global::ImageName.c_str() );

~https://github.com/ABelliqueux/mkpsxiso/commit/869091d7e0f21a46aa69ed3c111e8db2fa1d77cd~ ~https://github.com/ABelliqueux/mkpsxiso/commit/1232e9d88f83e80e312293e824e09eaf8fd5bdcd~

~Should I PR those changes ?~

EDIT: PR links are dead

SeaLiteral commented 3 years ago

Building from the target directory seems possible but took me a couple of tries:

  1. If I go into the build directory and run mkpsxiso -y -q ../iso.xml, it exits with the error ERROR: Unable to create cue sheet.
  2. If I then replace the paths to the generated files, it says it can't find system.cnf (probably because it's looking for it in the build directory).
  3. Finally, I removed all references to build/ in the XML file and added ../ to all paths that referred to source files. Then it seems to work as intended.
Lameguy64 commented 3 years ago

I've just committed a quick fix that strips the path of the .bin file in the cue sheet that doesn't need that stupid filesystem library. I haven't been able to test it properly because msys64 seems to be broken as mkpsxiso throws a segfault when it starts to build the disc image (not related to my changes, crashes during the directory tree building process) and was unable to debug it with gdb as it fails to open source files and locks up on breakpoints, but the changes should work.

64ghost commented 3 years ago

This problem fixed in the fork https://github.com/brill2k/mkpsxiso

ABelliqueux commented 3 years ago

@Lameguy64 I can confirm it works after building the last commit on Linux. Cheers!

SeaLiteral commented 3 years ago

I can confirm it works after building the last commit on Linux. Cheers!

So can I. So I guess I could close this issue now, since the only issue from this that remains would be if you try to put the bin and cue files in different directories, which I don't see why people would want to do (other than to make it work differently in different emulators). Thanks!