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