fix windows builds so that they can run without winpcap.dll being installed. this causes the initialization of softAP to be conditional. also add an assert where luigi needs to decide on a return value. also add an extensible driver system so that new platform-specific calls can be made from the core emulator without breaking all the other ports. look in windows port for an example of how to extend it. feel free to criticize the architecture before we get too stuck on it.

This commit is contained in:
zeromus 2009-03-29 21:38:06 +00:00
parent f10f44b0ac
commit d515af0367
9 changed files with 281 additions and 236 deletions

View File

@ -47,6 +47,8 @@
//#define USE_REAL_BIOS
TCommonSettings CommonSettings;
static Driver _stub_driver;
Driver* driver = &_stub_driver;
static BOOL LidClosed = FALSE;
static u8 countLid = 0;
@ -509,6 +511,7 @@ int NDS_Init( void) {
#ifdef EXPERIMENTAL_WIFI
WIFI_Init(&wifiMac) ;
if(wifiMac.netEnabled)
WIFI_SoftAP_Init(&wifiMac);
#endif
@ -529,6 +532,7 @@ void NDS_DeInit(void) {
gpu3D->NDS_3D_Close();
#ifdef EXPERIMENTAL_WIFI
if(wifiMac.netEnabled)
WIFI_SoftAP_Shutdown(&wifiMac);
#endif
}
@ -1023,8 +1027,10 @@ void NDS_Reset( void)
#ifdef EXPERIMENTAL_WIFI
WIFI_Init(&wifiMac);
if(wifiMac.netEnabled) {
WIFI_SoftAP_Shutdown(&wifiMac);
WIFI_SoftAP_Init(&wifiMac);
}
#endif
memcpy(FW_Mac, (MMU.fw.data + 0x36), 6);

View File

@ -317,6 +317,15 @@ extern struct TCommonSettings {
extern char ROMserial[20];
//this should be moved to a driver.h later, but for now, here they are.
//each platform needs to implement this, although it doesnt need to implement any functions
class Driver {
public:
virtual BOOL WIFI_Host_InitSystem() { return FALSE; }
virtual void WIFI_Host_ShutdownSystem() {}
};
extern Driver* driver;
#endif

View File

@ -18,6 +18,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <assert.h>
#include "wifi.h"
#include "armcpu.h"
#include "NDSSystem.h"
@ -427,8 +428,12 @@ static void WIFI_triggerIRQ(wifimac_t *wifi, u8 irq)
void WIFI_Init(wifimac_t *wifi)
{
WIFI_resetRF(&wifi->RF) ;
WIFI_Host_InitSystem() ;
wifi->netEnabled = false;
if(driver->WIFI_Host_InitSystem())
{
wifi->netEnabled = true;
wifi->udpSocket = WIFI_Host_OpenChannel(1) ;
}
wifi->powerOn = FALSE;
wifi->powerOnPending = FALSE;
}
@ -922,7 +927,8 @@ u16 WIFI_read16(wifimac_t *wifi,u32 address)
//printf("wifi: read reg 0x0214\n");
return 0x0009;
case 0x19C:
break;
assert(false); //luigi, please pick something to return from here
return 0;
default:
// printf("wifi: read unhandled reg %03X\n", address);
return wifi->ioMem[address >> 1];
@ -1502,24 +1508,4 @@ u16 WIFI_Host_RecvData(socket_t sock, u8 *data, u16 maxLength)
return 0 ;
}
BOOL WIFI_Host_InitSystem(void)
{
#ifdef WIN32
WSADATA wsaData ;
WORD version = MAKEWORD(1,1) ;
if (WSAStartup(version,&wsaData))
{
return FALSE ;
}
#endif
return TRUE ;
}
void WIFI_Host_ShutdownSystem(void)
{
#ifdef WIN32
WSACleanup() ;
#endif
}
#endif

View File

@ -494,6 +494,7 @@ typedef struct
} SoftAP;
/* desmume host communication */
bool netEnabled;
socket_t udpSocket ;
u8 channel ;

View File

@ -76,6 +76,7 @@
AdditionalDependencies="gdiplus\gdiplus.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2005-x32.lib zziplib-2005-x32.lib shlwapi.lib winpcap\wpcap.lib"
OutputFile="$(OutDir)\$(ProjectName)_debug.exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
DelayLoadDLLs="wpcap.dll"
GenerateDebugInformation="true"
GenerateMapFile="true"
/>
@ -165,6 +166,7 @@
AdditionalDependencies="gdiplus\gdiplus.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2005-x32.lib zziplib-2005-x32.lib shlwapi.lib"
OutputFile="$(OutDir)\$(ProjectName).exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
DelayLoadDLLs="wpcap.dll"
GenerateDebugInformation="true"
/>
<Tool
@ -257,6 +259,7 @@
AdditionalDependencies="gdiplus\gdiplus.lib gdiplus.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2005-x32.lib zziplib-2005-x32.lib shlwapi.lib winpcap\wpcap.lib"
OutputFile="$(OutDir)\$(ProjectName)_sse2.exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
DelayLoadDLLs="wpcap.dll"
GenerateDebugInformation="true"
GenerateMapFile="true"
EnableCOMDATFolding="0"
@ -329,6 +332,7 @@
<Tool
Name="VCLinkerTool"
AdditionalDependencies="gdiplus\gdiplus.lib gdiplus.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2005-x32.lib zziplib-2005-x32.lib shlwapi.lib"
DelayLoadDLLs="wpcap.dll"
/>
<Tool
Name="VCALinkTool"
@ -419,6 +423,7 @@
AdditionalDependencies="gdiplus\gdiplus.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2005-x32.lib zziplib-2005-x32.lib shlwapi.lib"
OutputFile="$(OutDir)\$(ProjectName)_sse2.exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
DelayLoadDLLs="wpcap.dll"
GenerateDebugInformation="true"
GenerateMapFile="true"
EnableCOMDATFolding="0"

View File

@ -75,6 +75,7 @@
AdditionalDependencies="gdiplus\gdiplus.lib vfw32.lib winmm.lib comctl32.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib shlwapi.lib winpcap\wpcap.lib"
OutputFile="$(OutDir)\$(ProjectName)_debug.exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
DelayLoadDLLs="wpcap.dll"
GenerateDebugInformation="true"
GenerateMapFile="true"
RandomizedBaseAddress="1"
@ -165,6 +166,7 @@
AdditionalDependencies="gdiplus\gdiplus.lib vfw32.lib winmm.lib comctl32.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib gdiplus.lib directx\dxguid.lib shell32.lib comdlg32.lib shlwapi.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2008-x32.lib zziplib-2008-x32.lib wpcap.lib"
OutputFile="$(OutDir)\$(ProjectName)_interim_sse2.exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib;.\winpcap"
DelayLoadDLLs="wpcap.dll"
GenerateDebugInformation="true"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
@ -254,6 +256,7 @@
AdditionalDependencies="gdiplus\gdiplus.lib vfw32.lib winmm.lib comctl32.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2008-x32.lib zziplib-2008-x32.lib shlwapi.lib"
OutputFile="$(OutDir)\$(ProjectName)_interim.exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
DelayLoadDLLs="wpcap.dll"
GenerateDebugInformation="true"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
@ -343,6 +346,7 @@
AdditionalDependencies="gdiplus\gdiplus.lib vfw32.lib winmm.lib comctl32.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2008-x32.lib zziplib-2008-x32.lib shlwapi.lib"
OutputFile="$(OutDir)\$(ProjectName).exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
DelayLoadDLLs="wpcap.dll"
GenerateDebugInformation="true"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
@ -433,6 +437,7 @@
AdditionalDependencies="gdiplus\gdiplus.lib vfw32.lib winmm.lib comctl32.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib shlwapi.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2008-x32.lib zziplib-2008-x32.lib shlwapi.lib"
OutputFile="$(OutDir)\$(ProjectName)_sse2.exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
DelayLoadDLLs="wpcap.dll"
GenerateDebugInformation="true"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"

Binary file not shown.

View File

@ -1204,12 +1204,45 @@ static void ExitRunLoop()
emu_halt();
}
class WinDriver : public Driver
{
virtual BOOL WIFI_Host_InitSystem() {
#ifdef EXPERIMENTAL_WIFI
//require winsock initialization
WSADATA wsaData ;
WORD version = MAKEWORD(1,1) ;
if (WSAStartup(version,&wsaData))
{
printf("Failed initializing WSAStartup - softAP support disabled\n");
return FALSE ;
}
//require winpcap.dll
HMODULE temp = LoadLibrary("winpcap.dll");
if(temp == NULL) {
printf("Failed initializing winpcap.dll - softAP support disabled\n");
return FALSE;
}
FreeLibrary(temp);
return TRUE;
#else
return FALSE ;
#endif
}
virtual void WIFI_Host_ShutdownSystem() {
#ifdef EXPERIMENTAL_WIFI
WSACleanup() ;
#endif
}
};
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
driver = new WinDriver();
ULONG_PTR GdiplusToken;
GdiplusStartupInput GdiplusSI;