diff --git a/config/SZBE69_B8/config.json b/config/SZBE69_B8/config.json index 92ded657..7973d2c7 100644 --- a/config/SZBE69_B8/config.json +++ b/config/SZBE69_B8/config.json @@ -239,8 +239,8 @@ "sdk/RevoEX": { "base": "base", "flags": [ - "-func_align 4", - "-O4,p" + "-O4,p", + "-func_align 4" ] }, "sdk/DWC": { diff --git a/config/SZBE69_B8/objects.json b/config/SZBE69_B8/objects.json index 63553664..a1b53f66 100644 --- a/config/SZBE69_B8/objects.json +++ b/config/SZBE69_B8/objects.json @@ -777,19 +777,19 @@ "network/Platform/SpinTest.cpp": "MISSING", "network/Platform/StackTracer.cpp": "MISSING", "network/Platform/String.cpp": "NonMatching", - "network/Platform/StringConversion.cpp": "MISSING", + "network/Platform/StringConversion.cpp": "NonMatching", "network/Platform/StringConverter.cpp": "MISSING", "network/Platform/StringStream.cpp": "NonMatching", - "network/Platform/SystemChecker.cpp": "MISSING", + "network/Platform/SystemChecker.cpp": "Matching", "network/Platform/SystemClock.cpp": "MISSING", "network/Platform/SystemError.cpp": "MISSING", - "network/Platform/ThreadScrambler.cpp": "MISSING", + "network/Platform/ThreadScrambler.cpp": "Matching", "network/Platform/ThreadVariable.cpp": "MISSING", "network/Platform/Time.cpp": "NonMatching", "network/Platform/TraceLog.cpp": "Matching", "network/Platform/VirtualRootObject.cpp": "Matching", "network/Platform/WaterMark.cpp": "MISSING", - "network/Platform/WiiIpStack.cpp": "MISSING", + "network/Platform/WiiIpStack.cpp": "NonMatching", "network/Platform/WiiNetInit.cpp": "Matching" } }, @@ -2058,8 +2058,8 @@ "sdk/RevoEX/net/neterrorcode.c": "MISSING", "sdk/RevoEX/net/netmemcpy.c": "MISSING", "sdk/RevoEX/net/netmemset.c": "MISSING", - "sdk/RevoEX/net/NETVersion.c": "MISSING", - "sdk/RevoEX/net/wireless_macaddr.c": "MISSING", + "sdk/RevoEX/net/NETVersion.c": {"status": "NonMatching", "comment": "Linker just hates me i guess"}, + "sdk/RevoEX/net/wireless_macaddr.c": "Matching", "sdk/RevoEX/nhttp/d_nhttp.c": "MISSING", "sdk/RevoEX/nhttp/d_nhttp_common.c": "MISSING", diff --git a/src/network/Core/Job.h b/src/network/Core/Job.h new file mode 100644 index 00000000..2147a1ea --- /dev/null +++ b/src/network/Core/Job.h @@ -0,0 +1,12 @@ +#pragma once + +#include "Platform/RefCountedObject.h" + +namespace Quazal { +// forward decl cause i can't find the bastard +class DebugString; + +class Job : public RefCountedObject { + Job(const DebugString&); +}; +} diff --git a/src/network/Core/PeriodicJob.h b/src/network/Core/PeriodicJob.h new file mode 100644 index 00000000..5208dff7 --- /dev/null +++ b/src/network/Core/PeriodicJob.h @@ -0,0 +1,10 @@ +#pragma once + +#include "Core/Job.h" + +namespace Quazal { +class PeriodicJob : public Job { + PeriodicJob(const DebugString&); + virtual ~PeriodicJob() {} +}; +} diff --git a/src/network/Core/PseudoSingleton.h b/src/network/Core/PseudoSingleton.h new file mode 100644 index 00000000..2f3928d7 --- /dev/null +++ b/src/network/Core/PseudoSingleton.h @@ -0,0 +1,9 @@ +#pragma once + +namespace Quazal { +class PseudoSingleton { +public: + + static int GetCurrentContext(); +}; +} diff --git a/src/network/Core/Scheduler.h b/src/network/Core/Scheduler.h new file mode 100644 index 00000000..a80d81dc --- /dev/null +++ b/src/network/Core/Scheduler.h @@ -0,0 +1,8 @@ +#pragma once + +namespace Quazal { +class Scheduler { + public: + static bool CurrentThreadCanWaitForJob(); +}; +} diff --git a/src/network/Core/SystemComponent.cpp b/src/network/Core/SystemComponent.cpp index 6cf16cda..fed97265 100644 --- a/src/network/Core/SystemComponent.cpp +++ b/src/network/Core/SystemComponent.cpp @@ -1,4 +1,6 @@ #include "SystemComponent.h" +#include "Core/PseudoSingleton.h" +#include "Core/Scheduler.h" #include "decomp.h" #include "network/Platform/TraceLog.h" @@ -199,7 +201,14 @@ SystemComponent::Use::~Use() { } } -void SystemComponent::WaitForTerminatedState(unsigned int) { - +void SystemComponent::WaitForTerminatedState(unsigned int ui) { // returns struct + Terminate(); + if (ui != 0 && Scheduler::CurrentThreadCanWaitForJob()) { + if (PseudoSingleton::GetCurrentContext() == 0) { + + } else { + + } + } } } diff --git a/src/network/Platform/StringConversion.cpp b/src/network/Platform/StringConversion.cpp new file mode 100644 index 00000000..bce82d45 --- /dev/null +++ b/src/network/Platform/StringConversion.cpp @@ -0,0 +1,75 @@ +#include "StringConversion.h" +#include "types.h" +#include + +namespace { + void Latin1ToUtf8(const char* in, char* out, unsigned int len) { + u8 srch = *in; + len--; + while (srch != 0 && len != 0) { + if ((s16)srch >= 0x80) { + u8 nu_hi = ((u16)srch >> 6) & 0x1F; + srch &= 0x3F; + *out = nu_hi | 0xC0; + *(out + 1) = srch | 0x80; + len -= 2; + out += 2; + } else { + *(out++) = srch; + len--; + } + srch = *((const u8*)++in); + } + *out = 0; + } + void Utf8ToLatin1(const char* in, char* out, unsigned int len) { + u8 srch = *in; + len--; + bool hitNonLatin1Char = false; + while (srch != 0 && len != 0 && !hitNonLatin1Char) { + if (srch <= 0x7F) { + *out = srch; + out++; + len--; + } else { + if ((srch - 0xC0) <= 0x1F) { + u8 hi = *in; + len--; + u8 lo = *((const u8*)++in); + *out = ((hi - 0xC0) << 6) + lo - 0x80; + out++; + } else { + hitNonLatin1Char = true; + } + } + srch = *((const u8*)++in); + } + *out = 0; + } +} + +namespace Quazal { +namespace StringConversion { + void Char8_2T(const char* in, char* out, unsigned int len) { + strcpy(out, in); // BUG: should be strncpy(out, in, len); + } + + void T2Char8(const char* in, char* out, unsigned int len) { + strcpy(out, in); // BUG: should be strncpy(out, in, len); + } + + void Utf8ToT(const char* in, char* out, unsigned int len) { + Utf8ToLatin1(in, out, len); + } + + void TToUtf8(const char* in, char* out, unsigned int len) { + Latin1ToUtf8(in, out, len); + } + + int GetTToUtf8BufferSize(const char* str) { + return strlen(str) * 2 + 1; + } + +} +} + diff --git a/src/network/Platform/StringConversion.h b/src/network/Platform/StringConversion.h new file mode 100644 index 00000000..25605c41 --- /dev/null +++ b/src/network/Platform/StringConversion.h @@ -0,0 +1,11 @@ +#pragma once + +namespace Quazal { +namespace StringConversion { + void Char8_2T(const char* in, char* out, unsigned int len); + void T2Char8(const char* in, char* out, unsigned int len); + void Utf8ToT(const char* in, char* out, unsigned int len); + void TToUtf8(const char* in, char* out, unsigned int len); + int GetTToUtf8BufferSize(const char* str); +} +} diff --git a/src/network/Platform/SystemChecker.cpp b/src/network/Platform/SystemChecker.cpp new file mode 100644 index 00000000..139d90b4 --- /dev/null +++ b/src/network/Platform/SystemChecker.cpp @@ -0,0 +1,6 @@ +namespace Quazal { + namespace SystemChecker { + int s_pfGetSystemCheckInfo = 0; + } +} + diff --git a/src/network/Platform/ThreadScrambler.cpp b/src/network/Platform/ThreadScrambler.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/network/Platform/WiiIpStack.cpp b/src/network/Platform/WiiIpStack.cpp new file mode 100644 index 00000000..90e2aa4b --- /dev/null +++ b/src/network/Platform/WiiIpStack.cpp @@ -0,0 +1,54 @@ +#include "revolution/os/OSError.h" +#include "revolution/os/OSTime.h" +#include "revolution/rvl/so.h" +#include "sdk/RevoEX/so/SOBasic.h" +#include "types.h" + +uint htonl(uint x) { return SOHtoNl(x); } +uint htons(u16 x) { return SOHtoNs(x); } +uint ntohl(uint x) { return SONtoHl(x); } +uint ntohs(u16 x) { return SONtoHs(x); } + +so_ret_t poll(struct SOPollFD* fd, unsigned int pollct, int timeout) { + return SOPoll((so_poll_t*)fd, pollct, 1000); +} + +void bind(so_fd_t socket, const struct sockaddr* sa, unsigned int) { + SOBind(socket, (so_addr_t*)sa); +} + +void connect(so_fd_t socket, const sockaddr* sa, unsigned int) { + SOConnect(socket, (so_addr_t*)sa); +} + +void recv(so_fd_t sock, void* buf, unsigned long bufsiz, int flags) { + SORecv(sock, buf, bufsiz, flags); +} + +void recvfrom(so_fd_t sock, void* buf, size_t bufsiz, int flags, sockaddr* addr, unsigned int*) { + SORecvFrom(sock, buf, bufsiz, flags, (so_addr_t*)addr); +} + +void send(so_fd_t sock, const void* buf, size_t bufsiz, int flags) { + SOSend(sock, buf, bufsiz, flags); +} + +void sendto(so_fd_t sock, const void* buf, unsigned long bufsiz, int flags, const sockaddr* addr, unsigned int) { + SOSendTo(sock, buf, bufsiz, flags, (so_addr_t*)addr); +} + +void setsockopt(so_fd_t sock, int lvl, int name, const void* buf, unsigned int bufsiz) { + SOSetSockOpt(sock, (so_lvl_t)lvl, (so_opt_t)name, buf, bufsiz); +} + +so_fd_t socket(int a, int b, int c) { + return SOSocket((so_pf_t)a, (so_type_t)b, (so_prot_t)c); +} + +int closesocket(so_fd_t sock) { + int err; + if ((err = SOClose(sock))) { + OSReport("SOClose returns %d\n", err); + } + return err; +} diff --git a/src/sdk/RVL_SDK/revolution/rvl/so.h b/src/sdk/RVL_SDK/revolution/rvl/so.h index 52e55b1f..b8a1ad9e 100644 --- a/src/sdk/RVL_SDK/revolution/rvl/so.h +++ b/src/sdk/RVL_SDK/revolution/rvl/so.h @@ -338,24 +338,10 @@ enum so_opt_t { static inline so_ret_t SOStartup(void) { return SOStartupEx(60000); } -static inline so_ret_t SORecvFrom( - so_fd_t socket, void *buffer, size_t buffer_size, int flags, - so_addr_t *addr) { - return SOiRecvFrom(0, socket, buffer, buffer_size, flags, addr); -} -static inline so_ret_t SORecv( - so_fd_t socket, void *buffer, size_t buffer_size, int flags) { - return SOiRecvFrom(0, socket, buffer, buffer_size, flags, NULL); -} -static inline so_ret_t SOSendTo( - so_fd_t socket, const void *buffer, size_t buffer_size, int flags, - const so_addr_t *addr) { - return SOiSendTo(0, socket, buffer, buffer_size, flags, addr); -} -static inline so_ret_t SOSend( - so_fd_t socket, const void *buffer, size_t buffer_size, int flags) { - return SOiSendTo(0, socket, buffer, buffer_size, flags, NULL); -} +so_ret_t SORecvFrom(so_fd_t socket, void *buffer, size_t buffer_size, int flags, so_addr_t *addr); +so_ret_t SORecv(so_fd_t socket, void *buffer, size_t buffer_size, int flags); +so_ret_t SOSendTo(so_fd_t socket, const void *buffer, size_t buffer_size, int flags, const so_addr_t *addr); +so_ret_t SOSend(so_fd_t socket, const void *buffer, size_t buffer_size, int flags); // past this point are things i had to grab from mkwii since this so.h just Doesn't Have Them int SOiPrepare(const char*, s32*); diff --git a/src/sdk/RevoEX/ncd/ncdsystem.h b/src/sdk/RevoEX/ncd/ncdsystem.h new file mode 100644 index 00000000..9f94c3f2 --- /dev/null +++ b/src/sdk/RevoEX/ncd/ncdsystem.h @@ -0,0 +1,12 @@ +#pragma once +#ifdef __cplusplus +extern "C" { +#endif + +#include "types.h" + +u32 NCDiGetWirelessMacAddress(); + +#ifdef __cplusplus +} +#endif diff --git a/src/sdk/RevoEX/net/NETVersion.c b/src/sdk/RevoEX/net/NETVersion.c new file mode 100644 index 00000000..df7229f7 --- /dev/null +++ b/src/sdk/RevoEX/net/NETVersion.c @@ -0,0 +1,4 @@ +const char* NETRexPPCVersionPrintableString = "<< REX-PPC 2.4.255.0 (RevoEX-2.4) REL 090609111526 >>"; +const char* NETGetRexPPCVersionPrintable(void) { + return NETRexPPCVersionPrintableString; +} diff --git a/src/sdk/RevoEX/net/wireless_macaddr.c b/src/sdk/RevoEX/net/wireless_macaddr.c new file mode 100644 index 00000000..1531ff72 --- /dev/null +++ b/src/sdk/RevoEX/net/wireless_macaddr.c @@ -0,0 +1,2 @@ +#include "RevoEX/ncd/ncdsystem.h" +void NETGetWirelessMacAddress(void) { NCDiGetWirelessMacAddress(); } diff --git a/src/sdk/RevoEX/so/SOBasic.h b/src/sdk/RevoEX/so/SOBasic.h new file mode 100644 index 00000000..76a12c74 --- /dev/null +++ b/src/sdk/RevoEX/so/SOBasic.h @@ -0,0 +1,16 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +uint SONtoHl(uint); +uint SONtoHs(uint); +uint SOHtoNl(uint); +uint SOHtoNs(uint); + +#ifdef __cplusplus +} +#endif \ No newline at end of file