Mercurial > hg > Game > Cerium
annotate TaskManager/Test/test_render/spe/DrawSpan.cpp @ 161:18c42658e0e7 draft fullHD_omedetou
texture の座標がマイナスになったあと、それを 0 にし忘れてた
author | gongo@localhost.localdomain |
---|---|
date | Mon, 08 Dec 2008 16:37:02 +0900 |
parents | 16c3cbbbfc50 |
children | dc7d10ae7460 |
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
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
15 static const int hashsize = 263; |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
16 |
161
18c42658e0e7
texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents:
156
diff
changeset
|
17 static TilePtr hash_table[hashsize] = {0}; |
128
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
18 |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
19 unsigned short PRIME[8] = { |
95e2046eb46f
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, |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
21 }; |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
22 |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
23 static TileListPtr tileList; |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
24 |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
25 static int |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
26 hash(uint32 data) |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
27 { |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
28 int value = 0; |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
29 int n = 0; |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
30 int key; |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
31 |
95e2046eb46f
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 ++) { |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
33 key = data & 0xf; |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
34 value += key * PRIME[n++]; |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
35 data >>= 4; |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
36 } |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
37 |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
38 return value % hashsize; |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
39 } |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
40 |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
41 static int |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
42 put(void *key, TilePtr data) |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
43 { |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
44 int hashval = hash((uint32)key); |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
45 |
95e2046eb46f
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++) { |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
47 int index = (hashval + i*i)%hashsize; |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
48 |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
49 if (hash_table[index] == 0) { |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
50 hash_table[index] = data; |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
51 return index; |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
52 } |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
53 } |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
54 |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
55 return -1; |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
56 } |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
57 |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
58 static TilePtr |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
59 get(void *key) |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
60 { |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
61 int hashval = hash((uint32)key); |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
62 |
95e2046eb46f
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++) { |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
64 int index = (hashval + i*i)%hashsize; |
95e2046eb46f
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
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
68 return hash_table[index]; |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
69 } |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
70 } |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
71 |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
72 return NULL; |
95e2046eb46f
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
8f1419174cdf
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
74341c8bf935
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
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
116 if (tile == NULL) { |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
117 if (tileList->size >= MAX_TILE) { |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
118 tileList->init(); |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
119 bzero(hash_table, sizeof(TilePtr)*hashsize); |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
120 } |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
121 |
95e2046eb46f
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, |
161
18c42658e0e7
texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents:
156
diff
changeset
|
126 sizeof(uint32)*TEXTURE_BLOCK_SIZE, TEX_LOAD); |
128
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
127 |
95e2046eb46f
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
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
135 if (index < 0) { |
95e2046eb46f
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); |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
137 return 0xff0000; |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
138 } |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
139 |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
140 tileList->size++; |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
141 |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
142 smanager->dma_wait(TEX_LOAD); |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
143 } |
95e2046eb46f
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
74d0a70f60e9
fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
123
diff
changeset
|
147 alpha = 255; |
74d0a70f60e9
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
74d0a70f60e9
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 | |
128
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
171 tileList = (TileListPtr)smanager->allocate(sizeof(TileList)); |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
172 tileList->init(); |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
173 |
161
18c42658e0e7
texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents:
156
diff
changeset
|
174 void *texture_image = global_get(TEXTURE_ID); |
109 | 175 int rangex_start = get_param(0); // Υô x ϰϤλ |
176 int rangex_end = get_param(1); // (start <= x <= end) | |
177 int rangey = get_param(2); // y ϰ (render_y + rangey - 1) | |
178 int rangex = rangex_end - rangex_start + 1; | |
179 | |
180 float *zRow = zRow_init(rangex, rangey); | |
181 | |
182 int **linebuf = (int**)smanager->allocate(sizeof(int*)*rangey); | |
183 | |
184 for (int i = 0; i < rangey; i++) { | |
185 linebuf[i] = (int*)smanager->get_output(i); | |
133
8f1419174cdf
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
186 linebuf_init(linebuf[i], rangex, 0xffffff); |
109 | 187 } |
188 | |
128
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
189 bzero(hash_table, sizeof(TilePtr)*hashsize); |
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
190 |
109 | 191 do { |
192 /** | |
193 * SpanPack->next ¸ߤ硢 | |
194 * ߤ SpanPack Ƥ֤ | |
195 * SpanPack DMA žԤ | |
196 */ | |
197 if (sp->next != NULL) { | |
198 smanager->dma_load(next_sp, (uint32)sp->next, | |
199 sizeof(SpanPack), SPAN_PACK_LOAD); | |
200 } else { | |
201 next_sp = NULL; | |
202 } | |
203 | |
204 for (int t = 0; t < sp->info.size; t++) { | |
205 span = &sp->span[t]; | |
206 | |
147 | 207 smanager->dma_load(tilist, (uint32)span->tilelist, |
208 sizeof(TileInfoList), TILE_INFO_LOAD); | |
209 | |
109 | 210 Uint32 rgb = 0x00ff00; |
211 int tex_xpos; | |
212 int tex_ypos; | |
213 int tex_zpos; | |
214 int x = span->x; | |
215 int y = span->y; | |
133
8f1419174cdf
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
216 int x_len = span->length_x; |
109 | 217 float z = span->start_z; |
218 float zpos = span->end_z; | |
219 | |
220 // ɸ [0 .. split_screen_w-1] 褦 x,y -1 | |
221 int localx = getLocalX(x-1); | |
222 int localy = getLocalY(y-1); | |
131 | 223 |
147 | 224 smanager->dma_wait(TILE_INFO_LOAD); |
225 | |
133
8f1419174cdf
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
226 if (x_len == 1) { |
109 | 227 if (x < rangex_start || rangex_end < x) { |
228 continue; | |
229 } | |
148
74341c8bf935
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
230 |
156 | 231 tex_xpos = tilist->tileinfo[0].tix; |
232 tex_ypos = tilist->tileinfo[0].tiy; | |
161
18c42658e0e7
texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents:
156
diff
changeset
|
233 tex_zpos = (int)z; |
156 | 234 texture_image = tilist->tileinfo[0].tile; |
109 | 235 |
236 if (zpos < zRow[localx + (rangex * localy)]) { | |
156 | 237 rgb = get_rgb(tex_xpos, tex_ypos, texture_image); |
109 | 238 zRow[localx + (rangex * localy)] = zpos; |
239 linebuf[localy][localx] = rgb; | |
240 } | |
241 } else { | |
242 int js = (x < rangex_start) ? rangex_start - x : 0; | |
133
8f1419174cdf
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
243 int je = (x + x_len > rangex_end) ? rangex_end - x : x_len; |
155 | 244 |
147 | 245 if (js > je) continue; |
246 | |
247 int cur_x = 0; | |
248 int max_x = je; | |
155 | 249 int len = 0; |
109 | 250 |
148
74341c8bf935
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
251 /** |
74341c8bf935
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
252 * Span ɽʤϰ([js..je]) TileInfoList |
74341c8bf935
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
253 * äƤΤǡФ |
74341c8bf935
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
254 */ |
155 | 255 while (cur_x + MAX_TILE_LIST <= js) { |
148
74341c8bf935
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
256 smanager->dma_load(next_tilist, (uint32)tilist->next, |
74341c8bf935
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
257 sizeof(TileInfoList), TILE_INFO_LOAD); |
147 | 258 smanager->dma_wait(TILE_INFO_LOAD); |
148
74341c8bf935
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
259 |
74341c8bf935
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
260 TileInfoListPtr tmp = tilist; |
74341c8bf935
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
261 tilist = next_tilist; |
74341c8bf935
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
262 next_tilist = tmp; |
74341c8bf935
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
263 |
147 | 264 cur_x += MAX_TILE_LIST; |
265 } | |
266 | |
267 cur_x = js; | |
133
8f1419174cdf
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
131
diff
changeset
|
268 |
148
74341c8bf935
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
269 while (cur_x <= max_x) { |
155 | 270 /** |
271 * TileInfoList 30 ĤǶڤƤΤ | |
272 * cur_x TileInfoList 椫ϤޤäƤ | |
273 * MAX_TILE_LIST ˼ޤͤ | |
274 * (ex.) | |
275 * cur_x (=js) 0 Ϥޤä硢 | |
276 * cur_x = 0, len = 29 | |
277 * cur_x (=js) 15 Ϥޤä硢 | |
278 * cur_x = 15, len = 14 ˤʤ | |
279 */ | |
280 int cur_x_diff = MAX_TILE_LIST - (cur_x % MAX_TILE_LIST); | |
281 | |
282 if (cur_x + cur_x_diff - 1 < max_x) { | |
147 | 283 smanager->dma_load(next_tilist, (uint32)tilist->next, |
148
74341c8bf935
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
284 sizeof(TileInfoList), |
74341c8bf935
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
285 TILE_INFO_LOAD); |
155 | 286 len = cur_x_diff - 1; |
147 | 287 } else { |
288 len = max_x - cur_x; | |
109 | 289 } |
148
74341c8bf935
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
290 |
147 | 291 for (int j = cur_x; j <= cur_x + len; j++) { |
156 | 292 TileInfoPtr tinfo = &tilist->tileinfo[j%MAX_TILE_LIST]; |
161
18c42658e0e7
texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents:
156
diff
changeset
|
293 float tex_z |
18c42658e0e7
texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents:
156
diff
changeset
|
294 = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1); |
18c42658e0e7
texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents:
156
diff
changeset
|
295 |
147 | 296 localx = getLocalX(x-1+j); |
156 | 297 |
298 tex_xpos = tinfo->tix; | |
299 tex_ypos = tinfo->tiy; | |
300 texture_image = tinfo->tile; | |
148
74341c8bf935
Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
147
diff
changeset
|
301 |
147 | 302 if (tex_z < zRow[localx + (rangex*localy)]) { |
156 | 303 rgb = get_rgb(tex_xpos, tex_ypos, texture_image); |
147 | 304 zRow[localx + (rangex*localy)] = tex_z; |
305 linebuf[localy][localx] = rgb; | |
306 } | |
307 } | |
308 | |
309 smanager->dma_wait(TILE_INFO_LOAD); | |
310 | |
311 TileInfoListPtr tmp = tilist; | |
312 tilist = next_tilist; | |
313 next_tilist = tmp; | |
314 | |
155 | 315 cur_x += cur_x_diff; |
109 | 316 } |
317 } | |
318 } | |
147 | 319 |
109 | 320 smanager->dma_wait(SPAN_PACK_LOAD); |
321 | |
322 tmp_sp = sp; | |
323 sp = next_sp; | |
324 next_sp = tmp_sp; | |
325 } while (sp); | |
326 | |
327 free(free_sp); | |
328 free(linebuf); | |
329 free(zRow); | |
128
95e2046eb46f
texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
126
diff
changeset
|
330 free(tileList); |
147 | 331 free(tilist); |
332 free(next_tilist); | |
109 | 333 |
334 return 0; | |
335 } |