mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-26 15:50:00 -06:00
Backport LAN (#2131)
backport the old LAN feature to the modern melonDS codebase.
This commit is contained in:
@ -21,6 +21,7 @@
|
||||
|
||||
#include "types.h"
|
||||
#include "Platform.h"
|
||||
#include "MPInterface.h"
|
||||
|
||||
namespace melonDS
|
||||
{
|
||||
@ -33,20 +34,11 @@ struct MPStatusData
|
||||
u16 MPReplyBitmask; // bitmask of which clients replied in time
|
||||
};
|
||||
|
||||
struct MPPacketHeader
|
||||
{
|
||||
u32 Magic;
|
||||
u32 SenderID;
|
||||
u32 Type; // 0=regular 1=CMD 2=reply 3=ack
|
||||
u32 Length;
|
||||
u64 Timestamp;
|
||||
};
|
||||
|
||||
constexpr u32 kPacketQueueSize = 0x10000;
|
||||
constexpr u32 kReplyQueueSize = 0x10000;
|
||||
constexpr u32 kMaxFrameSize = 0x948;
|
||||
|
||||
class LocalMP
|
||||
class LocalMP : public MPInterface
|
||||
{
|
||||
public:
|
||||
LocalMP() noexcept;
|
||||
@ -56,8 +48,7 @@ public:
|
||||
LocalMP& operator=(LocalMP&& other) = delete;
|
||||
~LocalMP() noexcept;
|
||||
|
||||
[[nodiscard]] int GetRecvTimeout() const noexcept { return RecvTimeout; }
|
||||
void SetRecvTimeout(int timeout) noexcept { RecvTimeout = timeout; }
|
||||
void Process() {}
|
||||
|
||||
void Begin(int inst);
|
||||
void End(int inst);
|
||||
@ -69,11 +60,13 @@ public:
|
||||
int SendAck(int inst, u8* data, int len, u64 timestamp);
|
||||
int RecvHostPacket(int inst, u8* data, u64* timestamp);
|
||||
u16 RecvReplies(int inst, u8* data, u64 timestamp, u16 aidmask);
|
||||
|
||||
private:
|
||||
void FIFORead(int inst, int fifo, void* buf, int len) noexcept;
|
||||
void FIFOWrite(int inst, int fifo, void* buf, int len) noexcept;
|
||||
int SendPacketGeneric(int inst, u32 type, u8* packet, int len, u64 timestamp) noexcept;
|
||||
int RecvPacketGeneric(int inst, u8* packet, bool block, u64* timestamp) noexcept;
|
||||
|
||||
Platform::Mutex* MPQueueLock;
|
||||
MPStatusData MPStatus {};
|
||||
u8 MPPacketQueue[kPacketQueueSize] {};
|
||||
@ -81,8 +74,6 @@ private:
|
||||
u32 PacketReadOffset[16] {};
|
||||
u32 ReplyReadOffset[16] {};
|
||||
|
||||
int RecvTimeout = 25;
|
||||
|
||||
int LastHostID = -1;
|
||||
Platform::Semaphore* SemPool[32] {};
|
||||
};
|
||||
|
Reference in New Issue
Block a user