Mercurial > hg > Game > Cerium
changeset 77:459f54b49648
*** empty log message ***
author | chiaki |
---|---|
date | Mon, 18 Feb 2008 14:33:05 +0900 |
parents | 5a1a5f4c28fd |
children | 3c6dec161ade |
files | TaskManager/Test/simple_pack/span_pack.h TaskManager/Test/simple_pack/task/create_pp.cpp TaskManager/Test/simple_pack/task/create_sgp.cpp TaskManager/Test/simple_pack/task/create_span.cpp TaskManager/Test/simple_pack/task/spu_draw.cpp |
diffstat | 5 files changed, 156 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Test/simple_pack/span_pack.h Mon Feb 18 11:40:11 2008 +0900 +++ b/TaskManager/Test/simple_pack/span_pack.h Mon Feb 18 14:33:05 2008 +0900 @@ -15,7 +15,7 @@ int light_rgb[3]; } info; //SPAN span[250]; - SPAN span[100]; + SPAN span[70]; //SPAN *span; } SPANPACK, *SPANPACK_PTR;
--- a/TaskManager/Test/simple_pack/task/create_pp.cpp Mon Feb 18 11:40:11 2008 +0900 +++ b/TaskManager/Test/simple_pack/task/create_pp.cpp Mon Feb 18 14:33:05 2008 +0900 @@ -54,7 +54,7 @@ pp->tri[pt].ver3.tex_x = node->texture[nt+4]; pp->tri[pt].ver3.tex_y = node->texture[nt+4+1]; - //pp->tri[pt].tex_addr = node->tex_addr; + pp->tri[pt].tex_addr = node->tex_addr; pp->tri[pt].tex_width = node->tex_width; pp->tri[pt].tex_height = node->tex_height;
--- a/TaskManager/Test/simple_pack/task/create_sgp.cpp Mon Feb 18 11:40:11 2008 +0900 +++ b/TaskManager/Test/simple_pack/task/create_sgp.cpp Mon Feb 18 14:33:05 2008 +0900 @@ -45,7 +45,7 @@ node->interaction = 0; node->pn = nnpn; - //node->tex_addr = t->texture_image; + node->tex_addr = t->texture_image->pixels; node->tex_width = t->texture_image->w; node->tex_height = t->texture_image->h;
--- a/TaskManager/Test/simple_pack/task/create_span.cpp Mon Feb 18 11:40:11 2008 +0900 +++ b/TaskManager/Test/simple_pack/task/create_span.cpp Mon Feb 18 14:33:05 2008 +0900 @@ -100,12 +100,15 @@ //int spu_no = 0; int c = spl->dline[spu_no].info.size; + /* if(c > 100) { cout << "over c = " << c << endl; c = 0; spl->dline[spu_no].info.size = 0; } + */ + spl->dline[spu_no].span[c].tex_addr = tex_addr; spl->dline[spu_no].span[c].tex_width = tex_width; spl->dline[spu_no].span[c].tex_height = tex_height;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Test/simple_pack/task/spu_draw.cpp Mon Feb 18 14:33:05 2008 +0900 @@ -0,0 +1,150 @@ +#include <iostream> +#include "polygon_pack.h" +#include "span_pack.h" +#include "spu_span.h" +using namespace std; + +#define PIXELSIZE 11520 //32 line pixel size + +int linebuf[2][8][IMG_MAX_Y]; + + + +void linebuf_init(int j) { + int i; + for(int t= 0; t < 8; t++) { + for(i = 0; i < IMG_MAX_Y; i++) { + linebuf[j][t][i] = 0; + } + } +} +char *get_pixel(int tx, int ty, void *texture_image) +{ + //return (char*)texture_image->pixels+(texture_image->format->BytesPerPixel*((texture_image->w)*ty+tx)); + return (char*)texture_image+(3*((128)*ty+tx)); +} + +Uint32 Polygon::get_rgb(int tx, int ty, void *texture) +{ + Uint8 red, green, blue; + + if (tx<0) tx = 0; + if (128-1< tx) tx = 128-1 ; + if (ty<0) ty = 0; + if (128-1< ty) ty = 128-1 ; + + char *p = get_pixel(tx,ty,texture); + + blue = (Uint8) p[0]; + green = (Uint8) p[1]; + red = (Uint8) p[2]; + + SDL_PixelFormat pf; + pf.BitsPerPixel = 32; + pf.BytesPerPixel = 4; + alpha = 255; + + return SDL_MapRGB(pf, red, green, blue); +} + +void write_pixel(int x, int y, float z, Uint32 rgb) +{ + +} + +void zRow_init() { + int i; + //printf("zRow_init?n"); + for(int t = 0; t < 8; t++) { + for(i = 0; i < IMG_MAX_Y; i++) { + zRow[t][i] = 65535; + } + } +} + +int spu_draw(SPUSPAN *ss, unsigned int fbdev_addr) +{ + void *texture = new void[128*128*3]; + long *addr = ss->sp[0].tex_addr; + GLushort zRow[8][IMG_MAX_Y]; + static int j = 0; + int render_y = 0; + spu_mfcdma32(texture, addr, PIXELSIZE, 17, MFC_GET_CMD); + spu_mfcdma32(texture+PIXELSIZE, addr+PIXELSIZE, PIXELSIZE, 18, MFC_GET_CMD); + spu_mfcdma32(texture+PIXELSIZE*2, addr+PIXELSIZE*2, PIXELSIZE, 19, MFC_GET_CMD); + spu_mfcdma32(texture+PIXELSIZE*3, addr+PIXELSIZE*3, PIXELSIZE, 20, MFC_GET_CMD); + spu_writech(MFC_WrTagMask, 1 << 17); + spu_mfcstat(MFC_TAG_UPDATE_ALL); + spu_writech(MFC_WrTagMask, 1 << 18); + spu_mfcstat(MFC_TAG_UPDATE_ALL); + spu_writech(MFC_WrTagMask, 1 << 19); + spu_mfcstat(MFC_TAG_UPDATE_ALL); + spu_writech(MFC_WrTagMask, 1 << 20); + spu_mfcstat(MFC_TAG_UPDATE_ALL); + zRow_init(); + linebuf_init(j); + render_y = ss->sp[0].span[0].y; + for(int i; i<ss->length; i++) + { + for(int t; t<ss->sp[i].info.size; t++) + { + int end = sp->span[n].length_x; + Uint32 rgb; + float tex1 = sp->span[n].tex_x1; + float tex2= sp->span[n].tex_x2; + float tey1 = sp->span[n].tex_y1; + float tey2= sp->span[n].tex_y2; + int tex_xpos; + int tex_ypos; + int tex_zpos; + int x = sp->span[n].x; + int y = sp->span[n].y; + float z = sp->span[n].start_z; + float zpos = sp->span[n].end_z; + float tex_x,tex_y,tex_z; + + if(end == 1) { + //printf("end == 1\n"); + //printf("tex_x:%f tex_y:%f\n",tex1,tex2); + //if(tex1 > 1) tex1 = 1; + //if(tey1 > 1) tey1 = 1; + tex_xpos = (int)((sp->span[n].tex_height-1) * tex1); + tex_ypos = (int)((sp->span[n].tex_width-1) * tey1); + tex_zpos = (int)z; + //printf("tex_xpos:%d tex_ypos:%d\n",tex_xpos,tex_ypos); + //printf("image->h:%d tex_x:%f\n",(int)sp->span[n].tex_height,tex1); + if(z < zRow[x][y%8]) { + rgb = get_rgb(tex_xpos,tex_ypos); + //viewer->write_pixel(x,y,zpos,rgb); + linebuf[j][x][y%8] = rgb; + } + + }else { + //printf("end != 1\n"); + for(int j = 0; j < end; j++) { + tex_x = tex1*(end-1-j)/(end-1) + tex2*j/(end-1); + tex_y = tey1*(end-1-j)/(end-1) + tey2*j/(end-1); + tex_z = z*(end-1-j)/(end-1) + zpos*j/(end-1); + if(tex_x > 1) tex_x = 1; + if(tex_y > 1) tex_y = 1; + tex_xpos = (int)((sp->span[n].tex_height-1) * tex_x); + tex_ypos = (int)((sp->span[n].tex_width-1) * tex_y); + //printf("tex_xpos:%d tex_ypos:%d\n",tex_xpos,tex_ypos); + //printf("z:%f zpos:%f tex_z:%f\n",z,zpos,tex_z); + //printf("tex_x:%f tex_y:%f\n",tex_x,tex_y); + if(z < zRow[x][y%8]) { + rgb = get_rgb(tex_xpos,tex_ypos); + linebuf[j][x][y%8] = rgb; + //viewer->write_pixel(j+x,y,tex_z,rgb); + } + } + } + } + writebuffer(j,fbdev_addr,render_y); + } + j ^= 1; +} + +void writebuffer(int i,fbdev_addr,int y) { + spu_mfcdma32(&linebuf[0][0],fbdev_addr,PIXELSIZE,21,MFC_PUT_CMD); +}