Mercurial > hg > Members > kono > Cerium
annotate TaskManager/Test/test_render/spe/DrawSpan.cpp @ 156:cd5ad7adc5e1
fix
author | gongo@gendarme.local |
---|---|
date | Thu, 04 Dec 2008 14:25:00 +0900 |
parents | 77dac07efd79 |
children | 1f4c3f3238e6 |
rev | line source |
---|---|
109 | 1 #include <stdlib.h> |
2 #include <string.h> | |
3 #include "DrawSpan.h" | |
4 #include "polygon_pack.h" | |
5 #include "SpanPack.h" | |
6 #include "texture.h" | |
7 #include "viewer_types.h" | |
8 | |
9 #define SPAN_PACK_LOAD 0 | |
120 | 10 #define TEX_LOAD 1 |
147 | 11 #define TILE_INFO_LOAD 2 |
109 | 12 |
13 SchedDefineTask(DrawSpan); | |
14 | |
128
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
15 static const int hashsize = 263; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
16 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
17 static TilePtr hash_table[hashsize] = {NULL}; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
18 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
19 unsigned short PRIME[8] = { |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
20 0x002, 0x065, 0x0c7, 0x133, 0x191, 0x1f3, 0x259, 0x2bd, |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
21 }; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
22 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
23 static TileListPtr tileList; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
24 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
25 static int |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
26 hash(uint32 data) |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
27 { |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
28 int value = 0; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
29 int n = 0; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
30 int key; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
31 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
32 for (int i = 0; i < 8; i ++) { |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
33 key = data & 0xf; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
34 value += key * PRIME[n++]; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
35 data >>= 4; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
36 } |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
37 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
38 return value % hashsize; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
39 } |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
40 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
41 static int |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
42 put(void *key, TilePtr data) |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
43 { |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
44 int hashval = hash((uint32)key); |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
45 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
46 for (int i = 0; i < hashsize/2; i++) { |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
47 int index = (hashval + i*i)%hashsize; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
48 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
49 if (hash_table[index] == 0) { |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
50 hash_table[index] = data; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
51 return index; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
52 } |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
53 } |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
54 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
55 return -1; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
56 } |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
57 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
58 static TilePtr |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
59 get(void *key) |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
60 { |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
61 int hashval = hash((uint32)key); |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
62 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
63 for (int i = 0; i < hashsize/2; i++) { |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
64 int index = (hashval + i*i)%hashsize; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
65 |
131 | 66 if (hash_table[index] != NULL && |
67 hash_table[index]->texture_addr == key) { | |
128
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
68 return hash_table[index]; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
69 } |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
70 } |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
71 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
72 return NULL; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
73 } |
120 | 74 |
109 | 75 void |
76 DrawSpan::linebuf_init(int *buf, int x, int rgb) | |
77 { | |
78 for (int i = 0; i < x; i++) { | |
79 buf[i] = rgb; | |
80 } | |
81 } | |
82 | |
83 float* | |
84 DrawSpan::zRow_init(int w, int h) | |
85 { | |
86 float *zRow = NULL; | |
87 float z = 65535.0f; | |
88 int length = w*h; | |
89 | |
90 zRow = (float*)smanager->allocate(sizeof(float)*length); | |
91 | |
92 for (int i = 0; i < length; i++) { | |
93 zRow[i] = z; | |
94 } | |
95 | |
96 return zRow; | |
97 } | |
98 | |
99 | |
100 char* | |
101 DrawSpan::get_pixel(int tx, int ty, void *texture_image) | |
102 { | |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
103 return (char*)texture_image+(4*((TEXTURE_SPLIT_PIXEL)*ty+tx)); |
109 | 104 } |
105 | |
106 Uint32 | |
156 | 107 DrawSpan::get_rgb(int tx, int ty, void *addr) |
109 | 108 { |
109 Uint8 red, green, blue, alpha; | |
148
9642aeef298d
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
110 TilePtr tile; |
109 | 111 |
131 | 112 /** |
113 * get,put ϥ֥(HashȤ)äƥ뤫 | |
114 */ | |
156 | 115 tile = get(addr); |
128
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
116 if (tile == NULL) { |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
117 if (tileList->size >= MAX_TILE) { |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
118 tileList->init(); |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
119 bzero(hash_table, sizeof(TilePtr)*hashsize); |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
120 } |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
121 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
122 tile = &tileList->tile[tileList->size]; |
156 | 123 tile->texture_addr = addr; |
120 | 124 |
156 | 125 smanager->dma_load(tile->pixel, (uint32)addr, |
128
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
126 sizeof(uint32)*64, TEX_LOAD); |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
127 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
128 int index = put(tile->texture_addr, tile); |
131 | 129 |
130 /** | |
131 * TODO: | |
132 * ʤäĤ | |
133 * ޤǤΤĤ褷Ƥ³Ȥ | |
134 */ | |
128
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
135 if (index < 0) { |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
136 printf("[%p] Can't entry\n", tile); |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
137 return 0xff0000; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
138 } |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
139 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
140 tileList->size++; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
141 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
142 smanager->dma_wait(TEX_LOAD); |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
143 } |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
144 |
156 | 145 char *p = get_pixel(tx, ty, tile->pixel); |
120 | 146 |
126
7635f223fc7d
fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
123
diff
changeset
|
147 alpha = 255; |
7635f223fc7d
fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
123
diff
changeset
|
148 red = (Uint8) p[0]; |
109 | 149 green = (Uint8) p[1]; |
126
7635f223fc7d
fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
123
diff
changeset
|
150 blue = (Uint8) p[2]; |
109 | 151 |
152 return (red & 0xff) * 0x10000 + (green & 0xff) * 0x100 | |
153 + (blue & 0xff) + (alpha << 24); | |
154 } | |
155 | |
156 int | |
157 DrawSpan::run(void *rbuf, void *wbuf) | |
158 { | |
159 SpanPack *sp = (SpanPack*)smanager->get_input(0); | |
160 SpanPack *next_sp = | |
161 (SpanPack*)smanager->allocate(sizeof(SpanPack)); | |
162 SpanPack *free_sp = next_sp; // next_sp free() | |
163 SpanPack *tmp_sp = NULL; | |
164 Span *span; | |
165 | |
147 | 166 TileInfoListPtr tilist = |
167 (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList)); | |
168 TileInfoListPtr next_tilist = | |
169 (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList)); | |
170 TileInfoPtr tinfo; | |
171 | |
172 | |
128
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
173 tileList = (TileListPtr)smanager->allocate(sizeof(TileList)); |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
174 tileList->init(); |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
175 |
109 | 176 int render_y = sp->info.y_top; |
177 void *texture_image = global_get(TEXTURE_ID); | |
178 | |
179 int rangex_start = get_param(0); // Υô x ϰϤλ | |
180 int rangex_end = get_param(1); // (start <= x <= end) | |
181 int rangey = get_param(2); // y ϰ (render_y + rangey - 1) | |
182 int rangex = rangex_end - rangex_start + 1; | |
183 | |
184 float *zRow = zRow_init(rangex, rangey); | |
185 | |
186 int **linebuf = (int**)smanager->allocate(sizeof(int*)*rangey); | |
187 | |
188 for (int i = 0; i < rangey; i++) { | |
189 linebuf[i] = (int*)smanager->get_output(i); | |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
190 linebuf_init(linebuf[i], rangex, 0xffffff); |
109 | 191 } |
192 | |
128
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
193 bzero(hash_table, sizeof(TilePtr)*hashsize); |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
194 |
109 | 195 do { |
196 /** | |
197 * SpanPack->next ¸ߤ硢 | |
198 * ߤ SpanPack Ƥ֤ | |
199 * SpanPack DMA žԤ | |
200 */ | |
201 if (sp->next != NULL) { | |
202 smanager->dma_load(next_sp, (uint32)sp->next, | |
203 sizeof(SpanPack), SPAN_PACK_LOAD); | |
204 } else { | |
205 next_sp = NULL; | |
206 } | |
207 | |
208 for (int t = 0; t < sp->info.size; t++) { | |
209 span = &sp->span[t]; | |
210 | |
147 | 211 smanager->dma_load(tilist, (uint32)span->tilelist, |
212 sizeof(TileInfoList), TILE_INFO_LOAD); | |
213 | |
109 | 214 Uint32 rgb = 0x00ff00; |
215 float tex1 = span->tex_x1; | |
216 float tex2 = span->tex_x2; | |
217 float tey1 = span->tex_y1; | |
218 float tey2 = span->tex_y2; | |
219 int tex_xpos; | |
220 int tex_ypos; | |
221 int tex_zpos; | |
222 int x = span->x; | |
223 int y = span->y; | |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
224 int x_len = span->length_x; |
109 | 225 float z = span->start_z; |
226 float zpos = span->end_z; | |
227 | |
228 // ɸ [0 .. split_screen_w-1] 褦 x,y -1 | |
229 int localx = getLocalX(x-1); | |
230 int localy = getLocalY(y-1); | |
131 | 231 |
147 | 232 smanager->dma_wait(TILE_INFO_LOAD); |
233 | |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
234 if (x_len == 1) { |
109 | 235 if (x < rangex_start || rangex_end < x) { |
236 continue; | |
237 } | |
148
9642aeef298d
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
238 |
156 | 239 #if 1 |
240 tex_xpos = tilist->tileinfo[0].tix; | |
241 tex_ypos = tilist->tileinfo[0].tiy; | |
242 texture_image = tilist->tileinfo[0].tile; | |
243 #else | |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
244 tex_xpos = (int)((span->tex_width-1) * tex1); |
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
245 tex_ypos = (int)((span->tex_height-1) * tey1); |
109 | 246 tex_zpos = (int)z; |
156 | 247 #endif |
109 | 248 |
249 if (zpos < zRow[localx + (rangex * localy)]) { | |
156 | 250 rgb = get_rgb(tex_xpos, tex_ypos, texture_image); |
109 | 251 zRow[localx + (rangex * localy)] = zpos; |
252 linebuf[localy][localx] = rgb; | |
253 } | |
254 } else { | |
255 int js = (x < rangex_start) ? rangex_start - x : 0; | |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
256 int je = (x + x_len > rangex_end) ? rangex_end - x : x_len; |
155 | 257 |
147 | 258 if (js > je) continue; |
259 | |
260 int cur_x = 0; | |
261 int max_x = je; | |
155 | 262 int len = 0; |
109 | 263 |
148
9642aeef298d
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
264 /** |
9642aeef298d
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
265 * Span ɽʤϰ([js..je]) TileInfoList |
9642aeef298d
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
266 * äƤΤǡФ |
9642aeef298d
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
267 */ |
155 | 268 while (cur_x + MAX_TILE_LIST <= js) { |
148
9642aeef298d
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
269 smanager->dma_load(next_tilist, (uint32)tilist->next, |
9642aeef298d
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
270 sizeof(TileInfoList), TILE_INFO_LOAD); |
147 | 271 smanager->dma_wait(TILE_INFO_LOAD); |
148
9642aeef298d
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
272 |
9642aeef298d
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
273 TileInfoListPtr tmp = tilist; |
9642aeef298d
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
274 tilist = next_tilist; |
9642aeef298d
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
275 next_tilist = tmp; |
9642aeef298d
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
276 |
147 | 277 cur_x += MAX_TILE_LIST; |
278 } | |
279 | |
280 cur_x = js; | |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
281 |
148
9642aeef298d
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
282 while (cur_x <= max_x) { |
155 | 283 /** |
284 * TileInfoList 30 ĤǶڤƤΤ | |
285 * cur_x TileInfoList 椫ϤޤäƤ | |
286 * MAX_TILE_LIST ˼ޤͤ | |
287 * (ex.) | |
288 * cur_x (=js) 0 Ϥޤä硢 | |
289 * cur_x = 0, len = 29 | |
290 * cur_x (=js) 15 Ϥޤä硢 | |
291 * cur_x = 15, len = 14 ˤʤ | |
292 */ | |
293 int cur_x_diff = MAX_TILE_LIST - (cur_x % MAX_TILE_LIST); | |
294 | |
295 if (cur_x + cur_x_diff - 1 < max_x) { | |
147 | 296 smanager->dma_load(next_tilist, (uint32)tilist->next, |
148
9642aeef298d
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
297 sizeof(TileInfoList), |
9642aeef298d
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
298 TILE_INFO_LOAD); |
155 | 299 len = cur_x_diff - 1; |
147 | 300 } else { |
301 len = max_x - cur_x; | |
109 | 302 } |
148
9642aeef298d
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
303 |
147 | 304 float tex_x, tex_y, tex_z; |
155 | 305 |
147 | 306 for (int j = cur_x; j <= cur_x + len; j++) { |
156 | 307 TileInfoPtr tinfo = &tilist->tileinfo[j%MAX_TILE_LIST]; |
147 | 308 localx = getLocalX(x-1+j); |
309 tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1); | |
156 | 310 |
311 #if 1 | |
312 tex_xpos = tinfo->tix; | |
313 tex_ypos = tinfo->tiy; | |
314 texture_image = tinfo->tile; | |
315 #else | |
147 | 316 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1); |
317 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1); | |
318 if (tex_x > 1) tex_x = 1; | |
319 if (tex_y > 1) tex_y = 1; | |
320 tex_xpos = (int)((span->tex_width-1) * tex_x); | |
321 tex_ypos = (int)((span->tex_height-1) * tex_y); | |
156 | 322 #endif |
148
9642aeef298d
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
323 |
147 | 324 if (tex_z < zRow[localx + (rangex*localy)]) { |
156 | 325 rgb = get_rgb(tex_xpos, tex_ypos, texture_image); |
147 | 326 zRow[localx + (rangex*localy)] = tex_z; |
327 linebuf[localy][localx] = rgb; | |
328 } | |
329 } | |
330 | |
331 smanager->dma_wait(TILE_INFO_LOAD); | |
332 | |
333 TileInfoListPtr tmp = tilist; | |
334 tilist = next_tilist; | |
335 next_tilist = tmp; | |
336 | |
155 | 337 cur_x += cur_x_diff; |
109 | 338 } |
339 } | |
340 } | |
147 | 341 |
109 | 342 smanager->dma_wait(SPAN_PACK_LOAD); |
343 | |
344 tmp_sp = sp; | |
345 sp = next_sp; | |
346 next_sp = tmp_sp; | |
347 } while (sp); | |
348 | |
349 free(free_sp); | |
350 free(linebuf); | |
351 free(zRow); | |
128
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
352 free(tileList); |
147 | 353 free(tilist); |
354 free(next_tilist); | |
109 | 355 |
356 return 0; | |
357 } |