[Glide64] New trace method

This commit is contained in:
zilmar 2016-02-04 21:22:19 +11:00
parent e9c3d01d38
commit 4921024636
13 changed files with 193 additions and 293 deletions

View File

@ -41,6 +41,7 @@
#include "Gfx_1.3.h"
#include "Util.h"
#include "Combine.h"
#include "trace.h"
#define FASTSEARCH // Enable fast combine mode searching algorithm
@ -152,8 +153,8 @@ COMBINE cmb;
cmb.tmu1_func = GR_COMBINE_FUNCTION_LOCAL, \
cmb.tmu0_func = GR_COMBINE_FUNCTION_SCALE_OTHER, \
cmb.tmu0_fac = GR_COMBINE_FACTOR_ONE; \
} \
else { \
} \
else { \
USE_T0(); \
}
#define T0_ADD_T1() \
@ -189,13 +190,13 @@ COMBINE cmb;
#define T0_INTER_T1_USING_FACTOR(factor) \
if (factor == 0xFF) { \
USE_T1(); \
} \
else if (factor == 0x00) { \
} \
else if (factor == 0x00) { \
USE_T0(); \
}\
else {\
else {\
if (factor <= 0x80) rdp.best_tex = 0; \
else rdp.best_tex = 1; \
else rdp.best_tex = 1; \
cmb.tex |= 3, \
cmb.tmu1_func = GR_COMBINE_FUNCTION_LOCAL, \
cmb.tmu0_func = GR_COMBINE_FUNCTION_BLEND, \
@ -206,13 +207,13 @@ COMBINE cmb;
#define T1_INTER_T0_USING_FACTOR(factor) /* inverse of above */\
if (factor == 0xFF) { \
USE_T0(); \
} \
else if (factor == 0x00) { \
} \
else if (factor == 0x00) { \
USE_T1(); \
}\
else {\
else {\
if (factor <= 0x80) rdp.best_tex = 0; \
else rdp.best_tex = 1; \
else rdp.best_tex = 1; \
cmb.tex |= 3, \
cmb.tmu1_func = GR_COMBINE_FUNCTION_LOCAL, \
cmb.tmu0_func = GR_COMBINE_FUNCTION_BLEND, \
@ -235,8 +236,8 @@ COMBINE cmb;
#define T0_INTER_T1_USING_T1() \
if (!cmb.combine_ext) { \
T0_INTER_T1_USING_FACTOR(0x7F); \
}\
else {\
}\
else {\
rdp.best_tex = 0; \
cmb.tex |= 3, \
cmb.t1c_ext_a = GR_CMBX_LOCAL_TEXTURE_RGB, \
@ -266,8 +267,8 @@ COMBINE cmb;
#define T0_INTER_T1_USING_PRIM() \
if (!cmb.combine_ext) { \
T0_INTER_T1_USING_FACTOR ((rdp.prim_color&0xFF)); \
}\
else {\
}\
else {\
rdp.best_tex = 0; \
cmb.tex |= 3, \
cmb.t1c_ext_a = GR_CMBX_LOCAL_TEXTURE_RGB, \
@ -292,8 +293,8 @@ COMBINE cmb;
#define T1_INTER_T0_USING_PRIM() /* inverse of above */\
if (!cmb.combine_ext) { \
T1_INTER_T0_USING_FACTOR ((rdp.prim_color&0xFF)); \
}\
else {\
}\
else {\
rdp.best_tex = 0; \
cmb.tex |= 3, \
cmb.t1c_ext_a = GR_CMBX_LOCAL_TEXTURE_RGB, \
@ -318,8 +319,8 @@ COMBINE cmb;
#define T0_INTER_T1_USING_ENV() \
if (!cmb.combine_ext) { \
T0_INTER_T1_USING_FACTOR ((rdp.env_color&0xFF)); \
}\
else {\
}\
else {\
rdp.best_tex = 0; \
cmb.tex |= 3, \
cmb.t1c_ext_a = GR_CMBX_LOCAL_TEXTURE_RGB, \
@ -344,8 +345,8 @@ COMBINE cmb;
#define T1_INTER_T0_USING_ENV() /* inverse of above */\
if (!cmb.combine_ext) { \
T1_INTER_T0_USING_FACTOR ((rdp.env_color&0xFF)); \
}\
else {\
}\
else {\
rdp.best_tex = 0; \
cmb.tex |= 3, \
cmb.t1c_ext_a = GR_CMBX_LOCAL_TEXTURE_RGB, \
@ -370,8 +371,8 @@ COMBINE cmb;
#define T0_INTER_T1_USING_SHADEA() \
if (!cmb.combine_ext) { \
T0_INTER_T1_USING_FACTOR (0x7F); \
}\
else {\
}\
else {\
rdp.best_tex = 0; \
cmb.tex |= 3, \
cmb.t1c_ext_a = GR_CMBX_LOCAL_TEXTURE_RGB, \
@ -395,8 +396,8 @@ COMBINE cmb;
#define T1_INTER_T0_USING_SHADEA() \
if (!cmb.combine_ext) { \
T0_INTER_T1_USING_FACTOR (0x7F); \
}\
else {\
}\
else {\
rdp.best_tex = 0; \
cmb.tex |= 3, \
cmb.t1c_ext_a = GR_CMBX_LOCAL_TEXTURE_RGB, \
@ -460,7 +461,7 @@ COMBINE cmb;
MOD_0_FAC (lod_frac & 0xFF);
#define T1_SUB_PRIM_MUL_PRIMLOD_ADD_T0() \
if (cmb.combine_ext) \
{ \
{ \
T1CCMBEXT(GR_CMBX_LOCAL_TEXTURE_RGB, GR_FUNC_MODE_X, \
GR_CMBX_TMU_CCOLOR, GR_FUNC_MODE_NEGATIVE_X, \
GR_CMBX_DETAIL_FACTOR, 0, \
@ -473,8 +474,8 @@ COMBINE cmb;
cmb.tex |= 3; \
percent = (float)(lod_frac) / 255.0f; \
cmb.dc0_detailmax = cmb.dc1_detailmax = percent; \
} \
else \
} \
else \
{ \
T0_ADD_T1 (); \
MOD_1 (TMOD_TEX_SUB_COL_MUL_FAC); \
@ -484,8 +485,8 @@ COMBINE cmb;
#define PRIM_INTER_T0_USING_SHADEA() \
if (!cmb.combine_ext) { \
USE_T0 (); \
}\
else {\
}\
else {\
rdp.best_tex = 0; \
cmb.tex |= 1, \
cmb.t0c_ext_a = GR_CMBX_LOCAL_TEXTURE_RGB, \
@ -509,8 +510,8 @@ COMBINE cmb;
cmb.tmu1_a_func = GR_COMBINE_FUNCTION_LOCAL, \
cmb.tmu0_a_func = GR_COMBINE_FUNCTION_SCALE_OTHER, \
cmb.tmu0_a_fac = GR_COMBINE_FACTOR_ONE; \
} \
else { \
} \
else { \
A_USE_T0(); \
}
#define A_T0_ADD_T1() \
@ -554,11 +555,11 @@ COMBINE cmb;
#define A_T0_INTER_T1_USING_FACTOR(factor) \
if (factor == 0xFF) { \
A_USE_T1(); \
} \
else if (factor == 0x00) { \
} \
else if (factor == 0x00) { \
A_USE_T0(); \
}\
else { \
else { \
cmb.tex |= 3, \
cmb.tmu1_a_func = GR_COMBINE_FUNCTION_LOCAL, \
cmb.tmu0_a_func = GR_COMBINE_FUNCTION_BLEND, \
@ -569,11 +570,11 @@ COMBINE cmb;
#define A_T1_INTER_T0_USING_FACTOR(factor) /* inverse of above */\
if (factor == 0xFF) { \
A_USE_T0(); \
} \
else if (factor == 0x00) { \
} \
else if (factor == 0x00) { \
A_USE_T1(); \
}\
else { \
else { \
cmb.tex |= 3, \
cmb.tmu1_a_func = GR_COMBINE_FUNCTION_LOCAL, \
cmb.tmu0_a_func = GR_COMBINE_FUNCTION_BLEND, \
@ -584,8 +585,8 @@ COMBINE cmb;
#define A_T0_INTER_T1_USING_SHADEA() \
if (!cmb.combine_ext) { \
A_T0_INTER_T1_USING_FACTOR (0x7F); \
}\
else {\
}\
else {\
rdp.best_tex = 0; \
cmb.tex |= 3, \
cmb.t1a_ext_a = GR_CMBX_LOCAL_TEXTURE_ALPHA, \
@ -631,7 +632,6 @@ COMBINE cmb;
percent = (float)(rdp.env_color&0xFF) / 255.0f, \
cmb.dc0_detailmax = cmb.dc1_detailmax = percent
// UNIMP - writes to the unimplemented log, if it's enabled
#ifdef UNIMP_LOG
#define UNIMPMODE() { \
@ -15974,12 +15974,12 @@ void CombineBlender()
void InitCombine()
{
LOG("InitCombine() ");
WriteTrace(TraceGlide64, TraceDebug, "-");
memset(&cmb, 0, sizeof(cmb));
const char *extensions = grGetString(GR_EXTENSION);
if (const char * extstr = strstr(extensions, "COMBINE")) {
if (!strncmp(extstr, "COMBINE", 7)) {
LOG("extensions ");
WriteTrace(TraceGlide64, TraceDebug, "extensions");
cmb.grColorCombineExt = (GRCOLORCOMBINEEXT)grColorCombineExt;
cmb.grAlphaCombineExt = (GRCOLORCOMBINEEXT)grAlphaCombineExt;
cmb.grTexColorCombineExt = (GRTEXCOLORCOMBINEEXT)grTexColorCombineExt;
@ -15989,7 +15989,7 @@ void InitCombine()
cmb.grTexColorCombineExt && cmb.grTexAlphaCombineExt)
{
cmb.combine_ext = TRUE;
LOG("initialized.");
WriteTrace(TraceGlide64, TraceDebug, "initialized.");
}
else
{
@ -16000,7 +16000,6 @@ void InitCombine()
cmb.dc0_lodbias = cmb.dc1_lodbias = 31;
cmb.dc0_detailscale = cmb.dc1_detailscale = 7;
cmb.lodbias0 = cmb.lodbias1 = 1.0f;
LOG("\n");
}
void ColorCombinerToExtension()

View File

@ -47,6 +47,7 @@
#include "Gfx_1.3.h"
#include "DepthBufferRender.h"
#include "Config.h"
#include "trace.h"
#ifdef _WIN32
#include <Common/CriticalSection.h>
@ -1073,7 +1074,7 @@ output: none
*******************************************************************/
void CALL DllConfig(HWND hParent)
{
LOG("DllConfig ()\n");
WriteTrace(TraceGlide64, TraceDebug, "-");
#ifdef _WIN32
CGuard guard(*g_ProcessDListCS);
ReadSettings();

View File

@ -102,7 +102,6 @@ extern "C" {
// ********************************
// ** TAKE OUT BEFORE RELEASE!!! **
//#define LOGGING // log of spec functions called
//#define LOG_KEY // says "Key!!!" in the log when space bar is pressed
//#define LOG_UCODE
@ -192,13 +191,6 @@ extern "C" {
extern int64 perf_next;
#endif
#ifdef LOGGING
extern std::ofstream loga;
#define LOG(x) loga.open("glide64_log.txt",std::ios::app); loga << x; loga.flush(); loga.close();
#else
#define LOG(x)
#endif
#ifdef RDP_LOGGING
extern int log_open;
extern std::ofstream rdp_log;

View File

@ -65,10 +65,6 @@ int ghq_dmptex_toggle_key = 0;
std::ofstream extlog;
#endif
#ifdef LOGGING
std::ofstream loga;
#endif
#ifdef RDP_LOGGING
int log_open = FALSE;
std::ofstream rdp_log;
@ -217,12 +213,8 @@ void _ChangeSize()
rdp.vi_height = (vend - vstart) * fscale_y * 1.0126582f;
float aspect = (g_settings->adjust_aspect && (fscale_y > fscale_x) && (rdp.vi_width > rdp.vi_height)) ? fscale_x / fscale_y : 1.0f;
#ifdef LOGGING
sprintf (out_buf, "hstart: %d, hend: %d, vstart: %d, vend: %d\n", hstart, hend, vstart, vend);
LOG (out_buf);
sprintf (out_buf, "size: %d x %d\n", (int)rdp.vi_width, (int)rdp.vi_height);
LOG (out_buf);
#endif
WriteTrace(TraceResolution, TraceDebug, "hstart: %d, hend: %d, vstart: %d, vend: %d\n", hstart, hend, vstart, vend);
WriteTrace(TraceResolution, TraceDebug, "size: %d x %d\n", (int)rdp.vi_width, (int)rdp.vi_height);
rdp.scale_x = (float)g_settings->res_x / rdp.vi_width;
if (region > 0 && g_settings->pal230)
@ -566,12 +558,12 @@ void WriteSettings(bool saveEmulationSettings)
SetSetting(Set_wrpAnisotropic, g_settings->wrpAnisotropic);
#ifndef _ENDUSER_RELEASE_
SetSetting(Set_autodetect_ucode,g_settings->autodetect_ucode);
SetSetting(Set_ucode,(int)g_settings->ucode);
SetSetting(Set_wireframe,g_settings->wireframe);
SetSetting(Set_wfmode,g_settings->wfmode);
SetSetting(Set_logging,g_settings->logging);
SetSetting(Set_log_clear,g_settings->log_clear);
SetSetting(Set_autodetect_ucode, g_settings->autodetect_ucode);
SetSetting(Set_ucode, (int)g_settings->ucode);
SetSetting(Set_wireframe, g_settings->wireframe);
SetSetting(Set_wfmode, g_settings->wfmode);
SetSetting(Set_logging, g_settings->logging);
SetSetting(Set_log_clear, g_settings->log_clear);
SetSetting(Set_run_in_window,g_settings->run_in_window);
SetSetting(Set_elogging,g_settings->elogging);
SetSetting(Set_filter_cache,g_settings->filter_cache);
@ -804,7 +796,7 @@ int InitGfx()
OPEN_RDP_LOG(); // doesn't matter if opens again; it will check for it
OPEN_RDP_E_LOG();
LOG("InitGfx ()\n");
WriteTrace(TraceGlide64, TraceDebug, "-");
debugging = FALSE;
rdp_reset();
@ -859,7 +851,7 @@ int InitGfx()
// we get better texture cache hits with UMA on
grEnable(GR_TEXTURE_UMA_EXT);
voodoo.tex_UMA = TRUE;
LOG("Using TEXUMA extension.\n");
WriteTrace(TraceGlide64, TraceDebug, "Using TEXUMA extension");
}
//*/
@ -1099,7 +1091,7 @@ int InitGfx()
void ReleaseGfx()
{
LOG("ReleaseGfx ()\n");
WriteTrace(TraceGlide64, TraceDebug, "-");
// Restore gamma settings
if (voodoo.gamma_correction)
@ -1176,12 +1168,10 @@ CriticalSection * g_ProcessDListCS = NULL;
extern "C" int WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID /*lpReserved*/)
{
sprintf(out_buf, "DllMain (%0p - %d)\n", hinst, fdwReason);
LOG(out_buf);
if (fdwReason == DLL_PROCESS_ATTACH)
{
hinstDLL = hinst;
SetupTrace();
if (g_ProcessDListCS == NULL)
{
g_ProcessDListCS = new CriticalSection();
@ -1265,7 +1255,7 @@ void CALL ReadScreen(void **dest, int *width, int *height)
// Unlock the frontbuffer
grLfbUnlock(GR_LFB_READ_ONLY, GR_BUFFER_FRONTBUFFER);
}
LOG("ReadScreen. Success.\n");
WriteTrace(TraceGlide64, TraceDebug, "Success");
}
/******************************************************************
@ -1290,7 +1280,7 @@ output: none
*******************************************************************/
EXPORT void CALL ChangeWindow(void)
{
LOG("ChangeWindow()\n");
WriteTrace(TraceGlide64, TraceDebug, "-");
if (evoodoo)
{
@ -1357,7 +1347,7 @@ output: none
*******************************************************************/
void CALL CloseDLL(void)
{
LOG("CloseDLL ()\n");
WriteTrace(TraceGlide64, TraceDebug, "-");
// re-set the old window proc
#ifdef WINPROC_OVERRIDE
@ -1369,7 +1359,7 @@ void CALL CloseDLL(void)
{
UnhookWindowsHookEx(hhkLowLevelKybd);
hhkLowLevelKybd = 0;
}
}
#endif
//CLOSELOG ();
@ -1420,7 +1410,7 @@ output: none
*******************************************************************/
void CALL DrawScreen(void)
{
LOG("DrawScreen ()\n");
WriteTrace(TraceGlide64, TraceDebug, "-");
}
/******************************************************************
@ -1433,7 +1423,7 @@ output: none
*******************************************************************/
void CALL GetDllInfo(PLUGIN_INFO * PluginInfo)
{
LOG("GetDllInfo ()\n");
WriteTrace(TraceGlide64, TraceDebug, "-");
PluginInfo->Version = 0x0104; // Set to 0x0104
PluginInfo->Type = PLUGIN_TYPE_GFX; // Set to PLUGIN_TYPE_GFX
#ifdef _DEBUG
@ -1539,7 +1529,7 @@ void CALL MoveScreen(int xpos, int ypos)
{
xpos = xpos;
ypos = ypos;
LOG("MoveScreen (" << xpos << ", " << ypos << ")\n");
WriteTrace(TraceGlide64, TraceDebug, "xpos: %d ypos: %d", xpos, ypos);
rdp.window_changed = TRUE;
}
@ -1550,7 +1540,6 @@ void CALL PluginLoaded(void)
Set_texture_dir = FindSystemSettingId("Dir:Texture");
Set_log_flush = FindSystemSettingId("Log Auto Flush");
Set_log_dir = FindSystemSettingId("Dir:Log");
SetupTrace();
WriteTrace(TraceInterface, TraceDebug, "Start");
@ -1651,7 +1640,7 @@ output: none
*******************************************************************/
void CALL RomClosed(void)
{
LOG("RomClosed ()\n");
WriteTrace(TraceGlide64, TraceDebug, "-");
CLOSE_RDP_LOG();
CLOSE_RDP_E_LOG();
@ -1691,7 +1680,7 @@ output: none
*******************************************************************/
void CALL RomOpen(void)
{
LOG("RomOpen ()\n");
WriteTrace(TraceGlide64, TraceDebug, "-");
no_dlist = true;
romopen = TRUE;
ucode_error_report = TRUE; // allowed to report ucode errors
@ -1784,13 +1773,13 @@ output: none
bool no_dlist = true;
void CALL ShowCFB(void)
{
WriteTrace(TraceGlide64, TraceDebug, "-");
no_dlist = true;
LOG("ShowCFB ()\n");
}
void drawViRegBG()
{
LRDP("drawViRegBG\n");
WriteTrace(TraceGlide64, TraceDebug, "-");
const uint32_t VIwidth = *gfx.VI_WIDTH_REG;
FB_TO_SCREEN_INFO fb_info;
fb_info.width = VIwidth;
@ -1848,10 +1837,7 @@ void CALL UpdateScreen(void)
LOG("KEY!!!\n");
}
#endif
char out_buf[128];
sprintf(out_buf, "UpdateScreen (). Origin: %08x, Old origin: %08x, width: %d\n", *gfx.VI_ORIGIN_REG, rdp.vi_org_reg, *gfx.VI_WIDTH_REG);
LOG(out_buf);
LRDP(out_buf);
WriteTrace(TraceGlide64, TraceDebug, "Origin: %08x, Old origin: %08x, width: %d\n", *gfx.VI_ORIGIN_REG, rdp.vi_org_reg, *gfx.VI_WIDTH_REG);
uint32_t width = (*gfx.VI_WIDTH_REG) << 1;
if (*gfx.VI_ORIGIN_REG > width)
@ -2207,7 +2193,7 @@ void newSwapBuffers()
if (fb_hwfbe_enabled && !(g_settings->hacks&hack_RE2) && !evoodoo)
grAuxBufferExt(GR_BUFFER_AUXBUFFER);
LOG("BUFFER SWAPPED\n");
WriteTrace(TraceGlide64, TraceDebug, "BUFFER SWAPPED");
grBufferSwap(g_settings->vsync);
fps_count++;
if (*gfx.VI_STATUS_REG & 0x08) //gamma correction is used

View File

@ -50,6 +50,7 @@
#include "FBtoScreen.h"
#include "CRC.h"
#include <Common/StdString.h>
#include "trace.h"
#ifdef _WIN32
#include <Common/CriticalSection.h>
@ -60,7 +61,7 @@ extern CriticalSection * g_ProcessDListCS;
const int NumOfFormats = 1;
SCREEN_SHOT_FORMAT ScreenShotFormats[NumOfFormats] =
{
{ "PNG", "png", rdpBITMAP_TYPE_PNG},
{ "PNG", "png", rdpBITMAP_TYPE_PNG },
};
const char *ACmp[] = { "NONE", "THRESHOLD", "UNKNOWN", "DITHER" };
@ -547,7 +548,7 @@ void GoToFullScreen()
{
if (!InitGfx())
{
LOG("FAILED!!!\n");
WriteTrace(TraceGlide64, TraceError, "tInitGfx failed");
return;
}
#ifdef __WINDOWS__
@ -594,7 +595,7 @@ EXPORT void CALL ProcessDList(void)
}
#endif
LOG("ProcessDList ()\n");
WriteTrace(TraceGlide64, TraceDebug, "ProcessDList");
if (reset)
{
@ -3114,7 +3115,7 @@ output: none
*******************************************************************/
EXPORT void CALL FBRead(uint32_t addr)
{
LOG("FBRead ()\n");
WriteTrace(TraceGlide64, TraceDebug, "-");
if (cpu_fb_ignore)
return;
@ -3170,16 +3171,9 @@ input: FrameBufferModifyEntry *plist
size = size of the plist, max = 1024
output: none
*******************************************************************/
#ifdef RDP_LOGGING
EXPORT void CALL FBWList(FrameBufferModifyEntry* /*plist*/, uint32_t size)
#else
EXPORT void CALL FBWList(FrameBufferModifyEntry* /*plist*/, uint32_t)
#endif
{
LOG("FBWList ()\n");
#ifdef RDP_LOGGING
FRDP("FBWList. size: %d\n", size);
#endif
WriteTrace(TraceGlide64, TraceDebug, "size: %d", size);
}
/******************************************************************
@ -3193,7 +3187,7 @@ output: none
*******************************************************************/
EXPORT void CALL FBWrite(uint32_t addr, uint32_t /*size*/)
{
LOG("FBWrite ()\n");
WriteTrace(TraceGlide64, TraceDebug, "-");
if (cpu_fb_ignore)
return;
if (cpu_fb_read_called)
@ -3248,7 +3242,7 @@ typedef struct
} FrameBufferInfo;
EXPORT void CALL FBGetFrameBufferInfo(void *p)
{
LOG("FBGetFrameBufferInfo ()\n");
WriteTrace(TraceGlide64, TraceDebug, "-");
FrameBufferInfo * pinfo = (FrameBufferInfo *)p;
memset(pinfo, 0, sizeof(FrameBufferInfo) * 6);
if (!(g_settings->frame_buffer&fb_get_info))
@ -4123,8 +4117,7 @@ void CALL ProcessRDPList(void)
#ifdef _WIN32
CGuard guard(*g_ProcessDListCS);
#endif
LOG("ProcessRDPList ()\n");
LRDP("ProcessRDPList ()\n");
WriteTrace(TraceGlide64, TraceDebug, "-");
uint32_t i;
uint32_t cmd, length, cmd_length;
@ -4176,4 +4169,4 @@ void CALL ProcessRDPList(void)
dp_status &= ~0x0002;
//}
}
}

View File

@ -46,7 +46,7 @@ void SetupTrace(void)
TraceSetMaxModule(MaxTraceModuleGlide64, TraceVerbose);
#else
#ifdef _DEBUG
TraceSetMaxModule(MaxTraceModuleGlide64, TraceVerbose);
TraceSetMaxModule(MaxTraceModuleGlide64, TraceInfo);
#else
TraceSetMaxModule(MaxTraceModuleGlide64, TraceError);
#endif
@ -55,7 +55,10 @@ void SetupTrace(void)
TraceSetModuleName(TraceMD5, "MD5");
TraceSetModuleName(TraceSettings, "Settings");
TraceSetModuleName(TraceUnknown, "Unknown");
TraceSetModuleName(TraceGlide64, "Glide64");
TraceSetModuleName(TraceInterface, "Interface");
TraceSetModuleName(TraceResolution, "Resolution");
TraceSetModuleName(TraceGlitch, "Glitch");
char log_dir[260];
memset(log_dir, 0, sizeof(log_dir));

View File

@ -6,7 +6,10 @@ enum TraceModuleGlide64
{
TraceSettings = MaxTraceModuleCommon,
TraceUnknown,
TraceGlide64,
TraceInterface,
TraceResolution,
TraceGlitch,
MaxTraceModuleGlide64,
};

View File

@ -9,6 +9,7 @@
#include <stdlib.h>
#include "glide.h"
#include "glitchmain.h"
#include <Glide64\trace.h>
static int fct[4], source0[4], operand0[4], source1[4], operand1[4], source2[4], operand2[4];
static int fcta[4], sourcea0[4], operanda0[4], sourcea1[4], operanda1[4], sourcea2[4], operanda2[4];
@ -565,7 +566,7 @@ void set_lambda()
FX_ENTRY void FX_CALL
grConstantColorValue(GrColor_t value)
{
LOG("grConstantColorValue(%d)\r\n", value);
WriteTrace(TraceResolution, TraceDebug, "value: %d", value);
switch (lfb_color_fmt)
{
case GR_COLORFORMAT_ARGB:
@ -713,7 +714,8 @@ GrCombineFunction_t function, GrCombineFactor_t factor,
GrCombineLocal_t local, GrCombineOther_t other,
FxBool invert)
{
LOG("grColorCombine(%d,%d,%d,%d,%d)\r\n", function, factor, local, other, invert);
WriteTrace(TraceResolution, TraceDebug, "function: %d factor: %d local: %d other: %d invert: %d", function, factor, local, other, invert);
static int last_function = 0;
static int last_factor = 0;
static int last_local = 0;
@ -921,7 +923,7 @@ GrCombineLocal_t local, GrCombineOther_t other,
FxBool invert
)
{
LOG("grAlphaCombine(%d,%d,%d,%d,%d)\r\n", function, factor, local, other, invert);
WriteTrace(TraceResolution, TraceDebug, "function: %d factor: %d local: %d other: %d invert: %d", function, factor, local, other, invert);
static int last_function = 0;
static int last_factor = 0;
static int last_local = 0;
@ -1159,7 +1161,7 @@ FxBool rgb_invert,
FxBool alpha_invert
)
{
LOG("grTexCombine(%d,%d,%d,%d,%d,%d,%d)\r\n", tmu, rgb_function, rgb_factor, alpha_function, alpha_factor, rgb_invert, alpha_invert);
WriteTrace(TraceResolution, TraceDebug, "tmu: %d rgb_function: %d rgb_factor: %d alpha_function: %d alpha_factor: %d rgb_invert: %d alpha_invert: %d", tmu, rgb_function, rgb_factor, alpha_function, alpha_factor, rgb_invert, alpha_invert);
int num_tex;
if (tmu == GR_TMU0) num_tex = 1;
@ -1410,7 +1412,7 @@ GrAlphaBlendFnc_t alpha_sf, GrAlphaBlendFnc_t alpha_df
)
{
int sfactorRGB = 0, dfactorRGB = 0, sfactorAlpha = 0, dfactorAlpha = 0;
LOG("grAlphaBlendFunction(%d,%d,%d,%d)\r\n", rgb_sf, rgb_df, alpha_sf, alpha_df);
WriteTrace(TraceResolution, TraceDebug, "rgb_sf: %d rgb_df: %d alpha_sf: %d alpha_df: %d", rgb_sf, rgb_df, alpha_sf, alpha_df);
switch (rgb_sf)
{
@ -1483,7 +1485,7 @@ GrAlphaBlendFnc_t alpha_sf, GrAlphaBlendFnc_t alpha_df
FX_ENTRY void FX_CALL
grAlphaTestReferenceValue(GrAlpha_t value)
{
LOG("grAlphaTestReferenceValue(%d)\r\n", value);
WriteTrace(TraceResolution, TraceDebug, "value: %d", value);
alpha_ref = value;
grAlphaTestFunction(alpha_func);
}
@ -1491,7 +1493,7 @@ grAlphaTestReferenceValue(GrAlpha_t value)
FX_ENTRY void FX_CALL
grAlphaTestFunction(GrCmpFnc_t function)
{
LOG("grAlphaTestFunction(%d)\r\n", function);
WriteTrace(TraceResolution, TraceDebug, "function: %d", function);
alpha_func = function;
switch (function)
{
@ -1520,7 +1522,7 @@ grAlphaTestFunction(GrCmpFnc_t function)
FX_ENTRY void FX_CALL
grFogMode(GrFogMode_t mode)
{
LOG("grFogMode(%d)\r\n", mode);
WriteTrace(TraceResolution, TraceDebug, "mode: %d", mode);
switch (mode)
{
case GR_FOG_DISABLE:
@ -1548,7 +1550,7 @@ grFogMode(GrFogMode_t mode)
FX_ENTRY float FX_CALL
guFogTableIndexToW(int i)
{
LOG("guFogTableIndexToW(%d)\r\n", i);
WriteTrace(TraceResolution, TraceDebug, "i: %d", i);
return (float)(pow(2.0, 3.0 + (double)(i >> 2)) / (8 - (i & 3)));
}
@ -1556,7 +1558,7 @@ FX_ENTRY void FX_CALL
guFogGenerateLinear(GrFog_t * /*fogtable*/,
float nearZ, float farZ)
{
LOG("guFogGenerateLinear(%f,%f)\r\n", nearZ, farZ);
WriteTrace(TraceResolution, TraceDebug, "nearZ: %f farZ: %f", nearZ, farZ);
glFogi(GL_FOG_MODE, GL_LINEAR);
glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
glFogf(GL_FOG_START, nearZ / 255.0f);
@ -1568,14 +1570,14 @@ float nearZ, float farZ)
FX_ENTRY void FX_CALL
grFogTable(const GrFog_t /*ft */[])
{
LOG("grFogTable()\r\n");
WriteTrace(TraceResolution, TraceDebug, "-");
}
FX_ENTRY void FX_CALL
grFogColorValue(GrColor_t fogcolor)
{
float color[4];
LOG("grFogColorValue(%x)\r\n", fogcolor);
WriteTrace(TraceResolution, TraceDebug, "fogcolor: %x", fogcolor);
switch (lfb_color_fmt)
{
@ -1604,7 +1606,7 @@ grFogColorValue(GrColor_t fogcolor)
FX_ENTRY void FX_CALL
grChromakeyMode(GrChromakeyMode_t mode)
{
LOG("grChromakeyMode(%d)\r\n", mode);
WriteTrace(TraceResolution, TraceDebug, "mode: %d", mode);
switch (mode)
{
case GR_CHROMAKEY_DISABLE:
@ -1622,7 +1624,7 @@ grChromakeyMode(GrChromakeyMode_t mode)
FX_ENTRY void FX_CALL
grChromakeyValue(GrColor_t value)
{
LOG("grChromakeyValue(%x)\r\n", value);
WriteTrace(TraceResolution, TraceDebug, "value: %d", value);
int chroma_color_location;
switch (lfb_color_fmt)
@ -1692,7 +1694,7 @@ FX_ENTRY void FX_CALL
grStipplePattern(
GrStipplePattern_t stipple)
{
LOG("grStipplePattern(%x)\r\n", stipple);
WriteTrace(TraceResolution, TraceDebug, "value: %x", stipple);
srand(stipple);
setPattern();
}
@ -1700,7 +1702,7 @@ GrStipplePattern_t stipple)
FX_ENTRY void FX_CALL
grStippleMode(GrStippleMode_t mode)
{
LOG("grStippleMode(%d)\r\n", mode);
WriteTrace(TraceResolution, TraceDebug, "mode: %d", mode);
switch (mode)
{
case GR_STIPPLE_DISABLE:
@ -1735,7 +1737,7 @@ GrCCUColor_t c, FxBool c_invert,
GrCCUColor_t d, FxBool d_invert,
FxU32 shift, FxBool invert)
{
LOG("grColorCombineExt(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d)\r\n", a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
WriteTrace(TraceResolution, TraceDebug, "a: %d a_mode: %d b: %d b_mode: %d c: %d c_invert: %d d: %d d_invert: %d shift: %d invert: %d", a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
if (invert) display_warning("grColorCombineExt : inverted result");
if (shift) display_warning("grColorCombineExt : shift = %d", shift);
@ -1917,7 +1919,7 @@ GrACUColor_t c, FxBool c_invert,
GrACUColor_t d, FxBool d_invert,
FxU32 shift, FxBool invert)
{
LOG("grAlphaCombineExt(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)\r\n", a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
WriteTrace(TraceResolution, TraceDebug, "a: %d a_mode: %d b: %d b_mode: %d c: %d c_invert: %d d: %d d_invert: %d shift: %d invert: %d", a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
if (invert) display_warning("grAlphaCombineExt : inverted result");
if (shift) display_warning("grAlphaCombineExt : shift = %d", shift);
@ -2071,7 +2073,7 @@ GrTCCUColor_t d, FxBool d_invert,
FxU32 shift, FxBool invert)
{
int num_tex;
LOG("grTexColorCombineExt(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)\r\n", tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
WriteTrace(TraceResolution, TraceDebug, "tmu: %d a: %d a_mode: %d b: %d b_mode: %d c: %d c_invert: %d d: %d d_invert: %d shift: %d invert: %d", tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
if (invert) display_warning("grTexColorCombineExt : inverted result");
if (shift) display_warning("grTexColorCombineExt : shift = %d", shift);
@ -2436,7 +2438,7 @@ GrTACUColor_t d, FxBool d_invert,
FxU32 shift, FxBool invert)
{
int num_tex;
LOG("grTexAlphaCombineExt(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)\r\n", tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
WriteTrace(TraceResolution, TraceDebug, "tmu: %d a: %d a_mode: %d b: %d b_mode: %d c: %d c_invert: %d d: %d d_invert: %d shift, invert: %d", tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
if (invert) display_warning("grTexAlphaCombineExt : inverted result");
if (shift) display_warning("grTexAlphaCombineExt : shift = %d", shift);
@ -2716,7 +2718,7 @@ grConstantColorValueExt(GrChipID_t tmu,
GrColor_t value)
{
int num_tex;
LOG("grConstantColorValueExt(%d,%d)\r\n", tmu, value);
WriteTrace(TraceResolution, TraceDebug, "tmu: %d value: %d", tmu, value);
if (tmu == GR_TMU0) num_tex = 1;
else num_tex = 0;

View File

@ -4,6 +4,7 @@
#endif // _WIN32
#include "glide.h"
#include "glitchmain.h"
#include <Glide64\trace.h>
#define Z_MAX (65536.0f)
@ -60,7 +61,7 @@ void init_geometry()
FX_ENTRY void FX_CALL
grCoordinateSpace(GrCoordinateSpaceMode_t mode)
{
LOG("grCoordinateSpace(%d)\r\n", mode);
WriteTrace(TraceGlitch, TraceDebug, "mode: %d", mode);
switch (mode)
{
case GR_WINDOW_COORDS:
@ -73,7 +74,7 @@ grCoordinateSpace(GrCoordinateSpaceMode_t mode)
FX_ENTRY void FX_CALL
grVertexLayout(FxU32 param, FxI32 offset, FxU32 mode)
{
LOG("grVertexLayout(%d,%d,%d)\r\n", param, offset, mode);
WriteTrace(TraceGlitch, TraceDebug, "param: %d offset: %d mode: %d", param, offset, mode);
switch (param)
{
case GR_PARAM_XY:
@ -112,7 +113,7 @@ grVertexLayout(FxU32 param, FxI32 offset, FxU32 mode)
FX_ENTRY void FX_CALL
grCullMode(GrCullMode_t mode)
{
LOG("grCullMode(%d)\r\n", mode);
WriteTrace(TraceGlitch, TraceDebug, "mode: %d", mode);
static int oldmode = -1, oldinv = -1;
culling_mode = mode;
if (inverted_culling == oldinv && oldmode == mode)
@ -149,7 +150,7 @@ grCullMode(GrCullMode_t mode)
FX_ENTRY void FX_CALL
grDepthBufferMode(GrDepthBufferMode_t mode)
{
LOG("grDepthBufferMode(%d)\r\n", mode);
WriteTrace(TraceGlitch, TraceDebug, "mode: %d", mode);
switch (mode)
{
case GR_DEPTHBUFFER_DISABLE:
@ -175,7 +176,7 @@ grDepthBufferMode(GrDepthBufferMode_t mode)
FX_ENTRY void FX_CALL
grDepthBufferFunction(GrCmpFnc_t function)
{
LOG("grDepthBufferFunction(%d)\r\n", function);
WriteTrace(TraceGlitch, TraceDebug, "function: %d", function);
switch (function)
{
case GR_CMP_GEQUAL:
@ -224,7 +225,7 @@ grDepthBufferFunction(GrCmpFnc_t function)
FX_ENTRY void FX_CALL
grDepthMask(FxBool mask)
{
LOG("grDepthMask(%d)\r\n", mask);
WriteTrace(TraceGlitch, TraceDebug, "mask: %d", mask);
glDepthMask((GLboolean)mask);
grDisplayGLError("grDepthMask");
}
@ -292,7 +293,7 @@ void FindBestDepthBias()
FX_ENTRY void FX_CALL
grDepthBiasLevel(FxI32 level)
{
LOG("grDepthBiasLevel(%d)\r\n", level);
WriteTrace(TraceGlitch, TraceDebug, "level: %d", level);
if (level)
{
if (w_buffer_mode)
@ -346,7 +347,7 @@ grDrawTriangle(const void *a, const void *b, const void *c)
float *c_s1 = (float*)c + st1_off / sizeof(float);
float *c_t1 = (float*)c + st1_off / sizeof(float) + 1;
float *c_fog = (float*)c + fog_ext_off / sizeof(float);
LOG("grDrawTriangle()\r\n");
WriteTrace(TraceGlitch, TraceDebug, "-");
// ugly ? i know but nvidia drivers are losing the viewport otherwise
@ -461,7 +462,7 @@ grDrawPoint(const void *pt)
float *s1 = (float*)pt + st1_off / sizeof(float);
float *t1 = (float*)pt + st1_off / sizeof(float) + 1;
float *fog = (float*)pt + fog_ext_off / sizeof(float);
LOG("grDrawPoint()\r\n");
WriteTrace(TraceGlitch, TraceDebug, "-");
if (nvidia_viewport_hack && !render_to_texture)
{
@ -530,7 +531,7 @@ grDrawLine(const void *a, const void *b)
float *b_s1 = (float*)b + st1_off / sizeof(float);
float *b_t1 = (float*)b + st1_off / sizeof(float) + 1;
float *b_fog = (float*)b + fog_ext_off / sizeof(float);
LOG("grDrawLine()\r\n");
WriteTrace(TraceGlitch, TraceDebug, "-");
if (nvidia_viewport_hack && !render_to_texture)
{
@ -606,7 +607,7 @@ grDrawVertexArray(FxU32 mode, FxU32 Count, void *pointers2)
float *x, *y, *q, *s0, *t0, *s1, *t1, *z, *fog;
unsigned char *pargb;
void **pointers = (void**)pointers2;
LOG("grDrawVertexArray(%d,%d)\r\n", mode, Count);
WriteTrace(TraceGlitch, TraceDebug, "mode: %d Count: %d", mode, Count);
if (nvidia_viewport_hack && !render_to_texture)
{
@ -678,7 +679,7 @@ grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count, void *pointers, FxU32 strid
unsigned int i;
float *x, *y, *q, *s0, *t0, *s1, *t1, *z, *fog;
unsigned char *pargb;
LOG("grDrawVertexArrayContiguous(%d,%d,%d)\r\n", mode, Count, stride);
WriteTrace(TraceGlitch, TraceDebug, "mode: %d Count: %d stride: %d", mode, Count, stride);
if (nvidia_viewport_hack && !render_to_texture)
{

View File

@ -17,6 +17,7 @@
#include "glide.h"
#include "g3ext.h"
#include "glitchmain.h"
#include <Glide64\trace.h>
#ifdef VPDEBUG
#include <IL/il.h>
@ -69,23 +70,30 @@ public:
void getResolution(FxU32 _idx, FxU32 * _width, FxU32 * _height, FxU32 * _frequency = 0)
{
LOG("getResolution(%d)\r\n", _idx);
WriteTrace(TraceResolution, TraceDebug, "_idx: %d", _idx);
if (dwNumResolutions == 0)
{
init();
if (_idx >= dwNumResolutions) {
LOG("getResolution error! NumResolutions=%d\r\n", dwNumResolutions);
}
if (_idx >= dwNumResolutions)
{
WriteTrace(TraceGlitch, TraceError, "NumResolutions = %d", dwNumResolutions);
_idx = 0;
}
*_width = (FxU32)aResolutions[_idx].dwW;
*_height = (FxU32)aResolutions[_idx].dwH;
if (_frequency != 0)
{
*_frequency = (FxU32)aResolutions[_idx].dwF;
}
}
char ** getResolutionsList(FxI32 * Size)
{
if (dwNumResolutions == 0)
{
init();
}
*Size = (FxI32)dwNumResolutions;
return aResolutionsStr;
}
@ -102,14 +110,16 @@ private:
FullScreenResolutions::~FullScreenResolutions()
{
for (unsigned int i = 0; i < dwNumResolutions; i++)
{
delete[] aResolutionsStr[i];
}
delete[] aResolutionsStr;
delete[] aResolutions;
}
void FullScreenResolutions::init()
{
LOG("FullScreenResolutions::init()\r\n");
WriteTrace(TraceGlitch, TraceDebug, "executing");
#ifdef _WIN32
DEVMODE enumMode;
int iModeNum = 0;
@ -203,7 +213,7 @@ bool FullScreenResolutions::changeDisplaySettings(FxU32 _resolution)
ResolutionInfo curInfo(enumMode.dmPelsWidth, enumMode.dmPelsHeight, enumMode.dmDisplayFrequency);
if (enumMode.dmBitsPerPel == 32 && curInfo == info) {
bool bRes = ChangeDisplaySettings(&enumMode, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL;
LOG("changeDisplaySettings width=%d, height=%d, freq=%d %s\r\n", enumMode.dmPelsWidth, enumMode.dmPelsHeight, enumMode.dmDisplayFrequency, bRes ? "Success" : "Failed");
WriteTrace(TraceGlitch, TraceDebug, "width=%d, height=%d, freq=%d %s\r\n", enumMode.dmPelsWidth, enumMode.dmPelsHeight, enumMode.dmDisplayFrequency, bRes ? "Success" : "Failed");
return bRes;
}
}
@ -548,90 +558,19 @@ void display_warning(const char *text, ...)
void display_error()
{
LPVOID lpMsgBuf;
if (!FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR)&lpMsgBuf,
0,
NULL))
if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL))
{
// Handle the error.
return;
}
// Process any inserts in lpMsgBuf.
// ...
// Display the string.
MessageBox(NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION);
// Free the buffer.
LocalFree(lpMsgBuf);
}
#endif // _WIN32
#ifdef LOGGING
char out_buf[256];
bool log_open = false;
std::ofstream log_file;
void OPEN_LOG()
{
if (!log_open)
{
log_file.open ("wrapper_log.txt", std::ios_base::out|std::ios_base::app);
log_open = true;
}
}
void CLOSE_LOG()
{
if (log_open)
{
log_file.close();
log_open = false;
}
}
void LOG(const char *text, ...)
{
#ifdef VPDEBUG
if (!dumping) return;
#endif
if (!log_open)
return;
va_list ap;
va_start(ap, text);
vsprintf(out_buf, text, ap);
log_file << out_buf;
log_file.flush();
va_end(ap);
}
class LogManager {
public:
LogManager() {
OPEN_LOG();
}
~LogManager() {
CLOSE_LOG();
}
};
LogManager logManager;
#else // LOGGING
#define OPEN_LOG()
#define CLOSE_LOG()
#define LOG
#endif // LOGGING
FX_ENTRY void FX_CALL
grSstOrigin(GrOriginLocation_t origin)
{
LOG("grSstOrigin(%d)\r\n", origin);
WriteTrace(TraceGlitch, TraceDebug, "origin = %d", origin);
if (origin != GR_ORIGIN_UPPER_LEFT)
display_warning("grSstOrigin : %x", origin);
}
@ -639,7 +578,7 @@ grSstOrigin(GrOriginLocation_t origin)
FX_ENTRY void FX_CALL
grClipWindow(FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy)
{
LOG("grClipWindow(%d,%d,%d,%d)\r\n", minx, miny, maxx, maxy);
WriteTrace(TraceGlitch, TraceDebug, "minx = %d, miny: %d maxy: %d", minx, miny, maxy);
if (use_fbo && render_to_texture) {
if (int(minx) < 0) minx = 0;
@ -678,7 +617,7 @@ grClipWindow(FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy)
FX_ENTRY void FX_CALL
grColorMask(FxBool rgb, FxBool a)
{
LOG("grColorMask(%d, %d)\r\n", rgb, a);
WriteTrace(TraceGlitch, TraceDebug, "rgb = %d, a: %d", rgb, a);
glColorMask((GLboolean)rgb, (GLboolean)rgb, (GLboolean)rgb, (GLboolean)a);
grDisplayGLError("grColorMask");
}
@ -686,13 +625,13 @@ grColorMask(FxBool rgb, FxBool a)
FX_ENTRY void FX_CALL
grGlideInit(void)
{
LOG("grGlideInit()\r\n");
WriteTrace(TraceGlitch, TraceDebug, "-");
}
FX_ENTRY void FX_CALL
grSstSelect(int which_sst)
{
LOG("grSstSelect(%d)\r\n", which_sst);
WriteTrace(TraceGlitch, TraceDebug, "which_sst = %d", which_sst);
}
int isExtensionSupported(const char *extension)
@ -770,11 +709,8 @@ GrPixelFormat_t /*pixelformat*/,
int nColBuffers,
int nAuxBuffers)
{
LOG(
"grSstWinOpenExt(%d, %d, %d, %d, %d, %d %d)\r\n",
hWnd, screen_resolution, refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers);
return grSstWinOpen(
hWnd, screen_resolution, refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers);
WriteTrace(TraceGlitch, TraceDebug, "hWnd: %d, screen_resolution: %d, refresh_rate: %d, color_format: %d, origin_location: %d, nColBuffers: %d, nAuxBuffers: %d", hWnd, screen_resolution, refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers);
return grSstWinOpen(hWnd, screen_resolution, refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers);
}
#ifdef WIN32
@ -820,7 +756,7 @@ int nAuxBuffers)
int pfm;
#endif // _WIN32
LOG("grSstWinOpen(%08lx, %d, %d, %d, %d, %d %d)\r\n", hWnd, screen_resolution&~0x80000000, refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers);
WriteTrace(TraceGlitch, TraceDebug, "hWnd: %d, screen_resolution: %d, refresh_rate: %d, color_format: %d, origin_location: %d, nColBuffers: %d, nAuxBuffers: %d", hWnd, screen_resolution&~0x80000000, refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers);
#ifdef _WIN32
if ((HWND)hWnd == NULL) hWnd = GetActiveWindow();
@ -1393,7 +1329,7 @@ int nAuxBuffers)
FX_ENTRY void FX_CALL
grGlideShutdown(void)
{
LOG("grGlideShutdown\r\n");
WriteTrace(TraceGlitch, TraceDebug, "-");
}
FX_ENTRY FxBool FX_CALL
@ -1403,7 +1339,7 @@ grSstWinClose(GrContext_t context)
#ifndef WIN32
int clear_texbuff = use_fbo;
#endif
LOG("grSstWinClose(%d)\r\n", context);
WriteTrace(TraceGlitch, TraceDebug, "context: %d", context);
for (i = 0; i < 2; i++) {
tmu_usage[i].min = 0x0FFFFFFFul;
@ -1429,8 +1365,8 @@ grSstWinClose(GrContext_t context)
for (i=0; i<nb_fb; i++)
{
glDeleteTextures( 1, &(fbs[i].texid) );
glDeleteFramebuffersEXT( 1, &(fbs[i].fbid) );
glDeleteRenderbuffersEXT( 1, &(fbs[i].zbid) );
glDeleteFramebuffersEXT(1, &(fbs[i].fbid));
glDeleteRenderbuffersEXT(1, &(fbs[i].zbid));
}
}
#endif
@ -1481,8 +1417,7 @@ FX_ENTRY void FX_CALL grTextureBufferExt(GrChipID_t tmu,
int i;
static int fbs_init = 0;
//printf("grTextureBufferExt(%d, %d, %d, %d, %d, %d, %d)\r\n", tmu, startAddress, lodmin, lodmax, aspect, fmt, evenOdd);
LOG("grTextureBufferExt(%d, %d, %d, %d %d, %d, %d)\r\n", tmu, startAddress, lodmin, lodmax, aspect, fmt, evenOdd);
WriteTrace(TraceGlitch, TraceDebug, "tmu: %d startAddress: %d lodmin: %d lodmax: %d aspect: %d fmt: %d evenOdd: %d", tmu, startAddress, lodmin, lodmax, aspect, fmt, evenOdd);
if (lodmin != lodmax) display_warning("grTextureBufferExt : loading more than one LOD");
if (!use_fbo) {
if (!render_to_texture) { //initialization
@ -1802,8 +1737,7 @@ GrAspectRatio_t aspectRatio,
GrTextureFormat_t format,
FxU32 odd_even_mask)
{
LOG("grTextureAuxBufferExt(%d, %d, %d, %d %d, %d, %d)\r\n", tmu, startAddress, thisLOD, largeLOD, aspectRatio, format, odd_even_mask);
//display_warning("grTextureAuxBufferExt");
WriteTrace(TraceGlitch, TraceDebug, "tmu: %d startAddress: %d thisLOD: %d largeLOD: %d aspectRatio: %d format: %d odd_even_mask: %d", tmu, startAddress, thisLOD, largeLOD, aspectRatio, format, odd_even_mask);
}
FX_ENTRY void FX_CALL grAuxBufferExt(GrBuffer_t buffer);
@ -1811,7 +1745,7 @@ FX_ENTRY void FX_CALL grAuxBufferExt(GrBuffer_t buffer);
FX_ENTRY GrProc FX_CALL
grGetProcAddress(char *procName)
{
LOG("grGetProcAddress(%s)\r\n", procName);
WriteTrace(TraceGlitch, TraceDebug, "procName: %s", procName);
if (!strcmp(procName, "grSstWinOpenExt"))
return (GrProc)grSstWinOpenExt;
if (!strcmp(procName, "grTextureBufferExt"))
@ -1858,7 +1792,7 @@ grGetProcAddress(char *procName)
FX_ENTRY FxU32 FX_CALL
grGet(FxU32 pname, FxU32 plength, FxI32 *params)
{
LOG("grGet(%d,%d)\r\n", pname, plength);
WriteTrace(TraceGlitch, TraceDebug, "pname: %d plength: %d", pname, plength);
switch (pname)
{
case GR_MAX_TEXTURE_SIZE:
@ -1976,7 +1910,7 @@ grGet(FxU32 pname, FxU32 plength, FxI32 *params)
FX_ENTRY const char * FX_CALL
grGetString(FxU32 pname)
{
LOG("grGetString(%d)\r\n", pname);
WriteTrace(TraceGlitch, TraceDebug, "pname: %d", pname);
switch (pname)
{
case GR_EXTENSION:
@ -2069,8 +2003,7 @@ void reloadTexture()
if (use_fbo || !render_to_texture || buffer_cleared)
return;
LOG("reload texture %dx%d\n", width, height);
//printf("reload texture %dx%d\n", width, height);
WriteTrace(TraceGlitch, TraceDebug, "width: %d height: %d", width, height);
buffer_cleared = 1;
@ -2097,12 +2030,12 @@ void reloadTexture()
void updateTexture()
{
if (!use_fbo && render_to_texture == 2) {
LOG("update texture %x\n", pBufferAddress);
WriteTrace(TraceGlitch, TraceDebug, "pBufferAddress: %x", pBufferAddress);
//printf("update texture %x\n", pBufferAddress);
// nothing changed, don't update the texture
if (!buffer_cleared) {
LOG("update cancelled\n", pBufferAddress);
WriteTrace(TraceGlitch, TraceDebug, "update cancelled");
return;
}
@ -2182,7 +2115,7 @@ grRenderBuffer(GrBuffer_t buffer)
static HANDLE region = NULL;
//int realWidth = pBufferWidth, realHeight = pBufferHeight;
#endif // _WIN32
LOG("grRenderBuffer(%d)\r\n", buffer);
WriteTrace(TraceGlitch, TraceDebug, "buffer: %d", buffer);
//printf("grRenderBuffer(%d)\n", buffer);
switch (buffer)
@ -2298,8 +2231,7 @@ grRenderBuffer(GrBuffer_t buffer)
FX_ENTRY void FX_CALL
grAuxBufferExt(GrBuffer_t buffer)
{
LOG("grAuxBufferExt(%d)\r\n", buffer);
//display_warning("grAuxBufferExt");
WriteTrace(TraceGlitch, TraceDebug, "buffer: %d", buffer);
if (buffer == GR_BUFFER_AUXBUFFER) {
invtex[0] = 0;
@ -2324,7 +2256,7 @@ grAuxBufferExt(GrBuffer_t buffer)
FX_ENTRY void FX_CALL
grBufferClear(GrColor_t color, GrAlpha_t alpha, FxU32 depth)
{
LOG("grBufferClear(%d,%d,%d)\r\n", color, alpha, depth);
WriteTrace(TraceGlitch, TraceDebug, "color: %d alpha: %d depth: %d", color, alpha, depth);
switch (lfb_color_fmt)
{
case GR_COLORFORMAT_ARGB:
@ -2360,7 +2292,7 @@ FX_ENTRY void FX_CALL
grBufferSwap(FxU32 swap_interval)
{
int i;
LOG("grBufferSwap(%d)\r\n", swap_interval);
WriteTrace(TraceGlitch, TraceDebug, "swap_interval: %d", swap_interval);
//printf("swap\n");
if (render_to_texture) {
display_warning("swap while render_to_texture\n");
@ -2411,7 +2343,7 @@ grLfbLock(GrLock_t type, GrBuffer_t buffer, GrLfbWriteMode_t writeMode,
GrOriginLocation_t origin, FxBool pixelPipeline,
GrLfbInfo_t *info)
{
LOG("grLfbLock(%d,%d,%d,%d,%d)\r\n", type, buffer, writeMode, origin, pixelPipeline);
WriteTrace(TraceGlitch, TraceDebug, "type: %d buffer: %d writeMode: %d origin: %d pixelPipeline: %d", type, buffer, writeMode, origin, pixelPipeline);
if (type == GR_LFB_WRITE_ONLY)
{
display_warning("grLfbLock : write only");
@ -2482,7 +2414,7 @@ GrLfbInfo_t *info)
FX_ENTRY FxBool FX_CALL
grLfbUnlock(GrLock_t type, GrBuffer_t buffer)
{
LOG("grLfbUnlock(%d,%d)\r\n", type, buffer);
WriteTrace(TraceGlitch, TraceDebug, "type: %d, buffer: %d", type, buffer);
if (type == GR_LFB_WRITE_ONLY)
{
display_warning("grLfbUnlock : write only");
@ -2500,7 +2432,7 @@ FxU32 dst_stride, void *dst_data)
unsigned int i, j;
unsigned short *frameBuffer = (unsigned short*)dst_data;
unsigned short *depthBuffer = (unsigned short*)dst_data;
LOG("grLfbReadRegion(%d,%d,%d,%d,%d,%d)\r\n", src_buffer, src_x, src_y, src_width, src_height, dst_stride);
WriteTrace(TraceGlitch, TraceDebug, "src_buffer: %d src_x: %d src_y: %d src_width: %d src_height: %d dst_stride: %d", src_buffer, src_x, src_y, src_width, src_height, dst_stride);
switch (src_buffer)
{
@ -2569,7 +2501,7 @@ FxI32 src_stride, void *src_data)
unsigned short *frameBuffer = (unsigned short*)src_data;
int texture_number;
unsigned int tex_width = 1, tex_height = 1;
LOG("grLfbWriteRegion(%d,%d,%d,%d,%d,%d,%d,%d)\r\n", dst_buffer, dst_x, dst_y, src_format, src_width, src_height, pixelPipeline, src_stride);
WriteTrace(TraceGlitch, TraceDebug, "dst_buffer: %d dst_x: %d dst_y: %d src_format: %d src_width: %d src_height: %d pixelPipeline: %d src_stride: %d", dst_buffer, dst_x, dst_y, src_format, src_width, src_height, pixelPipeline, src_stride);
glPushAttrib(GL_ALL_ATTRIB_BITS);
@ -2686,8 +2618,8 @@ FxI32 src_stride, void *src_data)
#ifdef VPDEBUG
if (dumping) {
unsigned char * buf2 = (unsigned char *)malloc(src_width*(src_height+(viewport_offset)));
for (i=0; i<src_width*src_height ; i++)
unsigned char * buf2 = (unsigned char *)malloc(src_width*(src_height + (viewport_offset)));
for (i = 0; i < src_width*src_height; i++)
buf2[i] = buf[i]*255.0f;
ilTexImage(src_width, src_height, 1, 1, IL_LUMINANCE, IL_UNSIGNED_BYTE, buf2);
char name[128];
@ -2721,13 +2653,13 @@ FxI32 src_stride, void *src_data)
FX_ENTRY char ** FX_CALL
grQueryResolutionsExt(FxI32 * Size)
{
LOG("grQueryResolutionsExt\r\n");
WriteTrace(TraceGlitch, TraceDebug, "-");
return g_FullScreenResolutions.getResolutionsList(Size);
}
FX_ENTRY GrScreenResolution_t FX_CALL grWrapperFullScreenResolutionExt(FxU32* width, FxU32* height)
{
LOG("grWrapperFullScreenResolutionExt\r\n");
WriteTrace(TraceGlitch, TraceDebug, "-");
g_FullScreenResolutions.getResolution(config.res, width, height);
return config.res;
}
@ -2759,7 +2691,7 @@ FX_ENTRY FxBool FX_CALL grKeyPressedExt(FxU32 key)
FX_ENTRY void FX_CALL grConfigWrapperExt(FxI32 resolution, FxI32 vram, FxBool fbo, FxBool aniso)
{
LOG("grConfigWrapperExt\r\n");
WriteTrace(TraceGlitch, TraceDebug, "-");
config.res = resolution;
config.vram_size = vram;
config.fbo = fbo;
@ -2775,7 +2707,7 @@ grQueryResolutions(const GrResolution *resTemplate, GrResolution *output)
int res_sup = 0xf;
int i;
int n = 0;
LOG("grQueryResolutions\r\n");
WriteTrace(TraceGlitch, TraceDebug, "-");
display_warning("grQueryResolutions");
if ((unsigned int)resTemplate->resolution != GR_QUERY_ANY)
{
@ -2807,7 +2739,7 @@ grReset(FxU32 /*what*/)
FX_ENTRY void FX_CALL
grEnable(GrEnableMode_t mode)
{
LOG("grEnable(%d)\r\n", mode);
WriteTrace(TraceGlitch, TraceDebug, "-");
if (mode == GR_TEXTURE_UMA_EXT)
UMAmode = 1;
}
@ -2815,7 +2747,7 @@ grEnable(GrEnableMode_t mode)
FX_ENTRY void FX_CALL
grDisable(GrEnableMode_t mode)
{
LOG("grDisable(%d)\r\n", mode);
WriteTrace(TraceGlitch, TraceDebug, "-");
if (mode == GR_TEXTURE_UMA_EXT)
UMAmode = 0;
}
@ -3040,7 +2972,7 @@ static void CorrectGamma(const FxU16 aGammaRamp[3][256])
FX_ENTRY void FX_CALL
grLoadGammaTable(FxU32 /*nentries*/, FxU32 *red, FxU32 *green, FxU32 *blue)
{
LOG("grLoadGammaTable\r\n");
WriteTrace(TraceGlitch, TraceDebug, "-");
if (!fullscreen)
return;
FxU16 aGammaRamp[3][256];
@ -3057,7 +2989,7 @@ grLoadGammaTable(FxU32 /*nentries*/, FxU32 *red, FxU32 *green, FxU32 *blue)
FX_ENTRY void FX_CALL
grGetGammaTableExt(FxU32 /*nentries*/, FxU32 *red, FxU32 *green, FxU32 *blue)
{
LOG("grGetGammaTableExt()\r\n");
WriteTrace(TraceGlitch, TraceDebug, "-");
FxU16 aGammaRamp[3][256];
#ifdef _WIN32
HDC hdc = GetDC(NULL);
@ -3082,7 +3014,7 @@ grGetGammaTableExt(FxU32 /*nentries*/, FxU32 *red, FxU32 *green, FxU32 *blue)
FX_ENTRY void FX_CALL
guGammaCorrectionRGB(FxFloat gammaR, FxFloat gammaG, FxFloat gammaB)
{
LOG("guGammaCorrectionRGB()\r\n");
WriteTrace(TraceGlitch, TraceDebug, "-");
if (!fullscreen)
return;
FxU16 aGammaRamp[3][256];
@ -3276,7 +3208,7 @@ void dump_tex(int id)
tl[tl_i++] = id;
int i = tl_i-1;
int i = tl_i - 1;
}
#endif

View File

@ -7,6 +7,7 @@
#include "glitchmain.h"
#include <stdio.h>
#include <stdlib.h>
#include <Glide64\trace.h>
/* Napalm extensions to GrTextureFormat_t */
#define GR_TEXFMT_ARGB_CMP_FXT1 0x11
@ -140,7 +141,7 @@ void free_textures()
FX_ENTRY FxU32 FX_CALL
grTexMinAddress(GrChipID_t tmu)
{
LOG("grTexMinAddress(%d)\r\n", tmu);
WriteTrace(TraceGlitch, TraceDebug, "tmu = %d", tmu);
if (UMAmode)
return 0;
else
@ -150,7 +151,7 @@ grTexMinAddress(GrChipID_t tmu)
FX_ENTRY FxU32 FX_CALL
grTexMaxAddress(GrChipID_t tmu)
{
LOG("grTexMaxAddress(%d)\r\n", tmu);
WriteTrace(TraceGlitch, TraceDebug, "tmu = %d", tmu);
if (UMAmode)
return TMU_SIZE * 2 - 1;
else
@ -161,8 +162,8 @@ FX_ENTRY FxU32 FX_CALL
grTexTextureMemRequired(FxU32 evenOdd,
GrTexInfo *info)
{
WriteTrace(TraceGlitch, TraceDebug, "evenOdd = %d", evenOdd);
int width, height;
LOG("grTextureMemRequired(%d)\r\n", evenOdd);
if (info->largeLodLog2 != info->smallLodLog2) display_warning("grTexTextureMemRequired : loading more than one LOD");
if (info->aspectRatioLog2 < 0)
@ -211,8 +212,8 @@ grTexCalcMemRequired(
GrLOD_t lodmin, GrLOD_t lodmax,
GrAspectRatio_t aspect, GrTextureFormat_t fmt)
{
WriteTrace(TraceGlitch, TraceDebug, "lodmin = %d, lodmax: %d aspect: %d fmt: %d", lodmin, lodmax, aspect, fmt);
int width, height;
LOG("grTexCalcMemRequired(%d, %d, %d, %d)\r\n", lodmin, lodmax, aspect, fmt);
if (lodmax != lodmin) display_warning("grTexCalcMemRequired : loading more than one LOD");
if (aspect < 0)
@ -387,11 +388,12 @@ FxU32 startAddress,
FxU32 evenOdd,
GrTexInfo *info)
{
WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, startAddress: %d evenOdd: %d", tmu, startAddress, evenOdd);
int width, height, i, j;
int factor;
int glformat = 0;
int gltexfmt = 0, glpixfmt = 0, glpackfmt = 0;
LOG("grTexDownloadMipMap(%d,%d,%d)\r\n", tmu, startAddress, evenOdd);
if (info->largeLodLog2 != info->smallLodLog2) display_warning("grTexDownloadMipMap : loading more than one LOD");
if (info->aspectRatioLog2 < 0)
@ -649,7 +651,7 @@ FxU32 startAddress,
FxU32 evenOdd,
GrTexInfo *info)
{
LOG("grTexSource(%d,%d,%d)\r\n", tmu, startAddress, evenOdd);
WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, startAddress: %d evenOdd: %d", tmu, startAddress, evenOdd);
if (tmu == GR_TMU1 || nbTextureUnits <= 2)
{
@ -669,7 +671,7 @@ GrTexInfo *info)
glBindTexture(GL_TEXTURE_2D, startAddress + 1);
#ifdef VPDEBUG
dump_tex(startAddress+1);
dump_tex(startAddress + 1);
#endif
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter0);
@ -693,7 +695,7 @@ GrTexInfo *info)
glBindTexture(GL_TEXTURE_2D, startAddress + 1);
#ifdef VPDEBUG
dump_tex(startAddress+1);
dump_tex(startAddress + 1);
#endif
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter1);
@ -733,7 +735,7 @@ FxU8 detail_scale,
float detail_max
)
{
LOG("grTexDetailControl(%d,%d,%d,%d)\r\n", tmu, lod_bias, detail_scale, detail_max);
WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, lod_bias: %d detail_scale: %d detail_max: %d", tmu, lod_bias, detail_scale, detail_max);
if (lod_bias != 31 && detail_scale != 7)
{
if (!lod_bias && !detail_scale && !detail_max) return;
@ -753,7 +755,7 @@ float detail_max
FX_ENTRY void FX_CALL
grTexLodBiasValue(GrChipID_t tmu, float bias)
{
LOG("grTexLodBiasValue(%d,%f)\r\n", tmu, bias);
WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, bias: %f", tmu, bias);
}
FX_ENTRY void FX_CALL
@ -763,7 +765,7 @@ GrTextureFilterMode_t minfilter_mode,
GrTextureFilterMode_t magfilter_mode
)
{
LOG("grTexFilterMode(%d,%d,%d)\r\n", tmu, minfilter_mode, magfilter_mode);
WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, bias: %d magfilter_mode: %d", tmu, minfilter_mode, magfilter_mode);
if (tmu == GR_TMU1 || nbTextureUnits <= 2)
{
if (tmu == GR_TMU1 && nbTextureUnits <= 2) return;
@ -799,7 +801,7 @@ GrTextureClampMode_t s_clampmode,
GrTextureClampMode_t t_clampmode
)
{
LOG("grTexClampMode(%d, %d, %d)\r\n", tmu, s_clampmode, t_clampmode);
WriteTrace(TraceGlitch, TraceDebug, "tmu = %d, s_clampmode: %d t_clampmode: %d", tmu, s_clampmode, t_clampmode);
if (tmu == GR_TMU1 || nbTextureUnits <= 2)
{
if (tmu == GR_TMU1 && nbTextureUnits <= 2) return;

View File

@ -287,18 +287,4 @@ GrColor_t value);
}\
}
#ifdef VPDEBUG
#define LOGGING
#endif
#ifdef LOGGING
void OPEN_LOG();
void CLOSE_LOG();
void LOG(const char *text, ...);
#else // LOGGING
#define OPEN_LOG()
#define CLOSE_LOG()
#define LOG
#endif // LOGGING
#endif