Added the StretchToFit option to the config menu in the OpenGL plugin. This fixes the blackness in SSBM. I also added a keep aspect ratio option, it will keep your aspect ratio at 4:3, but then SSBM will have the blackness problem again. You find the options under the Enhancements window in the OpenGL configuration.

I also added a wx debugging window for the OpenGL plugin. I connected it to the old console window that was in the plugin. Other than that it doesn't do anything at the moment but it could be useful to show all the current important information and parameter statuses and so on.

Again there's a problem with wx windows collisions.  Show() can't be used because then DLL_PROCESS_DETACH is called immediately after the window is opened, and if we open it with ShowModal() before we have loaded a game the main video window will be blocked. And we can't pass on any variables from a DllDebugger() that is called when Dolphin is started because the dll is reloaded and lose all variables sometime before a game is loaded. So we can't auto open the window that way. So I made the debugging window open as a game is loaded if it is enabled in the ini, the downside is that the ini setting will open the window even if we are not opening Dolphin with the -d flag. However, this will only affect people that have used the debugger at least once so in my opinion this is the most convenient solution. But feel free to come up with a better solution. Preferably some solution to how to use Show() and preventing DLL_PROCESS_DETACH to be called.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@812 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson 2008-10-09 18:47:53 +00:00
parent ef617bc4f4
commit d4f8f0d3ae
29 changed files with 1796 additions and 114 deletions

@ -24,8 +24,7 @@ DynamicLibrary CPlugin::m_hInstLib;
void(__cdecl * CPlugin::m_GetDllInfo) (PLUGIN_INFO * _PluginInfo) = 0;
//void(__cdecl * CPlugin::m_DllAbout) (HWND _hParent) = 0;
void(__cdecl * CPlugin::m_DllConfig) (HWND _hParent) = 0;
void(__cdecl * CPlugin::m_DllDebugger) (HWND _hParent) = 0; // phew, is this the last one? how many
// of these can you have?
void(__cdecl * CPlugin::m_DllDebugger) (HWND _hParent) = 0;
void
CPlugin::Release(void)

@ -25,6 +25,7 @@ namespace PluginVideo
// Function Pointer
TGetDllInfo GetDllInfo = 0;
TDllConfig DllConfig = 0;
TDllDebugger DllDebugger = 0;
TVideo_Initialize Video_Initialize = 0;
TVideo_Prepare Video_Prepare = 0;
TVideo_Shutdown Video_Shutdown = 0;
@ -49,6 +50,7 @@ void UnloadPlugin()
// set Functions to 0
GetDllInfo = 0;
DllConfig = 0;
DllDebugger = 0;
Video_Initialize = 0;
Video_Prepare = 0;
Video_Shutdown = 0;
@ -67,6 +69,7 @@ bool LoadPlugin(const char *_Filename)
{
GetDllInfo = reinterpret_cast<TGetDllInfo> (plugin.Get("GetDllInfo"));
DllConfig = reinterpret_cast<TDllConfig> (plugin.Get("DllConfig"));
DllDebugger = reinterpret_cast<TDllDebugger> (plugin.Get("DllDebugger"));
Video_Initialize = reinterpret_cast<TVideo_Initialize> (plugin.Get("Video_Initialize"));
Video_Prepare = reinterpret_cast<TVideo_Prepare> (plugin.Get("Video_Prepare"));
Video_Shutdown = reinterpret_cast<TVideo_Shutdown> (plugin.Get("Video_Shutdown"));

@ -34,6 +34,7 @@ void UnloadPlugin();
typedef void (__cdecl* TGetDllInfo)(PLUGIN_INFO*);
//typedef void (__cdecl* TDllAbout)(HWND);
typedef void (__cdecl* TDllConfig)(HWND);
typedef void (__cdecl* TDllDebugger)(HWND);
typedef void (__cdecl* TVideo_Initialize)(SVideoInitialize*);
typedef void (__cdecl* TVideo_Prepare)();
typedef void (__cdecl* TVideo_Shutdown)();
@ -48,6 +49,7 @@ typedef void (__cdecl* TVideo_Stop)();
// Function Pointers
extern TGetDllInfo GetDllInfo;
extern TDllConfig DllConfig;
extern TDllDebugger DllDebugger;
extern TVideo_Initialize Video_Initialize;
extern TVideo_Prepare Video_Prepare;
extern TVideo_Shutdown Video_Shutdown;

@ -56,6 +56,7 @@
#include "PowerPC/Jit64/JitCache.h"
#include "Plugins/Plugin_DSP.h" // new stuff, to let us open the DLLDebugger
#include "Plugins/Plugin_Video.h" // new stuff, to let us open the DLLDebugger
#include "../../DolphinWX/Src/PluginManager.h"
#include "../../DolphinWX/Src/Config.h"
@ -85,6 +86,7 @@ BEGIN_EVENT_TABLE(CCodeWindow, wxFrame)
EVT_MENU(IDM_MEMORYWINDOW, CCodeWindow::OnToggleMemoryWindow)
EVT_MENU(IDM_JITWINDOW, CCodeWindow::OnToggleJitWindow)
EVT_MENU(IDM_SOUNDWINDOW, CCodeWindow::OnToggleSoundWindow)
EVT_MENU(IDM_VIDEOWINDOW, CCodeWindow::OnToggleVideoWindow)
EVT_MENU(IDM_INTERPRETER, CCodeWindow::OnInterpreter)
@ -204,6 +206,7 @@ bool bBreakpointWindow = true;
bool bMemoryWindow = true;
bool bJitWindow = true;
bool bSoundWindow = false;
bool bVideoWindow = false;
// -------------------
void CCodeWindow::CreateGUIControls(const SCoreStartupParameter& _LocalCoreStartupParameter)
{
@ -219,6 +222,7 @@ void CCodeWindow::CreateGUIControls(const SCoreStartupParameter& _LocalCoreStart
ini.Get("ShowOnStart", "MemoryWindow", &bMemoryWindow, true);
ini.Get("ShowOnStart", "JitWindow", &bJitWindow, true);
ini.Get("ShowOnStart", "SoundWindow", &bSoundWindow, false);
ini.Get("ShowOnStart", "VideoWindow", &bVideoWindow, false);
// ===============
CreateMenu(_LocalCoreStartupParameter);
@ -289,6 +293,15 @@ void CCodeWindow::CreateGUIControls(const SCoreStartupParameter& _LocalCoreStart
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin.c_str()
);
} // don't have any else, just ignore it
if(bVideoWindow)
{
// possible todo: add some kind of if here to? can it fail?
CPluginManager::GetInstance().OpenDebug(
GetHandle(),
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin.c_str()
);
} // don't have any else, just ignore it
}
@ -335,6 +348,9 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParam
wxMenuItem* pSound = pDebugDialogs->Append(IDM_SOUNDWINDOW, _T("&Sound"), wxEmptyString, wxITEM_CHECK);
pSound->Check(bSoundWindow);
wxMenuItem* pVideo = pDebugDialogs->Append(IDM_VIDEOWINDOW, _T("&Video"), wxEmptyString, wxITEM_CHECK);
pVideo->Check(bVideoWindow);
pMenuBar->Append(pDebugDialogs, _T("&Views"));
}
// ===============
@ -846,6 +862,34 @@ void CCodeWindow::OnToggleSoundWindow(wxCommandEvent& event)
// ===========
// =======================================================================================
// Toggle Video Debugging Window
// ------------
void CCodeWindow::OnToggleVideoWindow(wxCommandEvent& event)
{
bool show = GetMenuBar()->IsChecked(event.GetId());
IniFile ini;
ini.Load("Debugger.ini");
ini.Set("ShowOnStart", "VideoWindow", show);
ini.Save("Debugger.ini");
if (show)
{
// TODO: add some kind of if() check here to?
CPluginManager::GetInstance().OpenDebug(
GetHandle(),
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin.c_str()
);
}
else // hide
{
// can we close the dll window from here?
}
}
// ===========
void CCodeWindow::OnToggleJitWindow(wxCommandEvent& event)
{
bool show = GetMenuBar()->IsChecked(event.GetId());

@ -85,6 +85,7 @@ class CCodeWindow
IDM_BREAKPOINTWINDOW,
IDM_MEMORYWINDOW,
IDM_SOUNDWINDOW, // sound
IDM_VIDEOWINDOW, // video
IDM_JITWINDOW, // jit
IDM_SCANFUNCTIONS,
IDM_LOGINSTRUCTIONS,
@ -148,7 +149,8 @@ class CCodeWindow
void OnToggleMemoryWindow(wxCommandEvent& event);
void OnToggleJitWindow(wxCommandEvent& event);
void OnToggleSoundWindow(wxCommandEvent& event);
void OnToggleVideoWindow(wxCommandEvent& event);
void OnHostMessage(wxCommandEvent& event);
void OnSymbolsMenu(wxCommandEvent& event);
void OnJitMenu(wxCommandEvent& event);

@ -95,6 +95,14 @@ EXPORT void CALL GetDllInfo(PLUGIN_INFO* _pPluginInfo);
//
EXPORT void CALL DllConfig(HWND _hParent);
// __________________________________________________________________________________________________
// Function: DllDebugger
// Purpose: Open the debugger
// input: a handle to the window that calls this function
// output: none
//
EXPORT void CALL DllDebugger(HWND _hParent);
// __________________________________________________________________________________________________
// Function: Video_Initialize
// Purpose:

@ -37,7 +37,7 @@ extern bool gOnlyLooping;
// =======================================================================================
// Declare events
BEGIN_EVENT_TABLE(CDebugger,wxDialog)
BEGIN_EVENT_TABLE(CDebugger,wxDialog)
EVT_CLOSE(CDebugger::OnClose)
EVT_BUTTON(ID_UPD,CDebugger::OnUpdate)
EVT_CHECKBOX(IDC_CHECK0,CDebugger::SaveFile)
@ -74,7 +74,6 @@ CDebugger::~CDebugger()
// empty
IniFile file;
file.Load("Debugger.ini");
this->Save(file);
file.Save("Debugger.ini");
}
@ -266,7 +265,13 @@ SetTitle(wxT("Sound Debugging"));
}
void CDebugger::OnClose(wxCloseEvent& /*event*/)
{
{
// save the window position when we hide the window to
IniFile file;
file.Load("Debugger.ini");
this->Save(file);
file.Save("Debugger.ini");
EndModal(0);
// I turned this off for now because of the ShowModal() problem and because I wanted
@ -428,7 +433,6 @@ void CDebugger::DoShowHideConsole()
if(m_Check[2]->IsChecked())
{
OpenConsole();
}
else
{

@ -122,7 +122,7 @@ class CDebugger : public wxDialog
ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values
};
void OnClose(wxCloseEvent& event);
void CreateGUIControls();
};

@ -551,34 +551,34 @@ void CUCode_AX::Logging(short* _pBuffer, int _iSize, int a)
if(m_frame)
{
m_frame->m_GPRListView->m_CachedRegs[2][i] = gsamplePos[i];
m_frame->m_GPRListView->m_CachedRegs[2][i] = gsampleEnd[i];
m_frame->m_GPRListView->m_CachedRegs[3][i] = gloopPos[i];
m_frame->m_GPRListView->m_CachedRegs[3][i] = gsampleEnd[i];
m_frame->m_GPRListView->m_CachedRegs[4][i] = gloopPos[i];
m_frame->m_GPRListView->m_CachedRegs[4][i] = gvolume_left[i];
m_frame->m_GPRListView->m_CachedRegs[5][i] = gvolume_right[i];
m_frame->m_GPRListView->m_CachedRegs[5][i] = gvolume_left[i];
m_frame->m_GPRListView->m_CachedRegs[6][i] = gvolume_right[i];
m_frame->m_GPRListView->m_CachedRegs[6][i] = glooping[i];
m_frame->m_GPRListView->m_CachedRegs[7][i] = gloop1[i];
m_frame->m_GPRListView->m_CachedRegs[8][i] = gloop2[i];
m_frame->m_GPRListView->m_CachedRegs[9][i] = gloop3[i];
m_frame->m_GPRListView->m_CachedRegs[7][i] = glooping[i];
m_frame->m_GPRListView->m_CachedRegs[8][i] = gloop1[i];
m_frame->m_GPRListView->m_CachedRegs[9][i] = gloop2[i];
m_frame->m_GPRListView->m_CachedRegs[10][i] = gloop3[i];
m_frame->m_GPRListView->m_CachedRegs[10][i] = gis_stream[i];
m_frame->m_GPRListView->m_CachedRegs[11][i] = gis_stream[i];
m_frame->m_GPRListView->m_CachedRegs[11][i] = gaudioFormat[i];
m_frame->m_GPRListView->m_CachedRegs[12][i] = gsrc_type[i];
m_frame->m_GPRListView->m_CachedRegs[13][i] = gcoef[i];
m_frame->m_GPRListView->m_CachedRegs[12][i] = gaudioFormat[i];
m_frame->m_GPRListView->m_CachedRegs[13][i] = gsrc_type[i];
m_frame->m_GPRListView->m_CachedRegs[14][i] = gcoef[i];
m_frame->m_GPRListView->m_CachedRegs[14][i] = gfrac[i];
m_frame->m_GPRListView->m_CachedRegs[15][i] = gfrac[i];
m_frame->m_GPRListView->m_CachedRegs[15][i] = gratio[i];
m_frame->m_GPRListView->m_CachedRegs[16][i] = gratiohi[i];
m_frame->m_GPRListView->m_CachedRegs[17][i] = gratiolo[i];
m_frame->m_GPRListView->m_CachedRegs[16][i] = gratio[i];
m_frame->m_GPRListView->m_CachedRegs[17][i] = gratiohi[i];
m_frame->m_GPRListView->m_CachedRegs[18][i] = gratiolo[i];
m_frame->m_GPRListView->m_CachedRegs[18][i] = gupdates1[i];
m_frame->m_GPRListView->m_CachedRegs[19][i] = gupdates2[i];
m_frame->m_GPRListView->m_CachedRegs[20][i] = gupdates3[i];
m_frame->m_GPRListView->m_CachedRegs[21][i] = gupdates4[i];
m_frame->m_GPRListView->m_CachedRegs[22][i] = gupdates5[i];
m_frame->m_GPRListView->m_CachedRegs[19][i] = gupdates1[i];
m_frame->m_GPRListView->m_CachedRegs[20][i] = gupdates2[i];
m_frame->m_GPRListView->m_CachedRegs[21][i] = gupdates3[i];
m_frame->m_GPRListView->m_CachedRegs[22][i] = gupdates4[i];
m_frame->m_GPRListView->m_CachedRegs[23][i] = gupdates5[i];
}
// add new line

@ -45,6 +45,13 @@ HINSTANCE g_hInstance = NULL;
SVideoInitialize g_VideoInitialize;
int initCount = 0;
void DllDebugger(HWND _hParent)
{
// TODO: implement
}
BOOL APIENTRY DllMain( HINSTANCE hinstDLL, // DLL module handle
DWORD dwReason, // reason called
LPVOID lpvReserved) // reserved

@ -897,6 +897,46 @@
>
</File>
</Filter>
<Filter
Name="Debugger"
>
<File
RelativePath=".\Src\Debugger\Debugger.cpp"
>
</File>
<File
RelativePath=".\Src\Debugger\Debugger.h"
>
</File>
<File
RelativePath=".\Src\Debugger\PBView.cpp"
>
</File>
<File
RelativePath=".\Src\Debugger\PBView.h"
>
</File>
</Filter>
<Filter
Name="Logging"
>
<File
RelativePath=".\Src\Logging\Console.cpp"
>
</File>
<File
RelativePath=".\Src\Logging\Console.h"
>
</File>
<File
RelativePath=".\Src\Logging\Logging.cpp"
>
</File>
<File
RelativePath=".\Src\Logging\Logging.h"
>
</File>
</Filter>
<File
RelativePath=".\Src\GLInit.cpp"
>

@ -15,6 +15,9 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
// ---------------------------------------------------------------------------------------
// includes
// -------------
#include "Globals.h"
#include "Profiler.h"
@ -28,7 +31,10 @@
#include "VertexShaderManager.h"
#include "PixelShaderManager.h"
// ---------------------------------------------------------------------------------------
// State translation lookup tables
// -------------
static const GLenum glSrcFactors[8] =
{
GL_ZERO,
@ -57,6 +63,11 @@ void BPInit()
bpmem.bpMask = 0xFFFFFF;
}
// =======================================================================================
// Called att the end of every: OpcodeDecoding.cpp ExecuteDisplayList > Decode() >
// LoadBPReg()
// ---------------
void BPWritten(int addr, int changes, int newval)
{
DVSTARTPROFILE();
@ -70,8 +81,10 @@ void BPWritten(int addr, int changes, int newval)
if (changes) {
VertexManager::Flush();
((u32*)&bpmem)[addr] = newval;
PRIM_LOG("genmode: texgen=%d, col=%d, ms_en=%d, tev=%d, culmode=%d, ind=%d, zfeeze=%d\n", bpmem.genMode.numtexgens, bpmem.genMode.numcolchans,
bpmem.genMode.ms_en, bpmem.genMode.numtevstages+1, bpmem.genMode.cullmode, bpmem.genMode.numindstages, bpmem.genMode.zfreeze);
PRIM_LOG("genmode: texgen=%d, col=%d, ms_en=%d, tev=%d, culmode=%d, ind=%d, zfeeze=%d\n",
bpmem.genMode.numtexgens, bpmem.genMode.numcolchans,
bpmem.genMode.ms_en, bpmem.genMode.numtevstages+1, bpmem.genMode.cullmode,
bpmem.genMode.numindstages, bpmem.genMode.zfreeze);
// none, ccw, cw, ccw
if (bpmem.genMode.cullmode>0) {
@ -111,7 +124,8 @@ void BPWritten(int addr, int changes, int newval)
if (changes) {
VertexManager::Flush();
((u32*)&bpmem)[addr] = newval;
PRIM_LOG("zmode: test=%d, func=%d, upd=%d\n", bpmem.zmode.testenable, bpmem.zmode.func, bpmem.zmode.updateenable);
PRIM_LOG("zmode: test=%d, func=%d, upd=%d\n", bpmem.zmode.testenable, bpmem.zmode.func,
bpmem.zmode.updateenable);
if (bpmem.zmode.testenable) {
glEnable(GL_DEPTH_TEST);
@ -133,8 +147,8 @@ void BPWritten(int addr, int changes, int newval)
if (changes) {
VertexManager::Flush();
((u32*)&bpmem)[addr] = newval;
PRIM_LOG("alphacmp: ref0=%d, ref1=%d, comp0=%d, comp1=%d, logic=%d\n", bpmem.alphaFunc.ref0, bpmem.alphaFunc.ref1,
bpmem.alphaFunc.comp0, bpmem.alphaFunc.comp1, bpmem.alphaFunc.logic);
PRIM_LOG("alphacmp: ref0=%d, ref1=%d, comp0=%d, comp1=%d, logic=%d\n", bpmem.alphaFunc.ref0,
bpmem.alphaFunc.ref1, bpmem.alphaFunc.comp0, bpmem.alphaFunc.comp1, bpmem.alphaFunc.logic);
PixelShaderMngr::SetAlpha(bpmem.alphaFunc);
}
break;
@ -549,6 +563,7 @@ void BPWritten(int addr, int changes, int newval)
}
}
void SetColorMask()
{
if (bpmem.blendmode.alphaupdate && bpmem.blendmode.colorupdate)
@ -559,36 +574,64 @@ void SetColorMask()
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_FALSE);
}
// =======================================================================================
// Call browser: OpcodeDecoding.cpp ExecuteDisplayList > Decode() > LoadBPReg()
// case 0x52 > SetScissorRect()
// ---------------
// This function handles the OpenGL glScissor() function
// ---------------
// bpmem.scissorTL.x, y = 342x342
// bpmem.scissorBR.x, y = 981x821
// Renderer::GetTargetHeight() = the fixed ini file setting
// ---------------
bool SetScissorRect()
{
int xoff = bpmem.scissorOffset.x * 2 - 342;
int yoff = bpmem.scissorOffset.y * 2 - 342;
RECT rc;
rc.left = bpmem.scissorTL.x + xoff - 342;
rc.left *= MValueX;
if (rc.left < 0) rc.left = 0;
rc.top = bpmem.scissorTL.y + yoff - 342;
rc.top *= MValueY;
if (rc.top < 0) rc.top = 0;
rc.left = bpmem.scissorTL.x + xoff - 342; // left = 0
rc.left *= MValueX;
if (rc.left < 0) rc.left = 0;
rc.top = bpmem.scissorTL.y + yoff - 342; // right = 0
rc.top *= MValueY;
if (rc.top < 0) rc.top = 0;
rc.right = bpmem.scissorBR.x + xoff - 342;
rc.right *= MValueX;
if (rc.right > 640 * MValueX) rc.right = 640 * MValueX;
rc.bottom = bpmem.scissorBR.y + yoff - 342;
rc.bottom *= MValueY;
if (rc.bottom > 480 * MValueY) rc.bottom = 480 * MValueY;
rc.right = bpmem.scissorBR.x + xoff - 342; // right = 640
rc.right *= MValueX;
if (rc.right > 640 * MValueX) rc.right = 640 * MValueX;
//printf("scissor: lt=(%d,%d),rb=(%d,%d),off=(%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom, xoff, yoff);
rc.bottom = bpmem.scissorBR.y + yoff - 342; // bottom = 480
rc.bottom *= MValueY;
if (rc.bottom > 480 * MValueY) rc.bottom = 480 * MValueY;
if( rc.right>=rc.left && rc.bottom>=rc.top ) {
glScissor(rc.left, Renderer::GetTargetHeight()-(rc.bottom), (rc.right-rc.left), (rc.bottom-rc.top));
/*__Log("Scissor: lt=(%d,%d), rb=(%d,%d,%i), off=(%d,%d)\n",
rc.left, rc.top,
rc.right, rc.bottom, Renderer::GetTargetHeight(),
xoff, yoff
);*/
if( rc.right>=rc.left && rc.bottom>=rc.top )
{
glScissor(
rc.left, // x = 0
Renderer::GetTargetHeight()-(rc.bottom), // y = 0
(rc.right-rc.left), // y = 0
(rc.bottom-rc.top) // y = 0
);
return true;
}
return false;
}
// =======================================================================================
// Call browser: OpcodeDecoding.cpp ExecuteDisplayList > Decode() > LoadBPReg()
// ---------------
void LoadBPReg(u32 value0)
{
DVSTARTPROFILE();
@ -751,8 +794,11 @@ void LoadBPReg(u32 value0)
//((u32*)&bpmem)[opcode] = newval;
}
// =======================================================================================
// Never called?
// ---------------
void BPReload()
{
for (int i=0; i<254; i++)
BPWritten(i, 0xFFFFFF, ((u32*)&bpmem)[i]);
BPWritten(i, 0xFFFFFF, ((u32*)&bpmem)[i]);
}

@ -0,0 +1,431 @@
//////////////////////////////////////////////////////////////////////////////////////////
//
// Licensetype: GNU General Public License (GPL)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
//
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
//
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
//
//////////////////////////////////////////////////////////////////////////////////////////
#include "Globals.h"
#include "Debugger.h"
#include "PBView.h"
#include "IniFile.h"
#include "../Logging/Console.h" // open and close console
// externals
extern int gSaveFile; // make this an int to allow multiple save file options
extern int gUpdFreq;
extern int gPreset;
int A, B;
// =======================================================================================
// Declare events
BEGIN_EVENT_TABLE(CDebugger,wxDialog)
EVT_SHOW(CDebugger::OnShow)
EVT_CLOSE(CDebugger::OnClose)
EVT_BUTTON(ID_UPD,CDebugger::OnUpdate)
EVT_CHECKBOX(IDC_CHECK0,CDebugger::SaveFile)
EVT_CHECKBOX(IDC_CHECK2,CDebugger::ShowHideConsole)
EVT_RADIOBOX(IDC_RADIO1,CDebugger::ChangeFrequency)
EVT_RADIOBOX(IDC_RADIO2,CDebugger::ChangePreset)
EVT_BUTTON(ID_AP,CDebugger::Ap)
EVT_BUTTON(ID_AM,CDebugger::Am)
EVT_BUTTON(ID_BP,CDebugger::Bp)
EVT_BUTTON(ID_BM,CDebugger::Bm)
END_EVENT_TABLE()
// =======================================================================================
CDebugger::CDebugger(wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
, m_GPRListView(NULL)
{
CreateGUIControls();
// load ini...
IniFile file;
file.Load("Debugger.ini");
this->Load(file);
}
CDebugger::~CDebugger()
{
// empty
IniFile file;
file.Load("Debugger.ini");
this->Save(file);
file.Save("Debugger.ini");
}
void CDebugger::Save(IniFile& _IniFile) const
{
// TODO1: make this work when we close the entire program to, currently on total close we get
// weird values, perhaps because of some conflict with the rendering window
// TODO2: get the screen resolution and make limits from that
if(GetPosition().x < 1000 && GetPosition().y < 1000
&& GetSize().GetWidth() < 1000 && GetSize().GetHeight() < 1000
)
{
_IniFile.Set("VideoWindow", "x", GetPosition().x);
_IniFile.Set("VideoWindow", "y", GetPosition().y);
_IniFile.Set("VideoWindow", "w", GetSize().GetWidth());
_IniFile.Set("VideoWindow", "h", GetSize().GetHeight());
}
_IniFile.Set("VideoWindow", "Console", m_Check[2]->IsChecked()); // save settings
_IniFile.Set("VideoWindow", "UpdateFrequency", m_RadioBox[1]->GetSelection());
}
void CDebugger::Load(IniFile& _IniFile)
{
int x,y,w,h;
_IniFile.Get("VideoWindow", "x", &x, GetPosition().x);
_IniFile.Get("VideoWindow", "y", &y, GetPosition().y);
_IniFile.Get("VideoWindow", "w", &w, GetSize().GetWidth());
_IniFile.Get("VideoWindow", "h", &h, GetSize().GetHeight());
SetSize(x, y, w, h);
// saved settings
bool Console;
_IniFile.Get("VideoWindow", "Console", &Console, m_Check[2]->IsChecked());
m_Check[2]->SetValue(Console);
DoShowHideConsole();
int UpdateFrequency;
_IniFile.Get("VideoWindow", "UpdateFrequency", &UpdateFrequency, m_RadioBox[1]->GetSelection());
m_RadioBox[1]->SetSelection(UpdateFrequency);
DoChangeFrequency();
}
void CDebugger::CreateGUIControls()
{
SetTitle(wxT("OpenGL Debugging"));
// basic settings
SetIcon(wxNullIcon);
SetSize(8, 8, 200, 100); // these will become the minimin sizes allowed by resizing
Center();
// the big window
m_GPRListView = new CPBView(this, ID_GPR, wxDefaultPosition, GetSize(),
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL | wxLC_SORT_ASCENDING);
// declarations
wxBoxSizer* sMain;
wxButton* m_Upd;
wxButton* m_Ap; wxButton* m_Am;
wxButton* m_Bp; wxButton* m_Bm;
wxStaticBoxSizer* sLeft;
// buttons -----------------------------------------------------
m_Upd = new wxButton(this, ID_UPD, wxT("Update"),
wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Ap = new wxButton(this, ID_AP, wxT("A +"),
wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
//m_SelC->Enable(false);
m_Am = new wxButton(this, ID_AM, wxT("A -"),
wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
//m_Presets->Enable(false);
m_Bp = new wxButton(this, ID_BP, wxT("B +"),
wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Bm = new wxButton(this, ID_BM, wxT("B -"),
wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
// checkboxes and labels -----------------------------------------------------
m_Label[0] = new wxStaticBox(this, IDG_LABEL1, wxT("Options"),
wxDefaultPosition, wxDefaultSize, 0);
wxStaticBoxSizer * m_checkSizer = new wxStaticBoxSizer (m_Label[0], wxVERTICAL);
// checkboxes
m_Check[0] = new wxCheckBox(this, IDC_CHECK0, wxT("Save to file"),
wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Check[1] = new wxCheckBox(this, IDC_CHECK1, wxT("A +"),
wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Check[1]->Enable(false);
m_Check[7] = new wxCheckBox(this, IDC_CHECK7, wxT("A -"),
wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Check[7]->Enable(false);
m_Check[2] = new wxCheckBox(this, IDC_CHECK2, wxT("Show console"),
wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_checkSizer->Add(m_Check[0], 0, 0, 5);
m_checkSizer->Add(m_Check[1], 0, 0, 5);
m_checkSizer->Add(m_Check[7], 0, 0, 5);
m_checkSizer->Add(m_Check[2], 0, 0, 5);
// ------------------------
// settings checkboxes -----------------------------------------------------
m_Label[1] = new wxStaticBox(this, IDG_LABEL2, wxT("Settings"),
wxDefaultPosition, wxDefaultSize, 0);
wxStaticBoxSizer * m_checkSizer2 = new wxStaticBoxSizer (m_Label[1], wxVERTICAL);
// checkboxes
m_Check[3] = new wxCheckBox(this, IDC_CHECK3, wxT("Setting"),
wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Check[3]->SetValue(false);
m_Check[3]->Enable(false);
m_checkSizer2->Add(m_Check[3], 0, 0, 5);
// ------------------------
// radio boxes -----------------------------------------------------
int m_radioBoxNChoices[2];
wxString m_radioBoxChoices0[] = { wxT("Show base 10"), wxT("Show base 16") };
m_radioBoxNChoices[0] = sizeof( m_radioBoxChoices0 ) / sizeof( wxString );
m_RadioBox[0] = new wxRadioBox( this, IDC_RADIO0, wxT("Show base"),
wxDefaultPosition, wxDefaultSize, m_radioBoxNChoices[0], m_radioBoxChoices0, 1, wxRA_SPECIFY_COLS);
m_RadioBox[0]->Enable(false);
wxString m_radioBoxChoices1[] = { wxT("Never"), wxT("5 times/s"), wxT("15 times/s"), wxT("30 times/s") };
m_radioBoxNChoices[1] = sizeof( m_radioBoxChoices1 ) / sizeof( wxString );
m_RadioBox[1] = new wxRadioBox( this, IDC_RADIO1, wxT("Update freq."),
wxDefaultPosition, wxDefaultSize, m_radioBoxNChoices[1], m_radioBoxChoices1, 1, wxRA_SPECIFY_COLS);
wxString m_radioBoxChoices2[] = { wxT("Win stretch") };
m_radioBoxNChoices[2] = sizeof( m_radioBoxChoices2 ) / sizeof( wxString );
m_RadioBox[2] = new wxRadioBox( this, IDC_RADIO2, wxT("Presets"),
wxDefaultPosition, wxDefaultSize, m_radioBoxNChoices[2], m_radioBoxChoices2, 1, wxRA_SPECIFY_COLS);
// ------------------------
// right buttons
wxBoxSizer* sButtons2;
sButtons2 = new wxBoxSizer(wxVERTICAL);
sButtons2->AddStretchSpacer(1);
sButtons2->Add(m_RadioBox[2], 0, 0, 5);
sButtons2->AddStretchSpacer(1);
sButtons2->Add(m_checkSizer2, 0, 2, 5);
sButtons2->AddStretchSpacer(1);
// left buttons
wxBoxSizer* sButtons;
sButtons = new wxBoxSizer(wxVERTICAL);
sButtons->AddStretchSpacer(1);
sButtons->Add(m_Upd, 0, 0, 5);
sButtons->Add(m_Ap, 0, 0, 5);
sButtons->Add(m_Am, 0, 0, 5);
sButtons->Add(m_Bp, 0, 0, 5);
sButtons->Add(m_Bm, 0, 0, 5);
sButtons->AddStretchSpacer(1);
sButtons->Add(m_checkSizer, 0, 2, 5);
sButtons->AddStretchSpacer(1);
sButtons->Add(m_RadioBox[0], 0, 0, 5);
sButtons->AddStretchSpacer(1);
sButtons->Add(m_RadioBox[1], 0, 0, 5);
sButtons->AddStretchSpacer(1);
// blocks view
sLeft = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Current Status"));
sLeft->Add(m_GPRListView, 1, wxEXPAND|wxALL, 5);
// add all stuff to the main container
sMain = new wxBoxSizer(wxHORIZONTAL);
sMain->Add(sLeft, 1, wxEXPAND|wxALL, 5);
sMain->Add(sButtons, 0, wxEXPAND, 0);
sMain->Add(sButtons2, 0, wxEXPAND, 0);
this->SetSizer(sMain);
sMain->SetSizeHints(this);
//NotifyUpdate();
Freeze(); // unfreeze this if you want to use it
}
void CDebugger::OnShow(wxShowEvent& /*event*/)
{
// bring the console back to
if(m_Check[2]->IsChecked())
{
OpenConsole();
MoveWindow(GetConsoleHwnd(), 0,400, 1280,500, true); // move window, TODO: make this
// adjustable from the debugging window
}
}
void CDebugger::OnClose(wxCloseEvent& /*event*/)
{
// save the window position when we hide the window to
IniFile file;
file.Load("Debugger.ini");
this->Save(file);
file.Save("Debugger.ini");
EndModal(0); // it seems like this works for Show() to, not just ShowModal();
// The console goes with the wx window
CloseConsole();
}
void CDebugger::OnUpdate(wxCommandEvent& /*event*/)
{
this->NotifyUpdate();
}
// =======================================================================================
// Change preset
// --------------
void CDebugger::ChangePreset(wxCommandEvent& event)
{
DoChangePreset();
}
void CDebugger::DoChangePreset()
{
if(m_RadioBox[2]->GetSelection() == 0)
{
gPreset = 0;
}
else if(m_RadioBox[2]->GetSelection() == 1)
{
gPreset = 1;
}
else if(m_RadioBox[2]->GetSelection() == 2)
{
gPreset = 2;
}
else if(m_RadioBox[2]->GetSelection() == 3)
{
gPreset = 3;
}
}
// ==============
// =======================================================================================
// Control variables
// --------------
void CDebugger::Ap(wxCommandEvent& event)
{
A += 50;
//MessageBox(0, "", "", 0);
__Log("%i", A);
}
void CDebugger::Am(wxCommandEvent& event)
{
A -= 50;
}
void CDebugger::Bp(wxCommandEvent& event)
{
B += 50;
}
void CDebugger::Bm(wxCommandEvent& event)
{
B -= 50;
}
// ==============
// =======================================================================================
// Change update frequency
// --------------
void CDebugger::ChangeFrequency(wxCommandEvent& event)
{
DoChangeFrequency();
}
void CDebugger::DoChangeFrequency()
{
if(m_RadioBox[1]->GetSelection() == 0)
{
gUpdFreq = 0;
}
else if(m_RadioBox[1]->GetSelection() == 1)
{
gUpdFreq = 5;
}
else if(m_RadioBox[1]->GetSelection() == 2)
{
gUpdFreq = 15;
}
else
{
gUpdFreq = 30;
}
}
// ==============
// =======================================================================================
// Save to file
// --------------
void CDebugger::SaveFile(wxCommandEvent& event)
{
if(m_Check[0]->IsChecked())
{
gSaveFile = 1;
}
else
{
gSaveFile = 0;
}
}
// ==============
// =======================================================================================
// Show or hide console window
// --------------
void CDebugger::ShowHideConsole(wxCommandEvent& event)
{
DoShowHideConsole();
}
void CDebugger::DoShowHideConsole()
{
if(m_Check[2]->IsChecked())
{
OpenConsole();
MoveWindow(GetConsoleHwnd(), 0,400, 1280,500, true); // move window, TODO: make this
// adjustable from the debugging window
}
else
{
CloseConsole();
}
}
// ==============
void CDebugger::NotifyUpdate()
{
if (m_GPRListView != NULL)
{
m_GPRListView->Update();
}
}

@ -0,0 +1,131 @@
//////////////////////////////////////////////////////////////////////////////////////////
//
// Licensetype: GNU General Public License (GPL)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
//
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
//
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
//
//////////////////////////////////////////////////////////////////////////////////////////
#ifndef __CDebugger_h__
#define __CDebugger_h__
// wx stuff, I'm not sure if we use all these
#ifndef WX_PRECOMP
#include <wx/wx.h>
#include <wx/dialog.h>
#else
#include <wx/wxprec.h>
#endif
#include <wx/button.h>
#include <wx/stattext.h>
#include <wx/statbox.h>
#include <wx/statbmp.h>
#include <wx/sizer.h>
#include <wx/filepicker.h>
#include <wx/listctrl.h>
#include <wx/imaglist.h>
#include "../Globals.h"
class CPBView;
class IniFile;
// Window settings - I'm not sure what these do. I just copied them gtom elsewhere basically.
#undef CDebugger_STYLE
#define CDebugger_STYLE wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN | wxNO_FULL_REPAINT_ON_RESIZE
class CDebugger : public wxDialog
{
private:
DECLARE_EVENT_TABLE();
public:
CDebugger(wxWindow *parent, wxWindowID id = 1, const wxString &title = _("Sound Debugger"),
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = CDebugger_STYLE);
virtual ~CDebugger();
void Save(IniFile& _IniFile) const;
void Load(IniFile& _IniFile);
void NotifyUpdate();
void OnUpdate(wxCommandEvent& event);
void SaveFile(wxCommandEvent& event);
void ShowHideConsole(wxCommandEvent& event);
void DoShowHideConsole();
void ChangeFrequency(wxCommandEvent& event);
void DoChangeFrequency();
void ChangePreset(wxCommandEvent& event);
void DoChangePreset();
void Ap(wxCommandEvent& event);
void Am(wxCommandEvent& event);
void Bp(wxCommandEvent& event);
void Bm(wxCommandEvent& event);
CPBView* m_GPRListView;
private:
// declarations
wxCheckBox *m_Check[6];
wxRadioButton *m_Radio[5];
wxRadioBox *m_RadioBox[3];
wxStaticBox *m_Label[1];
wxPanel *m_Controller;
// WARNING: Make sure these are not also elsewhere, for example in resource.h.
enum
{
IDC_CHECK0 = 2000,
IDC_CHECK1,
IDC_CHECK2,
IDC_CHECK3,
IDC_CHECK4,
IDC_CHECK5,
IDC_CHECK6,
IDC_CHECK7,
IDC_CHECK8,
IDC_CHECK9,
IDC_RADIO0,
IDC_RADIO1,
IDC_RADIO2,
IDC_RADIO3,
IDG_LABEL1,
IDG_LABEL2,
ID_UPD,
ID_AP,
ID_AM,
ID_BP,
ID_BM,
ID_GPR,
ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values
};
void OnShow(wxShowEvent& event);
void OnClose(wxCloseEvent& event);
void CreateGUIControls();
};
#endif

@ -0,0 +1,147 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
// ---------------------------------------------------------------------------------------
// includes
// -----------------
#include "Globals.h"
#include "PBView.h"
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
// ---------------------------------------------------------------------------------------
// external declarations
// -----------------
extern const char* GetGRPName(unsigned int index);
// ---------------------------------------------------------------------------------------
// No buttons or events so far
// -----------------
BEGIN_EVENT_TABLE(CPBView, wxListCtrl)
END_EVENT_TABLE()
// =======================================================================================
// The main wxListCtrl
// -------------
CPBView::CPBView(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
: wxListCtrl(parent, id, pos, size, style)
{
InsertColumn(0, wxT("Block"), wxLIST_FORMAT_CENTER, 40);
SetFont(wxFont(8, wxSWISS, wxNORMAL, wxNORMAL, false, wxT("Segoe UI")));
for (int i = 0; i < 1; i++)
{
// Print values from 0 to 63
char buffer [33];
sprintf(buffer, "%02i", i);
int Item = InsertItem(0, wxString::FromAscii(buffer));
wxListItem item;
item.SetId(Item);
item.SetBackgroundColour(0xFFFFFF);
item.SetData(i);
SetItem(item);
}
// This is a wx call that leads to MSWDrawSubItem
Refresh();
}
void
CPBView::Update()
{
Refresh();
}
bool
CPBView::MSWDrawSubItem(wxPaintDC& rPainDC, int item, int subitem)
{
bool Result = false;
// don't change 0, it has the block values
if(subitem > 0)
{
#ifdef __WXMSW__ // what's this? should I use that?
const wxChar* bgColor = _T("#ffffff");
wxBrush bgBrush(bgColor);
wxPen bgPen(bgColor);
wxRect SubItemRect;
this->GetSubItemRect(item, subitem, SubItemRect);
rPainDC.SetBrush(bgBrush);
rPainDC.SetPen(bgPen);
rPainDC.DrawRectangle(SubItemRect);
#endif
// A somewhat primitive attempt to show the playing history for a certain block.
wxString text;
if(subitem == 1)
{
char cbuff [33];
sprintf(cbuff, "%08i", m_CachedRegs[subitem][item]);
std::string c = cbuff;
int n[8];
for (int j = 0; j < 8; j++)
{
n[j] = atoi( c.substr(j, 1).c_str());
// 149 = dot, 160 = space
if (n[j] == 1){
n[j] = 149;} else {n[j] = 160;}
}
// pretty neat huh?
text.Printf(wxT("%c%c%c%c%c%c%c%c"), n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]);
}
else
{
text.Printf(wxT("0x%08x"), m_CachedRegs[subitem][item]);
}
#ifdef __WXMSW__
rPainDC.DrawText(text, SubItemRect.GetLeft() + 10, SubItemRect.GetTop() + 4);
#else
// May not show up pretty in !Win32
rPainDC.DrawText(text, 10, 4);
#endif
return(true);
}
else
{
// what does this mean?
return(Result);
}
}

@ -0,0 +1,47 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef __PBView_h__
#define __PBView_h__
#include <wx/listctrl.h>
#include <wx/dcclient.h>
#include "Common.h"
class CPBView
: public wxListCtrl
{
public:
CPBView(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
void Update();
u32 m_CachedRegs[10][10];
private:
DECLARE_EVENT_TABLE()
bool m_CachedRegHasChanged[64];
virtual bool MSWDrawSubItem(wxPaintDC& rPainDC, int item, int subitem);
};
#endif

@ -34,9 +34,14 @@
// Handles OpenGL and the window
// screen offset
int nBackbufferWidth, nBackbufferHeight;
int nXoff, nYoff;
// ---------------------------------------------------------------------------------------
// externals
// -------------
int gleft, gright, gtop, gbottom;
int nBackbufferWidth, nBackbufferHeight; // screen width
int nXoff, nYoff; // screen offset
float AR; // aspect ratio
#ifndef _WIN32
GLWindow GLWin;
@ -112,6 +117,9 @@ void UpdateFPSDisplay(const char *text)
}
// =======================================================================================
// Create window. Called from main.cpp
// ----------------
bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight)
{
int _twidth, _theight;
@ -143,30 +151,42 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
EmuWindow::SetSize(_twidth, _theight);
#endif
// ---------------------------------------------------------------------------------------
// Control window size and picture scaling
// ------------------
// nBackbufferWidth and nBackbufferHeight = Screen resolution from ini, or 640x480
// See OpenGL_Update() for documentation of the other variables
// ------------------
nBackbufferWidth = _twidth;
nBackbufferHeight = _theight;
float FactorW = 640.0f / (float)nBackbufferWidth;
float FactorH = 480.0f / (float)nBackbufferHeight;
float FactorW = 640.0f / (float)nBackbufferWidth;
float FactorH = 480.0f / (float)nBackbufferHeight;
float Max = (FactorW < FactorH) ? FactorH : FactorW;
if(g_Config.bStretchToFit)
{
MValueX = 1.0f / FactorW;
MValueY = 1.0f / FactorH;
nXoff = 0;
nYoff = 0;
}
else
{
MValueX = 1.0f / Max;
MValueY = 1.0f / Max;
nXoff = (nBackbufferWidth - (640 * MValueX)) / 2;
nYoff = (nBackbufferHeight - (480 * MValueY)) / 2;
}
float Max = (FactorW < FactorH) ? FactorH : FactorW;
if(g_Config.bStretchToFit)
{
MValueX = 1.0f / FactorW;
MValueY = 1.0f / FactorH;
nXoff = 0;
nYoff = 0;
}
else
{
MValueX = 1.0f / Max;
MValueY = 1.0f / Max;
nXoff = (nBackbufferWidth - (640 * MValueX)) / 2;
nYoff = (nBackbufferHeight - (480 * MValueY)) / 2;
}
g_VideoInitialize.pPeekMessages = &Callback_PeekMessages;
g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay;
//char buff[100];
//sprintf(buff, "%i %i %d %d %d", nBackbufferWidth, nBackbufferHeight, Max, MValueX, MValueY);
//MessageBox(0, buff, "", 0);
#if USE_SDL
//init sdl video
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
@ -482,6 +502,10 @@ bool OpenGL_MakeCurrent()
return true;
}
// =======================================================================================
// Update window width, size and etc. Called from Render.cpp
// ----------------
void OpenGL_Update()
{
#if USE_SDL
@ -495,6 +519,11 @@ void OpenGL_Update()
RECT rcWindow;
GetWindowRect(EmuWindow::GetParentWnd(), &rcWindow);
// ---------------------------------------------------------------------------------------
// Get the new window width and height
// ------------------
// See below for documentation
// ------------------
int width = rcWindow.right - rcWindow.left;
int height = rcWindow.bottom - rcWindow.top;
@ -567,15 +596,28 @@ void OpenGL_Update()
return;
#endif
// ---------------------------------------------------------------------------------------
// Get the new window width and height
// ------------------
// nBackbufferWidth and nBackbufferHeight = now the actual screen size
// Max = the highest of w and h
// MValueX and MValueY = used for the picture resolution-change rescaling
// nXoff and nYoff = controls the picture's position inside the Dolphin window
// ------------------
/* MValueX and MValueY will be used in
TextureMngr and VertexShaderManager: Rescale textures on resolution changes
BPStructs.cpp: Control glScissor()
*/
// ------------------
float FactorW = 640.0f / (float)nBackbufferWidth;
float FactorH = 480.0f / (float)nBackbufferHeight;
float Max = (FactorW < FactorH) ? FactorH : FactorW;
AR = (float)nBackbufferWidth / (float)nBackbufferHeight;
if(g_Config.bStretchToFit)
{
MValueX = 1.0f / FactorW;
MValueY = 1.0f / FactorH;
MValueX = 1;
MValueY = 1;
nXoff = 0;
nYoff = 0;
}
@ -586,9 +628,17 @@ void OpenGL_Update()
nXoff = (nBackbufferWidth - (640 * MValueX)) / 2;
nYoff = (nBackbufferHeight - (480 * MValueY)) / 2;
}
// tell the debugger
gleft = rcWindow.left; gright = rcWindow.right;
gtop = rcWindow.top; gbottom = rcWindow.bottom;
}
// =======================================================================================
// Close plugin
// ----------------
void OpenGL_Shutdown()
{
#if USE_SDL

@ -33,6 +33,8 @@ BEGIN_EVENT_TABLE(ConfigDialog,wxDialog)
EVT_COMBOBOX(ID_ALIASMODECB,ConfigDialog::AACB)
EVT_CHECKBOX(ID_FORCEFILTERING,ConfigDialog::ForceFilteringCheck)
EVT_CHECKBOX(ID_FORCEANISOTROPY,ConfigDialog::ForceAnisotropyCheck)
EVT_CHECKBOX(ID_STRETCHTOFIT,ConfigDialog::StretchToFitCheck)
EVT_CHECKBOX(ID_KEEPAR,ConfigDialog::KeepARCheck)
EVT_CHECKBOX(ID_WIREFRAME,ConfigDialog::WireframeCheck)
EVT_CHECKBOX(ID_SHOWFPS,ConfigDialog::ShowFPSCheck)
EVT_CHECKBOX(ID_STATISTICS,ConfigDialog::OverlayCheck)
@ -112,11 +114,25 @@ void ConfigDialog::CreateGUIControls()
tmp<<g_Config.iMultisampleMode;
m_AliasModeCB->SetValue(tmp);
//page2
// page2 -------------------------
m_ForceFiltering = new wxCheckBox(m_PageEnhancements, ID_FORCEFILTERING, wxT("Force bi/trilinear filtering (May cause small glitches)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_ForceFiltering->SetValue(g_Config.bForceFiltering);
//page3
//TODO: make the following work ^^
m_ForceAnisotropy = new wxCheckBox(m_PageEnhancements, ID_FORCEANISOTROPY, wxT("Force maximum anisotropy filtering"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
//m_ForceAnisotropy->SetValue(g_Config.bForceMaxAniso);
m_ForceAnisotropy->Enable(false);
m_StretchToFit = new wxCheckBox(m_PageEnhancements, ID_STRETCHTOFIT, wxT("Stretch to fit (instead of changing res.)"),
wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_StretchToFit->SetValue(g_Config.bStretchToFit);
m_KeepAR = new wxCheckBox(m_PageEnhancements, ID_KEEPAR, wxT("Keep 4:3 aspect ratio"),
wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_KeepAR->SetValue(g_Config.bKeepAR);
// page3 -------------------------
m_ShowFPS = new wxCheckBox(m_PageAdvanced, ID_SHOWFPS, wxT("Overlay FPS"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_ShowFPS->SetValue(g_Config.bShowFPS);
@ -135,11 +151,6 @@ void ConfigDialog::CreateGUIControls()
m_TexturePath->SetPath(wxString::FromAscii(g_Config.texDumpPath));
m_TexturePath->Enable(m_DumpTextures->IsChecked());
//TODO: make the following work ^^
m_ForceAnisotropy = new wxCheckBox(m_PageEnhancements, ID_FORCEANISOTROPY, wxT("Force maximum anisotropy filtering"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
//m_ForceAnisotropy->SetValue(g_Config.bForceMaxAniso);
m_ForceAnisotropy->Enable(false);
m_Wireframe = new wxCheckBox(m_PageAdvanced, ID_WIREFRAME, wxT("Wireframe"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
//m_Wireframe->SetValue(g_Config.bWireFrame);
m_Wireframe->Enable(false);
@ -155,7 +166,8 @@ void ConfigDialog::CreateGUIControls()
sPage1->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
sPage1->Add(m_Fullscreen, wxGBPosition(0, 0), wxGBSpan(1, 2), wxALL, 5);
sPage1->Add(m_RenderToMainWindow, wxGBPosition(1, 0), wxGBSpan(1, 2), wxALL, 5);
sPage1->Add(FSText, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5);
sPage1->Add(FSText, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); // drop down boxes
sPage1->Add(m_FullscreenCB, wxGBPosition(2, 1), wxGBSpan(1, 1), wxALL, 5);
sPage1->Add(WMText, wxGBPosition(3, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5);
sPage1->Add(m_WindowResolutionCB, wxGBPosition(3, 1), wxGBSpan(1, 1), wxALL, 5);
@ -168,6 +180,8 @@ void ConfigDialog::CreateGUIControls()
sPage2 = new wxBoxSizer(wxVERTICAL);
sPage2->Add(m_ForceFiltering, 0, wxALL, 5);
sPage2->Add(m_ForceAnisotropy, 0, wxALL, 5);
sPage2->Add(m_StretchToFit, 0, wxALL, 5); // stretch
sPage2->Add(m_KeepAR, 0, wxALL, 5); // keep AR
m_PageEnhancements->SetSizer(sPage2);
sPage2->Layout();
@ -219,6 +233,16 @@ void ConfigDialog::RenderMainCheck(wxCommandEvent& event)
g_Config.renderToMainframe = m_RenderToMainWindow->IsChecked();
}
void ConfigDialog::StretchToFitCheck(wxCommandEvent& event) // stretch
{
g_Config.bStretchToFit = m_StretchToFit->IsChecked();
}
void ConfigDialog::KeepARCheck(wxCommandEvent& event) // keep AR
{
g_Config.bKeepAR = m_KeepAR->IsChecked();
}
void ConfigDialog::AddFSReso(char *reso)
{
m_FullscreenCB->Append(wxString::FromAscii(reso));

@ -45,17 +45,22 @@ class ConfigDialog : public wxDialog
ConfigDialog(wxWindow *parent, wxWindowID id = 1, const wxString &title = wxT("OpenGL Plugin Configuration"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = ConfigDialog_STYLE);
virtual ~ConfigDialog();
void OKClick(wxCommandEvent& event);
void FullScreenCheck(wxCommandEvent& event);
void RenderMainCheck(wxCommandEvent& event);
void FullScreenCheck(wxCommandEvent& event); // video
void RenderMainCheck(wxCommandEvent& event);
void AddFSReso(char *reso);
void FSCB(wxCommandEvent& event);
void AddWindowReso(char *reso);
void WMCB(wxCommandEvent& event);
void AddAAMode(int mode);
void AACB(wxCommandEvent& event);
void ForceFilteringCheck(wxCommandEvent& event);
void ForceFilteringCheck(wxCommandEvent& event); // enhancements
void ForceAnisotropyCheck(wxCommandEvent& event);
void WireframeCheck(wxCommandEvent& event);
void StretchToFitCheck(wxCommandEvent& event);
void KeepARCheck(wxCommandEvent& event);
void WireframeCheck(wxCommandEvent& event); // advanced
void ShowFPSCheck(wxCommandEvent& event);
void OverlayCheck(wxCommandEvent& event);
void ShowShaderErrorsCheck(wxCommandEvent& event);
@ -78,11 +83,13 @@ class ConfigDialog : public wxDialog
wxCheckBox *m_ShaderErrors;
wxCheckBox *m_Wireframe;
wxCheckBox *m_ForceAnisotropy;
wxCheckBox *m_StretchToFit;
wxCheckBox *m_KeepAR;
wxCheckBox *m_ForceFiltering;
wxComboBox *m_AliasModeCB;
wxComboBox *m_WindowResolutionCB;
wxComboBox *m_FullscreenCB;
wxCheckBox *m_RenderToMainWindow;
wxCheckBox *m_RenderToMainWindow;
wxCheckBox *m_Fullscreen;
wxPanel *m_PageAdvanced;
wxPanel *m_PageEnhancements;
@ -105,6 +112,8 @@ class ConfigDialog : public wxDialog
ID_DUMPTEXTURES,
ID_WIREFRAME,
ID_FORCEANISOTROPY,
ID_STRETCHTOFIT,
ID_KEEPAR,
ID_FORCEFILTERING,
ID_ALIASMODECB,
ID_AATEXT,

@ -51,9 +51,12 @@ void Config::Load()
std::string temp;
IniFile iniFile;
iniFile.Load("gfx_opengl.ini");
iniFile.Get("Hardware", "Adapter", &iAdapter, 0);
if (iAdapter == -1)
iAdapter = 0;
// get resolution
iniFile.Get("Hardware", "WindowedRes", &temp, 0);
if(temp.empty())
temp = "640x480";
@ -62,10 +65,11 @@ void Config::Load()
if(temp.empty())
temp = "640x480";
strcpy(iFSResolution, temp.c_str());
iniFile.Get("Hardware", "Fullscreen", &bFullscreen, 0);
iniFile.Get("Hardware", "Fullscreen", &bFullscreen, 0); // Hardware
iniFile.Get("Hardware", "RenderToMainframe", &renderToMainframe, 0);
iniFile.Get("Settings", "ShowFPS", &bShowFPS, false);
iniFile.Get("Settings", "ShowFPS", &bShowFPS, false); // Settings
iniFile.Get("Settings", "OverlayStats", &bOverlayStats, false);
iniFile.Get("Settings", "Postprocess", &iPostprocessEffect, 0);
iniFile.Get("Settings", "DLOptimize", &iCompileDLsLevel, 0);
@ -90,6 +94,7 @@ void Config::Load()
iniFile.Get("Enhancements", "ForceFiltering", &bForceFiltering, 0);
iniFile.Get("Enhancements", "ForceMaxAniso", &bForceMaxAniso, 0);
iniFile.Get("Enhancements", "StretchToFit", &bStretchToFit, false);
iniFile.Get("Enhancements", "KeepAR", &bKeepAR, false);
}
void Config::Save()
@ -100,7 +105,7 @@ void Config::Save()
iniFile.Set("Hardware", "WindowedRes", iWindowedRes);
iniFile.Set("Hardware", "FullscreenRes", iFSResolution);
iniFile.Set("Hardware", "Fullscreen", bFullscreen);
iniFile.Set("Hardware", "RenderToMainframe", renderToMainframe);
iniFile.Set("Hardware", "RenderToMainframe", renderToMainframe);
iniFile.Set("Settings", "ShowFPS", bShowFPS);
iniFile.Set("Settings", "OverlayStats", bOverlayStats);
@ -117,6 +122,7 @@ void Config::Save()
iniFile.Set("Enhancements", "ForceFiltering", bForceFiltering);
iniFile.Set("Enhancements", "ForceMaxAniso", bForceMaxAniso);
iniFile.Set("Enhancements", "StretchToFit", bStretchToFit);
iniFile.Set("Enhancements", "KeepAR", bKeepAR);
iniFile.Save("gfx_opengl.ini");
}
@ -198,6 +204,7 @@ bool SaveData(const char* filename, const char* data)
return true;
}
#ifdef _WIN32
// The one for Linux is in Linux/Linux.cpp
static HANDLE hConsole = NULL;
@ -209,15 +216,19 @@ void OpenConsole() {
if (hConsole) return;
AllocConsole();
SetConsoleTitle("Opengl Plugin Output");
csize.X = 80;
// set width and height
csize.X = 155; // this fits on 1280 pixels TODO: make it adjustable from the wx debugging window
csize.Y = 1024;
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), csize);
// make the internal buffer match the width we set
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbiInfo);
srect = csbiInfo.srWindow;
srect.Right = srect.Left + 79;
srect.Right = srect.Left + csize.X - 1; // match
srect.Bottom = srect.Top + 44;
SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &srect);
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
}
@ -225,13 +236,14 @@ void CloseConsole() {
if (hConsole == NULL) return;
FreeConsole(); hConsole = NULL;
}
#endif
static FILE* pfLog = NULL;
void __Log(const char *fmt, ...)
{
char* Msg = (char*)alloca(strlen(fmt)+512);
va_list ap;
@ -251,10 +263,12 @@ void __Log(const char *fmt, ...)
#else
//printf("%s", Msg);
#endif
}
void __Log(int type, const char *fmt, ...)
{
char* Msg = (char*)alloca(strlen(fmt)+512);
va_list ap;
@ -268,4 +282,5 @@ void __Log(int type, const char *fmt, ...)
DWORD tmp;
WriteConsole(hConsole, Msg, (DWORD)strlen(Msg), &tmp, 0);
#endif
}

@ -89,7 +89,7 @@ extern float MValueX, MValueY;
#define ERROR_LOG __Log
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUGFAST)
#define INFO_LOG if( g_Config.iLog & 1 ) __Log
#define PRIM_LOG if( g_Config.iLog & 2 ) __Log
#define DEBUG_LOG __Log
@ -135,6 +135,7 @@ struct Config
bool bForceFiltering;
bool bForceMaxAniso;
bool bStretchToFit;
bool bKeepAR;
bool bShowFPS;
bool bTexFmtOverlayEnable;

@ -0,0 +1,192 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
// --------------------
// Includes
#include <string>
#include <stdio.h>
#ifdef _WIN32
#include <windows.h>
#endif
#include "Globals.h"
// --------------------
// On and off
bool g_consoleEnable = true;
int gSaveFile = 0;
#define DEBUGG
// --------------------
// Settings
int nFiles = 1;
// --------------------
// Create handles
#ifdef DEBUGG
FILE* __fStdOut[1]; // you have to update this manually, we can't place a nFiles in there
#endif
#ifdef _WIN32
HANDLE __hStdOut = NULL;
#endif
// =======================================================================================
/* Start console window - width and height is the size of console window, if you specify
fname, the output will also be written to this file. TODO: Close the file pointer when the app
is closed */
// -------------
void startConsoleWin(int width, int height, char* fname)
{
#if defined(DEBUGG) && defined(_WIN32)
AllocConsole();
SetConsoleTitle(fname);
__hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
// swt the width and height of the window
COORD co = {width,height};
SetConsoleScreenBufferSize(__hStdOut, co);
// make the internal buffer match the width we set
SMALL_RECT coo = {0,0,(width - 1),70}; // top, left, right, bottom
SetConsoleWindowInfo(__hStdOut, TRUE, &coo);
// ---------------------------------------------------------------------------------------
// Write to a file
if(fname)
{
for(int i = 0; i < nFiles; i++)
{
// Edit the log file name
std::string FileEnding = ".log";
std::string FileName = fname;
char buffer[33]; itoa(i, buffer, 10); // convert number to string
std::string FullFilename = (FileName + buffer + FileEnding);
__fStdOut[i] = fopen(FullFilename.c_str(), "w");
}
}
// ---------------
#endif
}
// ---------------------------------------------------------------------------------------
// File printf function
int aprintf(int a, char *fmt, ...)
{
#if defined(DEBUGG) && defined(_WIN32)
if(gSaveFile)
{
char s[5000]; // WARNING: mind this value
va_list argptr;
int cnt;
va_start(argptr, fmt);
cnt = vsnprintf(s, 5000, fmt, argptr); // remember to update this value to
va_end(argptr);
// ---------------------------------------------------------------------------------------
if(__fStdOut[a]) // TODO: make this work, we have to set all default values to NULL
//to make it work
fprintf(__fStdOut[a], s);
// -------------
return(cnt);
}
else
{
return 0;
}
#else
return 0;
#endif
}
void ClearScreen()
{
#if defined(DEBUGG) && defined(_WIN32)
if(g_consoleEnable)
{
COORD coordScreen = { 0, 0 };
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsole, &csbi);
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize,
coordScreen, &cCharsWritten);
GetConsoleScreenBufferInfo(hConsole, &csbi);
FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize,
coordScreen, &cCharsWritten);
SetConsoleCursorPosition(hConsole, coordScreen);
}
#endif
}
#if defined(DEBUGG) && defined(_WIN32)
HWND GetConsoleHwnd(void)
{
#define MY_BUFSIZE 1024 // Buffer size for console window titles.
HWND hwndFound; // This is what is returned to the caller.
char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated
// WindowTitle.
char pszOldWindowTitle[MY_BUFSIZE]; // Contains original
// WindowTitle.
// Fetch current window title.
GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
// Format a "unique" NewWindowTitle.
wsprintf(pszNewWindowTitle,"%d/%d",
GetTickCount(),
GetCurrentProcessId());
// Change current window title.
SetConsoleTitle(pszNewWindowTitle);
// Ensure window title has been updated.
Sleep(40);
// Look for NewWindowTitle.
hwndFound = FindWindow(NULL, pszNewWindowTitle);
// Restore original window title.
SetConsoleTitle(pszOldWindowTitle);
return(hwndFound);
}
#endif // win32

@ -0,0 +1,27 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
void startConsoleWin(int width, int height, char* fname);
int aprintf(int a, char *fmt, ...);
void ClearScreen();
void OpenConsole();
void CloseConsole();
#ifdef _WIN32
HWND GetConsoleHwnd(void);
#endif

@ -0,0 +1,276 @@
//////////////////////////////////////////////////////////////////////////////////////////
//
// Licensetype: GNU General Public License (GPL)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
//
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
//
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
//
//////////////////////////////////////////////////////////////////////////////////////////
// ---------------------------------------------------------------------------------------
// Includes
// -------------
#include <iostream>
#include <vector>
#include <string> // so that we can test std::string == abc
#include <math.h> // for the pow() function
#ifdef _WIN32
#include <windows.h>
#endif
#include "Globals.h"
#include "../Debugger/Debugger.h" // for the CDebugger class
#include "../Debugger/PBView.h"
#include "Console.h" // open and close console, clear console window
#include "../Logging/Logging.h" // for global logging values
#include "../Globals.h" // for __Log()
// ---------------------------------------------------------------------------------------
// Externals
// -------------
extern int nFiles;
float ratioFactor; // a global to get the ratio factor from MixAdd
int gUpdFreq = 5;
int gPreset = 0;
u32 gLastBlock;
extern bool gSSBM;
extern bool gSSBMremedy1;
extern bool gSSBMremedy2;
extern bool gSequenced;
extern bool gReset;
bool gOnlyLooping = false;
extern int gSaveFile;
extern int gleft, gright, gtop, gbottom; // from BPStructs.cpp
// ---------------------------------------------------------------------------------------
// Counters
// -------------
int j = 0;
int k = 0;
bool iupdonce = false;
std::vector<u16> viupd(15); // the length of the update frequency bar
// ---------------------------------------------------------------------------------------
// Classes
// -------------
extern CDebugger* m_frame;
// =======================================================================================
// Write title
// --------------
std::string writeTitle(int a)
{
std::string b;
if(a == 0)
{
b = "lef rig top bot | wid hei\n";
}
return b;
}
// =======================================================================================
// =======================================================================================
// Write main message (presets)
// --------------
std::string writeMessage(int a, int i)
{
char buf [1000] = "";
std::string sbuf;
// =======================================================================================
// PRESETS
// ---------------------------------------------------------------------------------------
/*
PRESET 0
"lef rig top bot | xof yof\n";
"000 000 000 000 | 000 000
*/
if(a == 0)
{
sprintf(buf,"%03i %03i %03i %03i | %03i %03i",
gleft, gright, gtop, gbottom, gright-gleft, gbottom-gtop
);
}
sbuf = buf;
return sbuf;
}
// =======================================================================================
// Logging
void Logging(int a)
{
// =======================================================================================
// Update parameter values
// --------------
// AXPB base
// ==============
// ---------------------------------------------------------------------------------------
// Write to file
// --------------
for (int ii = 0; ii < nFiles; ii++)
{
std::string sfbuff;
sfbuff = sfbuff + writeMessage(ii, 0);
aprintf(ii, (char *)sfbuff.c_str());
}
// --------------
// =======================================================================================
// Control how often the screen is updated, and then update the screen
// --------------
if(a == 0) j++;
//if(l == pow((double)2,32)) l=0; // reset l
//l++;
if (gUpdFreq > 0 && j > (30/gUpdFreq))
{
// =======================================================================================
// Write header
// --------------
char buffer [1000] = "";
std::string sbuff;
sbuff = writeTitle(gPreset);
// ==============
// hopefully this is false if we don't have a debugging window and so it doesn't cause a crash
/* // nothing do do here yet
if(m_frame)
{
m_frame->m_GPRListView->m_CachedRegs[1][0] = 0;
}
*/
// add new line
sbuff = sbuff + writeMessage(gPreset, 0); strcpy(buffer, "");
sbuff = sbuff + "\n";
// =======================================================================================
// Write global values
// ---------------
/*
sprintf(buffer, "\nThe parameter blocks span from %08x to %08x | distance %i %i\n", m_addressPBs, gLastBlock, (gLastBlock-m_addressPBs), (gLastBlock-m_addressPBs) / 192);
sbuff = sbuff + buffer; strcpy(buffer, "");
*/
// ===============
// =======================================================================================
// Write settings
// ---------------
/*
sprintf(buffer, "\nSettings: SSBM fix %i | SSBM rem1 %i | SSBM rem2 %i | Sequenced %i | Reset %i | Only looping %i | Save file %i\n",
gSSBM, gSSBMremedy1, gSSBMremedy2, gSequenced, gReset, gOnlyLooping, gSaveFile);
sbuff = sbuff + buffer; strcpy(buffer, "");
*/
// ===============
// =======================================================================================
// Show update frequency
// ---------------
sbuff = sbuff + "\n";
if(!iupdonce)
{
/*
for (int i = 0; i < 10; i++)
{
viupd.at(i) == 0;
}
*/
viupd.at(0) = 1;
viupd.at(1) = 1;
viupd.at(2) = 1;
iupdonce = true;
}
for (int i = 0; i < viupd.size(); i++) // 0, 1,..., 9
{
if (i < viupd.size()-1)
{
viupd.at(viupd.size()-i-1) = viupd.at(viupd.size()-i-2); // move all forward
}
else
{
viupd.at(0) = viupd.at(viupd.size()-1);
}
// Correction
if (viupd.at(viupd.size()-3) == 1 && viupd.at(viupd.size()-2) == 1 && viupd.at(viupd.size()-1) == 1)
{
viupd.at(0) = 0;
}
if(viupd.at(0) == 0 && viupd.at(1) == 1 && viupd.at(2) == 1 && viupd.at(3) == 0)
{
viupd.at(0) = 1;
}
}
for (int i = 0; i < viupd.size(); i++)
{
if(viupd.at(i) == 0)
sbuff = sbuff + " ";
else
sbuff = sbuff + ".";
}
// ================
// =======================================================================================
// Print
// ----------------
ClearScreen();
__Log("%s", sbuff.c_str());
sbuff.clear(); strcpy(buffer, "");
// ================
// New values are written so update - DISABLED - It flickered a lot, even worse than a
// console window. So for now only the console windows is updated.
/*
if(m_frame)
{
m_frame->NotifyUpdate();
}
*/
k=0;
j=0;
} // end of if (j>20)
} // end of function

@ -0,0 +1,21 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
// functions
void Logging(int a);

@ -30,6 +30,8 @@
#include "../../Core/Src/Core.h"
#include "Win32.h"
#include "IniFile.h" // we need this for the debugger to work
void OpenConsole();
void CloseConsole();
@ -76,7 +78,8 @@ BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
return TRUE;
}
void DoDllDebugger();
extern bool gShowDebugger;
namespace EmuWindow
{
HWND m_hWnd = NULL;
@ -208,6 +211,14 @@ namespace EmuWindow
ShowWindow(m_hWnd, SW_SHOW);
BringWindowToTop(m_hWnd);
UpdateWindow(m_hWnd);
// gShowDebugger from main.cpp is forgotten between the Dolphin-Debugger is opened and a game is
// started so we have to use an ini file setting here
bool bVideoWindow = false;
IniFile ini;
ini.Load("Debugger.ini");
ini.Get("ShowOnStart", "VideoWindow", &bVideoWindow, false);
if(bVideoWindow) DoDllDebugger();
}
HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title)

@ -33,6 +33,8 @@
#include "PixelShaderManager.h"
#include "VertexLoader.h"
#include "XFB.h"
#include "Debugger/Debugger.h" // for the CDebugger class
#include "Logging/Logging.h" // for Logging()
#ifdef _WIN32
#include "OS/Win32.h"
@ -49,6 +51,7 @@ struct MESSAGE
CGcontext g_cgcontext;
CGprofile g_cgvProf, g_cgfProf;
extern CDebugger* m_frame; // the debugging class
static int g_MaxTexWidth = 0, g_MaxTexHeight = 0;
static RasterFont* s_pfont = NULL;
@ -456,12 +459,18 @@ void Renderer::ReinitView(int nNewWidth, int nNewHeight)
}
int Renderer::GetTargetWidth()
{
return nBackbufferWidth;
if(g_Config.bStretchToFit)
return 640;
else
return nBackbufferWidth; // return the actual window width
}
int Renderer::GetTargetHeight()
{
return nBackbufferHeight;
if(g_Config.bStretchToFit)
return 480;
else
return nBackbufferHeight; // return the actual window height
}
bool Renderer::CanBlendLogicOp()
@ -553,15 +562,37 @@ void Renderer::FlushZBufferAlphaToTarget()
for(int i = 1; i < 8; ++i) TextureMngr::DisableStage(i);
GL_REPORT_ERRORD();
// setup the stencil to only accept pixels that have been written
glStencilFunc(GL_EQUAL, 1, 0xff);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
if(g_Config.bStretchToFit)
{
//TODO: Do Correctly in a bit
float FactorW = (float)640 / (float)nBackbufferWidth;
float FactorH = (float)480 / (float)nBackbufferHeight;
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(-1,-1);
glTexCoord2f(0, (float)(GetTargetHeight())); glVertex2f(-1,1);
glTexCoord2f((float)(GetTargetWidth()), (float)(GetTargetHeight())); glVertex2f(1,1);
glTexCoord2f((float)(GetTargetWidth()), 0); glVertex2f(1,-1);
float Max = (FactorW < FactorH) ? FactorH : FactorW;
float Temp = 1 / Max;
FactorW *= Temp;
FactorH *= Temp;
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(-FactorW,-FactorH);
glTexCoord2f(0, (float)GetTargetHeight()); glVertex2f(-FactorW,FactorH);
glTexCoord2f((float)GetTargetWidth(), (float)GetTargetHeight()); glVertex2f(FactorW,FactorH);
glTexCoord2f((float)GetTargetWidth(), 0); glVertex2f(FactorW,-FactorH);
__Log("%d, %d", FactorW, FactorH);
}
else
{
// setup the stencil to only accept pixels that have been written
glStencilFunc(GL_EQUAL, 1, 0xff);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(-1,-1);
glTexCoord2f(0, (float)(GetTargetHeight())); glVertex2f(-1,1);
glTexCoord2f((float)(GetTargetWidth()), (float)(GetTargetHeight())); glVertex2f(1,1);
glTexCoord2f((float)(GetTargetWidth()), 0); glVertex2f(1,-1);
}
glEnd();
GL_REPORT_ERRORD();
@ -643,6 +674,7 @@ u32 Renderer::GetZBufferTarget()
{
return nZBufferRender > 0 ? s_ZBufferTarget : 0;
}
void Renderer::Swap(const TRectangle& rc)
{
OpenGL_Update(); // just updates the render window position and the backbuffer size
@ -686,6 +718,16 @@ void Renderer::Swap(const TRectangle& rc)
fpscount = 0;
}
// ---------------------------------------------------------------------------------------
// Write logging data to debugger
// -----------------
if(m_frame)
{
Logging(0);
}
if (g_Config.bOverlayStats) {
char st[2048];
char *p = st;

@ -16,7 +16,6 @@
// http://code.google.com/p/dolphin-emu/
#include "Globals.h"
#include "Profiler.h"
@ -35,12 +34,16 @@ float VertexShaderMngr::rawProjection[7] = {0};
float GC_ALIGNED16(g_fProjectionMatrix[16]);
static int s_nMaxVertexInstructions;
extern int A, B;
extern float AR;
extern int nBackbufferWidth, nBackbufferHeight;
////////////////////////
// Internal Variables //
////////////////////////
static float s_fMaterials[16];
// track changes
static bool bTexMatricesChanged[2], bPosNormalMatrixChanged, bProjectionChanged, bViewportChanged;
int nMaterialsChanged;
@ -101,7 +104,7 @@ VERTEXSHADER* VertexShaderMngr::GetShader(u32 components)
VSCacheEntry& entry = vshaders[uid];
char *code = GenerateVertexShader(components, Renderer::GetZBufferTarget() != 0);
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUGFAST)
if( g_Config.iLog & CONF_SAVESHADERS && code ) {
static int counter = 0;
char szTemp[MAX_PATH];
@ -210,7 +213,10 @@ const u16 s_mtrltable[16][2] = {{0, 0}, {0, 1}, {1, 1}, {0, 2},
{3, 1}, {0, 4}, {1, 3}, {0, 4},
{2, 2}, {0, 4}, {1, 3}, {0, 4}};
/// syncs the shader constant buffers with xfmem
// =======================================================================================
// Syncs the shader constant buffers with xfmem
// ----------------
void VertexShaderMngr::SetConstants(VERTEXSHADER& vs)
{
//nTransformMatricesChanged[0] = 0; nTransformMatricesChanged[1] = 256;
@ -332,10 +338,77 @@ void VertexShaderMngr::SetConstants(VERTEXSHADER& vs)
// [3] = xorig + width/2 + 342
// [4] = yorig + height/2 + 342
// [5] = 16777215 * farz
INFO_LOG("view: topleft=(%f,%f), wh=(%f,%f), z=(%f,%f)\n",rawViewport[3]-rawViewport[0]-342,rawViewport[4]+rawViewport[1]-342,
2 * rawViewport[0], 2 * rawViewport[1], (rawViewport[5]-rawViewport[2])/16777215.0f, rawViewport[5]/16777215.0f);
glViewport((int)(rawViewport[3]-rawViewport[0]-342) * MValueX,Renderer::GetTargetHeight()-((int)(rawViewport[4]-rawViewport[1]-342)) * MValueY, abs((int)(2 * rawViewport[0])) * MValueX, abs((int)(2 * rawViewport[1])) * MValueY);
glDepthRange(-(0.0f - (rawViewport[5]-rawViewport[2])/-16777215.0f), rawViewport[5]/16777215.0f);
/*INFO_LOG("view: topleft=(%f,%f), wh=(%f,%f), z=(%f,%f)\n",
rawViewport[3]-rawViewport[0]-342, rawViewport[4]+rawViewport[1]-342,
2 * rawViewport[0], 2 * rawViewport[1],
(rawViewport[5] - rawViewport[2]) / 16777215.0f, rawViewport[5] / 16777215.0f);*/
// =======================================================================================
// Keep aspect ratio at 4:3
// -------------
// rawViewport[0] = 320, rawViewport[1] = -240
// -------------
float fourThree = 4.0f/3.0f;
float ratio = AR / fourThree;
float hAdj; float wAdj; float actualRatiow; float actualRatioh;
int overfl; int xoffs = 0; int yoffs = 0;
int wid, hei, actualWid, actualHei;
int winw = nBackbufferWidth; int winh = nBackbufferHeight;
if(g_Config.bKeepAR)
{
// Check if height or width is the limiting factor
if(ratio > 1) // then we are to wide and have to limit the width
{
wAdj = ratio;
hAdj = 1;
wid = ceil(abs(2 * rawViewport[0]) / wAdj);
hei = ceil(abs(2 * rawViewport[1]) / hAdj);
actualWid = ceil((float)winw / ratio);
actualRatiow = (float)actualWid / (float)wid; // the picture versus the screen
overfl = (winw - actualWid) / actualRatiow;
xoffs = overfl / 2;
}
else // the window is to high, we have to limit the height
{
ratio = 1 / ratio;
wAdj = 1;
hAdj = ratio;
wid = ceil(abs(2 * rawViewport[0]) / wAdj);
hei = ceil(abs(2 * rawViewport[1]) / hAdj);
actualHei = ceil((float)winh / ratio);
actualRatioh = (float)actualHei / (float)hei; // the picture versus the screen
overfl = (winh - actualHei) / actualRatioh;
yoffs = overfl / 2;
}
}
else
{
wid = ceil(abs(2 * rawViewport[0]));
hei = ceil(abs(2 * rawViewport[1]));
}
if(g_Config.bStretchToFit)
{
glViewport(
(int)(rawViewport[3]-rawViewport[0]-342) + xoffs,
Renderer::GetTargetHeight() - ((int)(rawViewport[4]-rawViewport[1]-342)) + yoffs,
wid, // width
hei // height
);
}
else
{
glViewport((int)(rawViewport[3]-rawViewport[0]-342) * MValueX,
Renderer::GetTargetHeight()-((int)(rawViewport[4]-rawViewport[1]-342)) * MValueY,
abs((int)(2 * rawViewport[0])) * MValueX, abs((int)(2 * rawViewport[1])) * MValueY);
}
glDepthRange(-(0.0f - (rawViewport[5]-rawViewport[2])/-16777215.0f), rawViewport[5]/16777215.0f);
}
if (bProjectionChanged) {

@ -36,13 +36,39 @@
#include "VertexLoader.h"
#include "PixelShaderManager.h"
#include "VertexShaderManager.h"
#include "VideoState.h"
#include "Debugger/Debugger.h" // for the CDebugger class
SVideoInitialize g_VideoInitialize;
#define VERSION_STRING "0.1"
// =======================================================================================
// Create debugging window. We can't use Show() here as usual because then DLL_PROCESS_DETACH will
// be called immediately. And if we use ShowModal() we block the main video window from appearing.
// So I've made a separate function called DoDllDebugger() that creates the window.
// -------------------
CDebugger* m_frame;
void DllDebugger(HWND _hParent)
{
if(m_frame) // if we have created it, let us show it again
{
m_frame->Show();
}
else
{
wxMessageBox(_T("The debugging window will open after you start a game."));
}
}
void DoDllDebugger()
{
m_frame = new CDebugger(NULL);
m_frame->Show();
}
// ===================
void GetDllInfo (PLUGIN_INFO* _PluginInfo)
{
_PluginInfo->Version = 0x0100;
@ -165,9 +191,9 @@ void Video_Initialize(SVideoInitialize* _pVideoInitialize)
_pVideoInitialize->pWindowHandle = g_VideoInitialize.pWindowHandle;
Renderer::AddMessage("Dolphin OpenGL Video Plugin v" VERSION_STRING ,5000);
}
void Video_DoState(unsigned char **ptr, int mode) {
// Clear all caches
@ -178,6 +204,9 @@ void Video_DoState(unsigned char **ptr, int mode) {
//PanicAlert("Saving/Loading state from OpenGL");
}
// =======================================================================================
// This is run after Video_Initialize() from the Core
// --------------
void Video_Prepare(void)
{
OpenGL_MakeCurrent();
@ -197,6 +226,7 @@ void Video_Prepare(void)
PixelShaderMngr::Init();
GL_REPORT_ERRORD();
}
// ==============
void Video_Shutdown(void)
@ -224,7 +254,7 @@ void Video_EnterLoop()
void DebugLog(const char* _fmt, ...)
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUGFAST)
char* Msg = (char*)alloca(strlen(_fmt)+512);
va_list ap;