- put the WX libraries into the project settings. (I had to do it with Notepad++ to be compatible with x64. Hoping I didn't fuck up anything but everything should be ok). Start getting rid of those #pragma comment's.
- first attempt at implementing touchscreen. Doesn't work, probably due to crossplatformness issues. >_<
This commit is contained in:
luigi__ 2010-06-23 22:11:53 +00:00
parent a562c7f966
commit 90086cf357
2 changed files with 316 additions and 265 deletions

View File

@ -79,7 +79,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="Rpcrt4.lib directx-win32-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua-vc8-Win32-debug.lib glib-vc8-Win32.lib 7z-vc8-Win32.lib zlib-vc8-Win32.lib agg-2.5.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib comctl32.lib" AdditionalDependencies="Rpcrt4.lib directx-win32-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua-vc8-Win32-debug.lib glib-vc8-Win32.lib 7z-vc8-Win32.lib zlib-vc8-Win32.lib agg-2.5.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib comctl32.lib wxbase28d.lib wxmsw28d_core.lib"
OutputFile="$(OutDir)\$(ProjectName)_debug.exe" OutputFile="$(OutDir)\$(ProjectName)_debug.exe"
AdditionalLibraryDirectories="..\windows\zlib123;..\windows\agg;.libs" AdditionalLibraryDirectories="..\windows\zlib123;..\windows\agg;.libs"
DelayLoadDLLs="" DelayLoadDLLs=""
@ -170,7 +170,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="Rpcrt4.lib directx-x64-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua-vc8-x64.lib glib-vc8-x64.lib 7z-vc8-x64.lib zlib-vc8-x64.lib agg-2.5-x64.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib comctl32.lib" AdditionalDependencies="Rpcrt4.lib directx-x64-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua-vc8-x64.lib glib-vc8-x64.lib 7z-vc8-x64.lib zlib-vc8-x64.lib agg-2.5-x64.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib comctl32.lib wxbase28d-x64.lib wxmsw28d_core-x64.lib"
OutputFile="$(OutDir)\$(ProjectName)_x64_debug.exe" OutputFile="$(OutDir)\$(ProjectName)_x64_debug.exe"
AdditionalLibraryDirectories="..\windows\zlib123;..\windows\agg;.libs" AdditionalLibraryDirectories="..\windows\zlib123;..\windows\agg;.libs"
GenerateDebugInformation="true" GenerateDebugInformation="true"
@ -263,7 +263,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="Rpcrt4.lib directx-win32-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua-vc8-Win32.lib glib-vc8-Win32.lib 7z-vc8-Win32.lib zlib-vc8-Win32.lib agg-2.5.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib comctl32.lib" AdditionalDependencies="Rpcrt4.lib directx-win32-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua-vc8-Win32.lib glib-vc8-Win32.lib 7z-vc8-Win32.lib zlib-vc8-Win32.lib agg-2.5.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib comctl32.lib wxbase28.lib wxmsw28_core.lib"
OutputFile="$(OutDir)\$(ProjectName)_release.exe" OutputFile="$(OutDir)\$(ProjectName)_release.exe"
AdditionalLibraryDirectories="..\windows\zlib123;..\windows\agg;.libs" AdditionalLibraryDirectories="..\windows\zlib123;..\windows\agg;.libs"
DelayLoadDLLs="" DelayLoadDLLs=""
@ -358,7 +358,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="directx-x64-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua-vc8-x64.lib glib-vc8-x64.lib 7z-vc8-x64.lib zlib-vc8-x64.lib agg-2.5-x64.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib" AdditionalDependencies="directx-x64-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua-vc8-x64.lib glib-vc8-x64.lib 7z-vc8-x64.lib zlib-vc8-x64.lib agg-2.5-x64.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib wxbase28-x64.lib wxmsw28_core-x64.lib"
OutputFile="$(OutDir)\$(ProjectName)_x64_release.exe" OutputFile="$(OutDir)\$(ProjectName)_x64_release.exe"
AdditionalLibraryDirectories="..\windows\zlib123;..\windows\agg;.libs" AdditionalLibraryDirectories="..\windows\zlib123;..\windows\agg;.libs"
GenerateDebugInformation="true" GenerateDebugInformation="true"
@ -452,7 +452,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="Rpcrt4.lib directx-win32-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua-vc8-Win32.lib glib-vc8-Win32.lib 7z-vc8-Win32.lib zlib-vc8-Win32.lib agg-2.5.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib comctl32.lib" AdditionalDependencies="Rpcrt4.lib directx-win32-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua-vc8-Win32.lib glib-vc8-Win32.lib 7z-vc8-Win32.lib zlib-vc8-Win32.lib agg-2.5.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib comctl32.lib wxbase28.lib wxmsw28_core.lib"
OutputFile="$(OutDir)\$(ProjectName)_dev+.exe" OutputFile="$(OutDir)\$(ProjectName)_dev+.exe"
AdditionalLibraryDirectories="..\windows\zlib123;..\windows\agg;.libs" AdditionalLibraryDirectories="..\windows\zlib123;..\windows\agg;.libs"
DelayLoadDLLs="" DelayLoadDLLs=""
@ -548,7 +548,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="directx-x64-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua-vc8-x64.lib glib-vc8-x64.lib 7z-vc8-x64.lib zlib-vc8-x64.lib agg-2.5-x64.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib" AdditionalDependencies="directx-x64-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua-vc8-x64.lib glib-vc8-x64.lib 7z-vc8-x64.lib zlib-vc8-x64.lib agg-2.5-x64.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib wxbase28-x64.lib wxmsw28_core-x64.lib"
OutputFile="$(OutDir)\$(ProjectName)_x64_dev+.exe" OutputFile="$(OutDir)\$(ProjectName)_x64_dev+.exe"
AdditionalLibraryDirectories="..\windows\zlib123;..\windows\agg;.libs" AdditionalLibraryDirectories="..\windows\zlib123;..\windows\agg;.libs"
GenerateDebugInformation="true" GenerateDebugInformation="true"

View File

@ -12,25 +12,7 @@
#include "OGLRender.h" #include "OGLRender.h"
#include "firmware.h" #include "firmware.h"
#ifdef WIN32 #ifndef WIN32
#ifdef _M_X64
#ifndef NDEBUG
#pragma comment(lib,"wxmsw28d_core-x64.lib")
#pragma comment(lib,"wxbase28d-x64.lib")
#else
#pragma comment(lib,"wxmsw28_core-x64.lib")
#pragma comment(lib,"wxbase28-x64.lib")
#endif
#else
#ifndef NDEBUG
#pragma comment(lib,"wxmsw28d_core.lib")
#pragma comment(lib,"wxbase28d.lib")
#else
#pragma comment(lib,"wxmsw28_core.lib")
#pragma comment(lib,"wxbase28.lib")
#endif
#endif
#else
#define lstrlen(a) strlen((a)) #define lstrlen(a) strlen((a))
#endif #endif
@ -48,18 +30,19 @@
#include <wx/wx.h> #include <wx/wx.h>
#endif #endif
#ifdef GDB_STUB #ifdef GDB_STUB
#include "gdbstub.h" #include "gdbstub.h"
#endif #endif
#include <wx/config.h> #include <wx/config.h>
#include <wx/docview.h> #include <wx/docview.h>
#define SCREEN_SIZE (256*192*3)
#define GAP_DEFAULT 64
#define GAP_MAX 90
static int nds_gap_size;
static int nds_screen_rotation_angle;
static bool Touch = false;
#define SCREEN_SIZE (256*192*3)
#define GAP_DEFAULT 64
#define GAP_MAX 90
static int nds_gap_size;
static int nds_screen_rotation_angle;
SoundInterface_struct *SNDCoreList[] = { SoundInterface_struct *SNDCoreList[] = {
&SNDDummy, &SNDDummy,
#ifdef WIN32 #ifdef WIN32
@ -91,17 +74,17 @@ class DesmumeFrame: public wxFrame
{ {
public: public:
DesmumeFrame(const wxString& title); DesmumeFrame(const wxString& title);
~DesmumeFrame() { ~DesmumeFrame() {
delete history; delete history;
}
void OnQuit(wxCommandEvent& WXUNUSED(event))
{
execute = false;
NDS_DeInit();
Close(true);
} }
void OnQuit(wxCommandEvent& WXUNUSED(event))
{
execute = false;
NDS_DeInit();
Close(true);
}
void OnAbout(wxCommandEvent& WXUNUSED(event)) void OnAbout(wxCommandEvent& WXUNUSED(event))
{ {
wxMessageBox( wxMessageBox(
@ -180,89 +163,151 @@ public:
void LoadRom(wxCommandEvent& event){ void LoadRom(wxCommandEvent& event){
wxFileDialog dialog(this,_T("Load Rom"),wxGetHomeDir(),_T(""),_T("*.nds"),wxFD_OPEN, wxDefaultPosition, wxDefaultSize); wxFileDialog dialog(this,_T("Load Rom"),wxGetHomeDir(),_T(""),_T("*.nds"),wxFD_OPEN, wxDefaultPosition, wxDefaultSize);
if(dialog.ShowModal() == wxID_OK) { if(dialog.ShowModal() == wxID_OK) {
history->AddFileToHistory(dialog.GetPath()); history->AddFileToHistory(dialog.GetPath());
execute = true; execute = true;
NDS_LoadROM(dialog.GetPath().mb_str(), dialog.GetPath().mb_str()); NDS_LoadROM(dialog.GetPath().mb_str(), dialog.GetPath().mb_str());
} }
} }
void gpu_screen_to_rgb(u8 *rgb1, u8 *rgb2)
{ //----------------------------------------------------------------------------
u16 gpu_pixel; // Touchscreen
u8 pixel[3]; //----------------------------------------------------------------------------
u8 *rgb = rgb1;
const int rot = nds_screen_rotation_angle; // De-transform coordinates.
int done = false; // Returns true if the coordinates are within the touchscreen.
int offset = 0; bool DetransformTouchCoords(int& X, int& Y)
{
loop: int dtX, dtY;
for (int i = 0; i < 256; i++) {
for (int j = 0; j < 192; j++) { // TODO: descaling (when scaling is supported)
gpu_pixel = *((u16 *) & GPU_screen[(i + (j + offset) * 256) << 1]);
pixel[0] = ((gpu_pixel >> 0) & 0x1f) << 3; // De-rotate coordinates
pixel[1] = ((gpu_pixel >> 5) & 0x1f) << 3; switch (nds_screen_rotation_angle)
pixel[2] = ((gpu_pixel >> 10) & 0x1f) << 3; {
switch (rot) { case 0: dtX = X; dtY = Y - 191 - nds_gap_size; break;
case 0: case 90: dtX = Y; dtY = 191 - X; break;
memcpy(rgb+((i+j*256)*3),pixel,3); case 180: dtX = 255 - X; dtY = 191 - Y; break;
break; case 270: dtX = 255 - Y; dtY = X - 191 - nds_gap_size; break;
case 90: }
memcpy(rgb+SCREEN_SIZE-((j+(255-i)*192)*3)-3,pixel,3);
break; // Atleast one of the coordinates is out of range
case 180: if ((dtX < 0) || (dtX > 255) || (dtY < 0) || (dtY > 191))
memcpy(rgb+SCREEN_SIZE-((i+j*256)*3)-3,pixel,3); {
break; X = wxClip(dtX, 0, 255);
case 270: Y = wxClip(dtY, 0, 191);
memcpy(rgb+((j+(255-i)*192)*3),pixel,3); return false;
break; }
} else
} {
X = dtX;
} Y = dtY;
return true;
if (done == false) { }
offset = 192; }
rgb = rgb2;
done = true; void OnTouchEvent(wxMouseEvent& evt)
goto loop; {
} wxPoint pt = evt.GetPosition();
} bool inside = DetransformTouchCoords(pt.x, pt.y);
//TODO should integrate filter system if (evt.LeftDown() && inside)
void onPaint(wxPaintEvent &event) {
{ Touch = true;
u8 rgb1[SCREEN_SIZE], rgb2[SCREEN_SIZE]; NDS_setTouchPos((u16)pt.x, (u16)pt.y);
wxPaintDC dc(this); }
int w, h; else if(evt.LeftUp() && Touch)
{
if (nds_screen_rotation_angle == 90 || nds_screen_rotation_angle == 270) { Touch = false;
w = 192; NDS_releaseTouch();
h = 256; }
} else { else if (Touch)
w = 256; {
h = 192; NDS_setTouchPos((u16)pt.x, (u16)pt.y);
} }
}
gpu_screen_to_rgb(rgb1, rgb2);
wxBitmap m_bitmap1(wxImage(w, h, rgb1, true)); //----------------------------------------------------------------------------
wxBitmap m_bitmap2(wxImage(w, h, rgb2, true)); // Video
switch (nds_screen_rotation_angle) { //----------------------------------------------------------------------------
case 0:
dc.DrawBitmap(m_bitmap1, 0, 0, true); void gpu_screen_to_rgb(u8 *rgb1, u8 *rgb2)
dc.DrawBitmap(m_bitmap2, 0, 192+nds_gap_size, true); {
break; u16 gpu_pixel;
case 90: u8 pixel[3];
dc.DrawBitmap(m_bitmap2, 0, 0, true); u8 *rgb = rgb1;
dc.DrawBitmap(m_bitmap1, 192+nds_gap_size, 0, true); const int rot = nds_screen_rotation_angle;
break; int done = false;
case 180: int offset = 0;
dc.DrawBitmap(m_bitmap2, 0, 0, true);
dc.DrawBitmap(m_bitmap1, 0, 192+nds_gap_size, true); loop:
break; for (int i = 0; i < 256; i++) {
case 270: for (int j = 0; j < 192; j++) {
dc.DrawBitmap(m_bitmap1, 0, 0, true); gpu_pixel = *((u16 *) & GPU_screen[(i + (j + offset) * 256) << 1]);
dc.DrawBitmap(m_bitmap2, 192+nds_gap_size, 0, true); pixel[0] = ((gpu_pixel >> 0) & 0x1f) << 3;
break; pixel[1] = ((gpu_pixel >> 5) & 0x1f) << 3;
} pixel[2] = ((gpu_pixel >> 10) & 0x1f) << 3;
switch (rot) {
case 0:
memcpy(rgb+((i+j*256)*3),pixel,3);
break;
case 90:
memcpy(rgb+SCREEN_SIZE-((j+(255-i)*192)*3)-3,pixel,3);
break;
case 180:
memcpy(rgb+SCREEN_SIZE-((i+j*256)*3)-3,pixel,3);
break;
case 270:
memcpy(rgb+((j+(255-i)*192)*3),pixel,3);
break;
}
}
}
if (done == false) {
offset = 192;
rgb = rgb2;
done = true;
goto loop;
}
}
//TODO should integrate filter system
void onPaint(wxPaintEvent &event)
{
u8 rgb1[SCREEN_SIZE], rgb2[SCREEN_SIZE];
wxPaintDC dc(this);
int w, h;
if (nds_screen_rotation_angle == 90 || nds_screen_rotation_angle == 270) {
w = 192;
h = 256;
} else {
w = 256;
h = 192;
}
gpu_screen_to_rgb(rgb1, rgb2);
wxBitmap m_bitmap1(wxImage(w, h, rgb1, true));
wxBitmap m_bitmap2(wxImage(w, h, rgb2, true));
switch (nds_screen_rotation_angle) {
case 0:
dc.DrawBitmap(m_bitmap1, 0, 0, true);
dc.DrawBitmap(m_bitmap2, 0, 192+nds_gap_size, true);
break;
case 90:
dc.DrawBitmap(m_bitmap2, 0, 0, true);
dc.DrawBitmap(m_bitmap1, 192+nds_gap_size, 0, true);
break;
case 180:
dc.DrawBitmap(m_bitmap2, 0, 0, true);
dc.DrawBitmap(m_bitmap1, 0, 192+nds_gap_size, true);
break;
case 270:
dc.DrawBitmap(m_bitmap1, 0, 0, true);
dc.DrawBitmap(m_bitmap2, 192+nds_gap_size, 0, true);
break;
}
} }
void onIdle(wxIdleEvent &event){ void onIdle(wxIdleEvent &event){
@ -271,8 +316,8 @@ loop:
applyInput(); applyInput();
if(execute) { if(execute) {
NDS_exec<false>(); NDS_exec<false>();
SPU_Emulate_user(); SPU_Emulate_user();
}; };
osd->update(); osd->update();
DrawHUD(); DrawHUD();
osd->clear(); osd->clear();
@ -363,10 +408,10 @@ loop:
void closeRom(wxCommandEvent& event) { void closeRom(wxCommandEvent& event) {
NDS_FreeROM(); NDS_FreeROM();
execute = false; execute = false;
SPU_Pause(1); SPU_Pause(1);
#ifdef HAVE_LIBAGG #ifdef HAVE_LIBAGG
Hud.resetTransient(); Hud.resetTransient();
#endif #endif
NDS_Reset(); NDS_Reset();
} }
@ -399,9 +444,9 @@ loop:
void OnOpenLuaWindow(wxCommandEvent& WXUNUSED (event)) void OnOpenLuaWindow(wxCommandEvent& WXUNUSED (event))
{ {
#ifdef WIN32 #ifdef WIN32
new wxLuaWindow(this, wxDefaultPosition, wxSize(600, 390)); new wxLuaWindow(this, wxDefaultPosition, wxSize(600, 390));
#endif #endif
} }
void OnOpenControllerConfiguration(wxCommandEvent& WXUNUSED (event)) void OnOpenControllerConfiguration(wxCommandEvent& WXUNUSED (event))
@ -424,24 +469,24 @@ loop:
void Menu_SaveStates(wxCommandEvent &event); void Menu_SaveStates(wxCommandEvent &event);
void Menu_LoadStates(wxCommandEvent &event); void Menu_LoadStates(wxCommandEvent &event);
void NDSInitialize(); void NDSInitialize();
void OnRotation(wxCommandEvent &event); void OnRotation(wxCommandEvent &event);
void ChangeRotation(int rot, bool skip); void ChangeRotation(int rot, bool skip);
void onResize(wxSizeEvent &event); void onResize(wxSizeEvent &event);
bool LoadSettings(); bool LoadSettings();
bool SaveSettings(); bool SaveSettings();
void OnClose(wxCloseEvent &event); void OnClose(wxCloseEvent &event);
void OnOpenRecent(wxCommandEvent &event); void OnOpenRecent(wxCommandEvent &event);
private: private:
struct NDS_fw_config_data fw_config; struct NDS_fw_config_data fw_config;
wxFileHistory* history; wxFileHistory* history;
#ifdef GDB_STUB #ifdef GDB_STUB
gdbstub_handle_t arm9_gdb_stub; gdbstub_handle_t arm9_gdb_stub;
gdbstub_handle_t arm7_gdb_stub; gdbstub_handle_t arm7_gdb_stub;
struct armcpu_memory_iface *arm9_memio; struct armcpu_memory_iface *arm9_memio;
struct armcpu_memory_iface *arm7_memio; struct armcpu_memory_iface *arm7_memio;
struct armcpu_ctrl_iface *arm9_ctrl_iface; struct armcpu_ctrl_iface *arm9_ctrl_iface;
struct armcpu_ctrl_iface *arm7_ctrl_iface; struct armcpu_ctrl_iface *arm7_ctrl_iface;
#endif #endif
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
@ -486,7 +531,7 @@ enum
wRot90, wRot90,
wRot180, wRot180,
wRot270, wRot270,
/* stupid enums: these two should be the at the end */ /* stupid enums: these two should be the at the end */
wLoadState01, wLoadState01,
wSaveState01 = wLoadState01+20 wSaveState01 = wLoadState01+20
}; };
@ -494,52 +539,58 @@ enum
void DesmumeFrame::Menu_SaveStates(wxCommandEvent &event){savestate_slot(event.GetId() - wSaveState01);} void DesmumeFrame::Menu_SaveStates(wxCommandEvent &event){savestate_slot(event.GetId() - wSaveState01);}
void DesmumeFrame::Menu_LoadStates(wxCommandEvent &event){loadstate_slot(event.GetId() - wLoadState01);} void DesmumeFrame::Menu_LoadStates(wxCommandEvent &event){loadstate_slot(event.GetId() - wLoadState01);}
void DesmumeFrame::OnRotation(wxCommandEvent &event) { void DesmumeFrame::OnRotation(wxCommandEvent &event) {
ChangeRotation((event.GetId() - wRot0)*90, true); ChangeRotation((event.GetId() - wRot0)*90, true);
} }
void DesmumeFrame::ChangeRotation(int rot, bool skip) { void DesmumeFrame::ChangeRotation(int rot, bool skip) {
wxSize sizeMin, sizeMax; wxSize sizeMin, sizeMax;
if (skip && rot == nds_screen_rotation_angle) if (skip && rot == nds_screen_rotation_angle)
return; return;
SetMinSize(wxSize(-1,-1)); SetMinSize(wxSize(-1,-1));
SetMaxSize(wxSize(-1,-1)); SetMaxSize(wxSize(-1,-1));
if (rot == 90 || rot == 270) { if (rot == 90 || rot == 270) {
SetClientSize(384 + nds_gap_size, 256); SetClientSize(384 + nds_gap_size, 256);
sizeMax = sizeMin = ClientToWindowSize(wxSize(384,256)); sizeMax = sizeMin = ClientToWindowSize(wxSize(384,256));
sizeMax.IncBy(GAP_MAX,0); sizeMax.IncBy(GAP_MAX,0);
} else { } else {
SetClientSize(256, 384 + nds_gap_size); SetClientSize(256, 384 + nds_gap_size);
sizeMax = sizeMin = ClientToWindowSize(wxSize(256,384)); sizeMax = sizeMin = ClientToWindowSize(wxSize(256,384));
sizeMax.IncBy(0,GAP_MAX); sizeMax.IncBy(0,GAP_MAX);
} }
SetMinSize(sizeMin); SetMinSize(sizeMin);
SetMaxSize(sizeMax); SetMaxSize(sizeMax);
nds_screen_rotation_angle = rot; nds_screen_rotation_angle = rot;
} }
void DesmumeFrame::onResize(wxSizeEvent &event) { void DesmumeFrame::onResize(wxSizeEvent &event) {
int w, h; int w, h;
GetClientSize(&w,&h); GetClientSize(&w,&h);
if (nds_screen_rotation_angle == 90 || nds_screen_rotation_angle == 270) { if (nds_screen_rotation_angle == 90 || nds_screen_rotation_angle == 270) {
if (w>=384) if (w>=384)
nds_gap_size = w-384; nds_gap_size = w-384;
} else { } else {
if (h>=384) if (h>=384)
nds_gap_size = h-384; nds_gap_size = h-384;
} }
event.Skip(); event.Skip();
} }
BEGIN_EVENT_TABLE(DesmumeFrame, wxFrame) BEGIN_EVENT_TABLE(DesmumeFrame, wxFrame)
EVT_PAINT(DesmumeFrame::onPaint) EVT_PAINT(DesmumeFrame::onPaint)
EVT_IDLE(DesmumeFrame::onIdle) EVT_IDLE(DesmumeFrame::onIdle)
EVT_SIZE(DesmumeFrame::onResize) EVT_SIZE(DesmumeFrame::onResize)
EVT_CLOSE(DesmumeFrame::OnClose) EVT_LEFT_DOWN(DesmumeFrame::OnTouchEvent)
EVT_LEFT_UP(DesmumeFrame::OnTouchEvent)
EVT_LEFT_DCLICK(DesmumeFrame::OnTouchEvent)
EVT_MOTION(DesmumeFrame::OnTouchEvent)
EVT_CLOSE(DesmumeFrame::OnClose)
EVT_MENU(wxID_EXIT, DesmumeFrame::OnQuit) EVT_MENU(wxID_EXIT, DesmumeFrame::OnQuit)
EVT_MENU(wxID_OPEN, DesmumeFrame::LoadRom) EVT_MENU(wxID_OPEN, DesmumeFrame::LoadRom)
EVT_MENU(wxID_ABOUT,DesmumeFrame::OnAbout) EVT_MENU(wxID_ABOUT,DesmumeFrame::OnAbout)
@ -569,16 +620,16 @@ EVT_MENU(wSubmitABugReport,DesmumeFrame::submitABugReport)
EVT_MENU(wSaveStateAs,DesmumeFrame::saveStateAs) EVT_MENU(wSaveStateAs,DesmumeFrame::saveStateAs)
EVT_MENU(wLoadStateFrom,DesmumeFrame::loadStateFrom) EVT_MENU(wLoadStateFrom,DesmumeFrame::loadStateFrom)
EVT_MENU_RANGE(wSaveState01,wSaveState01+9,DesmumeFrame::Menu_SaveStates) EVT_MENU_RANGE(wSaveState01,wSaveState01+9,DesmumeFrame::Menu_SaveStates)
EVT_MENU_RANGE(wLoadState01,wLoadState01+9,DesmumeFrame::Menu_LoadStates) EVT_MENU_RANGE(wLoadState01,wLoadState01+9,DesmumeFrame::Menu_LoadStates)
EVT_MENU(wCloseRom,DesmumeFrame::closeRom) EVT_MENU(wCloseRom,DesmumeFrame::closeRom)
EVT_MENU(wImportBackupMemory,DesmumeFrame::importBackupMemory) EVT_MENU(wImportBackupMemory,DesmumeFrame::importBackupMemory)
EVT_MENU(wExportBackupMemory,DesmumeFrame::exportBackupMemory) EVT_MENU(wExportBackupMemory,DesmumeFrame::exportBackupMemory)
EVT_MENU_RANGE(wRot0,wRot270,DesmumeFrame::OnRotation) EVT_MENU_RANGE(wRot0,wRot270,DesmumeFrame::OnRotation)
EVT_MENU(wSaveScreenshotAs,DesmumeFrame::saveScreenshotAs) EVT_MENU(wSaveScreenshotAs,DesmumeFrame::saveScreenshotAs)
EVT_MENU(wQuickScreenshot,DesmumeFrame::quickScreenshot) EVT_MENU(wQuickScreenshot,DesmumeFrame::quickScreenshot)
@ -591,8 +642,8 @@ EVT_MENU(w3dView,DesmumeFrame::_3dView)
EVT_MENU(wLuaWindow,DesmumeFrame::OnOpenLuaWindow) EVT_MENU(wLuaWindow,DesmumeFrame::OnOpenLuaWindow)
EVT_MENU(wConfigureControls,DesmumeFrame::OnOpenControllerConfiguration) EVT_MENU(wConfigureControls,DesmumeFrame::OnOpenControllerConfiguration)
EVT_MENU_RANGE(wxID_FILE1,wxID_FILE9,DesmumeFrame::OnOpenRecent) EVT_MENU_RANGE(wxID_FILE1,wxID_FILE9,DesmumeFrame::OnOpenRecent)
END_EVENT_TABLE() END_EVENT_TABLE()
@ -601,28 +652,28 @@ IMPLEMENT_APP(Desmume)
static SPADInitialize PADInitialize; static SPADInitialize PADInitialize;
void DesmumeFrame::NDSInitialize() { void DesmumeFrame::NDSInitialize() {
NDS_FillDefaultFirmwareConfigData( &fw_config); NDS_FillDefaultFirmwareConfigData( &fw_config);
#ifdef HAVE_LIBAGG #ifdef HAVE_LIBAGG
Desmume_InitOnce(); Desmume_InitOnce();
aggDraw.hud->attach((u8*)GPU_screen, 256, 384, 1024);//TODO aggDraw.hud->attach((u8*)GPU_screen, 256, 384, 1024);//TODO
#endif #endif
//TODO //TODO
addon_type = NDS_ADDON_NONE; addon_type = NDS_ADDON_NONE;
addonsChangePak(addon_type); addonsChangePak(addon_type);
#ifdef GDB_STUB #ifdef GDB_STUB
arm9_memio = &arm9_base_memory_iface; arm9_memio = &arm9_base_memory_iface;
arm7_memio = &arm7_base_memory_iface; arm7_memio = &arm7_base_memory_iface;
NDS_Init( arm9_memio, &arm9_ctrl_iface, NDS_Init( arm9_memio, &arm9_ctrl_iface,
arm7_memio, &arm7_ctrl_iface); arm7_memio, &arm7_ctrl_iface);
#else #else
NDS_Init(); NDS_Init();
#endif #endif
#ifndef WIN32 #ifndef WIN32
SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4); SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4);
#endif #endif
NDS_3D_ChangeCore(0); NDS_3D_ChangeCore(0);
NDS_CreateDummyFirmware( &fw_config); NDS_CreateDummyFirmware( &fw_config);
} }
@ -639,9 +690,9 @@ bool Desmume::OnInit()
OpenConsole(); OpenConsole();
#endif #endif
SetAppName(_T("desmume")); SetAppName(_T("desmume"));
wxConfigBase *pConfig = new wxFileConfig(); wxConfigBase *pConfig = new wxFileConfig();
wxConfigBase::Set(pConfig); wxConfigBase::Set(pConfig);
wxString emu_version(EMU_DESMUME_NAME_AND_VERSION(), wxConvUTF8); wxString emu_version(EMU_DESMUME_NAME_AND_VERSION(), wxConvUTF8);
DesmumeFrame *frame = new DesmumeFrame(emu_version); DesmumeFrame *frame = new DesmumeFrame(emu_version);
frame->NDSInitialize(); frame->NDSInitialize();
@ -652,7 +703,7 @@ bool Desmume::OnInit()
#ifndef WIN32 #ifndef WIN32
extern void Initialize(void *init); extern void Initialize(void *init);
Initialize(&PADInitialize); Initialize(&PADInitialize);
#endif #endif
@ -663,20 +714,20 @@ DesmumeFrame::DesmumeFrame(const wxString& title)
: wxFrame(NULL, wxID_ANY, title) : wxFrame(NULL, wxID_ANY, title)
{ {
history = new wxFileHistory; history = new wxFileHistory;
wxMenu *fileMenu = new wxMenu; wxMenu *fileMenu = new wxMenu;
wxMenu *emulationMenu = new wxMenu; wxMenu *emulationMenu = new wxMenu;
wxMenu *viewMenu = new wxMenu; wxMenu *viewMenu = new wxMenu;
wxMenu *configMenu = new wxMenu; wxMenu *configMenu = new wxMenu;
wxMenu *toolsMenu = new wxMenu; wxMenu *toolsMenu = new wxMenu;
wxMenu *helpMenu = new wxMenu; wxMenu *helpMenu = new wxMenu;
wxMenu *saves(MakeStatesSubMenu(wSaveState01)); wxMenu *saves(MakeStatesSubMenu(wSaveState01));
wxMenu *loads(MakeStatesSubMenu(wLoadState01)); wxMenu *loads(MakeStatesSubMenu(wLoadState01));
wxMenu *recentMenu = new wxMenu; wxMenu *recentMenu = new wxMenu;
history->UseMenu(recentMenu); history->UseMenu(recentMenu);
fileMenu->Append(wxID_OPEN, _T("Load R&om\tAlt-R")); fileMenu->Append(wxID_OPEN, _T("Load R&om\tAlt-R"));
fileMenu->AppendSubMenu(recentMenu, _T("Recent files")); fileMenu->AppendSubMenu(recentMenu, _T("Recent files"));
fileMenu->Append(wCloseRom, _T("Close Rom")); fileMenu->Append(wCloseRom, _T("Close Rom"));
fileMenu->AppendSeparator(); fileMenu->AppendSeparator();
fileMenu->Append(wSaveStateAs, _T("Save State As...")); fileMenu->Append(wSaveStateAs, _T("Save State As..."));
@ -701,14 +752,14 @@ DesmumeFrame::DesmumeFrame(const wxString& title)
emulationMenu->Append(wPause, _T("&Pause\tAlt-P"), _T("Pause Emulation")); emulationMenu->Append(wPause, _T("&Pause\tAlt-P"), _T("Pause Emulation"));
emulationMenu->Append(wReset, _T("&Reset\tAlt-R"), _T("Reset Emulation")); emulationMenu->Append(wReset, _T("&Reset\tAlt-R"), _T("Reset Emulation"));
wxMenu *rotateMenu = new wxMenu; wxMenu *rotateMenu = new wxMenu;
{ {
rotateMenu->AppendRadioItem(wRot0, _T("0")); rotateMenu->AppendRadioItem(wRot0, _T("0"));
rotateMenu->AppendRadioItem(wRot90, _T("90")); rotateMenu->AppendRadioItem(wRot90, _T("90"));
rotateMenu->AppendRadioItem(wRot180, _T("180")); rotateMenu->AppendRadioItem(wRot180, _T("180"));
rotateMenu->AppendRadioItem(wRot270, _T("270")); rotateMenu->AppendRadioItem(wRot270, _T("270"));
} }
viewMenu->AppendSubMenu(rotateMenu, _T("Rotate")); viewMenu->AppendSubMenu(rotateMenu, _T("Rotate"));
viewMenu->AppendSeparator(); viewMenu->AppendSeparator();
viewMenu->AppendCheckItem(wFrameCounter, _T("&Display Frame Counter")); viewMenu->AppendCheckItem(wFrameCounter, _T("&Display Frame Counter"));
viewMenu->AppendCheckItem(wFPS, _T("&Display FPS")); viewMenu->AppendCheckItem(wFPS, _T("&Display FPS"));
@ -721,26 +772,26 @@ DesmumeFrame::DesmumeFrame(const wxString& title)
wxMenu *layersMenu = new wxMenu; wxMenu *layersMenu = new wxMenu;
{ {
layersMenu->AppendCheckItem(wMainGPU, _T("Main GPU")); layersMenu->AppendCheckItem(wMainGPU, _T("Main GPU"));
layersMenu->Check(wMainGPU, true); layersMenu->Check(wMainGPU, true);
layersMenu->AppendCheckItem(wMainBG0, _T("Main BG 0")); layersMenu->AppendCheckItem(wMainBG0, _T("Main BG 0"));
layersMenu->Check(wMainBG0, true); layersMenu->Check(wMainBG0, true);
layersMenu->AppendCheckItem(wMainBG1, _T("Main BG 1")); layersMenu->AppendCheckItem(wMainBG1, _T("Main BG 1"));
layersMenu->Check(wMainBG1, true); layersMenu->Check(wMainBG1, true);
layersMenu->AppendCheckItem(wMainBG2, _T("Main BG 2")); layersMenu->AppendCheckItem(wMainBG2, _T("Main BG 2"));
layersMenu->Check(wMainBG2, true); layersMenu->Check(wMainBG2, true);
layersMenu->AppendCheckItem(wMainBG3, _T("Main BG 3")); layersMenu->AppendCheckItem(wMainBG3, _T("Main BG 3"));
layersMenu->Check(wMainBG3, true); layersMenu->Check(wMainBG3, true);
layersMenu->AppendSeparator(); layersMenu->AppendSeparator();
layersMenu->AppendCheckItem(wSubGPU, _T("Sub GPU")); layersMenu->AppendCheckItem(wSubGPU, _T("Sub GPU"));
layersMenu->Check(wSubGPU, true); layersMenu->Check(wSubGPU, true);
layersMenu->AppendCheckItem(wSubBG0, _T("Sub BG 0")); layersMenu->AppendCheckItem(wSubBG0, _T("Sub BG 0"));
layersMenu->Check(wSubBG0, true); layersMenu->Check(wSubBG0, true);
layersMenu->AppendCheckItem(wSubBG1, _T("Sub BG 1")); layersMenu->AppendCheckItem(wSubBG1, _T("Sub BG 1"));
layersMenu->Check(wSubBG1, true); layersMenu->Check(wSubBG1, true);
layersMenu->AppendCheckItem(wSubBG2, _T("Sub BG 2")); layersMenu->AppendCheckItem(wSubBG2, _T("Sub BG 2"));
layersMenu->Check(wSubBG2, true); layersMenu->Check(wSubBG2, true);
layersMenu->AppendCheckItem(wSubBG3, _T("Sub BG 3")); layersMenu->AppendCheckItem(wSubBG3, _T("Sub BG 3"));
layersMenu->Check(wSubBG3, true); layersMenu->Check(wSubBG3, true);
} }
configMenu->Append(wConfigureControls, _T("Controls")); configMenu->Append(wConfigureControls, _T("Controls"));
@ -764,9 +815,9 @@ DesmumeFrame::DesmumeFrame(const wxString& title)
// CreateStatusBar(2); // CreateStatusBar(2);
// SetStatusText("Welcome to Desmume!"); // SetStatusText("Welcome to Desmume!");
LoadSettings(); LoadSettings();
rotateMenu->Check(wRot0+(nds_screen_rotation_angle/90), true); rotateMenu->Check(wRot0+(nds_screen_rotation_angle/90), true);
ChangeRotation(nds_screen_rotation_angle, false); ChangeRotation(nds_screen_rotation_angle, false);
} }
#ifdef WIN32 #ifdef WIN32
@ -786,29 +837,29 @@ createThread_gdb( void (APIENTRY *thread_function)( void *data),
void void
joinThread_gdb( void *thread_handle) { joinThread_gdb( void *thread_handle) {
} }
#endif #endif
bool DesmumeFrame::LoadSettings() { bool DesmumeFrame::LoadSettings() {
wxConfigBase::Get()->Read(_T("/Screen/Gap"),&nds_gap_size,0); wxConfigBase::Get()->Read(_T("/Screen/Gap"),&nds_gap_size,0);
wxConfigBase::Get()->Read(_T("/Screen/Rotation"),&nds_screen_rotation_angle,0); wxConfigBase::Get()->Read(_T("/Screen/Rotation"),&nds_screen_rotation_angle,0);
wxConfigBase::Get()->SetPath(_T("/History")); wxConfigBase::Get()->SetPath(_T("/History"));
history->Load(*wxConfigBase::Get()); history->Load(*wxConfigBase::Get());
return true; return true;
} }
bool DesmumeFrame::SaveSettings() { bool DesmumeFrame::SaveSettings() {
wxConfigBase::Get()->Write(_T("/Screen/Gap"),nds_gap_size); wxConfigBase::Get()->Write(_T("/Screen/Gap"),nds_gap_size);
wxConfigBase::Get()->Write(_T("/Screen/Rotation"),nds_screen_rotation_angle); wxConfigBase::Get()->Write(_T("/Screen/Rotation"),nds_screen_rotation_angle);
wxConfigBase::Get()->SetPath(_T("/History")); wxConfigBase::Get()->SetPath(_T("/History"));
history->Save(*wxConfigBase::Get()); history->Save(*wxConfigBase::Get());
return true; return true;
} }
void DesmumeFrame::OnClose(wxCloseEvent &event) { void DesmumeFrame::OnClose(wxCloseEvent &event) {
SaveSettings(); SaveSettings();
event.Skip(); event.Skip();
} }
void DesmumeFrame::OnOpenRecent(wxCommandEvent &event) { void DesmumeFrame::OnOpenRecent(wxCommandEvent &event) {
execute = true; execute = true;
NDS_LoadROM(history->GetHistoryFile(event.GetId()-wxID_FILE1).mb_str(),NULL); NDS_LoadROM(history->GetHistoryFile(event.GetId()-wxID_FILE1).mb_str(),NULL);
} }