Creating a bootable Dreamcast disc

From dreamcast.wiki
Revision as of 20:24, 15 February 2025 by Darc (talk | contribs) (→‎Full Overview of the steps involved)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Full Overview of the steps involved

The full list of steps to make self-bootable disc for the Dreamcast goes like this:

  • Build your source (usually using KallistiOS)
  • Transform your .elf executable into binary
  • Scramble the binary
  • Build a .iso image from a directory (representing the second session of a multisession disc and not bootable)
  • Transform the .iso into a .cdi image (representing a self-booting multisession disc image)
  • Transfer the .cdi image to your GDEMU (or other optical disc drive emulator device), or burn the .cdi image to a CD-R to launch it in a standard Dreamcast.

There are other details that could be taken into account:

  • You can make Audio/Data and Data/Data .cdi files. Both can selfboot, but the files will be organized differently on the physical CD. Citation needed
  • You'll need to provide a valid IP.BIN, these can be modified to display a logo during the boot screen, apply patches or execute some code.
  • It is possible to make CDDA compatible images, this process in not currently covered here.

Depending on the method/tools used, some of the above steps are simplified a lot:

  • mkdcdisc: does the heavy lifting for you. Linux only for now.
  • mkisofs + cdi4dc
  • mkisofs + cdrecord

mkdcdisc (Linux only for now)

mkdcdisc is a recent (2022) tool that pretty much does all the steps for you.

The minimum you need for it, is your executable .elf.

Example to build a bootable DC disc image nehe05.cdi, starting from an executable called nehe05.elf:

mkdcdisc -e nehe05.elf -o nehe05.cdi

Example to build a bootable DC disc image mygame.cdi, starting from an executable called mygame.elf, with assets/textures/... files stored in a subfolder called "data":

mkdcdisc -e mygame.elf -D data -o mygame.cdi

There are a lot of commandline options, so be sure to check them all out!

mkisofs + cdi4dc

This is an example for automating the .cdi image process under Linux. Consider this more like a template as you'll need to edit the paths, names, etc to your own project.

 #! /bin/sh
 PROJECT_DIR=$PWD/build
 PROJECT_NAME="Project_Name"
 TARGET="main.elf"
 # Build your program
 # This assumes that you can properly build your source code. The program main output will be $TARGET
 make $TARGET
 # Elf transform
 sh-elf-objcopy -R .stack -O binary $TARGET output.bin
 # Scrambling process
 $KOS_BASE/utils/scramble/scramble output.bin 1ST_READ.bin
 # Creating a .iso image from a directory 
 # Make sure you have a working IP.BIN in your current directory. Or change IP.BIN path to wherever you like.
 # Useful option for mkisofs is *-m* which allow to exclude files from the iso image (useful to remove .git, or some other folder) 
 mkisofs -C 0,11702 -V $PROJECT_NAME -G IP.BIN -r -J -l -o $PROJECT_NAME.iso $DIR
 # Transform your .iso into a .cdi
 $KOS_BASE/utils/cdi4dc/cdi4dc $PROJECT_NAME.iso $PROJECT_NAME.cdi

mkisofs + cdrecord

TODO