diff --git a/desmume/src/wx/wxDeSmuME_2008.vcproj b/desmume/src/wx/wxDeSmuME_2008.vcproj
index 66fe1b1c6..88bfc0476 100644
--- a/desmume/src/wx/wxDeSmuME_2008.vcproj
+++ b/desmume/src/wx/wxDeSmuME_2008.vcproj
@@ -111,195 +111,6 @@
Name="VCPostBuildEventTool"
/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1519,26 +1523,6 @@
Outputs=".libs\7z.tag"
/>
-
-
-
-
-
-
@@ -1549,6 +1533,16 @@
Outputs=".libs\7z.tag"
/>
+
+
+
@@ -1559,12 +1553,22 @@
Outputs=".libs\7z.tag"
/>
+
+
+
@@ -1593,26 +1597,6 @@
Outputs=".libs\directx.tag"
/>
-
-
-
-
-
-
@@ -1623,6 +1607,16 @@
Outputs=".libs\directx.tag"
/>
+
+
+
@@ -1633,6 +1627,16 @@
Outputs=".libs\directx.tag"
/>
+
+
+
@@ -1657,26 +1661,6 @@
Outputs=".libs\glib-vc8.tag"
/>
-
-
-
-
-
-
@@ -1687,6 +1671,16 @@
Outputs=".libs\glib-vc8.tag"
/>
+
+
+
@@ -1697,6 +1691,16 @@
Outputs=".libs\glib-vc8.tag"
/>
+
+
+
@@ -1716,27 +1720,7 @@
>
-
-
-
-
-
-
@@ -1751,6 +1735,16 @@
Outputs=".libs\lua.tag"
/>
+
+
+
@@ -1761,6 +1755,16 @@
Outputs=".libs\lua.tag"
/>
+
+
+
@@ -1796,21 +1800,21 @@
/>
@@ -1829,26 +1833,6 @@
Outputs=".libs\wx.tag"
/>
-
-
-
-
-
-
@@ -1859,6 +1843,16 @@
Outputs=".libs\wx.tag"
/>
+
+
+
@@ -1869,6 +1863,16 @@
Outputs=".libs\wx.tag"
/>
+
+
+
diff --git a/desmume/src/wx/wxMain.cpp b/desmume/src/wx/wxMain.cpp
index f20e1a005..e2ef51a4e 100644
--- a/desmume/src/wx/wxMain.cpp
+++ b/desmume/src/wx/wxMain.cpp
@@ -1,3 +1,5 @@
+
+#include "wxMain.h"
#include "NDSSystem.h"
#include "GPU_osd.h"
#include
@@ -37,7 +39,7 @@
#define GAP_DEFAULT 64
#define GAP_MAX 90
static int nds_gap_size;
-static int nds_screen_rotation_angle;
+static SPADInitialize PADInitialize;
static bool Touch = false;
SoundInterface_struct *SNDCoreList[] = {
@@ -57,481 +59,555 @@ GPU3DInterface *core3DList[] = {
volatile bool execute = false;
-class Desmume: public wxApp
+bool Desmume::OnInit()
{
-public:
- virtual bool OnInit();
-};
-class DesmumeFrame: public wxFrame
+ if ( !wxApp::OnInit() )
+ return false;
+
+
+#ifdef WIN32
+ extern void OpenConsole();
+ OpenConsole();
+#endif
+
+ SetAppName(_T("desmume"));
+ wxConfigBase *pConfig = new wxFileConfig(wxEmptyString,wxEmptyString,_T("desmume.ini"),wxEmptyString,wxCONFIG_USE_RELATIVE_PATH);
+ wxConfigBase::Set(pConfig);
+ wxString emu_version(EMU_DESMUME_NAME_AND_VERSION(), wxConvUTF8);
+ DesmumeFrame *frame = new DesmumeFrame(emu_version);
+ frame->NDSInitialize();
+
+ frame->Show(true);
+
+ PADInitialize.padNumber = 1;
+
+#ifndef WIN32
+ extern void Initialize(void *init);
+
+ Initialize(&PADInitialize);
+#endif
+
+ return true;
+}
+
+
+void DesmumeFrame::NDSInitialize() {
+ NDS_FillDefaultFirmwareConfigData( &fw_config);
+
+#ifdef HAVE_LIBAGG
+ Desmume_InitOnce();
+ aggDraw.hud->attach((u8*)GPU_screen, 256, 384, 1024);//TODO
+#endif
+
+ //TODO
+ addon_type = NDS_ADDON_NONE;
+ addonsChangePak(addon_type);
+
+#ifdef GDB_STUB
+ arm9_memio = &arm9_base_memory_iface;
+ arm7_memio = &arm7_base_memory_iface;
+ NDS_Init( arm9_memio, &arm9_ctrl_iface,
+ arm7_memio, &arm7_ctrl_iface);
+#else
+ NDS_Init();
+#endif
+ SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4);
+ NDS_3D_ChangeCore(0);
+ NDS_CreateDummyFirmware( &fw_config);
+}
+
+DesmumeFrame::DesmumeFrame(const wxString& title)
+: wxFrame(NULL, wxID_ANY, title)
{
-public:
- DesmumeFrame(const wxString& title);
- ~DesmumeFrame() {
- delete history;
- }
+ history = new wxFileHistory;
+ wxMenuBar *menuBar = new wxMenuBar();
+ wxMenu *fileMenu = new wxMenu;
+ wxMenu *emulationMenu = new wxMenu;
+ wxMenu *viewMenu = new wxMenu;
+ wxMenu *configMenu = new wxMenu;
+ wxMenu *toolsMenu = new wxMenu;
+ wxMenu *helpMenu = new wxMenu;
+ wxMenu *recentMenu = new wxMenu;
+ wxMenu *saves(MakeStatesSubMenu(wSaveState01));
+ wxMenu *loads(MakeStatesSubMenu(wLoadState01));
+ wxMenu *layersMenu = new wxMenu;
+ wxMenu *rotateMenu = new wxMenu;
+
+ LoadSettings();
- void OnQuit(wxCommandEvent& WXUNUSED(event))
- {
- execute = false;
- NDS_DeInit();
- Close(true);
- }
+ menuBar->Append(fileMenu, _T("&File"));
+ menuBar->Append(emulationMenu, _T("&Emulation"));
+ menuBar->Append(viewMenu, _T("&View"));
+ menuBar->Append(configMenu, _T("&Config"));
+ menuBar->Append(toolsMenu, _T("&Tools"));
+ menuBar->Append(helpMenu, _T("&Help"));
- void OnAbout(wxCommandEvent& WXUNUSED(event))
- {
- wxMessageBox(
- wxString::Format(wxT("Desmume on %s"),wxGetOsDescription().c_str()),
- wxT("About Desmume"),
- wxOK | wxICON_INFORMATION,
- this);
- }
+ fileMenu->Append(wxID_OPEN, _T("Load R&om\tAlt-R"));
+ fileMenu->AppendSubMenu(recentMenu, _T("Recent files"));
+ fileMenu->Append(wCloseRom, _T("Close Rom"));
+ fileMenu->AppendSeparator();
+ fileMenu->Append(wSaveStateAs, _T("Save State As..."));
+ fileMenu->Append(wLoadStateFrom, _T("Load State From..."));
+ fileMenu->AppendSubMenu(saves, _T("Save State"));
+ fileMenu->AppendSubMenu(loads, _T("Load State"));
+ fileMenu->AppendSeparator();
+ fileMenu->Append(wImportBackupMemory, _T("Import Backup Memory..."));
+ fileMenu->Append(wExportBackupMemory, _T("Export Backup Memory..."));
+ fileMenu->AppendSeparator();
+ fileMenu->Append(wSaveScreenshotAs, _T("Save Screenshot As"));
+ fileMenu->Append(wQuickScreenshot, _T("Quick Screenshot"));
+ fileMenu->AppendSeparator();
+ fileMenu->Append(wPlayMovie, _T("Play Movie"));
+ fileMenu->Append(wRecordMovie, _T("Record Movie"));
+ fileMenu->Append(wStopMovie, _T("Stop Movie"));
+ fileMenu->AppendSeparator();
+ fileMenu->Append(wLuaWindow, _T("New Lua Script Window..."));
+ fileMenu->AppendSeparator();
+ fileMenu->Append(wxID_EXIT, _T("E&xit\tAlt-X"), _T("Quit this program"));
- void applyInput(){
+ emulationMenu->Append(wPause, _T("&Pause\tAlt-P"), _T("Pause Emulation"));
+ emulationMenu->Append(wReset, _T("&Reset\tAlt-R"), _T("Reset Emulation"));
+
+ configMenu->Append(wConfigureControls, _T("Controls"));
- bool up,down,left,right,x,y,a,b,l,r,start,select;
+ toolsMenu->Append(w3dView, _T("&3d Viewer"));
+ toolsMenu->AppendSeparator();
+ toolsMenu->AppendSubMenu(layersMenu, _T("View Layers"));
- up = down = left = right = x = y = a = b = l = r = start = select = false;
+ layersMenu->AppendCheckItem(wMainGPU, _T("Main GPU"));
+ layersMenu->Check(wMainGPU, true);
+ layersMenu->AppendCheckItem(wMainBG0, _T("Main BG 0"));
+ layersMenu->Check(wMainBG0, true);
+ layersMenu->AppendCheckItem(wMainBG1, _T("Main BG 1"));
+ layersMenu->Check(wMainBG1, true);
+ layersMenu->AppendCheckItem(wMainBG2, _T("Main BG 2"));
+ layersMenu->Check(wMainBG2, true);
+ layersMenu->AppendCheckItem(wMainBG3, _T("Main BG 3"));
+ layersMenu->Check(wMainBG3, true);
+ layersMenu->AppendSeparator();
+ layersMenu->AppendCheckItem(wSubGPU, _T("Sub GPU"));
+ layersMenu->Check(wSubGPU, true);
+ layersMenu->AppendCheckItem(wSubBG0, _T("Sub BG 0"));
+ layersMenu->Check(wSubBG0, true);
+ layersMenu->AppendCheckItem(wSubBG1, _T("Sub BG 1"));
+ layersMenu->Check(wSubBG1, true);
+ layersMenu->AppendCheckItem(wSubBG2, _T("Sub BG 2"));
+ layersMenu->Check(wSubBG2, true);
+ layersMenu->AppendCheckItem(wSubBG3, _T("Sub BG 3"));
+ layersMenu->Check(wSubBG3, true);
- SPADStatus s;
- memset(&s,0,sizeof(s));
+ helpMenu->Append(wWebsite, _T("&Website"));
+ helpMenu->Append(wForums, _T("&Forums"));
+ helpMenu->Append(wSubmitABugReport, _T("&Submit A Bug Report"));
+ helpMenu->Append(wxID_ABOUT);
+
+ viewMenu->AppendSubMenu(rotateMenu, _T("Rotate"));
+ viewMenu->AppendSeparator();
+ viewMenu->Append(wSetHUDFont, _T("&Set HUD Font"));
+ viewMenu->AppendCheckItem(wFrameCounter, _T("&Display Frame Counter"));
+ viewMenu->AppendCheckItem(wFPS, _T("&Display FPS"));
+ viewMenu->AppendCheckItem(wDisplayInput, _T("&Display Input"));
+ viewMenu->AppendCheckItem(wDisplayGraphicalInput, _T("&Display Graphical Input"));
+ viewMenu->AppendCheckItem(wDisplayLagCounter, _T("&Display Lag Counter"));
+ viewMenu->AppendCheckItem(wDisplayMicrophone, _T("&Display Microphone"));
- //TODO !!!!!!!!!!!!!!!!!!!!!! FIXME!!!!!!!!!!1
+ rotateMenu->AppendRadioItem(wRot0, _T("0"));
+ rotateMenu->AppendRadioItem(wRot90, _T("90"));
+ rotateMenu->AppendRadioItem(wRot180, _T("180"));
+ rotateMenu->AppendRadioItem(wRot270, _T("270"));
+ rotateMenu->Check(wRot0+(nds_screen_rotation_angle/90), true);
+
+ /*
+ loadfileMenu(fileMenu);
+ loademulationMenu(emulationMenu);
+ loadconfigMenu(configMenu);
+ loadtoolsMenu(toolsMenu);
+ loadhelpMenu(helpMenu);
+ loadviewMenu(viewMenu);
+
+ loadmenuBar(menuBar);
+ */
+ ChangeRotation(nds_screen_rotation_angle, false);
+ SetMenuBar(menuBar);
+}
+
+void DesmumeFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
+{
+ execute = false;
+ NDS_DeInit();
+ Close(true);
+}
+void DesmumeFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
+{
+ wxMessageBox(
+ wxString::Format(wxT("Desmume on %s"),wxGetOsDescription().c_str()),
+ wxT("About Desmume"),
+ wxOK | wxICON_INFORMATION,
+ this);
+}
+
+void DesmumeFrame::applyInput()
+{
+
+ bool up,down,left,right,x,y,a,b,l,r,start,select;
+
+ up = down = left = right = x = y = a = b = l = r = start = select = false;
+
+ SPADStatus s;
+ memset(&s,0,sizeof(s));
+
+ //TODO !!!!!!!!!!!!!!!!!!!!!! FIXME!!!!!!!!!!1
#ifndef _MSC_VER
// PAD_GetStatus(0, &s);
#endif
- if(s.button & PAD_BUTTON_LEFT)
- left = true;
- if(s.button & PAD_BUTTON_RIGHT)
- right = true;
- if(s.button & PAD_BUTTON_UP)
- up = true;
- if(s.button & PAD_BUTTON_DOWN)
- down = true;
- if(s.button & PAD_BUTTON_A)
- a = true;
- if(s.button & PAD_BUTTON_B)
- b = true;
- if(s.button & PAD_BUTTON_X)
- x = true;
- if(s.button & PAD_BUTTON_Y)
- y = true;
- if(s.button & PAD_TRIGGER_L)
- l = true;
- if(s.button & PAD_TRIGGER_R)
- r = true;
- if(s.button & PAD_BUTTON_START)
- start = true;
+ if(s.button & PAD_BUTTON_LEFT)
+ left = true;
+ if(s.button & PAD_BUTTON_RIGHT)
+ right = true;
+ if(s.button & PAD_BUTTON_UP)
+ up = true;
+ if(s.button & PAD_BUTTON_DOWN)
+ down = true;
+ if(s.button & PAD_BUTTON_A)
+ a = true;
+ if(s.button & PAD_BUTTON_B)
+ b = true;
+ if(s.button & PAD_BUTTON_X)
+ x = true;
+ if(s.button & PAD_BUTTON_Y)
+ y = true;
+ if(s.button & PAD_TRIGGER_L)
+ l = true;
+ if(s.button & PAD_TRIGGER_R)
+ r = true;
+ if(s.button & PAD_BUTTON_START)
+ start = true;
- u16 pad1 = (0 |
- ((a ? 0 : 0x80) >> 7) |
- ((b ? 0 : 0x80) >> 6) |
- ((select? 0 : 0x80) >> 5) |
- ((start ? 0 : 0x80) >> 4) |
- ((right ? 0 : 0x80) >> 3) |
- ((left ? 0 : 0x80) >> 2) |
- ((up ? 0 : 0x80) >> 1) |
- ((down ? 0 : 0x80) ) |
- ((r ? 0 : 0x80) << 1) |
- ((l ? 0 : 0x80) << 2)) ;
+ u16 pad1 = (0 |
+ ((a ? 0 : 0x80) >> 7) |
+ ((b ? 0 : 0x80) >> 6) |
+ ((select? 0 : 0x80) >> 5) |
+ ((start ? 0 : 0x80) >> 4) |
+ ((right ? 0 : 0x80) >> 3) |
+ ((left ? 0 : 0x80) >> 2) |
+ ((up ? 0 : 0x80) >> 1) |
+ ((down ? 0 : 0x80) ) |
+ ((r ? 0 : 0x80) << 1) |
+ ((l ? 0 : 0x80) << 2)) ;
- ((u16 *)MMU.ARM9_REG)[0x130>>1] = (u16)pad1;
- ((u16 *)MMU.ARM7_REG)[0x130>>1] = (u16)pad1;
+ ((u16 *)MMU.ARM9_REG)[0x130>>1] = (u16)pad1;
+ ((u16 *)MMU.ARM7_REG)[0x130>>1] = (u16)pad1;
- bool debug = false;
- bool lidClosed = false;
+ bool debug = false;
+ bool lidClosed = false;
- u16 padExt = (((u16 *)MMU.ARM7_REG)[0x136>>1] & 0x0070) |
- ((x ? 0 : 0x80) >> 7) |
- ((y ? 0 : 0x80) >> 6) |
- ((debug ? 0 : 0x80) >> 4) |
- ((lidClosed) << 7) |
- 0x0034;
+ u16 padExt = (((u16 *)MMU.ARM7_REG)[0x136>>1] & 0x0070) |
+ ((x ? 0 : 0x80) >> 7) |
+ ((y ? 0 : 0x80) >> 6) |
+ ((debug ? 0 : 0x80) >> 4) |
+ ((lidClosed) << 7) |
+ 0x0034;
- ((u16 *)MMU.ARM7_REG)[0x136>>1] = (u16)padExt;
+ ((u16 *)MMU.ARM7_REG)[0x136>>1] = (u16)padExt;
+}
+
+void DesmumeFrame::LoadRom(wxCommandEvent& event)
+{
+ wxFileDialog dialog(this,_T("Load Rom"),wxGetHomeDir(),_T(""),_T("*.nds"),wxFD_OPEN, wxDefaultPosition, wxDefaultSize);
+ if(dialog.ShowModal() == wxID_OK) {
+ history->AddFileToHistory(dialog.GetPath());
+ execute = true;
+ NDS_LoadROM(dialog.GetPath().mb_str(), dialog.GetPath().mb_str());
}
+}
+bool DesmumeFrame::DetransformTouchCoords(int& X, int& Y)
+{
+ int dtX, dtY;
+
+ // TODO: descaling (when scaling is supported)
- //TODO integrate paths system?
- void LoadRom(wxCommandEvent& event){
- wxFileDialog dialog(this,_T("Load Rom"),wxGetHomeDir(),_T(""),_T("*.nds"),wxFD_OPEN, wxDefaultPosition, wxDefaultSize);
- if(dialog.ShowModal() == wxID_OK) {
- history->AddFileToHistory(dialog.GetPath());
- execute = true;
- NDS_LoadROM(dialog.GetPath().mb_str(), dialog.GetPath().mb_str());
- }
- }
-
- //----------------------------------------------------------------------------
- // Touchscreen
- //----------------------------------------------------------------------------
-
- // De-transform coordinates.
- // Returns true if the coordinates are within the touchscreen.
- bool DetransformTouchCoords(int& X, int& Y)
+ // De-rotate coordinates
+ switch (nds_screen_rotation_angle)
{
- int dtX, dtY;
-
- // TODO: descaling (when scaling is supported)
-
- // De-rotate coordinates
- switch (nds_screen_rotation_angle)
- {
- case 0: dtX = X; dtY = Y - 191 - nds_gap_size; break;
- case 90: dtX = Y; dtY = 191 - X; break;
- case 180: dtX = 255 - X; dtY = 191 - Y; break;
- case 270: dtX = 255 - Y; dtY = X - 191 - nds_gap_size; break;
- }
-
- // Atleast one of the coordinates is out of range
- if ((dtX < 0) || (dtX > 255) || (dtY < 0) || (dtY > 191))
- {
- X = wxClip(dtX, 0, 255);
- Y = wxClip(dtY, 0, 191);
- return false;
- }
- else
- {
- X = dtX;
- Y = dtY;
- return true;
- }
+ case 0: dtX = X; dtY = Y - 191 - nds_gap_size; break;
+ case 90: dtX = Y; dtY = 191 - X; break;
+ case 180: dtX = 255 - X; dtY = 191 - Y; break;
+ case 270: dtX = 255 - Y; dtY = X - 191 - nds_gap_size; break;
}
- void OnTouchEvent(wxMouseEvent& evt)
+ // Atleast one of the coordinates is out of range
+ if ((dtX < 0) || (dtX > 255) || (dtY < 0) || (dtY > 191))
{
- wxPoint pt = evt.GetPosition();
- bool inside = DetransformTouchCoords(pt.x, pt.y);
-
- if (evt.LeftDown() && inside)
- {
- Touch = true;
- NDS_setTouchPos((u16)pt.x, (u16)pt.y);
- }
- else if(evt.LeftUp() && Touch)
- {
- Touch = false;
- NDS_releaseTouch();
- }
- else if (Touch)
- {
- NDS_setTouchPos((u16)pt.x, (u16)pt.y);
- }
+ X = wxClip(dtX, 0, 255);
+ Y = wxClip(dtY, 0, 191);
+ return false;
}
-
- //----------------------------------------------------------------------------
- // Video
- //----------------------------------------------------------------------------
-
- void gpu_screen_to_rgb(u8 *rgb1, u8 *rgb2)
+ else
{
- u16 gpu_pixel;
- u8 pixel[3];
- u8 *rgb = rgb1;
- const int rot = nds_screen_rotation_angle;
- int done = false;
- int offset = 0;
+ X = dtX;
+ Y = dtY;
+ return true;
+ }
+}
+void DesmumeFrame::OnTouchEvent(wxMouseEvent& evt)
+{
+ wxPoint pt = evt.GetPosition();
+ bool inside = DetransformTouchCoords(pt.x, pt.y);
+
+ if (evt.LeftDown() && inside)
+ {
+ Touch = true;
+ NDS_setTouchPos((u16)pt.x, (u16)pt.y);
+ }
+ else if(evt.LeftUp() && Touch)
+ {
+ Touch = false;
+ NDS_releaseTouch();
+ }
+ else if (Touch)
+ {
+ NDS_setTouchPos((u16)pt.x, (u16)pt.y);
+ }
+}
+void DesmumeFrame::gpu_screen_to_rgb(u8 *rgb1, u8 *rgb2)
+{
+ u16 gpu_pixel;
+ u8 pixel[3];
+ u8 *rgb = rgb1;
+ const int rot = nds_screen_rotation_angle;
+ int done = false;
+ int offset = 0;
loop:
- for (int i = 0; i < 256; i++) {
- for (int j = 0; j < 192; j++) {
- gpu_pixel = *((u16 *) & GPU_screen[(i + (j + offset) * 256) << 1]);
- pixel[0] = ((gpu_pixel >> 0) & 0x1f) << 3;
- 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;
- }
+ for (int i = 0; i < 256; i++) {
+ for (int j = 0; j < 192; j++) {
+ gpu_pixel = *((u16 *) & GPU_screen[(i + (j + offset) * 256) << 1]);
+ pixel[0] = ((gpu_pixel >> 0) & 0x1f) << 3;
+ 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;
- }
+ if (done == false) {
+ offset = 192;
+ rgb = rgb2;
+ done = true;
+ goto loop;
}
-
- void onIdle(wxIdleEvent &event){
- Refresh(false);
- event.RequestMore();
- if (execute)
- {
- applyInput();
- NDS_exec();
- SPU_Emulate_user();
- osd->update();
- DrawHUD();
- osd->clear();
- }
- else
- wxMilliSleep(250);
- // wxMicroSleep(16.7*1000);
- }
-
- void pause(wxCommandEvent& event){
- if (execute) {
- execute=false;
- SPU_Pause(1);
- } else {
- execute=true;
- SPU_Pause(0);
- }
- }
- void reset(wxCommandEvent& event){NDS_Reset();}
-
- void frameCounter(wxCommandEvent& event){
- CommonSettings.hud.FrameCounterDisplay ^= true;
- osd->clear();
- }
-
- void FPS(wxCommandEvent& event){
- CommonSettings.hud.FpsDisplay ^= true;
- osd->clear();
- }
- void displayInput(wxCommandEvent& event){
- CommonSettings.hud.ShowInputDisplay ^= true;
- osd->clear();
- }
- void displayGraphicalInput(wxCommandEvent& event){
- CommonSettings.hud.ShowGraphicalInputDisplay ^= true;
- osd->clear();
- }
- void displayLagCounter(wxCommandEvent& event){
- CommonSettings.hud.ShowLagFrameCounter ^= true;
- osd->clear();
- }
- void displayMicrophone(wxCommandEvent& event){
- CommonSettings.hud.ShowMicrophone ^= true;
- osd->clear();
- }
-
- void mainG(int n) {
- if(CommonSettings.dispLayers[0][n])
- GPU_remove(MainScreen.gpu, n);
- else
- GPU_addBack(MainScreen.gpu, n);
- }
- void subG(int n) {
- if(CommonSettings.dispLayers[1][n])
- GPU_remove(SubScreen.gpu, n);
- else
- GPU_addBack(SubScreen.gpu, n);
- }
- void mainGPU(wxCommandEvent& event){CommonSettings.showGpu.main^=true;}
- void mainBG0(wxCommandEvent& event){mainG(0);}
- void mainBG1(wxCommandEvent& event){mainG(1);}
- void mainBG2(wxCommandEvent& event){mainG(2);}
- void mainBG3(wxCommandEvent& event){mainG(3);}
-
- void subGPU(wxCommandEvent& event){CommonSettings.showGpu.sub^=true;}
- void subBG0(wxCommandEvent& event){subG(0);}
- void subBG1(wxCommandEvent& event){subG(1);}
- void subBG2(wxCommandEvent& event){subG(2);}
- void subBG3(wxCommandEvent& event){subG(3);}
-
- void website(wxCommandEvent& event) {wxLaunchDefaultBrowser(_T("http://desmume.org/"));}
- void forums(wxCommandEvent& event) {wxLaunchDefaultBrowser(_T("http://forums.desmume.org/index.php"));}
- void submitABugReport(wxCommandEvent& event) {wxLaunchDefaultBrowser(_T("http://sourceforge.net/tracker/?func=add&group_id=164579&atid=832291"));}
-
- void _3dView(wxCommandEvent& event) {
- driver->VIEW3D_Init();
- driver->view3d->Launch();
- }
-
- void saveStateAs(wxCommandEvent& event) {
- wxFileDialog dialog(this,_T("Save State As"),wxGetHomeDir(),_T(""),_T("*.dst"),wxFD_SAVE, wxDefaultPosition, wxDefaultSize);
- if(dialog.ShowModal() == wxID_OK)
- savestate_save (dialog.GetPath().mb_str());
- }
- void loadStateFrom(wxCommandEvent& event) {
- wxFileDialog dialog(this,_T("Load State From"),wxGetHomeDir(),_T(""),_T("*.dst"),wxFD_OPEN, wxDefaultPosition, wxDefaultSize);
- if(dialog.ShowModal() == wxID_OK)
- savestate_load (dialog.GetPath().mb_str());
- }
-
- void closeRom(wxCommandEvent& event) {
- NDS_FreeROM();
- execute = false;
- SPU_Pause(1);
-#ifdef HAVE_LIBAGG
- Hud.resetTransient();
-#endif
- NDS_Reset();
- }
-
- void importBackupMemory(wxCommandEvent& event) {
- wxFileDialog dialog(this,_T("Import Backup Memory"),wxGetHomeDir(),_T(""),_T("*.duc, *.sav"),wxFD_OPEN, wxDefaultPosition, wxDefaultSize);
- if(dialog.ShowModal() == wxID_OK)
- if (!NDS_ImportSave(dialog.GetPath().mb_str()))
- wxMessageBox(wxString::Format(_T("Save was not successfully imported")),_T("Error"),wxOK | wxICON_ERROR,this);
- }
-
- void exportBackupMemory(wxCommandEvent& event) {
- wxFileDialog dialog(this,_T("Export Backup Memory"),wxGetHomeDir(),_T(""),_T("*.duc, *.sav"),wxFD_SAVE, wxDefaultPosition, wxDefaultSize);
- if(dialog.ShowModal() == wxID_OK)
- if (!NDS_ExportSave(dialog.GetPath().mb_str()))
- wxMessageBox(wxString::Format(_T("Save was not successfully exported")),_T("Error"),wxOK | wxICON_ERROR,this);
- }
- void saveScreenshotAs(wxCommandEvent& event) {
- wxFileDialog dialog(this,_T("Save Screenshot As"),wxGetHomeDir(),_T(""),_T("*.png"),wxFD_SAVE, wxDefaultPosition, wxDefaultSize);
- if(dialog.ShowModal() == wxID_OK)
- NDS_WritePNG(dialog.GetPath().mb_str());
- }
- void quickScreenshot(wxCommandEvent& event) {
- NDS_WritePNG(wxStandardPaths::Get().GetExecutablePath().mb_str());//TODO GetExecutablePath is wrong
- }
-
- //TODO
- void playMovie(wxCommandEvent& event) {}
- void recordMovie(wxCommandEvent& event) {}
- void stopMovie(wxCommandEvent& event) {FCEUI_StopMovie();}
-
- void OnOpenLuaWindow(wxCommandEvent& WXUNUSED (event))
- {
-#ifdef WIN32
- new wxLuaWindow(this, wxDefaultPosition, wxSize(600, 390));
-#endif
- }
-
- void OnOpenControllerConfiguration(wxCommandEvent& WXUNUSED (event))
- {
-//#ifndef _MSC_VER
- // new PADConfigDialogSimple(this);
- (new wxControlsConfigDialog(this))->ShowModal();
-//#endif
- }
-
- wxMenu* MakeStatesSubMenu( int baseid ) const
- {
- wxMenu* mnuSubstates = new wxMenu();
-
- for (int i = 0; i < 10; i++)
- {
- mnuSubstates->Append( baseid+i, wxString::Format(_T("Slot %d"), i) );
- }
- return mnuSubstates;
- }
- void Menu_SaveStates(wxCommandEvent &event);
- void Menu_LoadStates(wxCommandEvent &event);
- void NDSInitialize();
- void OnRotation(wxCommandEvent &event);
- void ChangeRotation(int rot, bool skip);
- void onResize(wxSizeEvent &event);
- bool LoadSettings();
- bool SaveSettings();
- void OnClose(wxCloseEvent &event);
- void OnOpenRecent(wxCommandEvent &event);
-
-private:
- struct NDS_fw_config_data fw_config;
- wxFileHistory* history;
-#ifdef GDB_STUB
- gdbstub_handle_t arm9_gdb_stub;
- gdbstub_handle_t arm7_gdb_stub;
- struct armcpu_memory_iface *arm9_memio;
- struct armcpu_memory_iface *arm7_memio;
- struct armcpu_ctrl_iface *arm9_ctrl_iface;
- struct armcpu_ctrl_iface *arm7_ctrl_iface;
-#endif
- DECLARE_EVENT_TABLE()
-};
-
-enum
+}
+void DesmumeFrame::onPaint(wxPaintEvent &event)
{
- wPause,
- wReset,
- wFrameCounter,
- wFPS,
- wDisplayInput,
- wDisplayGraphicalInput,
- wDisplayLagCounter,
- wDisplayMicrophone,
- wMainGPU,
- wMainBG0,
- wMainBG1,
- wMainBG2,
- wMainBG3,
- wSubGPU,
- wSubBG0,
- wSubBG1,
- wSubBG2,
- wSubBG3,
- wWebsite,
- wForums,
- wSubmitABugReport,
- w3dView,
- wSaveStateAs,
- wLoadStateFrom,
- wCloseRom,
- wImportBackupMemory,
- wExportBackupMemory,
- wPlayMovie,
- wRecordMovie,
- wStopMovie,
- wSaveScreenshotAs,
- wQuickScreenshot,
- wLuaWindow,
- wConfigureControls,
- wRot0,
- wRot90,
- wRot180,
- wRot270,
- /* stupid enums: these two should be the at the end */
- wLoadState01,
- wSaveState01 = wLoadState01+20
-};
+ 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 DesmumeFrame::onIdle(wxIdleEvent &event)
+{
+ Refresh(false);
+ event.RequestMore();
+ if (execute)
+ {
+ applyInput();
+ NDS_exec();
+ SPU_Emulate_user();
+ osd->update();
+ DrawHUD();
+ osd->clear();
+ }
+ else
+ wxMilliSleep(250);
+ // wxMicroSleep(16.7*1000);
+}
+
+void DesmumeFrame::pause(wxCommandEvent& event)
+{
+ if (execute) {
+ execute=false;
+ SPU_Pause(1);
+ } else {
+ execute=true;
+ SPU_Pause(0);
+ }
+}
+void DesmumeFrame::frameCounter(wxCommandEvent& event)
+{
+ CommonSettings.hud.FrameCounterDisplay ^= true;
+ osd->clear();
+}
+void DesmumeFrame::FPS(wxCommandEvent& event)
+{
+ CommonSettings.hud.FpsDisplay ^= true;
+ osd->clear();
+}
+
+void DesmumeFrame::displayInput(wxCommandEvent& event)
+{
+ CommonSettings.hud.ShowInputDisplay ^= true;
+ osd->clear();
+}
+
+void DesmumeFrame::displayGraphicalInput(wxCommandEvent& event)
+{
+ CommonSettings.hud.ShowGraphicalInputDisplay ^= true;
+ osd->clear();
+}
+void DesmumeFrame::displayLagCounter(wxCommandEvent& event)
+{
+ CommonSettings.hud.ShowLagFrameCounter ^= true;
+ osd->clear();
+}
+void DesmumeFrame::displayMicrophone(wxCommandEvent& event)
+{
+ CommonSettings.hud.ShowMicrophone ^= true;
+ osd->clear();
+}
+void DesmumeFrame::setHUDFont(wxCommandEvent &event)
+{
+ wxArrayString fontchoices;
+ for(int i = 0; i < font_Nums;i++)
+ {
+ fontchoices.Add(_T(fonts_list[i].name));
+ }
+
+ wxSingleChoiceDialog fontDialog(this,
+ _T("Please select a font for use on the HUD:\n"),
+ _T("Configure HUD font"),
+ fontchoices);
+ fontDialog.SetSelection(fontchoices.GetCount() - 1);
+ if(fontDialog.ShowModal() == wxID_OK)
+ {
+ aggDraw.hud->setFont(fonts_list[fontDialog.GetSelection()].name);
+ }
+
+}
+void DesmumeFrame::mainG(int n)
+{
+ if(CommonSettings.dispLayers[0][n])
+ GPU_remove(MainScreen.gpu, n);
+ else
+ GPU_addBack(MainScreen.gpu, n);
+}
+void DesmumeFrame::subG(int n)
+{
+ if(CommonSettings.dispLayers[1][n])
+ GPU_remove(SubScreen.gpu, n);
+ else
+ GPU_addBack(SubScreen.gpu, n);
+}
+void DesmumeFrame::_3dView(wxCommandEvent& event)
+{
+ driver->VIEW3D_Init();
+ driver->view3d->Launch();
+}
+void DesmumeFrame::saveStateAs(wxCommandEvent& event)
+{
+ wxFileDialog dialog(this,_T("Save State As"),wxGetHomeDir(),_T(""),_T("*.dst"),wxFD_SAVE, wxDefaultPosition, wxDefaultSize);
+ if(dialog.ShowModal() == wxID_OK)
+ savestate_save (dialog.GetPath().mb_str());
+}
+void DesmumeFrame::loadStateFrom(wxCommandEvent& event)
+{
+ wxFileDialog dialog(this,_T("Load State From"),wxGetHomeDir(),_T(""),_T("*.dst"),wxFD_OPEN, wxDefaultPosition, wxDefaultSize);
+ if(dialog.ShowModal() == wxID_OK)
+ savestate_load (dialog.GetPath().mb_str());
+}
+void DesmumeFrame::closeRom(wxCommandEvent& event)
+{
+ NDS_FreeROM();
+ execute = false;
+ SPU_Pause(1);
+#ifdef HAVE_LIBAGG
+ Hud.resetTransient();
+#endif
+ NDS_Reset();
+}
+void DesmumeFrame::importBackupMemory(wxCommandEvent& event)
+{
+ wxFileDialog dialog(this,_T("Import Backup Memory"),wxGetHomeDir(),_T(""),_T("*.duc, *.sav"),wxFD_OPEN, wxDefaultPosition, wxDefaultSize);
+ if(dialog.ShowModal() == wxID_OK)
+ if (!NDS_ImportSave(dialog.GetPath().mb_str()))
+ wxMessageBox(wxString::Format(_T("Save was not successfully imported")),_T("Error"),wxOK | wxICON_ERROR,this);
+}
+void DesmumeFrame::exportBackupMemory(wxCommandEvent& event)
+{
+ wxFileDialog dialog(this,_T("Export Backup Memory"),wxGetHomeDir(),_T(""),_T("*.duc, *.sav"),wxFD_SAVE, wxDefaultPosition, wxDefaultSize);
+ if(dialog.ShowModal() == wxID_OK)
+ if (!NDS_ExportSave(dialog.GetPath().mb_str()))
+ wxMessageBox(wxString::Format(_T("Save was not successfully exported")),_T("Error"),wxOK | wxICON_ERROR,this);
+}
+void DesmumeFrame::saveScreenshotAs(wxCommandEvent& event)
+{
+ wxFileDialog dialog(this,_T("Save Screenshot As"),wxGetHomeDir(),_T(""),_T("*.png"),wxFD_SAVE, wxDefaultPosition, wxDefaultSize);
+ if(dialog.ShowModal() == wxID_OK)
+ NDS_WritePNG(dialog.GetPath().mb_str());
+}
+void DesmumeFrame::quickScreenshot(wxCommandEvent& event)
+{
+ NDS_WritePNG(wxStandardPaths::Get().GetExecutablePath().mb_str());//TODO GetExecutablePath is wrong
+}
+void DesmumeFrame::OnOpenLuaWindow(wxCommandEvent& WXUNUSED (event))
+{
+#ifdef WIN32
+ new wxLuaWindow(this, wxDefaultPosition, wxSize(600, 390));
+#endif
+}
+void DesmumeFrame::OnOpenControllerConfiguration(wxCommandEvent& WXUNUSED (event))
+{
+//#ifndef _MSC_VER
+// new PADConfigDialogSimple(this);
+ (new wxControlsConfigDialog(this))->ShowModal();
+//#endif
+}
void DesmumeFrame::Menu_SaveStates(wxCommandEvent &event){savestate_slot(event.GetId() - wSaveState01);}
void DesmumeFrame::Menu_LoadStates(wxCommandEvent &event){loadstate_slot(event.GetId() - wLoadState01);}
@@ -579,240 +655,74 @@ void DesmumeFrame::onResize(wxSizeEvent &event) {
BEGIN_EVENT_TABLE(DesmumeFrame, wxFrame)
-EVT_PAINT(DesmumeFrame::onPaint)
-EVT_IDLE(DesmumeFrame::onIdle)
-EVT_SIZE(DesmumeFrame::onResize)
-EVT_LEFT_DOWN(DesmumeFrame::OnTouchEvent)
-EVT_LEFT_UP(DesmumeFrame::OnTouchEvent)
-EVT_LEFT_DCLICK(DesmumeFrame::OnTouchEvent)
-EVT_MOTION(DesmumeFrame::OnTouchEvent)
-EVT_CLOSE(DesmumeFrame::OnClose)
+ EVT_PAINT(DesmumeFrame::onPaint)
+ EVT_IDLE(DesmumeFrame::onIdle)
+ EVT_SIZE(DesmumeFrame::onResize)
+ 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_OPEN, DesmumeFrame::LoadRom)
-EVT_MENU(wxID_ABOUT,DesmumeFrame::OnAbout)
-EVT_MENU(wPause,DesmumeFrame::pause)
-EVT_MENU(wReset,DesmumeFrame::reset)
-EVT_MENU(wFrameCounter,DesmumeFrame::frameCounter)
-EVT_MENU(wFPS,DesmumeFrame::FPS)
-EVT_MENU(wDisplayInput,DesmumeFrame::displayInput)
-EVT_MENU(wDisplayGraphicalInput,DesmumeFrame::displayGraphicalInput)
-EVT_MENU(wDisplayLagCounter,DesmumeFrame::displayLagCounter)
-EVT_MENU(wDisplayMicrophone,DesmumeFrame::displayMicrophone)
+ EVT_MENU(wxID_EXIT, DesmumeFrame::OnQuit)
+ EVT_MENU(wxID_OPEN, DesmumeFrame::LoadRom)
+ EVT_MENU(wxID_ABOUT,DesmumeFrame::OnAbout)
+ EVT_MENU(wPause,DesmumeFrame::pause)
+ EVT_MENU(wReset,DesmumeFrame::reset)
+ EVT_MENU(wFrameCounter,DesmumeFrame::frameCounter)
+ EVT_MENU(wFPS,DesmumeFrame::FPS)
+ EVT_MENU(wDisplayInput,DesmumeFrame::displayInput)
+ EVT_MENU(wDisplayGraphicalInput,DesmumeFrame::displayGraphicalInput)
+ EVT_MENU(wDisplayLagCounter,DesmumeFrame::displayLagCounter)
+ EVT_MENU(wDisplayMicrophone,DesmumeFrame::displayMicrophone)
+ EVT_MENU(wSetHUDFont,DesmumeFrame::setHUDFont)
-EVT_MENU(wMainGPU,DesmumeFrame::mainGPU)
-EVT_MENU(wMainBG0,DesmumeFrame::mainBG0)
-EVT_MENU(wMainBG1,DesmumeFrame::mainBG1)
-EVT_MENU(wMainBG2,DesmumeFrame::mainBG2)
-EVT_MENU(wMainBG3,DesmumeFrame::mainBG3)
-EVT_MENU(wSubGPU,DesmumeFrame::subGPU)
-EVT_MENU(wSubBG0,DesmumeFrame::subBG0)
-EVT_MENU(wSubBG1,DesmumeFrame::subBG1)
-EVT_MENU(wSubBG2,DesmumeFrame::subBG2)
-EVT_MENU(wSubBG3,DesmumeFrame::subBG3)
+ EVT_MENU(wMainGPU,DesmumeFrame::mainGPU)
+ EVT_MENU(wMainBG0,DesmumeFrame::mainBG0)
+ EVT_MENU(wMainBG1,DesmumeFrame::mainBG1)
+ EVT_MENU(wMainBG2,DesmumeFrame::mainBG2)
+ EVT_MENU(wMainBG3,DesmumeFrame::mainBG3)
+ EVT_MENU(wSubGPU,DesmumeFrame::subGPU)
+ EVT_MENU(wSubBG0,DesmumeFrame::subBG0)
+ EVT_MENU(wSubBG1,DesmumeFrame::subBG1)
+ EVT_MENU(wSubBG2,DesmumeFrame::subBG2)
+ EVT_MENU(wSubBG3,DesmumeFrame::subBG3)
-EVT_MENU(wWebsite,DesmumeFrame::website)
-EVT_MENU(wForums,DesmumeFrame::forums)
-EVT_MENU(wSubmitABugReport,DesmumeFrame::submitABugReport)
+ EVT_MENU(wWebsite,DesmumeFrame::website)
+ EVT_MENU(wForums,DesmumeFrame::forums)
+ EVT_MENU(wSubmitABugReport,DesmumeFrame::submitABugReport)
-EVT_MENU(wSaveStateAs,DesmumeFrame::saveStateAs)
-EVT_MENU(wLoadStateFrom,DesmumeFrame::loadStateFrom)
+ EVT_MENU(wSaveStateAs,DesmumeFrame::saveStateAs)
+ EVT_MENU(wLoadStateFrom,DesmumeFrame::loadStateFrom)
-EVT_MENU_RANGE(wSaveState01,wSaveState01+9,DesmumeFrame::Menu_SaveStates)
-EVT_MENU_RANGE(wLoadState01,wLoadState01+9,DesmumeFrame::Menu_LoadStates)
+ EVT_MENU_RANGE(wSaveState01,wSaveState01+9,DesmumeFrame::Menu_SaveStates)
+ EVT_MENU_RANGE(wLoadState01,wLoadState01+9,DesmumeFrame::Menu_LoadStates)
-EVT_MENU(wCloseRom,DesmumeFrame::closeRom)
-EVT_MENU(wImportBackupMemory,DesmumeFrame::importBackupMemory)
-EVT_MENU(wExportBackupMemory,DesmumeFrame::exportBackupMemory)
+ EVT_MENU(wCloseRom,DesmumeFrame::closeRom)
+ EVT_MENU(wImportBackupMemory,DesmumeFrame::importBackupMemory)
+ 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(wQuickScreenshot,DesmumeFrame::quickScreenshot)
+ EVT_MENU(wSaveScreenshotAs,DesmumeFrame::saveScreenshotAs)
+ EVT_MENU(wQuickScreenshot,DesmumeFrame::quickScreenshot)
-EVT_MENU(wPlayMovie,DesmumeFrame::playMovie)
-EVT_MENU(wStopMovie,DesmumeFrame::stopMovie)
-EVT_MENU(wRecordMovie,DesmumeFrame::recordMovie)
+ EVT_MENU(wPlayMovie,DesmumeFrame::playMovie)
+ EVT_MENU(wStopMovie,DesmumeFrame::stopMovie)
+ EVT_MENU(wRecordMovie,DesmumeFrame::recordMovie)
-EVT_MENU(w3dView,DesmumeFrame::_3dView)
+ 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()
IMPLEMENT_APP(Desmume)
-static SPADInitialize PADInitialize;
-
-void DesmumeFrame::NDSInitialize() {
- NDS_FillDefaultFirmwareConfigData( &fw_config);
-
-#ifdef HAVE_LIBAGG
- Desmume_InitOnce();
- aggDraw.hud->attach((u8*)GPU_screen, 256, 384, 1024);//TODO
-#endif
-
- //TODO
- addon_type = NDS_ADDON_NONE;
- addonsChangePak(addon_type);
-
-#ifdef GDB_STUB
- arm9_memio = &arm9_base_memory_iface;
- arm7_memio = &arm7_base_memory_iface;
- NDS_Init( arm9_memio, &arm9_ctrl_iface,
- arm7_memio, &arm7_ctrl_iface);
-#else
- NDS_Init();
-#endif
- SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4);
- NDS_3D_ChangeCore(0);
- NDS_CreateDummyFirmware( &fw_config);
-}
-
-bool Desmume::OnInit()
-{
-
- if ( !wxApp::OnInit() )
- return false;
-
-
-#ifdef WIN32
- extern void OpenConsole();
- OpenConsole();
-#endif
-
- SetAppName(_T("desmume"));
- wxConfigBase *pConfig = new wxFileConfig();
- wxConfigBase::Set(pConfig);
- wxString emu_version(EMU_DESMUME_NAME_AND_VERSION(), wxConvUTF8);
- DesmumeFrame *frame = new DesmumeFrame(emu_version);
- frame->NDSInitialize();
-
- frame->Show(true);
-
- PADInitialize.padNumber = 1;
-
-#ifndef WIN32
- extern void Initialize(void *init);
-
- Initialize(&PADInitialize);
-#endif
-
- return true;
-}
-
-DesmumeFrame::DesmumeFrame(const wxString& title)
-: wxFrame(NULL, wxID_ANY, title)
-{
- history = new wxFileHistory;
- wxMenu *fileMenu = new wxMenu;
- wxMenu *emulationMenu = new wxMenu;
- wxMenu *viewMenu = new wxMenu;
- wxMenu *configMenu = new wxMenu;
- wxMenu *toolsMenu = new wxMenu;
- wxMenu *helpMenu = new wxMenu;
- wxMenu *saves(MakeStatesSubMenu(wSaveState01));
- wxMenu *loads(MakeStatesSubMenu(wLoadState01));
- wxMenu *recentMenu = new wxMenu;
- history->UseMenu(recentMenu);
-
- fileMenu->Append(wxID_OPEN, _T("Load R&om\tAlt-R"));
- fileMenu->AppendSubMenu(recentMenu, _T("Recent files"));
- fileMenu->Append(wCloseRom, _T("Close Rom"));
- fileMenu->AppendSeparator();
- fileMenu->Append(wSaveStateAs, _T("Save State As..."));
- fileMenu->Append(wLoadStateFrom, _T("Load State From..."));
- fileMenu->AppendSubMenu(saves, _T("Save State"));
- fileMenu->AppendSubMenu(loads, _T("Load State"));
- fileMenu->AppendSeparator();
- fileMenu->Append(wImportBackupMemory, _T("Import Backup Memory..."));
- fileMenu->Append(wExportBackupMemory, _T("Export Backup Memory..."));
- fileMenu->AppendSeparator();
- fileMenu->Append(wSaveScreenshotAs, _T("Save Screenshot As"));
- fileMenu->Append(wQuickScreenshot, _T("Quick Screenshot"));
- fileMenu->AppendSeparator();
- fileMenu->Append(wPlayMovie, _T("Play Movie"));
- fileMenu->Append(wRecordMovie, _T("Record Movie"));
- fileMenu->Append(wStopMovie, _T("Stop Movie"));
- fileMenu->AppendSeparator();
- fileMenu->Append(wLuaWindow, _T("New Lua Script Window..."));
- fileMenu->AppendSeparator();
- fileMenu->Append(wxID_EXIT, _T("E&xit\tAlt-X"), _T("Quit this program"));
-
- emulationMenu->Append(wPause, _T("&Pause\tAlt-P"), _T("Pause Emulation"));
- emulationMenu->Append(wReset, _T("&Reset\tAlt-R"), _T("Reset Emulation"));
-
- wxMenu *rotateMenu = new wxMenu;
- {
- rotateMenu->AppendRadioItem(wRot0, _T("0"));
- rotateMenu->AppendRadioItem(wRot90, _T("90"));
- rotateMenu->AppendRadioItem(wRot180, _T("180"));
- rotateMenu->AppendRadioItem(wRot270, _T("270"));
- }
- viewMenu->AppendSubMenu(rotateMenu, _T("Rotate"));
- viewMenu->AppendSeparator();
- viewMenu->AppendCheckItem(wFrameCounter, _T("&Display Frame Counter"));
- viewMenu->AppendCheckItem(wFPS, _T("&Display FPS"));
- viewMenu->AppendCheckItem(wDisplayInput, _T("&Display Input"));
- viewMenu->AppendCheckItem(wDisplayGraphicalInput, _T("&Display Graphical Input"));
- viewMenu->AppendCheckItem(wDisplayLagCounter, _T("&Display Lag Counter"));
- viewMenu->AppendCheckItem(wDisplayMicrophone, _T("&Display Microphone"));
-
- toolsMenu->Append(w3dView, _T("&3d Viewer"));
- wxMenu *layersMenu = new wxMenu;
- {
- layersMenu->AppendCheckItem(wMainGPU, _T("Main GPU"));
- layersMenu->Check(wMainGPU, true);
- layersMenu->AppendCheckItem(wMainBG0, _T("Main BG 0"));
- layersMenu->Check(wMainBG0, true);
- layersMenu->AppendCheckItem(wMainBG1, _T("Main BG 1"));
- layersMenu->Check(wMainBG1, true);
- layersMenu->AppendCheckItem(wMainBG2, _T("Main BG 2"));
- layersMenu->Check(wMainBG2, true);
- layersMenu->AppendCheckItem(wMainBG3, _T("Main BG 3"));
- layersMenu->Check(wMainBG3, true);
- layersMenu->AppendSeparator();
- layersMenu->AppendCheckItem(wSubGPU, _T("Sub GPU"));
- layersMenu->Check(wSubGPU, true);
- layersMenu->AppendCheckItem(wSubBG0, _T("Sub BG 0"));
- layersMenu->Check(wSubBG0, true);
- layersMenu->AppendCheckItem(wSubBG1, _T("Sub BG 1"));
- layersMenu->Check(wSubBG1, true);
- layersMenu->AppendCheckItem(wSubBG2, _T("Sub BG 2"));
- layersMenu->Check(wSubBG2, true);
- layersMenu->AppendCheckItem(wSubBG3, _T("Sub BG 3"));
- layersMenu->Check(wSubBG3, true);
- }
-
- configMenu->Append(wConfigureControls, _T("Controls"));
-
- toolsMenu->AppendSeparator();
- toolsMenu->AppendSubMenu(layersMenu, _T("View Layers"));
-
- helpMenu->Append(wWebsite, _T("&Website"));
- helpMenu->Append(wForums, _T("&Forums"));
- helpMenu->Append(wSubmitABugReport, _T("&Submit A Bug Report"));
- helpMenu->Append(wxID_ABOUT);
-
- wxMenuBar *menuBar = new wxMenuBar();
- menuBar->Append(fileMenu, _T("&File"));
- menuBar->Append(emulationMenu, _T("&Emulation"));
- menuBar->Append(viewMenu, _T("&View"));
- menuBar->Append(configMenu, _T("&Config"));
- menuBar->Append(toolsMenu, _T("&Tools"));
- menuBar->Append(helpMenu, _T("&Help"));
- SetMenuBar(menuBar);
-
- // CreateStatusBar(2);
- // SetStatusText("Welcome to Desmume!");
- LoadSettings();
- rotateMenu->Check(wRot0+(nds_screen_rotation_angle/90), true);
- ChangeRotation(nds_screen_rotation_angle, false);
-}
#ifdef WIN32
/*
@@ -863,3 +773,133 @@ void DesmumeFrame::OnOpenRecent(wxCommandEvent &event) {
else
history->RemoveFileFromHistory(id);
}
+
+
+void DesmumeFrame::loadfileMenu(wxMenu *fileMenu)
+{
+ wxMenu *recentMenu = new wxMenu;
+ wxMenu *saves(MakeStatesSubMenu(wSaveState01));
+ wxMenu *loads(MakeStatesSubMenu(wLoadState01));
+ fileMenu->Append(wxID_OPEN, _T("Load R&om\tAlt-R"));
+ fileMenu->AppendSubMenu(recentMenu, _T("Recent files"));
+ fileMenu->Append(wCloseRom, _T("Close Rom"));
+ fileMenu->AppendSeparator();
+ fileMenu->Append(wSaveStateAs, _T("Save State As..."));
+ fileMenu->Append(wLoadStateFrom, _T("Load State From..."));
+ fileMenu->AppendSubMenu(saves, _T("Save State"));
+ fileMenu->AppendSubMenu(loads, _T("Load State"));
+ fileMenu->AppendSeparator();
+ fileMenu->Append(wImportBackupMemory, _T("Import Backup Memory..."));
+ fileMenu->Append(wExportBackupMemory, _T("Export Backup Memory..."));
+ fileMenu->AppendSeparator();
+ fileMenu->Append(wSaveScreenshotAs, _T("Save Screenshot As"));
+ fileMenu->Append(wQuickScreenshot, _T("Quick Screenshot"));
+ fileMenu->AppendSeparator();
+ fileMenu->Append(wPlayMovie, _T("Play Movie"));
+ fileMenu->Append(wRecordMovie, _T("Record Movie"));
+ fileMenu->Append(wStopMovie, _T("Stop Movie"));
+ fileMenu->AppendSeparator();
+ fileMenu->Append(wLuaWindow, _T("New Lua Script Window..."));
+ fileMenu->AppendSeparator();
+ fileMenu->Append(wxID_EXIT, _T("E&xit\tAlt-X"), _T("Quit this program"));
+
+// history->UseMenu(recentMenu);
+}
+void DesmumeFrame::loademulationMenu(wxMenu *emulationMenu)
+{
+ emulationMenu->Append(wPause, _T("&Pause\tAlt-P"), _T("Pause Emulation"));
+ emulationMenu->Append(wReset, _T("&Reset\tAlt-R"), _T("Reset Emulation"));
+}
+void DesmumeFrame::loadrotateMenu(wxMenu *rotateMenu)
+{
+ rotateMenu->AppendRadioItem(wRot0, _T("0"));
+ rotateMenu->AppendRadioItem(wRot90, _T("90"));
+ rotateMenu->AppendRadioItem(wRot180, _T("180"));
+ rotateMenu->AppendRadioItem(wRot270, _T("270"));
+ rotateMenu->Check(wRot0+(nds_screen_rotation_angle/90), true);
+}
+void DesmumeFrame::loadviewMenu(wxMenu *viewMenu)
+{
+ wxMenu *rotateMenu = new wxMenu;
+ viewMenu->AppendSubMenu(rotateMenu, _T("Rotate"));
+ viewMenu->AppendSeparator();
+ viewMenu->Append(wSetHUDFont, _T("&Set HUD Font"));
+ viewMenu->AppendCheckItem(wFrameCounter, _T("&Display Frame Counter"));
+ viewMenu->AppendCheckItem(wFPS, _T("&Display FPS"));
+ viewMenu->AppendCheckItem(wDisplayInput, _T("&Display Input"));
+ viewMenu->AppendCheckItem(wDisplayGraphicalInput, _T("&Display Graphical Input"));
+ viewMenu->AppendCheckItem(wDisplayLagCounter, _T("&Display Lag Counter"));
+ viewMenu->AppendCheckItem(wDisplayMicrophone, _T("&Display Microphone"));
+ loadrotateMenu(rotateMenu);
+}
+void DesmumeFrame::loadtoolsMenu(wxMenu *toolsMenu)
+{
+ wxMenu *layersMenu = new wxMenu;
+
+ toolsMenu->Append(w3dView, _T("&3d Viewer"));
+ toolsMenu->AppendSeparator();
+ toolsMenu->AppendSubMenu(layersMenu, _T("View Layers"));
+
+ loadlayersMenu(layersMenu);
+}
+
+void DesmumeFrame::loadlayersMenu(wxMenu *layersMenu)
+{
+ layersMenu->AppendCheckItem(wMainGPU, _T("Main GPU"));
+ layersMenu->Check(wMainGPU, true);
+ layersMenu->AppendCheckItem(wMainBG0, _T("Main BG 0"));
+ layersMenu->Check(wMainBG0, true);
+ layersMenu->AppendCheckItem(wMainBG1, _T("Main BG 1"));
+ layersMenu->Check(wMainBG1, true);
+ layersMenu->AppendCheckItem(wMainBG2, _T("Main BG 2"));
+ layersMenu->Check(wMainBG2, true);
+ layersMenu->AppendCheckItem(wMainBG3, _T("Main BG 3"));
+ layersMenu->Check(wMainBG3, true);
+ layersMenu->AppendSeparator();
+ layersMenu->AppendCheckItem(wSubGPU, _T("Sub GPU"));
+ layersMenu->Check(wSubGPU, true);
+ layersMenu->AppendCheckItem(wSubBG0, _T("Sub BG 0"));
+ layersMenu->Check(wSubBG0, true);
+ layersMenu->AppendCheckItem(wSubBG1, _T("Sub BG 1"));
+ layersMenu->Check(wSubBG1, true);
+ layersMenu->AppendCheckItem(wSubBG2, _T("Sub BG 2"));
+ layersMenu->Check(wSubBG2, true);
+ layersMenu->AppendCheckItem(wSubBG3, _T("Sub BG 3"));
+ layersMenu->Check(wSubBG3, true);
+}
+void DesmumeFrame::loadconfigMenu(wxMenu *configMenu)
+{
+ configMenu->Append(wConfigureControls, _T("Controls"));
+}
+void DesmumeFrame::loadhelpMenu(wxMenu *helpMenu)
+{
+ helpMenu->Append(wWebsite, _T("&Website"));
+ helpMenu->Append(wForums, _T("&Forums"));
+ helpMenu->Append(wSubmitABugReport, _T("&Submit A Bug Report"));
+ helpMenu->Append(wxID_ABOUT);
+}
+
+void DesmumeFrame::loadmenuBar(wxMenuBar *menuBar)
+{
+ wxMenu *fileMenu = new wxMenu;
+ wxMenu *emulationMenu = new wxMenu;
+ wxMenu *viewMenu = new wxMenu;
+ wxMenu *configMenu = new wxMenu;
+ wxMenu *toolsMenu = new wxMenu;
+ wxMenu *helpMenu = new wxMenu;
+
+ menuBar->Append(fileMenu, _T("&File"));
+ menuBar->Append(emulationMenu, _T("&Emulation"));
+ menuBar->Append(viewMenu, _T("&View"));
+ menuBar->Append(configMenu, _T("&Config"));
+ menuBar->Append(toolsMenu, _T("&Tools"));
+ menuBar->Append(helpMenu, _T("&Help"));
+
+ loadfileMenu(fileMenu);
+ loademulationMenu(emulationMenu);
+ loadconfigMenu(configMenu);
+ loadtoolsMenu(toolsMenu);
+ loadhelpMenu(helpMenu);
+ loadviewMenu(viewMenu);
+
+}
\ No newline at end of file
diff --git a/desmume/src/wx/wxMain.h b/desmume/src/wx/wxMain.h
new file mode 100644
index 000000000..197bcb35a
--- /dev/null
+++ b/desmume/src/wx/wxMain.h
@@ -0,0 +1,173 @@
+
+#include "NDSSystem.h"
+#include
+#include "movie.h"
+#include
+#include
+static int nds_screen_rotation_angle;
+static wxFileConfig *desmumeConfig;
+enum
+{
+ wPause = 1,
+ wReset,
+ wFrameCounter,
+ wFPS,
+ wDisplayInput,
+ wDisplayGraphicalInput,
+ wDisplayLagCounter,
+ wDisplayMicrophone,
+ wSetHUDFont,
+ wMainGPU,
+ wMainBG0,
+ wMainBG1,
+ wMainBG2,
+ wMainBG3,
+ wSubGPU,
+ wSubBG0,
+ wSubBG1,
+ wSubBG2,
+ wSubBG3,
+ wWebsite,
+ wForums,
+ wSubmitABugReport,
+ w3dView,
+ wSaveStateAs,
+ wLoadStateFrom,
+ wCloseRom,
+ wImportBackupMemory,
+ wExportBackupMemory,
+ wPlayMovie,
+ wRecordMovie,
+ wStopMovie,
+ wSaveScreenshotAs,
+ wQuickScreenshot,
+ wLuaWindow,
+ wConfigureControls,
+ wRot0,
+ wRot90,
+ wRot180,
+ wRot270,
+ /* stupid enums: these two should be the at the end */
+ wLoadState01,
+ wSaveState01 = wLoadState01+20
+};
+
+class Desmume: public wxApp
+{
+public:
+ virtual bool OnInit();
+};
+
+class DesmumeFrame: public wxFrame
+{
+public:
+ DesmumeFrame(const wxString& title);
+ ~DesmumeFrame() {delete history;}
+ void OnQuit(wxCommandEvent& WXUNUSED(event));
+ void OnAbout(wxCommandEvent& WXUNUSED(event));
+ void applyInput();
+ //TODO integrate paths system?
+ void LoadRom(wxCommandEvent& event);
+ //----------------------------------------------------------------------------
+ // Touchscreen
+ //----------------------------------------------------------------------------
+
+ // De-transform coordinates.
+ // Returns true if the coordinates are within the touchscreen.
+ bool DetransformTouchCoords(int& X, int& Y);
+ void OnTouchEvent(wxMouseEvent& evt);
+ //----------------------------------------------------------------------------
+ // Video
+ //----------------------------------------------------------------------------
+ void gpu_screen_to_rgb(u8 *rgb1, u8 *rgb2);
+ //TODO should integrate filter system
+ void onPaint(wxPaintEvent &event);
+ void onIdle(wxIdleEvent &event);
+ void pause(wxCommandEvent& event);
+ void reset(wxCommandEvent& event){NDS_Reset();}
+ void frameCounter(wxCommandEvent& event);
+ void FPS(wxCommandEvent& event);
+ void displayInput(wxCommandEvent& event);
+ void displayGraphicalInput(wxCommandEvent& event);
+ void displayLagCounter(wxCommandEvent& event);
+ void displayMicrophone(wxCommandEvent& event);
+ void setHUDFont(wxCommandEvent &event);
+
+ void mainG(int n);
+ void subG(int n);
+
+ void mainGPU(wxCommandEvent& event){CommonSettings.showGpu.main^=true;}
+ void mainBG0(wxCommandEvent& event){mainG(0);}
+ void mainBG1(wxCommandEvent& event){mainG(1);}
+ void mainBG2(wxCommandEvent& event){mainG(2);}
+ void mainBG3(wxCommandEvent& event){mainG(3);}
+
+ void subGPU(wxCommandEvent& event){CommonSettings.showGpu.sub^=true;}
+ void subBG0(wxCommandEvent& event){subG(0);}
+ void subBG1(wxCommandEvent& event){subG(1);}
+ void subBG2(wxCommandEvent& event){subG(2);}
+ void subBG3(wxCommandEvent& event){subG(3);}
+
+ void website(wxCommandEvent& event) {wxLaunchDefaultBrowser(_T("http://desmume.org/"));}
+ void forums(wxCommandEvent& event) {wxLaunchDefaultBrowser(_T("http://forums.desmume.org/index.php"));}
+ void submitABugReport(wxCommandEvent& event) {wxLaunchDefaultBrowser(_T("http://sourceforge.net/tracker/?func=add&group_id=164579&atid=832291"));}
+
+ void _3dView(wxCommandEvent& event);
+ void saveStateAs(wxCommandEvent& event);
+ void loadStateFrom(wxCommandEvent& event);
+
+ void closeRom(wxCommandEvent& event);
+ void importBackupMemory(wxCommandEvent& event);
+ void exportBackupMemory(wxCommandEvent& event);
+ void saveScreenshotAs(wxCommandEvent& event);
+ void quickScreenshot(wxCommandEvent& event);
+ //TODO
+ void playMovie(wxCommandEvent& event) {}
+ void recordMovie(wxCommandEvent& event) {}
+ void stopMovie(wxCommandEvent& event) {FCEUI_StopMovie();}
+
+ void OnOpenLuaWindow(wxCommandEvent& WXUNUSED (event));
+ void OnOpenControllerConfiguration(wxCommandEvent& WXUNUSED (event));
+ wxMenu* MakeStatesSubMenu( int baseid ) const
+ {
+ wxMenu* mnuSubstates = new wxMenu();
+
+ for (int i = 0; i < 10; i++)
+ {
+ mnuSubstates->Append( baseid+i, wxString::Format(_T("Slot %d"), i) );
+ }
+ return mnuSubstates;
+ }
+ void Menu_SaveStates(wxCommandEvent &event);
+ void Menu_LoadStates(wxCommandEvent &event);
+ void NDSInitialize();
+ void OnRotation(wxCommandEvent &event);
+ void ChangeRotation(int rot, bool skip);
+ void onResize(wxSizeEvent &event);
+ bool LoadSettings();
+ bool SaveSettings();
+ void OnClose(wxCloseEvent &event);
+ void OnOpenRecent(wxCommandEvent &event);
+
+private:
+ void loadfileMenu(wxMenu *fileMenu);
+ void loadmenuBar(wxMenuBar *menuBar);
+ void loadhelpMenu(wxMenu *helpMenu);
+ void loadconfigMenu(wxMenu *configMenu);
+ void loadtoolsMenu(wxMenu *toolsMenu);
+ void loadlayersMenu(wxMenu *layersMenu);
+ void loadviewMenu(wxMenu *viewMenu);
+ void loadrotateMenu(wxMenu *rotateMenu);
+ void loademulationMenu(wxMenu *emulationMenu);
+ struct NDS_fw_config_data fw_config;
+ wxFileHistory* history;
+#ifdef GDB_STUB
+ gdbstub_handle_t arm9_gdb_stub;
+ gdbstub_handle_t arm7_gdb_stub;
+ struct armcpu_memory_iface *arm9_memio;
+ struct armcpu_memory_iface *arm7_memio;
+ struct armcpu_ctrl_iface *arm9_ctrl_iface;
+ struct armcpu_ctrl_iface *arm7_ctrl_iface;
+#endif
+ DECLARE_EVENT_TABLE()
+};
\ No newline at end of file