shithub: sce

ref: 907f053cc5b9626b62c6087ec5a2a07f1765c546
dir: /utils/sceass/

View raw version
#!/bin/rc
if(! ~ $#* 7){
	echo usage: sceass grp name frm rot id dx dy
	exit usage
}
grp=$1
name=$2
frm=$3
rot=`{echo $4 | awk '{printf "%02d", $1 % 17}'}
id=$5
dx=$6
dy=$7
echo '
	!r '^$grp^' s
	m = z == 3 ? Z : s[x,y,0] == Z && s[x,y,1] == 0 && s[x,y,2] == Z || s[x,y,0] == 222 && s[x,y,1] == 0 && s[x,y,2] == 222 || s[x,y,0] == 189 && s[x,y,1] == 0 && s[x,y,2] == 189 || s[x,y,0] == 156 && s[x,y,1] == 0 && s[x,y,2] == 156 || s[x,y,0] == 124 && s[x,y,1] == 0 && s[x,y,2] == 124 || s[x,y,0] == 91 && s[x,y,1] == 0 && s[x,y,2] == 91 || s[x,y,0] == 58 && s[x,y,1] == 0 && s[x,y,2] == 58 || s[x,y,0] == 25 && s[x,y,1] == 0 && s[x,y,2] == 25 ? s[x,y,0] : 0
	white = m > 0 ? m : s
	red = m > 0 ? z == 0 ? s[x,y,0] : z == 1 ? s[x,y,1] : z == 2 ? s[x,y,1] : Z : s
	blue = m > 0 ? z == 0 ? s[x,y,1] : z == 1 ? s[x,y,1] : z == 2 ? m : Z : s
	teal = m > 0 ? z == 0 ? s[x,y,1] : z == 1 ? s[x,y,0] : z == 2 ? s[x,y,0] : Z : s
	yellow = m > 0 ? z == 0 ? s[x,y,0] : z == 1 ? s[x,y,0] : z == 2 ? s[x,y,1] : Z : s
	purple = m > 0 ? z == 0 ? s[x,y,0]/2 : z == 1 ? s[x,y,1] : z == 2 ? s[x,y,0] : Z : s
	brown = m > 0 ? z == 0 ? s[x,y,0]/2 : z == 1 ? s[x,y,0]/2 : z == 2 ? s[x,y,1] : Z : s
	orange = m > 0 ? z == 0 ? s[x,y,0] : z == 1 ? s[x,y,0]/2 : z == 2 ? s[x,y,1] : Z : s
	!w red '^$name^'1'^$id^'.'^$frm^.^$rot^'.bit
	!w blue '^$name^'2'^$id^'.'^$frm^.^$rot^'.bit
	!w teal '^$name^'3'^$id^'.'^$frm^.^$rot^'.bit
	!w purple '^$name^'4'^$id^'.'^$frm^.^$rot^'.bit
	!w orange '^$name^'5'^$id^'.'^$frm^.^$rot^'.bit
	!w brown '^$name^'6'^$id^'.'^$frm^.^$rot^'.bit
	!w white '^$name^'7'^$id^'.'^$frm^.^$rot^'.bit
	!w yellow '^$name^'8'^$id^'.'^$frm^.^$rot^'.bit
' | pico
t=`{read -c 36 $grp | awk '{print $2+'^$dx^', $3+'^$dy^'}'}
for(i in $name^?^$id^.^$frm^.^$rot.bit)
	iconv -c r8g8b8 $i | crop -t $t > a && mv a $i