Skip to content

Commit

Permalink
V0.2 update
Browse files Browse the repository at this point in the history
Adds a tonne of new code, such CD Audio support and CCD conversion.
  • Loading branch information
Kippykip committed Oct 9, 2018
1 parent 47aef96 commit a4e9532
Show file tree
Hide file tree
Showing 4 changed files with 873 additions and 174 deletions.
61 changes: 61 additions & 0 deletions CRC16.bmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
'Ported code from Mednafen

Global CRC16_tab:Int[] =
[$0000, $1021, $2042, $3063, $4084, $50a5, $60c6, $70e7,
$8108, $9129, $a14a, $b16b, $c18c, $d1ad, $e1ce, $f1ef,
$1231, $0210, $3273, $2252, $52b5, $4294, $72f7, $62d6,
$9339, $8318, $b37b, $a35a, $d3bd, $c39c, $f3ff, $e3de,
$2462, $3443, $0420, $1401, $64e6, $74c7, $44a4, $5485,
$a56a, $b54b, $8528, $9509, $e5ee, $f5cf, $c5ac, $d58d,
$3653, $2672, $1611, $0630, $76d7, $66f6, $5695, $46b4,
$b75b, $a77a, $9719, $8738, $f7df, $e7fe, $d79d, $c7bc,
$48c4, $58e5, $6886, $78a7, $0840, $1861, $2802, $3823,
$c9cc, $d9ed, $e98e, $f9af, $8948, $9969, $a90a, $b92b,
$5af5, $4ad4, $7ab7, $6a96, $1a71, $0a50, $3a33, $2a12,
$dbfd, $cbdc, $fbbf, $eb9e, $9b79, $8b58, $bb3b, $ab1a,
$6ca6, $7c87, $4ce4, $5cc5, $2c22, $3c03, $0c60, $1c41,
$edae, $fd8f, $cdec, $ddcd, $ad2a, $bd0b, $8d68, $9d49,
$7e97, $6eb6, $5ed5, $4ef4, $3e13, $2e32, $1e51, $0e70,
$ff9f, $efbe, $dfdd, $cffc, $bf1b, $af3a, $9f59, $8f78,
$9188, $81a9, $b1ca, $a1eb, $d10c, $c12d, $f14e, $e16f,
$1080, $00a1, $30c2, $20e3, $5004, $4025, $7046, $6067,
$83b9, $9398, $a3fb, $b3da, $c33d, $d31c, $e37f, $f35e,
$02b1, $1290, $22f3, $32d2, $4235, $5214, $6277, $7256,
$b5ea, $a5cb, $95a8, $8589, $f56e, $e54f, $d52c, $c50d,
$34e2, $24c3, $14a0, $0481, $7466, $6447, $5424, $4405,
$a7db, $b7fa, $8799, $97b8, $e75f, $f77e, $c71d, $d73c,
$26d3, $36f2, $0691, $16b0, $6657, $7676, $4615, $5634,
$d94c, $c96d, $f90e, $e92f, $99c8, $89e9, $b98a, $a9ab,
$5844, $4865, $7806, $6827, $18c0, $08e1, $3882, $28a3,
$cb7d, $db5c, $eb3f, $fb1e, $8bf9, $9bd8, $abbb, $bb9a,
$4a75, $5a54, $6a37, $7a16, $0af1, $1ad0, $2ab3, $3a92,
$fd2e, $ed0f, $dd6c, $cd4d, $bdaa, $ad8b, $9de8, $8dc9,
$7c26, $6c07, $5c64, $4c45, $3ca2, $2c83, $1ce0, $0cc1,
$ef1f, $ff3e, $cf5d, $df7c, $af9b, $bfba, $8fd9, $9ff8,
$6e17, $7e36, $4e55, $5e74, $2e93, $3eb2, $0ed1, $1ef0]

Function CRC16:Short(Array:Byte[])
Local cksum:Short
For Local i = 0 To Len(Array) - 1
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
105 changes: 86 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,66 @@

# SBITools
SBITools v0.1 - http://kippykip.com
SBITools v0.2 - http://kippykip.com

**Description:**

This is a small set of conversion tools written in BlitzMax to convert .SBI/.LSD files back into .SUB files, which can be read into popular CD Burning software such as CloneCD.
This way, LibCrypt protected games dumped in other formats can still be burned as 1:1 copies on a real Sony PlayStation console again with the LibCrypt changes intact.
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.
This way, LibCrypt protected games dumped in other formats can still be burned as 1:1 copies on a real Sony PlayStation console again with the LibCrypt changes fully intact.
**These tools are only intended for intended for PlayStation images, there's no telling how these tools would react to standard Mode 1 PC disc images.**

**Requirements:**

psxt001z, to be in the same directory as SBITools
It can be downloaded from: http://redump.org/download/psxt001z-0.21b1.7z
Source Code: https://github.com/Dremora/psxt001z
psxt001z, to be in the same directory as SBITools
It can be downloaded from: http://redump.org/download/psxt001z-0.21b1.7z
Source Code: https://github.com/Dremora/psxt001z
It's pre-included in the "Releases" section for SBITools
https://github.com/Kippykip/SBITools/releases

**Arguments:**
> SBITools.exe -sbi image.(bin/img) subchannel.sbi subchannel.sub
> SBITools.exe -lsd image.(bin/img) subchannel.lsd subchannel.sub
> SBITools.exe -sbi cuefile subchannel.sbi
> SBITools.exe -lsd cuefile subchannel.lsd
> SBITools.exe -cue2ccd cuefile
**Argument Definitions:**

**Example:**
>SBITools.exe -sbi MediEvil.bin "MediEvil (Europe).sbi" MediEvil.sub
-sbi: Patches an images subchannel with a .SBI file.
-lsd: Patches an images subchannel with a .LSD file.
Both -sbi and -lsd export the patched .SUB file to:
\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

**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.

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)
They can be easily found on http://redump.org/disc/DISCID#/lsd

**Note:**
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!

**Upcoming**
- Add a -**cdd2cue** function to reverse the process, just in case.
- Add support for image files that have the tracks seperated (Such as "CoolGame (Track 1).bin, CoolGame (Track 2).bin, CoolGame (Track 3).bin") etc.
- Maybe even remove the need for psxt001z too as it's only used for
generating blank .SUB subchannel, although it is a very useful tool to have in combination with SBITools.
- Add a .LSD to .SBI converter, maybe the inverse too if I find a way to perfectly recreate it.
- Add full XOR support for SBI CRC16 recreation.

The .SUB path will be overridden if it exists! Be careful.
I'm planning on making a BIN/CUE/SBI -> IMG/CUE/CCD/SUB function for the future.
Maybe even remove the need for psxt001z too as it's only used for generating a blank .SUB subchannel initially.
**Version History**

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
file for -SBI and -LSD functions. SUB files are now exported to the \SUB directory
in these functions too.
- The -SBI function now recreates some of the CRC16 bytes required for handful of games,
although still not 100% compatible.
- Command line functions are no longer case sensitive. (oops)
- Added -cue2ccd, which allows you to do a full burnable conversion.
Version 0.1
- Initial release
# SBI File Format Specifications

*HEADER*
Expand All @@ -42,7 +76,7 @@ SBITools v0.1 - http://kippykip.com
Example:
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

*CONTINUOUS*
Expand All @@ -55,5 +89,38 @@ SBITools v0.1 - http://kippykip.com
Example:
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
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)*

Note: CRC16 is not needed to start LibCrypt games, but it is modified on LibCrypt'ed games.
**Ape Escape (PAL)**
Main menu navigation will be completely disabled, making you unable to start the game.
**Crash Team Racing (PAL)**
Game will hang once at the end of the loading screen (for the level itself).
**Crash Team Racing (PAL)**
Game will hang once at the end of the loading screen (for the level itself).
**Legacy of Kain: Soul Reaver (PAL)**
The game will hang when you're introduced with the combat tutorial when the camera pans to show the enemies.
**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.
**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.
**MediEvil 2** - Will also have the same disc error icon as above, except upon loading Kensington.
**PGA European Tour Golf (PAL)**
In the third hole of the first tournament or by selecting some holes, the game will get stuck in "demo" mode (and will not you play anything).
**Resident Evil 3: Nemesis (PAL)**
Will hang at the "Game contains violence and gore" screen.
**Spyro 3: Year of the Dragon**
Interesting case for this one, the game will eventually randomly delete eggs, reset progress with unlocked characters, remove sheep in boss battles, change the language and even tell you off for playing a "hacked copy" + more.
Interesting to note that the game also detected early LibCrypt knockout PPF patches back when the game was first released as it had checksum checks throughout the game, which caused the same effects above.
**This is Football (PAL)**
Hangs on the loading screen going ingame.
**V-Rally: Championship Edition 2 (PAL)**
The game will endlessly load on the heartbeat loading screen (with no disc activity).
**Wip3out (PAL)**
The game will freeze when passing the finish line.
# CloneCD LibCrypt Ripping guide
TODO
# CloneCD LibCrypt Burning guide
TODO
Loading

0 comments on commit a4e9532

Please sign in to comment.