annotate TaskManager/Test/test_render/spe/DrawSpan.cpp @ 148:74341c8bf935 draft

Span への Texture List の渡し。じゃっかん texture がバグってるので 要チェック
author gongo@charles.cr.ie.u-ryukyu.ac.jp
date Tue, 02 Dec 2008 18:49:04 +0900
parents 4636153abc9f
children 79ded2ad7236 8c9cae96404b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
1 #include <stdlib.h>
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
2 #include <string.h>
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
3 #include "DrawSpan.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
4 #include "polygon_pack.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
5 #include "SpanPack.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
6 #include "texture.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
7 #include "viewer_types.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
8
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
9 #define SPAN_PACK_LOAD 0
120
13b43de5ef5d fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
10 #define TEX_LOAD 1
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
11 #define TILE_INFO_LOAD 2
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
12
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
13 SchedDefineTask(DrawSpan);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
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
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
17 static TilePtr hash_table[hashsize] = {NULL};
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
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
66 if (hash_table[index] != NULL &&
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
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
13b43de5ef5d fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
74
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
75 void
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
76 DrawSpan::linebuf_init(int *buf, int x, int rgb)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
77 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
78 for (int i = 0; i < x; i++) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
79 buf[i] = rgb;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
80 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
81 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
82
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
83 float*
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
84 DrawSpan::zRow_init(int w, int h)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
85 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
86 float *zRow = NULL;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
87 float z = 65535.0f;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
88 int length = w*h;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
89
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
90 zRow = (float*)smanager->allocate(sizeof(float)*length);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
91
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
92 for (int i = 0; i < length; i++) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
93 zRow[i] = z;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
94 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
95
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
96 return zRow;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
97 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
98
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
99
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
100 char*
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
101 DrawSpan::get_pixel(int tx, int ty, void *texture_image)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
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
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
104 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
105
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
106 Uint32
131
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
107 DrawSpan::get_rgb(int tx, int ty, int tw, int th, void *texture)
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
108 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
109 Uint8 red, green, blue, alpha;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
110
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
111 if (tx<0) tx = 0;
131
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
112 if (tw-1< tx) tx = tw-1 ;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
113 if (ty<0) ty = 0;
131
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
114 if (th-1< ty) ty = th-1 ;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
115
120
13b43de5ef5d fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
116 void *texture_addr;
148
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
117 TilePtr tile;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
118
148
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
119 #if 0
133
8f1419174cdf DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
120 int blockX = tx / TEXTURE_SPLIT_PIXEL;
8f1419174cdf DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
121 int blockY = ty / TEXTURE_SPLIT_PIXEL;
120
13b43de5ef5d fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
122 void** addrList = (void**)global_get(TEXTURE2_ID);
128
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
123
133
8f1419174cdf DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
124 texture_addr = addrList[blockX + (tw/TEXTURE_SPLIT_PIXEL)*blockY];
148
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
125 #else
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
126 texture_addr = texture;
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
127 #endif
128
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
128
131
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
129 /**
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
130 * get,put ϥ֥(HashȤ)äƥ뤫
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
131 */
128
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
132 tile = get(texture_addr);
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
133 if (tile == NULL) {
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
134 if (tileList->size >= MAX_TILE) {
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
135 tileList->init();
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
136 bzero(hash_table, sizeof(TilePtr)*hashsize);
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
137 }
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 tile = &tileList->tile[tileList->size];
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
140 tile->texture_addr = texture_addr;
120
13b43de5ef5d fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
141
128
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
142 smanager->dma_load(tile->pixel, (uint32)texture_addr,
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
143 sizeof(uint32)*64, TEX_LOAD);
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
144
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
145 int index = put(tile->texture_addr, tile);
131
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
146
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
147 /**
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
148 * TODO:
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
149 * ʤäĤ
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
150 * ޤǤΤĤ褷Ƥ³򤹤Ȥ
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
151 */
128
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
152 if (index < 0) {
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
153 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
154 return 0xff0000;
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
155 }
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
156
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
157 tileList->size++;
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
158
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
159 smanager->dma_wait(TEX_LOAD);
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
160 }
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
161
133
8f1419174cdf DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
162 char *p = get_pixel(tx%TEXTURE_SPLIT_PIXEL,
8f1419174cdf DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
163 ty%TEXTURE_SPLIT_PIXEL, tile->pixel);
120
13b43de5ef5d fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
164
126
74d0a70f60e9 fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 123
diff changeset
165 alpha = 255;
74d0a70f60e9 fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 123
diff changeset
166 red = (Uint8) p[0];
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
167 green = (Uint8) p[1];
126
74d0a70f60e9 fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 123
diff changeset
168 blue = (Uint8) p[2];
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
169
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
170 return (red & 0xff) * 0x10000 + (green & 0xff) * 0x100
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
171 + (blue & 0xff) + (alpha << 24);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
172 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
173
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
174 int
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
175 DrawSpan::run(void *rbuf, void *wbuf)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
176 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
177 SpanPack *sp = (SpanPack*)smanager->get_input(0);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
178 SpanPack *next_sp =
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
179 (SpanPack*)smanager->allocate(sizeof(SpanPack));
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
180 SpanPack *free_sp = next_sp; // next_sp free()
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
181 SpanPack *tmp_sp = NULL;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
182 Span *span;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
183
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
184 TileInfoListPtr tilist =
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
185 (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList));
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
186 TileInfoListPtr next_tilist =
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
187 (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList));
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
188 TileInfoPtr tinfo;
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
189
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
190
128
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
191 tileList = (TileListPtr)smanager->allocate(sizeof(TileList));
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
192 tileList->init();
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
193
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
194 int render_y = sp->info.y_top;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
195 void *texture_image = global_get(TEXTURE_ID);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
196
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
197 int rangex_start = get_param(0); // Υô x ϰϤλ
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
198 int rangex_end = get_param(1); // (start <= x <= end)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
199 int rangey = get_param(2); // y ϰ (render_y + rangey - 1)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
200 int rangex = rangex_end - rangex_start + 1;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
201
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
202 float *zRow = zRow_init(rangex, rangey);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
203
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
204 int **linebuf = (int**)smanager->allocate(sizeof(int*)*rangey);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
205
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
206 for (int i = 0; i < rangey; i++) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
207 linebuf[i] = (int*)smanager->get_output(i);
133
8f1419174cdf DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
208 linebuf_init(linebuf[i], rangex, 0xffffff);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
209 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
210
128
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
211 bzero(hash_table, sizeof(TilePtr)*hashsize);
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
212
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
213 do {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
214 /**
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
215 * SpanPack->next ¸ߤ硢
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
216 * ߤ SpanPack Ƥ֤
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
217 * SpanPack DMA žԤ
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
218 */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
219 if (sp->next != NULL) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
220 smanager->dma_load(next_sp, (uint32)sp->next,
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
221 sizeof(SpanPack), SPAN_PACK_LOAD);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
222 } else {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
223 next_sp = NULL;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
224 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
225
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
226 for (int t = 0; t < sp->info.size; t++) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
227 span = &sp->span[t];
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
228
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
229 smanager->dma_load(tilist, (uint32)span->tilelist,
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
230 sizeof(TileInfoList), TILE_INFO_LOAD);
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
231
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
232 Uint32 rgb = 0x00ff00;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
233 float tex1 = span->tex_x1;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
234 float tex2 = span->tex_x2;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
235 float tey1 = span->tex_y1;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
236 float tey2 = span->tex_y2;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
237 int tex_xpos;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
238 int tex_ypos;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
239 int tex_zpos;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
240 int x = span->x;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
241 int y = span->y;
133
8f1419174cdf DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
242 int x_len = span->length_x;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
243 float z = span->start_z;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
244 float zpos = span->end_z;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
245
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
246 // ɸ [0 .. split_screen_w-1] 褦 x,y -1
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
247 int localx = getLocalX(x-1);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
248 int localy = getLocalY(y-1);
131
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
249
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
250 smanager->dma_wait(TILE_INFO_LOAD);
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
251
133
8f1419174cdf DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
252 if (x_len == 1) {
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
253 if (x < rangex_start || rangex_end < x) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
254 continue;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
255 }
148
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
256
133
8f1419174cdf DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
257 tex_xpos = (int)((span->tex_width-1) * tex1);
8f1419174cdf DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
258 tex_ypos = (int)((span->tex_height-1) * tey1);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
259 tex_zpos = (int)z;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
260
148
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
261 #if 0
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
262 if (tex_xpos != tilist->tileinfo[0].tix
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
263 && tex_xpos != tilist->tileinfo[0].tix) {
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
264 fprintf(stderr, "1: (%3d, %3d), (%3d, %3d)\n",
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
265 tex_xpos, tex_ypos, tilist->tileinfo[0].tix,
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
266 tilist->tileinfo[0].tiy);
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
267 }
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
268 #endif
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
269
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
270 tex_xpos = tilist->tileinfo[0].tix;
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
271 tex_ypos = tilist->tileinfo[0].tiy;
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
272 texture_image = tilist->tileinfo[0].tile;
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
273
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
274 if (zpos < zRow[localx + (rangex * localy)]) {
131
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
275 rgb = get_rgb(tex_xpos, tex_ypos, span->tex_width,
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
276 span->tex_height, texture_image);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
277 zRow[localx + (rangex * localy)] = zpos;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
278 linebuf[localy][localx] = rgb;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
279 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
280 } else {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
281 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
282 int je = (x + x_len > rangex_end) ? rangex_end - x : x_len;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
283
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
284 if (js > je) continue;
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
285
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
286 int cur_x = 0;
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
287 int max_x = je;
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
288 int len;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
289
148
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
290 /**
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
291 * Span ɽʤϰ([js..je]) TileInfoList
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
292 * äƤΤǡФ
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
293 */
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
294 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
295 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
296 sizeof(TileInfoList), TILE_INFO_LOAD);
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
297 smanager->dma_wait(TILE_INFO_LOAD);
148
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
298
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
299 TileInfoListPtr tmp = tilist;
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
300 tilist = next_tilist;
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
301 next_tilist = tmp;
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
302
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
303 cur_x += MAX_TILE_LIST;
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
304 }
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
305
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
306 cur_x = js;
133
8f1419174cdf DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
307
148
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
308 while (cur_x <= max_x) {
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
309 if (cur_x + MAX_TILE_LIST - 1 < max_x) {
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
310 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
311 sizeof(TileInfoList),
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
312 TILE_INFO_LOAD);
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
313 len = MAX_TILE_LIST - 1;
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
314 } else {
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
315 len = max_x - cur_x;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
316 }
148
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
317
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
318 float tex_x, tex_y, tex_z;
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
319
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
320 for (int j = cur_x; j <= cur_x + len; j++) {
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
321 localx = getLocalX(x-1+j);
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
322 tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1);
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
323
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
324 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1);
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
325 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1);
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
326 if (tex_x > 1) tex_x = 1;
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
327 if (tex_y > 1) tex_y = 1;
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
328 tex_xpos = (int)((span->tex_width-1) * tex_x);
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
329 tex_ypos = (int)((span->tex_height-1) * tex_y);
148
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
330
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
331 #if 0
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
332 if (tex_xpos != tilist->tileinfo[j%MAX_TILE_LIST].tix
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
333 && tex_xpos != tilist->tileinfo[j%MAX_TILE_LIST].tix) {
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
334 fprintf(stderr, "size = %d\n", tilist->size);
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
335 fprintf(stderr, "(%3d ..%3d) %d, %d %d\n",
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
336 x, x + x_len, js, max_x, j%MAX_TILE_LIST);
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
337 fprintf(stderr, "(%3d, %3d), (%3d, %3d)\n",
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
338 tex_xpos, tex_ypos,
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
339 tilist->tileinfo[j%MAX_TILE_LIST].tix,
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
340 tilist->tileinfo[j%MAX_TILE_LIST].tiy);
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
341 }
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
342 #endif
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
343
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
344 tex_xpos = tilist->tileinfo[j%MAX_TILE_LIST].tix;
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
345 tex_ypos = tilist->tileinfo[j%MAX_TILE_LIST].tiy;
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
346 texture_image = tilist->tileinfo[j%MAX_TILE_LIST].tile;
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
347
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
348 if (tex_z < zRow[localx + (rangex*localy)]) {
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
349 rgb = get_rgb(tex_xpos, tex_ypos, span->tex_width,
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
350 span->tex_height, texture_image);
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
351 zRow[localx + (rangex*localy)] = tex_z;
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
352 linebuf[localy][localx] = rgb;
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
353 }
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
354 }
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
355
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
356 smanager->dma_wait(TILE_INFO_LOAD);
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
357
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
358 TileInfoListPtr tmp = tilist;
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
359 tilist = next_tilist;
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
360 next_tilist = tmp;
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
361
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
362 cur_x += MAX_TILE_LIST;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
363 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
364 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
365 }
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
366
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
367 smanager->dma_wait(SPAN_PACK_LOAD);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
368
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
369 tmp_sp = sp;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
370 sp = next_sp;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
371 next_sp = tmp_sp;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
372 } while (sp);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
373
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
374 free(free_sp);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
375 free(linebuf);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
376 free(zRow);
128
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
377 free(tileList);
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
378 free(tilist);
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
379 free(next_tilist);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
380
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
381 return 0;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
382 }