annotate TaskManager/Test/test_render/spe/DrawSpan.cpp @ 166:8831c058a1ff draft

fix
author gongo@localhost.localdomain
date Tue, 09 Dec 2008 11:53:51 +0900
parents 121b08b64b44
children 508beb59e0eb
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
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
11
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
12 SchedDefineTask(DrawSpan);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
13
128
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
14 static const int hashsize = 263;
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
15
161
18c42658e0e7 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
16 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
17
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
18 unsigned short PRIME[8] = {
95e2046eb46f 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,
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
20 };
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 static TileListPtr tileList;
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
23
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
24 /**
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
25 * ƥϡTEXTURE_SPLIT_PIXEL^2 Υ֥åʬ䤹
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
26 *
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
27 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
28 * | 0 | 1 | 2 | 3 | 4 | 5 |
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
29 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
30 * | | | | | |11 |
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
31 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
32 * | | | | | |17 |
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
33 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
34 * | | | | | |23 |
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
35 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
36 * | | | | | |29 |
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
37 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
38 * | | | | | |35 |
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
39 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
40 *
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
41 * դ TEXTURE_SPLIT Ȥ
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
42 * ƥ֥åο֥åIDȤʤ롣
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
43 */
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
44
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
45 /**
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
46 * ƥκɸ顢
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
47 * ƥΤɤΥ֥å
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
48 *
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
49 * @param[in] tx X coordinates of texture
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
50 * @param[in] tx Y coordinates of texture
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
51 * @param[in] twidth Width of texture
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
52 * @return block ID
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
53 */
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
54 static inline int
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
55 get_tex_block(int tx, int ty, int twidth)
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
56 {
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
57 int blockX, blockY;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
58
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
59 blockX = tx / TEXTURE_SPLIT_PIXEL;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
60 blockY = ty / TEXTURE_SPLIT_PIXEL;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
61
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
62 return blockX + (twidth/TEXTURE_SPLIT_PIXEL)*blockY;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
63 }
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
64
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
65 /**
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
66 * block ID ȡƥ TOP address
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
67 * (tx,ty) ǻȤƥ Tile addres
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
68 *
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
69 * @param[in] tx X coordinates of texture
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
70 * @param[in] tx Y coordinates of texture
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
71 * @param[in] tw Width of texture
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
72 * @param[in] tex_addr_top (tx,ty) ǻȤƥƬaddress
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
73 * @return block ID
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
74 */
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
75 static inline uint32*
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
76 getTile(int tx, int ty, int tw, uint32 *tex_addr_top)
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
77 {
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
78 int block = get_tex_block(tx, ty, tw);
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
79 return tex_addr_top + block*TEXTURE_BLOCK_SIZE;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
80 }
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
81
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
82
128
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
83 static int
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
84 hash(uint32 data)
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
85 {
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
86 int value = 0;
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
87 int n = 0;
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
88 int key;
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
89
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
90 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
91 key = data & 0xf;
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
92 value += key * PRIME[n++];
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
93 data >>= 4;
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
94 }
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
95
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
96 return value % hashsize;
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
97 }
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
98
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
99 static int
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
100 put(void *key, TilePtr data)
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
101 {
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
102 int hashval = hash((uint32)key);
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
103
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
104 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
105 int index = (hashval + i*i)%hashsize;
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
106
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
107 if (hash_table[index] == 0) {
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
108 hash_table[index] = data;
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
109 return index;
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
110 }
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
111 }
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
112
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
113 return -1;
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
114 }
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
115
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
116 static TilePtr
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
117 get(void *key)
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
118 {
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
119 int hashval = hash((uint32)key);
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 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
122 int index = (hashval + i*i)%hashsize;
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
123
131
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
124 if (hash_table[index] != NULL &&
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
125 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
126 return hash_table[index];
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 }
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
129
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
130 return NULL;
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
131 }
120
13b43de5ef5d fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
132
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
133 void
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
134 DrawSpan::linebuf_init(int *buf, int x, int rgb)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
135 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
136 for (int i = 0; i < x; i++) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
137 buf[i] = rgb;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
138 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
139 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
140
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
141 float*
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
142 DrawSpan::zRow_init(int w, int h)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
143 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
144 float *zRow = NULL;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
145 float z = 65535.0f;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
146 int length = w*h;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
147
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
148 zRow = (float*)smanager->allocate(sizeof(float)*length);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
149
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
150 for (int i = 0; i < length; i++) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
151 zRow[i] = z;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
152 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
153
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
154 return zRow;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
155 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
156
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
157
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
158 char*
166
gongo@localhost.localdomain
parents: 165
diff changeset
159 DrawSpan::get_pixel(int tx, int ty, uint32 *texture_image)
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
160 {
166
gongo@localhost.localdomain
parents: 165
diff changeset
161 return (char*)(texture_image+((TEXTURE_SPLIT_PIXEL)*ty+tx));
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
162 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
163
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
164 Uint32
166
gongo@localhost.localdomain
parents: 165
diff changeset
165 DrawSpan::get_rgb(int tx, int ty, uint32 *addr)
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
166 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
167 Uint8 red, green, blue, alpha;
148
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
168 TilePtr tile;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
169
131
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
170 /**
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
171 * get,put ϥ֥(HashȤ)äƥ뤫
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
172 */
156
gongo@gendarme.local
parents: 155
diff changeset
173 tile = get(addr);
128
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
174 if (tile == NULL) {
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
175 if (tileList->size >= MAX_TILE) {
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
176 tileList->init();
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
177 bzero(hash_table, sizeof(TilePtr)*hashsize);
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
178 }
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
179
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
180 tile = &tileList->tile[tileList->size];
156
gongo@gendarme.local
parents: 155
diff changeset
181 tile->texture_addr = addr;
120
13b43de5ef5d fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
182
156
gongo@gendarme.local
parents: 155
diff changeset
183 smanager->dma_load(tile->pixel, (uint32)addr,
161
18c42658e0e7 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
184 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
185
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
186 int index = put(tile->texture_addr, tile);
131
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
187
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
188 /**
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
189 * TODO:
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
190 * ʤäĤ
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
191 * ޤǤΤĤ褷Ƥ³򤹤Ȥ
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
192 */
128
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
193 if (index < 0) {
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
194 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
195 return 0xff0000;
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
196 }
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
197
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
198 tileList->size++;
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
199
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
200 smanager->dma_wait(TEX_LOAD);
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
201 }
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
202
156
gongo@gendarme.local
parents: 155
diff changeset
203 char *p = get_pixel(tx, ty, tile->pixel);
120
13b43de5ef5d fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
204
126
74d0a70f60e9 fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 123
diff changeset
205 alpha = 255;
74d0a70f60e9 fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 123
diff changeset
206 red = (Uint8) p[0];
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
207 green = (Uint8) p[1];
126
74d0a70f60e9 fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 123
diff changeset
208 blue = (Uint8) p[2];
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
209
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
210 return (red & 0xff) * 0x10000 + (green & 0xff) * 0x100
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
211 + (blue & 0xff) + (alpha << 24);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
212 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
213
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
214
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
215
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
216 int
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
217 DrawSpan::run(void *rbuf, void *wbuf)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
218 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
219 SpanPack *sp = (SpanPack*)smanager->get_input(0);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
220 SpanPack *next_sp =
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
221 (SpanPack*)smanager->allocate(sizeof(SpanPack));
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
222 SpanPack *free_sp = next_sp; // next_sp free()
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
223 SpanPack *tmp_sp = NULL;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
224 Span *span;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
225
128
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
226 tileList = (TileListPtr)smanager->allocate(sizeof(TileList));
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
227 tileList->init();
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
228
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
229 int rangex_start = get_param(0); // Υô x ϰϤλ
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
230 int rangex_end = get_param(1); // (start <= x <= end)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
231 int rangey = get_param(2); // y ϰ (render_y + rangey - 1)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
232 int rangex = rangex_end - rangex_start + 1;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
233
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
234 float *zRow = zRow_init(rangex, rangey);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
235
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
236 int **linebuf = (int**)smanager->allocate(sizeof(int*)*rangey);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
237
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
238 for (int i = 0; i < rangey; i++) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
239 linebuf[i] = (int*)smanager->get_output(i);
133
8f1419174cdf DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
240 linebuf_init(linebuf[i], rangex, 0xffffff);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
241 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
242
128
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
243 bzero(hash_table, sizeof(TilePtr)*hashsize);
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
244
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
245 do {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
246 /**
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
247 * SpanPack->next ¸ߤ硢
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
248 * ߤ SpanPack Ƥ֤
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
249 * SpanPack DMA žԤ
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
250 */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
251 if (sp->next != NULL) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
252 smanager->dma_load(next_sp, (uint32)sp->next,
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
253 sizeof(SpanPack), SPAN_PACK_LOAD);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
254 } else {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
255 next_sp = NULL;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
256 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
257
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
258 for (int t = 0; t < sp->info.size; t++) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
259 span = &sp->span[t];
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
260
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
261 Uint32 rgb = 0x00ff00;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
262 float tex1 = span->tex_x1;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
263 float tex2 = span->tex_x2;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
264 float tey1 = span->tex_y1;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
265 float tey2 = span->tex_y2;
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
266
166
gongo@localhost.localdomain
parents: 165
diff changeset
267 /**
gongo@localhost.localdomain
parents: 165
diff changeset
268 * Span 1 pixel
gongo@localhost.localdomain
parents: 165
diff changeset
269 * ƥκɸ
gongo@localhost.localdomain
parents: 165
diff changeset
270 */
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
271 int tex_xpos;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
272 int tex_ypos;
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
273
166
gongo@localhost.localdomain
parents: 165
diff changeset
274 /**
gongo@localhost.localdomain
parents: 165
diff changeset
275 * (tex_xpos, tex_ypos) Ρ֥å(ο޻)Ǥκɸ
gongo@localhost.localdomain
parents: 165
diff changeset
276 * Υ֥åΥɥ쥹(MainMemory)
gongo@localhost.localdomain
parents: 165
diff changeset
277 */
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
278 int tex_localx;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
279 int tex_localy;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
280 uint32 *tex_addr;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
281
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
282 int x = span->x;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
283 int y = span->y;
133
8f1419174cdf DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
284 int x_len = span->length_x;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
285 float z = span->start_z;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
286 float zpos = span->end_z;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
287
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
288 // ɸ [0 .. split_screen_w-1] 褦 x,y -1
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
289 int localx = getLocalX(x-1);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
290 int localy = getLocalY(y-1);
131
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
291
133
8f1419174cdf DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
292 if (x_len == 1) {
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
293 if (x < rangex_start || rangex_end < x) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
294 continue;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
295 }
148
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
296
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
297 tex_xpos = (int)((span->tex_width-1) * tex1);
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
298 tex_ypos = (int)((span->tex_height-1) * tey1);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
299
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
300 if (zpos < zRow[localx + (rangex * localy)]) {
166
gongo@localhost.localdomain
parents: 165
diff changeset
301 tex_addr = getTile(tex_xpos, tex_ypos,
gongo@localhost.localdomain
parents: 165
diff changeset
302 span->tex_width, span->tex_addr);
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
303 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
304 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
166
gongo@localhost.localdomain
parents: 165
diff changeset
305
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
306 rgb = get_rgb(tex_localx, tex_localy, tex_addr);
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
307
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
308 zRow[localx + (rangex * localy)] = zpos;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
309 linebuf[localy][localx] = rgb;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
310 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
311 } else {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
312 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
313 int je = (x + x_len > rangex_end) ? rangex_end - x : x_len;
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
314 float tex_x, tex_y, tex_z;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
315
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
316 for (int j = js; j <= je; j++) {
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
317 localx = getLocalX(x-1+j);
148
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
318
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
319 tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1);
133
8f1419174cdf DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
320
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
321 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1);
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
322 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1);
165
gongo@localhost.localdomain
parents: 164
diff changeset
323 /**
gongo@localhost.localdomain
parents: 164
diff changeset
324 * ʤ󤫤äʤ
gongo@localhost.localdomain
parents: 164
diff changeset
325 */
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
326 if (tex_x > 1) tex_x = 1;
165
gongo@localhost.localdomain
parents: 164
diff changeset
327 if (tex_x < 0) tex_x = 0;
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
328 if (tex_y > 1) tex_y = 1;
165
gongo@localhost.localdomain
parents: 164
diff changeset
329 if (tex_y < 0) tex_y = 0;
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
330 tex_xpos = (int)((span->tex_width-1) * tex_x);
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
331 tex_ypos = (int)((span->tex_height-1) * tex_y);
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
332
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
333 if (tex_z < zRow[localx + (rangex*localy)]) {
166
gongo@localhost.localdomain
parents: 165
diff changeset
334 tex_addr = getTile(tex_xpos, tex_ypos,
gongo@localhost.localdomain
parents: 165
diff changeset
335 span->tex_width, span->tex_addr);
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
336 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
337 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
338
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
339 rgb = get_rgb(tex_localx, tex_localy, tex_addr);
148
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
340
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
341 zRow[localx + (rangex*localy)] = tex_z;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
342 linebuf[localy][localx] = rgb;
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
343 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
344 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
345 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
346 }
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
347
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
348 smanager->dma_wait(SPAN_PACK_LOAD);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
349
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
350 tmp_sp = sp;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
351 sp = next_sp;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
352 next_sp = tmp_sp;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
353 } while (sp);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
354
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
355 free(free_sp);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
356 free(linebuf);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
357 free(zRow);
128
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
358 free(tileList);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
359
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
360 return 0;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
361 }