diff --git a/config/RSPE01_01/symbols.txt b/config/RSPE01_01/symbols.txt index 1dfab822..bec68251 100644 --- a/config/RSPE01_01/symbols.txt +++ b/config/RSPE01_01/symbols.txt @@ -6969,7 +6969,7 @@ fn_80186054 = .text:0x80186054; // type:function size:0xAC fn_80186100 = .text:0x80186100; // type:function size:0x8 fn_80186108 = .text:0x80186108; // type:function size:0x12C setLanguage__17RPSysProjectLocalFQ217RPSysProjectLocal5EArea = .text:0x80186234; // type:function size:0x8 -setDialect__17RPSysProjectLocalFQ217RPSysProjectLocal5EArea = .text:0x8018623C; // type:function size:0x8 +setLocale__17RPSysProjectLocalFQ217RPSysProjectLocal5EArea = .text:0x8018623C; // type:function size:0x8 appendLocalDirectory__17RPSysProjectLocalFPcPCc = .text:0x80186244; // type:function size:0x120 __dt__17RPSysProjectLocalFv = .text:0x80186364; // type:function size:0x40 CreateInstance__17RPSysProjectLocalFPQ23EGG4Heap = .text:0x801863A4; // type:function size:0x8C @@ -7613,16 +7613,16 @@ fn_8019FFE0 = .text:0x8019FFE0; // type:function size:0x11C fn_801A00FC = .text:0x801A00FC; // type:function size:0x134 fn_801A0230 = .text:0x801A0230; // type:function size:0x60 fn_801A0290 = .text:0x801A0290; // type:function size:0x2C -fn_801A02BC = .text:0x801A02BC; // type:function size:0xB4 -fn_801A0370 = .text:0x801A0370; // type:function size:0xA8 -fn_801A0418 = .text:0x801A0418; // type:function size:0x6C -fn_801A0484 = .text:0x801A0484; // type:function size:0xFC -fn_801A0580 = .text:0x801A0580; // type:function size:0x1F4 -fn_801A0774 = .text:0x801A0774; // type:function size:0xFC -fn_801A0870 = .text:0x801A0870; // type:function size:0xDC -fn_801A094C = .text:0x801A094C; // type:function size:0x64 -fn_801A09B0 = .text:0x801A09B0; // type:function size:0x60 -fn_801A0A10 = .text:0x801A0A10; // type:function size:0x50 +ChangePointHalfFull__18RPSysStringUtilityFPw = .text:0x801A02BC; // type:function size:0xB4 +ChangePoint__18RPSysStringUtilityFPw = .text:0x801A0370; // type:function size:0xA8 +GetFloat__18RPSysStringUtilityFPCw = .text:0x801A0418; // type:function size:0x6C +GetStringHalfSizeTime__18RPSysStringUtilityFUlUlPw = .text:0x801A0484; // type:function size:0xFC +GetStringHalfSizeDate__18RPSysStringUtilityFUlUlUlPwUll = .text:0x801A0580; // type:function size:0x1F4 +GetStringHalfSizeNumber__18RPSysStringUtilityFfllPwUlbQ218RPSysStringUtility8FillType = .text:0x801A0774; // type:function size:0xFC +GetStringFullSizeNumber__18RPSysStringUtilityFlPwUlb = .text:0x801A0870; // type:function size:0xDC +GetStringHalfSizeNumber__18RPSysStringUtilityFlPwUlb = .text:0x801A094C; // type:function size:0x64 +IsSingular__18RPSysStringUtilityFf = .text:0x801A09B0; // type:function size:0x60 +IsSingular__18RPSysStringUtilityFl = .text:0x801A0A10; // type:function size:0x50 calc__26RPSysKokeshiCtrlDataLoaderFv = .text:0x801A0A60; // type:function size:0x84 isIdle__26RPSysKokeshiCtrlDataLoaderCFv = .text:0x801A0AE4; // type:function size:0x18 load__26RPSysKokeshiCtrlDataLoaderFv = .text:0x801A0AFC; // type:function size:0x70 diff --git a/configure.py b/configure.py index de413985..0ea514cb 100755 --- a/configure.py +++ b/configure.py @@ -1128,7 +1128,7 @@ def MatchingFor(*versions): Object(NonMatching, "Pack/RPKernel/RPSysLytDynamicAnm.cpp"), Object(Matching, "Pack/RPKernel/RPSysKokeshiIterater.cpp"), Object(NonMatching, "Pack/RPKernel/RPSysCursorDrawMgr.cpp"), - Object(NonMatching, "Pack/RPKernel/RPSysStringUtility.cpp"), + Object(Matching, "Pack/RPKernel/RPSysStringUtility.cpp"), Object(Matching, "Pack/RPKernel/RPSysKokeshiCtrlDataLoader.cpp"), Object(NonMatching, "Pack/RPKernel/RPSysPauseMenu.cpp"), Object(NonMatching, "Pack/RPKernel/RPSysSystemWinMgr.cpp"), diff --git a/include/Pack/RPKernel.h b/include/Pack/RPKernel.h index 435f9ff7..0f480270 100644 --- a/include/Pack/RPKernel.h +++ b/include/Pack/RPKernel.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Pack/RPKernel/RPSysStringUtility.h b/include/Pack/RPKernel/RPSysStringUtility.h new file mode 100644 index 00000000..5a853c1a --- /dev/null +++ b/include/Pack/RPKernel/RPSysStringUtility.h @@ -0,0 +1,130 @@ +#ifndef RP_KERNEL_STRING_UTILITY_H +#define RP_KERNEL_STRING_UTILITY_H +#include + +//! @addtogroup rp_kernel +//! @{ + +/** + * @brief String utility functions + */ +class RPSysStringUtility { +public: + /** + * @brief Decimal point fill type + */ + enum FillType { + FillType_HalfWidth, //!< Use half-width characters + FillType_FullWidth, //!< Use full-width characters + }; + +public: + /** + * @brief Tests whether the specified integral value is a singular noun + * + * @param x Integral value + */ + static bool IsSingular(s32 x); + + /** + * @brief Tests whether the specified decimal value is a singular noun + * + * @param x Decimal value + */ + static bool IsSingular(f32 x); + + /** + * @brief Converts the specified integer to a half-width string + * + * @param x Integer value + * @param[out] pBuffer String buffer + * @param maxLen Buffer length + * @param plusSign Whether to include signage for positive values + */ + static void GetStringHalfSizeNumber(s32 x, wchar_t* pBuffer, u32 maxLen, + bool plusSign = false); + + /** + * @brief Converts the specified integer to a full-width string + * + * @param x Integer value + * @param[out] pBuffer String buffer + * @param maxLen Buffer length + * @param plusSign Whether to include signage for positive values + */ + static void GetStringFullSizeNumber(s32 x, wchar_t* pBuffer, u32 maxLen, + bool plusSign = false); + + /** + * @brief Converts the specified decimal to a half-width string + * + * @param x Decimal value + * @param width Value string width + * @param precision Value string precision + * @param[out] pBuffer String buffer + * @param maxLen Buffer length + * @param plusSign Whether to include signage for positive values + * @param fillType Decimal point fill type + */ + static void GetStringHalfSizeNumber(f32 x, s32 width, s32 precision, + wchar_t* pBuffer, u32 maxLen, + bool plusSign, FillType fillType); + + /** + * @brief Converts half-width characters in the specified string to + * full-width characters + * + * @param[in,out] pStr Input string + */ + static void ChangeToFullSize(wchar_t* pStr); + + /** + * @brief Converts the specified date to a half-width string + * + * @param year Year + * @param month Month + * @param day Day + * @param[out] pBuffer String buffer + * @param maxLen Buffer length + * @param yearSize Number of digits to use when expressing the year + */ + static void GetStringHalfSizeDate(u32 year, u32 month, u32 day, + wchar_t* pBuffer, u32 maxLen, + s32 yearSize = 4); + + /** + * @brief Converts the specified time to a half-width string + * + * @param hour Hour + * @param min Minute + * @param[out] pBuffer String buffer + */ + static void GetStringHalfSizeTime(u32 hour, u32 min, wchar_t* pBuffer); + + /** + * @brief Parses a float value from the specified string + * @details This function supports strings using commas as the decimal + * + * @param pStr Input string + */ + static f32 GetFloat(const wchar_t* pStr); + + /** + * @brief Changes decimal points in the specified string to match the locale + * + * @param pStr Input string + */ + static void ChangePoint(wchar_t* pStr); + + /** + * @brief Swaps decimal points in the specified string between half and full + * width + * + * @param pStr Input string + */ + static void ChangePointHalfFull(wchar_t* pStr); +}; + +//! @} + +#endif diff --git a/include/Pack/RPSystem/RPSysProjectLocal.h b/include/Pack/RPSystem/RPSysProjectLocal.h index 6ca2daf2..ee019054 100644 --- a/include/Pack/RPSystem/RPSysProjectLocal.h +++ b/include/Pack/RPSystem/RPSysProjectLocal.h @@ -60,11 +60,11 @@ class RPSysProjectLocal { void appendLocalDirectory(char* pPath, const char* pSuffix = ""); /** - * @brief Sets the current dialect + * @brief Sets the current locale * - * @param dialect Dialect area + * @param locale Locale area */ - void setDialect(EArea dialect); + void setLocale(EArea locale); /** * @brief Sets the current language @@ -88,10 +88,10 @@ class RPSysProjectLocal { } /** - * @brief Gets the current language dialect + * @brief Gets the current game locale */ - EArea getDialect() const { - return mDialect; + EArea getLocale() const { + return mLocale; } /** @@ -120,8 +120,8 @@ class RPSysProjectLocal { ERegion mRegion; // at 0x8 //! Pack Project title RPSysSceneCreator::EPackID mPack; // at 0xC - //! Language dialect - EArea mDialect; // at 0x10 + //! Game locale + EArea mLocale; // at 0x10 //! Game language EArea mLanguage; // at 0x14 //! Whether the display is 50Hz diff --git a/include/nw4r/ut/ut_FileStream.h b/include/nw4r/ut/ut_FileStream.h index e0a803c9..40a1f45f 100644 --- a/include/nw4r/ut/ut_FileStream.h +++ b/include/nw4r/ut/ut_FileStream.h @@ -11,7 +11,7 @@ class FileStream : public IOStream { public: NW4R_UT_RTTI_DECL(FileStream); - enum SeekOrigin { SEEK_BEG, SEEK_CUR, SEEK_END }; + enum SeekOrigin { SEEK_ORIGIN_BEG, SEEK_ORIGIN_CUR, SEEK_ORIGIN_END }; public: FileStream() {} diff --git a/src/Pack/RPKernel/RPSysStringUtility.cpp b/src/Pack/RPKernel/RPSysStringUtility.cpp new file mode 100644 index 00000000..5ee38213 --- /dev/null +++ b/src/Pack/RPKernel/RPSysStringUtility.cpp @@ -0,0 +1,405 @@ +#include +#include + +#include +#include + +/** + * @brief Tests whether the specified integral value is a singular noun + * + * @param x Integral value + */ +bool RPSysStringUtility::IsSingular(s32 x) { + RPSysProjectLocal::EArea locale = + RP_GET_INSTANCE(RPSysProjectLocal)->getLocale(); + + if (locale == RPSysProjectLocal::EArea_France) { + if (x < 2 && x > -2) { + return true; + } + + return false; + } + + if (x == 1 || x == -1) { + return true; + } + + return false; +} + +/** + * @brief Tests whether the specified decimal value is a singular noun + * + * @param x Decimal value + */ +bool RPSysStringUtility::IsSingular(f32 x) { + RPSysProjectLocal::EArea locale = + RP_GET_INSTANCE(RPSysProjectLocal)->getLocale(); + + if (locale == RPSysProjectLocal::EArea_France) { + if (2.0f > x && -2.0f < x) { + return true; + } + + return false; + } + + if (x == 1.0f || x == -1.0f) { + return true; + } + + return false; +} + +/** + * @brief Converts the specified integer to a half-width string + * + * @param x Integer value + * @param[out] pBuffer String buffer + * @param maxLen Buffer length + * @param plusSign Whether to include signage for positive values + */ +void RPSysStringUtility::GetStringHalfSizeNumber(s32 x, wchar_t* pBuffer, + u32 maxLen, bool plusSign) { + s32 skip = 0; + + if (plusSign && x == 0) { + skip = 1; + *pBuffer = L'±'; + } else if (plusSign && x > 0) { + skip = 1; + *pBuffer = L'+'; + } + + std::swprintf(pBuffer + skip, maxLen - skip, L"%d", x); +} + +/** + * @brief Converts the specified integer to a full-width string + * + * @param x Integer value + * @param[out] pBuffer String buffer + * @param maxLen Buffer length + * @param plusSign Whether to include signage for positive values + */ +void RPSysStringUtility::GetStringFullSizeNumber(s32 x, wchar_t* pBuffer, + u32 maxLen, bool plusSign) { + GetStringHalfSizeNumber(x, pBuffer, maxLen, plusSign); + ChangeToFullSize(pBuffer); +} + +/** + * @brief Converts the specified decimal to a half-width string + * + * @param x Decimal value + * @param width Value string width + * @param precision Value string precision + * @param[out] pBuffer String buffer + * @param maxLen Buffer length + * @param plusSign Whether to include signage for positive values + * @param fillType Decimal point fill type + */ +void RPSysStringUtility::GetStringHalfSizeNumber(f32 x, s32 width, + s32 precision, + wchar_t* pBuffer, u32 maxLen, + bool plusSign, + FillType fillType) { + wchar_t fmt[16]; + std::swprintf(fmt, ARRAY_SIZE(fmt), L"%%%d.%df", width, precision); + + s32 skip = 0; + + if (plusSign && x == 0.0f) { + skip = 1; + *pBuffer = L'±'; + } else if (plusSign && 0.0f < x) { + skip = 1; + *pBuffer = L'+'; + } + + std::swprintf(pBuffer + skip, maxLen - skip, fmt, x); + ChangePoint(pBuffer); + + if (fillType != FillType_HalfWidth) { + ChangePointHalfFull(pBuffer); + } +} + +/** + * @brief Converts half-width characters in the specified string to + * full-width characters + * + * @param pStr Input string + */ +void RPSysStringUtility::ChangeToFullSize(wchar_t* pStr) { + u32 len = std::wcslen(pStr); + + for (u32 i = 0; i < len; i++) { + if (pStr[i] == L' ') { + pStr[i] = 0x3000 /* ideographic space */; + } else if (pStr[i] >= L'!' && pStr[i] <= L'~') { + pStr[i] += 0xFEE0; + } + } +} + +/** + * @brief Converts the specified date to a half-width string + * + * @param year Year + * @param month Month + * @param day Day + * @param[out] pBuffer String buffer + * @param maxLen Buffer length + * @param yearSize Number of digits to use when expressing the year + */ +void RPSysStringUtility::GetStringHalfSizeDate(u32 year, u32 month, u32 day, + wchar_t* pBuffer, + u32 /* maxLen */, s32 yearSize) { + RPSysProjectLocal::EArea locale = + RP_GET_INSTANCE(RPSysProjectLocal)->getLocale(); + + s32 index = 0; + + // Date string indices + enum { T1 = 0, SEP1 = 2, T2 = 3, SEP2 = 5, T3 = 6, SEP3 = 8 }; + + switch (locale) { + // YY/MM/DD + case RPSysProjectLocal::EArea_Japan: { + pBuffer[yearSize + SEP1 - SEP1] = L'/'; + pBuffer[yearSize + SEP2 - SEP1] = L'/'; + break; + } + + // DD/MM/YY + case RPSysProjectLocal::EArea_Germany: { + pBuffer[SEP1] = L'.'; + pBuffer[SEP2] = L'.'; + break; + } + + // MM/DD/YY + default: { + pBuffer[SEP1] = L'/'; + pBuffer[SEP2] = L'/'; + break; + } + } + + switch (locale) { + // YY/MM/DD + case RPSysProjectLocal::EArea_Japan: { + index = T1; + break; + } + + // MM/DD/YY or DD/MM/YY + default: { + index = T3; + break; + } + } + + if (yearSize == 4) { + s32 yearIdx = index; + pBuffer[yearIdx] = L'0' + year / 1000; + pBuffer[++yearIdx] = L'0' + (year % 1000) / 100; + + index += 2; + } + + pBuffer[index] = L'0' + (year % 100) / 10; + pBuffer[++index] = L'0' + year % 10; + + switch (locale) { + // YY/MM/DD + case RPSysProjectLocal::EArea_Japan: { + index = yearSize + 1; + break; + } + + // MM/DD/YY + case RPSysProjectLocal::EArea_USA: { + index = T1; + break; + } + + // DD/MM/YY + default: { + index = T2; + break; + } + } + + pBuffer[index] = L'0' + month / 10; + pBuffer[++index] = L'0' + month % 10; + + switch (locale) { + // YY/MM/DD + case RPSysProjectLocal::EArea_Japan: { + index = yearSize + T3 - SEP1; + break; + } + + // MM/DD/YY + case RPSysProjectLocal::EArea_USA: { + index = T2; + break; + } + + // DD/MM/YY + default: { + index = T1; + break; + } + } + + pBuffer[index] = L'0' + day / 10; + pBuffer[++index] = L'0' + day % 10; + + pBuffer[yearSize + T3 - T1] = L'\0'; +} + +/** + * @brief Converts the specified time to a half-width string + * + * @param hour Hour + * @param min Minute + * @param[out] pBuffer String buffer + */ +void RPSysStringUtility::GetStringHalfSizeTime(u32 hour, u32 min, + wchar_t* pBuffer) { + RPSysProjectLocal::EArea locale = + RP_GET_INSTANCE(RPSysProjectLocal)->getLocale(); + + // Time string indices + enum { HH = 0, HSEP = 2, MM = 3, MSEP = 5, PER = 6, END = 10 }; + + // Only US builds append the AM/PM period + pBuffer[MSEP] = L'\0'; + pBuffer[HSEP] = L':'; + + if (locale == RPSysProjectLocal::EArea_USA) { + pBuffer[MSEP] = L' '; + pBuffer[END] = L'\0'; + + if (hour > 11) { + pBuffer[PER + 0] = L'p'; + pBuffer[PER + 1] = L'.'; + pBuffer[PER + 2] = L'm'; + pBuffer[PER + 3] = L'.'; + + hour %= 12; + + if (hour == 0) { + hour = 12; + } + } else { + pBuffer[PER + 0] = L'a'; + pBuffer[PER + 1] = L'.'; + pBuffer[PER + 2] = L'm'; + pBuffer[PER + 3] = L'.'; + } + } + + if (hour / 10 == 0) { + pBuffer[HH + 0] = L' '; + } else { + pBuffer[HH + 0] = L'0' + hour / 10; + } + pBuffer[HH + 1] = L'0' + hour % 10; + + pBuffer[MM + 0] = L'0' + min / 10; + pBuffer[MM + 1] = L'0' + min % 10; +} + +/** + * @brief Parses a float value from the specified string + * @details This function supports strings using commas as the decimal + * + * @param pStr Input string + */ +f32 RPSysStringUtility::GetFloat(const wchar_t* pStr) { + char work[128]; + u32 i; + + for (i = 0; pStr[i] != L'\0'; i++) { + if (pStr[i] == L',') { + work[i] = '.'; + } else { + work[i] = static_cast(pStr[i]); + } + } + + work[i] = '\0'; + return static_cast(std::atof(work)); +} + +/** + * @brief Changes decimal points in the specified string to match the locale + * + * @param pStr Input string + */ +void RPSysStringUtility::ChangePoint(wchar_t* pStr) { + RPSysProjectLocal::EArea locale = + RP_GET_INSTANCE(RPSysProjectLocal)->getLocale(); + + if (locale == RPSysProjectLocal::EArea_Japan || + locale == RPSysProjectLocal::EArea_USA || + locale == RPSysProjectLocal::EArea_England) { + return; + } + + u32 len = std::wcslen(pStr); + + for (u32 i = 0; i < len; i++) { + if (pStr[i] == L'.') { + pStr[i] = L','; + break; + } else if (pStr[i] == L'.' /* full-width period */) { + pStr[i] = L',' /* full-width comma */; + break; + } + } +} + +/** + * @brief Swaps decimal points in the specified string between half and full + * width + * + * @param pStr Input string + */ +void RPSysStringUtility::ChangePointHalfFull(wchar_t* pStr) { + u32 len = std::wcslen(pStr); + + for (u32 i = 0; i < len; i++) { + switch (pStr[i]) { + default: { + break; + } + + case L'.': { + pStr[i] = L'.'; /* full-width period */ + break; + } + + case L'.' /* full-width period */: { + pStr[i] = L'.'; + break; + } + + case L',': { + // @bug Should be a full-width character + pStr[i] = L','; + break; + } + + case L',' /* full-width comma */: { + pStr[i] = L','; + break; + } + } + } +} diff --git a/src/Pack/RPSystem/RPSysProjectLocal.cpp b/src/Pack/RPSystem/RPSysProjectLocal.cpp index 460bf22b..3ab52d30 100644 --- a/src/Pack/RPSystem/RPSysProjectLocal.cpp +++ b/src/Pack/RPSystem/RPSysProjectLocal.cpp @@ -14,7 +14,7 @@ RPSysProjectLocal::RPSysProjectLocal(EGG::Heap* pHeap) #if defined(VERSION_RSPE01_01) mRegion(ERegion_NTSC_U), - mDialect(EArea_USA), + mLocale(EArea_USA), mLanguage(EArea_USA), mIsPal50(false), mSoundStorage(EStorage_Memory), @@ -40,7 +40,7 @@ RPSysProjectLocal::~RPSysProjectLocal() {} * @param pSuffix Optional suffix to append after the locale */ void RPSysProjectLocal::appendLocalDirectory(char* pPath, const char* pSuffix) { - switch (mDialect) { + switch (mLocale) { case EArea_England: { std::strcat(pPath, "EN/"); break; @@ -93,12 +93,12 @@ void RPSysProjectLocal::appendLocalDirectory(char* pPath, const char* pSuffix) { } /** - * @brief Sets the current dialect + * @brief Sets the current locale * - * @param dialect Dialect area + * @param locale Locale area */ -void RPSysProjectLocal::setDialect(EArea dialect) { - mDialect = dialect; +void RPSysProjectLocal::setLocale(EArea locale) { + mLocale = locale; } /** diff --git a/src/nw4r/snd/snd_DvdSoundArchive.cpp b/src/nw4r/snd/snd_DvdSoundArchive.cpp index 400ca1b3..f8c1081e 100644 --- a/src/nw4r/snd/snd_DvdSoundArchive.cpp +++ b/src/nw4r/snd/snd_DvdSoundArchive.cpp @@ -177,7 +177,7 @@ DvdSoundArchive::DvdFileStream::DvdFileStream(const DVDFileInfo* pFileInfo, mSize = ut::DvdFileStream::GetSize(); } - ut::DvdFileStream::Seek(mOffset, SEEK_BEG); + ut::DvdFileStream::Seek(mOffset, SEEK_ORIGIN_BEG); } DvdSoundArchive::DvdFileStream::DvdFileStream(s32 entrynum, u32 offset, @@ -187,7 +187,7 @@ DvdSoundArchive::DvdFileStream::DvdFileStream(s32 entrynum, u32 offset, mSize = ut::DvdFileStream::GetSize(); } - ut::DvdFileStream::Seek(mOffset, SEEK_BEG); + ut::DvdFileStream::Seek(mOffset, SEEK_ORIGIN_BEG); } s32 DvdSoundArchive::DvdFileStream::Read(void* pDst, u32 size) { @@ -203,17 +203,17 @@ s32 DvdSoundArchive::DvdFileStream::Read(void* pDst, u32 size) { void DvdSoundArchive::DvdFileStream::Seek(s32 offset, u32 origin) { switch (origin) { - case SEEK_BEG: { + case SEEK_ORIGIN_BEG: { offset += mOffset; break; } - case SEEK_CUR: { + case SEEK_ORIGIN_CUR: { offset += ut::DvdFileStream::Tell(); break; } - case SEEK_END: { + case SEEK_ORIGIN_END: { offset = mOffset + mSize - offset; break; } @@ -229,7 +229,7 @@ void DvdSoundArchive::DvdFileStream::Seek(s32 offset, u32 origin) { offset = mOffset + mSize; } - ut::DvdFileStream::Seek(offset, SEEK_BEG); + ut::DvdFileStream::Seek(offset, SEEK_ORIGIN_BEG); } } // namespace snd diff --git a/src/nw4r/snd/snd_MemorySoundArchive.cpp b/src/nw4r/snd/snd_MemorySoundArchive.cpp index 06b3e212..a068b21d 100644 --- a/src/nw4r/snd/snd_MemorySoundArchive.cpp +++ b/src/nw4r/snd/snd_MemorySoundArchive.cpp @@ -173,17 +173,17 @@ s32 MemorySoundArchive::MemoryFileStream::Read(void* pDst, u32 size) { void MemorySoundArchive::MemoryFileStream::Seek(s32 offset, u32 origin) { switch (origin) { - case SEEK_BEG: { + case SEEK_ORIGIN_BEG: { mOffset = offset; break; } - case SEEK_CUR: { + case SEEK_ORIGIN_CUR: { mOffset += offset; break; } - case SEEK_END: { + case SEEK_ORIGIN_END: { mOffset = mSize - offset; break; } diff --git a/src/nw4r/snd/snd_NandSoundArchive.cpp b/src/nw4r/snd/snd_NandSoundArchive.cpp index 0eed5502..01b2186f 100644 --- a/src/nw4r/snd/snd_NandSoundArchive.cpp +++ b/src/nw4r/snd/snd_NandSoundArchive.cpp @@ -200,7 +200,7 @@ NandSoundArchive::NandFileStream::NandFileStream(const NANDFileInfo* pFileInfo, mSize = ut::NandFileStream::GetSize(); } - ut::NandFileStream::Seek(mOffset, SEEK_BEG); + ut::NandFileStream::Seek(mOffset, SEEK_ORIGIN_BEG); } } @@ -215,7 +215,7 @@ NandSoundArchive::NandFileStream::NandFileStream(const char* pPath, u32 offset, mSize = ut::NandFileStream::GetSize(); } - ut::NandFileStream::Seek(mOffset, SEEK_BEG); + ut::NandFileStream::Seek(mOffset, SEEK_ORIGIN_BEG); } } @@ -235,17 +235,17 @@ s32 NandSoundArchive::NandFileStream::Read(void* pDst, u32 size) { void NandSoundArchive::NandFileStream::Seek(s32 offset, u32 origin) { switch (origin) { - case SEEK_BEG: { + case SEEK_ORIGIN_BEG: { offset += mOffset; break; } - case SEEK_CUR: { + case SEEK_ORIGIN_CUR: { offset += ut::NandFileStream::Tell(); break; } - case SEEK_END: { + case SEEK_ORIGIN_END: { offset = mOffset + mSize - offset; break; } @@ -261,7 +261,7 @@ void NandSoundArchive::NandFileStream::Seek(s32 offset, u32 origin) { offset = mOffset + mSize; } - ut::NandFileStream::Seek(offset, SEEK_BEG); + ut::NandFileStream::Seek(offset, SEEK_ORIGIN_BEG); } } // namespace snd diff --git a/src/nw4r/snd/snd_SeqSound.cpp b/src/nw4r/snd/snd_SeqSound.cpp index 67374aa8..03a66889 100644 --- a/src/nw4r/snd/snd_SeqSound.cpp +++ b/src/nw4r/snd/snd_SeqSound.cpp @@ -161,7 +161,7 @@ SeqSound::SeqLoadTask::SeqLoadTask() : fileStream(NULL), buffer(NULL), callback(NULL), callbackData(NULL) {} void SeqSound::SeqLoadTask::Execute() { - fileStream->Seek(0, ut::FileStream::SEEK_BEG); + fileStream->Seek(0, ut::FileStream::SEEK_ORIGIN_BEG); s32 bytesRead = fileStream->Read(buffer, bufferSize); fileStream = NULL; diff --git a/src/nw4r/snd/snd_StrmFile.cpp b/src/nw4r/snd/snd_StrmFile.cpp index 1ce98821..6d417ad3 100644 --- a/src/nw4r/snd/snd_StrmFile.cpp +++ b/src/nw4r/snd/snd_StrmFile.cpp @@ -95,7 +95,7 @@ bool StrmFileLoader::LoadFileHeader(void* pStrmBin, u32 size) { u8 headerArea[HEADER_ALIGNED_SIZE + 32]; u32 bytesRead; - mStream.Seek(0, ut::FileStream::SEEK_BEG); + mStream.Seek(0, ut::FileStream::SEEK_ORIGIN_BEG); bytesRead = mStream.Read(ut::RoundUp(headerArea, 32), HEADER_ALIGNED_SIZE); if (bytesRead != HEADER_ALIGNED_SIZE) { return false; @@ -115,7 +115,7 @@ bool StrmFileLoader::LoadFileHeader(void* pStrmBin, u32 size) { u32 loadSize = pHeader->headBlockOffset + pHeader->headBlockSize; - mStream.Seek(0, ut::FileStream::SEEK_BEG); + mStream.Seek(0, ut::FileStream::SEEK_ORIGIN_BEG); bytesRead = mStream.Read(pStrmBin, loadSize); if (bytesRead != loadSize) { return false; @@ -135,7 +135,7 @@ bool StrmFileLoader::ReadAdpcBlockData(u16* pYN1, u16* pYN2, int block, block * channels * (2 * sizeof(u16)) + sizeof(ut::BinaryBlockHeader); - mStream.Seek(offset, ut::FileStream::SEEK_BEG); + mStream.Seek(offset, ut::FileStream::SEEK_ORIGIN_BEG); u16 buffer[StrmPlayer::StrmHeader::STRM_CHANNEL_MAX * 2] ALIGN(32); // @bug Read size not validated diff --git a/src/nw4r/snd/snd_StrmPlayer.cpp b/src/nw4r/snd/snd_StrmPlayer.cpp index 11660800..577d993d 100644 --- a/src/nw4r/snd/snd_StrmPlayer.cpp +++ b/src/nw4r/snd/snd_StrmPlayer.cpp @@ -301,7 +301,7 @@ bool StrmPlayer::LoadStreamData(ut::FileStream* pFileStream, int offset, ut::detail::AutoLock lock(sLoadBufferMutex); DCInvalidateRange(sLoadBuffer, size); - pFileStream->Seek(offset, ut::FileStream::SEEK_BEG); + pFileStream->Seek(offset, ut::FileStream::SEEK_ORIGIN_BEG); s32 bytesRead = pFileStream->Read(sLoadBuffer, size); if (bytesRead != size) { diff --git a/src/nw4r/ut/ut_DvdFileStream.cpp b/src/nw4r/ut/ut_DvdFileStream.cpp index 8df244a6..3d82a4ba 100644 --- a/src/nw4r/ut/ut_DvdFileStream.cpp +++ b/src/nw4r/ut/ut_DvdFileStream.cpp @@ -68,7 +68,7 @@ bool DvdFileStream::Open(s32 entrynum) { if (DVDFastOpen(entrynum, &mFileInfo.dvdInfo)) { mFilePosition.SetFileSize(mFileInfo.dvdInfo.size); - mFilePosition.Seek(0, SEEK_BEG); + mFilePosition.Seek(0, SEEK_ORIGIN_BEG); mCloseOnDestroyFlg = true; mCloseEnableFlg = true; @@ -87,7 +87,7 @@ bool DvdFileStream::Open(const DVDFileInfo* pInfo, bool close) { mFileInfo.dvdInfo = *pInfo; mFilePosition.SetFileSize(mFileInfo.dvdInfo.size); - mFilePosition.Seek(0, SEEK_BEG); + mFilePosition.Seek(0, SEEK_ORIGIN_BEG); mCloseOnDestroyFlg = false; mCloseEnableFlg = close; diff --git a/src/nw4r/ut/ut_FileStream.cpp b/src/nw4r/ut/ut_FileStream.cpp index 382c3063..3736314a 100644 --- a/src/nw4r/ut/ut_FileStream.cpp +++ b/src/nw4r/ut/ut_FileStream.cpp @@ -37,17 +37,17 @@ u32 FileStream::FilePosition::Append(s32 offset) { void FileStream::FilePosition::Seek(s32 offset, u32 origin) { switch (origin) { - case SEEK_BEG: { + case SEEK_ORIGIN_BEG: { mPosition = 0; break; } - case SEEK_END: { + case SEEK_ORIGIN_END: { mPosition = mFileSize; break; } - case SEEK_CUR: + case SEEK_ORIGIN_CUR: default: { break; } diff --git a/src/nw4r/ut/ut_NandFileStream.cpp b/src/nw4r/ut/ut_NandFileStream.cpp index 7554933d..cc5b2635 100644 --- a/src/nw4r/ut/ut_NandFileStream.cpp +++ b/src/nw4r/ut/ut_NandFileStream.cpp @@ -73,7 +73,7 @@ bool NandFileStream::Open(const char* pPath, u32 mode) { mFilePosition.SetFileSize(fileSize); } - mFilePosition.Seek(0, SEEK_BEG); + mFilePosition.Seek(0, SEEK_ORIGIN_BEG); mCloseOnDestroyFlg = true; mCloseEnableFlg = true; @@ -103,7 +103,7 @@ bool NandFileStream::Open(const NANDFileInfo* pInfo, u32 mode, } mFilePosition.SetFileSize(fileSize); - mFilePosition.Seek(0, SEEK_BEG); + mFilePosition.Seek(0, SEEK_ORIGIN_BEG); mCloseOnDestroyFlg = false; mCloseEnableFlg = enableClose;