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
20 changes: 20 additions & 0 deletions config/HAFE/splits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,26 @@ System.cpp:
.sbss start:0x80330AD0 end:0x80330B78
.sdata2 start:0x80331F00 end:0x80331F78

ChannelMathData.cpp:
.sdata2 start:0x80331F78 end:0x80331FC0

WiiConnect24.cpp:
.text start:0x80032610 end:0x80035BA8
.data start:0x8019BD08 end:0x8019C189
.bss start:0x801D99E0 end:0x801F6B28
.sdata start:0x80330170 end:0x80330190
.sbss start:0x80330B78 end:0x80330B98

DragScroll.cpp:
.text start:0x80035BA8 end:0x80035DC4

WeatherUtil.cpp:
.text start:0x80035DC4 end:0x800367F4
.rodata start:0x8018F4D0 end:0x8018F4E6

MtxUtil.cpp:
.text start:0x800367F4 end:0x80036978

Tween.cpp:
.text start:0x80036994 end:0x800369F4
.sdata2 start:0x80331FC0 end:0x80331FC8
Expand Down
205 changes: 124 additions & 81 deletions config/HAFE/symbols.txt

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,11 @@ def MatchingFor(*versions):
Object(Matching, "main.cpp"),
Object(Matching, "DrawUtil.cpp"),
Object(Matching, "GlobeDots.cpp"),
Object(Matching, "WiiConnect24.cpp"),
Object(Matching, "WeatherUtil.cpp"),
Object(Matching, "ChannelMathData.cpp"),
Object(Matching, "DragScroll.cpp"),
Object(Matching, "MtxUtil.cpp"),
Object(Matching, "System.cpp"),
Object(Matching, "Tween.cpp"),
Object(NonMatching, "LayoutButton.cpp"),
Expand Down
18 changes: 18 additions & 0 deletions include/MSL_C/include/wchar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef WCHAR_H
#define WCHAR_H

#include "size_t.h"
#include "wchar_t.h"

#ifdef __cplusplus
extern "C" {
#endif

int wcscmp(const wchar_t* lhs, const wchar_t* rhs);
wchar_t* wcsncpy(wchar_t* dst, const wchar_t* src, size_t count);

#ifdef __cplusplus
}
#endif

#endif // WCHAR_H
30 changes: 30 additions & 0 deletions include/channel/ChannelMathData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef CHANNEL_CHANNEL_MATH_DATA_H
#define CHANNEL_CHANNEL_MATH_DATA_H

#include <types.h>

// These constants are defined in ChannelMathData.cpp. The code units must see
// them as external objects: defining them alongside the functions lets MWCC
// fold them into anonymous local constants, which does not match the target.
extern const f32 sDragScrollZero;
extern const f32 sDragScrollOffset;
extern const f32 sDragScrollThreshold;
extern const f32 sDragScrollNegThreshold;
extern const f32 sDragScrollMax;
extern const f32 sDragScrollAngleScale;
extern const f32 sDragScrollHalfPi;
extern const f32 sDragScrollTimerScale;

extern const f32 sSmoothEpsilon;
extern const f32 sSmoothEpsilonNeg;
extern const f32 sAngleZero;
extern const f32 sAngleFull;
extern const f32 sAngleHalfNeg;
extern const f32 sAngleHalf;
extern const f32 sIdxToFIdx;
extern const f32 sHalf;

extern const f32 sDegToRad;
extern const f32 sDegToFIdx;

#endif // CHANNEL_CHANNEL_MATH_DATA_H
78 changes: 67 additions & 11 deletions include/channel/WiiConnect24.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,84 @@
#define CHANNEL_WII_CONNECT24_H
#include <types.h>

// A WiiConnect24 request running on the worker thread (size 0x1B8)
// A pair of buffers/timestamps/sizes used by a WiiConnect24 download task.
// Each pair occupies 0x60 bytes; the remaining words are reserved and are
// only ever copied as part of the whole task.
struct WC24BufferSet {
void* forecast; // at 0x000
void* shortForecast; // at 0x004
u32 unk08[22]; // at 0x008
};

struct WC24TimeSet {
s64* forecast; // at 0x000
s64* shortForecast; // at 0x004
u32 unk08[22]; // at 0x008
};

struct WC24SizeSet {
u32* forecast; // at 0x000
u32* shortForecast; // at 0x004
u32 unk08[22]; // at 0x008
};

// A request queued for the WiiConnect24 worker thread (size 0x1B8)
struct WC24Task {
u8 unk0[0x164]; // at 0x0
s32 mState; // at 0x164
s32 mResult; // at 0x168
s32 mErrorCode; // at 0x16C
s32 mNwc24Result; // at 0x170
u8 unk174[0x1B8 - 0x174];
u32 mType; // at 0x000
u16 mTaskId; // at 0x004
u16 mSubTaskId; // at 0x006
u32 unk008; // at 0x008
u32 unk00C; // at 0x00C
u32 unk010; // at 0x010
WC24BufferSet mBuffers; // at 0x014
WC24TimeSet mTimes; // at 0x074
WC24SizeSet mSizes; // at 0x0D4
s64 mNextDownloadTimes[2]; // at 0x138
const char* mForecastUrl; // at 0x148
const char* mShortUrl; // at 0x14C
u32 mForecastBufferSize; // at 0x150
u32 mBufferSizes[2]; // at 0x154
u16 mDownloadInterval; // at 0x15C
u16 mDownloadCount; // at 0x15E
u8 mRedownload; // at 0x160
s32 mState; // at 0x164
s32 mResult; // at 0x168
s32 mErrorCode; // at 0x16C
s32 mNwc24Result; // at 0x170
char mMessage[0x40]; // at 0x174
};

extern WC24Task gWC24Tasks[];

enum WC24TaskType {
WC24_TASK_GET_WEATHER = 0,
WC24_TASK_DOWNLOAD_WEATHER = 1,
WC24_TASK_SET_WEATHER = 2,
WC24_TASK_DELETE_WEATHER = 3,
};

enum WC24TaskId {
WC24_TASK_ID_NONE = 0,
WC24_TASK_ID_FORECAST = 3,
WC24_TASK_ID_SHORT = 4,
};

void InitDownloader(void);
void UpdateDownloader(void);
void ShutdownDownloader(s32 event);


// WiiConnect24.cpp: weather download tasks
class CWiiConnect24 {
public:
static s32 getWeather(void* forecastBuf, s64* forecastTime, u32* forecastSize, void* shortBuf,
s64* shortTime, u32* shortSize, const char* forecastUrl, const char* shortUrl,
static s32 getWeather(void* forecastBuf, s64* forecastTime, u32* forecastSize,
void* shortBuf, s64* shortTime, u32* shortSize,
const char* forecastUrl, const char* shortUrl,
u32 forecastBufSize, u32 forecastMaxSize, u32 shortBufSize);
static s32 downloadWeatherForecast(void* buf, s64* time, u32* size, u32 bufSize);
static s32 downloadWeatherShort(void* buf, s64* time, u32* size, u32 bufSize);
static s32 setWeather(const char* forecastUrl, const char* shortUrl, u32 forecastBufSize, u32 arg3,
u32 arg4);
static s32 setWeather(const char* forecastUrl, const char* shortUrl, u32 forecastBufSize,
u32 redownload, u32 interval);
static s32 deleteWeather();
};

Expand Down
40 changes: 40 additions & 0 deletions include/channel/WiiConnect24Internal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef CHANNEL_WII_CONNECT24_INTERNAL_H
#define CHANNEL_WII_CONNECT24_INTERNAL_H
#include <types.h>

#include <revolution/MEM.h>
#include <revolution/OS.h>

#include <channel/WiiConnect24.h>

extern OSMessageQueue gWC24Queue;
extern OSMessage gWC24QueueBuffer[16];
extern OSThread gWC24Thread;
extern u8 gWC24ThreadStack[];
extern u8 gWC24FileBuffer[];
extern volatile u8 gWC24DownloadComplete;
extern volatile u8 gWC24NetInitialized;
extern volatile u8 gWC24ShutdownFlag1;
extern volatile u8 gWC24ShutdownFlag2;
extern volatile s32 gWC24DownloadIndex;
extern volatile s32 gWC24QueueIndex;
extern volatile s32 gWC24TaskCount;
extern void* gWC24HeapBlock;
extern MEMiHeapHead* gWC24Heap;

// The SO block is not split yet; keep the dependency declarations together.
#ifdef __cplusplus
extern "C" {
#endif
s32 SOInit(void* init);
s32 SOStartup(void);
s32 SOGetLastError(void);
#ifdef __cplusplus
}
#endif

void* DownloaderThread(void* pArg);
void* WC24Alloc(u32 unused, s32 size);
void WC24Free(void* unused, void* pBlock, s32 size);

#endif
20 changes: 20 additions & 0 deletions include/revolution/NWC24/NWC24Download.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,26 @@ typedef struct NWC24DlTask {
NWC24Err NWC24CheckDlTask(NWC24DlTask* pTask);
NWC24Err NWC24DeleteDlTaskForced(NWC24DlTask* pTask);
NWC24Err NWC24GetDlTask(NWC24DlTask* pTask, u16 id);
NWC24Err NWC24InitDlTask(NWC24DlTask* pTask, u32 type);
NWC24Err NWC24SetDlId(NWC24DlTask* pTask, u16 id);
NWC24Err NWC24GetDlId(NWC24DlTask* pTask, u32* pId);
NWC24Err NWC24SetDlPriority(NWC24DlTask* pTask, s32 priority);
NWC24Err NWC24SetDlInterval(NWC24DlTask* pTask, u16 interval);
NWC24Err NWC24GetDlInterval(NWC24DlTask* pTask, u16* pInterval);
NWC24Err NWC24SetDlRetryMargin(NWC24DlTask* pTask, s32 margin);
NWC24Err NWC24SetDlUrl(NWC24DlTask* pTask, const char* url);
NWC24Err NWC24GetDlUrl(NWC24DlTask* pTask, char* url, u32 len);
NWC24Err NWC24SetDlFlags(NWC24DlTask* pTask, u32 flags);
NWC24Err NWC24SetDlFilename(NWC24DlTask* pTask, const char* name);
NWC24Err NWC24GetDlFilename(NWC24DlTask* pTask, char* name, u32 len);
NWC24Err NWC24SetDlCount(NWC24DlTask* pTask, s16 count);
NWC24Err NWC24GetDlLastUpdate(NWC24DlTask* pTask, s64* time);
NWC24Err NWC24UpdateDlTask(NWC24DlTask* pTask);
NWC24Err NWC24DeleteDlTask(NWC24DlTask* pTask);
NWC24Err NWC24AddDlTask(NWC24DlTask* pTask);
NWC24Err NWC24GetDlNextTime(NWC24DlTask* pTask, s64* time);
NWC24Err NWC24GetDlVfName(NWC24DlTask* pTask, char* name, u32 len);
NWC24Err NWC24CreateDlVf(NWC24DlTask* pTask, u32 size);

#ifdef __cplusplus
}
Expand Down
1 change: 1 addition & 0 deletions include/revolution/NWC24/NWC24Schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extern "C" {

s32 NWC24SuspendScheduler(void);
s32 NWC24ResumeScheduler(void);
NWC24Err NWC24ExecDownloadTask(s32 mode, u16 taskId, s32 flags);

#ifdef __cplusplus
}
Expand Down
1 change: 1 addition & 0 deletions include/revolution/NWC24/internal/NWC24iDownload.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ NWC24Err NWC24iCloseDlTaskList(void);
NWC24iDlHeader* NWC24iGetCachedDlHeader(void);
NWC24Err NWC24iCheckHeaderConsistency(NWC24iDlHeader* pHeader, BOOL clear)
DECOMP_DONT_INLINE;
NWC24Err NWC24iCheckDlTask(NWC24DlTask* pTask);
NWC24Err NWC24iLoadDlHeader(void);

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion include/revolution/NWC24/internal/NWC24iSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extern "C" {
#endif

NWC24Err NWC24iPrepareShutdown(void);
NWC24Err NWC24iRequestShutdown(u32 event, NWC24Err* pResult);
NWC24Err NWC24iRequestShutdown(u32 event);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion include/revolution/SC/scapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ typedef struct SCSimpleAddress {
u8 SCGetAspectRatio(void);
s8 SCGetDisplayOffsetH(void);
u8 SCGetEuRgb60Mode(void);
void SCGetIdleMode(SCIdleModeInfo* mode);
BOOL SCGetIdleMode(SCIdleModeInfo* mode);
u8 SCGetLanguage(void);
BOOL SCSetLanguage(u8 language);
BOOL SCGetParentalControl(SCParentalControlsInfo* pcInfo);
Expand Down
25 changes: 25 additions & 0 deletions src/ChannelMathData.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <types.h>
#include <channel/ChannelMathData.h>

// Definitions deliberately live in a separate TU from the functions that use
// them. This forces named external constants; same-TU definitions are folded
// by MWCC into anonymous locals and break the target match.

const f32 sDragScrollZero = 0.0f;
const f32 sDragScrollOffset = 228.0f;
const f32 sDragScrollThreshold = 20.0f;
const f32 sDragScrollNegThreshold = -20.0f;
const f32 sDragScrollMax = 185.2f;
const f32 sDragScrollAngleScale = 40.743664f;
const f32 sDragScrollHalfPi = 1.5707964f;
const f32 sDragScrollTimerScale = 23.0f;
const f32 sSmoothEpsilon = 0.0008f;
const f32 sSmoothEpsilonNeg = -0.0008f;
const f32 sAngleZero = 0.0f;
const f32 sAngleFull = 360.0f;
const f32 sAngleHalfNeg = -180.0f;
const f32 sAngleHalf = 180.0f;
const f32 sIdxToFIdx = 0.00390625f;
const f32 sHalf = 0.5f;
const f32 sDegToRad = 0.017453292f;
const f32 sDegToFIdx = 0.7111111f;
84 changes: 84 additions & 0 deletions src/DragScroll.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#include <channel/System.h>
#include <channel/ChannelMathData.h>
#include <nw4r/math.h>


// Layout matches gDragScroll in SceneBase.cpp (size 0x34).
struct DragScroll {
DragScroll();
void Reset();
void Update();
void UpdateChan(s32 chan);

f32 mScroll[4]; // at 0x00
s32 mTimer[4]; // at 0x10
s32 mState[4]; // at 0x20
u8 mActive; // at 0x30
u8 unk31[3]; // at 0x31
};

DragScroll::DragScroll() {
for (int i = 0; i < 4; i++) {
mScroll[i] = sDragScrollZero;
mTimer[i] = 0;
mState[i] = 0;
}
mActive = 0;
}

void DragScroll::Reset() {
for (int i = 0; i < 4; i++) {
mScroll[i] = sDragScrollZero;
mTimer[i] = 0;
mState[i] = 0;
}
mActive = 0;
}

void DragScroll::UpdateChan(s32 chan) {
f32* pScroll = &mScroll[chan];
s32* pTimer = &mTimer[chan];
s32* pState = &mState[chan];

f32 scroll = sDragScrollOffset - gPointerY[chan][0];
*pScroll = scroll;

BOOL zero = scroll < sDragScrollThreshold && scroll > sDragScrollNegThreshold;
if (zero) {
*pScroll = sDragScrollZero;
return;
}

if (*pTimer > 0)
(*pTimer)--;

if (*pTimer != 0)
return;

*pState = *pScroll > sDragScrollZero ? 1 : 2;

f32 max = sDragScrollMax;
f32 amount = __fabsf(*pScroll) - sDragScrollThreshold;
if (amount > max)
amount = max;

f32 angle = sDragScrollAngleScale * (sDragScrollHalfPi * amount / max);
*pTimer = (s32)(sDragScrollTimerScale * nw4r::math::CosFIdx(angle)) + 1;
}

void DragScroll::Update() {
s32* pTimer = mTimer;
s32* pState = mState;
int i;

for (i = 0; i < 4; i++, pState++, pTimer++) {
*pState = 0;

if (gHold[i] & 0x400) { // WPAD_BUTTON_B
mActive = TRUE;
UpdateChan(i);
} else {
*pTimer = 0;
}
}
}
Loading
Loading