Updated to SFML 2.2. Fixed LINK build on Linux.

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@1292 a31d4220-a93d-0410-bf67-fe4944624d44

Conflicts:
	project/vs2010_mfc/VBA2010.vcxproj
	project/vs2010_mfc/VBA2010.vcxproj.filters
This commit is contained in:
Arthur Moore 2015-04-10 03:31:07 -04:00
parent 7b9c6fa39c
commit 9ff72c0c69
7 changed files with 137 additions and 89 deletions

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
@ -64,7 +64,7 @@
<ClCompile> <ClCompile>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\src;..\..\fex;..\..\..\dependencies\libpng;..\..\..\dependencies\msvc;..\..\..\dependencies\SFML\include;..\..\..\dependencies\SubWCRev;..\..\..\dependencies\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\src;..\..\fex;..\..\..\dependencies\libpng;..\..\..\dependencies\msvc;..\..\..\dependencies\SFML\include;..\..\..\dependencies\SubWCRev;..\..\..\dependencies\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;DEV_VERSION;BKPT_SUPPORT;GBA_LOGGING;MMX;ASM;_CRT_SECURE_NO_WARNINGS;HAS_FILE_EXTRACTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;SFML_SYSTEM_EXPORTS;SFML_NETWORK_EXPORTS;DEV_VERSION;BKPT_SUPPORT;GBA_LOGGING;MMX;ASM;_CRT_SECURE_NO_WARNINGS;HAS_FILE_EXTRACTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>false</StringPooling> <StringPooling>false</StringPooling>
<MinimalRebuild>true</MinimalRebuild> <MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@ -110,7 +110,7 @@
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<AdditionalIncludeDirectories>..\..\src;..\..\fex;..\..\..\dependencies\libpng;..\..\..\dependencies\msvc;..\..\..\dependencies\SFML\include;..\..\..\dependencies\SubWCRev;..\..\..\dependencies\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\src;..\..\fex;..\..\..\dependencies\libpng;..\..\..\dependencies\msvc;..\..\..\dependencies\SFML\include;..\..\..\dependencies\SubWCRev;..\..\..\dependencies\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;NO_OAL;NDEBUG;GBA_LOGGING;OEMRESOURCE;MMX;ASM;FINAL_VERSION;BKPT_SUPPORT;_CRT_SECURE_NO_DEPRECATE;HAS_FILE_EXTRACTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;SFML_SYSTEM_EXPORTS;SFML_NETWORK_EXPORTS;GBA_LOGGING;OEMRESOURCE;MMX;ASM;FINAL_VERSION;BKPT_SUPPORT;_CRT_SECURE_NO_DEPRECATE;HAS_FILE_EXTRACTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet> <EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
<FloatingPointModel>Fast</FloatingPointModel> <FloatingPointModel>Fast</FloatingPointModel>
@ -167,7 +167,9 @@
<ClInclude Include="..\..\src\apu\Multi_Buffer.h" /> <ClInclude Include="..\..\src\apu\Multi_Buffer.h" />
<ClInclude Include="..\..\src\gba\agbprint.h" /> <ClInclude Include="..\..\src\gba\agbprint.h" />
<ClInclude Include="..\..\src\gba\ereader.h" /> <ClInclude Include="..\..\src\gba\ereader.h" />
<ClInclude Include="..\..\src\gba\BreakpointStructures.h" />
<ClInclude Include="..\..\src\gba\bios.h" /> <ClInclude Include="..\..\src\gba\bios.h" />
<ClInclude Include="..\..\src\gba\debugger-expr-yacc.hpp" />
<ClInclude Include="..\..\src\gba\EEprom.h" /> <ClInclude Include="..\..\src\gba\EEprom.h" />
<ClInclude Include="..\..\src\gba\elf.h" /> <ClInclude Include="..\..\src\gba\elf.h" />
<ClInclude Include="..\..\src\gba\Flash.h" /> <ClInclude Include="..\..\src\gba\Flash.h" />
@ -184,6 +186,8 @@
<ClInclude Include="..\..\src\filters\hq2x.h" /> <ClInclude Include="..\..\src\filters\hq2x.h" />
<ClInclude Include="..\..\src\filters\interp.h" /> <ClInclude Include="..\..\src\filters\interp.h" />
<ClInclude Include="..\..\src\filters\lq2x.h" /> <ClInclude Include="..\..\src\filters\lq2x.h" />
<ClInclude Include="..\..\src\filters\xBRZ\config.h" />
<ClInclude Include="..\..\src\filters\xBRZ\xbrz.h" />
<ClInclude Include="..\..\src\gba\armdis.h" /> <ClInclude Include="..\..\src\gba\armdis.h" />
<ClInclude Include="..\..\src\gba\Cheats.h" /> <ClInclude Include="..\..\src\gba\Cheats.h" />
<ClInclude Include="..\..\src\gba\CheatSearch.h" /> <ClInclude Include="..\..\src\gba\CheatSearch.h" />
@ -293,6 +297,9 @@
<ClCompile Include="..\..\src\apu\Multi_Buffer.cpp" /> <ClCompile Include="..\..\src\apu\Multi_Buffer.cpp" />
<ClCompile Include="..\..\src\gba\agbprint.cpp" /> <ClCompile Include="..\..\src\gba\agbprint.cpp" />
<ClCompile Include="..\..\src\gba\bios.cpp" /> <ClCompile Include="..\..\src\gba\bios.cpp" />
<ClCompile Include="..\..\src\gba\BreakpointStructures.cpp" />
<ClCompile Include="..\..\src\gba\debugger-expr-lex.cpp" />
<ClCompile Include="..\..\src\gba\debugger-expr-yacc.cpp" />
<ClCompile Include="..\..\src\gba\EEprom.cpp" /> <ClCompile Include="..\..\src\gba\EEprom.cpp" />
<ClCompile Include="..\..\src\gba\elf.cpp" /> <ClCompile Include="..\..\src\gba\elf.cpp" />
<ClCompile Include="..\..\src\gba\ereader.cpp" /> <ClCompile Include="..\..\src\gba\ereader.cpp" />
@ -323,6 +330,8 @@
<ClCompile Include="..\..\src\win32\rpi.cpp" /> <ClCompile Include="..\..\src\win32\rpi.cpp" />
<ClCompile Include="..\..\src\filters\scanline.cpp" /> <ClCompile Include="..\..\src\filters\scanline.cpp" />
<ClCompile Include="..\..\src\filters\simpleFilter.cpp" /> <ClCompile Include="..\..\src\filters\simpleFilter.cpp" />
<ClCompile Include="..\..\src\filters\xbrzfilter.cpp" />
<ClCompile Include="..\..\src\filters\xBRZ\xbrz.cpp" />
<ClCompile Include="..\..\src\filters\hq2x.cpp" /> <ClCompile Include="..\..\src\filters\hq2x.cpp" />
<ClCompile Include="..\..\src\filters\hq\asm\hq3x32.cpp" /> <ClCompile Include="..\..\src\filters\hq\asm\hq3x32.cpp" />
<ClCompile Include="..\..\src\gba\armdis.cpp" /> <ClCompile Include="..\..\src\gba\armdis.cpp" />

View File

@ -29,6 +29,9 @@
<Filter Include="Pixel Filter\HQ\3x_4x_asm"> <Filter Include="Pixel Filter\HQ\3x_4x_asm">
<UniqueIdentifier>{443f5282-9e21-46cb-b187-746986699f99}</UniqueIdentifier> <UniqueIdentifier>{443f5282-9e21-46cb-b187-746986699f99}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Pixel Filter\xBRZ">
<UniqueIdentifier>{5ab58341-15e1-499c-9fee-7695e1a98161}</UniqueIdentifier>
</Filter>
<Filter Include="Functionality"> <Filter Include="Functionality">
<UniqueIdentifier>{b9123fa0-e9e8-444a-a69c-82a2d3bee747}</UniqueIdentifier> <UniqueIdentifier>{b9123fa0-e9e8-444a-a69c-82a2d3bee747}</UniqueIdentifier>
</Filter> </Filter>
@ -112,6 +115,12 @@
<ClInclude Include="..\..\src\gba\bios.h"> <ClInclude Include="..\..\src\gba\bios.h">
<Filter>Core\GBA</Filter> <Filter>Core\GBA</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\gba\BreakpointStructures.h">
<Filter>Core\GBA</Filter>
</ClInclude>
<ClInclude Include="..\..\src\gba\debugger-expr-yacc.hpp">
<Filter>Core\GBA</Filter>
</ClInclude>
<ClInclude Include="..\..\src\gba\EEprom.h"> <ClInclude Include="..\..\src\gba\EEprom.h">
<Filter>Core\GBA</Filter> <Filter>Core\GBA</Filter>
</ClInclude> </ClInclude>
@ -397,6 +406,12 @@
<ClInclude Include="..\..\src\win32\GBTileView.h"> <ClInclude Include="..\..\src\win32\GBTileView.h">
<Filter>MFC\GB</Filter> <Filter>MFC\GB</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\filters\xBRZ\xbrz.h">
<Filter>Pixel Filter\xBRZ</Filter>
</ClInclude>
<ClInclude Include="..\..\src\filters\xBRZ\config.h">
<Filter>Pixel Filter\xBRZ</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\..\src\win32\res\VBA.ico"> <None Include="..\..\src\win32\res\VBA.ico">
@ -475,6 +490,15 @@
<ClCompile Include="..\..\src\gba\bios.cpp"> <ClCompile Include="..\..\src\gba\bios.cpp">
<Filter>Core\GBA</Filter> <Filter>Core\GBA</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\gba\BreakpointStructures.cpp">
<Filter>Core\GBA</Filter>
</ClCompile>
<ClCompile Include="..\..\src\gba\debugger-expr-lex.cpp">
<Filter>Core\GBA</Filter>
</ClCompile>
<ClCompile Include="..\..\src\gba\debugger-expr-yacc.cpp">
<Filter>Core\GBA</Filter>
</ClCompile>
<ClCompile Include="..\..\src\gba\EEprom.cpp"> <ClCompile Include="..\..\src\gba\EEprom.cpp">
<Filter>Core\GBA</Filter> <Filter>Core\GBA</Filter>
</ClCompile> </ClCompile>
@ -565,6 +589,12 @@
<ClCompile Include="..\..\src\filters\hq\asm\hq3x32.cpp"> <ClCompile Include="..\..\src\filters\hq\asm\hq3x32.cpp">
<Filter>Pixel Filter\HQ\3x_4x_asm</Filter> <Filter>Pixel Filter\HQ\3x_4x_asm</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\filters\xBRZ\xbrz.cpp">
<Filter>Pixel Filter\xBRZ</Filter>
</ClCompile>
<ClCompile Include="..\..\src\filters\xbrzfilter.cpp">
<Filter>Pixel Filter\xBRZ</Filter>
</ClCompile>
<ClCompile Include="..\..\src\gba\armdis.cpp"> <ClCompile Include="..\..\src\gba\armdis.cpp">
<Filter>Functionality</Filter> <Filter>Functionality</Filter>
</ClCompile> </ClCompile>

View File

@ -71,7 +71,7 @@
<ClCompile> <ClCompile>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\src;..\..\fex;..\..\..\dependencies\libpng;..\..\..\dependencies\msvc;..\..\..\dependencies\SFML\include;..\..\..\dependencies\SubWCRev;..\..\..\dependencies\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\src;..\..\fex;..\..\..\dependencies\libpng;..\..\..\dependencies\msvc;..\..\..\dependencies\SFML\include;..\..\..\dependencies\SubWCRev;..\..\..\dependencies\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;DEV_VERSION;BKPT_SUPPORT;GBA_LOGGING;MMX;ASM;_CRT_SECURE_NO_WARNINGS;HAS_FILE_EXTRACTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;SFML_SYSTEM_EXPORTS;SFML_NETWORK_EXPORTS;DEV_VERSION;BKPT_SUPPORT;GBA_LOGGING;MMX;ASM;_CRT_SECURE_NO_WARNINGS;HAS_FILE_EXTRACTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>false</StringPooling> <StringPooling>false</StringPooling>
<MinimalRebuild>true</MinimalRebuild> <MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@ -117,7 +117,7 @@
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<AdditionalIncludeDirectories>..\..\src;..\..\fex;..\..\..\dependencies\libpng;..\..\..\dependencies\msvc;..\..\..\dependencies\SFML\include;..\..\..\dependencies\SubWCRev;..\..\..\dependencies\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\src;..\..\fex;..\..\..\dependencies\libpng;..\..\..\dependencies\msvc;..\..\..\dependencies\SFML\include;..\..\..\dependencies\SubWCRev;..\..\..\dependencies\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;GBA_LOGGING;OEMRESOURCE;MMX;ASM;FINAL_VERSION;BKPT_SUPPORT;_CRT_SECURE_NO_DEPRECATE;HAS_FILE_EXTRACTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;SFML_SYSTEM_EXPORTS;SFML_NETWORK_EXPORTS;GBA_LOGGING;OEMRESOURCE;MMX;ASM;FINAL_VERSION;BKPT_SUPPORT;_CRT_SECURE_NO_DEPRECATE;HAS_FILE_EXTRACTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet> <EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
<FloatingPointModel>Fast</FloatingPointModel> <FloatingPointModel>Fast</FloatingPointModel>

View File

@ -803,6 +803,7 @@ void gbWriteMemory(register u16 address, register u8 value)
case 0x02: { case 0x02: {
gbSerialOn = (value & 0x80); gbSerialOn = (value & 0x80);
#ifndef NO_LINK #ifndef NO_LINK
#if (defined __WIN32__ || defined _WIN32)
//trying to detect whether the game has exited multiplay mode, pokemon blue start w/ 0x7e while pocket racing start w/ 0x7c //trying to detect whether the game has exited multiplay mode, pokemon blue start w/ 0x7e while pocket racing start w/ 0x7c
if (EmuReseted || (gbMemory[0xff02] & 0x7c) || (value & 0x7c) || (!(value & 0x81))) { if (EmuReseted || (gbMemory[0xff02] & 0x7c) || (value & 0x7c) || (!(value & 0x81))) {
LinkFirstTime = true; LinkFirstTime = true;
@ -838,6 +839,7 @@ void gbWriteMemory(register u16 address, register u8 value)
gbSerialBits = 0; gbSerialBits = 0;
return; return;
#endif
#endif #endif
} }
@ -2202,10 +2204,12 @@ void gbGetHardwareType()
void gbReset() void gbReset()
{ {
#ifndef NO_LINK #ifndef NO_LINK
#if (defined __WIN32__ || defined _WIN32)
if (GetLinkMode() == LINK_GAMEBOY) { if (GetLinkMode() == LINK_GAMEBOY) {
EmuReseted = true; EmuReseted = true;
gbInitLink(); gbInitLink();
} }
#endif
#endif #endif
gbGetHardwareType(); gbGetHardwareType();
@ -5252,6 +5256,7 @@ void gbEmulate(int ticksToStop)
gbMemory[0xff41] = register_STAT; gbMemory[0xff41] = register_STAT;
#ifndef NO_LINK #ifndef NO_LINK
#if (defined __WIN32__ || defined _WIN32)
// serial emulation // serial emulation
gbSerialOn = (gbMemory[0xff02] & 0x80); gbSerialOn = (gbMemory[0xff02] & 0x80);
static int SIOctr = 0; static int SIOctr = 0;
@ -5345,6 +5350,7 @@ void gbEmulate(int ticksToStop)
} }
#endif #endif
} }
#endif
#endif #endif
soundTicks -= clockTicks; soundTicks -= clockTicks;

View File

@ -323,17 +323,17 @@ static ConnectionState gba_connection_state = LINK_OK;
static int linktime = 0; static int linktime = 0;
static GBASockClient* dol = NULL; static GBASockClient* dol = NULL;
static sf::IPAddress joybusHostAddr = sf::IPAddress::LocalHost; static sf::IpAddress joybusHostAddr = sf::IpAddress::LocalHost;
static const LinkDriver linkDrivers[] = static const LinkDriver linkDrivers[] =
{ {
#if (defined __WIN32__ || defined _WIN32) #if (defined __WIN32__ || defined _WIN32)
{ LINK_CABLE_IPC, InitIPC, NULL, StartCableIPC, UpdateCableIPC, CloseIPC, false }, { LINK_CABLE_IPC, InitIPC, NULL, StartCableIPC, UpdateCableIPC, CloseIPC, false },
{ LINK_RFU_IPC, InitIPC, NULL, StartRFU, UpdateRFUIPC, CloseIPC, false }, { LINK_RFU_IPC, InitIPC, NULL, StartRFU, UpdateRFUIPC, CloseIPC, false },
{ LINK_GAMEBOY, InitIPC, NULL, NULL, NULL, CloseIPC, false }, { LINK_GAMEBOY, InitIPC, NULL, NULL, NULL, CloseIPC, false },
#endif #endif
{ LINK_CABLE_SOCKET, InitSocket, ConnectUpdateSocket, StartCableSocket, UpdateSocket, CloseSocket, true }, { LINK_CABLE_SOCKET, InitSocket, ConnectUpdateSocket, StartCableSocket, UpdateSocket, CloseSocket, true },
{ LINK_GAMECUBE_DOLPHIN, JoyBusConnect, NULL, NULL, JoyBusUpdate, JoyBusShutdown, false } { LINK_GAMECUBE_DOLPHIN, JoyBusConnect, NULL, NULL, JoyBusUpdate, JoyBusShutdown, false }
}; };
enum enum
@ -345,7 +345,8 @@ enum
}; };
typedef struct { typedef struct {
sf::SocketTCP tcpsocket; sf::TcpSocket tcpsocket;
sf::TcpListener tcplistener;
int numslaves; int numslaves;
int connectedSlaves; int connectedSlaves;
int type; int type;
@ -355,7 +356,7 @@ typedef struct {
class lserver{ class lserver{
int numbytes; int numbytes;
sf::Selector<sf::SocketTCP> fdset; sf::SocketSelector fdset;
//timeval udptimeout; //timeval udptimeout;
char inbuffer[256], outbuffer[256]; char inbuffer[256], outbuffer[256];
s32 *intinbuffer; s32 *intinbuffer;
@ -366,15 +367,15 @@ class lserver{
int done; int done;
public: public:
int howmanytimes; int howmanytimes;
sf::SocketTCP tcpsocket[4]; sf::TcpSocket tcpsocket[4];
sf::IPAddress udpaddr[4]; sf::IpAddress udpaddr[4];
lserver(void); lserver(void);
void Send(void); void Send(void);
void Recv(void); void Recv(void);
}; };
class lclient{ class lclient{
sf::Selector<sf::SocketTCP> fdset; sf::SocketSelector fdset;
char inbuffer[256], outbuffer[256]; char inbuffer[256], outbuffer[256];
s32 *intinbuffer; s32 *intinbuffer;
u16 *u16inbuffer; u16 *u16inbuffer;
@ -382,7 +383,7 @@ class lclient{
u16 *u16outbuffer; u16 *u16outbuffer;
int numbytes; int numbytes;
public: public:
sf::IPAddress serveraddr; sf::IpAddress serveraddr;
unsigned short serverport; unsigned short serverport;
int numtransfers; int numtransfers;
lclient(void); lclient(void);
@ -474,20 +475,20 @@ void GetLinkServerHost(char * const host, size_t size) {
host[0] = '\0'; host[0] = '\0';
if (linkDriver && linkDriver->mode == LINK_GAMECUBE_DOLPHIN) if (linkDriver && linkDriver->mode == LINK_GAMECUBE_DOLPHIN)
strncpy(host, joybusHostAddr.ToString().c_str(), size); strncpy(host, joybusHostAddr.toString().c_str(), size);
else if (lanlink.server) else if (lanlink.server)
strncpy(host, sf::IPAddress::GetLocalAddress().ToString().c_str(), size); strncpy(host, sf::IpAddress::getLocalAddress().toString().c_str(), size);
else else
strncpy(host, lc.serveraddr.ToString().c_str(), size); strncpy(host, lc.serveraddr.toString().c_str(), size);
} }
bool SetLinkServerHost(const char *host) { bool SetLinkServerHost(const char *host) {
sf::IPAddress addr = sf::IPAddress(host); sf::IpAddress addr = sf::IpAddress(host);
lc.serveraddr = addr; lc.serveraddr = addr;
joybusHostAddr = addr; joybusHostAddr = addr;
return addr.IsValid(); return addr != sf::IpAddress::None;
} }
int GetLinkPlayerId() { int GetLinkPlayerId() {
@ -646,8 +647,10 @@ void StartGPLink(u16 value)
break; break;
case GP: case GP:
#if (defined __WIN32__ || defined _WIN32)
if (GetLinkMode() == LINK_RFU_IPC) if (GetLinkMode() == LINK_RFU_IPC)
rfu_state = RFU_INIT; rfu_state = RFU_INIT;
#endif
break; break;
} }
} }
@ -700,9 +703,9 @@ void lserver::Send(void) {
outbuffer[0] = 4; outbuffer[0] = 4;
outbuffer[1] = -32; //0xe0 outbuffer[1] = -32; //0xe0
for(i=1;i<=lanlink.numslaves;i++) { for(i=1;i<=lanlink.numslaves;i++) {
tcpsocket[i].Send(outbuffer, 4); tcpsocket[i].send(outbuffer, 4);
size_t nr; size_t nr;
tcpsocket[i].Receive(inbuffer, 4, nr); tcpsocket[i].receive(inbuffer, 4, nr);
} }
} }
outbuffer[1] = tspeed; outbuffer[1] = tspeed;
@ -711,27 +714,27 @@ void lserver::Send(void) {
if(lanlink.numslaves==1) { if(lanlink.numslaves==1) {
if(lanlink.type==0) { if(lanlink.type==0) {
outbuffer[0] = 8; outbuffer[0] = 8;
tcpsocket[1].Send(outbuffer, 8); tcpsocket[1].send(outbuffer, 8);
} }
} }
else if(lanlink.numslaves==2) { else if(lanlink.numslaves==2) {
WRITE16LE(&u16outbuffer[4], linkdata[2]); WRITE16LE(&u16outbuffer[4], linkdata[2]);
if(lanlink.type==0) { if(lanlink.type==0) {
outbuffer[0] = 10; outbuffer[0] = 10;
tcpsocket[1].Send(outbuffer, 10); tcpsocket[1].send(outbuffer, 10);
WRITE16LE(&u16outbuffer[4], linkdata[1]); WRITE16LE(&u16outbuffer[4], linkdata[1]);
tcpsocket[2].Send(outbuffer, 10); tcpsocket[2].send(outbuffer, 10);
} }
} else { } else {
if(lanlink.type==0) { if(lanlink.type==0) {
outbuffer[0] = 12; outbuffer[0] = 12;
WRITE16LE(&u16outbuffer[4], linkdata[2]); WRITE16LE(&u16outbuffer[4], linkdata[2]);
WRITE16LE(&u16outbuffer[5], linkdata[3]); WRITE16LE(&u16outbuffer[5], linkdata[3]);
tcpsocket[1].Send(outbuffer, 12); tcpsocket[1].send(outbuffer, 12);
WRITE16LE(&u16outbuffer[4], linkdata[1]); WRITE16LE(&u16outbuffer[4], linkdata[1]);
tcpsocket[2].Send(outbuffer, 12); tcpsocket[2].send(outbuffer, 12);
WRITE16LE(&u16outbuffer[5], linkdata[2]); WRITE16LE(&u16outbuffer[5], linkdata[2]);
tcpsocket[3].Send(outbuffer, 12); tcpsocket[3].send(outbuffer, 12);
} }
} }
} }
@ -741,10 +744,10 @@ void lserver::Send(void) {
void lserver::Recv(void) { void lserver::Recv(void) {
int numbytes; int numbytes;
if(lanlink.type==0) { // TCP if(lanlink.type==0) { // TCP
fdset.Clear(); fdset.clear();
for(i=0;i<lanlink.numslaves;i++) fdset.Add(tcpsocket[i+1]); for(i=0;i<lanlink.numslaves;i++) fdset.add(tcpsocket[i+1]);
// was linktimeout/1000 (i.e., drop ms part), but that's wrong // was linktimeout/1000 (i.e., drop ms part), but that's wrong
if (fdset.Wait((float)(linktimeout / 1000.)) == 0) if (fdset.wait(sf::seconds((float)(linktimeout / 1000.))) == 0)
{ {
return; return;
} }
@ -754,7 +757,7 @@ void lserver::Recv(void) {
inbuffer[0] = 1; inbuffer[0] = 1;
while(numbytes<howmanytimes*inbuffer[0]) { while(numbytes<howmanytimes*inbuffer[0]) {
size_t nr; size_t nr;
tcpsocket[i+1].Receive(inbuffer+numbytes, howmanytimes*inbuffer[0]-numbytes, nr); tcpsocket[i+1].receive(inbuffer+numbytes, howmanytimes*inbuffer[0]-numbytes, nr);
numbytes += nr; numbytes += nr;
} }
if(howmanytimes>1) memmove(inbuffer, inbuffer+inbuffer[0]*(howmanytimes-1), inbuffer[0]); if(howmanytimes>1) memmove(inbuffer, inbuffer+inbuffer[0]*(howmanytimes-1), inbuffer[0]);
@ -765,10 +768,10 @@ void lserver::Recv(void) {
outbuffer[0] = 4; outbuffer[0] = 4;
outbuffer[1] = -32; outbuffer[1] = -32;
for(i=1;i<lanlink.numslaves;i++) { for(i=1;i<lanlink.numslaves;i++) {
tcpsocket[i].Send(outbuffer, 12); tcpsocket[i].send(outbuffer, 12);
size_t nr; size_t nr;
tcpsocket[i].Receive(inbuffer, 256, nr); tcpsocket[i].receive(inbuffer, 256, nr);
tcpsocket[i].Close(); tcpsocket[i].disconnect();
} }
CloseLink(); CloseLink();
return; return;
@ -793,16 +796,16 @@ lclient::lclient(void) {
void lclient::CheckConn(void) { void lclient::CheckConn(void) {
size_t nr; size_t nr;
lanlink.tcpsocket.Receive(inbuffer, 1, nr); lanlink.tcpsocket.receive(inbuffer, 1, nr);
numbytes = nr; numbytes = nr;
if(numbytes>0) { if(numbytes>0) {
while(numbytes<inbuffer[0]) { while(numbytes<inbuffer[0]) {
lanlink.tcpsocket.Receive(inbuffer+numbytes, inbuffer[0] - numbytes, nr); lanlink.tcpsocket.receive(inbuffer+numbytes, inbuffer[0] - numbytes, nr);
numbytes += nr; numbytes += nr;
} }
if(inbuffer[1]==-32) { if(inbuffer[1]==-32) {
outbuffer[0] = 4; outbuffer[0] = 4;
lanlink.tcpsocket.Send(outbuffer, 4); lanlink.tcpsocket.send(outbuffer, 4);
systemScreenMessage(_("Server disconnected.")); systemScreenMessage(_("Server disconnected."));
CloseLink(); CloseLink();
return; return;
@ -823,11 +826,11 @@ void lclient::CheckConn(void) {
} }
void lclient::Recv(void) { void lclient::Recv(void) {
fdset.Clear(); fdset.clear();
// old code used socket # instead of mask again // old code used socket # instead of mask again
fdset.Add(lanlink.tcpsocket); fdset.add(lanlink.tcpsocket);
// old code stripped off ms again // old code stripped off ms again
if (fdset.Wait((float)(linktimeout / 1000.)) == 0) if (fdset.wait(sf::seconds((float)(linktimeout / 1000.))) == 0)
{ {
numtransfers = 0; numtransfers = 0;
return; return;
@ -836,12 +839,12 @@ void lclient::Recv(void) {
inbuffer[0] = 1; inbuffer[0] = 1;
size_t nr; size_t nr;
while(numbytes<inbuffer[0]) { while(numbytes<inbuffer[0]) {
lanlink.tcpsocket.Receive(inbuffer+numbytes, inbuffer[0] - numbytes, nr); lanlink.tcpsocket.receive(inbuffer+numbytes, inbuffer[0] - numbytes, nr);
numbytes += nr; numbytes += nr;
} }
if(inbuffer[1]==-32) { if(inbuffer[1]==-32) {
outbuffer[0] = 4; outbuffer[0] = 4;
lanlink.tcpsocket.Send(outbuffer, 4); lanlink.tcpsocket.send(outbuffer, 4);
systemScreenMessage(_("Server disconnected.")); systemScreenMessage(_("Server disconnected."));
CloseLink(); CloseLink();
return; return;
@ -863,7 +866,7 @@ void lclient::Send() {
outbuffer[0] = 4; outbuffer[0] = 4;
outbuffer[1] = linkid<<2; outbuffer[1] = linkid<<2;
WRITE16LE(&u16outbuffer[1], linkdata[linkid]); WRITE16LE(&u16outbuffer[1], linkdata[linkid]);
lanlink.tcpsocket.Send(outbuffer, 4); lanlink.tcpsocket.send(outbuffer, 4);
return; return;
} }
@ -877,11 +880,11 @@ static ConnectionState InitSocket() {
if (lanlink.server) { if (lanlink.server) {
lanlink.connectedSlaves = 0; lanlink.connectedSlaves = 0;
// should probably use GetPublicAddress() // should probably use GetPublicAddress()
//sid->ShowServerIP(sf::IPAddress::GetLocalAddress()); //sid->ShowServerIP(sf::IpAddress::getLocalAddress());
// too bad Listen() doesn't take an address as well // too bad Listen() doesn't take an address as well
// then again, old code used INADDR_ANY anyway // then again, old code used INADDR_ANY anyway
if (!lanlink.tcpsocket.Listen(IP_LINK_PORT)) if (lanlink.tcplistener.listen(IP_LINK_PORT) == sf::Socket::Error)
// Note: old code closed socket & retried once on bind failure // Note: old code closed socket & retried once on bind failure
return LINK_ERROR; // FIXME: error code? return LINK_ERROR; // FIXME: error code?
else else
@ -889,11 +892,11 @@ static ConnectionState InitSocket() {
} else { } else {
lc.serverport = IP_LINK_PORT; lc.serverport = IP_LINK_PORT;
if (!lc.serveraddr.IsValid()) { if (lc.serveraddr == sf::IpAddress::None) {
return LINK_ERROR; return LINK_ERROR;
} else { } else {
lanlink.tcpsocket.SetBlocking(false); lanlink.tcpsocket.setBlocking(false);
sf::Socket::Status status = lanlink.tcpsocket.Connect(lc.serverport, lc.serveraddr); sf::Socket::Status status = lanlink.tcpsocket.connect(lc.serveraddr, lc.serverport);
if (status == sf::Socket::Error || status == sf::Socket::Disconnected) if (status == sf::Socket::Error || status == sf::Socket::Disconnected)
return LINK_ERROR; return LINK_ERROR;
@ -907,17 +910,17 @@ static ConnectionState ConnectUpdateSocket(char * const message, size_t size) {
ConnectionState newState = LINK_NEEDS_UPDATE; ConnectionState newState = LINK_NEEDS_UPDATE;
if (lanlink.server) { if (lanlink.server) {
sf::Selector<sf::SocketTCP> fdset; sf::SocketSelector fdset;
fdset.Add(lanlink.tcpsocket); fdset.add(lanlink.tcplistener);
if (fdset.Wait(0.1) == 1) { if (fdset.wait(sf::seconds(0.1f))) {
int nextSlave = lanlink.connectedSlaves + 1; int nextSlave = lanlink.connectedSlaves + 1;
sf::Socket::Status st = lanlink.tcpsocket.Accept(ls.tcpsocket[nextSlave]); sf::Socket::Status st = lanlink.tcplistener.accept(ls.tcpsocket[nextSlave]);
if (st == sf::Socket::Error) { if (st == sf::Socket::Error) {
for (int j = 1; j < nextSlave; j++) for (int j = 1; j < nextSlave; j++)
ls.tcpsocket[j].Close(); ls.tcpsocket[j].disconnect();
snprintf(message, size, N_("Network error.")); snprintf(message, size, N_("Network error."));
newState = LINK_ERROR; newState = LINK_ERROR;
@ -926,7 +929,7 @@ static ConnectionState ConnectUpdateSocket(char * const message, size_t size) {
packet << static_cast<sf::Uint16>(nextSlave) packet << static_cast<sf::Uint16>(nextSlave)
<< static_cast<sf::Uint16>(lanlink.numslaves); << static_cast<sf::Uint16>(lanlink.numslaves);
ls.tcpsocket[nextSlave].Send(packet); ls.tcpsocket[nextSlave].send(packet);
snprintf(message, size, N_("Player %d connected"), nextSlave); snprintf(message, size, N_("Player %d connected"), nextSlave);
@ -939,7 +942,7 @@ static ConnectionState ConnectUpdateSocket(char * const message, size_t size) {
sf::Packet packet; sf::Packet packet;
packet << true; packet << true;
ls.tcpsocket[i].Send(packet); ls.tcpsocket[i].send(packet);
} }
snprintf(message, size, N_("All players connected")); snprintf(message, size, N_("All players connected"));
@ -948,7 +951,7 @@ static ConnectionState ConnectUpdateSocket(char * const message, size_t size) {
} else { } else {
sf::Packet packet; sf::Packet packet;
sf::Socket::Status status = lanlink.tcpsocket.Receive(packet); sf::Socket::Status status = lanlink.tcpsocket.receive(packet);
if (status == sf::Socket::Error || status == sf::Socket::Disconnected) { if (status == sf::Socket::Error || status == sf::Socket::Disconnected) {
snprintf(message, size, N_("Network error.")); snprintf(message, size, N_("Network error."));
@ -976,9 +979,9 @@ static ConnectionState ConnectUpdateSocket(char * const message, size_t size) {
} }
} }
sf::Selector<sf::SocketTCP> fdset; sf::SocketSelector fdset;
fdset.Add(lanlink.tcpsocket); fdset.add(lanlink.tcpsocket);
fdset.Wait(0.1); fdset.wait(sf::seconds(0.1f));
} }
} }
@ -1109,7 +1112,7 @@ static void CloseSocket() {
char outbuffer[4]; char outbuffer[4];
outbuffer[0] = 4; outbuffer[0] = 4;
outbuffer[1] = -32; outbuffer[1] = -32;
if(lanlink.type==0) lanlink.tcpsocket.Send(outbuffer, 4); if(lanlink.type==0) lanlink.tcpsocket.send(outbuffer, 4);
} else { } else {
char outbuffer[12]; char outbuffer[12];
int i; int i;
@ -1117,12 +1120,12 @@ static void CloseSocket() {
outbuffer[1] = -32; outbuffer[1] = -32;
for(i=1;i<=lanlink.numslaves;i++) { for(i=1;i<=lanlink.numslaves;i++) {
if(lanlink.type==0) { if(lanlink.type==0) {
ls.tcpsocket[i].Send(outbuffer, 12); ls.tcpsocket[i].send(outbuffer, 12);
} }
ls.tcpsocket[i].Close(); ls.tcpsocket[i].disconnect();
} }
} }
lanlink.tcpsocket.Close(); lanlink.tcpsocket.disconnect();
} }
// call this to clean up crashed program's shared state // call this to clean up crashed program's shared state

View File

@ -4,18 +4,18 @@
// Currently only for Joybus communications // Currently only for Joybus communications
GBASockClient::GBASockClient(sf::IPAddress _server_addr) GBASockClient::GBASockClient(sf::IpAddress _server_addr)
{ {
if (!_server_addr.IsValid()) if (_server_addr == sf::IpAddress::None)
server_addr = sf::IPAddress::LocalHost; server_addr = sf::IpAddress::LocalHost;
else else
server_addr = _server_addr; server_addr = _server_addr;
client.Connect(0xd6ba, server_addr); client.connect(server_addr, 0xd6ba);
client.SetBlocking(false); client.setBlocking(false);
clock_client.Connect(0xc10c, server_addr); clock_client.connect(server_addr, 0xc10c);
clock_client.SetBlocking(false); clock_client.setBlocking(false);
clock_sync = 0; clock_sync = 0;
is_disconnected = false; is_disconnected = false;
@ -23,8 +23,8 @@ GBASockClient::GBASockClient(sf::IPAddress _server_addr)
GBASockClient::~GBASockClient() GBASockClient::~GBASockClient()
{ {
client.Close(); client.disconnect();
clock_client.Close(); clock_client.disconnect();
} }
u32 clock_sync_ticks = 0; u32 clock_sync_ticks = 0;
@ -34,7 +34,7 @@ void GBASockClient::Send(std::vector<char> data)
char* plain_data = new char[data.size()]; char* plain_data = new char[data.size()];
std::copy(data.begin(), data.end(), plain_data); std::copy(data.begin(), data.end(), plain_data);
client.Send(plain_data, data.size()); client.send(plain_data, data.size());
delete[] plain_data; delete[] plain_data;
} }
@ -48,11 +48,11 @@ char GBASockClient::ReceiveCmd(char* data_in, bool block)
std::size_t num_received = 0; std::size_t num_received = 0;
if (block || clock_sync == 0) if (block || clock_sync == 0)
{ {
sf::SelectorTCP Selector; sf::SocketSelector Selector;
Selector.Add(client); Selector.add(client);
Selector.Wait(6); Selector.wait(sf::seconds(6));
} }
if (client.Receive(data_in, 5, num_received) == sf::Socket::Disconnected) if (client.receive(data_in, 5, num_received) == sf::Socket::Disconnected)
Disconnect(); Disconnect();
return data_in[0]; return data_in[0];
@ -65,7 +65,7 @@ void GBASockClient::ReceiveClock(bool block)
char sync_ticks[4] = { 0, 0, 0, 0 }; char sync_ticks[4] = { 0, 0, 0, 0 };
std::size_t num_received = 0; std::size_t num_received = 0;
if (clock_client.Receive(sync_ticks, 4, num_received) == sf::Socket::Disconnected) if (clock_client.receive(sync_ticks, 4, num_received) == sf::Socket::Disconnected)
Disconnect(); Disconnect();
if (num_received == 4) if (num_received == 4)
@ -88,12 +88,12 @@ void GBASockClient::ClockSync(u32 ticks)
void GBASockClient::Disconnect() void GBASockClient::Disconnect()
{ {
is_disconnected = true; is_disconnected = true;
client.Close(); client.disconnect();
clock_client.Close(); clock_client.disconnect();
} }
bool GBASockClient::IsDisconnected() bool GBASockClient::IsDisconnected()
{ {
return !client.IsValid() || !clock_client.IsValid() || is_disconnected; return is_disconnected;
} }
#endif // NO_LINK #endif // NO_LINK

View File

@ -6,10 +6,10 @@
class GBASockClient class GBASockClient
{ {
public: public:
GBASockClient(sf::IPAddress _server_addr); GBASockClient(sf::IpAddress _server_addr);
~GBASockClient(); ~GBASockClient();
bool Connect(sf::IPAddress server_addr); bool Connect(sf::IpAddress server_addr);
void Send(std::vector<char> data); void Send(std::vector<char> data);
char ReceiveCmd(char* data_in, bool block); char ReceiveCmd(char* data_in, bool block);
void ReceiveClock(bool block); void ReceiveClock(bool block);
@ -19,9 +19,9 @@ public:
bool IsDisconnected(); bool IsDisconnected();
private: private:
sf::IPAddress server_addr; sf::IpAddress server_addr;
sf::SocketTCP client; sf::TcpSocket client;
sf::SocketTCP clock_client; sf::TcpSocket clock_client;
s32 clock_sync; s32 clock_sync;
bool is_disconnected; bool is_disconnected;