forked from xyzz/taiga-aisaka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·240 lines (214 loc) · 5.99 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#! /bin/sh -
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PYTHON="python"
GPDA="java -cp $DIR/tools Gpda"
GIMCONV="wine $DIR/nonfree/gimconv/GimConv.exe"
fetchStrings=true
buildStrings=true
fetchImages=false
buildImages=false
compile=false
debug=false
fetchMenu=false
buildMenu=false
buildVoice=false
fast=false
if [ ! -f "$DIR/tools/modseekmap" -o ! -f "$DIR/tools/Gpda.class" ]; then
compile=true
fi
while test $# -gt 0
do
case "$1" in
--compile) compile=true
;;
--no-fetch-strings) fetchStrings=false
;;
--no-build-strings) buildStrings=false
;;
--debug) debug=true
;;
--fetch-menu) fetchMenu=true
;;
--no-fetch-menu) fetchMenu=false
;;
--build-menu) buildMenu=true
;;
--no-build-menu) buildMenu=false
;;
--build-images) buildImages=true
;;
--no-build-images) buildImages=false
;;
--build-voice) buildVoice=true
;;
--no-build-voice) buildVoice=false
;;
--fast) fast=true
;;
--*) echo "unknown option $1"
;;
esac
shift
done
if $compile; then
echo ">> Compiling tools"
cd $DIR/tools
g++ modseekmap.cpp -o modseekmap || exit
javac Gpda.java || exit
fi
echo ">> Cleaning up"
rm "$DIR/out/EBOOT.BIN"
rm "$DIR/out/first.dat"
rm "$DIR/out/first.dat.txt"
rm "$DIR/out/resource.dat"
rm "$DIR/out/resource.dat.txt"
rm "$DIR/out/voice.afs"
if ! $fast; then
echo ">> Clean working dir"
rm -rf $DIR/out/first*
rm -rf $DIR/out/resource*
cp -r $DIR/source/first* $DIR/out/
cp -r $DIR/source/resource* $DIR/out/
fi
if $buildVoice; then
echo ">> Building sounds"
rm -rf $DIR/data/voice
rm -rf $DIR/data/voice-mine
cp -r $DIR/source/voice $DIR/data
cp -r $DIR/source/voice-mine $DIR/data
echo ">> .wav -> .ahx"
cd $DIR/data/voice-mine
for x in *.wav; do
wine $DIR/nonfree/ahxencd/ahxencd.exe $x
done
cp *.ahx $DIR/data/voice
echo ">> building .afs"
cd $DIR/data
find voice/* | sort > $DIR/data/voice.map
$DIR/nonfree/afslnk/afslnk voice.map -odir=../out/ voice.afs
echo ">> patching EBOOT.BIN"
$PYTHON $DIR/tools/patch-eboot.py $DIR/source/EBOOT.BIN $(ls -1 $DIR/data/voice | wc -l) $DIR/out/EBOOT.BIN
fi
if $fetchStrings; then
echo ">> Fetching strings"
rm $DIR/data/strings/*
cd $DIR/data/strings
sh $DIR/modules/fetch-strings.sh
fi
if $buildStrings; then
echo ">> Building strings"
cd $DIR/data/strings
echo ">> po2txt"
for x in *.po; do
po2txt $x $x.out --fuzzy 2>/dev/null || exit
echo -n .
done
echo ""
fi
echo ">> repack .obj"
# copy old ones
cd $DIR/data/strings
find $DIR/source/resource/script.dat/ -name "*.obj.gz" -exec cp {} . \;
find $DIR/source/resource/script.dat/ -name "*.dat.gz" -exec cp {} . \;
gunzip -f *.gz
if $buildStrings; then
cd $DIR/data/strings
for x in *.obj; do
name=$(echo $x | sed s/.obj$//g)
$PYTHON $DIR/tools/repack.py $name $DIR/data/obj/$name || exit
echo -n .
done
echo ""
else
cd $DIR/data/strings
# just copy em
for x in *.obj; do
cp $x $DIR/data/obj/$x
echo -n .
done
for x in *.dat; do
cp $x $DIR/data/obj/$x
done
echo ""
fi
if $debug; then
echo ">> debug mode"
cp $DIR/misc/_0000ESS1_debug.obj $DIR/data/obj/_0000ESS1.obj
fi
echo ">> compress .obj"
cd $DIR/data/obj
gzip -n9 -f *.obj
echo ">> replace .obj.gz"
for x in *.obj.gz; do
name=$(echo $x | sed s/.obj.gz$//g)
cp $x $DIR/out/resource/script.dat/$name.dat/$name.dat_1/$name.obj.gz
echo -n .
done
echo ""
gzip -n9 -f *.dat
echo ">> replace .dat"
for x in *.dat.gz; do
name=$(echo $x | sed s/.dat.gz$//g)
cp $x $DIR/out/resource/script.dat/$name.dat/$name.dat_1/$name.dat.gz
echo -n .
done
echo ""
if $buildImages; then
echo ">> building images"
cp -r $DIR/images $DIR/data
# build sg_title
cd $DIR/data/images/sg_title
for x in *.png; do
# this is to convert "Color Type" to "Palette"
# which makes .gim output much smaller
pngquant $x -f --ext .png
$GIMCONV $x -o $x.gim --format_endian little
mv $x.gim $(echo $x|sed s/.png$//).gim
echo -n .
done
gzip -n9 -f *.gim
cp *.gim.gz $DIR/out/first/image_sharing.dat/
cd $DIR/modules/sprites
sh do.sh
gzip -n9f out.txt
pngquant out.png -f --ext .png
$GIMCONV out.png -o out.gim --format_endian little
gzip -n9f out.gim
cp out.gim.gz $DIR/out/resource/image_main.dat/sg_chaname.gim.gz
cp out.txt.gz $DIR/out/first/text.dat/charaname.txt.gz
fi
cp $DIR/Bhelp_00en.gim.gz $DIR/out/resource/image_block.dat/image_block_title.dat/bhelp_00.gim.gz
echo ">> Packing resource.dat"
cd $DIR/out
$GPDA resource.dat.txt >/dev/null
echo ">> Generating seekmap"
cd $DIR/tools
./modseekmap
cp $DIR/tools/seekmap.new $DIR/out/first
cd $DIR/out/first
gzip -n9 seekmap.new
mv seekmap.new.gz seekmap.dat
if $fetchMenu; then
echo ">> Fetching menu text"
curl http://t.minetest.ru/projects/toradora-portable/utf16/en/download/ > $DIR/data/menu.po
po2txt $DIR/data/menu.po $DIR/data/menu.tmp --fuzzy 2>/dev/null || exit
sed 'n;d;' $DIR/data/menu.tmp > $DIR/data/menu.txt
fi
if $buildMenu; then
echo ">> Building menu"
unix2dos $DIR/data/menu.txt
iconv -f utf8 -t utf16le $DIR/data/menu.txt > $DIR/data/menu.done
gzip -n9 -f $DIR/data/menu.done
cp $DIR/data/menu.done.gz $DIR/out/first/text.dat/utf16.txt.gz
fi
echo ">> Packing first.dat"
cd $DIR/out
$GPDA first.dat.txt >/dev/null
echo ">> Building .ISO"
cd $DIR/out
mv EBOOT.BIN iso/PSP_GAME/SYSDIR/EBOOT.BIN
mv first.dat iso/PSP_GAME/USRDIR/first.dat
mv resource.dat iso/PSP_GAME/USRDIR/resource.dat
mv voice.afs iso/PSP_GAME/USRDIR/voice.afs
mkisofs -sort filelist.txt -iso-level 4 -xa -A "PSP GAME" -V "Toradora" -sysid "PSP GAME" -volset "Toradora" -p "" -publisher "" -o out.iso iso/
echo "== Done!"