[Glide64] Clean up FBtoScreen.cpp

This commit is contained in:
zilmar 2016-02-11 18:13:51 +11:00
parent fb82959863
commit 6bdd5dd330
1 changed files with 568 additions and 569 deletions

View File

@ -42,7 +42,6 @@
// //
//**************************************************************** //****************************************************************
#include "Gfx_1.3.h" #include "Gfx_1.3.h"
#include "FBtoScreen.h" #include "FBtoScreen.h"
#include "TexCache.h" #include "TexCache.h"
@ -50,107 +49,107 @@
static int SetupFBtoScreenCombiner(uint32_t texture_size, uint32_t opaque) static int SetupFBtoScreenCombiner(uint32_t texture_size, uint32_t opaque)
{ {
int tmu; int tmu;
if (voodoo.tmem_ptr[GR_TMU0]+texture_size < voodoo.tex_max_addr[0]) if (voodoo.tmem_ptr[GR_TMU0] + texture_size < voodoo.tex_max_addr[0])
{ {
tmu = GR_TMU0; tmu = GR_TMU0;
grTexCombine( GR_TMU1, grTexCombine(GR_TMU1,
GR_COMBINE_FUNCTION_NONE, GR_COMBINE_FUNCTION_NONE,
GR_COMBINE_FACTOR_NONE, GR_COMBINE_FACTOR_NONE,
GR_COMBINE_FUNCTION_NONE, GR_COMBINE_FUNCTION_NONE,
GR_COMBINE_FACTOR_NONE, GR_COMBINE_FACTOR_NONE,
FXFALSE, FXFALSE,
FXFALSE ); FXFALSE);
grTexCombine( GR_TMU0, grTexCombine(GR_TMU0,
GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FUNCTION_LOCAL,
GR_COMBINE_FACTOR_NONE, GR_COMBINE_FACTOR_NONE,
GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FUNCTION_LOCAL,
GR_COMBINE_FACTOR_NONE, GR_COMBINE_FACTOR_NONE,
FXFALSE, FXFALSE,
FXFALSE ); FXFALSE);
} }
else else
{ {
if (voodoo.tmem_ptr[GR_TMU1]+texture_size >= voodoo.tex_max_addr[1]) if (voodoo.tmem_ptr[GR_TMU1] + texture_size >= voodoo.tex_max_addr[1])
ClearCache (); ClearCache();
tmu = GR_TMU1; tmu = GR_TMU1;
grTexCombine( GR_TMU1, grTexCombine(GR_TMU1,
GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FUNCTION_LOCAL,
GR_COMBINE_FACTOR_NONE, GR_COMBINE_FACTOR_NONE,
GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FUNCTION_LOCAL,
GR_COMBINE_FACTOR_NONE, GR_COMBINE_FACTOR_NONE,
FXFALSE, FXFALSE,
FXFALSE ); FXFALSE);
grTexCombine( GR_TMU0, grTexCombine(GR_TMU0,
GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FUNCTION_SCALE_OTHER,
GR_COMBINE_FACTOR_ONE, GR_COMBINE_FACTOR_ONE,
GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FUNCTION_SCALE_OTHER,
GR_COMBINE_FACTOR_ONE, GR_COMBINE_FACTOR_ONE,
FXFALSE, FXFALSE,
FXFALSE ); FXFALSE);
} }
int filter = (rdp.filter_mode!=2)?GR_TEXTUREFILTER_POINT_SAMPLED:GR_TEXTUREFILTER_BILINEAR; int filter = (rdp.filter_mode != 2) ? GR_TEXTUREFILTER_POINT_SAMPLED : GR_TEXTUREFILTER_BILINEAR;
grTexFilterMode (tmu, filter, filter); grTexFilterMode(tmu, filter, filter);
grTexClampMode (tmu, grTexClampMode(tmu,
GR_TEXTURECLAMP_CLAMP, GR_TEXTURECLAMP_CLAMP,
GR_TEXTURECLAMP_CLAMP); GR_TEXTURECLAMP_CLAMP);
// grConstantColorValue (0xFFFFFFFF); // grConstantColorValue (0xFFFFFFFF);
grColorCombine (GR_COMBINE_FUNCTION_SCALE_OTHER, grColorCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,
GR_COMBINE_FACTOR_ONE, GR_COMBINE_FACTOR_ONE,
GR_COMBINE_LOCAL_NONE, GR_COMBINE_LOCAL_NONE,
GR_COMBINE_OTHER_TEXTURE, GR_COMBINE_OTHER_TEXTURE,
// GR_COMBINE_OTHER_CONSTANT, // GR_COMBINE_OTHER_CONSTANT,
FXFALSE); FXFALSE);
grAlphaCombine (GR_COMBINE_FUNCTION_SCALE_OTHER, grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,
GR_COMBINE_FACTOR_ONE, GR_COMBINE_FACTOR_ONE,
GR_COMBINE_LOCAL_NONE, GR_COMBINE_LOCAL_NONE,
GR_COMBINE_OTHER_TEXTURE, GR_COMBINE_OTHER_TEXTURE,
FXFALSE); FXFALSE);
if (opaque) if (opaque)
{ {
grAlphaTestFunction (GR_CMP_ALWAYS); grAlphaTestFunction(GR_CMP_ALWAYS);
grAlphaBlendFunction( GR_BLEND_ONE, grAlphaBlendFunction(GR_BLEND_ONE,
GR_BLEND_ZERO, GR_BLEND_ZERO,
GR_BLEND_ONE, GR_BLEND_ONE,
GR_BLEND_ZERO); GR_BLEND_ZERO);
} }
else else
{ {
grAlphaBlendFunction( GR_BLEND_SRC_ALPHA, grAlphaBlendFunction(GR_BLEND_SRC_ALPHA,
GR_BLEND_ONE_MINUS_SRC_ALPHA, GR_BLEND_ONE_MINUS_SRC_ALPHA,
GR_BLEND_ONE, GR_BLEND_ONE,
GR_BLEND_ZERO); GR_BLEND_ZERO);
} }
grDepthBufferFunction (GR_CMP_ALWAYS); grDepthBufferFunction(GR_CMP_ALWAYS);
grCullMode(GR_CULL_DISABLE); grCullMode(GR_CULL_DISABLE);
grDepthMask (FXFALSE); grDepthMask(FXFALSE);
rdp.update |= UPDATE_COMBINE | UPDATE_ZBUF_ENABLED | UPDATE_CULL_MODE; rdp.update |= UPDATE_COMBINE | UPDATE_ZBUF_ENABLED | UPDATE_CULL_MODE;
return tmu; return tmu;
} }
static void DrawRE2Video(FB_TO_SCREEN_INFO & fb_info, float scale) static void DrawRE2Video(FB_TO_SCREEN_INFO & fb_info, float scale)
{ {
float scale_y = (float)fb_info.width/rdp.vi_height; float scale_y = (float)fb_info.width / rdp.vi_height;
float height = g_settings->scr_res_x/scale_y; float height = g_settings->scr_res_x / scale_y;
float ul_x = 0.5f; float ul_x = 0.5f;
float ul_y = (g_settings->scr_res_y - height)/2.0f; float ul_y = (g_settings->scr_res_y - height) / 2.0f;
float lr_y = g_settings->scr_res_y - ul_y - 1.0f; float lr_y = g_settings->scr_res_y - ul_y - 1.0f;
float lr_x = g_settings->scr_res_x - 1.0f; float lr_x = g_settings->scr_res_x - 1.0f;
float lr_u = (fb_info.width - 1)*scale; float lr_u = (fb_info.width - 1)*scale;
float lr_v = (fb_info.height - 1)*scale; float lr_v = (fb_info.height - 1)*scale;
VERTEX v[4] = { VERTEX v[4] = {
{ ul_x, ul_y, 1, 1, 0.5f, 0.5f, 0.5f, 0.5f, {0.5f, 0.5f, 0.5f, 0.5f} }, { ul_x, ul_y, 1, 1, 0.5f, 0.5f, 0.5f, 0.5f, { 0.5f, 0.5f, 0.5f, 0.5f } },
{ lr_x, ul_y, 1, 1, lr_u, 0.5f, lr_u, 0.5f, {lr_u, 0.5f, lr_u, 0.5f} }, { lr_x, ul_y, 1, 1, lr_u, 0.5f, lr_u, 0.5f, { lr_u, 0.5f, lr_u, 0.5f } },
{ ul_x, lr_y, 1, 1, 0.5f, lr_v, 0.5f, lr_v, {0.5f, lr_v, 0.5f, lr_v} }, { ul_x, lr_y, 1, 1, 0.5f, lr_v, 0.5f, lr_v, { 0.5f, lr_v, 0.5f, lr_v } },
{ lr_x, lr_y, 1, 1, lr_u, lr_v, lr_u, lr_v, {lr_u, lr_v, lr_u, lr_v} } { lr_x, lr_y, 1, 1, lr_u, lr_v, lr_u, lr_v, { lr_u, lr_v, lr_u, lr_v } }
}; };
grDrawTriangle (&v[0], &v[2], &v[1]); grDrawTriangle(&v[0], &v[2], &v[1]);
grDrawTriangle (&v[2], &v[3], &v[1]); grDrawTriangle(&v[2], &v[3], &v[1]);
} }
static void DrawRE2Video256(FB_TO_SCREEN_INFO & fb_info) static void DrawRE2Video256(FB_TO_SCREEN_INFO & fb_info)
{ {
FRDP("DrawRE2Video256. ul_x=%d, ul_y=%d, lr_x=%d, lr_y=%d, size=%d, addr=%08lx\n", fb_info.ul_x, fb_info.ul_y, fb_info.lr_x, fb_info.lr_y, fb_info.size, fb_info.addr); FRDP("DrawRE2Video256. ul_x=%d, ul_y=%d, lr_x=%d, lr_y=%d, size=%d, addr=%08lx\n", fb_info.ul_x, fb_info.ul_y, fb_info.lr_x, fb_info.lr_y, fb_info.size, fb_info.addr);
uint32_t * src = (uint32_t*)(gfx.RDRAM+fb_info.addr); uint32_t * src = (uint32_t*)(gfx.RDRAM + fb_info.addr);
GrTexInfo t_info; GrTexInfo t_info;
t_info.smallLodLog2 = GR_LOD_LOG2_256; t_info.smallLodLog2 = GR_LOD_LOG2_256;
t_info.largeLodLog2 = GR_LOD_LOG2_256; t_info.largeLodLog2 = GR_LOD_LOG2_256;
@ -165,11 +164,11 @@ static void DrawRE2Video256(FB_TO_SCREEN_INFO & fb_info)
for (uint32_t w = 0; w < 256; w++) for (uint32_t w = 0; w < 256; w++)
{ {
col = *(src++); col = *(src++);
r = (uint8_t)((col >> 24)&0xFF); r = (uint8_t)((col >> 24) & 0xFF);
r = (uint8_t)((float)r / 255.0f * 31.0f); r = (uint8_t)((float)r / 255.0f * 31.0f);
g = (uint8_t)((col >> 16)&0xFF); g = (uint8_t)((col >> 16) & 0xFF);
g = (uint8_t)((float)g / 255.0f * 63.0f); g = (uint8_t)((float)g / 255.0f * 63.0f);
b = (uint8_t)((col >> 8)&0xFF); b = (uint8_t)((col >> 8) & 0xFF);
b = (uint8_t)((float)b / 255.0f * 31.0f); b = (uint8_t)((float)b / 255.0f * 31.0f);
*(dst++) = (r << 11) | (g << 5) | b; *(dst++) = (r << 11) | (g << 5) | b;
} }
@ -178,12 +177,12 @@ static void DrawRE2Video256(FB_TO_SCREEN_INFO & fb_info)
t_info.format = GR_TEXFMT_RGB_565; t_info.format = GR_TEXFMT_RGB_565;
t_info.data = tex; t_info.data = tex;
int tmu = SetupFBtoScreenCombiner(grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &t_info), fb_info.opaque); int tmu = SetupFBtoScreenCombiner(grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &t_info), fb_info.opaque);
grTexDownloadMipMap (tmu, grTexDownloadMipMap(tmu,
voodoo.tex_min_addr[tmu]+voodoo.tmem_ptr[tmu], voodoo.tex_min_addr[tmu] + voodoo.tmem_ptr[tmu],
GR_MIPMAPLEVELMASK_BOTH, GR_MIPMAPLEVELMASK_BOTH,
&t_info); &t_info);
grTexSource (tmu, grTexSource(tmu,
voodoo.tex_min_addr[tmu]+voodoo.tmem_ptr[tmu], voodoo.tex_min_addr[tmu] + voodoo.tmem_ptr[tmu],
GR_MIPMAPLEVELMASK_BOTH, GR_MIPMAPLEVELMASK_BOTH,
&t_info); &t_info);
DrawRE2Video(fb_info, 1.0f); DrawRE2Video(fb_info, 1.0f);
@ -200,31 +199,31 @@ static void DrawFrameBufferToScreen256(FB_TO_SCREEN_INFO & fb_info)
uint32_t width = fb_info.lr_x - fb_info.ul_x + 1; uint32_t width = fb_info.lr_x - fb_info.ul_x + 1;
uint32_t height = fb_info.lr_y - fb_info.ul_y + 1; uint32_t height = fb_info.lr_y - fb_info.ul_y + 1;
GrTexInfo t_info; GrTexInfo t_info;
uint8_t * image = gfx.RDRAM+fb_info.addr; uint8_t * image = gfx.RDRAM + fb_info.addr;
uint32_t width256 = ((width-1) >> 8) + 1; uint32_t width256 = ((width - 1) >> 8) + 1;
uint32_t height256 = ((height-1) >> 8) + 1; uint32_t height256 = ((height - 1) >> 8) + 1;
t_info.smallLodLog2 = t_info.largeLodLog2 = GR_LOD_LOG2_256; t_info.smallLodLog2 = t_info.largeLodLog2 = GR_LOD_LOG2_256;
t_info.aspectRatioLog2 = GR_ASPECT_LOG2_1x1; t_info.aspectRatioLog2 = GR_ASPECT_LOG2_1x1;
t_info.format = GR_TEXFMT_ARGB_1555; t_info.format = GR_TEXFMT_ARGB_1555;
uint16_t * tex = (uint16_t*)texture_buffer; uint16_t * tex = (uint16_t*)texture_buffer;
t_info.data = tex; t_info.data = tex;
uint32_t tex_size = grTexTextureMemRequired (GR_MIPMAPLEVELMASK_BOTH, &t_info); uint32_t tex_size = grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &t_info);
int tmu = SetupFBtoScreenCombiner(tex_size*width256*height256, fb_info.opaque); int tmu = SetupFBtoScreenCombiner(tex_size*width256*height256, fb_info.opaque);
uint16_t * src = (uint16_t*)image; uint16_t * src = (uint16_t*)image;
src += fb_info.ul_x + fb_info.ul_y * fb_info.width; src += fb_info.ul_x + fb_info.ul_y * fb_info.width;
uint32_t * src32 = (uint32_t*)image; uint32_t * src32 = (uint32_t*)image;
src32 += fb_info.ul_x + fb_info.ul_y * fb_info.width; src32 += fb_info.ul_x + fb_info.ul_y * fb_info.width;
uint32_t w_tail = width%256; uint32_t w_tail = width % 256;
uint32_t h_tail = height%256; uint32_t h_tail = height % 256;
uint16_t c; uint16_t c;
uint32_t c32; uint32_t c32;
uint32_t idx; uint32_t idx;
uint32_t bound = BMASK+1-fb_info.addr; uint32_t bound = BMASK + 1 - fb_info.addr;
bound = fb_info.size == 2 ? bound >> 1 : bound >> 2; bound = fb_info.size == 2 ? bound >> 1 : bound >> 2;
uint8_t r, g, b, a; uint8_t r, g, b, a;
uint32_t cur_width, cur_height, cur_tail; uint32_t cur_width, cur_height, cur_tail;
uint32_t tex_adr = voodoo.tex_min_addr[tmu]+voodoo.tmem_ptr[tmu]; uint32_t tex_adr = voodoo.tex_min_addr[tmu] + voodoo.tmem_ptr[tmu];
if ((voodoo.tmem_ptr[tmu] < TEXMEM_2MB_EDGE) && (voodoo.tmem_ptr[tmu]+tex_size*width256*height256 > TEXMEM_2MB_EDGE)) if ((voodoo.tmem_ptr[tmu] < TEXMEM_2MB_EDGE) && (voodoo.tmem_ptr[tmu] + tex_size*width256*height256 > TEXMEM_2MB_EDGE))
{ {
tex_adr = TEXMEM_2MB_EDGE; tex_adr = TEXMEM_2MB_EDGE;
} }
@ -232,52 +231,52 @@ static void DrawFrameBufferToScreen256(FB_TO_SCREEN_INFO & fb_info)
{ {
for (uint32_t w = 0; w < width256; w++) for (uint32_t w = 0; w < width256; w++)
{ {
cur_width = (256*(w+1) < width) ? 256 : w_tail; cur_width = (256 * (w + 1) < width) ? 256 : w_tail;
cur_height = (256*(h+1) < height) ? 256 : h_tail; cur_height = (256 * (h + 1) < height) ? 256 : h_tail;
cur_tail = 256 - cur_width; cur_tail = 256 - cur_width;
uint16_t * dst = tex; uint16_t * dst = tex;
if (fb_info.size == 2) if (fb_info.size == 2)
{ {
for (uint32_t y=0; y < cur_height; y++) for (uint32_t y = 0; y < cur_height; y++)
{ {
for (uint32_t x=0; x < cur_width; x++) for (uint32_t x = 0; x < cur_width; x++)
{ {
idx = (x+256*w+(y+256*h)*fb_info.width)^1; idx = (x + 256 * w + (y + 256 * h)*fb_info.width) ^ 1;
if (idx >= bound) if (idx >= bound)
break; break;
c = src[idx]; c = src[idx];
*(dst++) = (c >> 1) | ((c&1)<<15); *(dst++) = (c >> 1) | ((c & 1) << 15);
} }
dst += cur_tail; dst += cur_tail;
} }
} }
else else
{ {
for (uint32_t y=0; y < cur_height; y++) for (uint32_t y = 0; y < cur_height; y++)
{ {
for (uint32_t x=0; x < cur_width; x++) for (uint32_t x = 0; x < cur_width; x++)
{ {
idx = (x+256*w+(y+256*h)*fb_info.width); idx = (x + 256 * w + (y + 256 * h)*fb_info.width);
if (idx >= bound) if (idx >= bound)
break; break;
c32 = src32[idx]; c32 = src32[idx];
r = (uint8_t)((c32 >> 24)&0xFF); r = (uint8_t)((c32 >> 24) & 0xFF);
r = (uint8_t)((float)r / 255.0f * 31.0f); r = (uint8_t)((float)r / 255.0f * 31.0f);
g = (uint8_t)((c32 >> 16)&0xFF); g = (uint8_t)((c32 >> 16) & 0xFF);
g = (uint8_t)((float)g / 255.0f * 63.0f); g = (uint8_t)((float)g / 255.0f * 63.0f);
b = (uint8_t)((c32 >> 8)&0xFF); b = (uint8_t)((c32 >> 8) & 0xFF);
b = (uint8_t)((float)b / 255.0f * 31.0f); b = (uint8_t)((float)b / 255.0f * 31.0f);
a = (c32&0xFF) ? 1 : 0; a = (c32 & 0xFF) ? 1 : 0;
*(dst++) = (a<<15) | (r << 10) | (g << 5) | b; *(dst++) = (a << 15) | (r << 10) | (g << 5) | b;
} }
dst += cur_tail; dst += cur_tail;
} }
} }
grTexDownloadMipMap (tmu, tex_adr, GR_MIPMAPLEVELMASK_BOTH, &t_info); grTexDownloadMipMap(tmu, tex_adr, GR_MIPMAPLEVELMASK_BOTH, &t_info);
grTexSource (tmu, tex_adr, GR_MIPMAPLEVELMASK_BOTH, &t_info); grTexSource(tmu, tex_adr, GR_MIPMAPLEVELMASK_BOTH, &t_info);
tex_adr += tex_size; tex_adr += tex_size;
float ul_x = (float)(fb_info.ul_x + 256*w); float ul_x = (float)(fb_info.ul_x + 256 * w);
float ul_y = (float)(fb_info.ul_y + 256*h); float ul_y = (float)(fb_info.ul_y + 256 * h);
float lr_x = (ul_x + (float)(cur_width)) * rdp.scale_x; float lr_x = (ul_x + (float)(cur_width)) * rdp.scale_x;
float lr_y = (ul_y + (float)(cur_height)) * rdp.scale_y; float lr_y = (ul_y + (float)(cur_height)) * rdp.scale_y;
ul_x *= rdp.scale_x; ul_x *= rdp.scale_x;
@ -287,17 +286,17 @@ static void DrawFrameBufferToScreen256(FB_TO_SCREEN_INFO & fb_info)
lr_x += rdp.offset_x; lr_x += rdp.offset_x;
lr_y += rdp.offset_y; lr_y += rdp.offset_y;
float lr_u = (float)(cur_width-1); float lr_u = (float)(cur_width - 1);
float lr_v = (float)(cur_height-1); float lr_v = (float)(cur_height - 1);
// Make the vertices // Make the vertices
VERTEX v[4] = { VERTEX v[4] = {
{ ul_x, ul_y, 1, 1, 0.5f, 0.5f, 0.5f, 0.5f, {0.5f, 0.5f, 0.5f, 0.5f} }, { ul_x, ul_y, 1, 1, 0.5f, 0.5f, 0.5f, 0.5f, { 0.5f, 0.5f, 0.5f, 0.5f } },
{ lr_x, ul_y, 1, 1, lr_u, 0.5f, lr_u, 0.5f, {lr_u, 0.5f, lr_u, 0.5f} }, { lr_x, ul_y, 1, 1, lr_u, 0.5f, lr_u, 0.5f, { lr_u, 0.5f, lr_u, 0.5f } },
{ ul_x, lr_y, 1, 1, 0.5f, lr_v, 0.5f, lr_v, {0.5f, lr_v, 0.5f, lr_v} }, { ul_x, lr_y, 1, 1, 0.5f, lr_v, 0.5f, lr_v, { 0.5f, lr_v, 0.5f, lr_v } },
{ lr_x, lr_y, 1, 1, lr_u, lr_v, lr_u, lr_v, {lr_u, lr_v, lr_u, lr_v} } { lr_x, lr_y, 1, 1, lr_u, lr_v, lr_u, lr_v, { lr_u, lr_v, lr_u, lr_v } }
}; };
grDrawTriangle (&v[0], &v[2], &v[1]); grDrawTriangle(&v[0], &v[2], &v[1]);
grDrawTriangle (&v[2], &v[3], &v[1]); grDrawTriangle(&v[2], &v[3], &v[1]);
} }
} }
} }
@ -309,14 +308,14 @@ bool DrawFrameBufferToScreen(FB_TO_SCREEN_INFO & fb_info)
uint32_t width = fb_info.lr_x - fb_info.ul_x + 1; uint32_t width = fb_info.lr_x - fb_info.ul_x + 1;
uint32_t height = fb_info.lr_y - fb_info.ul_y + 1; uint32_t height = fb_info.lr_y - fb_info.ul_y + 1;
uint32_t max_size = minval(voodoo.max_tex_size, 512); uint32_t max_size = minval(voodoo.max_tex_size, 512);
if (width > (uint32_t)max_size || height > (uint32_t)max_size) if (width >(uint32_t)max_size || height > (uint32_t)max_size)
{ {
DrawFrameBufferToScreen256(fb_info); DrawFrameBufferToScreen256(fb_info);
return true; return true;
} }
FRDP("DrawFrameBufferToScreen. ul_x=%d, ul_y=%d, lr_x=%d, lr_y=%d, size=%d, addr=%08lx\n", fb_info.ul_x, fb_info.ul_y, fb_info.lr_x, fb_info.lr_y, fb_info.size, fb_info.addr); FRDP("DrawFrameBufferToScreen. ul_x=%d, ul_y=%d, lr_x=%d, lr_y=%d, size=%d, addr=%08lx\n", fb_info.ul_x, fb_info.ul_y, fb_info.lr_x, fb_info.lr_y, fb_info.size, fb_info.addr);
GrTexInfo t_info; GrTexInfo t_info;
uint8_t * image = gfx.RDRAM+fb_info.addr; uint8_t * image = gfx.RDRAM + fb_info.addr;
uint32_t texwidth; uint32_t texwidth;
float scale; float scale;
if (width <= 256) if (width <= 256)
@ -332,7 +331,7 @@ bool DrawFrameBufferToScreen(FB_TO_SCREEN_INFO & fb_info)
t_info.smallLodLog2 = t_info.largeLodLog2 = GR_LOD_LOG2_512; t_info.smallLodLog2 = t_info.largeLodLog2 = GR_LOD_LOG2_512;
} }
if (height <= (texwidth>>1)) if (height <= (texwidth >> 1))
{ {
t_info.aspectRatioLog2 = GR_ASPECT_LOG2_2x1; t_info.aspectRatioLog2 = GR_ASPECT_LOG2_2x1;
} }
@ -349,20 +348,20 @@ bool DrawFrameBufferToScreen(FB_TO_SCREEN_INFO & fb_info)
src += fb_info.ul_x + fb_info.ul_y * fb_info.width; src += fb_info.ul_x + fb_info.ul_y * fb_info.width;
uint16_t c; uint16_t c;
uint32_t idx; uint32_t idx;
const uint32_t bound = (BMASK+1-fb_info.addr) >> 1; const uint32_t bound = (BMASK + 1 - fb_info.addr) >> 1;
bool empty = true; bool empty = true;
for (uint32_t y=0; y < height; y++) for (uint32_t y = 0; y < height; y++)
{ {
for (uint32_t x=0; x < width; x++) for (uint32_t x = 0; x < width; x++)
{ {
idx = (x+y*fb_info.width)^1; idx = (x + y*fb_info.width) ^ 1;
if (idx >= bound) if (idx >= bound)
break; break;
c = src[idx]; c = src[idx];
if (c) empty = false; if (c) empty = false;
*(dst++) = (c >> 1) | ((c&1)<<15); *(dst++) = (c >> 1) | ((c & 1) << 15);
} }
dst += texwidth-width; dst += texwidth - width;
} }
if (empty) if (empty)
return false; return false;
@ -377,30 +376,30 @@ bool DrawFrameBufferToScreen(FB_TO_SCREEN_INFO & fb_info)
src += fb_info.ul_x + fb_info.ul_y * fb_info.width; src += fb_info.ul_x + fb_info.ul_y * fb_info.width;
uint32_t col; uint32_t col;
uint32_t idx; uint32_t idx;
const uint32_t bound = (BMASK+1-fb_info.addr) >> 2; const uint32_t bound = (BMASK + 1 - fb_info.addr) >> 2;
for (uint32_t y=0; y < height; y++) for (uint32_t y = 0; y < height; y++)
{ {
for (uint32_t x=0; x < width; x++) for (uint32_t x = 0; x < width; x++)
{ {
idx = x+y*fb_info.width; idx = x + y*fb_info.width;
if (idx >= bound) if (idx >= bound)
break; break;
col = src[idx]; col = src[idx];
*(dst++) = (col >> 8) | 0xFF000000; *(dst++) = (col >> 8) | 0xFF000000;
} }
dst += texwidth-width; dst += texwidth - width;
} }
t_info.format = GR_TEXFMT_ARGB_8888; t_info.format = GR_TEXFMT_ARGB_8888;
t_info.data = tex; t_info.data = tex;
} }
int tmu = SetupFBtoScreenCombiner(grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &t_info), fb_info.opaque); int tmu = SetupFBtoScreenCombiner(grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &t_info), fb_info.opaque);
grTexDownloadMipMap (tmu, grTexDownloadMipMap(tmu,
voodoo.tex_min_addr[tmu]+voodoo.tmem_ptr[tmu], voodoo.tex_min_addr[tmu] + voodoo.tmem_ptr[tmu],
GR_MIPMAPLEVELMASK_BOTH, GR_MIPMAPLEVELMASK_BOTH,
&t_info); &t_info);
grTexSource (tmu, grTexSource(tmu,
voodoo.tex_min_addr[tmu]+voodoo.tmem_ptr[tmu], voodoo.tex_min_addr[tmu] + voodoo.tmem_ptr[tmu],
GR_MIPMAPLEVELMASK_BOTH, GR_MIPMAPLEVELMASK_BOTH,
&t_info); &t_info);
if (g_settings->hacks&hack_RE2) if (g_settings->hacks&hack_RE2)
@ -413,17 +412,17 @@ bool DrawFrameBufferToScreen(FB_TO_SCREEN_INFO & fb_info)
float ul_y = fb_info.ul_y * rdp.scale_y + rdp.offset_y; float ul_y = fb_info.ul_y * rdp.scale_y + rdp.offset_y;
float lr_x = fb_info.lr_x * rdp.scale_x + rdp.offset_x; float lr_x = fb_info.lr_x * rdp.scale_x + rdp.offset_x;
float lr_y = fb_info.lr_y * rdp.scale_y + rdp.offset_y; float lr_y = fb_info.lr_y * rdp.scale_y + rdp.offset_y;
float lr_u = (width-1)*scale; float lr_u = (width - 1)*scale;
float lr_v = (height-1)*scale; float lr_v = (height - 1)*scale;
// Make the vertices // Make the vertices
VERTEX v[4] = { VERTEX v[4] = {
{ ul_x, ul_y, 1, 1, 0.5f, 0.5f, 0.5f, 0.5f, {0.5f, 0.5f, 0.5f, 0.5f} }, { ul_x, ul_y, 1, 1, 0.5f, 0.5f, 0.5f, 0.5f, { 0.5f, 0.5f, 0.5f, 0.5f } },
{ lr_x, ul_y, 1, 1, lr_u, 0.5f, lr_u, 0.5f, {lr_u, 0.5f, lr_u, 0.5f} }, { lr_x, ul_y, 1, 1, lr_u, 0.5f, lr_u, 0.5f, { lr_u, 0.5f, lr_u, 0.5f } },
{ ul_x, lr_y, 1, 1, 0.5f, lr_v, 0.5f, lr_v, {0.5f, lr_v, 0.5f, lr_v} }, { ul_x, lr_y, 1, 1, 0.5f, lr_v, 0.5f, lr_v, { 0.5f, lr_v, 0.5f, lr_v } },
{ lr_x, lr_y, 1, 1, lr_u, lr_v, lr_u, lr_v, {lr_u, lr_v, lr_u, lr_v} } { lr_x, lr_y, 1, 1, lr_u, lr_v, lr_u, lr_v, { lr_u, lr_v, lr_u, lr_v } }
}; };
grDrawTriangle (&v[0], &v[2], &v[1]); grDrawTriangle(&v[0], &v[2], &v[1]);
grDrawTriangle (&v[2], &v[3], &v[1]); grDrawTriangle(&v[2], &v[3], &v[1]);
} }
return true; return true;
} }
@ -434,29 +433,29 @@ static void DrawDepthBufferToScreen256(FB_TO_SCREEN_INFO & fb_info)
uint32_t width = fb_info.lr_x - fb_info.ul_x + 1; uint32_t width = fb_info.lr_x - fb_info.ul_x + 1;
uint32_t height = fb_info.lr_y - fb_info.ul_y + 1; uint32_t height = fb_info.lr_y - fb_info.ul_y + 1;
GrTexInfo t_info; GrTexInfo t_info;
uint8_t * image = gfx.RDRAM+fb_info.addr; uint8_t * image = gfx.RDRAM + fb_info.addr;
uint32_t width256 = ((width-1) >> 8) + 1; uint32_t width256 = ((width - 1) >> 8) + 1;
uint32_t height256 = ((height-1) >> 8) + 1; uint32_t height256 = ((height - 1) >> 8) + 1;
t_info.smallLodLog2 = t_info.largeLodLog2 = GR_LOD_LOG2_256; t_info.smallLodLog2 = t_info.largeLodLog2 = GR_LOD_LOG2_256;
t_info.aspectRatioLog2 = GR_ASPECT_LOG2_1x1; t_info.aspectRatioLog2 = GR_ASPECT_LOG2_1x1;
t_info.format = GR_TEXFMT_ALPHA_INTENSITY_88; t_info.format = GR_TEXFMT_ALPHA_INTENSITY_88;
uint16_t * tex = (uint16_t*)texture_buffer; uint16_t * tex = (uint16_t*)texture_buffer;
t_info.data = tex; t_info.data = tex;
uint32_t tex_size = grTexTextureMemRequired (GR_MIPMAPLEVELMASK_BOTH, &t_info); uint32_t tex_size = grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &t_info);
int tmu = SetupFBtoScreenCombiner(tex_size*width256*height256, fb_info.opaque); int tmu = SetupFBtoScreenCombiner(tex_size*width256*height256, fb_info.opaque);
grConstantColorValue (rdp.fog_color); grConstantColorValue(rdp.fog_color);
grColorCombine (GR_COMBINE_FUNCTION_SCALE_OTHER, grColorCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,
GR_COMBINE_FACTOR_ONE, GR_COMBINE_FACTOR_ONE,
GR_COMBINE_LOCAL_NONE, GR_COMBINE_LOCAL_NONE,
GR_COMBINE_OTHER_CONSTANT, GR_COMBINE_OTHER_CONSTANT,
FXFALSE); FXFALSE);
uint16_t * src = (uint16_t*)image; uint16_t * src = (uint16_t*)image;
src += fb_info.ul_x + fb_info.ul_y * fb_info.width; src += fb_info.ul_x + fb_info.ul_y * fb_info.width;
uint32_t w_tail = width%256; uint32_t w_tail = width % 256;
uint32_t h_tail = height%256; uint32_t h_tail = height % 256;
uint32_t cur_width, cur_height, cur_tail; uint32_t cur_width, cur_height, cur_tail;
uint32_t tex_adr = voodoo.tex_min_addr[tmu]+voodoo.tmem_ptr[tmu]; uint32_t tex_adr = voodoo.tex_min_addr[tmu] + voodoo.tmem_ptr[tmu];
if ((voodoo.tmem_ptr[tmu] < TEXMEM_2MB_EDGE) && (voodoo.tmem_ptr[tmu]+tex_size*width256*height256 > TEXMEM_2MB_EDGE)) if ((voodoo.tmem_ptr[tmu] < TEXMEM_2MB_EDGE) && (voodoo.tmem_ptr[tmu] + tex_size*width256*height256 > TEXMEM_2MB_EDGE))
{ {
tex_adr = TEXMEM_2MB_EDGE; tex_adr = TEXMEM_2MB_EDGE;
} }
@ -464,38 +463,38 @@ static void DrawDepthBufferToScreen256(FB_TO_SCREEN_INFO & fb_info)
{ {
for (uint32_t w = 0; w < width256; w++) for (uint32_t w = 0; w < width256; w++)
{ {
cur_width = (256*(w+1) < width) ? 256 : w_tail; cur_width = (256 * (w + 1) < width) ? 256 : w_tail;
cur_height = (256*(h+1) < height) ? 256 : h_tail; cur_height = (256 * (h + 1) < height) ? 256 : h_tail;
cur_tail = 256 - cur_width; cur_tail = 256 - cur_width;
uint16_t * dst = tex; uint16_t * dst = tex;
for (uint32_t y=0; y < cur_height; y++) for (uint32_t y = 0; y < cur_height; y++)
{ {
for (uint32_t x=0; x < cur_width; x++) for (uint32_t x = 0; x < cur_width; x++)
{ {
*(dst++) = rdp.pal_8[src[(x+256*w+(y+256*h)*fb_info.width)^1]>>8]; *(dst++) = rdp.pal_8[src[(x + 256 * w + (y + 256 * h)*fb_info.width) ^ 1] >> 8];
} }
dst += cur_tail; dst += cur_tail;
} }
grTexDownloadMipMap (tmu, tex_adr, GR_MIPMAPLEVELMASK_BOTH, &t_info); grTexDownloadMipMap(tmu, tex_adr, GR_MIPMAPLEVELMASK_BOTH, &t_info);
grTexSource (tmu, tex_adr, GR_MIPMAPLEVELMASK_BOTH, &t_info); grTexSource(tmu, tex_adr, GR_MIPMAPLEVELMASK_BOTH, &t_info);
tex_adr += tex_size; tex_adr += tex_size;
float ul_x = (float)(fb_info.ul_x + 256*w); float ul_x = (float)(fb_info.ul_x + 256 * w);
float ul_y = (float)(fb_info.ul_y + 256*h); float ul_y = (float)(fb_info.ul_y + 256 * h);
float lr_x = (ul_x + (float)(cur_width)) * rdp.scale_x + rdp.offset_x; float lr_x = (ul_x + (float)(cur_width)) * rdp.scale_x + rdp.offset_x;
float lr_y = (ul_y + (float)(cur_height)) * rdp.scale_y + rdp.offset_y; float lr_y = (ul_y + (float)(cur_height)) * rdp.scale_y + rdp.offset_y;
ul_x = ul_x * rdp.scale_x + rdp.offset_x; ul_x = ul_x * rdp.scale_x + rdp.offset_x;
ul_y = ul_y * rdp.scale_y + rdp.offset_y; ul_y = ul_y * rdp.scale_y + rdp.offset_y;
float lr_u = (float)(cur_width-1); float lr_u = (float)(cur_width - 1);
float lr_v = (float)(cur_height-1); float lr_v = (float)(cur_height - 1);
// Make the vertices // Make the vertices
VERTEX v[4] = { VERTEX v[4] = {
{ ul_x, ul_y, 1, 1, 0.5f, 0.5f, 0.5f, 0.5f, {0.5f, 0.5f, 0.5f, 0.5f} }, { ul_x, ul_y, 1, 1, 0.5f, 0.5f, 0.5f, 0.5f, { 0.5f, 0.5f, 0.5f, 0.5f } },
{ lr_x, ul_y, 1, 1, lr_u, 0.5f, lr_u, 0.5f, {lr_u, 0.5f, lr_u, 0.5f} }, { lr_x, ul_y, 1, 1, lr_u, 0.5f, lr_u, 0.5f, { lr_u, 0.5f, lr_u, 0.5f } },
{ ul_x, lr_y, 1, 1, 0.5f, lr_v, 0.5f, lr_v, {0.5f, lr_v, 0.5f, lr_v} }, { ul_x, lr_y, 1, 1, 0.5f, lr_v, 0.5f, lr_v, { 0.5f, lr_v, 0.5f, lr_v } },
{ lr_x, lr_y, 1, 1, lr_u, lr_v, lr_u, lr_v, {lr_u, lr_v, lr_u, lr_v} } { lr_x, lr_y, 1, 1, lr_u, lr_v, lr_u, lr_v, { lr_u, lr_v, lr_u, lr_v } }
}; };
grDrawTriangle (&v[0], &v[2], &v[1]); grDrawTriangle(&v[0], &v[2], &v[1]);
grDrawTriangle (&v[2], &v[3], &v[1]); grDrawTriangle(&v[2], &v[3], &v[1]);
} }
} }
} }
@ -514,40 +513,40 @@ static void DrawHiresDepthBufferToScreen(FB_TO_SCREEN_INFO & fb_info)
t_info.format = GR_TEXFMT_ALPHA_INTENSITY_88; t_info.format = GR_TEXFMT_ALPHA_INTENSITY_88;
t_info.smallLodLog2 = t_info.largeLodLog2 = LOD; t_info.smallLodLog2 = t_info.largeLodLog2 = LOD;
t_info.aspectRatioLog2 = GR_ASPECT_LOG2_1x1; t_info.aspectRatioLog2 = GR_ASPECT_LOG2_1x1;
grConstantColorValue (rdp.fog_color); grConstantColorValue(rdp.fog_color);
grColorCombine (GR_COMBINE_FUNCTION_LOCAL, grColorCombine(GR_COMBINE_FUNCTION_LOCAL,
GR_COMBINE_FACTOR_NONE, GR_COMBINE_FACTOR_NONE,
GR_COMBINE_LOCAL_CONSTANT, GR_COMBINE_LOCAL_CONSTANT,
GR_COMBINE_OTHER_NONE, GR_COMBINE_OTHER_NONE,
FXFALSE); FXFALSE);
grAlphaCombine (GR_COMBINE_FUNCTION_SCALE_OTHER, grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,
GR_COMBINE_FACTOR_ONE, GR_COMBINE_FACTOR_ONE,
GR_COMBINE_LOCAL_NONE, GR_COMBINE_LOCAL_NONE,
GR_COMBINE_OTHER_TEXTURE, GR_COMBINE_OTHER_TEXTURE,
FXFALSE); FXFALSE);
grAlphaBlendFunction( GR_BLEND_SRC_ALPHA, grAlphaBlendFunction(GR_BLEND_SRC_ALPHA,
GR_BLEND_ONE_MINUS_SRC_ALPHA, GR_BLEND_ONE_MINUS_SRC_ALPHA,
GR_BLEND_ONE, GR_BLEND_ONE,
GR_BLEND_ZERO); GR_BLEND_ZERO);
grDepthBufferFunction (GR_CMP_ALWAYS); grDepthBufferFunction(GR_CMP_ALWAYS);
grDepthMask (FXFALSE); grDepthMask(FXFALSE);
grCullMode (GR_CULL_DISABLE); grCullMode(GR_CULL_DISABLE);
grTexCombine( GR_TMU1, grTexCombine(GR_TMU1,
GR_COMBINE_FUNCTION_NONE, GR_COMBINE_FUNCTION_NONE,
GR_COMBINE_FACTOR_NONE, GR_COMBINE_FACTOR_NONE,
GR_COMBINE_FUNCTION_NONE, GR_COMBINE_FUNCTION_NONE,
GR_COMBINE_FACTOR_NONE, GR_COMBINE_FACTOR_NONE,
FXFALSE, FXFALSE,
FXFALSE ); FXFALSE);
grTexCombine( GR_TMU0, grTexCombine(GR_TMU0,
GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FUNCTION_LOCAL,
GR_COMBINE_FACTOR_NONE, GR_COMBINE_FACTOR_NONE,
GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FUNCTION_LOCAL,
GR_COMBINE_FACTOR_NONE, GR_COMBINE_FACTOR_NONE,
FXFALSE, FXFALSE,
FXFALSE); FXFALSE);
// grAuxBufferExt( GR_BUFFER_AUXBUFFER ); // grAuxBufferExt( GR_BUFFER_AUXBUFFER );
grTexSource( rdp.texbufs[0].tmu, rdp.texbufs[0].begin, GR_MIPMAPLEVELMASK_BOTH, &(t_info) ); grTexSource(rdp.texbufs[0].tmu, rdp.texbufs[0].begin, GR_MIPMAPLEVELMASK_BOTH, &(t_info));
float ul_x = (float)rdp.scissor.ul_x; float ul_x = (float)rdp.scissor.ul_x;
float ul_y = (float)rdp.scissor.ul_y; float ul_y = (float)rdp.scissor.ul_y;
float lr_x = (float)rdp.scissor.lr_x; float lr_x = (float)rdp.scissor.lr_x;
@ -558,14 +557,14 @@ static void DrawHiresDepthBufferToScreen(FB_TO_SCREEN_INFO & fb_info)
float lr_v = (float)rdp.scissor.lr_y * scale; float lr_v = (float)rdp.scissor.lr_y * scale;
// Make the vertices // Make the vertices
VERTEX v[4] = { VERTEX v[4] = {
{ ul_x, ul_y, 1, 1, ul_u, ul_v, ul_u, ul_v, {ul_u, ul_v, ul_u, ul_v} }, { ul_x, ul_y, 1, 1, ul_u, ul_v, ul_u, ul_v, { ul_u, ul_v, ul_u, ul_v } },
{ lr_x, ul_y, 1, 1, lr_u, ul_v, lr_u, ul_v, {lr_u, ul_v, lr_u, ul_v} }, { lr_x, ul_y, 1, 1, lr_u, ul_v, lr_u, ul_v, { lr_u, ul_v, lr_u, ul_v } },
{ ul_x, lr_y, 1, 1, ul_u, lr_v, ul_u, lr_v, {ul_u, lr_v, ul_u, lr_v} }, { ul_x, lr_y, 1, 1, ul_u, lr_v, ul_u, lr_v, { ul_u, lr_v, ul_u, lr_v } },
{ lr_x, lr_y, 1, 1, lr_u, lr_v, lr_u, lr_v, {lr_u, lr_v, lr_u, lr_v} } { lr_x, lr_y, 1, 1, lr_u, lr_v, lr_u, lr_v, { lr_u, lr_v, lr_u, lr_v } }
}; };
grDrawTriangle (&v[0], &v[2], &v[1]); grDrawTriangle(&v[0], &v[2], &v[1]);
grDrawTriangle (&v[2], &v[3], &v[1]); grDrawTriangle(&v[2], &v[3], &v[1]);
// grAuxBufferExt( GR_BUFFER_TEXTUREAUXBUFFER_EXT ); // grAuxBufferExt( GR_BUFFER_TEXTUREAUXBUFFER_EXT );
rdp.update |= UPDATE_COMBINE | UPDATE_ZBUF_ENABLED | UPDATE_CULL_MODE; rdp.update |= UPDATE_COMBINE | UPDATE_ZBUF_ENABLED | UPDATE_CULL_MODE;
} }
@ -585,7 +584,7 @@ void DrawDepthBufferToScreen(FB_TO_SCREEN_INFO & fb_info)
} }
FRDP("DrawDepthBufferToScreen. ul_x=%d, ul_y=%d, lr_x=%d, lr_y=%d, size=%d, addr=%08lx\n", fb_info.ul_x, fb_info.ul_y, fb_info.lr_x, fb_info.lr_y, fb_info.size, fb_info.addr); FRDP("DrawDepthBufferToScreen. ul_x=%d, ul_y=%d, lr_x=%d, lr_y=%d, size=%d, addr=%08lx\n", fb_info.ul_x, fb_info.ul_y, fb_info.lr_x, fb_info.lr_y, fb_info.size, fb_info.addr);
GrTexInfo t_info; GrTexInfo t_info;
uint8_t * image = gfx.RDRAM+fb_info.addr; uint8_t * image = gfx.RDRAM + fb_info.addr;
uint32_t texwidth; uint32_t texwidth;
float scale; float scale;
if (width <= 256) if (width <= 256)
@ -601,7 +600,7 @@ void DrawDepthBufferToScreen(FB_TO_SCREEN_INFO & fb_info)
t_info.smallLodLog2 = t_info.largeLodLog2 = GR_LOD_LOG2_512; t_info.smallLodLog2 = t_info.largeLodLog2 = GR_LOD_LOG2_512;
} }
if (height <= (texwidth>>1)) if (height <= (texwidth >> 1))
{ {
t_info.aspectRatioLog2 = GR_ASPECT_LOG2_2x1; t_info.aspectRatioLog2 = GR_ASPECT_LOG2_2x1;
} }
@ -614,46 +613,46 @@ void DrawDepthBufferToScreen(FB_TO_SCREEN_INFO & fb_info)
uint16_t * dst = tex; uint16_t * dst = tex;
uint16_t * src = (uint16_t*)image; uint16_t * src = (uint16_t*)image;
src += fb_info.ul_x + fb_info.ul_y * fb_info.width; src += fb_info.ul_x + fb_info.ul_y * fb_info.width;
for (uint32_t y=0; y < height; y++) for (uint32_t y = 0; y < height; y++)
{ {
for (uint32_t x=0; x < width; x++) for (uint32_t x = 0; x < width; x++)
{ {
*(dst++) = rdp.pal_8[src[(x+y*fb_info.width)^1]>>8]; *(dst++) = rdp.pal_8[src[(x + y*fb_info.width) ^ 1] >> 8];
} }
dst += texwidth-width; dst += texwidth - width;
} }
t_info.format = GR_TEXFMT_ALPHA_INTENSITY_88; t_info.format = GR_TEXFMT_ALPHA_INTENSITY_88;
t_info.data = tex; t_info.data = tex;
int tmu = SetupFBtoScreenCombiner(grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &t_info), fb_info.opaque); int tmu = SetupFBtoScreenCombiner(grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &t_info), fb_info.opaque);
grConstantColorValue (rdp.fog_color); grConstantColorValue(rdp.fog_color);
grColorCombine (GR_COMBINE_FUNCTION_SCALE_OTHER, grColorCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,
GR_COMBINE_FACTOR_ONE, GR_COMBINE_FACTOR_ONE,
GR_COMBINE_LOCAL_NONE, GR_COMBINE_LOCAL_NONE,
GR_COMBINE_OTHER_CONSTANT, GR_COMBINE_OTHER_CONSTANT,
FXFALSE); FXFALSE);
grTexDownloadMipMap (tmu, grTexDownloadMipMap(tmu,
voodoo.tex_min_addr[tmu]+voodoo.tmem_ptr[tmu], voodoo.tex_min_addr[tmu] + voodoo.tmem_ptr[tmu],
GR_MIPMAPLEVELMASK_BOTH, GR_MIPMAPLEVELMASK_BOTH,
&t_info); &t_info);
grTexSource (tmu, grTexSource(tmu,
voodoo.tex_min_addr[tmu]+voodoo.tmem_ptr[tmu], voodoo.tex_min_addr[tmu] + voodoo.tmem_ptr[tmu],
GR_MIPMAPLEVELMASK_BOTH, GR_MIPMAPLEVELMASK_BOTH,
&t_info); &t_info);
float ul_x = fb_info.ul_x * rdp.scale_x + rdp.offset_x; float ul_x = fb_info.ul_x * rdp.scale_x + rdp.offset_x;
float ul_y = fb_info.ul_y * rdp.scale_y + rdp.offset_y; float ul_y = fb_info.ul_y * rdp.scale_y + rdp.offset_y;
float lr_x = fb_info.lr_x * rdp.scale_x + rdp.offset_x; float lr_x = fb_info.lr_x * rdp.scale_x + rdp.offset_x;
float lr_y = fb_info.lr_y * rdp.scale_y + rdp.offset_y; float lr_y = fb_info.lr_y * rdp.scale_y + rdp.offset_y;
float lr_u = (width-1)*scale; float lr_u = (width - 1)*scale;
float lr_v = (height-1)*scale; float lr_v = (height - 1)*scale;
float zero = scale*0.5f; float zero = scale*0.5f;
// Make the vertices // Make the vertices
VERTEX v[4] = { VERTEX v[4] = {
{ ul_x, ul_y, 1, 1, zero, zero, zero, zero, {zero, zero, zero, zero} }, { ul_x, ul_y, 1, 1, zero, zero, zero, zero, { zero, zero, zero, zero } },
{ lr_x, ul_y, 1, 1, lr_u, zero, lr_u, zero, {lr_u, zero, lr_u, zero} }, { lr_x, ul_y, 1, 1, lr_u, zero, lr_u, zero, { lr_u, zero, lr_u, zero } },
{ ul_x, lr_y, 1, 1, zero, lr_v, zero, lr_v, {zero, lr_v, zero, lr_v} }, { ul_x, lr_y, 1, 1, zero, lr_v, zero, lr_v, { zero, lr_v, zero, lr_v } },
{ lr_x, lr_y, 1, 1, lr_u, lr_v, lr_u, lr_v, {lr_u, lr_v, lr_u, lr_v} } { lr_x, lr_y, 1, 1, lr_u, lr_v, lr_u, lr_v, { lr_u, lr_v, lr_u, lr_v } }
}; };
grDrawTriangle (&v[0], &v[2], &v[1]); grDrawTriangle(&v[0], &v[2], &v[1]);
grDrawTriangle (&v[2], &v[3], &v[1]); grDrawTriangle(&v[2], &v[3], &v[1]);
} }