Mercurial > hg > Members > kono > Cerium
annotate TaskManager/Test/test_render/spe/DrawSpan.cpp @ 133:435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
add new xml file
author | gongo@charles.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Thu, 27 Nov 2008 15:08:10 +0900 |
parents | 805d27efafd8 |
children | 3ecf43bd1a35 |
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 |
109 | 11 |
12 SchedDefineTask(DrawSpan); | |
13 | |
128
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
14 static const int hashsize = 263; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
15 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
16 static TilePtr hash_table[hashsize] = {NULL}; |
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 unsigned short PRIME[8] = { |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
19 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
|
20 }; |
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 static TileListPtr tileList; |
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 int |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
25 hash(uint32 data) |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
26 { |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
27 int value = 0; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
28 int n = 0; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
29 int key; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
30 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
31 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
|
32 key = data & 0xf; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
33 value += key * PRIME[n++]; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
34 data >>= 4; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
35 } |
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 return value % hashsize; |
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 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
40 static int |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
41 put(void *key, TilePtr data) |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
42 { |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
43 int hashval = hash((uint32)key); |
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 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
|
46 int index = (hashval + i*i)%hashsize; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
47 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
48 if (hash_table[index] == 0) { |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
49 hash_table[index] = data; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
50 return index; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
51 } |
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 return -1; |
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 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
57 static TilePtr |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
58 get(void *key) |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
59 { |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
60 int hashval = hash((uint32)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 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
|
63 int index = (hashval + i*i)%hashsize; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
64 |
131 | 65 if (hash_table[index] != NULL && |
66 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
|
67 return hash_table[index]; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
68 } |
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 return NULL; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
72 } |
120 | 73 |
109 | 74 void |
75 DrawSpan::linebuf_init(int *buf, int x, int rgb) | |
76 { | |
77 for (int i = 0; i < x; i++) { | |
78 buf[i] = rgb; | |
79 } | |
80 } | |
81 | |
82 float* | |
83 DrawSpan::zRow_init(int w, int h) | |
84 { | |
85 float *zRow = NULL; | |
86 float z = 65535.0f; | |
87 int length = w*h; | |
88 | |
89 zRow = (float*)smanager->allocate(sizeof(float)*length); | |
90 | |
91 for (int i = 0; i < length; i++) { | |
92 zRow[i] = z; | |
93 } | |
94 | |
95 return zRow; | |
96 } | |
97 | |
98 | |
99 char* | |
100 DrawSpan::get_pixel(int tx, int ty, void *texture_image) | |
101 { | |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
102 return (char*)texture_image+(4*((TEXTURE_SPLIT_PIXEL)*ty+tx)); |
109 | 103 } |
104 | |
105 Uint32 | |
131 | 106 DrawSpan::get_rgb(int tx, int ty, int tw, int th, void *texture) |
109 | 107 { |
108 Uint8 red, green, blue, alpha; | |
109 | |
110 if (tx<0) tx = 0; | |
131 | 111 if (tw-1< tx) tx = tw-1 ; |
109 | 112 if (ty<0) ty = 0; |
131 | 113 if (th-1< ty) ty = th-1 ; |
109 | 114 |
120 | 115 void *texture_addr; |
109 | 116 |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
117 int blockX = tx / TEXTURE_SPLIT_PIXEL; |
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
118 int blockY = ty / TEXTURE_SPLIT_PIXEL; |
120 | 119 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
|
120 TilePtr tile; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
121 |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
122 texture_addr = addrList[blockX + (tw/TEXTURE_SPLIT_PIXEL)*blockY]; |
128
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
123 |
131 | 124 /** |
125 * get,put ϥ֥(HashȤ)äƥ뤫 | |
126 */ | |
128
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
127 tile = get(texture_addr); |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
128 if (tile == NULL) { |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
129 if (tileList->size >= MAX_TILE) { |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
130 tileList->init(); |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
131 bzero(hash_table, sizeof(TilePtr)*hashsize); |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
132 } |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
133 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
134 tile = &tileList->tile[tileList->size]; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
135 tile->texture_addr = texture_addr; |
120 | 136 |
128
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
137 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
|
138 sizeof(uint32)*64, TEX_LOAD); |
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 int index = put(tile->texture_addr, tile); |
131 | 141 |
142 /** | |
143 * TODO: | |
144 * ʤäĤ | |
145 * ޤǤΤĤ褷Ƥ³Ȥ | |
146 */ | |
128
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
147 if (index < 0) { |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
148 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
|
149 return 0xff0000; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
150 } |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
151 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
152 tileList->size++; |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
153 |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
154 smanager->dma_wait(TEX_LOAD); |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
155 } |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
156 |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
157 char *p = get_pixel(tx%TEXTURE_SPLIT_PIXEL, |
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
158 ty%TEXTURE_SPLIT_PIXEL, tile->pixel); |
120 | 159 |
126
7635f223fc7d
fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
123
diff
changeset
|
160 alpha = 255; |
7635f223fc7d
fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
123
diff
changeset
|
161 red = (Uint8) p[0]; |
109 | 162 green = (Uint8) p[1]; |
126
7635f223fc7d
fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
123
diff
changeset
|
163 blue = (Uint8) p[2]; |
109 | 164 |
165 return (red & 0xff) * 0x10000 + (green & 0xff) * 0x100 | |
166 + (blue & 0xff) + (alpha << 24); | |
167 } | |
168 | |
169 int | |
170 DrawSpan::run(void *rbuf, void *wbuf) | |
171 { | |
172 SpanPack *sp = (SpanPack*)smanager->get_input(0); | |
173 SpanPack *next_sp = | |
174 (SpanPack*)smanager->allocate(sizeof(SpanPack)); | |
175 SpanPack *free_sp = next_sp; // next_sp free() | |
176 SpanPack *tmp_sp = NULL; | |
177 Span *span; | |
178 | |
128
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
179 tileList = (TileListPtr)smanager->allocate(sizeof(TileList)); |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
180 tileList->init(); |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
181 |
109 | 182 int render_y = sp->info.y_top; |
183 void *texture_image = global_get(TEXTURE_ID); | |
184 | |
185 int rangex_start = get_param(0); // Υô x ϰϤλ | |
186 int rangex_end = get_param(1); // (start <= x <= end) | |
187 int rangey = get_param(2); // y ϰ (render_y + rangey - 1) | |
188 int rangex = rangex_end - rangex_start + 1; | |
189 | |
190 float *zRow = zRow_init(rangex, rangey); | |
191 | |
192 int **linebuf = (int**)smanager->allocate(sizeof(int*)*rangey); | |
193 | |
194 for (int i = 0; i < rangey; i++) { | |
195 linebuf[i] = (int*)smanager->get_output(i); | |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
196 linebuf_init(linebuf[i], rangex, 0xffffff); |
109 | 197 } |
198 | |
128
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
199 bzero(hash_table, sizeof(TilePtr)*hashsize); |
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
200 |
109 | 201 do { |
202 /** | |
203 * SpanPack->next ¸ߤ硢 | |
204 * ߤ SpanPack Ƥ֤ | |
205 * SpanPack DMA žԤ | |
206 */ | |
207 if (sp->next != NULL) { | |
208 smanager->dma_load(next_sp, (uint32)sp->next, | |
209 sizeof(SpanPack), SPAN_PACK_LOAD); | |
210 } else { | |
211 next_sp = NULL; | |
212 } | |
213 | |
214 for (int t = 0; t < sp->info.size; t++) { | |
215 span = &sp->span[t]; | |
216 | |
217 Uint32 rgb = 0x00ff00; | |
218 float tex1 = span->tex_x1; | |
219 float tex2 = span->tex_x2; | |
220 float tey1 = span->tex_y1; | |
221 float tey2 = span->tex_y2; | |
222 int tex_xpos; | |
223 int tex_ypos; | |
224 int tex_zpos; | |
225 int x = span->x; | |
226 int y = span->y; | |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
227 int x_len = span->length_x; |
109 | 228 float z = span->start_z; |
229 float zpos = span->end_z; | |
230 | |
231 // ɸ [0 .. split_screen_w-1] 褦 x,y -1 | |
232 int localx = getLocalX(x-1); | |
233 int localy = getLocalY(y-1); | |
131 | 234 |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
235 if (x_len == 1) { |
109 | 236 if (x < rangex_start || rangex_end < x) { |
237 continue; | |
238 } | |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
239 tex_xpos = (int)((span->tex_width-1) * tex1); |
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
240 tex_ypos = (int)((span->tex_height-1) * tey1); |
109 | 241 tex_zpos = (int)z; |
242 | |
243 if (zpos < zRow[localx + (rangex * localy)]) { | |
131 | 244 rgb = get_rgb(tex_xpos, tex_ypos, span->tex_width, |
245 span->tex_height, texture_image); | |
109 | 246 zRow[localx + (rangex * localy)] = zpos; |
247 linebuf[localy][localx] = rgb; | |
248 } | |
249 } else { | |
250 float tex_x, tex_y, tex_z; | |
251 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
|
252 int je = (x + x_len > rangex_end) ? rangex_end - x : x_len; |
109 | 253 |
254 for (int j = js; j <= je; j++) { | |
255 localx = getLocalX(x-1+j); | |
256 | |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
257 tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1); |
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
258 |
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
259 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1); |
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
260 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1); |
109 | 261 if (tex_x > 1) tex_x = 1; |
262 if (tex_y > 1) tex_y = 1; | |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
263 tex_xpos = (int)((span->tex_width-1) * tex_x); |
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
264 tex_ypos = (int)((span->tex_height-1) * tex_y); |
109 | 265 |
266 if (tex_z < zRow[localx + (rangex*localy)]) { | |
131 | 267 rgb = get_rgb(tex_xpos, tex_ypos, span->tex_width, |
268 span->tex_height, texture_image); | |
109 | 269 zRow[localx + (rangex*localy)] = tex_z; |
270 linebuf[localy][localx] = rgb; | |
271 } | |
272 } | |
273 } | |
274 } | |
275 | |
276 smanager->dma_wait(SPAN_PACK_LOAD); | |
277 | |
278 tmp_sp = sp; | |
279 sp = next_sp; | |
280 next_sp = tmp_sp; | |
281 } while (sp); | |
282 | |
283 free(free_sp); | |
284 free(linebuf); | |
285 free(zRow); | |
128
776eca0daa02
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
286 free(tileList); |
109 | 287 |
288 return 0; | |
289 } |