3 PROGNAME
="$(basename $0)"
5 [ "$PWD" ] || PWD
=$
(pwd)
11 KLICENSE
="e4e54fd67c16c316f47829a30484d843"
12 PS2CLASSIC
=$PWD/ps2classic
/ps2classic
13 PSNPACKAGE
=$PWD/psn_package_npdrm
/psn_package_npdrm
14 # FAT SLIM SUPER ULTRA
18 function title
() { echo -e "\033[0;1m=== $* ===\033[0;0m"; }
19 function pass
() { echo -e "\033[1;32m$*\033[0;0m"; }
20 function warn
() { echo -e "\033[1;33m$*\033[0;0m"; }
21 function fail
() { echo -e "\033[1;31m$*\033[0;0m"; exit 1; }
27 [ -f .
$PROGNAME ] && source .
$PROGNAME
33 serial
=$
(isoinfo
-f -i "$file" | \
34 grep "^/[A-Z][A-Z][A-Z][A-Z]_[0-9][0-9][0-9]\.[0-9][0-9];" | \
35 sed 's,[/.],,g;s,_,-,;s,;.*,,')
36 [ "$serial" ] ||
{ serial
=$
(printf "PS2U-1%04d" $id); let id
++; }
40 echo "id=$id" >> .
$PROGNAME
44 [ -f jlist2.html
] || wget https
://psxdatacenter.com
/psx
2/jlist2.html
45 [ -f plist2.html
] || wget https
://psxdatacenter.com
/psx
2/plist2.html
46 [ -f ulist2.html
] || wget https
://psxdatacenter.com
/psx
2/ulist2.html
48 getline; gsub(/<[^<]*>/, "")
57 [ -f "$CACHE/PS2-GAMEID-TITLE-MASTER.csv" ] ||
( cd "$CACHE"; wget https
://raw.githubusercontent.com
/VTSTech
/PS2-OPL-CFG
/master
/test
/PS2-GAMEID-TITLE-MASTER.csv
)
58 title
=$
(awk -F\
; '"'$serial'" == $1 {print $2}' "$CACHE/PS2-GAMEID-TITLE-MASTER.csv")
59 [ "$title" ] || title
=$
(basename "$file" |
sed 's/ *(.*//')
63 cid
=2P0001-
${serial/-}_00-$
(echo ${title}0000111122223333 | \
64 tr '[a-z]' '[A-Z]' | \
65 sed 's/[^A-Z0-9]//g;s/\(................\).*$/\1/')
70 echo "Serial: $serial"
71 echo "Title: '$title'"
75 title
"install skeleton"
77 tar -C $serial -xzf $PWD/skeleton.tgz
78 [ -d "$CACHE" ] || mkdir
"$CACHE"
83 # - PIC1.PNG 1920x1080
86 title
"get cover image"
87 if [ -f "$CACHE/$serial-ICON0.PNG" ]; then
88 cp "$CACHE/$serial-ICON0.PNG" $serial/ICON0.PNG
90 wget https
://psxdatacenter.com
/psx
2/images
2/covers
/$serial.jpg
91 if [ -f $serial.jpg
]; then
92 convert
$serial.jpg tmp.png
93 mogrify
-resize 320x176 tmp.png
94 mogrify
-background transparent
-gravity center
-extent 320x176 tmp.png
95 mv tmp.png
$serial/ICON0.PNG
97 cp $serial/ICON0.PNG
"$CACHE/$serial-ICON0.PNG"
99 warn
"can't find cover"
104 title
"get screenshot"
105 if [ -f "$CACHE/$serial-PIC0.PNG" ]; then
106 cp "$CACHE/$serial-PIC0.PNG" $serial/PIC0.PNG
109 find $HOME/.config
/PCSX
2/snaps
/ -type f |
xargs rm .
touch
111 capture
=$
(find $HOME/.config
/PCSX
2/snaps
/ -type f |
sort)
112 if [ "$capture" ]; then
113 cp "$capture" tmp.png
114 mogrify
-scale 1000x560 tmp.png
115 mogrify
-background transparent
-gravity center
-extent 1000x560 tmp.png
116 mv tmp.png
$serial/PIC0.PNG
117 cp $serial/PIC0.PNG
"$CACHE/$serial-PIC0.PNG"
119 warn
"can't find screenshot"
124 title
"create PARAM.SFO"
129 # - file: USRDIR/ISO.BIN.EDAT
131 echo -n $title | xxd | xxd
-r -s 0x120 - $serial/PARAM.SFO
132 echo -n ${serial/-} | xxd | xxd
-r -s 0x1a0 - $serial/PARAM.SFO
133 echo -n ${serial/-} | xxd | xxd
-r -s 0x17- $serial/USRDIR
/ISO.BIN.EDAT
137 dd bs
=1 count
=$
(expr ${#KLICENSE} / 2) if=/dev
/zero of
=$serial/ps2.key
138 echo "00000000 $KLICENSE" | xxd
-r - $serial/ps2.key
141 title
"find config file"
142 confname
=$
(echo $serial.CONFIG |
sed 's/-/_/;s/_\(...\)/_\1./')
143 if [ -f "$CACHE/$confname" ]; then
144 cp "$CACHE/$confname" $serial/$confname
148 config
=$
(cd $CONFIGS; find GX
-name $confname |
head -1)
151 config
=$
(cd $CONFIGS; find CUSTOM SOFT NET
-name $confname |
head -1)
152 #config=$(cd $CONFIGS; find SOFT NET -name $confname | head -1)
155 if [ "$config" ]; then
156 cp $CONFIGS/$config "$CACHE/$confname"
157 cp "$CACHE/$confname" $serial/$confname
160 [ -f $serial/$confname ] || warn
"can't find config"
162 # create package config
163 title
"create package config"
164 cat > $serial/package.conf
<< EOF
166 k_licensee = 0x$KLICENSE
168 Content_Type = PS2_Classics_Game
169 PackageVersion = 01.01
174 $PS2CLASSIC prepare
"$file" || fail
"can't prepare iso"
178 $PS2CLASSIC e cex
$serial/ps2.key
"$file" $serial/USRDIR
/ISO.BIN.ENC ISO.BIN.ENC
$cid || fail
"can't convert iso"
181 title
"create package"
182 ( cd $serial; $PSNPACKAGE package.conf .
) || fail
"can't create package"
183 mv $serial/$cid.pkg .
186 title
"create rap file"
187 cp $PWD/iso2ps2.rap
$cid.rap