Mercurial > hg > Members > kono > Cerium
diff TaskManager/Test/test_render/spe/DrawSpan.cpp @ 131:805d27efafd8
fix
author | gongo@charles.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Tue, 25 Nov 2008 17:24:18 +0900 |
parents | 776eca0daa02 |
children | 435e0d24db39 |
line wrap: on
line diff
--- a/TaskManager/Test/test_render/spe/DrawSpan.cpp Tue Nov 25 17:19:43 2008 +0900 +++ b/TaskManager/Test/test_render/spe/DrawSpan.cpp Tue Nov 25 17:24:18 2008 +0900 @@ -62,7 +62,8 @@ for (int i = 0; i < hashsize/2; i++) { int index = (hashval + i*i)%hashsize; - if (hash_table[index]->texture_addr == key) { + if (hash_table[index] != NULL && + hash_table[index]->texture_addr == key) { return hash_table[index]; } } @@ -106,14 +107,14 @@ } Uint32 -DrawSpan::get_rgb(int tx, int ty, void *texture) +DrawSpan::get_rgb(int tx, int ty, int tw, int th, void *texture) { Uint8 red, green, blue, alpha; if (tx<0) tx = 0; - if (tex_width-1< tx) tx = tex_width-1 ; + if (tw-1< tx) tx = tw-1 ; if (ty<0) ty = 0; - if (tex_height-1< ty) ty = tex_height-1 ; + if (th-1< ty) ty = th-1 ; void *texture_addr; @@ -122,8 +123,11 @@ void** addrList = (void**)global_get(TEXTURE2_ID); TilePtr tile; - texture_addr = addrList[blockX + (tex_width/8)*blockY]; + texture_addr = addrList[blockX + (tw/8)*blockY]; + /** + * get,put はオブジェクト(Hashとか?)を作ってアクセスするかな + */ tile = get(texture_addr); if (tile == NULL) { if (tileList->size >= MAX_TILE) { @@ -138,6 +142,12 @@ sizeof(uint32)*64, TEX_LOAD); int index = put(tile->texture_addr, tile); + + /** + * TODO: + * 入らなかったやつは + * 今までのやつを描画してから続きをするとか + */ if (index < 0) { printf("[%p] Can't entry\n", tile); return 0xff0000; @@ -148,7 +158,7 @@ smanager->dma_wait(TEX_LOAD); } - char *p = get_pixel(tx%8, ty%8, tile); + char *p = get_pixel(tx%8, ty%8, tile->pixel); alpha = 255; red = (Uint8) p[0]; @@ -224,18 +234,18 @@ // 座標が [0 .. split_screen_w-1] に入るように x,y を -1 int localx = getLocalX(x-1); int localy = getLocalY(y-1); - + if (end == 1) { if (x < rangex_start || rangex_end < x) { continue; } - tex_xpos = (int)((span->tex_height-1) * tex1); tex_ypos = (int)((span->tex_width-1) * tey1); tex_zpos = (int)z; if (zpos < zRow[localx + (rangex * localy)]) { - rgb = get_rgb(tex_xpos, tex_ypos, texture_image); + rgb = get_rgb(tex_xpos, tex_ypos, span->tex_width, + span->tex_height, texture_image); zRow[localx + (rangex * localy)] = zpos; linebuf[localy][localx] = rgb; } @@ -256,7 +266,8 @@ tex_ypos = (int)((span->tex_width-1) * tex_y); if (tex_z < zRow[localx + (rangex*localy)]) { - rgb = get_rgb(tex_xpos, tex_ypos, texture_image); + rgb = get_rgb(tex_xpos, tex_ypos, span->tex_width, + span->tex_height, texture_image); zRow[localx + (rangex*localy)] = tex_z; linebuf[localy][localx] = rgb; }