﻿Sega Saturn Patcher V1.91 (Beta for 2.0)

(C) 2021 Knight0fDragon - Knight0fDragon@gmail.com

If you would like to say thanks and offer a donation,  I accept only PayPal
at knight0fdragon@gmail.com

Thanks to everybody over at SegaXtreme and Sega Saturn Shiro, along 
with various people communicating with me on the side, 
working out all of the kinks with this program.

Special thanks to dibz' and the rest of SegaXtreme.met for providing a home for resources and access to the API.
Special thanks to SEGA RPG FAN for his research and development into the XBand driver patches.
Special thanks to TrekkiesUnite118 for his extensive testing with the patcher.
Special thanks to privateeye for his extensive testing with the patcher.

Thank you for using this patcher, and happy gaming.
	
You can find me hanging out in the following Discord channels:

https://discord.gg/snRw4KzHBy Sega Xtreme
https://discord.gg/cYwykZxXxw Sega Saturn Shiro
https://discord.gg/yWnUVCr My Shining Force 3 Discord




-------------------------------------------------------
Licence
-------------------------------------------------------

This program is provided free of charge for non commercial use
and is to be used at your own risk.
Knight0fDragon nor patch creators will be held responsible for any loss
of data or damage incurred during processing.

-------------------------------------------------------
Requirements
-------------------------------------------------------

Sega Saturn Patcher requires .NET 5.0 Desktop Runtimes.
If it is not included, the app will prompt you to install it.
It could also be dowbnloaded at https://dotnet.microsoft.com/download/dotnet/5.0

-------------------------------------------------------
Troubleshooting
-------------------------------------------------------
1)Continuous prompting of  .NET Runtime install.
Run the following command in command prompt: dotnet --list-runtimes
If only Microsoft.WindowsDesktop.App 5.#.# does not exist, install the desktop runtime above.
If Microsoft.NETCore.App 5.#.# does not exist, install the full runtime above.

-------------------------------------------------------
What is new?
-------------------------------------------------------

Patcher has been rebuild from the ground up.  

CDs and Images have wrappers written to now treat them as the same thing, so compatabilitiy issues should no longer be a problem.

New features to be available in 2.0.

Command line support.

Patchers will now work with command line arguments for batch processing (commands below.)
The GUI version does not output text to console, so a seperate CLR app will be made available if output is needed.

Meta data can now be included in the patch.  This can be used by developers to provide technical information about their patch.
Hopefully this will be used to provide patch updates.

Read me.  Developers can now include important notes and information they want users to read.

SSCD Image (previously SSG)fomat now exists.  It is a cd image format that uses compression, as well as allows for meta data to be added.

UI also exists to create SSCD.

More intuitive UI.  The UI provides more information a person may want,  as well as makes it easier to create or use patches.

Settings.  You can now customize the experience of the program.

Cheat Detection removal patch.  Will remove Action replay blocking methods in games. (Known in Panzer Dragoon Saga)

XBand Patch.  Add custom XBand/Netlink patches to applicable games.  Needs to be added via Settings.

Pseudo Kai Fast Boot patch.  If you are a Pseudo Kai user, you can apply this patch to skip the second Sega authorization check.

Application is now resizeable.

Command line can be used to create CD image formats.  

This feature will allow for homebrew developers to generate more accurate CD images.

-------------------------------------------------------
XBand Driver Setup
-------------------------------------------------------
Sega Saturn Patcher does not include custom drivers currently due to copyright issues.

Just place the files that need patching into a zip file,  and assign the file to SSP in the settings.

There are 2 different drivers that need to be added depending on the online play available.

Netlink(USA games)   Drivers use the USXBandPatchZipFile setting.
SegaNet(Japan games) Drivers use the JPXBandPatchZipFile setting.


Files to patch SegaNet games (Japan) to allow for Netplay can be found the SEGA DTS CD (Nov 1996).
The minimum files required are LOADER.BIN, XBAND.BIN, and XBLIBUS.BIN.  
These files do not need to be renamed or placed into any folders.

Other drivers exist created by SEGA RPG FAN that tweek the initialize strings for better performance on VoIP devices.


-------------------------------------------------------
Adding update information and urls
-------------------------------------------------------
SSP uses REST to grab data from a server.
All you simply need to do is provide a URL to grab the JSON object (JSONURL)
and provide and API key if applicalble (APIKey).

The JSON itself follows a simple structure:

{
  "resource":{
    "version":<string>
  }
  "errors": [
      {
          "code": <string>,
          "message": <string>,
      }
  ]
}

Other tags can be added, it will be simply ignored.

-------------------------------------------------------
Linking with SegaXtreme
-------------------------------------------------------
SSP is built to work with the SegaXtreme resource page.

To include your patch at SegaXtreme, go and set up an account if applicable.

Head over to the resources page, and click on Add Resource.

Fill out the form, but do not add your file yet.

After sumbmitted,  look at the URL to get your app ID.

The format will look like this https://segaxtreme.net/resources/<Title>.<ID>/

Go into the Edit META of your SSCD or SSP, and look for the key JSONURL.

Add the following URL https://segaxtreme.net/api/resources/<ID>/  where <ID> is the ID number from your URL.

Do not worry about the APIKey, this will be provided for you.

Press the Test JSON URL button to ensure it worked.

Save your SSP.

Congratulations.  This SSP will now notify users if they are using an older version of your patch.

Note*  Resources may need to be approved by admins prior to the test working.

-------------------------------------------------------
Command line arguments
-------------------------------------------------------

=General options=
-help                                      Lists help.  Also /h, -h, --h, /help, --help , /?, -?, --?
-imagetype <type>                          Image type output format. Valid choices:bin,iso,ccd,sscd.
-o <name>                                  Outut name for CD Image.
-quiet                                     Do not display any console output.
-multitrack                                Export tracks as separate files (if applicable.)
-meta <string>                             Meta data for SSCD format
-readme <string>                           Readme text for SSCD format


Additional options depending on task.
Do not mix patching options with generation.


=CD Patching options=


-cheat-check-defeat                        Apply cheat check defeat patch
-drive <letter>                            Letter of CD Drive to patch.
-extract <path>                            Extracts selected drive or image to path.
-fast-boot                                 Apply fast boot patch
-patch <filename>                          SSP file to apply to game.
-image <filename>                          CD Image to patch.
-region-free                               Apply region free patch


=CD Image generation options=


-audiotracks <filename>,<filename2>,...    Add audio tracks to image.
-appid <string>                            Application ID
-abstract <filename>                       ABSTRACT file.
-biblio <filename>                         BIBLIOGRAPHY file.
-cdda                                      Generate CDDA files in CD Image.  Format is CDDA#, where # is Track #.
-copyright <filename>                      COPYRIGHT file.
-generic-boot <filename                    See -ipbin
-i <foldername>                            Folder of files to create CD Image.
-ipbin <filename>                          Binary file that fills first 16 Sectors of CD Image.
-preparer <string>                         Preparer ID.
-publisher <string>                        Publisher ID.
-shortname                                 Omit ;1 from filename
-sort <filename>                           Directory and file order sheet.
-sysid <string>                            System ID.
-volid <string>                            Volume ID.
-volset <string>                           Volume Set ID.





==============================================================================================================================
Please back up any important data before running this program.
-------------
New to V1.2
Temporary bug fix for Bulk Slash and Cotton 2



New to V1.1

Patches made with V1.1 will not be supported in V1.0.

V1.1 is however backwards compatable with V1.0 patches.

1) Multiple CD support is now added.

To use, first create a patch with files to CD 1.
Click Build Disc # Patch button and save.

Repeat process for every additional disc.

End with loading in disc 1, and creating a patch containing all community files.

Then drag in the specific CD patches and build your patch normally.

There is a version feature that works in a similar way if you need to build a patch for a specific version.

Do not worry about containing different copies of the same file through out all of the different patches.

The patcher has a priority order when determining which file to use.

The file with the utmost priority is a Version.SSP located inside of a CD.SSP.
Then the CD.SSP has the next highest priorty.
The Version.SSP has the second lowest priority.
Finally the base SSP has the least priority.

2) New Delta algorithm used.

The files are now based on BSS Diff

3) Ability to export IPBin when creating a patcher

4) Ability to open CCD images.

-------------


Future plans.

Creating a new disc image format called SSG.
SSG will be used to distribute homebrew applications and will be archived in the same manner as SSP.

Add meta support to allow for SSP to "phone home" and alert users of updates.  
This way if your patch is located on other sites, your fans will be notified of the latest patch.

Command line support to allow for homebrew devs to build ISOs from their dev environments.  
This will allow them to build in one of the many disc image formats supported.

-------------




Sega Saturn Patcher is a multi-use program designed to be used with 
Sega Saturn discs.

The features include:
1) Creating a friendly CD rip that should require little to no conversion.
2) Applying region free patching to CD rips.-
3) Applying game patches to CD rips.
4) Creating patches that can be applied to CD rips.



1)  Creating a friendly CD rip.

To create a CD rip, first click on the button at the very top of the app
with the label "".

A drop down will appear giving the option of picking a CD drive or
a compatable existing CD image.

Click the desired option to load the game in.

Select one of the desired outputs in the radio buttons at the bottom of
the app.

--CUE + BIN - Creates a single 2352 BIN where all tracks are appended
  to the binary.

--CUE + BIN + Tracks - Creates a 2352 BIN file where all tracks are in 
  separate binaries.

--CUE + ISO - Creates a single 2048 ISO file where all tracks are appended
  to the binary.

--CUE + ISO + Tracks - Creates a 2048 ISO file where all tracks are in 
  separate binaries.
  
--CCD + IMG + SUB  Creates a CloneCD compliant CD image.


Click on Build Image, select a save location, and enjoy the rip once completed.

2)  Region Patching. 

Follow all the steps in section 1, but before clicking Build Image,
click Make Region Free.  This will enable region free patching. 
Now click on Build Image, and enjoy the rip once completed.

3)  Game Patching

Follow all the steps in section 1, but before clicking Build Image,
click Apply Patch.  A dialog will open up asking to open an SSP file.
Select the patch file that corresponds with the game being patched. 
Now click on Build Image.

A prompt may sometimes appear asking for optional patching or additional files.

For an optional patch, just click on yes or no if the user want to apply said option.

For an additional patch, use the dialog box to locate the additional file to be added.

and enjoy the rip once completed.

4)  Creating patches that can be applied to CD rips. (CD Image currently not supported)

To create patches to be used with the patcher, click on Create New Patch.
A screen will appear split into 2 sections and buttons on top and bottom.

The top section is for files that need to be patched/added/removed etc.
The bottom section is for audio tracks.

--File patching.
  
  To add patched files, simply drag and drop them in.  
  If the game has folders, be sure to keep the directory structure intact
  when dragging them in.
  
  On the left is a delete button that will allow removal of patch files.
  
  On the right is a button with 4 options.
  
  --Required:  This patch file is required for the patch to be successful.  
    No action needed from the user.
	
  --Optional:  This is an optional patch file that will prompt the user 
    during the process.
	
  --Additional:  This is an additional file that will require files outside
    of the patcher.  The user will be asked to add the file during patching.
	File can be blank.
	
  --Remove:  This is a patch file that will tell the patcher to remove this
    file from the CD rip.
	File can be blank,
	
	
--Track patching.

  To add or change a track, simply drag an audio file into this area.
  Most formats are supported and will be converted during creation.
  
  On the left is a delete button that will allow removal of patch track files.
  
  On the right is the option to change the track number.
  
  Selecting an existing track number will replace the original track.
  Providing a new number will append a new track.
  
  Currently there is no way to remove existing audio tracks.
  
--Notes
  SSP files are simply ZIP files renamed.
  SSP Patch are version controlled.  If a new version of the patcher 
  contains patch breaking changes, a prompt will appear notifiying the
  user. Anybody can check the version in the version.txt file.
  
--Additional Controls.

  --Add Version Patch.  This button will allow the addition of additional SSPs 
  that pertain to a particular version.  These SSPs only need to contain 
  patch files that are different than the main patch. The patcher will
  automatically prioritize version files over main files.
  #IMPORTANT# 
  The SSP name must match the version on the disc exactly.  
  Use the IPBin information on the patcher to get this value.
  
  
  --Import IPBIN.  Imports a custom IPBin to be patched with the patcher.
  --Edit IPBin,  Allows edit of basic IPBin information.
  --Change Drive Order.  Prompt will appear with how the files will be   
    listed on the CD rip.  Click and hold to drag the files around and 
	change this layout.
	
When all is arranged, click on Create Patch and wait for a prompt to
appear that generates the file.

Congratulations, a patch was sucessfully created.




TODO:
Optimize speed of patcher.
Fix progress bar when patching.
FiX progress bar to create patch.
CD Image Create Patch enabled.
Creating a new disc image format called SSG.
Add meta support.  
Command line support.  
Linux/MacOS native support.

If you would like to say thanks and offer a donation,  I accept only PayPal
at knight0fdragon@gmail.com

Special thanks to everybody over at SegaXtreme and Sega Saturn Shiro, along 
with various people communicating with me on the side, 
working out all of the kinks with this program.

Thank you for using this patcher, and happy gaming.
	
	
You can find me hanging out in the following Discord channels:

https://discord.gg/snRw4KzHBy Sega Xtreme
https://discord.gg/cYwykZxXxw Sega Saturn Shiro
https://discord.gg/yWnUVCr My Shining Force 3 Discord




	

  
  
