mksprite32
3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/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 "};"