diff --git a/project/vs2010_mfc/VBA2010.vcxproj b/project/vs2010_mfc/VBA2010.vcxproj index e4afd7c7..81af54c5 100644 --- a/project/vs2010_mfc/VBA2010.vcxproj +++ b/project/vs2010_mfc/VBA2010.vcxproj @@ -64,7 +64,7 @@ Disabled ..\..\src;..\..\fex;..\..\..\dependencies\libpng;..\..\..\dependencies\msvc;..\..\..\dependencies\SFML\include;..\..\..\dependencies\SubWCRev;..\..\..\dependencies\zlib;%(AdditionalIncludeDirectories) - WIN32;_WINDOWS;_DEBUG;DEV_VERSION;BKPT_SUPPORT;GBA_LOGGING;MMX;ASM;_CRT_SECURE_NO_WARNINGS;HAS_FILE_EXTRACTOR;%(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) false true EnableFastChecks @@ -110,7 +110,7 @@ AnySuitable Speed ..\..\src;..\..\fex;..\..\..\dependencies\libpng;..\..\..\dependencies\msvc;..\..\..\dependencies\SFML\include;..\..\..\dependencies\SubWCRev;..\..\..\dependencies\zlib;%(AdditionalIncludeDirectories) - WIN32;_WINDOWS;NDEBUG;GBA_LOGGING;OEMRESOURCE;MMX;ASM;FINAL_VERSION;BKPT_SUPPORT;_CRT_SECURE_NO_DEPRECATE;HAS_FILE_EXTRACTOR;%(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) MultiThreaded StreamingSIMDExtensions Fast diff --git a/project/vs2010_mfc/VBA2010.vcxproj.filters b/project/vs2010_mfc/VBA2010.vcxproj.filters index 7c50887e..52b54744 100644 --- a/project/vs2010_mfc/VBA2010.vcxproj.filters +++ b/project/vs2010_mfc/VBA2010.vcxproj.filters @@ -118,7 +118,7 @@ Core\GBA - + Core\GBA diff --git a/project/vs2013_mfc/VBA2013.vcxproj b/project/vs2013_mfc/VBA2013.vcxproj index f791178b..7d6b7876 100644 --- a/project/vs2013_mfc/VBA2013.vcxproj +++ b/project/vs2013_mfc/VBA2013.vcxproj @@ -71,7 +71,7 @@ Disabled ..\..\src;..\..\fex;..\..\..\dependencies\libpng;..\..\..\dependencies\msvc;..\..\..\dependencies\SFML\include;..\..\..\dependencies\SubWCRev;..\..\..\dependencies\zlib;%(AdditionalIncludeDirectories) - WIN32;_WINDOWS;_DEBUG;DEV_VERSION;BKPT_SUPPORT;GBA_LOGGING;MMX;ASM;_CRT_SECURE_NO_WARNINGS;HAS_FILE_EXTRACTOR;%(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) false true EnableFastChecks @@ -117,7 +117,7 @@ AnySuitable Speed ..\..\src;..\..\fex;..\..\..\dependencies\libpng;..\..\..\dependencies\msvc;..\..\..\dependencies\SFML\include;..\..\..\dependencies\SubWCRev;..\..\..\dependencies\zlib;%(AdditionalIncludeDirectories) - WIN32;_WINDOWS;NDEBUG;GBA_LOGGING;OEMRESOURCE;MMX;ASM;FINAL_VERSION;BKPT_SUPPORT;_CRT_SECURE_NO_DEPRECATE;HAS_FILE_EXTRACTOR;%(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) MultiThreaded StreamingSIMDExtensions Fast diff --git a/src/gb/GB.cpp b/src/gb/GB.cpp index b302edc7..e8db8598 100644 --- a/src/gb/GB.cpp +++ b/src/gb/GB.cpp @@ -1000,6 +1000,7 @@ void gbWriteMemory(register u16 address, register u8 value) case 0x02: { gbSerialOn = (value & 0x80); #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 if (EmuReseted || (gbMemory[0xff02] & 0x7c) || (value & 0x7c) || (!(value & 0x81))) { LinkFirstTime = true; @@ -1035,6 +1036,7 @@ void gbWriteMemory(register u16 address, register u8 value) gbSerialBits = 0; return; +#endif #endif } @@ -2493,10 +2495,12 @@ static void gbSelectColorizationPalette() void gbReset() { #ifndef NO_LINK +#if (defined __WIN32__ || defined _WIN32) if (GetLinkMode() == LINK_GAMEBOY) { EmuReseted = true; gbInitLink(); } +#endif #endif gbGetHardwareType(); @@ -5556,6 +5560,7 @@ void gbEmulate(int ticksToStop) gbMemory[0xff41] = register_STAT; #ifndef NO_LINK +#if (defined __WIN32__ || defined _WIN32) // serial emulation gbSerialOn = (gbMemory[0xff02] & 0x80); static int SIOctr = 0; @@ -5649,6 +5654,7 @@ void gbEmulate(int ticksToStop) } #endif } +#endif #endif soundTicks -= clockTicks; diff --git a/src/gba/GBALink.cpp b/src/gba/GBALink.cpp index f1037688..ee47d208 100644 --- a/src/gba/GBALink.cpp +++ b/src/gba/GBALink.cpp @@ -323,17 +323,17 @@ static ConnectionState gba_connection_state = LINK_OK; static int linktime = 0; static GBASockClient* dol = NULL; -static sf::IPAddress joybusHostAddr = sf::IPAddress::LocalHost; +static sf::IpAddress joybusHostAddr = sf::IpAddress::LocalHost; static const LinkDriver linkDrivers[] = { #if (defined __WIN32__ || defined _WIN32) - { LINK_CABLE_IPC, InitIPC, NULL, StartCableIPC, UpdateCableIPC, CloseIPC, false }, - { LINK_RFU_IPC, InitIPC, NULL, StartRFU, UpdateRFUIPC, CloseIPC, false }, - { LINK_GAMEBOY, InitIPC, NULL, NULL, NULL, CloseIPC, false }, + { LINK_CABLE_IPC, InitIPC, NULL, StartCableIPC, UpdateCableIPC, CloseIPC, false }, + { LINK_RFU_IPC, InitIPC, NULL, StartRFU, UpdateRFUIPC, CloseIPC, false }, + { LINK_GAMEBOY, InitIPC, NULL, NULL, NULL, CloseIPC, false }, #endif - { LINK_CABLE_SOCKET, InitSocket, ConnectUpdateSocket, StartCableSocket, UpdateSocket, CloseSocket, true }, - { LINK_GAMECUBE_DOLPHIN, JoyBusConnect, NULL, NULL, JoyBusUpdate, JoyBusShutdown, false } + { LINK_CABLE_SOCKET, InitSocket, ConnectUpdateSocket, StartCableSocket, UpdateSocket, CloseSocket, true }, + { LINK_GAMECUBE_DOLPHIN, JoyBusConnect, NULL, NULL, JoyBusUpdate, JoyBusShutdown, false } }; enum @@ -345,7 +345,8 @@ enum }; typedef struct { - sf::SocketTCP tcpsocket; + sf::TcpSocket tcpsocket; + sf::TcpListener tcplistener; int numslaves; int connectedSlaves; int type; @@ -355,7 +356,7 @@ typedef struct { class lserver{ int numbytes; - sf::Selector fdset; + sf::SocketSelector fdset; //timeval udptimeout; char inbuffer[256], outbuffer[256]; s32 *intinbuffer; @@ -366,15 +367,15 @@ class lserver{ int done; public: int howmanytimes; - sf::SocketTCP tcpsocket[4]; - sf::IPAddress udpaddr[4]; + sf::TcpSocket tcpsocket[4]; + sf::IpAddress udpaddr[4]; lserver(void); void Send(void); void Recv(void); }; class lclient{ - sf::Selector fdset; + sf::SocketSelector fdset; char inbuffer[256], outbuffer[256]; s32 *intinbuffer; u16 *u16inbuffer; @@ -382,7 +383,7 @@ class lclient{ u16 *u16outbuffer; int numbytes; public: - sf::IPAddress serveraddr; + sf::IpAddress serveraddr; unsigned short serverport; int numtransfers; lclient(void); @@ -474,20 +475,20 @@ void GetLinkServerHost(char * const host, size_t size) { host[0] = '\0'; 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) - strncpy(host, sf::IPAddress::GetLocalAddress().ToString().c_str(), size); + strncpy(host, sf::IpAddress::getLocalAddress().toString().c_str(), size); else - strncpy(host, lc.serveraddr.ToString().c_str(), size); + strncpy(host, lc.serveraddr.toString().c_str(), size); } bool SetLinkServerHost(const char *host) { - sf::IPAddress addr = sf::IPAddress(host); + sf::IpAddress addr = sf::IpAddress(host); lc.serveraddr = addr; joybusHostAddr = addr; - return addr.IsValid(); + return addr != sf::IpAddress::None; } int GetLinkPlayerId() { @@ -646,8 +647,10 @@ void StartGPLink(u16 value) break; case GP: +#if (defined __WIN32__ || defined _WIN32) if (GetLinkMode() == LINK_RFU_IPC) rfu_state = RFU_INIT; +#endif break; } } @@ -700,9 +703,9 @@ void lserver::Send(void) { outbuffer[0] = 4; outbuffer[1] = -32; //0xe0 for(i=1;i<=lanlink.numslaves;i++) { - tcpsocket[i].Send(outbuffer, 4); + tcpsocket[i].send(outbuffer, 4); size_t nr; - tcpsocket[i].Receive(inbuffer, 4, nr); + tcpsocket[i].receive(inbuffer, 4, nr); } } outbuffer[1] = tspeed; @@ -711,27 +714,27 @@ void lserver::Send(void) { if(lanlink.numslaves==1) { if(lanlink.type==0) { outbuffer[0] = 8; - tcpsocket[1].Send(outbuffer, 8); + tcpsocket[1].send(outbuffer, 8); } } else if(lanlink.numslaves==2) { WRITE16LE(&u16outbuffer[4], linkdata[2]); if(lanlink.type==0) { outbuffer[0] = 10; - tcpsocket[1].Send(outbuffer, 10); + tcpsocket[1].send(outbuffer, 10); WRITE16LE(&u16outbuffer[4], linkdata[1]); - tcpsocket[2].Send(outbuffer, 10); + tcpsocket[2].send(outbuffer, 10); } } else { if(lanlink.type==0) { outbuffer[0] = 12; WRITE16LE(&u16outbuffer[4], linkdata[2]); WRITE16LE(&u16outbuffer[5], linkdata[3]); - tcpsocket[1].Send(outbuffer, 12); + tcpsocket[1].send(outbuffer, 12); WRITE16LE(&u16outbuffer[4], linkdata[1]); - tcpsocket[2].Send(outbuffer, 12); + tcpsocket[2].send(outbuffer, 12); 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) { int numbytes; if(lanlink.type==0) { // TCP - fdset.Clear(); - for(i=0;i1) memmove(inbuffer, inbuffer+inbuffer[0]*(howmanytimes-1), inbuffer[0]); @@ -765,10 +768,10 @@ void lserver::Recv(void) { outbuffer[0] = 4; outbuffer[1] = -32; for(i=1;i0) { while(numbytesShowServerIP(sf::IPAddress::GetLocalAddress()); + //sid->ShowServerIP(sf::IpAddress::getLocalAddress()); // too bad Listen() doesn't take an address as well // 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 return LINK_ERROR; // FIXME: error code? else @@ -889,11 +892,11 @@ static ConnectionState InitSocket() { } else { lc.serverport = IP_LINK_PORT; - if (!lc.serveraddr.IsValid()) { + if (lc.serveraddr == sf::IpAddress::None) { return LINK_ERROR; } else { - lanlink.tcpsocket.SetBlocking(false); - sf::Socket::Status status = lanlink.tcpsocket.Connect(lc.serverport, lc.serveraddr); + lanlink.tcpsocket.setBlocking(false); + sf::Socket::Status status = lanlink.tcpsocket.connect(lc.serveraddr, lc.serverport); if (status == sf::Socket::Error || status == sf::Socket::Disconnected) return LINK_ERROR; @@ -907,17 +910,17 @@ static ConnectionState ConnectUpdateSocket(char * const message, size_t size) { ConnectionState newState = LINK_NEEDS_UPDATE; if (lanlink.server) { - sf::Selector fdset; - fdset.Add(lanlink.tcpsocket); + sf::SocketSelector fdset; + fdset.add(lanlink.tcplistener); - if (fdset.Wait(0.1) == 1) { + if (fdset.wait(sf::seconds(0.1f))) { 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) { for (int j = 1; j < nextSlave; j++) - ls.tcpsocket[j].Close(); + ls.tcpsocket[j].disconnect(); snprintf(message, size, N_("Network error.")); newState = LINK_ERROR; @@ -926,7 +929,7 @@ static ConnectionState ConnectUpdateSocket(char * const message, size_t size) { packet << static_cast(nextSlave) << static_cast(lanlink.numslaves); - ls.tcpsocket[nextSlave].Send(packet); + ls.tcpsocket[nextSlave].send(packet); snprintf(message, size, N_("Player %d connected"), nextSlave); @@ -939,7 +942,7 @@ static ConnectionState ConnectUpdateSocket(char * const message, size_t size) { sf::Packet packet; packet << true; - ls.tcpsocket[i].Send(packet); + ls.tcpsocket[i].send(packet); } snprintf(message, size, N_("All players connected")); @@ -948,7 +951,7 @@ static ConnectionState ConnectUpdateSocket(char * const message, size_t size) { } else { 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) { snprintf(message, size, N_("Network error.")); @@ -976,9 +979,9 @@ static ConnectionState ConnectUpdateSocket(char * const message, size_t size) { } } - sf::Selector fdset; - fdset.Add(lanlink.tcpsocket); - fdset.Wait(0.1); + sf::SocketSelector fdset; + fdset.add(lanlink.tcpsocket); + fdset.wait(sf::seconds(0.1f)); } } @@ -1109,7 +1112,7 @@ static void CloseSocket() { char outbuffer[4]; outbuffer[0] = 4; outbuffer[1] = -32; - if(lanlink.type==0) lanlink.tcpsocket.Send(outbuffer, 4); + if(lanlink.type==0) lanlink.tcpsocket.send(outbuffer, 4); } else { char outbuffer[12]; int i; @@ -1117,12 +1120,12 @@ static void CloseSocket() { outbuffer[1] = -32; for(i=1;i<=lanlink.numslaves;i++) { 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 diff --git a/src/gba/GBASockClient.cpp b/src/gba/GBASockClient.cpp index 83e97757..c7daeb4b 100644 --- a/src/gba/GBASockClient.cpp +++ b/src/gba/GBASockClient.cpp @@ -4,18 +4,18 @@ // Currently only for Joybus communications -GBASockClient::GBASockClient(sf::IPAddress _server_addr) +GBASockClient::GBASockClient(sf::IpAddress _server_addr) { - if (!_server_addr.IsValid()) - server_addr = sf::IPAddress::LocalHost; + if (_server_addr == sf::IpAddress::None) + server_addr = sf::IpAddress::LocalHost; else server_addr = _server_addr; - client.Connect(0xd6ba, server_addr); - client.SetBlocking(false); + client.connect(server_addr, 0xd6ba); + client.setBlocking(false); - clock_client.Connect(0xc10c, server_addr); - clock_client.SetBlocking(false); + clock_client.connect(server_addr, 0xc10c); + clock_client.setBlocking(false); clock_sync = 0; is_disconnected = false; @@ -23,8 +23,8 @@ GBASockClient::GBASockClient(sf::IPAddress _server_addr) GBASockClient::~GBASockClient() { - client.Close(); - clock_client.Close(); + client.disconnect(); + clock_client.disconnect(); } u32 clock_sync_ticks = 0; @@ -34,7 +34,7 @@ void GBASockClient::Send(std::vector data) char* plain_data = new char[data.size()]; std::copy(data.begin(), data.end(), plain_data); - client.Send(plain_data, data.size()); + client.send(plain_data, data.size()); delete[] plain_data; } @@ -48,11 +48,11 @@ char GBASockClient::ReceiveCmd(char* data_in, bool block) std::size_t num_received = 0; if (block || clock_sync == 0) { - sf::SelectorTCP Selector; - Selector.Add(client); - Selector.Wait(6); + sf::SocketSelector Selector; + Selector.add(client); + 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(); return data_in[0]; @@ -65,7 +65,7 @@ void GBASockClient::ReceiveClock(bool block) char sync_ticks[4] = { 0, 0, 0, 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(); if (num_received == 4) @@ -88,12 +88,12 @@ void GBASockClient::ClockSync(u32 ticks) void GBASockClient::Disconnect() { is_disconnected = true; - client.Close(); - clock_client.Close(); + client.disconnect(); + clock_client.disconnect(); } bool GBASockClient::IsDisconnected() { - return !client.IsValid() || !clock_client.IsValid() || is_disconnected; + return is_disconnected; } #endif // NO_LINK diff --git a/src/gba/GBASockClient.h b/src/gba/GBASockClient.h index 4c96367c..5b113201 100644 --- a/src/gba/GBASockClient.h +++ b/src/gba/GBASockClient.h @@ -6,10 +6,10 @@ class GBASockClient { public: - GBASockClient(sf::IPAddress _server_addr); + GBASockClient(sf::IpAddress _server_addr); ~GBASockClient(); - bool Connect(sf::IPAddress server_addr); + bool Connect(sf::IpAddress server_addr); void Send(std::vector data); char ReceiveCmd(char* data_in, bool block); void ReceiveClock(bool block); @@ -19,9 +19,9 @@ public: bool IsDisconnected(); private: - sf::IPAddress server_addr; - sf::SocketTCP client; - sf::SocketTCP clock_client; + sf::IpAddress server_addr; + sf::TcpSocket client; + sf::TcpSocket clock_client; s32 clock_sync; bool is_disconnected;