Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/RSBE01_02/splits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ sora/nt/nt_report.cpp:
.bss start:0x8049EA30 end:0x8049EBA8
.sdata2 start:0x805A2AC0 end:0x805A2AC4

sora/nt/nt_send.cpp:
.text start:0x8013D490 end:0x8013D8A8
.data start:0x8045E000 end:0x8045E018
.sbss start:0x805A0388 end:0x805A038C

sora/nt/nt_offline.cpp:
.text start:0x8014C004 end:0x8014C180
.data start:0x80460D40 end:0x80460D4C
Expand Down
20 changes: 10 additions & 10 deletions config/RSBE01_02/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6039,11 +6039,11 @@ __dt__6NtBaseFv = .text:0x8013D298; // type:function size:0x40
allocBuffer__8NtBufferFUlQ25Heaps8HeapType = .text:0x8013D2D8; // type:function size:0x4C
__sinit_\nt_report_cpp = .text:0x8013D324; // type:function size:0x15C scope:local
__ct__7NtBlockFv = .text:0x8013D480; // type:function size:0x10
fn_8013D490 = .text:0x8013D490; // type:function size:0x1BC
fn_8013D64C = .text:0x8013D64C; // type:function size:0x64
fn_8013D6B0 = .text:0x8013D6B0; // type:function size:0x10
fn_8013D6C0 = .text:0x8013D6C0; // type:function size:0x10C
fn_8013D7CC = .text:0x8013D7CC; // type:function size:0xDC
create__6NtSendFv = .text:0x8013D490; // type:function size:0x1BC
destroy__6NtSendFv = .text:0x8013D64C; // type:function size:0x64
clearSendBuffer__6NtSendFv = .text:0x8013D6B0; // type:function size:0x10
pushback__6NtSendFUcPCvl = .text:0x8013D6C0; // type:function size:0x10C
task__6NtSendVFv = .text:0x8013D7CC; // type:function size:0xDC
fn_8013D8A8 = .text:0x8013D8A8; // type:function size:0x2A0
fn_8013DB48 = .text:0x8013DB48; // type:function size:0x24
fn_8013DB6C = .text:0x8013DB6C; // type:function size:0x6C
Expand Down Expand Up @@ -8881,7 +8881,7 @@ OSLockMutex = .text:0x801DEBB4; // type:function size:0xDC
OSUnlockMutex = .text:0x801DEC90; // type:function size:0xC8
fn_801DED58 = .text:0x801DED58; // type:function size:0x6C
fn_801DEDC4 = .text:0x801DEDC4; // type:function size:0xBC
fn_801DEE80 = .text:0x801DEE80; // type:function size:0x4
OSInitCond = .text:0x801DEE80; // type:function size:0x4
fn_801DEE84 = .text:0x801DEE84; // type:function size:0xDC
fn_801DEF60 = .text:0x801DEF60; // type:function size:0x4
fn_801DEF64 = .text:0x801DEF64; // type:function size:0x6C
Expand Down Expand Up @@ -8940,7 +8940,7 @@ fn_801E1970 = .text:0x801E1970; // type:function size:0xEC
fn_801E1A5C = .text:0x801E1A5C; // type:function size:0x24
OSSleepTicks = .text:0x801E1A80; // type:function size:0xB4
OSGetTime = .text:0x801E1B34; // type:function size:0x18
fn_801E1B4C = .text:0x801E1B4C; // type:function size:0x8
OSGetTick = .text:0x801E1B4C; // type:function size:0x8
fn_801E1B54 = .text:0x801E1B54; // type:function size:0x64
fn_801E1BB8 = .text:0x801E1BB8; // type:function size:0x58
fn_801E1C10 = .text:0x801E1C10; // type:function size:0x170
Expand Down Expand Up @@ -13820,7 +13820,7 @@ fn_8034DE58 = .text:0x8034DE58; // type:function size:0x230
fn_8034E088 = .text:0x8034E088; // type:function size:0xD0
fn_8034E158 = .text:0x8034E158; // type:function size:0x8
fn_8034E160 = .text:0x8034E160; // type:function size:0x2B8
fn_8034E418 = .text:0x8034E418; // type:function size:0xF4
DWC_SendUnreliable = .text:0x8034E418; // type:function size:0xF4
fn_8034E50C = .text:0x8034E50C; // type:function size:0x70
fn_8034E57C = .text:0x8034E57C; // type:function size:0x20
fn_8034E59C = .text:0x8034E59C; // type:function size:0x38
Expand Down Expand Up @@ -30811,7 +30811,7 @@ lbl_805A0368 = .sbss:0x805A0368; // type:object size:0x8 data:4byte
g_acCmdArg = .sbss:0x805A0370; // type:object size:0x8 data:4byte
g_acAnimCmdNull = .sbss:0x805A0378; // type:object size:0x8 data:4byte
g_ftSystem = .sbss:0x805A0380; // type:object size:0x8 data:4byte
lbl_805A0388 = .sbss:0x805A0388; // type:object size:0x8 data:4byte
g_NtSend = .sbss:0x805A0388; // type:object size:0x4 data:4byte
lbl_805A0390 = .sbss:0x805A0390; // type:object size:0x4 data:4byte
NtConsumedDataCallback__8NtShared = .sbss:0x805A0394; // type:object size:0x4 data:4byte
lbl_805A0398 = .sbss:0x805A0398; // type:object size:0x4 data:4byte
Expand Down Expand Up @@ -30841,7 +30841,7 @@ lbl_805A0404 = .sbss:0x805A0404; // type:object size:0x4 data:4byte
lbl_805A0408 = .sbss:0x805A0408; // type:object size:0x1 data:byte
lbl_805A0409 = .sbss:0x805A0409; // type:object size:0x1 data:byte
lbl_805A040A = .sbss:0x805A040A; // type:object size:0x2 data:2byte
lbl_805A040C = .sbss:0x805A040C; // type:object size:0x4 data:4byte
g_NtAIDBitmap = .sbss:0x805A040C; // type:object size:0x4 data:4byte
lbl_805A0410 = .sbss:0x805A0410; // type:object size:0x1 data:byte
lbl_805A0414 = .sbss:0x805A0414; // type:object size:0x1 data:byte
lbl_805A0415 = .sbss:0x805A0415; // type:object size:0x1 data:byte
Expand Down
1 change: 1 addition & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ def MatchingFor(*versions):
Object(Matching, "sora/ac/ac_null.cpp"),
Object(Matching, "sora/ft/ft_system.cpp"),
Object(NonMatching, "sora/nt/nt_report.cpp", extra_cflags=["-RTTI off"]),
Object(NonMatching, "sora/nt/nt_send.cpp", extra_cflags=["-RTTI off"]),
Object(Matching, "sora/nt/nt_offline.cpp", extra_cflags=["-RTTI off"]),
Object(Matching, "sora/nt/d_net_connect.cpp"),
Object(Matching, "sora/nt/nt_etc_dwc.cpp", extra_cflags=["-RTTI off"]),
Expand Down
2 changes: 1 addition & 1 deletion include/lib/BrawlHeaders
80 changes: 80 additions & 0 deletions src/sora/nt/nt_send.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#include <cstring>
#include <gf/gf_heap_manager.h>
#include <mu/wifi/mu_wifi_interface.h>
#include <nt/nt_report.h>
#include <nt/nt_send.h>
#include <revolution/DWC/dwc_transport.h>
#include <revolution/OS/OSMutex.h>
#include <revolution/OS/OSTime.h>
#include <sr/sr_common.h>
#include <types.h>

NtSend* g_NtSend;

// NONMATCHING regswap in unrolled for loop
void NtSend::create() {
g_NtSend = this;
m_pktBuffer = static_cast<NtPacketArrPtr>(
gfHeapManager::alloc(Heaps::Network, Capacity * sizeof(NtPacket)));
m_pktMemory2.allocBuffer(sizeof(NtPacketData), Heaps::Network);
m_pktMemory.allocBuffer(Capacity * sizeof(NtPacketData), Heaps::Network);
memset(m_pktBuffer, 0, 4);
NtPacketArrPtr pktPtr = m_pktBuffer;
for (u32 i = 0; i < Capacity; i++) {
(*pktPtr)[i].rawData =
i + static_cast<NtPacketData*>(m_pktMemory.m_buf);
}
clearSendBuffer();
OSInitMutex(&m_mutex);
OSInitCond(&m_cond);
}

void NtSend::destroy() {
m_pktMemory2.freeBuffer();
m_pktMemory.freeBuffer();
gfHeapManager::free(m_pktBuffer);
m_pktBuffer = nullptr;
g_NtSend = nullptr;
}

void NtSend::clearSendBuffer() {
m_endIdx = 0;
m_startIdx = 0;
}

s32 NtSend::pushback(u8 aid, const void* packetData, s32 packetSize) {
if ((g_NtAIDBitmap & (1 << aid)) == 0)
return 0;
if (aid >= 4)
return -1;
if (packetSize > NtPacketData::MaxPacketSize)
netReport("Too large packet data\n");
if (((g_NtSend->m_endIdx - g_NtSend->m_startIdx) & 0x3F) >= 0x3E)
return -1;
(*m_pktBuffer)[m_endIdx].aid = aid;
(*m_pktBuffer)[m_endIdx].size = packetSize;
memcpy((*m_pktBuffer)[m_endIdx].rawData, packetData, packetSize);
m_endIdx = (m_endIdx + 1) & 0x3F;
return 0;
}

// TODO: Find better match than this volatile hack
void NtSend::task() volatile {
while (m_startIdx != m_endIdx) {
s32 i, j;
j = m_startIdx;
i = m_startIdx;
NtPacketArrPtr pkts = m_pktBuffer;
NtPacketData* pkt = (*pkts)[j].rawData;
u32 pktSize = (*pkts)[i].size;
u32 tick = OSGetTick();
pkt->data[pktSize] = tick >> 24;
pkt->data[pktSize+1] = tick >> 16;
pkt->data[pktSize+2] = tick >> 8;
pkt->data[pktSize+3] = tick;
u8 aid = (*m_pktBuffer)[m_startIdx].aid;
if ((g_NtAIDBitmap & (1 << aid)) != 0)
DWC_SendUnreliable(aid, pkt, pktSize+4);
m_startIdx = (m_startIdx + 1) & 0x3F;
}
}
Loading