Ticket #13248: extract-loom-pce.2.sh

File extract-loom-pce.2.sh, 2.0 KB (added by eriktorbjorn, 2 years ago)
Line 
1#! /bin/sh -e
2
3# This is a proof-of-concept script. I'm at best a bumbling amateur
4# when it comes to shell scripting. # Use this script from an empty
5# directory. Required packages (Debian):
6#
7# - cdrdao
8# - bchunk
9# - flac
10
11destination=./loom-pce
12
13# Rip the CD to hard disk. The cdrdao command has a bewildering number
14# of options, but apparently none for extracting single tracks. Oh
15# well, most of the tracks are interesting in some way.
16#
17# After some experimenting I came up with pretty much the same
18# parameters as in the DOSBox documentation, at which point I decided
19# to just follow their lead. The most interesting bit is probably the
20# 0x20000 option, which ensures the correct byte order for the
21# extracted audio. This allows the resulting BIN/CUE files to be run
22# in the Mednafen emulator, which is useful for testing.
23#
24# It's also possible to do this byte swapping in the bchunk step, by
25# adding the -s option there.
26#
27# This step is time-consuming, so only do it if there isn't already an
28# extracted loom.bin file there. It may be possible to generate a CUE
29# file instead of a TOC file here, but I didn't manage to.
30
31if [ ! -e loom.bin ] ; then
32 cdrdao read-cd --datafile loom.bin --driver generic-mmc:0x20000 --device /dev/cdrom --read-raw loom.toc
33fi
34
35# If there isn't a CUE file, convert the TOC file into something other
36# programs can work with.
37
38if [ ! -e loom.cue ] ; then
39 toc2cue loom.toc loom.cue
40fi
41
42# Split the BIN/CUE files into individual tracks.
43
44bchunk -w loom.bin loom.cue track
45
46# Create an new directory for the final game
47
48mkdir -p $destination
49
50# Compress the audio tracks. Note that there is a gap in the numbering
51# because of the data track.
52
53flac -8 *.wav
54
55mv track01.flac $destination
56
57previous=02
58
59for tracknr in `seq -w 3 22` ; do
60 mv track$tracknr.flac $destination/track$previous.flac
61 previous=$tracknr
62done
63
64# Finally, use scummvm-tools-cli to extract the oh-so-juicy data files.
65
66scummvm-tools-cli --tool extract_loom_tg16 -o $destination track02.iso
67
68# Cleanup
69
70rm -f loom.toc track02.iso track23.iso track??.wav