annotate TaskManager/Test/test_render/spe/DrawSpan.cpp @ 165:246881f0634b

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