shithub: sce

Download patch

ref: a3bc56d5bd49d953282fa352bfffefe08ce1368e
parent: 099ef74351e85208311d29377c67b1153ad5ac75
author: qwx <qwx@sciops.net>
date: Tue Mar 17 11:36:07 EDT 2020

update sce.db and sprite generation utils

the utilities could probably be rewritten more cleanly in awk

--- a/sce/sce.db
+++ b/sce/sce.db
@@ -3,8 +3,18 @@
 resource,vespene gas,0
 attack,fusion cutter,5,1,15
 attack,spines,5,1,22
-obj,scv,3,1,1,60,0,5,7,1,50,0,20,fusion cutter,
-obj,drone,1,1,1,40,0,5,7,1,50,0,20,spines,
-obj,control,8,4,3,1500,1,0,1,10,400,0,1800,,
-obj,hatchery,8,4,3,1250,1,0,1,10,300,0,1800,,
+obj,scv,32,3,1,1,60,0,5,7,1,50,0,20,fusion cutter,
+obj,drone,32,1,1,1,40,0,5,7,1,50,0,20,spines,
+obj,control,1,8,4,3,1500,1,0,1,10,400,0,1800,,
+obj,hatchery,1,8,4,3,1250,1,0,1,10,300,0,1800,,
 spawn,control,scv
+spr,scv,1,0
+spr,scv,0x8001,0
+spr,control,1,0
+spr,control,0x8001,0
+spr,drone,1,0
+spr,drone,2,0,1,2,3,4
+spr,drone,0x8001,0
+spr,drone,0x8002,0,1,2,3,4
+spr,hatchery,1,0,1,2,3,3,2,1,0
+spr,hatchery,0x8001,0,0,0,0,0,0,0,0
--- a/utils/genspr
+++ b/utils/genspr
@@ -2,58 +2,32 @@
 rfork n
 bind -a $home/p/pico /bin
 bind -a $home/p/sce/utils /bin
+bind -ca /sys/games/lib/sce .
 
-# drones
-for(i in `{awk 'BEGIN{s=0*17; for(i=s; i<s+17; i++) printf "%03d\n", i;}'})
-	sceass drone.grp.00^$i^.bit drone 00 $i '' -48 -47
-for(i in `{awk 'BEGIN{s=0*17; for(i=s; i<s+17; i++) printf "%03d\n", i;}'})
-	sceass drone.grp.00^$i^.bit drone 00 $i 'm' -48 -47
-for(i in `{awk 'BEGIN{s=1*17; for(i=s; i<s+17; i++) printf "%03d\n", i;}'})
-	sceass drone.grp.00^$i^.bit drone 01 $i 'm' -48 -47
-for(i in `{awk 'BEGIN{s=2*17; for(i=s; i<s+17; i++) printf "%03d\n", i;}'})
-	sceass drone.grp.00^$i^.bit drone 02 $i 'm' -48 -47
-for(i in `{awk 'BEGIN{s=3*17; for(i=s; i<s+17; i++) printf "%03d\n", i;}'})
-	sceass drone.grp.00^$i^.bit drone 03 $i 'm' -48 -47
-for(i in `{awk 'BEGIN{s=4*17; for(i=s; i<s+17; i++) printf "%03d\n", i;}'})
-	sceass drone.grp.00^$i^.bit drone 04 $i 'm' -48 -47
-for(i in `{seq 1 8})
-	scerot drone^$i^.00
-for(i in `{seq 1 8})
-	scerot drone^$i^m.00
-for(i in `{seq 1 8})
-	scerot drone^$i^m.01
-for(i in `{seq 1 8})
-	scerot drone^$i^m.02
-for(i in `{seq 1 8})
-	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
+fn unit{
+	n=`{echo '(' $#* - 4 ')' / 2 | pc -n}
+	s1=`{echo 5 + $n - 1 | pc -n}
+	s2=`{echo $s1 + 1 | pc -n}
+	rng=$*(5-$s1)
+	id=$*($s2-)
+	for(i in `{seq 1 $#id}){
+		for(n in `{awk 'BEGIN{s='^$rng($i)^'*17; for(i=s; i<s+17; i+=32/'^$2^') printf "%03d\n", i;}'})
+			sceass $1^.grp.^00^$n^.bit $1 $id($i) `{echo $n | awk '{printf "%02d", ($1%17) / (32/'^$2^')}'} $3 $4
+		for(n in (`{seq 1 8} s))
+			scerot $1^$n^.^$id($i) $2
+	}
+}
 
+unit drone 32 -48 -47 (0 1 2 3 4) (00 01 02 03 04)
+unit scv 32 -26 -14 0 00
+
 # hatchery
-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
+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
+crop -t -32 -30 zhashad.grp.00000.bit >hatcherys.00.00.bit
 
 # command center
-sceass -s 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;}'})
-	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
@@ -4,17 +4,16 @@
 	noshad=1
 	shift
 }
-if(! ~ $#* 7){
-	echo usage: $0 [-s] grp name frm rot id dx dy
+if(! ~ $#* 6){
+	echo usage: $0 [-s] grp name frm rot dx dy
 	exit usage
 }
 grp=$1
 name=$2
 frm=$3
-rot=`{echo $4 | awk '{printf "%02d", $1 % 17}'}
-id=$5
-dx=$6
-dy=$7
+rot=$4
+dx=$5
+dy=$6
 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
@@ -26,19 +25,20 @@
 	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
+	!w red '^$name^'1.'^$frm^.^$rot^'.bit
+	!w blue '^$name^'2.'^$frm^.^$rot^'.bit
+	!w teal '^$name^'3.'^$frm^.^$rot^'.bit
+	!w purple '^$name^'4.'^$frm^.^$rot^'.bit
+	!w orange '^$name^'5.'^$frm^.^$rot^'.bit
+	!w brown '^$name^'6.'^$frm^.^$rot^'.bit
+	!w white '^$name^'7.'^$frm^.^$rot^'.bit
+	!w yellow '^$name^'8.'^$frm^.^$rot^'.bit
 ' | pico
 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)
+for(i in $name^?.^$frm^.^$rot.bit)
 	iconv -c r8g8b8 $i | crop -t $t(1-2) > a && mv a $i
 if(~ $#noshad 0){
+	f=$name^s.^$frm^.^$rot.bit
 	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
@@ -45,8 +45,8 @@
 		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
+		!w o '^$f^'
 	' | 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
+	iconv -c r8g8b8 $f | crop -t $t(1) $t(3) > a && mv a $f
 }
 status=''
--- a/utils/scerot
+++ b/utils/scerot
@@ -1,85 +1,18 @@
 #!/bin/rc -e
-if(! ~ $#* 1){
-	echo usage: sceass radix
+if(! ~ $#* 2){
+	echo usage: sceass radix nrot
 	exit usage
 }
-name=$1	#scv1.00
-echo '
-	!r '^$name^'.15.bit s
-	m = s[X-x-1,y,z]
-	!w m '^$name^'.17.bit
-	!r '^$name^'.14.bit s
-	m = s[X-x-1,y,z]
-	!w m '^$name^'.18.bit
-	!r '^$name^'.13.bit s
-	m = s[X-x-1,y,z]
-	!w m '^$name^'.19.bit
-	!r '^$name^'.12.bit s
-	m = s[X-x-1,y,z]
-	!w m '^$name^'.20.bit
-	!r '^$name^'.11.bit s
-	m = s[X-x-1,y,z]
-	!w m '^$name^'.21.bit
-	!r '^$name^'.10.bit s
-	m = s[X-x-1,y,z]
-	!w m '^$name^'.22.bit
-	!r '^$name^'.09.bit s
-	m = s[X-x-1,y,z]
-	!w m '^$name^'.23.bit
-	!r '^$name^'.08.bit s
-	m = s[X-x-1,y,z]
-	!w m '^$name^'.24.bit
-	!r '^$name^'.07.bit s
-	m = s[X-x-1,y,z]
-	!w m '^$name^'.25.bit
-	!r '^$name^'.06.bit s
-	m = s[X-x-1,y,z]
-	!w m '^$name^'.26.bit
-	!r '^$name^'.05.bit s
-	m = s[X-x-1,y,z]
-	!w m '^$name^'.27.bit
-	!r '^$name^'.04.bit s
-	m = s[X-x-1,y,z]
-	!w m '^$name^'.28.bit
-	!r '^$name^'.03.bit s
-	m = s[X-x-1,y,z]
-	!w m '^$name^'.29.bit
-	!r '^$name^'.02.bit s
-	m = s[X-x-1,y,z]
-	!w m '^$name^'.30.bit
-	!r '^$name^'.01.bit s
-	m = s[X-x-1,y,z]
-	!w m '^$name^'.31.bit
-' | pico
-for(i in $name.^`{seq 17 31}^.bit)
-	iconv -c r8g8b8 $i > a && mv a $i
-t=`{read -c 46 $name^.15.bit | awk '{print $2, $3}'}
-crop -t $t $name^.17.bit > a && mv a $name^.17.bit
-t=`{read -c 46 $name^.14.bit | awk '{print $2, $3}'}
-crop -t $t $name^.18.bit > a && mv a $name^.18.bit
-t=`{read -c 46 $name^.13.bit | awk '{print $2, $3}'}
-crop -t $t $name^.19.bit > a && mv a $name^.19.bit
-t=`{read -c 46 $name^.12.bit | awk '{print $2, $3}'}
-crop -t $t $name^.20.bit > a && mv a $name^.20.bit
-t=`{read -c 46 $name^.11.bit | awk '{print $2, $3}'}
-crop -t $t $name^.21.bit > a && mv a $name^.21.bit
-t=`{read -c 46 $name^.10.bit | awk '{print $2, $3}'}
-crop -t $t $name^.22.bit > a && mv a $name^.22.bit
-t=`{read -c 46 $name^.09.bit | awk '{print $2, $3}'}
-crop -t $t $name^.23.bit > a && mv a $name^.23.bit
-t=`{read -c 46 $name^.08.bit | awk '{print $2, $3}'}
-crop -t $t $name^.24.bit > a && mv a $name^.24.bit
-t=`{read -c 46 $name^.07.bit | awk '{print $2, $3}'}
-crop -t $t $name^.25.bit > a && mv a $name^.25.bit
-t=`{read -c 46 $name^.06.bit | awk '{print $2, $3}'}
-crop -t $t $name^.26.bit > a && mv a $name^.26.bit
-t=`{read -c 46 $name^.05.bit | awk '{print $2, $3}'}
-crop -t $t $name^.27.bit > a && mv a $name^.27.bit
-t=`{read -c 46 $name^.04.bit | awk '{print $2, $3}'}
-crop -t $t $name^.28.bit > a && mv a $name^.28.bit
-t=`{read -c 46 $name^.03.bit | awk '{print $2, $3}'}
-crop -t $t $name^.29.bit > a && mv a $name^.29.bit
-t=`{read -c 46 $name^.02.bit | awk '{print $2, $3}'}
-crop -t $t $name^.30.bit > a && mv a $name^.30.bit
-t=`{read -c 46 $name^.01.bit | awk '{print $2, $3}'}
-crop -t $t $name^.31.bit > a && mv a $name^.31.bit
+id=`{awk 'BEGIN{for(i=1; i<='^$2^'/2-1; i++) printf "%02d\n", i}'}
+rev=`{awk 'BEGIN{for(i='^$2^'-1; i>='^$2^'/2+1; i--) printf "%02d\n", i}'}
+n=`{seq 1 $#id}
+echo `"{for(i in $n){
+	echo !r $1^.^$id($i)^.bit s
+	echo 'm = s[X-x-1,y,z]'
+	echo !w m $1^.$rev($i)^.bit
+}} | pico
+for(i in $n){
+	t=`{read -c 46 $1^.^$id($i)^.bit | awk '{print $2, $3}'}
+	f=$1^.^$rev($i)^.bit
+	iconv -c r8g8b8 $f | crop -t $t > a && mv a $f
+}