DiscImage class
#include <Utilities/AssetPacker/DiscImage.h>
Rewrites the game content of a bootable console disc image.
The consoles that boot from a read-only disc — the Sega Dreamcast, the PlayStation 2 and the GameCube — have their content authored into the image at build time, because there is nowhere else on any of them to put it. The price is that changing what is on a disc used to mean building the whole image again, with the console toolchain and an image authoring tool at hand. This does the other half of the job: it takes a finished image apart, keeps the bootstrap and the executable exactly as they are, and writes it back out around a different Content directory.
A disc cannot be patched in place: the files are laid out one after another at fixed addresses, so anything that changes a single size moves everything after it. The file system is therefore generated again from scratch, which is what Jazz2::
The GameCube image is the one kind this also creates (CreateGameCubeImage()): no image authoring tool knows its header, which is what the console's boot ROM reads before anything else. It is an ordinary ISO 9660 volume whose system area — the first 32 KB, which the file system leaves alone — holds the disc header, the bi2.bin block and the apploader, exactly where a GameCube disc has them, and the executable is one of the files of the volume, Content the directory next to it. Everything on a computer reads it as the ISO it is, the console and Dolphin as the disc it also is, and the game reads its content through the ISO 9660 hierarchy (see OgcDvd.cpp).
Public types
- struct GameCubeImageDescription
- What a new GameCube disc image is made of, see CreateGameCubeImage().
Public static functions
- static auto IsDiscJugglerImage(StringView path) -> bool
- Returns
trueif the file is a DiscJuggler image (.cdi), the form a Dreamcast disc is kept in. - static auto IsGameCubeImage(StringView path) -> bool
- Returns
trueif the file is a GameCube disc image, which is a plain.isothat starts with the disc header. - static auto CarriesLz4Images(StringView path) -> bool
- Returns
trueif the tilesets already on the disc are in LZ4. - static auto CarriesLz4Videos(StringView path) -> bool
- Returns
trueif the cinematics already on the disc have their frames in LZ4. - static auto SwapContent(StringView sourcePath, StringView targetPath, StringView contentPath) -> bool
- Writes a copy of a disc image with its
Contentdirectory replaced. - static auto CreateGameCubeImage(const GameCubeImageDescription& description, StringView targetPath) -> bool
- Writes a new bootable GameCube disc image.
Function documentation
static bool Jazz2:: AssetPacker:: DiscImage:: CarriesLz4Images(StringView path)
Returns true if the tilesets already on the disc are in LZ4.
Only a build of the game that decodes LZ4 sprite sheets and tilesets is ever given them, so this tells whether new content may use them too. false also when the disc has no tilesets to tell by.
static bool Jazz2:: AssetPacker:: DiscImage:: CarriesLz4Videos(StringView path)
Returns true if the cinematics already on the disc have their frames in LZ4.
The same question for Jazz2::false also when the disc has no cinematics to tell by.
static bool Jazz2:: AssetPacker:: DiscImage:: SwapContent(StringView sourcePath,
StringView targetPath,
StringView contentPath)
Writes a copy of a disc image with its Content directory replaced.
| Parameters | |
|---|---|
| sourcePath | Image to read — a DiscJuggler .cdi or a plain .iso |
| targetPath | Image to write, which may be the same file |
| contentPath | Directory that becomes Content on the disc, whatever it is called here |