mksprite32 3.08 KB
#!/bin/csh

echo "/*		AUTOMATIC SPRITE 32/16 bit mode"
echo -n "	Generated: "
date
echo "	By command: " $0 $1 $2 $3 $4 $5
echo -n "	In directory: "
pwd
echo

set spname  = $1
set imgname = $2
set spx     = $3
set spy     = $4
set overlap = $5

@ overlap = $overlap + 0

set sizes=`imgsize $imgname`

@ sx = $sizes[1]
@ sy = $sizes[2]

echo Sprite Name = $spname
echo Image  Name = $imgname
echo Sprite xsiz = $spx
echo Sprite ysiz = $spy
echo Image  xsiz = $sx
echo Image  ysiz = $sy
echo Overlap     = $overlap

unset noclobber

/bin/rm -f ${spname}_imgs.h ${spname}_bms.h

@ iy = 0
@  y = $sy - $spy
@  y = $y - $overlap
while( $y >= 0 )
    if( $y != 0 ) then
@       yp = $y + $spy + $overlap - 1
    endif

@   h = $yp + 1 - $y
@   hd = $h - $overlap

@   x = 0
@   ix = 0
    while( $x < ($sx - 1) )
@	xp = $x + $spx + $overlap - 1
	if( $xp >= $sx ) then
@	    xp = $sx - 1
	endif

@	w = $xp + 1 - $x
@	wd = $w - $overlap

@	wd2 = 2 * $wd
@	w2 = 2 * $w

	echo subimg $imgname tmpimg.rgb $x $xp $y $yp
	subimg $imgname tmpimg.rgb $x $xp $y $yp
	file tmpimg.rgb
	$ROOT/usr/sbin/rgb2c -F -m ${spname}_bm${iy}_${ix} -f RGBA -s 32 tmpimg.rgb >> ${spname}_imgs.h
	echo "{" $wd2, $w2, 0,0, ${spname}_bm${iy}_${ix}, "  $hd, 0 }," >> ${spname}_bms.h
@	x = $x + $spx
@	ix++
    end

    if( $y == 0 ) goto done

    if( $y > $spy ) then
@       y = $y - $spy
    else
@	yp = $y
@       y = 0
    endif

@   iy++
end

done:

/bin/rm -f tmpimg.rgb

@ sx = $sx - $overlap
@ sy = $sy - $overlap
@ spyh = $spy + $overlap

if( $overlap ) then
    set spflags = "SP_Z | SP_OVERLAP"
else
    set spflags = "SP_Z | SP_FASTCOPY"
endif

@ sx2 = 2 * $sx

echo "*/ "
echo ""
echo "#include <sp.h>"
echo ""
echo '#include "Texture/'${spname}'_imgs.h"'
echo ""
echo "static Bitmap " ${spname}"_bitmaps[] = {"
echo ""
echo '#include "Texture/'${spname}'_bms.h"'
echo ""
echo "};"
echo ""
echo "#define NUM_${spname}_BMS  (sizeof(${spname}_bitmaps)/sizeof(Bitmap))"
echo ""
echo "static Gfx      ${spname}_dl[NUM_DL(NUM_${spname}_BMS)];"
echo ""
echo "extern Sprite ${spname}_sprite;"
echo ""
echo "Sprite ${spname}_sprite = {"
echo ""
echo "	0,0,			/* Position: x,y */"
echo ""
echo "	$sx2,$sy,			/* Sprite size in texels (x,y) */"
echo ""
echo "	1.0,1.0,		/* Sprite Scale: x,y */"
echo ""
echo "	0,0,		/* Sprite Explosion Spacing: x,y */"
echo ""
echo "	$spflags,			/* Sprite Attributes */"
echo "	0x1234,			/* Sprite Depth: Z */"
echo ""
echo "	255,255,255,255,	/* Sprite Coloration: RGBA */"
echo ""
echo "	0,0,NULL,		/* Color LookUp Table: start_index, length, address */"
echo ""
echo "	0,1,			/* Sprite Bitmap index: start index, step increment */"
echo ""
echo "	NUM_${spname}_BMS,		/* Number of bitmaps */"
echo "	NUM_DL(NUM_${spname}_BMS),	/* Number of display list locations allocated */"
echo ""
echo "	$spy, $spyh,			/* Sprite Bitmap Height: Used_height, physical height */"
echo "	G_IM_FMT_RGBA,		/* Sprite Bitmap Format */"
echo "	G_IM_SIZ_16b,		/* Sprite Bitmap Texel Size */"
echo ""
echo "	${spname}_bitmaps,		/* Pointer to bitmaps */"
echo ""
echo "	${spname}_dl,			/* Display list memory */"
echo ""
echo "	NULL			/* next_dl pointer */"
echo ""
echo "};"