diff --git a/desmume/src/NDSSystem.h b/desmume/src/NDSSystem.h index f3a80736c..c247eb2c7 100644 --- a/desmume/src/NDSSystem.h +++ b/desmume/src/NDSSystem.h @@ -22,7 +22,7 @@ #ifndef NDSSYSTEM_H #define NDSSYSTEM_H -#include +#include #include "armcpu.h" #include "MMU.h" @@ -293,6 +293,7 @@ extern struct TCommonSettings { , UseExtFirmware(false) , BootFromFirmware(false) , DebugConsole(false) + , wifiBridgeAdapterNum(0) { strcpy(ARM9BIOS, "biosnds9.bin"); strcpy(ARM7BIOS, "biosnds7.bin"); @@ -308,7 +309,10 @@ extern struct TCommonSettings { bool UseExtFirmware; char Firmware[256]; bool BootFromFirmware; + bool DebugConsole; + + int wifiBridgeAdapterNum; } CommonSettings; extern char ROMserial[20]; diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index bcef7ecf7..da5cd50f9 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -85,6 +85,13 @@ using namespace std; using namespace Gdiplus; +#define HAVE_REMOTE +#define WPCAP +#define PACKET_SIZE 65535 + +#include +#include //uh? + //----Recent ROMs menu globals---------- vector RecentRoms; //The list of recent ROM filenames const unsigned int MAX_RECENT_ROMS = 10; //To change the recent rom max, simply change this number @@ -246,6 +253,7 @@ struct NDS_fw_config_data win_fw_config; LRESULT CALLBACK GFX3DSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp); LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK EmulationSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +LRESULT CALLBACK WifiSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); struct configured_features { u16 arm9_gdb_port; @@ -1365,6 +1373,10 @@ int WINAPI WinMain (HINSTANCE hThisInstance, EnableMenuItem(mainMenu, IDM_GBASLOT, MF_GRAYED); #endif +#ifdef EXPERIMENTAL_WIFI + EnableMenuItem(mainMenu, IDM_WIFISETTINGS, MF_ENABLED); +#endif + InitCustomKeys(&CustomKeys); @@ -1475,6 +1487,8 @@ int WINAPI WinMain (HINSTANCE hThisInstance, GetPrivateProfileString("Firmware", "FirmwareFile", "firmware.bin", CommonSettings.Firmware, 256, IniName); CommonSettings.BootFromFirmware = GetPrivateProfileInt("Firmware", "BootFromFirmware", FALSE, IniName); + CommonSettings.wifiBridgeAdapterNum = GetPrivateProfileInt("Wifi", "BridgeAdapter", 0, IniName); + /* Read the firmware settings from the init file */ win_fw_config.fav_colour = GetPrivateProfileInt("Firmware","favColor", 10, IniName); win_fw_config.birth_month = GetPrivateProfileInt("Firmware","bMonth", 7, IniName); @@ -2063,6 +2077,7 @@ enum CONFIGSCREEN CONFIGSCREEN_INPUT, CONFIGSCREEN_HOTKEY, CONFIGSCREEN_FIRMWARE, + CONFIGSCREEN_WIFI, CONFIGSCREEN_SOUND, CONFIGSCREEN_EMULATION }; @@ -2094,6 +2109,9 @@ void RunConfig(CONFIGSCREEN which) case CONFIGSCREEN_EMULATION: DialogBox(hAppInst, MAKEINTRESOURCE(IDD_EMULATIONSETTINGS), hwnd, (DLGPROC)EmulationSettingsDlgProc); break; + case CONFIGSCREEN_WIFI: + DialogBox(hAppInst,MAKEINTRESOURCE(IDD_WIFISETTINGS), hwnd, (DLGPROC) WifiSettingsDlgProc); + break; } if (tpaused) @@ -2489,6 +2507,9 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM case IDM_SOUNDSETTINGS: RunConfig(CONFIGSCREEN_SOUND); return 0; + case IDM_WIFISETTINGS: + RunConfig(CONFIGSCREEN_WIFI); + return 0; case IDM_EMULATIONSETTINGS: RunConfig(CONFIGSCREEN_EMULATION); return 0; @@ -3179,6 +3200,74 @@ LRESULT CALLBACK EmulationSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, L return FALSE; } +LRESULT CALLBACK WifiSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) + { + case WM_INITDIALOG: + { + char errbuf[PCAP_ERRBUF_SIZE]; + pcap_if_t *alldevs; + pcap_if_t *d; + int i; + HWND cur; + + if(pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1) + { + EndDialog(hDlg, TRUE); + return TRUE; + } + + cur = GetDlgItem(hDlg, IDC_BRIDGEADAPTER); + for(i = 0, d = alldevs; d != NULL; i++, d = d->next) + { + ComboBox_AddString(cur, d->description); + } + ComboBox_SetCurSel(cur, CommonSettings.wifiBridgeAdapterNum); + } + return TRUE; + + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + case IDOK: + { + int val = 0; + + if(romloaded) + val = MessageBox(hDlg, "The current ROM needs to be reset to apply changes.\nReset now ?", "DeSmuME", (MB_YESNO | MB_ICONQUESTION)); + + if((!romloaded) || (val == IDYES)) + { + HWND cur; + + cur = GetDlgItem(hDlg, IDC_BRIDGEADAPTER); + CommonSettings.wifiBridgeAdapterNum = ComboBox_GetCurSel(cur); + + WritePrivateProfileInt("Wifi", "BridgeAdapter", CommonSettings.wifiBridgeAdapterNum, IniName); + + if(romloaded) + { + CheatsSearchReset(); + NDS_Reset(); + frameCounter = 0; + } + } + } + case IDCANCEL: + { + EndDialog(hDlg, TRUE); + } + return TRUE; + } + } + return TRUE; + } + + return FALSE; +} + LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static UINT_PTR timerid=0;