mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-11 12:39:48 -04:00
4df8ccc871
* Reorganize files into libs/{dolphin,JSystem,PowerPC_EABI_Support,revolution,TRK_MINNOW_DOLPHIN}
* Update configure.py and project.py for new libs structure
* Refactor `#include <dolphin/x.h>` -> `<x.h>`
* Remove `__REVOLUTION_SDK__` forwards from dolphin
* Fix dolphin/ references in revolution
* Wrap `#include <dolphin.h>` in `!__REVOLUTION_SDK__`
* Always build TRK against dolphin headers
* Resolve revolution SDK header resolution issues
59 lines
1.6 KiB
C++
59 lines
1.6 KiB
C++
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
|
|
|
#include "JSystem/JHostIO/JORHostInfo.h"
|
|
#include "JSystem/JHostIO/JORServer.h"
|
|
|
|
// End of each month in standard year
|
|
static s32 YearDays[] = {
|
|
0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334,
|
|
};
|
|
|
|
// End of each month in leap year
|
|
static s32 LeapYearDays[] = {
|
|
0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335,
|
|
};
|
|
|
|
static BOOL IsLeapYear(int year) {
|
|
return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
|
|
}
|
|
|
|
BOOL JORGetYearDays(int year, int mon) {
|
|
s32* days = IsLeapYear(year) ? LeapYearDays : YearDays;
|
|
return days[mon];
|
|
}
|
|
|
|
bool JORGetHostInfo(u32 request_type, JORHostInfo* pHostinfo) {
|
|
JORMContext* mctx = JORServer::getInstance()->attachMCTX(MCTX_MSG_GET_HOST_INFO);
|
|
mctx->sendHostInfoRequest(request_type, pHostinfo);
|
|
JORServer::getInstance()->releaseMCTX(mctx);
|
|
|
|
while (pHostinfo->getResult() == 0) {
|
|
JOR_MESSAGELOOP();
|
|
}
|
|
|
|
return pHostinfo->getResult() == 1;
|
|
}
|
|
|
|
void JORGetComputerName(char* buffer, u32 buffer_size) {
|
|
JORHostInfo_String string;
|
|
string.setStringBuffer(buffer);
|
|
string.setBufferSize(buffer_size);
|
|
|
|
JORGetHostInfo(HOSTINFO_REQ_COMPUTER_NAME, &string);
|
|
}
|
|
|
|
void JORGetUserName(char* buffer, u32 buffer_size) {
|
|
JORHostInfo_String string;
|
|
string.setStringBuffer(buffer);
|
|
string.setBufferSize(buffer_size);
|
|
|
|
JORGetHostInfo(HOSTINFO_REQ_USERNAME, &string);
|
|
}
|
|
|
|
void JORGetLocalTime(OSCalendarTime* pCalendarTime) {
|
|
JORHostInfo_CalendarTime calendar_time;
|
|
calendar_time.setCalendarTimeBuffer(pCalendarTime);
|
|
|
|
JORGetHostInfo(HOSTINFO_REQ_LOCAL_TIME, &calendar_time);
|
|
}
|