annotate Renderer/Engine/spe/DrawSpan.cc @ 1144:e068c1269292 draft

light fix
author Yutaka_Kinjyo
date Sat, 19 Feb 2011 03:54:12 +0900
parents 2a63ba2c9506
children 4e898dca4ab9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <stdlib.h>
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <string.h>
1067
5ad8fb1dc70f print_arch add.
tkaito
parents: 1054
diff changeset
3 #include "polygon_pack.h"
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include "DrawSpan.h"
860
63a08f3a468a Still on the way
yutaka@localhost.localdomain
parents: 856
diff changeset
5 #include "task_texture.h"
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 #include "viewer_types.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 #include "Func.h"
1050
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 994
diff changeset
8 #include "matrix_calc.h"
618
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
9 #include "SchedTask.h"
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
10 #include "Tapestry.h"
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
11 #include "SpanPack.h"
764
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 761
diff changeset
12 #include <spu_intrinsics.h>
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
13 #include <math.h>
618
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
14
623
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 622
diff changeset
15 #if (__LITTLE_ENDIAN__)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 622
diff changeset
16 #define LITTLEENDIAN 1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 622
diff changeset
17 #else
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 622
diff changeset
18 #define LITTLEENDIAN 0
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 622
diff changeset
19 #endif
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 SchedDefineTask(DrawSpan);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #define TEX_LOAD1 0
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 #define TEX_LOAD2 1
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 #define SPAN_PACK_LOAD 2
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 #define FB_STORE 3
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27
618
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
28 typedef struct {
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
29 int **linebuf;
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
30 float *zRow;
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
31 TileListPtr tileList;
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
32 int doneWrite;
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
33 } G, *Gptr;
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
34
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
35 static int** linebuf_init(SchedTask *smanager, int width, int height, int rgb);
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
36 static float* zRow_init(SchedTask *smanager, int width, int height);
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
37 // static TilePtr set_rgb(memaddr addr, int wait_tag);
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
38 // static void set_rgbs(memaddr addr, uint32 *max_addr, int wait_tag);
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
39 static uint32 get_rgb(int tx, int ty, TilePtr tile);
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
40 // static TilePtr isAvailableTile(memaddr addr);
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
41 static memaddr getTile(int tx, int ty, int tw, memaddr tex_addr_top);
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
42 static int getTexBlock(int tx, int ty, int twidth);
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
43
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
44 static void updateBuffer(Gptr g, float zpos, int rangex, int loaclx, int localy,
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
45 int tex_x, int tex_y, float normal_x, float nomral_x, float normal_z,
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
46 TilePtr tile, int world_x, int world_y, float world_z,SchedTask *smanager);
618
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
47
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
48 // static void reboot(SpanPackPtr spack, int cur_span_x);
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
49
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
50 static int drawDot1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag);
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
51 //static void drawDot2(SchedTask *smanager, SpanPtr span, int startx, int endx, int js, int wait_tag);
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
52 static int drawLine1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag);
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
53 // static void drawLine2(SchedTask *smanager, SpanPtr span, int startx, int endx, int js, int wait_tag);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
54
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
55 static int infinity_light_calc(int color,float normal_x, float normal_y, float normal_z,
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
56 SchedTask *smanager,int x, int y, float z, int world_x, int world_y, float world_z);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
57
618
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
58
774
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
59
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
60 static inline void
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
61 normalize(vector float& v0, vector float& v1)
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
62 {
774
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
63 float norm;
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
64 vector float ret __attribute__((aligned(16))) = {0,0,0,0};
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
65
774
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
66 ret = spu_mul(v0,v1);
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
67 norm = (ret[0] + ret[1] + ret[2]);
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
68
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
69 ret = (vector float)spu_splats(norm);
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
70 ret = spu_rsqrte(ret);
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
71 v0 = spu_mul(v1,ret);
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
72 }
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
73
774
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
74 static inline float
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
75 innerProduct1(vector float& v0, vector float& v1)
621
64e05530e333 Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
76 {
764
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 761
diff changeset
77
774
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
78 vector float ret __attribute__((aligned(16))) = {0,0,0,0};
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
79 float inner;
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
80 ret = spu_mul(v0,v1);
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
81
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
82 inner = (ret[0] + ret[1] + ret[2]);
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
83 if (inner < 0) {
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
84 inner = 0;
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
85 }
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
86
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
87 return inner;
621
64e05530e333 Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
88 }
64e05530e333 Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
89
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
90
764
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 761
diff changeset
91
774
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
92
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 * テクスチャは、TEXTURE_SPLIT_PIXEL^2 のブロックに分割する
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 * +---+---+---+---+---+---+
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 * | 0 | 1 | 2 | 3 | 4 | 5 |
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 * +---+---+---+---+---+---+
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 * | | | | | |11 |
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 * +---+---+---+---+---+---+
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 * | | | | | |17 |
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 * +---+---+---+---+---+---+
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 * | | | | | |23 |
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 * +---+---+---+---+---+---+
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 * | | | | | |29 |
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 * +---+---+---+---+---+---+
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 * | | | | | |35 |
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 * +---+---+---+---+---+---+
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 * 一辺を TEXTURE_SPLIT とする
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 * 各ブロックの数字がブロックIDとなる。
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
113
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 * テクスチャの座標から、
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 * テクスチャのどのブロックかを求める
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 * @param[in] tx X coordinates of texture
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 * @param[in] tx Y coordinates of texture
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 * @param[in] twidth Width of texture
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 * @return block ID
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 static int
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 getTexBlock(int tx, int ty, int twidth)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 int blockX, blockY;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
127
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 blockX = tx / TEXTURE_SPLIT_PIXEL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 blockY = ty / TEXTURE_SPLIT_PIXEL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
130
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 return blockX + (twidth/TEXTURE_SPLIT_PIXEL)*blockY;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
133
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 * block ID と、テクスチャの TOP address から
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 * (tx,ty) で使われるテクスチャの Tile addres を求める
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 * @param[in] tx X coordinates of texture
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 * @param[in] tx Y coordinates of texture
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 * @param[in] tw Width of texture
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 * @param[in] tex_addr_top (tx,ty) で使うテクスチャの先頭address
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 * @return block ID
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 static memaddr
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 getTile(int tx, int ty, int tw, memaddr tex_addr_top)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 int block = getTexBlock(tx, ty, tw);
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
148 return tex_addr_top + block * TEXTURE_BLOCK_SIZE * sizeof(uint32);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
150
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 * FrameBuffer に書き込む rgb の領域初期化
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 * @param width Width of Buffer
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 * @param height Height of Buffer
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 * @param rgb Initial value of RGB at Buffer
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 * @return Buffer
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 */
618
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
159 static int **
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 linebuf_init(SchedTask *smanager, int width, int height, int rgb)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 {
618
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
162 int **linebuf = (int**)smanager->allocate(height*sizeof(int*));
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
163 for(int h = 0;h<height;h++) {
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
164 int *buf = linebuf[h] = (int*)smanager->get_output(h);
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
165 for (int i = 0; i < width; i++) {
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
166 buf[i] = rgb;
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
167 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 }
618
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
169 return linebuf;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
171
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 * Z-Buffer の初期化
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 * @param width Width of Z-Buffer
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 * @param height Height of Z-Buffer
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 * @return Z-Buffer
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 static float*
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 zRow_init(SchedTask *smanager, int width, int height)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 float *buf = (float*)smanager->allocate(sizeof(float)*width*height);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 float def = 65535.0f;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
184
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
185 for (int i = 0; i < width*height; i++) {
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
186 buf[i] = def;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
188
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 return buf;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
191
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
192
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 static uint32
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 get_rgb(int tx, int ty, TilePtr tile)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 uint32 *data = (uint32 *)tile->data;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 return data[(TEXTURE_SPLIT_PIXEL)*ty+tx];
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
199
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
200
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
201
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 * zRow と Linebuf を更新する
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 * @param zpos 更新する pixel のZ座標
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 * @param rangex このタスクが処理する描画領域の x の長さ
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 * @param x pixel の、描画領域内での x 座標
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 * @param y 〃 の、y 座標
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 * @param tex_x pixel が使用するテクスチャの、Tile (8x8) 内での x 座標
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 * @param tex_y 〃 の y 座標
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 * @param tex_addr テクスチャのアドレス(MainMemory)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 static void
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
214 updateBuffer(Gptr g, float zpos, int rangex, int localx, int localy, int tex_x, int tex_y,
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
215 float normal_x, float normal_y, float normal_z, TilePtr tile,
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
216 int world_x, int world_y, float world_z, SchedTask *smanager)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 {
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
218
994
56c3b9dd37a7 SDL mode fix
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 914
diff changeset
219 uint32 color = get_rgb(tex_x, tex_y, tile);
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
220 /*下位4bitを抽出*/
623
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 622
diff changeset
221 #if LITTLEENDIAN
618
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
222 int alpha = color & 0x000000ff;
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
223 #else
599
9e288ef22377 change alpha
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 594
diff changeset
224 int alpha = color & 0xff000000;
618
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
225 #endif
994
56c3b9dd37a7 SDL mode fix
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 914
diff changeset
226
56c3b9dd37a7 SDL mode fix
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 914
diff changeset
227 //完全に透けているか判断
1054
ab16fc9a6570 light fix..?
Yutaka_Kinjyo
parents: 1050
diff changeset
228 int flag = (alpha != 0);
1123
2a63ba2c9506 bug fix.
yutaka@localhost.localdomain
parents: 1121
diff changeset
229
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
230 int *light_sysswitch = (int*)smanager->global_get(LightSysSwitch);
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
231 //smanager->printf("sys %d\n",light_sysswitch);
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
232
856
Yutaka_Kinjyo
parents: 855
diff changeset
233 if ( *light_sysswitch == 1 && flag) {
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
234 color = infinity_light_calc(color,normal_x,normal_y,normal_z,
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
235 smanager,localx,localy,zpos,
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
236 world_x,world_y,world_z);
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
237 }
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
238
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
239 g->zRow[localx + (rangex*localy)] = zpos*flag + g->zRow[localx + (rangex*localy)]*(1-flag);
994
56c3b9dd37a7 SDL mode fix
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 914
diff changeset
240 int *point = &g->linebuf[localy][localx];
618
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
241 *point = color*flag + *point *(1-flag);
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
242
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
244
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 * 長さが 1 の Span の描画 (要するに 1 pixel)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 * @param span Span
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 * @param startx 描画開始範囲
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 * @param endx 描画終了範囲
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 static int
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 drawDot1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 int rangex = endx - startx + 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
256
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
257 float normal_x = span->normal_x;
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
258 float normal_y = span->normal_y;
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
259 float normal_z = span->normal_z;
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
260
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
261
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 /* span->x に対応する Texture の座標 (tex_xpos, tex_ypos) */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 int tex_xpos, tex_ypos;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
264
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
265 // span の始点に対応する Texture の座標 (tex1, tey1)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
266 float tex = span->tex_x1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 float tey = span->tex_y1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
268
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 // span の始点に対応する z 座標
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 float zpos = span->start_z;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
271
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 /* Tile 内での座標 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 int localx = getLocalX(span->x-1);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 int localy = getLocalY(span->y-1);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
275
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
276 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
277 * (tex_xpos, tex_ypos) の、Tile 内(上の図参照)での座標と
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 * そのブロックのアドレス(MainMemory)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 int tex_localx;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 int tex_localy;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 memaddr tex_addr;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
283
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 if (span->x < startx || endx < span->x) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 return -1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
287
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 tex_xpos = (int)((span->tex_width-1) * tex);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 tex_ypos = (int)((span->tex_height-1) * tey);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
290
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 if (zpos < g->zRow[localx + (rangex*localy)]) {
1087
20f09564c586 fix (not yet tested)
root@localhost.localdomain
parents: 1067
diff changeset
292 if (!span->tex_addr) return -1; // broken case, I'd like to write some thing...
20f09564c586 fix (not yet tested)
root@localhost.localdomain
parents: 1067
diff changeset
293
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 tex_addr = getTile(tex_xpos, tex_ypos,
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 span->tex_width, (memaddr)span->tex_addr);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
298
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
299 TilePtr tile = smanager->get_segment(tex_addr,g->tileList);
1121
d6725e0a7b3e get_segment test.
tkaito@henri
parents: 1087
diff changeset
300 smanager->wait_segment(tile);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
301
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 updateBuffer(g, zpos, rangex, localx, localy,
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
303 tex_localx, tex_localy,
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
304 normal_x,normal_y,normal_z,tile,
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
305 span->x, span->y, zpos, smanager);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
306 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
307
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
308 return -1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
309 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
310
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
311 #if 0
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
312 static void
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
313 drawDot2(SchedTask *smanager, SpanPtr span, int startx, int end, int js, int wait_tag)
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
314 {
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
315 //printf("%d\n", js);
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
316 }
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
317 #endif
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
318
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
319 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 * 長さが 1 より大きい Span の描画
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
321 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
322 * 本来の目的として、この関数(drawLine1) では
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
323 * : 既に SPE 上に Tile のある pixel だけ描画
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
324 * : それ以外は、ここで予め DMA load しておき、
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
325 * : drawLine2 で一気に描画する
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
326 * ってものだったんだけど、どうも上手く行かなかったので
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
327 * 今は drawLine1 で load -> wait -> rendering を全部やってます
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
328 * (rendering といっても、rendering buffer に書き込むだけで
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
329 * まだ main memory (frame buffer) に dma store してるわけではない)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
330 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
331 * @param span Span
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
332 * @param startx 描画開始範囲
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
333 * @param endx 描画終了範囲
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
334 * @return 「span のどの位置まで rendering が終わったか」の x 座標
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
335 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
336 static int
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
337 drawLine1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
338 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
339 int x = span->x;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
340 int rangex = endx - startx + 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
341 int x_len = span->length_x;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
342
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
343 float normal_x = span->normal_x;
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
344 float normal_y = span->normal_y;
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
345 float normal_z = span->normal_z;
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
346
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
347
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
348 int js = (x < startx) ? startx - x : 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
349 int je = (x + x_len > endx) ? endx - x : x_len;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
350
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
351 /* span->x に対応する Texture の座標 (tex_xpos, tex_ypos) */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
352 int tex_xpos, tex_ypos;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
353
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 // span の始点に対応する座標 (tex1, tey1)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
355 float tex1 = span->tex_x1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
356 float tey1 = span->tex_y1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
357
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
358 // span の終点に対応する座標 (tex2, tey2)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
359 float tex2 = span->tex_x2;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
360 float tey2 = span->tex_y2;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
361
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
362 // span の始点、終点に対応する z 座標
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
363 float zpos1 = span->start_z;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
364 float zpos2 = span->end_z;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
365
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
366 //spanを右から左に見ていくうちに、zが下がるのか、上がっていくのか。
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
367 float z_inclination = (zpos2 - zpos1) / x_len;
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
368 float world_z = zpos2;
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
369
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
370 // Tile 内での座標
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
371 int localx, localy = getLocalY(span->y-1);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
372
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
373 int ret = je+1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
374
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
375 //for (int j = js; j <= je; j++) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
376 for (int j = je; j >= js; j--) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
377 float tex_x, tex_y, tex_z;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
378
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
379 world_z -= z_inclination;
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
380
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
381 localx = getLocalX(x-1+j);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
382
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
383 tex_z = zpos1*(x_len-1-j)/(x_len-1) + zpos2*j/(x_len-1);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
384
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
386 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
387 if (tex_x > 1) tex_x = 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
388 if (tex_x < 0) tex_x = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
389 if (tex_y > 1) tex_y = 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
390 if (tex_y < 0) tex_y = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
391 tex_xpos = (int)((span->tex_width-1) * tex_x);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 tex_ypos = (int)((span->tex_height-1) * tex_y);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
393
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
394 if (tex_z < g->zRow[localx + (rangex*localy)]) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
395 // (tex_xpos, tex_ypos) の、Tile 内(上の図参照)での座標と
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
396 // そのブロックのアドレス(MainMemory)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
397 memaddr tex_addr;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
398 int tex_localx;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
399 int tex_localy;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
400
1087
20f09564c586 fix (not yet tested)
root@localhost.localdomain
parents: 1067
diff changeset
401 if (!span->tex_addr) return -1; // broken case, I'd like to write some thing...
20f09564c586 fix (not yet tested)
root@localhost.localdomain
parents: 1067
diff changeset
402 tex_addr = getTile(tex_xpos, tex_ypos,
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
403 span->tex_width, (memaddr)span->tex_addr);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
404 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
405 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
406 TilePtr tile = smanager->get_segment(tex_addr,g->tileList);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
407 smanager->wait_segment(tile);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
408
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
409 updateBuffer(g, tex_z, rangex, localx, localy,
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
410 tex_localx, tex_localy,
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
411 normal_x, normal_y, normal_z, tile,
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
412 span->x+j, span->y, world_z, smanager);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
413 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
415
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
416 return ret;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
417 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
418
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
419 static int
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
420 infinity_light_calc(int color,float normal_x, float normal_y,
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
421 float normal_z, SchedTask *smanager, int x, int y, float z,
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
422 int world_x, int world_y, float world_z)
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 650
diff changeset
423
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
424 {
764
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 761
diff changeset
425
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
426 unsigned char rgb[4];
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
427
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
428 // 引数で受け取った color の rgb 情報の抜き出し
623
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 622
diff changeset
429 #if LITTLEENDIAN
618
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
430 rgb[0] = (color & 0xff000000) >> 24;
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
431 rgb[1] = (color & 0x00ff0000) >> 16;
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
432 rgb[2] = (color & 0x0000ff00) >> 8;
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
433 rgb[3] = (color & 0x000000ff);
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
434 #else
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
435 rgb[3] = (color & 0xff000000) >> 24;
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
436 rgb[2] = (color & 0x00ff0000) >> 16;
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
437 rgb[1] = (color & 0x0000ff00) >> 8;
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
438 rgb[0] = (color & 0x000000ff);
618
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
439 #endif
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
440
764
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 761
diff changeset
441
774
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
442 vector float *light_xyz = (vector float*)smanager->global_get(Light);
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
443
764
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 761
diff changeset
444 vector float v_rgb __attribute__((aligned(16))) = {(float)rgb[0],(float)rgb[1],(float)rgb[2],0};
774
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
445 vector float normal_vector __attribute__((aligned(16))) = {normal_x,normal_y,normal_z,0};
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
446 vector float light_vector __attribute__((aligned(16))) = {0,0,0,0};
764
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 761
diff changeset
447 vector float v_inner __attribute__((aligned(16)));
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 761
diff changeset
448 vector float v_world[4] __attribute__((aligned(16))) = {{world_x, world_y, -world_z, 0},
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 761
diff changeset
449 {world_x, world_y, -world_z, 0},
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 761
diff changeset
450 {world_x, world_y, -world_z, 0},
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
451 {world_x, world_y, -world_z, 0}};
764
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 761
diff changeset
452
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 761
diff changeset
453
774
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
454 int light_rgb;
1144
e068c1269292 light fix
Yutaka_Kinjyo
parents: 1123
diff changeset
455 float inner_product = 0.2;
764
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 761
diff changeset
456
774
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
457 normalize(normal_vector, normal_vector);
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
458
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
459 vector float vtmp_rgb __attribute__((aligned(16))) = {0,0,0,0};
764
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 761
diff changeset
460
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
461 int light_num = 4;
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
462 int *light_switch = (int*)smanager->global_get(LightSwitch);
764
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 761
diff changeset
463
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
464 for (int i = 0; i < light_num; i++) {
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
465
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
466 if (light_switch[i] == 1) {
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
467 light_vector = spu_sub(v_world[i],light_xyz[i]);
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
468 normalize(light_vector, light_vector);
1144
e068c1269292 light fix
Yutaka_Kinjyo
parents: 1123
diff changeset
469 float tmp_inner_product = innerProduct1(normal_vector,light_vector);
e068c1269292 light fix
Yutaka_Kinjyo
parents: 1123
diff changeset
470
e068c1269292 light fix
Yutaka_Kinjyo
parents: 1123
diff changeset
471 if (inner_product < tmp_inner_product) {
e068c1269292 light fix
Yutaka_Kinjyo
parents: 1123
diff changeset
472 inner_product = tmp_inner_product;
e068c1269292 light fix
Yutaka_Kinjyo
parents: 1123
diff changeset
473 }
e068c1269292 light fix
Yutaka_Kinjyo
parents: 1123
diff changeset
474
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
475 v_inner = spu_splats(inner_product);
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
476 vtmp_rgb = spu_madd(v_rgb,v_inner,vtmp_rgb);
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
477 }
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
478
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
479 }
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
480
764
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 761
diff changeset
481 vector unsigned int v_flag __attribute__((aligned(16)));
774
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
482 vector float max_rgb __attribute__((aligned(16))) = (vector float)spu_splats((float)255.0f);
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
483
774
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
484 v_flag = spu_cmpgt(max_rgb,vtmp_rgb);
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
485 vtmp_rgb = spu_sel(max_rgb,vtmp_rgb,v_flag);
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
486
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
487 vector unsigned int last_rgb __attribute__((aligned(16)));
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 764
diff changeset
488 last_rgb = spu_convtu(vtmp_rgb,0);
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
489
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
490
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
491 //計算した rgb を light_rgb にまとめる。
623
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 622
diff changeset
492 #if LITTLEENDIAN
764
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 761
diff changeset
493 light_rgb = (last_rgb[0] << 24) + (last_rgb[1] << 16) + (last_rgb[2] << 8) + (last_rgb[3]);
618
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
494 #else
764
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 761
diff changeset
495 light_rgb = (last_rgb[3] << 24) + (last_rgb[2] << 16) + (last_rgb[1] << 8) + (last_rgb[0]);
618
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
496 #endif
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
497
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
498 return light_rgb;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
499 }
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
500
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
501
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
502 static int
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
503 run(SchedTask *smanager, void *rbuf, void *wbuf)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
504 {
838
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
505
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
506 if ((int)smanager->get_param(5) == 0) {
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
507
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
508 int rangex_start = (long)smanager->get_param(2);
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
509 int rangex_end = (long)smanager->get_param(3);
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
510
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
511 int rangex = rangex_end - rangex_start + 1;
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
512 int rangey = (long)smanager->get_param(4);
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
513
914
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 860
diff changeset
514 for(int h = 0; h < rangey; h++) {
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 860
diff changeset
515 int *buf = (int*)smanager->get_output(h);
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 860
diff changeset
516 for (int i = 0; i < rangex; i++) {
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 860
diff changeset
517 buf[i] = 0;
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 860
diff changeset
518 }
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 860
diff changeset
519 }
838
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
520
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
521 return 0;
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
522
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
523 }
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
524
623
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 622
diff changeset
525 G g0;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 622
diff changeset
526 Gptr g = &g0;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
527
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
528 SpanPackPtr spack = (SpanPackPtr)smanager->get_input(0);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
529 SpanPackPtr next_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack));
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
530 SpanPackPtr free_spack = next_spack; // next_spack の free() 用
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
531 Span *span;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
532
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
533 Span nop_span;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
534 nop_span.length_x = 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
535
626
0e91ddaad798 64bit mode compatibility on Cell
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 623
diff changeset
536 // uint32 display = (long)smanager->get_param(0);
0e91ddaad798 64bit mode compatibility on Cell
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 623
diff changeset
537 // int screen_width = (long)smanager->get_param(1);
0e91ddaad798 64bit mode compatibility on Cell
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 623
diff changeset
538 int rangex_start = (long)smanager->get_param(2);
0e91ddaad798 64bit mode compatibility on Cell
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 623
diff changeset
539 int rangex_end = (long)smanager->get_param(3);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
540
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
541 // このタスクが担当する x の範囲
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
542 int rangex = rangex_end - rangex_start + 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
543
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
544 // y の範囲
626
0e91ddaad798 64bit mode compatibility on Cell
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 623
diff changeset
545 int rangey = (long)smanager->get_param(4);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
546 g->tileList = (TileListPtr)smanager->global_get(GLOBAL_TILE_LIST);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
547
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
548 g->zRow = zRow_init(smanager, rangex, rangey);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
549 g->linebuf = linebuf_init(smanager, rangex, rangey, 0);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
550
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
551 int tl_tag[2] = {TEX_LOAD1, TEX_LOAD2};
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
552 int tl_tag_flg1 = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
553 int tl_tag_flg2 = 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
554
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
555 do {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
556 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
557 * SpanPack->next が存在する場合、
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
558 * 現在の SpanPack を処理してる間に
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
559 * 次の SpanPack の DMA 転送を行う
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
560 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
561 if (spack->next != NULL) {
618
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
562 smanager->dma_load(next_spack, (memaddr)spack->next,
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
563 sizeof(SpanPack), SPAN_PACK_LOAD);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
564 } else {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
565 next_spack = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
566 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
567
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
568 SpanPtr resume_span = &nop_span;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
569
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
570 for (int t = 0; t < spack->info.size; t++) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
571 SpanPtr next_span;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
572
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
573 span = &spack->span[t];
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
574
622
911050e9f99d remove non relocatable funcion call.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
575 if (span->length_x != 1) {
994
56c3b9dd37a7 SDL mode fix
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 914
diff changeset
576 drawLine1(
56c3b9dd37a7 SDL mode fix
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 914
diff changeset
577 smanager, g,
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
578 span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]);
622
911050e9f99d remove non relocatable funcion call.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
579 } else {
994
56c3b9dd37a7 SDL mode fix
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 914
diff changeset
580 drawDot1(
56c3b9dd37a7 SDL mode fix
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 914
diff changeset
581 smanager, g,
56c3b9dd37a7 SDL mode fix
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 914
diff changeset
582 span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]);
622
911050e9f99d remove non relocatable funcion call.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
583 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
584 next_span = span;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
585
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
586 resume_span = next_span;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
587
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
588 tl_tag_flg1 ^= 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
589 tl_tag_flg2 ^= 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
590 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
591
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
592 smanager->dma_wait(SPAN_PACK_LOAD);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
593
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
594 SpanPackPtr tmp_spack = spack;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
595 spack = next_spack;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
596 next_spack = tmp_spack;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
597 } while (spack);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
598
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
599
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
600 free(g->zRow);
618
58417006268c worked. Cell fix. (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
601 free(g->linebuf);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
602
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
603 //FINISH:
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
604 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
605 * goto FINISH; の時は reboot なので
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
606 * linebuf, zRow は free() しない
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
607 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
608
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
609 free(free_spack);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
610
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
611
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
612 return 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
613 }
594
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
614
43579f972263 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
615 /* end */