* updated plan9port (70cc6e5 -> d0d4408)
[t2.git] / target / dreamcast / DreamBurn.sh
blob31ad85e463fb4a4b9e65ffaf6c3447b75b5b0f7d
1 #!/bin/bash
2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 #
5 # T2 SDE: target/dreamcast/DreamBurn.sh
6 # Copyright (C) 2004 - 2005 The T2 SDE Project
7 #
8 # More information can be found in the files COPYING and README.
9 #
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- T2-COPYRIGHT-NOTE-END ---
16 show_usage() {
17 cat <<EOT
19 Usage:
20 $0 <content> <IP.BIN> [ -cdrw ] [-dev <device>] [-genopt <string>] [-burnopt <string>] [-xa <string>]
22 Burn boot-able discs for the SEGA Dreamcast console using cdrecord.
23 mandatory parameters:
25 <content> file or directory containing scrambled executable
27 <IP.BIN> valid IP header conforming to <content>
29 options:
31 -cdrw burn CD-RW (blank PMA, TOC, Pregap first). Note that
32 the Dreamcast cannot read CD-RWs !
34 -dev cdrecord device string. Default is "0,0,0"
36 -genopt additional cdrecord options. Default is ""
38 -burnopt additional cdrecord options for burning (e.g. speed=8 ).
39 Default is ""
41 -xa cdrecord option for CD/XA with form 1 sectors with 2048
42 bytes per sector. Depending on cdrecord version this is
43 -xa or -xa1 (consult the manpage !). Default is "-xa"
44 EOT
45 exit 1
49 ##### default values
51 cdrw=""
52 dev="0,0,0"
53 genopt=""
54 burnopt=""
55 xa="-xa"
57 ####################
60 content=$1
61 ip=$2
62 shift ; shift
64 while [ "$1" ] ; do
65 case "$1" in
66 -cdrw) cdrw=" blank=minimal" ; shift ;;
67 -dev) dev="$2" ; shift ; shift ;;
68 -genopt) genopt=" $2" ; shift ; shift ;;
69 -burnopt) burnopt=" $2" ; shift ; shift ;;
70 -xa) xa="$2" ; shift ; shift ;;
72 *) echo "Unknown option: $1" ; show_usage ;;
73 esac
74 done
76 [ -e "$content" -a -f "$ip" ] || show_usage;
78 cdr="cdrecord dev=$dev$genopt"
79 burnaudio="$cdr$burnopt$cdrw -multi -audio"
80 info="$cdr -msinfo"
81 burndata="$cdr$burnopt -multi $xa"
83 cat <<EOT
85 cdrecord calls to be executed:
87 # $burnaudio (FILE)
88 # $info
89 # $burndata (FILE)
91 EOT
92 echo -n "Proceed ? [Y/n] "
93 read confirm;
95 [ -z "$confirm" -o "$confirm" == "y" -o "$confirm" == "Y" ] || exit 0;
97 audiofile=`mktemp -t audio.raw.XXXXXX`
98 datafile=`mktemp -t data.raw.XXXXXX`
99 isofile=`mktemp -t data.iso.XXXXXX`
101 echo "Creating bogus audio track."
102 dd if=/dev/zero bs=2352 count=300 of=$audiofile 2>/dev/null
103 echo
104 echo
106 echo "Burning...."
107 cmd="$burnaudio $audiofile"
108 echo "$cmd"
109 eval "$cmd"
110 echo
111 echo
113 echo "Geting multisession status:"
114 echo "$info"
115 status=`eval "$info"`
116 echo "--> $status"
117 echo
118 echo
120 echo "Creating image."
121 mkisofs -l -C $status -o $isofile $content
122 echo "Inserting $ip."
123 ( cat $ip ; dd if=$isofile bs=2048 skip=16 ) > $datafile
124 echo
125 echo
127 echo "Burning..."
128 cmd="$burndata $datafile"
129 echo "$cmd"
130 eval "$cmd"
131 echo
132 echo
134 echo "Cleaning up."
135 rm -f $audiofile $isofile $datafile
136 echo "Done."