void LoadTexture() { int i; u32 * texture_mem = tiny3d_AllocTexture(64*1024*1024); // alloc 64MB of space for textures (this pointer can be global) u32 * texture_pointer; // use to asign texture space without changes texture_mem if(!texture_mem) return; // fail! texture_pointer = texture_mem; Load_PNG(); // copy texture datas from PNG to the RSX memory allocated for textures for(i = 0; i < 8; i++) { texture_ghost_offset[i] = 0; if(texture_ghost[i].bmp_out) { memcpy(texture_pointer, texture_ghost[i].bmp_out, texture_ghost[i].wpitch * texture_ghost[i].height); free(texture_ghost[i].bmp_out); texture_ghost[i].bmp_out= texture_pointer; texture_pointer += (texture_ghost[i].wpitch * texture_ghost[i].height + 3) & ~3; // aligned to 16 bytes (it is u32) and update the pointer texture_ghost_offset[i] = tiny3d_TextureOffset(texture_ghost[i].bmp_out); // get the offset (RSX use offset instead address) } } }
void LoadTexture() { u32 * texture_mem = tiny3d_AllocTexture(64*1024*1024); // alloc 64MB of space for textures (this pointer can be global) u32 * texture_pointer; // use to asign texture space without changes texture_mem if(!texture_mem) exit(0); // fail! texture_pointer = texture_mem; Load_PNG(); if(!png1.bmp_out) exit(0); // fail! ResetFont(); texture_pointer = (u32 *) AddFontFromBitmapArray((u8 *) msx, (u8 *) texture_pointer, 0, 254, 8, 8, 1, BIT7_FIRST_PIXEL); // build AYUV 32 bits map from PNG texture[0].addr = (void *) texture_pointer; texture[0].offset = tiny3d_TextureOffset(texture_pointer); texture[0].w = png1.width; texture[0].h = png1.height; texture[0].stride = png1.wpitch; texture_pointer = (u32 *) build_AYUV_32bits((u8 *)texture_pointer, png1.bmp_out, png1.width, png1.height, png1.wpitch); // build Y 8 bits map from PNG (width * height) * 1 texture[1].addr = (void *) texture_pointer; texture[1].offset = tiny3d_TextureOffset(texture_pointer); texture[1].w = png1.width; texture[1].h = png1.height; texture[1].stride = png1.wpitch/4; texture_pointer = (u32 *) build_Y_8bits((u8 *)texture_pointer, png1.bmp_out, png1.width, png1.height, png1.wpitch); // build U 8 bits map from PNG (width/2 * height/2) * 1 texture[2].addr = (void *) texture_pointer; texture[2].offset = tiny3d_TextureOffset(texture_pointer); texture[2].w = png1.width/2; texture[2].h = png1.height/2; texture[2].stride = texture[2].w; texture_pointer = (u32 *) build_U_8bits((u8 *)texture_pointer, png1.bmp_out, png1.width, png1.height, png1.wpitch); // build V 8 bits map from PNG (width/2 * height/2) * 1 texture[3].addr = (void *) texture_pointer; texture[3].offset = tiny3d_TextureOffset(texture_pointer); texture[3].w = png1.width/2; texture[3].h = png1.height/2; texture[3].stride = texture[3].w; texture_pointer = (u32 *) build_V_8bits((u8 *)texture_pointer, png1.bmp_out, png1.width, png1.height, png1.wpitch); }