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