Skip to content

Commit

Permalink
Updated to 1.23 fixing LBA bugs on audio tracks integrated as files
Browse files Browse the repository at this point in the history
  • Loading branch information
Lameguy64 committed Dec 20, 2018
1 parent af216c6 commit 7196686
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 31 deletions.
33 changes: 20 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# MKPSXISO
Basically a modern clone of BUILDCD that came included with the leaked PlayStation PsyQ SDK used for creating ISO disc images for developing PlayStation software. The problem with BUILDCD however is that it is an old real-mode DOS program and will not work natively on 64-bit versions of Windows without a DOS emulator which not only makes automated build scripts that produce ISO images messy and inconvenient to manage but it also slows down ISO creation speed considerably.
MKPSXISO is basically a modern clone of BUILDCD used for building CD images of PlayStation games in the official development tools. The problem with BUILDCD however is, apart from licensing issues, its an old 16-bit DOS program which will not work natively under 64-bit versions of Windows without a DOS emulator which not only makes automated build scripts that produce ISO images messy in homebrew development but it also slows ISO creation speed considerably. BUILDCD also only produces CD images in a special image format supported by early CD burners and must be converted to an ISO format with a separate tool making the already slow ISO creation process even slower.

Also, BUILDCD only produces CD images in a non standard CD image format used by early CD burners which must be converted to a usable ISO format with a separate tool. This makes the already slow ISO generation process even slower.

While other ISO creation tools such as MKISOFS may work as an alternative, most do not let you control the order of the files stored in the ISO image (and is essential for optimizing file order to speed up access times) and all do not support mixed-mode XA files for streamed data such as XA audio and MDEC video streams. MKPSXISO was made specifically to replace BUILDCD to aid in PlayStation homebrew development on modern systems as well as modification/hacking of existing PlayStation titles.
While other ISO creation tools such as MKISOFS may work as an alternative most do not let you control the order of the files stored in the ISO image which is essential for optimizing file order to speed up access times and all do not support mixed-mode type files for CD streaming such as XA audio and MDEC video streams. MKPSXISO is made specifically to replace BUILDCD to aid in PlayStation homebrew development on modern systems as well as modification/hacking of existing PlayStation titles. MKPSXISO can also be used as a regular ISO creation tool that complies with the older ISO9660 standard with no Joliet extensions.

MKPSXISO more or less replicates most of the functionality of BUILDCD but better! The most notable difference is that MKPSXISO is much faster and creates ISO images in either standalone iso or cue+bin format so that generated images can immediately be run on an emulator or burned to a CD.

Another notable difference of MKPSXISO is that it injects the Sony license data correctly into the disc image which eliminates the need of having to use a separate program for properly licensing the ISO image. However, the license data is not included so one must have a copy of the official PlayStation Programmer's Tool SDK or the PsyQ SDK (both of which can be found in www.psxdev.net) for the license files to be able to take advantage of this feature. This is to avoid possible legal problems when including Sony's license data into open source programs... Better to be safe than sorry!
Another notable difference of MKPSXISO is that it injects the Sony license data correctly into the disc image which eliminates the need of having to use a separate program for properly licensing the ISO image. However, the license data is not included so one must have a copy of the official PlayStation Programmer's Tool SDK or the PsyQ SDK (both of which can be found in www.psxdev.net) for the license files to be able to take advantage of this feature. This is to avoid possible legal problems when including Sony's license data into open source programs.

## Features
* Uses XML for scripting ISO projects.
Expand Down Expand Up @@ -36,13 +34,18 @@ Older versions (probably going to be removed soon, there's no benefit to using t
This tool requires tinyxml2 to compile.
Compile with --std=c++11.

### Windows (CodeBlocks without CMake)
1. Install CodeBlocks (Preferably with MinGW32 GCC compiler bundled).
### Windows (make, no Netbeans)
1. Install your preferred MinGW GCC compiler.
2. Extract and compile tinyxml2 in the root of your C: drive (C:\tinyxml2).
3. Make sure the tinyxml2 library is named libtinyxml2.a.
3. Open the project file mkpsxiso.cbp inside the src directory.
4. Press Ctrl+F9 to compile the program.
5. The result will be in the base folder named "mkpsxiso.exe"
4. Run "mingw32-make CONF=Release" in the mkpsxiso directory.
5. The result will be in "dist\Release\MinGW-Windows" named "mkpsxiso.exe".

### Windows (Netbeans)
1. Extract and compile tinyxml2 in the root of your C: drive (C:\tinyxml2).
2. Open the mkpsxiso directory as a project within the Netbeans IDE.
3. Select Release build and press F6 to compile.
4. The result will be in "dist\Release\MinGW-Windows" named "mkpsxiso.exe".

### Windows (CMake)
1. Install cygwin64 with the following:
Expand All @@ -55,10 +58,10 @@ Compile with --std=c++11.
4. Run "cmake ." to generate the make file.
5. Run "make" to compile the program.
6. The result will be in bin_win, named "mkpsxiso.exe"

### Linux (Ubuntu)
### Linux (Ubuntu/CMake)
1. Install the following:
* Build Essentials
* Build Essentials (gcc, g++, make)
* cmake
* tinyxml2
2. Open a terminal.
Expand Down Expand Up @@ -104,6 +107,10 @@ This can be avoided by minimizing identically named directories but its best to

## Changelog

**Version 1.23 (12/20/2018)**
* Fixed broken LBA and timecode calculation for audio tracks integrated as files (iso::DirTreeClass::GetWavSize returns an incorrect value from the WAV file).
* Updated build instructions (CodeBlocks project had been replaced with Netbeans but forgot to update instructions).

**Version 1.22 (12/4/2018)**
* Fixed issues with subheader detection logic and made it as a warning instead of a critical error.
* Fixed bug where CD-DA length of possibly being 1 sector larger than it should.
Expand Down
8 changes: 4 additions & 4 deletions nbproject/Makefile-Debug.mk
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,22 @@ ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/mkpsxiso.exe: ${OBJECTFILES}
${OBJECTDIR}/src/cdwriter.o: src/cdwriter.cpp
${MKDIR} -p ${OBJECTDIR}/src
${RM} "$@.d"
$(COMPILE.cc) -g -s -I/C/tinyxml2 -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/src/cdwriter.o src/cdwriter.cpp
$(COMPILE.cc) -g -s -DDEBUG -I/C/tinyxml2 -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/src/cdwriter.o src/cdwriter.cpp

${OBJECTDIR}/src/edcecc.o: src/edcecc.cpp
${MKDIR} -p ${OBJECTDIR}/src
${RM} "$@.d"
$(COMPILE.cc) -g -s -I/C/tinyxml2 -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/src/edcecc.o src/edcecc.cpp
$(COMPILE.cc) -g -s -DDEBUG -I/C/tinyxml2 -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/src/edcecc.o src/edcecc.cpp

${OBJECTDIR}/src/iso.o: src/iso.cpp
${MKDIR} -p ${OBJECTDIR}/src
${RM} "$@.d"
$(COMPILE.cc) -g -s -I/C/tinyxml2 -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/src/iso.o src/iso.cpp
$(COMPILE.cc) -g -s -DDEBUG -I/C/tinyxml2 -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/src/iso.o src/iso.cpp

${OBJECTDIR}/src/main.o: src/main.cpp
${MKDIR} -p ${OBJECTDIR}/src
${RM} "$@.d"
$(COMPILE.cc) -g -s -I/C/tinyxml2 -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/src/main.o src/main.cpp
$(COMPILE.cc) -g -s -DDEBUG -I/C/tinyxml2 -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/src/main.o src/main.cpp

# Subprojects
.build-subprojects:
Expand Down
3 changes: 3 additions & 0 deletions nbproject/configurations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
<incDir>
<pElem>C:/tinyxml2</pElem>
</incDir>
<preprocessorList>
<Elem>DEBUG</Elem>
</preprocessorList>
</ccTool>
<linkerTool>
<linkerAddLib>
Expand Down
51 changes: 40 additions & 11 deletions src/iso.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,37 @@ int iso::DirTreeClass::GetWavSize(const char* wavFile)

fread( &WAV_Subchunk1, 1, sizeof(WAV_Subchunk1), fp );

// Check if its a valid WAVE file
if ( memcmp( &WAV_Subchunk1.id, "fmt ", 4 ) )
{
fclose( fp );
return 0;
}

// Search for the data chunk
struct
{
char id[4];
int len;
} WAV_Subchunk2;

while ( 1 )
{
fread( &WAV_Subchunk2, 1, sizeof(WAV_Subchunk2), fp );

if ( memcmp( &WAV_Subchunk2.id, "data", 4 ) )
{
fseek( fp, WAV_Subchunk2.len, SEEK_CUR );
}
else
{
break;
}
}

fclose( fp );

return 2352*((WAV_Subchunk1.size+2351)/2352);
return 2352*((WAV_Subchunk2.len+2351)/2352);
}

int iso::DirTreeClass::PackWaveFile(cd::IsoWriter* writer, const char* wavFile, int pregap)
Expand Down Expand Up @@ -187,23 +215,23 @@ int iso::DirTreeClass::PackWaveFile(cd::IsoWriter* writer, const char* wavFile,
{
char id[4];
int len;
} Subchunk2;
} WAV_Subchunk2;

while ( 1 )
{
fread( &Subchunk2, 1, sizeof(Subchunk2), fp );
fread( &WAV_Subchunk2, 1, sizeof(WAV_Subchunk2), fp );

if ( memcmp( &Subchunk2.id, "data", 4 ) )
if ( memcmp( &WAV_Subchunk2.id, "data", 4 ) )
{
fseek( fp, Subchunk2.len, SEEK_CUR );
fseek( fp, WAV_Subchunk2.len, SEEK_CUR );
}
else
{
break;
}
}

waveLen = Subchunk2.len;
waveLen = WAV_Subchunk2.len;

// Write pregap region
memset(buff, 0x00, CD_SECTOR_SIZE);
Expand Down Expand Up @@ -324,7 +352,7 @@ int iso::DirTreeClass::AddFileEntry(const char* id, int type, const char* srcfil
printf(" ");
}

printf("WARNING: %s does not have a valid subheader. ", srcfile);
printf("WARNING: %s may not have a valid subheader. ", srcfile);
}

// Check STR data
Expand Down Expand Up @@ -579,9 +607,9 @@ int iso::DirTreeClass::CalculateTreeLBA(int lba)
for ( int i=0; i<entries.size(); i++ )
{
// Set current LBA to directory record entry
if ( ( entries[i].type == EntryDA ) && ( first_track ) )
if ( ( entries[i].type == EntryDA ) && ( !first_track ) )
{
entries[i].lba = 150+lba;
entries[i].lba = lba;
}
else
{
Expand Down Expand Up @@ -615,12 +643,12 @@ int iso::DirTreeClass::CalculateTreeLBA(int lba)
{
if ( !first_track )
{
lba += ((entries[i].length+2351)/2352);
lba += ((entries[i].length+2351)/2352)+150;
first_track = true;
}
else
{
lba += ((entries[i].length+2351)/2352)+150;
lba += ((entries[i].length+2351)/2352);
}
}
}
Expand Down Expand Up @@ -1248,6 +1276,7 @@ int iso::DirTreeClass::WriteCueEntries(FILE* fp, int* trackNum)
{
((DirTreeClass*)entries[i].subdir)->WriteCueEntries( fp, trackNum );
}

}

return *trackNum;
Expand Down
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "cdwriter.h" // CD image writer module
#include "iso.h" // ISO file system generator module

#define VERSION "1.22"
#define VERSION "1.23"


namespace global
Expand Down Expand Up @@ -107,7 +107,7 @@ int main(int argc, const char* argv[])
if ( argc == 1 )
{
printf( "mkpsxiso [-y] [-q] [-o <file>] [-lba <file>] "
"[-lbahead <file>] [-nolimit] [-noisogen] <xml>\n\n" );
"[-lbahead <file>] [-nolimit]\n [-noisogen] <xml>\n\n" );
printf( " -y - Always overwrite ISO image files.\n" );
printf( " -q - Quiet mode (prints nothing but warnings and "
"errors).\n" );
Expand Down Expand Up @@ -1066,7 +1066,7 @@ int ParseDirectory(iso::DirTreeClass* dirTree, tinyxml2::XMLElement* dirElement)
{
printf( " " );
}
printf( "ERROR: DA audio file(s) found but no CUE sheet specified.\n" );
printf( "ERROR: DA audio file(s) specified but no CUE sheet specified.\n" );
return false;
}
found_da = true;
Expand Down

0 comments on commit 7196686

Please sign in to comment.