Mercurial > hg > Members > kono > Cerium
comparison Renderer/Engine/task/DrawSpan.cc @ 623:f35a9bee38a6
endian
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 15 Nov 2009 04:16:35 +0900 |
parents | 6a5e88112ed9 |
children | 60aa3f241b10 |
comparison
equal
deleted
inserted
replaced
622:6a5e88112ed9 | 623:f35a9bee38a6 |
---|---|
9 #include "global_alloc.h" | 9 #include "global_alloc.h" |
10 #include "SchedTask.h" | 10 #include "SchedTask.h" |
11 #include "Tapestry.h" | 11 #include "Tapestry.h" |
12 #include "SpanPack.h" | 12 #include "SpanPack.h" |
13 | 13 |
14 #define BIGENDIAN 1 | 14 #if (__LITTLE_ENDIAN__) |
15 #define LITTLEENDIAN 1 | |
16 #else | |
17 #define LITTLEENDIAN 0 | |
18 #endif | |
15 | 19 |
16 SchedDefineTask(DrawSpan); | 20 SchedDefineTask(DrawSpan); |
17 | 21 |
18 #define TEX_LOAD1 0 | 22 #define TEX_LOAD1 0 |
19 #define TEX_LOAD2 1 | 23 #define TEX_LOAD2 1 |
179 float normal_x, float normal_y, float normal_z, TilePtr tile) | 183 float normal_x, float normal_y, float normal_z, TilePtr tile) |
180 { | 184 { |
181 | 185 |
182 int color = get_rgb(tex_x, tex_y, tile); | 186 int color = get_rgb(tex_x, tex_y, tile); |
183 /*下位4bitを抽出*/ | 187 /*下位4bitを抽出*/ |
184 #if BIGENDIAN | 188 #if LITTLEENDIAN |
185 int alpha = color & 0x000000ff; | 189 int alpha = color & 0x000000ff; |
186 #else | 190 #else |
187 int alpha = color & 0xff000000; | 191 int alpha = color & 0xff000000; |
188 #endif | 192 #endif |
189 /*完全に透けているか判断*/ | 193 /*完全に透けているか判断*/ |
370 // 光のベクトル,きめうちしちゃった。どうにかする | 374 // 光のベクトル,きめうちしちゃった。どうにかする |
371 float light_vector[4] = {0,0,-1,0}; | 375 float light_vector[4] = {0,0,-1,0}; |
372 float inner_product; | 376 float inner_product; |
373 | 377 |
374 // 引数で受け取った color の rgb 情報の抜き出し | 378 // 引数で受け取った color の rgb 情報の抜き出し |
375 #if BIGENDIAN | 379 #if LITTLEENDIAN |
376 rgb[0] = (color & 0xff000000) >> 24; | 380 rgb[0] = (color & 0xff000000) >> 24; |
377 rgb[1] = (color & 0x00ff0000) >> 16; | 381 rgb[1] = (color & 0x00ff0000) >> 16; |
378 rgb[2] = (color & 0x0000ff00) >> 8; | 382 rgb[2] = (color & 0x0000ff00) >> 8; |
379 rgb[3] = (color & 0x000000ff); | 383 rgb[3] = (color & 0x000000ff); |
380 #else | 384 #else |
393 rgb[0] = (unsigned char)(rgb[0]*inner_product*flag); | 397 rgb[0] = (unsigned char)(rgb[0]*inner_product*flag); |
394 rgb[1] = (unsigned char)(rgb[1]*inner_product*flag); | 398 rgb[1] = (unsigned char)(rgb[1]*inner_product*flag); |
395 rgb[2] = (unsigned char)(rgb[2]*inner_product*flag); | 399 rgb[2] = (unsigned char)(rgb[2]*inner_product*flag); |
396 | 400 |
397 //計算した rgb を light_rgb にまとめる。 | 401 //計算した rgb を light_rgb にまとめる。 |
398 #if BIGENDIAN | 402 #if LITTLEENDIAN |
399 light_rgb = (rgb[0] << 24) + (rgb[1] << 16) + (rgb[2] << 8) + (rgb[3]); | 403 light_rgb = (rgb[0] << 24) + (rgb[1] << 16) + (rgb[2] << 8) + (rgb[3]); |
400 #else | 404 #else |
401 light_rgb = (rgb[3] << 24) + (rgb[2] << 16) + (rgb[1] << 8) + (rgb[0]); | 405 light_rgb = (rgb[3] << 24) + (rgb[2] << 16) + (rgb[1] << 8) + (rgb[0]); |
402 #endif | 406 #endif |
403 | 407 |
406 | 410 |
407 | 411 |
408 static int | 412 static int |
409 run(SchedTask *smanager, void *rbuf, void *wbuf) | 413 run(SchedTask *smanager, void *rbuf, void *wbuf) |
410 { | 414 { |
411 Gptr g = (Gptr)smanager->allocate(sizeof(G)); | 415 G g0; |
416 Gptr g = &g0; | |
412 | 417 |
413 SpanPackPtr spack = (SpanPackPtr)smanager->get_input(0); | 418 SpanPackPtr spack = (SpanPackPtr)smanager->get_input(0); |
414 SpanPackPtr next_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack)); | 419 SpanPackPtr next_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack)); |
415 SpanPackPtr free_spack = next_spack; // next_spack の free() 用 | 420 SpanPackPtr free_spack = next_spack; // next_spack の free() 用 |
416 Span *span; | 421 Span *span; |
417 | 422 |
418 Span nop_span; | 423 Span nop_span; |
419 nop_span.length_x = 1; | 424 nop_span.length_x = 1; |
420 | |
421 int (*drawFunc1[2])(SchedTask *, Gptr, SpanPtr, int, int, int) = { | |
422 &drawDot1, &drawLine1 | |
423 }; | |
424 | 425 |
425 // uint32 display = smanager->get_param(0); | 426 // uint32 display = smanager->get_param(0); |
426 // int screen_width = smanager->get_param(1); | 427 // int screen_width = smanager->get_param(1); |
427 int rangex_start = smanager->get_param(2); | 428 int rangex_start = smanager->get_param(2); |
428 int rangex_end = smanager->get_param(3); | 429 int rangex_end = smanager->get_param(3); |
475 next_span = span; | 476 next_span = span; |
476 | 477 |
477 resume_span = next_span; | 478 resume_span = next_span; |
478 resume_span_x = next_span_x; | 479 resume_span_x = next_span_x; |
479 | 480 |
480 //smanager->dma_wait(tl_tag[tl_tag_flg1]); | |
481 | |
482 tl_tag_flg1 ^= 1; | 481 tl_tag_flg1 ^= 1; |
483 tl_tag_flg2 ^= 1; | 482 tl_tag_flg2 ^= 1; |
484 } | 483 } |
485 | |
486 // 現在 drawLine2、drawDot2 は機能してないので | |
487 //(this->*drawFunc2[(resume_span->length_x != 1)])( | |
488 //resume_span, rangex_start, rangex_end, resume_span_x, | |
489 //tl_tag[tl_tag_flg1]); | |
490 | 484 |
491 smanager->dma_wait(SPAN_PACK_LOAD); | 485 smanager->dma_wait(SPAN_PACK_LOAD); |
492 | 486 |
493 SpanPackPtr tmp_spack = spack; | 487 SpanPackPtr tmp_spack = spack; |
494 spack = next_spack; | 488 spack = next_spack; |
496 } while (spack); | 490 } while (spack); |
497 | 491 |
498 | 492 |
499 free(g->zRow); | 493 free(g->zRow); |
500 free(g->linebuf); | 494 free(g->linebuf); |
501 free(g); | |
502 | 495 |
503 //FINISH: | 496 //FINISH: |
504 /** | 497 /** |
505 * goto FINISH; の時は reboot なので | 498 * goto FINISH; の時は reboot なので |
506 * linebuf, zRow は free() しない | 499 * linebuf, zRow は free() しない |