shithub: sce

Download patch

ref: d980a1c4e5f4f5d524eff17b9957b3a2a73f1af1
parent: f91aca52e7e978613bdecf33a486efdb990c8520
author: qwx <qwx@sciops.net>
date: Mon Mar 16 02:50:20 EDT 2020

utils: extract object shadows

--- a/utils/genspr
+++ b/utils/genspr
@@ -1,6 +1,7 @@
 #!/bin/rc -e
+rfork n
 bind -a $home/p/pico /bin
-bind -a $home/p/sce/rc /bin
+bind -a $home/p/sce/utils /bin
 
 # drones
 for(i in `{awk 'BEGIN{s=0*17; for(i=s; i<s+17; i++) printf "%03d\n", i;}'})
@@ -27,19 +28,28 @@
 	scerot drone^$i^m.03
 for(i in `{seq 1 8})
 	scerot drone^$i^m.04
+scerot drones.00
+scerot dronesm.00
+scerot dronesm.01
+scerot dronesm.02
+scerot dronesm.03
+scerot dronesm.04
 
 # hatchery
-sceass hatchery.grp.00000.bit hatchery 00 00 '' -32 -30
-sceass hatchery.grp.00001.bit hatchery 01 00 '' -32 -30
-sceass hatchery.grp.00002.bit hatchery 02 00 '' -32 -30
-sceass hatchery.grp.00003.bit hatchery 03 00 '' -32 -30
-sceass hatchery.grp.00003.bit hatchery 04 00 '' -32 -30
-sceass hatchery.grp.00002.bit hatchery 05 00 '' -32 -30
-sceass hatchery.grp.00001.bit hatchery 06 00 '' -32 -30
-sceass hatchery.grp.00000.bit hatchery 07 00 '' -32 -30
+sceass -s hatchery.grp.00000.bit hatchery 00 00 '' -32 -30
+sceass -s hatchery.grp.00001.bit hatchery 01 00 '' -32 -30
+sceass -s hatchery.grp.00002.bit hatchery 02 00 '' -32 -30
+sceass -s hatchery.grp.00003.bit hatchery 03 00 '' -32 -30
+sceass -s hatchery.grp.00003.bit hatchery 04 00 '' -32 -30
+sceass -s hatchery.grp.00002.bit hatchery 05 00 '' -32 -30
+sceass -s hatchery.grp.00001.bit hatchery 06 00 '' -32 -30
+sceass -s hatchery.grp.00000.bit hatchery 07 00 '' -32 -30
+for(i in `{seq 0 7})
+	crop -t -32 -30 zhashad.grp.00000.bit >hatcherys.0^$i^.00.bit
 
 # command center
-sceass control.grp.00005.bit control 00 00 '' -2 -32
+sceass -s control.grp.00005.bit control 00 00 '' -2 -32
+crop -t -2 -32 tccShad.grp.00000.bit >controls.00.00.bit
 
 # scv
 for(i in `{awk 'BEGIN{s=0*17; for(i=s; i<s+17; i++) printf "%03d\n", i;}'})
@@ -46,3 +56,4 @@
 	sceass scv.grp.00^$i^.bit scv 00 $i '' -26 -14
 for(i in `{seq 1 8})
 	scerot scv^$i^.00
+scerot scvs.00
--- a/utils/sceass
+++ b/utils/sceass
@@ -1,6 +1,11 @@
 #!/bin/rc
+rfork e
+if(~ $1 -s){
+	noshad=1
+	shift
+}
 if(! ~ $#* 7){
-	echo usage: sceass grp name frm rot id dx dy
+	echo usage: $0 [-s] grp name frm rot id dx dy
 	exit usage
 }
 grp=$1
@@ -30,6 +35,18 @@
 	!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^'}'}
+t=`{read -c 36 $grp | awk '{dx=$2+'^$dx^'; dy=$3+'^$dy^'; print dx, dy, dy+8}'}
 for(i in $name^?^$id^.^$frm^.^$rot.bit)
-	iconv -c r8g8b8 $i | crop -t $t > a && mv a $i
+	iconv -c r8g8b8 $i | crop -t $t(1-2) > a && mv a $i
+if(~ $#noshad 0){
+	echo '
+		!r '^$grp^' s
+		m = z == 3 ? Z : y >= Y-8 ? Z : s[x,y+8,0] != 0 || s[x,y+8,1] != Z || s[x,y+8,2] != Z ? 0 : Z
+		b = z == 3 ? Z : s[x,y,0] != 0 || s[x,y,1] != Z || s[x,y,2] != Z ? 0 : Z
+		o = z == 3 || y < 8 ? Z : Z-m + b
+		o = z == 3 ? Z : z == 2 ? Z : z == 0 ? o == 0 ? o + 35 : 0 : z == 1 ? o == 0 ? o + 35 : Z : Z
+		!w o '^$name^'s'^$id^'.'^$frm^.^$rot^'.bit
+	' | pico
+	iconv -c r8g8b8 $name^s^$id^.^$frm^.^$rot.bit | crop -t $t(1) $t(3) > a && mv a $name^s^$id^.^$frm^.^$rot.bit
+}
+status=''