shithub: sce

ref: ab0aec975dbb6edd2e31cb425b7046cdde0ed93c
dir: /utils/genspr/

View raw version
#!/bin/rc -e
rfork n
bind -a $home/p/pico /bin
bind -a $home/p/sce/utils /bin
bind -ca /sys/games/lib/sce .

# pwd must contain extracted object bitmaps and corresponding shadows,
# tile palette, tileset (wpe vr4 vx4) files
# and sctile in /bin

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 r8g8b8
	}
}

fn asprite{
	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;}'}){
			crop -t $3 $4 $1^.grp.^00^$n^.bit >a
			mv a $1^.^$id($i)^.^`{echo $n | awk '{printf "%02d", ($1%17) / (32/'^$2^')}'}^.bit
		}
		scerot $1^.^$id($i) $2 a8r8g8b8
	}
}

# individual units
unit drone 32 -48 -47 (0 1 2 3 4) (00 01 02 03 04)
unit scv 32 -26 -14 0 00

# sprites with transparency
asprite tscglow 32 -26 -14 (0 1 2 3) (00 01 02 03)

# 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
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
crop -t -2 -32 tccShad.grp.00000.bit >controls.00.00.bit

# generate tileset palette and tileset bitmap
sctile badlands
rm badlands.?[1-4]???.bit badlands.00[1-9]??.bit badlands.000[3-9]?.bit badlands.000^(25 26 27 28 29)^.bit badlands.00000.bit

# now fix the shit we just generated...
# (FIXME: remove the need for this)
scefix