diff --git a/CRC16.bmx b/CRC16.bmx index 2221832..50d6ea9 100644 --- a/CRC16.bmx +++ b/CRC16.bmx @@ -40,22 +40,4 @@ Function CRC16:Short(Array:Byte[]) cksum:Short = CRC16_tab[(cksum:Short Shr 8) ~ Array[i]] ~ (cksum Shl 8) Next Return ~cksum:Short -End Function -Local QSub:Byte[10] - -rem -QSub[0] = $41 -QSub[1] = $01 -QSub[2] = $01 -QSub[3] = $23 -QSub[4] = $06 -QSub[5] = $05 -QSub[6] = $00 -QSub[7] = $03 -QSub[8] = $08 -QSub[9] = $01 - - -Print Hex(crc16(QSub) + 128) -Print crc16(QSub) -endrem \ No newline at end of file +End Function \ No newline at end of file diff --git a/README.md b/README.md index b8c3f3c..5eab7c2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ + # SBITools -SBITools v0.2 - http://kippykip.com +SBITools v0.2.1 - http://kippykip.com **Description:** This is a small set of conversion tools written in BlitzMax to reconstruct .SUB files using .SBI/.LSD files, and can even convert a full BIN/CUE/SBI emulator setup into a IMG/CCD/SUB setup which can be put into popular CD Burning programs such as CloneCD. @@ -27,15 +28,22 @@ SBITools v0.2 - http://kippykip.com \SUB\GAMENAME\GAMENAME.SUB -cue2ccd: Converts a 'BIN/CUE/SBI|LSD' setup into a 'IMG/CCD/CUE/SUB' setup. This makes burning LibCrypt games easily possible with software such - as CloneCD" - It exports the converted files to the "\CCD\GAMENAME\" directory + as CloneCD. SBI/LSD files are loaded from the same directory as the .CUE + file under the same name. + + It exports the converted files to the "\CCD\GAMENAME\" directory, + remember to burn/launch the game from the .CCD file and not the .CUE file! **Notes:** - It's ***very important*** to note, SBI files do not contain the CRC16 bytes, which is needed for certain games such as V-Rally 2: Championship Edition, MediEvil and most likely a few others. Most LibCrypt games I've tested don't check for this though. + It's ***very important*** to note, SBI files do not contain the CRC16 bytes, which is needed for certain games such as V-Rally 2: Championship Edition, MediEvil and most likely a few others. Most LibCrypt games I've tested don't check for these two bytes though. - Regardless, SBITools v0.2 now partially reconstructs the CRC16 using a XOR of $0080 although it's not a perfect reconstruction for the whole SubChannel in anyway (as that's impossible). - Until I find a way to recreate it enough to be playable, some games may not work (I know MediEvil is one of them!) I obviously can't test every game to see if it passes LibCrypt, so in the meantime if you're a purist like me, definitely go for .LSD files instead. They're the superior format (and I'm not sure why they weren't the standard instead of .SBI) + ~~Regardless, SBITools v0.2 now partially reconstructs the CRC16 using a XOR of $0080 although it's not a perfect reconstruction for the whole SubChannel in anyway (as that's impossible). + Until I find a way to recreate it enough to be playable, some games may not work (I know MediEvil is one of them!)~~ + SBITools v0.2.1 now creates a CRC16 the same way Mednafen does by making a false CRC16 hash with "bitwise exclusive or", as LibCrypt only checks if it's the wrong hash in order to start the game. Every LibCrypt game I own that I've tested now works fine with SBITool's SBI functions, including MediEvil mentioned above. + +While this is enough to start a LibCrypt game, if you're a purist like me and want the original CRC16 bytes anyway, definitely go for .LSD files instead. They're the superior format (and I'm not sure why they weren't the standard instead of .SBI) They can be easily found on http://redump.org/disc/DISCID#/lsd +Or you can get them all on the [releases page](https://github.com/Kippykip/SBITools/releases). Remember to ***ALWAYS*** test games converted with the **-cue2ccd** function on an emulator before you burn! I personally recommend using BizHawk (which uses Mednafen) and opening the converted game from the .CCD file. Do ***NOT*** run the game in BizHawk from the .CUE file! The LibCrypt copy protection will kick in if you do that! @@ -50,6 +58,9 @@ They can be easily found on http://redump.org/disc/DISCID#/lsd **Version History** + Version 0.2.1 + - SBI Patching functions were modified to now work with every game. + - Cleaned up a tiny bit of code in CRC16.bmx Version 0.2 - .SUB patch functions now also add the CD Audio track data to the subchannel. Although this change now requires you to specify a .CUE file instead of a Binary @@ -61,7 +72,7 @@ They can be easily found on http://redump.org/disc/DISCID#/lsd - Added -cue2ccd, which allows you to do a full burnable conversion. Version 0.1 - Initial release -# SBI File Format Specifications +## SBI File Format Specifications *HEADER* [4 BYTES] SUB\0 @@ -77,7 +88,7 @@ They can be easily found on http://redump.org/disc/DISCID#/lsd S B I NUL MIN SEC FRA DUM [ QSUB ] 53 42 49 00 03 08 05 01 41 01 01 07 06 05 00 23 08 05 I'm unsure why they didn't include the modified CRC16 bytes in SBI, as it's extremely important. -# LSD File Format Specifications +## LSD File Format Specifications *CONTINUOUS* [1 BYTE] Minutes (In HEX -> Text) @@ -90,7 +101,7 @@ I'm unsure why they didn't include the modified CRC16 bytes in SBI, as it's extr MIN SEC FRA [ QSUB ] [CRC16] 03 08 05 41 01 01 07 06 05 00 23 08 05 38 39 -# LibCrypt failed check, causes and effects +## LibCrypt failed check, causes and effects Here's a list of what LibCrypt'ed games will do to the player when it realises the SubChannel data isn't correct. Obviously these aren't all the LibCrypted games (check on Redump.org for that), these are just games I've personally tested and some I've been told about. Look out for these effects when testing games modified with SBITools on an accurate PSX emulator such as BizHawk. *(Run from .CCD)* @@ -105,6 +116,7 @@ The game will hang when you're introduced with the combat tutorial when the came **Lucky Luke: Western Fever (PAL)**\ The game stops when you get to the Mexican guy blocking the bridge, he just won't move from there, ever. Even when you complete the quest. +The game also has anti-cracking protection where the game will block a path with a fallen tree + maybe more. **MediEvil (PAL)**\ Will have a disc error icon upon loading The Hilltop Mausoleum. Interesting to note this was actually the *FIRST* game to use LibCrypt. @@ -131,7 +143,15 @@ The game will endlessly load on the heartbeat loading screen (with no disc activ **Wip3out (PAL)**\ The game will freeze when passing the finish line. -# CloneCD LibCrypt Ripping guide +## CloneCD LibCrypt Ripping guide TODO -# CloneCD LibCrypt Burning guide +## CloneCD LibCrypt Burning guide TODO +## Additional Credits: +**qnorsten**: For creating a script to grab all .LSD files from ReDump.org +**LoStraniero91, krHACKen**: For explaining some LibCrypt cause and effects. +**dizzzy**: For general assistance/important emulator advice. +**themabus**: SBI Format and XOR information on a [forum thread.](http://forum.redump.org/post/17317/#p17317) +**Mednafen**: Workaround for using SBI files without the original CRC16 bytes, and CRC16 function. +**Dremora**: Explanation and whereabouts of .LSD files, creator of [psxt001z](https://github.com/Dremora/psxt001z/). +*And everyone else at the ReDump team!* diff --git a/functions.bmx b/functions.bmx index b5c7eb4..d6ffbf0 100644 --- a/functions.bmx +++ b/functions.bmx @@ -79,13 +79,22 @@ Function SBIToSub(SBIPath:String, SUB:TBank) Next Print "Replaced 10 byte QSUB at MSF: " + SBI_Minutes:Int + ":" + SBI_Seconds:Int + ":" + SBI_Frames:Int + " (sector: " + SectorMSF:Int + ") at offset: " + Hex(ReplaceOffset:Int) + 'Old V0.2 notes, didn't work out as you can see. 'Now we have to recalculate the CRC16 if we want to make all the games fully work. 'Although stupidly, the modified CRC16 on LibCrypt games are not included in SBIs, and different LibCrypt games generate them differently 'Lets assume it needs recalculating, with a 0080 XOR, although some use 8001 but there's no way to easily check. Why did they make this a standard? - Local SUB_CRC16:Short = CRC16(QSub) + 'Local SUB_CRC16:Short = CRC16(QSub) + 'V0.2 code bits '0080 XOR is whatmost LibCrypt games use according to ReDump - Local SUB_CRCA:Byte = (SUB_CRC16 + $0080) Shr 8 - Local SUB_CRCB:Byte = (SUB_CRC16 + $0080) - (SUB_CRCA Shl 8) + 'Local SUB_CRCA:Byte = (SUB_CRC16 + $0080) Shr 8 + 'Local SUB_CRCB:Byte = (SUB_CRC16 + $0080) - (SUB_CRCA Shl 8) + 'Print "Added 2 byte LibCrypt CRC16 to QSUB with a value of: " + Right(Hex(SUB_CRC16:Short + $0080), 4) + + 'So according to the mednafen source, you just do a regular CRC16, then do a "bitwise exclusive or" to purposely make the CRC16 wrong... + 'But then despite having the wrong CRC16 compared to the original LibCrypt CRC16 hash, the game will work. Ok? + Local SUB_CRC16:Short = ~CRC16(QSub) + Local SUB_CRCA:Byte = (SUB_CRC16) Shr 8 + Local SUB_CRCB:Byte = (SUB_CRC16) - (SUB_CRCA Shl 8) 'Have to do it this way as PokeShort will reverse to little endian or something PokeByte(SUB, ReplaceOffset:Int + 10, SUB_CRCA) PokeByte(SUB, ReplaceOffset:Int + 11, SUB_CRCB) diff --git a/sbitools.bmx b/sbitools.bmx index a42865b..1892b2e 100644 --- a/sbitools.bmx +++ b/sbitools.bmx @@ -6,7 +6,7 @@ Include "CRC16.bmx" Include "functions.bmx" 'Main Program -Print "SBITools v0.2 - http://kippykip.com" +Print "SBITools v0.2.1 - http://kippykip.com" Global Prog:Int = 0 'Check for psxt001z.exe @@ -322,7 +322,8 @@ Select Prog Print "-lsd: Patches an images subchannel with a .LSD file." Print "-cue2ccd: Converts a 'BIN/CUE/SBI|LSD' setup into a 'IMG/CCD/CUE/SUB' setup." Print " This makes burning LibCrypt games easily possible with software such" - Print " as CloneCD" + Print " as CloneCD. SBI/LSD files are loaded from the same directory as the .CUE" + Print " file under the same name." Print "" Print "Examples:" Print "SBITools.exe -sbi " + Chr(34) + "C:\CoolGameRips\VRally2.CUE" + Chr(34) + " " + Chr(34) + "C:\CoolGameRips\sbipatches\V-Rally - Championship Edition 2 (Europe) (En,Fr,De).sbi" + Chr(34)