annotate Renderer/Engine/spe/DrawSpan.cc @ 614:4e44147d78ee

remove uncessary Task Name definision
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Nov 2009 18:21:14 +0900
parents e923249c318a
children 360032cc500e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <stdlib.h>
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <string.h>
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include "DrawSpan.h"
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include "polygon_pack.h"
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 #include "texture.h"
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 #include "viewer_types.h"
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 #include "Func.h"
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
8 #include "sys.h"
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 #include "global_alloc.h"
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 SchedDefineTask(DrawSpan);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 SchedDefineTask1(DrawSpanEnd,draw_span_end);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 #define TEX_LOAD1 0
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 #define TEX_LOAD2 1
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 #define SPAN_PACK_LOAD 2
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 #define FB_STORE 3
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 static int
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 draw_span_end(SchedTask *s, void *rbuf, void *wbuf)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 Gptr g = (Gptr)s->get_param(0);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 s->dma_wait(FB_STORE);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 free((void*)((int)g->linebuf*g->doneWrite));
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 free(g);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 return 0;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 /**
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 * テクスチャは、TEXTURE_SPLIT_PIXEL^2 のブロックに分割する
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 *
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 * +---+---+---+---+---+---+
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 * | 0 | 1 | 2 | 3 | 4 | 5 |
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 * +---+---+---+---+---+---+
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 * | | | | | |11 |
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 * +---+---+---+---+---+---+
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 * | | | | | |17 |
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 * +---+---+---+---+---+---+
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 * | | | | | |23 |
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 * +---+---+---+---+---+---+
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 * | | | | | |29 |
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 * +---+---+---+---+---+---+
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 * | | | | | |35 |
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 * +---+---+---+---+---+---+
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 *
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 * 一辺を TEXTURE_SPLIT とする
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 * 各ブロックの数字がブロックIDとなる。
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 */
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 /**
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 * テクスチャの座標から、
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 * テクスチャのどのブロックかを求める
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 *
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 * @param[in] tx X coordinates of texture
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 * @param[in] tx Y coordinates of texture
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 * @param[in] twidth Width of texture
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 * @return block ID
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 */
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 static int
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 getTexBlock(int tx, int ty, int twidth)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 int blockX, blockY;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 blockX = tx / TEXTURE_SPLIT_PIXEL;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 blockY = ty / TEXTURE_SPLIT_PIXEL;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 return blockX + (twidth/TEXTURE_SPLIT_PIXEL)*blockY;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 /**
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 * block ID と、テクスチャの TOP address から
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 * (tx,ty) で使われるテクスチャの Tile addres を求める
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 *
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 * @param[in] tx X coordinates of texture
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 * @param[in] tx Y coordinates of texture
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 * @param[in] tw Width of texture
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 * @param[in] tex_addr_top (tx,ty) で使うテクスチャの先頭address
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 * @return block ID
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 */
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 static memaddr
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 getTile(int tx, int ty, int tw, memaddr tex_addr_top)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 int block = getTexBlock(tx, ty, tw);
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
84 return tex_addr_top + block * TEXTURE_BLOCK_SIZE * sizeof(uint32);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 /**
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 * FrameBuffer に書き込む rgb の領域初期化
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 *
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 * @param width Width of Buffer
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 * @param height Height of Buffer
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 * @param rgb Initial value of RGB at Buffer
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 * @return Buffer
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 */
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 static int*
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 linebuf_init(SchedTask *smanager, int width, int height, int rgb)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 int *buf = (int*)smanager->allocate(sizeof(int)*width*height);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 for (int i = 0; i < width*height; i++) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 buf[i] = rgb;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 return buf;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 /**
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 * Z-Buffer の初期化
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 *
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 * @param width Width of Z-Buffer
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 * @param height Height of Z-Buffer
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 * @return Z-Buffer
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 */
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 static float*
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 zRow_init(SchedTask *smanager, int width, int height)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 float *buf = (float*)smanager->allocate(sizeof(float)*width*height);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 float def = 65535.0f;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
119
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
120 for (int i = 0; i < width*height; i++) {
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
121 buf[i] = def;
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
123
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 return buf;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
127
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 static uint32
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 get_rgb(int tx, int ty, TilePtr tile)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 uint32 *data = (uint32 *)tile->data;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 return data[(TEXTURE_SPLIT_PIXEL)*ty+tx];
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
134
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
135
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 static void
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 writebuffer(SchedTask *smanager, Gptr g, unsigned int display,
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
138 int buf_width, int height, int screen_width)
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 for (int i = 0; i < height; i++) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 smanager->dma_store(&g->linebuf[i*buf_width],
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 display + (sizeof(int)*screen_width*i),
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 sizeof(int)*buf_width, FB_STORE);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
145
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 g->doneWrite = 1;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
148
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 /**
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 * zRow と Linebuf を更新する
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 *
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 * @param zpos 更新する pixel のZ座標
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 * @param rangex このタスクが処理する描画領域の x の長さ
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 * @param x pixel の、描画領域内での x 座標
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 * @param y 〃 の、y 座標
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 * @param tex_x pixel が使用するテクスチャの、Tile (8x8) 内での x 座標
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 * @param tex_y 〃 の y 座標
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 * @param tex_addr テクスチャのアドレス(MainMemory)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 */
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 static void
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
161 updateBuffer(Gptr g, float zpos, int rangex, int x, int y, int tex_x, int tex_y,
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
162 float normal_x, float normal_y, float normal_z, TilePtr tile)
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 {
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
164
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
165
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
166 int color = get_rgb(tex_x, tex_y, tile);
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
167 /*下位4bitを抽出*/
599
e923249c318a change alpha
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 594
diff changeset
168 int alpha = color & 0xff000000;
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
169 /*完全に透けているか判断*/
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
170 int flag = (alpha != 0);
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
171
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
172 color = infinity_light_calc(color,normal_x,normal_y,normal_z);
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
173
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
174 g->zRow[x + (rangex*y)] = zpos*flag + g->zRow[x + (rangex*y)]*(1-flag);
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
175 g->linebuf[x + (rangex*y)] = color*flag + g->linebuf[x + (rangex*y)]*(1-flag);
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
176
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
178
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 /**
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 * 長さが 1 の Span の描画 (要するに 1 pixel)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 *
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 * @param span Span
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 * @param startx 描画開始範囲
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 * @param endx 描画終了範囲
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 */
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 static int
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 drawDot1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 int rangex = endx - startx + 1;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
190
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
191 float normal_x = span->normal_x;
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
192 float normal_y = span->normal_y;
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
193 float normal_z = span->normal_z;
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
194
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
195
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 /* span->x に対応する Texture の座標 (tex_xpos, tex_ypos) */
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 int tex_xpos, tex_ypos;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
198
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 // span の始点に対応する Texture の座標 (tex1, tey1)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 float tex = span->tex_x1;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 float tey = span->tex_y1;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
202
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 // span の始点に対応する z 座標
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 float zpos = span->start_z;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
205
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 /* Tile 内での座標 */
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 int localx = getLocalX(span->x-1);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 int localy = getLocalY(span->y-1);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
209
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 /**
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 * (tex_xpos, tex_ypos) の、Tile 内(上の図参照)での座標と
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 * そのブロックのアドレス(MainMemory)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 */
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
214 int tex_localx;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 int tex_localy;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 memaddr tex_addr;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
217
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
218 if (span->x < startx || endx < span->x) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 return -1;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
221
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 tex_xpos = (int)((span->tex_width-1) * tex);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 tex_ypos = (int)((span->tex_height-1) * tey);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
224
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 if (zpos < g->zRow[localx + (rangex*localy)]) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
226 tex_addr = getTile(tex_xpos, tex_ypos,
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 span->tex_width, (memaddr)span->tex_addr);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
230
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
231 TilePtr tile = smanager->get_segment(tex_addr,g->tileList);
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
232 smanager->wait_segment(tile);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
233
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 updateBuffer(g, zpos, rangex, localx, localy,
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
235 tex_localx, tex_localy,
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
236 normal_x,normal_y,normal_z,tile);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
238
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 return -1;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
241
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
242 #if 0
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
243 static void
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
244 drawDot2(SchedTask *smanager, SpanPtr span, int startx, int end, int js, int wait_tag)
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
245 {
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
246 //printf("%d\n", js);
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
247 }
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
248 #endif
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
249
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 /**
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 * 長さが 1 より大きい Span の描画
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 *
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 * 本来の目的として、この関数(drawLine1) では
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 * : 既に SPE 上に Tile のある pixel だけ描画
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 * : それ以外は、ここで予め DMA load しておき、
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
256 * : drawLine2 で一気に描画する
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 * ってものだったんだけど、どうも上手く行かなかったので
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 * 今は drawLine1 で load -> wait -> rendering を全部やってます
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 * (rendering といっても、rendering buffer に書き込むだけで
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 * まだ main memory (frame buffer) に dma store してるわけではない)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 *
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 * @param span Span
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 * @param startx 描画開始範囲
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 * @param endx 描画終了範囲
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
265 * @return 「span のどの位置まで rendering が終わったか」の x 座標
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
266 */
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 static int
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 drawLine1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 int x = span->x;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 int rangex = endx - startx + 1;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 int x_len = span->length_x;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
273
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
274 float normal_x = span->normal_x;
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
275 float normal_y = span->normal_y;
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
276 float normal_z = span->normal_z;
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
277
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
278
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 int js = (x < startx) ? startx - x : 0;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 int je = (x + x_len > endx) ? endx - x : x_len;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
281
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 /* span->x に対応する Texture の座標 (tex_xpos, tex_ypos) */
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
283 int tex_xpos, tex_ypos;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
284
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 // span の始点に対応する座標 (tex1, tey1)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 float tex1 = span->tex_x1;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 float tey1 = span->tex_y1;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
288
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 // span の終点に対応する座標 (tex2, tey2)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 float tex2 = span->tex_x2;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 float tey2 = span->tex_y2;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
292
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 // span の始点、終点に対応する z 座標
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 float zpos1 = span->start_z;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 float zpos2 = span->end_z;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
296
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 // Tile 内での座標
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 int localx, localy = getLocalY(span->y-1);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
299
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 int ret = je+1;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
301
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 //for (int j = js; j <= je; j++) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 for (int j = je; j >= js; j--) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 float tex_x, tex_y, tex_z;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
305
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
306 localx = getLocalX(x-1+j);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
307
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
308 tex_z = zpos1*(x_len-1-j)/(x_len-1) + zpos2*j/(x_len-1);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
309
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
310 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
311 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 if (tex_x > 1) tex_x = 1;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
313 if (tex_x < 0) tex_x = 0;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
314 if (tex_y > 1) tex_y = 1;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
315 if (tex_y < 0) tex_y = 0;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
316 tex_xpos = (int)((span->tex_width-1) * tex_x);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
317 tex_ypos = (int)((span->tex_height-1) * tex_y);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
318
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
319 if (tex_z < g->zRow[localx + (rangex*localy)]) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 // (tex_xpos, tex_ypos) の、Tile 内(上の図参照)での座標と
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
321 // そのブロックのアドレス(MainMemory)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
322 memaddr tex_addr;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
323 int tex_localx;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
324 int tex_localy;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
325
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
326 tex_addr = getTile(tex_xpos, tex_ypos,
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
327 span->tex_width, (memaddr)span->tex_addr);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
328 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
329 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
330 TilePtr tile = smanager->get_segment(tex_addr,g->tileList);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
331 smanager->wait_segment(tile);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
332
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
333 updateBuffer(g, tex_z, rangex, localx, localy,
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
334 tex_localx, tex_localy,
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
335 normal_x, normal_y, normal_z, tile);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
336 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
337 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
338
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
339 return ret;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
340 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
341
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
342 float
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
343 innerProduct(float *v0, float *v1)
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
344 {
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
345 return (v0[0]*v1[0] + v0[1]*v1[1] + v0[2]*v1[2]);
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
346 }
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
347
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
348 static int
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
349 infinity_light_calc(int color,float normal_x, float normal_y, float normal_z)
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
350 {
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
351 unsigned char rgb[4];
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
352 int light_rgb;
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
353 int flag;
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
354 float normal_vector[4] = {normal_x,normal_y,normal_z,0};
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
355 // 光のベクトル,きめうちしちゃった。どうにかする
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
356 float light_vector[4] = {0,0,-1,0};
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
357 float inner_product;
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
358
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
359 // 引数で受け取った color の rgb 情報の抜き出し
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
360 rgb[3] = (color & 0xff000000) >> 24;
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
361 rgb[2] = (color & 0x00ff0000) >> 16;
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
362 rgb[1] = (color & 0x0000ff00) >> 8;
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
363 rgb[0] = (color & 0x000000ff);
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
364
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
365 // 法線ベクトルと光源ベクトルとの内積をとる
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
366 inner_product = innerProduct(normal_vector,light_vector);
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
367 // 内積がマイナスの場合は色がない。
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
368 flag = (inner_product > 0);
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
369
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
370 // 内積を rgb にかけていく
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
371 rgb[0] = (unsigned char)(rgb[0]*inner_product*flag);
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
372 rgb[1] = (unsigned char)(rgb[1]*inner_product*flag);
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
373 rgb[2] = (unsigned char)(rgb[2]*inner_product*flag);
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
374
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
375 //計算した rgb を light_rgb にまとめる。
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
376 light_rgb = (rgb[3] << 24) + (rgb[2] << 16) + (rgb[1] << 8) + (rgb[0]);
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
377
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
378 return light_rgb;
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
379 }
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
380
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
381
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
382 static int
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
383 run(SchedTask *smanager, void *rbuf, void *wbuf)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
384 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 Gptr g = (Gptr)smanager->allocate(sizeof(G));
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
386
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
387 SpanPackPtr spack = (SpanPackPtr)smanager->get_input(0);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
388 SpanPackPtr next_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack));
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
389 SpanPackPtr free_spack = next_spack; // next_spack の free() 用
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
390 Span *span;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
391
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 Span nop_span;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
393 nop_span.length_x = 1;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
394
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
395 int (*drawFunc1[2])(SchedTask *, Gptr, SpanPtr, int, int, int) = {
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
396 &drawDot1, &drawLine1
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
397 };
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
398
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
399 uint32 display = smanager->get_param(0);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
400 int screen_width = smanager->get_param(1);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
401 int rangex_start = smanager->get_param(2);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
402 int rangex_end = smanager->get_param(3);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
403
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
404 // このタスクが担当する x の範囲
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
405 int rangex = rangex_end - rangex_start + 1;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
406
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
407 // y の範囲
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 int rangey = smanager->get_param(4);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
409 g->tileList = (TileListPtr)smanager->global_get(GLOBAL_TILE_LIST);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
410
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
411 g->zRow = zRow_init(smanager, rangex, rangey);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
412 //linebuf = linebuf_init(rangex, rangey, 0x00ffffff);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
413 g->linebuf = linebuf_init(smanager, rangex, rangey, 0);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
414
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
415 g->doneWrite = 0;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
416
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
417 int tl_tag[2] = {TEX_LOAD1, TEX_LOAD2};
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
418 int tl_tag_flg1 = 0;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
419 int tl_tag_flg2 = 1;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
420
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
421 do {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
422 /**
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
423 * SpanPack->next が存在する場合、
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
424 * 現在の SpanPack を処理してる間に
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
425 * 次の SpanPack の DMA 転送を行う
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
426 */
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
427 if (spack->next != NULL) {
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
428 smanager->dma_load(next_spack, (uint32)spack->next,
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
429 sizeof(SpanPack), SPAN_PACK_LOAD);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
430 } else {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
431 next_spack = NULL;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
432 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
433
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
434 SpanPtr resume_span = &nop_span;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
435 int resume_span_x = 0;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
436
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
437 for (int t = 0; t < spack->info.size; t++) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
438 SpanPtr next_span;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
439 int next_span_x;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
440
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
441 span = &spack->span[t];
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
442
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
443 /**
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
444 * span の長さによって、drawLine か drawDot を選択している
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
445 */
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
446 next_span_x
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
447 = (*drawFunc1[(span->length_x != 1)])(
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
448 smanager, g,
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
449 span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
450 next_span = span;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
451
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
452 resume_span = next_span;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
453 resume_span_x = next_span_x;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
454
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
455 //smanager->dma_wait(tl_tag[tl_tag_flg1]);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
456
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
457 tl_tag_flg1 ^= 1;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
458 tl_tag_flg2 ^= 1;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
459 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
460
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
461 // 現在 drawLine2、drawDot2 は機能してないので
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
462 //(this->*drawFunc2[(resume_span->length_x != 1)])(
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
463 //resume_span, rangex_start, rangex_end, resume_span_x,
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
464 //tl_tag[tl_tag_flg1]);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
465
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
466 smanager->dma_wait(SPAN_PACK_LOAD);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
467
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
468 SpanPackPtr tmp_spack = spack;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
469 spack = next_spack;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
470 next_spack = tmp_spack;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
471 } while (spack);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
472
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
473 writebuffer(smanager, g, display, rangex, rangey, screen_width);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
474
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
475 // linebuf は、writebuffer() の dma_store を wait する
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
476 // DrawSpan::~DrawSpan() 内で free する。
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
477 //free(linebuf);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
478 free(g->zRow);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
479
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
480 //FINISH:
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
481 /**
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
482 * goto FINISH; の時は reboot なので
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
483 * linebuf, zRow は free() しない
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
484 */
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
485
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
486 free(free_spack);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
487
614
4e44147d78ee remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 599
diff changeset
488 TaskPtr nextTask = smanager->create_task(DrawSpanEnd);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
489 nextTask->add_param((int)g);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
490 smanager->wait_task(nextTask);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
491
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
492 return 0;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
493 }
594
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
494
20166ecb1a78 add light
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
495 /* end */