shithub: sce

Download patch

ref: 5b85f622f66ccdd13b583e5654f4c5777124404f
parent: b10d223226d69e6a0989f1cc949c455322ff75c8
author: qwx <[email protected]>
date: Sun Apr 11 19:40:54 EDT 2021

utils: sprite offsets may be 0, and crop(1) doesn't like that

the real fix might be to modify crop(1) instead.  it checks if
anything was actually specified at startup and compares
translate offsets to ZP.  if true it assumes usage error.

technically, it makes sense to treat noops as a usage error,
but you lose writing the same image to stdout.  given a file
argument, it's fine, but breaks pipelines.  perhaps it should
just ignore noop's, at least if there is no file argument.

--- a/utils/sceass
+++ b/utils/sceass
@@ -36,7 +36,7 @@
 ' | pico
 t=`{read -c 36 $grp | awk '{dx=$2+'^$dx^'; dy=$3+'^$dy^'; print dx, dy, dy+8}'}
 for(i in $name^?.^$frm^.^$rot.bit)
-	iconv -c r8g8b8 $i | crop -t $t(1-2) > a && mv a $i
+	iconv -c r8g8b8 $i | {crop -t $t(1-2) >[2]/dev/null || cat} > a && mv a $i
 if(~ $#noshad 0){
 	f=$name^s.^$frm^.^$rot.bit
 	echo '
@@ -49,6 +49,6 @@
 		o = z == 3 ? o[x,y,0] + o[x,y,1] + o[x,y,2] > 0 ? 0 : Z/2+1 : o
 		!w o '^$f^'
 	' | pico
-	iconv -c a8r8g8b8 $f | crop -t $t(1) $t(3) > a && mv a $f
+	iconv -c a8r8g8b8 $f | {crop -t $t(1) $t(3) >[2]/dev/null || cat} > a && mv a $f
 }
 status=''
--- a/utils/scefix
+++ b/utils/scefix
@@ -39,7 +39,7 @@
 		/env/fuckrc >/env/forever
 	</env/forever $home/p/pico/pico
 	iconv -c r8g8b8 /tmp/b.bit |\
-		crop -t $x1 $y1 \
+		{crop -t $x1 $y1 >[2]/dev/null || cat} \
 		>$name.$frm.$rot.bit
 	mv $name^s.$frm.$rot.bit $name.$frm.$rot.s.bit
 	rm /tmp/b.bit
@@ -81,7 +81,8 @@
 }
 
 fn translate{
-	crop -t $2 $3 $1 > a && mv a $1
+	if(! ~ $2 0 || ! ~ $3 0)
+		crop -t $2 $3 $1 > a && mv a $1
 }
 
 cat <<! >/env/fuckrc
--- a/utils/scerot
+++ b/utils/scerot
@@ -14,5 +14,5 @@
 for(i in $n){
 	t=`{read -c 46 $1^.^$id($i)^.bit | awk '{print $2, $3}'}
 	f=$1^.^$rev($i)^.bit
-	iconv -c $3 $f | crop -t $t > a && mv a $f
+	iconv -c $3 $f | {crop -t $t >[2]/dev/null || cat} > a && mv a $f
 }