Mercurial > hg > old > magoroku_racing
annotate ps2util.cc @ 99:c534f339ee8b
change c++
author | e085768 |
---|---|
date | Thu, 02 Jun 2011 17:51:41 +0900 |
parents | ps2util.c@1033fece71ce |
children | e5f2eb98b575 |
rev | line source |
---|---|
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
1 /* ps2util.c */ |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
2 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
3 #include <string.h> |
91 | 4 #include <stdio.h> |
5 #include <stdlib.h> | |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
6 #include <math.h> |
91 | 7 #include "libps2.h" |
8 #include "ps2util.h" | |
9 | |
10 /* | |
11 たぶん、本当は読み込んだ xml file から情報を取得するとかそんなんだと思う | |
12 どんな処理か分からないので、とりあえず、初期化している。 | |
13 */ | |
14 | |
15 OBJECT *ps2util_obj_Create_fromXML(char *filename) | |
16 { | |
17 OBJECT *body; | |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
18 |
91 | 19 /* |
20 body->xyz = {0,0,0,0}; | |
21 body->angle = {0,0,0,0}; | |
22 body->transfer = { {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0} }; | |
23 body->*name = filename; | |
24 body->*free_me = NULL; | |
25 */ | |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
26 |
91 | 27 return body; |
28 } | |
29 | |
30 | |
31 | |
32 void ps2util_obj_Set_effect(OBJECT *body, int def) | |
33 { | |
34 //none | |
35 } | |
36 | |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
37 // ベクトル v1 をベクトル v2 にコピーする |
91 | 38 void ps2_vu0_copy_vector(FVECTOR directionA, FVECTOR directionB) |
39 { | |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
40 memcpy(directionA, directionB, sizeof(FVECTOR)); |
91 | 41 } |
42 | |
43 | |
44 void ps2util_obj_Renew_transMatrix(OBJECT *car){ | |
45 //none | |
46 } | |
47 | |
48 | |
49 /* | |
50 ps2 内の texture.c から | |
51 */ | |
52 TEXTURE* read_png_file(char *texname) | |
53 { | |
98 | 54 printf("trace\n"); |
91 | 55 //とりあえず戻り値を返してエラーをどうにか |
56 TEXTURE* tex; | |
98 | 57 |
91 | 58 return tex; |
59 } | |
60 | |
61 | |
62 | |
95 | 63 int ps2util_tex_Set(TEXTURE* tex) |
91 | 64 { |
95 | 65 return -1; |
66 } | |
67 | |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
68 int ps2util_sprite_Create(ps2utilSprite *Sp, TEXTURE *sprite_tex) |
95 | 69 { |
70 return -1; | |
91 | 71 } |
72 | |
73 | |
74 void ps2util_obj_Set_texture(OBJECT* car_body, TEXTURE *tex) | |
75 { | |
76 //none | |
77 } | |
78 | |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
79 // 与えられた行列を単位行列に変換する |
95 | 80 void ps2_vu0_unit_matrix(FMATRIX m) |
91 | 81 { |
95 | 82 m[0][1] = m[0][2] = m[0][3] = 0; |
83 m[1][0] = m[1][2] = m[1][3] = 0; | |
84 m[2][0] = m[2][1] = m[2][3] = 0; | |
85 m[3][0] = m[3][1] = m[3][2] = 0; | |
86 m[0][0] = m[1][1] = m[2][2] = m[3][3] = 1.0; | |
91 | 87 } |
88 | |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
89 /* |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
90 Y軸を中心とした行列の回転 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
91 回転角 rx より X 軸を中心とした回転マトリックスを求めて、マトリックス m1 に左側から乗算して、その結果をマトリックス m0 に与える。 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
92 X 軸だけでなく Y 軸、Z 軸を中心とした関数もある。また3ついっんに回転させる関数もある。 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
93 */ |
95 | 94 void ps2_vu0_rot_matrix_y(FMATRIX result, FMATRIX m, float radian) |
91 | 95 { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
96 // 回転行列を作ってかけてやれば良い |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
97 |
95 | 98 m[0][1] = m[0][2] = m[0][3] = 0; |
99 m[1][0] = m[1][2] = m[1][3] = 0; | |
100 m[2][0] = m[2][1] = m[2][3] = 0; | |
101 m[3][0] = m[3][1] = m[3][2] = 0; | |
102 m[0][0] = m[1][1] = m[2][2] = m[3][3] = 1.0; | |
103 | |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
104 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
105 m[0][0] = sinf(radian); |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
106 m[2][2] = sinf(radian); |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
107 m[0][2] = -cosf(radian); |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
108 m[2][0] = cosf(radian); |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
109 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
110 FMATRIX m1;// = m; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
111 memcpy(&m1, m, sizeof(FMATRIX)); |
95 | 112 |
113 ps2_vu0_mul_matrix(result, m1, m); | |
91 | 114 } |
115 | |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
116 // ベクトルの計算 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
117 // マトリックス m にベクトル を右から乗算して result に与える |
95 | 118 void ps2_vu0_apply_matrix(FVECTOR result, FMATRIX m, FVECTOR v) |
91 | 119 { |
95 | 120 result[0] = m[0][0] * v[0] + m[0][1] * v[1] + m[0][2] * v[2] + m[0][3] * v[3] ; |
121 result[1] = m[1][0] * v[0] + m[1][1] * v[1] + m[1][2] * v[2] + m[1][3] * v[3] ; | |
122 result[2] = m[2][0] * v[0] + m[2][1] * v[1] + m[2][2] * v[2] + m[2][3] * v[3] ; | |
123 result[3] = m[3][0] * v[0] + m[3][1] * v[1] + m[3][2] * v[2] + m[3][3] * v[3] ; | |
91 | 124 } |
125 | |
126 | |
127 void ps2_vu0_scale_vector(FVECTOR mov, FVECTOR car_direction, float car_speed) | |
128 { | |
95 | 129 mov[0] = car_direction[0] * car_speed ; |
130 mov[1] = car_direction[1] * car_speed ; | |
131 mov[2] = car_direction[2] * car_speed ; | |
132 mov[3] = car_direction[3]; | |
91 | 133 } |
134 | |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
135 // ベクトル v1 の各要素とベクトル v2 の各要素を各々加算してv0に与える |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
136 // v0 = v1+v2 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
137 void ps2_vu0_add_vector(FVECTOR result, FVECTOR v0, FVECTOR v1) |
91 | 138 { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
139 result[0] = v0[0] + v1[0]; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
140 result[1] = v0[1] + v1[1]; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
141 result[2] = v0[2] + v1[2]; |
98 | 142 // result[3] = v0[3] + v1[3]; |
143 result[3] = v0[3]; | |
91 | 144 } |
145 | |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
146 // 外積 |
95 | 147 void ps2_vu0_outer_product(FVECTOR result, FVECTOR v0, FVECTOR v1) |
91 | 148 { |
95 | 149 result[0] = v0[1] * v1[2] - v0[2] * v1[1] ; |
150 result[1] = v0[0] * v1[2] - v0[2] * v1[0] ; | |
151 result[2] = v0[0] * v1[1] - v0[1] * v1[0] ; | |
152 result[3] = 1; | |
91 | 153 } |
154 | |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
155 // 内積 |
95 | 156 float ps2_vu0_inner_product(FVECTOR v0, FVECTOR v1) |
91 | 157 { |
95 | 158 return v0[0] * v1[0] + v0[1] * v1[1] + v0[2] * v1[2]; |
91 | 159 } |
160 | |
161 | |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
162 void ps2_vu0_mul_matrix(FMATRIX result, FMATRIX m0, FMATRIX m1) |
91 | 163 { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
164 result[0][0] = m0[0][0] * m1[0][0] + m0[0][1] * m1[1][0] + m0[0][2] * m1[2][0] + m0[0][3] * m1[3][0]; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
165 result[0][1] = m0[0][0] * m1[0][1] + m0[0][1] * m1[1][1] + m0[0][2] * m1[2][1] + m0[0][3] * m1[3][1]; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
166 result[0][2] = m0[0][0] * m1[0][2] + m0[0][1] * m1[1][2] + m0[0][2] * m1[2][2] + m0[0][3] * m1[3][2]; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
167 result[0][3] = m0[0][0] * m1[0][3] + m0[0][1] * m1[1][3] + m0[0][2] * m1[2][3] + m0[0][3] * m1[3][3]; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
168 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
169 result[1][0] = m0[1][0] * m1[0][0] + m0[1][1] * m1[1][0] + m0[1][2] * m1[2][0] + m0[1][3] * m1[3][0]; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
170 result[1][1] = m0[1][0] * m1[0][1] + m0[1][1] * m1[1][1] + m0[1][2] * m1[2][1] + m0[1][3] * m1[3][1]; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
171 result[1][2] = m0[1][0] * m1[0][2] + m0[1][1] * m1[1][2] + m0[1][2] * m1[2][2] + m0[1][3] * m1[3][2]; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
172 result[1][3] = m0[1][0] * m1[0][3] + m0[1][1] * m1[1][3] + m0[1][2] * m1[2][3] + m0[1][3] * m1[3][3]; |
91 | 173 |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
174 result[2][0] = m0[2][0] * m1[0][0] + m0[2][1] * m1[1][0] + m0[2][2] * m1[2][0] + m0[2][3] * m1[3][0]; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
175 result[2][1] = m0[2][0] * m1[0][1] + m0[2][1] * m1[1][1] + m0[2][2] * m1[2][1] + m0[2][3] * m1[3][1]; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
176 result[2][2] = m0[2][0] * m1[0][2] + m0[2][1] * m1[1][2] + m0[2][2] * m1[2][2] + m0[2][3] * m1[3][2]; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
177 result[2][3] = m0[2][0] * m1[0][3] + m0[2][1] * m1[1][3] + m0[2][2] * m1[2][3] + m0[2][3] * m1[3][3]; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
178 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
179 result[3][0] = m0[3][0] * m1[0][0] + m0[3][1] * m1[1][0] + m0[3][2] * m1[2][0] + m0[3][3] * m1[3][0]; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
180 result[3][1] = m0[3][0] * m1[0][1] + m0[3][1] * m1[1][1] + m0[3][2] * m1[2][1] + m0[3][3] * m1[3][1]; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
181 result[3][2] = m0[3][0] * m1[0][2] + m0[3][1] * m1[1][2] + m0[3][2] * m1[2][2] + m0[3][3] * m1[3][2]; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
182 result[3][3] = m0[3][0] * m1[0][3] + m0[3][1] * m1[1][3] + m0[3][2] * m1[2][3] + m0[3][3] * m1[3][3]; |
91 | 183 } |
184 | |
185 | |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
186 void ps2_vu0_copy_matrix(FMATRIX transfer, FMATRIX pose) |
91 | 187 { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
188 memcpy(transfer, pose, sizeof(FMATRIX)); |
91 | 189 } |
190 | |
95 | 191 void ps2util_obj_Free(OBJECT* obj) |
91 | 192 { |
95 | 193 free(obj); |
91 | 194 } |
195 | |
196 | |
197 | |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
198 void ps2_vu0_sub_vector(FVECTOR result, FVECTOR v0, FVECTOR v1) |
91 | 199 { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
200 result[0] = v0[0] - v1[0]; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
201 result[1] = v0[1] - v1[1]; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
202 result[2] = v0[2] - v1[2]; |
98 | 203 result[3] = v0[3];// - v1[3]; |
91 | 204 } |
205 | |
206 | |
207 | |
95 | 208 void ps2_vu0_normalize(FVECTOR result, FVECTOR v) |
91 | 209 { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
210 // 大きさで割ってるだけって |
98 | 211 float d = sqrtf(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); |
95 | 212 result[0] = v[0] / d; |
213 result[1] = v[1] / d; | |
214 result[2] = v[2] / d; | |
215 result[3] = 1; | |
91 | 216 } |
217 | |
218 | |
219 void xml_free(PolygonInfo xml) | |
220 { | |
221 //none | |
222 } | |
223 | |
224 | |
225 void ps2util_obj_Draw(OBJECT *object) | |
226 { | |
227 //none | |
228 } | |
229 | |
230 | |
231 void ps2util_sprite_Destroy(ps2utilSprite *title_sprite ) | |
232 { | |
233 //none | |
234 } | |
235 | |
236 | |
237 | |
238 | |
95 | 239 void ps2util_sprite_Set_basicAttribute(ps2utilSprite *p, |
240 unsigned short x, unsigned short y, | |
241 unsigned short sptable_tw1, unsigned short sptable_th1, | |
242 unsigned short sptable_tx, unsigned short sptable_ty, | |
243 unsigned short sptable_tw2, unsigned short sptable_th2, | |
244 int sprite_prio_foreground) | |
245 { | |
246 //none | |
247 } | |
248 | |
249 void ps2util_sprite_Request(ps2utilSprite *p) | |
250 { | |
251 //none | |
252 } | |
253 | |
254 | |
255 void ps2util_sprite_Unuse_alpha(ps2utilSprite *sp) | |
256 { | |
257 //none | |
258 } | |
259 | |
260 void ps2util_graphic_Init() | |
261 { | |
262 //none | |
263 } | |
264 | |
265 | |
266 /* | |
267 ps2 依存関係の sprite.c より引用。 | |
268 */ | |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
269 #define SPRITE_HAS_4VERTEXIS 4 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
270 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
271 #define PS2_GS_XYZ3 1 // なにかわからん定数だから適当に作りました |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
272 |
97
afddacdf30dd
compile on Mac OS X -no Warning
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
96
diff
changeset
|
273 void |
95 | 274 sprite_disappear( SPRITE* sprite ) |
275 { | |
276 int i; | |
277 GsSpritePacket* packet = sprite->gs_packet; | |
278 for (i=0; i<SPRITE_HAS_4VERTEXIS; i++) | |
279 packet->primData[i].xyz_addr = PS2_GS_XYZ3; | |
280 } | |
281 | |
282 | |
283 | |
284 | |
91 | 285 /* |
286 からの関数 | |
287 ps2 依存関係にあったけど、( name_dictionary.c ) の中のもの | |
288 だけど、他にも持ってくるものが増えるので、とりあえず、からの関数に | |
289 */ | |
290 void delete_name_dictionary(const char *string) | |
291 { | |
292 /* | |
293 int number; | |
294 NAME_DIC *dic_ptr; | |
295 | |
296 if (string == NULL) return; | |
297 | |
298 number = hash_func(string,NAME_HASH_SIZE); | |
299 | |
300 for (dic_ptr=name_hash+number;dic_ptr->name;dic_ptr=name_hash+number) { | |
301 if (!strcmp(string,dic_ptr->name)) { | |
302 dic_ptr->ref_num--; | |
303 if (dic_ptr->ref_num == 0) { | |
304 free(dic_ptr->name); | |
305 dic_ptr->name = NULL; | |
306 } | |
307 return; | |
308 } else { | |
309 number += REHASH_NUM; | |
310 if (number > NAME_HASH_SIZE) number -= NAME_HASH_SIZE; | |
311 } | |
312 } | |
313 */ | |
314 } | |
315 | |
316 | |
317 | |
318 /* | |
319 ps2 依存関係から持ってきた。 | |
320 テクスチャに割り振ったメモリの解放処理? | |
321 元ファイル:texture.c | |
322 */ | |
323 void free_texture(TEXTURE *tex) | |
324 { | |
325 if (tex == NULL) return; | |
326 | |
327 delete_name_dictionary(tex->name); | |
328 free(tex->free_texenv); | |
329 free(tex->free_image); | |
330 free(tex); | |
331 } | |
332 | |
333 | |
334 /* | |
335 ps2 依存関係内の、texture.c から拝借 | |
336 この malloc によるメモリ取得をあちこちで行っているっぽい | |
95 | 337 cerium にある。 |
91 | 338 */ |
339 int malloc_align16(void *free, void *aligned, int size) | |
340 { | |
341 char *index; | |
342 unsigned int *f=(unsigned int *)free,*a=(unsigned int *)aligned; | |
343 | |
344 if (free == NULL || aligned == NULL || size <= 0) return(-1); | |
345 | |
346 index = (char *)malloc(size + ALIGN_16BYTE); | |
347 if (index == NULL) { | |
348 return(-1); | |
349 } | |
350 | |
351 *f = *a = (unsigned long int)index; | |
352 if (((unsigned long int)index % ALIGN_16BYTE) != 0) { | |
353 index += ALIGN_16BYTE - ((unsigned long int)index % ALIGN_16BYTE); | |
354 *a = (unsigned long int)index; | |
355 } | |
356 | |
357 return(0); | |
358 } | |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
359 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
360 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
361 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
362 // miya |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
363 void ps2util_tex_Exclude( TEXTURE* t ) |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
364 { |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
365 char *miyahira; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
366 miyahira = "なにこの関数?"; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
367 } |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
368 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
369 void ps2util_sprite_Draw() |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
370 { |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
371 printf("ps2util_sprite_Draw()\n"); |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
372 } |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
373 |
97
afddacdf30dd
compile on Mac OS X -no Warning
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
96
diff
changeset
|
374 void ps2util_graphic_Finish() |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
375 { |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
376 printf("ps2util_graphic_Finish()\n"); |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
377 } |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
378 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
379 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
380 // title.cに書いてた |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
381 void ps2util_sprite_Use_alpha( ps2utilSprite *title ) |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
382 { |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
383 printf("ps2util_sprite_Use_alpha()\n"); |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
95
diff
changeset
|
384 } |