diff --git a/src/frontend/qt_sdl/CMakeLists.txt b/src/frontend/qt_sdl/CMakeLists.txt index cc9244d5..dbc3c98c 100644 --- a/src/frontend/qt_sdl/CMakeLists.txt +++ b/src/frontend/qt_sdl/CMakeLists.txt @@ -26,6 +26,7 @@ set(SOURCES_QT_SDL TitleManagerDialog.cpp Input.cpp IPC.cpp + LAN.cpp LAN_PCap.cpp LAN_Socket.cpp Netplay.cpp diff --git a/src/frontend/qt_sdl/IPC.cpp b/src/frontend/qt_sdl/IPC.cpp index 1b0abf06..85766417 100644 --- a/src/frontend/qt_sdl/IPC.cpp +++ b/src/frontend/qt_sdl/IPC.cpp @@ -98,9 +98,6 @@ const u32 kMPReplyEnd = kBufferSize; int MPRecvTimeout; int MPLastHostID; -int MPRecvTimeout; -int MPLastHostID; - // we need to come up with our own abstraction layer for named semaphores // because QSystemSemaphore doesn't support waiting with a timeout // and, as such, is unsuitable to our needs diff --git a/src/frontend/qt_sdl/LAN.cpp b/src/frontend/qt_sdl/LAN.cpp new file mode 100644 index 00000000..49646952 --- /dev/null +++ b/src/frontend/qt_sdl/LAN.cpp @@ -0,0 +1,116 @@ +/* + Copyright 2016-2022 melonDS team + + This file is part of melonDS. + + melonDS is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + melonDS is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with melonDS. If not, see http://www.gnu.org/licenses/. +*/ + +#include +#include +#include + +// + +#include "LAN.h" +#include "Config.h" +//#include "main.h" +// + + +//extern EmuThread* emuThread; + + +namespace LAN +{ + +// + + +bool Init() +{ + // + + return true; +} + +void DeInit() +{ + // +} + + +void SetMPRecvTimeout(int timeout) +{ + //MPRecvTimeout = timeout; +} + +void MPBegin() +{ + // +} + +void MPEnd() +{ + // +} + +void SetActive(bool active) +{ + // +} + +u16 GetInstanceBitmask() +{ + // + return 0; +} + + +int SendMPPacket(u8* packet, int len, u64 timestamp) +{ + return 0; +} + +int RecvMPPacket(u8* packet, u64* timestamp) +{ + return 0; +} + + +int SendMPCmd(u8* packet, int len, u64 timestamp) +{ + return 0; +} + +int SendMPReply(u8* packet, int len, u64 timestamp, u16 aid) +{ + return 0; +} + +int SendMPAck(u8* packet, int len, u64 timestamp) +{ + return 0; +} + +int RecvMPHostPacket(u8* packet, u64* timestamp) +{ + return 0; +} + +u16 RecvMPReplies(u8* packets, u64 timestamp, u16 aidmask) +{ + return 0; +} + +} diff --git a/src/frontend/qt_sdl/LAN.h b/src/frontend/qt_sdl/LAN.h new file mode 100644 index 00000000..bc19e662 --- /dev/null +++ b/src/frontend/qt_sdl/LAN.h @@ -0,0 +1,50 @@ +/* + Copyright 2016-2022 melonDS team + + This file is part of melonDS. + + melonDS is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + melonDS is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with melonDS. If not, see http://www.gnu.org/licenses/. +*/ + +#ifndef LAN_H +#define LAN_H + +#include + +#include "types.h" + +namespace LAN +{ + +bool Init(); +void DeInit(); + +void SetMPRecvTimeout(int timeout); +void MPBegin(); +void MPEnd(); + +void SetActive(bool active); + +u16 GetInstanceBitmask(); + +int SendMPPacket(u8* data, int len, u64 timestamp); +int RecvMPPacket(u8* data, u64* timestamp); +int SendMPCmd(u8* data, int len, u64 timestamp); +int SendMPReply(u8* data, int len, u64 timestamp, u16 aid); +int SendMPAck(u8* data, int len, u64 timestamp); +int RecvMPHostPacket(u8* data, u64* timestamp); +u16 RecvMPReplies(u8* data, u64 timestamp, u16 aidmask); + +} + +#endif // LAN_H diff --git a/src/frontend/qt_sdl/Netplay.cpp b/src/frontend/qt_sdl/Netplay.cpp index 4cfd1c29..b6c1511f 100644 --- a/src/frontend/qt_sdl/Netplay.cpp +++ b/src/frontend/qt_sdl/Netplay.cpp @@ -633,6 +633,7 @@ printf("[MC] finish blob type=%d len=%d\n", type, len); // load initial state // TODO: terrible hack!! + #if 0 FILE* f = Platform::OpenFile("netplay2.mln", "wb"); fwrite(Blobs[Blob_InitState], BlobLens[Blob_InitState], 1, f); fclose(f); @@ -654,6 +655,7 @@ printf("[MC] finish blob type=%d len=%d\n", type, len); printf("[MC] state loaded, PC=%08X/%08X\n", NDS::GetPC(0), NDS::GetPC(1)); ENetPacket* resp = enet_packet_create(buf, 1, ENET_PACKET_FLAG_RELIABLE); enet_peer_send(peer, 1, resp); + #endif } else if (buf[0] == 0x05) { @@ -666,12 +668,12 @@ void SyncMirrorClients() { printf("[MIRROR HOST] syncing clients\n"); - SendBlobToMirrorClients(Blob_CartROM, NDSCart::CartROMSize, NDSCart::CartROM); + //SendBlobToMirrorClients(Blob_CartROM, NDSCart::CartROMSize, NDSCart::CartROM); SendBlobToMirrorClients(Blob_CartSRAM, NDSCart::GetSaveMemoryLength(), NDSCart::GetSaveMemory()); // send initial state // TODO: this is a terrible hack! - printf("[MH] state start\n"); + /*printf("[MH] state start\n"); Savestate* state = new Savestate("netplay.mln", true); NDS::DoSavestate(state); delete state; @@ -687,7 +689,7 @@ void SyncMirrorClients() printf("[MH] state read, len=%d\n", flen); SendBlobToMirrorClients(Blob_InitState, flen, statebuf); printf("[MH] state sent\n"); - delete[] statebuf; + delete[] statebuf;*/ u8 data[2]; data[0] = 0x04;