Merge pull request #150 from retr0s4ge/master

Add WiFi fix from desmume-reloaded, tweak the wait for display thread added in commit ee8fdeb
This commit is contained in:
zeromus 2018-06-29 23:57:48 -04:00 committed by GitHub
commit 490c7e917c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 1519 additions and 1364 deletions

View File

@ -24,8 +24,8 @@
#include "types.h"
#include "ROMReader.h"
#include "wifi.h"
class BaseDriver;
class CFIRMWARE;
class EMUFILE;
@ -72,7 +72,6 @@ extern BOOL click;
#define NDS_FW_LANG_CHI 6
#define NDS_FW_LANG_RES 7
extern BaseDriver *driver;
extern CFIRMWARE *firmware;
#define DSGBA_LOADER_SIZE 512

View File

@ -142,6 +142,8 @@ ENDL
" Select basic console type; default FAT" ENDL
" --bios-arm9 BIN_FILE Uses the ARM9 BIOS provided at the specified path" ENDL
" --bios-arm7 BIN_FILE Uses the ARM7 BIOS provided at the specified path" ENDL
" --firmware-path BIN_FILE Uses the firmware provided at the specified path" ENDL
" --firmware-boot 0|1 Boot from firmware" ENDL
" --bios-swi Uses SWI from the provided bios files (else HLE)" ENDL
" --lang N Firmware language (can affect game translations)" ENDL
" 0 = Japanese, 1 = English (default), 2 = French" ENDL
@ -195,6 +197,8 @@ ENDL
#define OPT_ARM9 201
#define OPT_ARM7 202
#define OPT_LANGUAGE 203
#define OPT_FIRMPATH 204
#define OPT_FIRMBOOT 205
#define OPT_SLOT1 300
#define OPT_SLOT1_FAT_DIR 301
@ -269,6 +273,8 @@ bool CommandLine::parse(int argc,char **argv)
{ "bios-arm9", required_argument, NULL, OPT_ARM9},
{ "bios-arm7", required_argument, NULL, OPT_ARM7},
{ "bios-swi", no_argument, &_bios_swi, 1},
{ "firmware-path", required_argument, NULL, OPT_FIRMPATH},
{ "firmware-boot", required_argument, NULL, OPT_FIRMBOOT},
{ "lang", required_argument, NULL, OPT_LANGUAGE},
//slot-1 contents
@ -332,6 +338,8 @@ bool CommandLine::parse(int argc,char **argv)
case OPT_CONSOLE_TYPE: console_type = optarg; break;
case OPT_ARM9: _bios_arm9 = strdup(optarg); break;
case OPT_ARM7: _bios_arm7 = strdup(optarg); break;
case OPT_FIRMPATH: _fw_path = strdup(optarg); break;
case OPT_FIRMBOOT: _fw_boot = atoi(optarg); break;
//slot-1 contents
case OPT_SLOT1: slot1 = strtoupper(optarg); break;
@ -418,6 +426,10 @@ bool CommandLine::parse(int argc,char **argv)
//TODO NOT MAX PRIORITY! change ARM9BIOS etc to be a std::string
if(_bios_arm9) { CommonSettings.UseExtBIOS = true; strcpy(CommonSettings.ARM9BIOS,_bios_arm9); }
if(_bios_arm7) { CommonSettings.UseExtBIOS = true; strcpy(CommonSettings.ARM7BIOS,_bios_arm7); }
#ifndef HOST_WINDOWS
if(_fw_path) { CommonSettings.UseExtFirmware = true; CommonSettings.UseExtFirmwareSettings = true; strcpy(CommonSettings.Firmware,_fw_path); }
#endif
if(_fw_boot) CommonSettings.BootFromFirmware = true;
if(_bios_swi) CommonSettings.SWIFromBIOS = true;
if(_spu_sync_mode != -1) CommonSettings.SPU_sync_mode = _spu_sync_mode;
if(_spu_sync_method != -1) CommonSettings.SPU_sync_method = _spu_sync_method;
@ -490,6 +502,10 @@ bool CommandLine::validate()
printerror("If either bios-swi is used, bios-arm9 and bios-arm7 must be specified.\n");
}
if(_fw_boot && (!_fw_path)) {
printerror("If either firmware boot is used, firmware path must be specified.\n");
}
if((_cflash_image && _gbaslot_rom) || (_cflash_path && _gbaslot_rom)) {
printerror("Cannot specify both cflash and gbaslot rom (both occupy SLOT-2)\n");
}

View File

@ -91,6 +91,8 @@ private:
char* _cflash_path;
char* _gbaslot_rom;
char* _bios_arm9, *_bios_arm7;
char* _fw_path;
int _fw_boot;
int _load_to_memory;
int _bios_swi;
int _spu_advanced;

View File

@ -38,6 +38,10 @@ armcpu_t* TDebugEventData::cpu() { return procnum==0?&NDS_ARM9:&NDS_ARM7; }
TDebugEventData DebugEventData;
u32 debugFlag;
// PACKET HACK VARS
FILE *log_ptr; // File to store the dumped data
const u32 rc4_addr[2] = { 0x020986A8, 0x02098710 };
//DEBUG CONFIGURATION
const bool debug_acl = false;
const bool debug_cacheMiss = false;
@ -78,9 +82,60 @@ void HandleDebugEvent_Read()
void HandleDebugEvent_Write()
{
if(!debug_acl) return;
if(DebugEventData.procnum != ARMCPU_ARM9) return; //acl only valid on arm9
acl_check_access(DebugEventData.addr,CP15_ACCESS_WRITE);
// Disabled by default.
// If you want to enable first you must know and update the address of the
// RC4 algoritm function.
return;
// This method is called twice, so ommit one call.
extern bool nds_debug_continuing[2];
if (nds_debug_continuing[DebugEventData.procnum]) {
nds_debug_continuing[DebugEventData.procnum] = false;
return;
}
// RC4 encrypt / decrypt function
// R1: Pointer to data to operate (to decrypt or encrypt)
// R2: Size of this data
if (DebugEventData.addr == rc4_addr[0] || DebugEventData.addr == rc4_addr[1]) {
nds_debug_continuing[DebugEventData.procnum] = true;
u32 addr = DebugEventData.addr;
printf("WIFI: Call to RC4_ALGORITM\n");
// Write log. Append current data
// TODO: It needs to open the file each time, it could be slow.
// An improvement could be opening the file at the start of the function
// and closing at the end of the function.
log_ptr = fopen("wifi_log.txt", "a");
if (log_ptr != NULL)
{
// Create header
time_t ti;
time(&ti);
tm* t = localtime(&ti);
fprintf(log_ptr, "\n[%02d-%02d-%02d-%02d-%02d] %s of RC4_ALGORITM -----------\n",
t->tm_mon, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec,
(addr == rc4_addr[0]) ? "Start" : "End"
);
// Dump data
int length = DebugEventData.cpu()->R[2];
int position = DebugEventData.cpu()->R[1] - 0x02000000; // Relative to memory array
fwrite(MMU.MAIN_MEM + position, sizeof(char), length, log_ptr);
// End
fprintf(log_ptr, "\n- THE END -----------------------------------------------\n");
// Flush and close by the moment
fflush(log_ptr);
fclose(log_ptr);
}
else {
printf("Error opening log file\n");
}
}
}
void HandleDebugEvent_Execute()

View File

@ -49,11 +49,6 @@ BaseDriver::~BaseDriver()
{
}
void BaseDriver::USR_InfoMessage(const char *message)
{
LOG("%s\n", message);
}
void BaseDriver::AddLine(const char *fmt, ...)
{
#if HAVE_LIBAGG
@ -68,4 +63,4 @@ void BaseDriver::SetLineColor(u8 r, u8 b, u8 g)
#if HAVE_LIBAGG
osd->setLineColor(r,b,g);
#endif
}
}

View File

@ -20,6 +20,11 @@
#include <stdio.h>
#include "types.h"
#include "debug.h"
#ifdef EXPERIMENTAL_WIFI_COMM
#include <pcap.h>
#endif
class VIEW3D_Driver
{
@ -35,11 +40,57 @@ public:
BaseDriver();
~BaseDriver();
#ifdef EXPERIMENTAL_WIFI_COMM
#ifdef HOST_WINDOWS
virtual bool WIFI_SocketsAvailable() { return true; }
virtual bool WIFI_PCapAvailable() { return false; }
virtual void WIFI_GetUniqueMAC(u8* mac) {}
virtual bool WIFI_WFCWarning() { return false; }
virtual int PCAP_findalldevs(pcap_if_t** alldevs, char* errbuf) { return -1; }
virtual void PCAP_freealldevs(pcap_if_t* alldevs) {}
virtual pcap_t* PCAP_open(const char* source, int snaplen, int flags, int readtimeout, char* errbuf) { return NULL; }
virtual void PCAP_close(pcap_t* dev) {}
virtual int PCAP_setnonblock(pcap_t* dev, int nonblock, char* errbuf) { return -1; }
virtual int PCAP_sendpacket(pcap_t* dev, const u_char* data, int len) { return -1; }
virtual int PCAP_dispatch(pcap_t* dev, int num, pcap_handler callback, u_char* userdata) { return -1; }
#else
virtual bool WIFI_SocketsAvailable() { return true; }
virtual bool WIFI_PCapAvailable() { return true; }
virtual void WIFI_GetUniqueMAC(u8* mac) {}
virtual bool WIFI_WFCWarning() { return false; }
virtual int PCAP_findalldevs(pcap_if_t** alldevs, char* errbuf) {
return pcap_findalldevs(alldevs, errbuf); }
virtual void PCAP_freealldevs(pcap_if_t* alldevs) {
pcap_freealldevs(alldevs); }
virtual pcap_t* PCAP_open(const char* source, int snaplen, int flags, int readtimeout, char* errbuf) {
return pcap_open_live(source, snaplen, flags, readtimeout, errbuf); }
virtual void PCAP_close(pcap_t* dev) {
pcap_close(dev); }
virtual int PCAP_setnonblock(pcap_t* dev, int nonblock, char* errbuf) {
return pcap_setnonblock(dev, nonblock, errbuf); }
virtual int PCAP_sendpacket(pcap_t* dev, const u_char* data, int len) {
return pcap_sendpacket(dev, data, len); }
virtual int PCAP_dispatch(pcap_t* dev, int num, pcap_handler callback, u_char* userdata) {
return pcap_dispatch(dev, num, callback, userdata); }
#endif
#endif
virtual void AVI_SoundUpdate(void* soundData, int soundLen) {}
virtual bool AVI_IsRecording() { return FALSE; }
virtual bool WAV_IsRecording() { return FALSE; }
virtual void USR_InfoMessage(const char *message);
virtual void USR_InfoMessage(const char *message) { LOG("%s\n", message); }
virtual void USR_RefreshScreen() {}
virtual void USR_SetDisplayPostpone(int milliseconds, bool drawNextFrame) {} // -1 == indefinitely, 0 == don't pospone, 500 == don't draw for 0.5 seconds
@ -56,9 +107,7 @@ public:
virtual bool EMU_HasEmulationStarted() { return true; }
virtual bool EMU_IsAtFrameBoundary() { return true; }
virtual void EMU_DebugIdleEnter() {}
virtual void EMU_DebugIdleUpdate() {}
virtual void EMU_DebugIdleWakeUp() {}
enum eDebug_IOReg
{
@ -74,5 +123,6 @@ public:
virtual void AddLine(const char *fmt, ...);
virtual void SetLineColor(u8 r, u8 b, u8 g);
};
extern BaseDriver* driver;
#endif //_DRIVER_H_

View File

@ -18,7 +18,11 @@
#ifndef _AVIOUT_H_
#define _AVIOUT_H_
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <Commdlg.h>
#include <Shellapi.h>
#include <vfw.h>
#include <queue>

View File

@ -149,7 +149,7 @@
<!-- export other user options to preprocessor -->
<PreprocessorDefinitions Condition="'$(DEVELOPER)' == 'true'">DEVELOPER=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(GDB_STUB)' == 'true'">GDB_STUB=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(EXPERIMENTAL_WIFI_COMM)' == 'true'">EXPERIMENTAL_WIFI_COMM=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>EXPERIMENTAL_WIFI_COMM=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<!-- desmume configuration: features we always have in windows -->
<PreprocessorDefinitions>HAVE_LIBAGG=1;HAVE_JIT=1;HAVE_LUA=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -19,6 +19,11 @@
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <Commdlg.h>
#include <Shellapi.h>
#include "hotkey.h"
#include "NDSSystem.h"

View File

@ -24,6 +24,7 @@
#define INPUTDX_INCLUDED
#include <windows.h>
#include <Mmsystem.h>
#define DIRECTINPUT_VERSION 0x0800
#include "directx/dinput.h"
#include "directx/xinput.h"

View File

@ -21,8 +21,10 @@
#include <map>
#include <string>
#include <algorithm>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <Commdlg.h>
#include <Shellapi.h>
#include "driver.h"
#include "lua-engine.h"

View File

@ -2292,7 +2292,7 @@ static void StepRunLoop_User()
Hud.fps3d = GPU->GetFPSRender3D();
// wait for the HUD to update from last frame
WaitForSingleObject(display_done_event, display_done_timeout);
if(frameskiprate==0) WaitForSingleObject(display_done_event, display_done_timeout);
Display();
mainLoopData.fps3d = Hud.fps3d;
@ -2693,7 +2693,11 @@ static void ExitRunLoop()
emu_halt(EMUHALT_REASON_USER_REQUESTED_HALT, NDSErrorTag_None);
}
class WinWifiHandler : public WifiHandler
//-----------------------------------------------------------------------------
// Platform driver for Win32
//-----------------------------------------------------------------------------
class WinDriver : public BaseDriver
{
#ifdef EXPERIMENTAL_WIFI_COMM
virtual bool WIFI_SocketsAvailable() { return bSocketsAvailable; }
@ -2754,7 +2758,7 @@ class WinWifiHandler : public WifiHandler
"Do you still want to connect?",
"DeSmuME - WFC warning",
MB_YESNO | MB_DEFBUTTON2 | MB_ICONWARNING
) == IDYES;
) == IDYES;
}
virtual int PCAP_findalldevs(pcap_if_t** alldevs, char* errbuf) {
@ -2785,14 +2789,7 @@ class WinWifiHandler : public WifiHandler
return _pcap_dispatch(dev, num, callback, userdata);
}
#endif
};
//-----------------------------------------------------------------------------
// Platform driver for Win32
//-----------------------------------------------------------------------------
class WinDriver : public BaseDriver
{
virtual bool AVI_IsRecording()
{
return ::AVI_IsRecording();
@ -2986,7 +2983,6 @@ int _main()
#endif
driver = new WinDriver();
CurrentWifiHandler = new WinWifiHandler();
WinGPUEvent = new GPUEventHandlerWindows;
InitializeCriticalSection(&win_execute_sync);
@ -7000,7 +6996,7 @@ LRESULT CALLBACK WifiSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
if (bWinPCapAvailable)
{
if(CurrentWifiHandler->PCAP_findalldevs(&alldevs, errbuf) == -1)
if(driver->PCAP_findalldevs(&alldevs, errbuf) == -1)
{
// TODO: fail more gracefully!
EndDialog(hDlg, TRUE);

View File

@ -21,7 +21,10 @@
#include "throttle.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <Commdlg.h>
#include <Shellapi.h>
#include "types.h"
#include "debug.h"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff