cleanup: cleanup2-x7 (gotos, comma conditions, placeholders) #1362
@@ -4,7 +4,7 @@
|
||||
#include <nw4r/snd.h>
|
||||
|
||||
#include <revolution/os.h>
|
||||
#pragma sym on
|
||||
|
||||
namespace EGG {
|
||||
ArcPlayer::ArcPlayer(nw4r::snd::SoundHeap* pHeap) : mpSoundHeap(pHeap) {
|
||||
mStorage = SARC_STORAGE_NONE;
|
||||
|
||||
@@ -74,8 +74,7 @@ namespace EGG {
|
||||
return MEMAllocFromFrmHeapEx(mHeapHandle, size, align);
|
||||
}
|
||||
|
||||
void FrmHeap::free(void* ptr) {
|
||||
#pragma unused(ptr)
|
||||
void FrmHeap::free(void*) {
|
||||
}
|
||||
|
||||
u32 FrmHeap::resizeForMBlock(void* ptr, u32 size) {
|
||||
|
||||
@@ -36,8 +36,6 @@ namespace EGG {
|
||||
}
|
||||
|
||||
void* Heap::alloc(u32 size, int align, Heap* heap) {
|
||||
void* ptr = NULL;
|
||||
|
||||
if (sAllocatableHeap != NULL) {
|
||||
if (sCurrentHeap != NULL && heap == NULL) {
|
||||
heap = sCurrentHeap;
|
||||
@@ -53,13 +51,7 @@ namespace EGG {
|
||||
}
|
||||
|
||||
if (sCurrentHeap != NULL) {
|
||||
ptr = sCurrentHeap->alloc(size, align);
|
||||
|
||||
if (ptr == NULL) {
|
||||
// stripped out EGG_PRINT
|
||||
}
|
||||
|
||||
return ptr;
|
||||
return sCurrentHeap->alloc(size, align);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -170,7 +162,7 @@ void* operator new[](size_t size, EGG::Heap* heap, int align) {
|
||||
|
||||
void operator delete(void* ptr) {
|
||||
EGG::Heap::free(ptr, NULL);
|
||||
// don't inline. (NO_INLINE did not want to work)
|
||||
// MWCC needs these no-op statements to keep operator delete out of Heap's destructor.
|
||||
(void)0;
|
||||
(void)0;
|
||||
(void)0;
|
||||
|
||||
@@ -18,29 +18,29 @@ namespace nw4r {
|
||||
inline u32 CalcOffsetSheetData(u16 countNames) {
|
||||
return ROUNDUP(CalcOffsetNameOffsetData() + countNames * sizeof(u16), 4);
|
||||
}
|
||||
inline u32 CalcOffset0AData(u16 countNames, u16 countSheets) {
|
||||
inline u32 CalcOffsetCWDHData(u16 countNames, u16 countSheets) {
|
||||
return ROUNDUP(CalcOffsetSheetData(countNames) + countSheets * sizeof(u32), 4);
|
||||
}
|
||||
inline u32 CalcOffset0CData(u16 countNames, u16 countSheets, u16 count0A) {
|
||||
return ROUNDUP(CalcOffset0AData(countNames, countSheets) + count0A * sizeof(u32), 4);
|
||||
inline u32 CalcOffsetCMAPData(u16 countNames, u16 countSheets, u16 countCWDH) {
|
||||
return ROUNDUP(CalcOffsetCWDHData(countNames, countSheets) + countCWDH * sizeof(u32), 4);
|
||||
}
|
||||
|
||||
inline u32 CalcSizeFlagSet(u32 entries) {
|
||||
return ((s32)entries + 0x1f) / 32 * 4;
|
||||
}
|
||||
|
||||
inline u32 CalcOffsetSheetFlags(u16 countNames, u16 countSheets, u16 count0A, u16 count0C) {
|
||||
return ROUNDUP(CalcOffset0CData(countNames, countSheets, count0A) + count0C * sizeof(u32), 4);
|
||||
inline u32 CalcOffsetSheetFlags(u16 countNames, u16 countSheets, u16 countCWDH, u16 countCMAP) {
|
||||
return ROUNDUP(CalcOffsetCMAPData(countNames, countSheets, countCWDH) + countCMAP * sizeof(u32), 4);
|
||||
}
|
||||
inline u32 CalcOffset0AFlags(u16 countNames, u16 countSheets, u16 count0A, u16 count0C) {
|
||||
u32 offsetSheetFlags = CalcOffsetSheetFlags(countNames, countSheets, count0A, count0C);
|
||||
inline u32 CalcOffsetCWDHFlags(u16 countNames, u16 countSheets, u16 countCWDH, u16 countCMAP) {
|
||||
u32 offsetSheetFlags = CalcOffsetSheetFlags(countNames, countSheets, countCWDH, countCMAP);
|
||||
u32 stepSheet = CalcSizeFlagSet(countSheets);
|
||||
return ROUNDUP(offsetSheetFlags + stepSheet * countNames, 4);
|
||||
}
|
||||
inline u32 CalcOffset0CFlags(u16 countNames, u16 countSheets, u16 count0A, u16 count0C) {
|
||||
u32 offset0AFlags = CalcOffset0AFlags(countNames, countSheets, count0A, count0C);
|
||||
u32 step0A = CalcSizeFlagSet(count0A);
|
||||
return ROUNDUP(offset0AFlags + step0A * countNames, 4);
|
||||
inline u32 CalcOffsetCMAPFlags(u16 countNames, u16 countSheets, u16 countCWDH, u16 countCMAP) {
|
||||
u32 offsetCWDHFlags = CalcOffsetCWDHFlags(countNames, countSheets, countCWDH, countCMAP);
|
||||
u32 stepCWDH = CalcSizeFlagSet(countCWDH);
|
||||
return ROUNDUP(offsetCWDHFlags + stepCWDH * countNames, 4);
|
||||
}
|
||||
|
||||
inline u32 CalcSizeSheetOffsets(u32 countSheets) {
|
||||
|
||||
@@ -92,8 +92,8 @@ namespace nw4r {
|
||||
u16 sheetGlyphCount; // 0x04
|
||||
u16 nameCount; // 0x06
|
||||
u16 sheetCount; // 0x08
|
||||
u16 smthCount_0x0a; // 0x0A
|
||||
u16 smthCount_0x0c; // 0x0C
|
||||
u16 cwdhCount; // 0x0A
|
||||
u16 cmapCount; // 0x0C
|
||||
u16 nameOffsets[0];
|
||||
} GlyphGroups;
|
||||
|
||||
|
||||
@@ -207,56 +207,50 @@ namespace nw4r {
|
||||
}
|
||||
|
||||
static void DoDrawConsole_(ConsoleHandle console, ut::TextWriter* writer) {
|
||||
{
|
||||
s32 viewOffset;
|
||||
u16 line;
|
||||
u16 printLines;
|
||||
s32 viewOffset;
|
||||
u16 line;
|
||||
u16 printLines;
|
||||
|
||||
viewOffset = console->viewTopLine - console->ringTopLineCnt;
|
||||
printLines = 0;
|
||||
viewOffset = console->viewTopLine - console->ringTopLineCnt;
|
||||
printLines = 0;
|
||||
|
||||
if (viewOffset < 0) {
|
||||
viewOffset = 0;
|
||||
} else if (viewOffset > GetActiveLines_(console)) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
line = static_cast<u16>(console->ringTop + viewOffset);
|
||||
|
||||
if (line >= console->height) {
|
||||
line -= console->height;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
if (line == console->printTop && !console->printTopUsed) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
DoDrawString_(console, printLines, GetTextPtr_(console, line, 0), writer);
|
||||
printLines++;
|
||||
|
||||
if (line == console->printTop) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
line++;
|
||||
|
||||
if (line == console->height) {
|
||||
if (console->attr & (1 << 1)) {
|
||||
goto end;
|
||||
}
|
||||
line = 0;
|
||||
}
|
||||
|
||||
if (printLines >= console->viewLines) {
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
if (viewOffset < 0) {
|
||||
viewOffset = 0;
|
||||
} else if (viewOffset > GetActiveLines_(console)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// maybe not, with this end label?
|
||||
end:
|
||||
return;
|
||||
line = static_cast<u16>(console->ringTop + viewOffset);
|
||||
|
||||
if (line >= console->height) {
|
||||
line -= console->height;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
if (line == console->printTop && !console->printTopUsed) {
|
||||
break;
|
||||
}
|
||||
|
||||
DoDrawString_(console, printLines, GetTextPtr_(console, line, 0), writer);
|
||||
printLines++;
|
||||
|
||||
if (line == console->printTop) {
|
||||
break;
|
||||
}
|
||||
|
||||
line++;
|
||||
|
||||
if (line == console->height) {
|
||||
if (console->attr & (1 << 1)) {
|
||||
break;
|
||||
}
|
||||
line = 0;
|
||||
}
|
||||
|
||||
if (printLines >= console->viewLines) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Console_DrawDirect(ConsoleHandle console) {
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace {
|
||||
} else if (operation == ut::OPERATION_CHAR_SPACE) {
|
||||
bCharSpace = true;
|
||||
} else if (operation == ut::OPERATION_NEXT_LINE) {
|
||||
goto end_draw;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (bCharSpace) {
|
||||
@@ -128,12 +128,11 @@ namespace {
|
||||
|
||||
if (pRect->GetWidth() > maxWidth) {
|
||||
*pbOver = true;
|
||||
goto end_draw;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end_draw:
|
||||
if (*pbOver && prStrPos) {
|
||||
*pRect = prMaxRect;
|
||||
return prStrPos - str;
|
||||
@@ -223,7 +222,7 @@ namespace nw4r {
|
||||
} else if (void* fontRes = resBlockSet.pResAccessor->GetResource('font', fontName, NULL)) {
|
||||
if (void* pMemFont = Layout::AllocMemory(sizeof(ut::ResFont))) {
|
||||
ut::ResFont* pResFont = new (pMemFont) ut::ResFont();
|
||||
bool bSuccess = pResFont->SetResource(fontRes);
|
||||
pResFont->SetResource(fontRes);
|
||||
|
||||
mpFont = pResFont;
|
||||
mTextBoxFlag.allocFont = true;
|
||||
|
||||
@@ -18,14 +18,15 @@ extern "C" const u8 scLytFatalColorA;
|
||||
extern "C" char scLytFatalMsg[];
|
||||
|
||||
#undef NW4R_ASSERT
|
||||
#define NW4R_GLOBAL_ASSERT(x) \
|
||||
{ \
|
||||
if (!(x)) { \
|
||||
GXColor front = {*((volatile const u8*)&::scLytFatalColorR), *((volatile const u8*)&::scLytFatalColorG), \
|
||||
*((volatile const u8*)&::scLytFatalColorB), *((volatile const u8*)&::scLytFatalColorA)}; \
|
||||
GXColor back = {0, 0, 0, 0}; \
|
||||
OSFatal(front, back, ::scLytFatalMsg); \
|
||||
} \
|
||||
// MWCC needs byte loads from the named color constants instead of folding their values.
|
||||
#define NW4R_GLOBAL_ASSERT(x) \
|
||||
{ \
|
||||
if (!(x)) { \
|
||||
GXColor front = {*((volatile const u8*)&::scLytFatalColorR), *((volatile const u8*)&::scLytFatalColorG), \
|
||||
*((volatile const u8*)&::scLytFatalColorB), *((volatile const u8*)&::scLytFatalColorA)}; \
|
||||
GXColor back = {0, 0, 0, 0}; \
|
||||
OSFatal(front, back, ::scLytFatalMsg); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define NW4R_ASSERT(x) \
|
||||
|
||||
@@ -20,25 +20,24 @@ namespace nw4r {
|
||||
const HeaderedGlyphGroups* pGlgr;
|
||||
const ArchiveFontBinaryLayout* font;
|
||||
|
||||
u16 countName, countSheet, count0A, count0C;
|
||||
u16 countName, countSheet, countCWDH, countCMAP;
|
||||
|
||||
u32 stepSheets, step0A, step0C;
|
||||
u32 stepSheets, stepCWDH, stepCMAP;
|
||||
|
||||
u32 dataSheetsOff, data0AOff, data0COff;
|
||||
const u32* dataSheets;
|
||||
const u32* data0A;
|
||||
const u32* data0C;
|
||||
u32 dataSheetsOff, dataCWDHOff, dataCMAPOff;
|
||||
const u32* dataCWDH;
|
||||
const u32* dataCMAP;
|
||||
|
||||
u32 flagsSheetsOff, flags0AOff, flags0COff;
|
||||
u32 flagsSheetsOff, flagsCWDHOff, flagsCMAPOff;
|
||||
const u32* flagsSheets;
|
||||
const u32* flags0A;
|
||||
const u32* flags0C;
|
||||
const u32* flagsCWDH;
|
||||
const u32* flagsCMAP;
|
||||
|
||||
int i;
|
||||
int entryI;
|
||||
const HeaderedGlyphGroups* offsetPGlgr;
|
||||
const HeaderedGlyphGroups* groupHeaderCursor;
|
||||
const u8* offsetFlags;
|
||||
u32 loadedSheetCount, loadedSmth0ASize, loadedSmth0CSize;
|
||||
u32 loadedSheetCount, loadedCWDHSize, loadedCMAPSize;
|
||||
u32 flagWord;
|
||||
const char* groupName;
|
||||
const u32* offsetData;
|
||||
@@ -49,11 +48,10 @@ namespace nw4r {
|
||||
u32 neededCharacterSize;
|
||||
u32 baseSize;
|
||||
|
||||
u32 count0CWork;
|
||||
// MWCC needs this widened CMAP count for the original temporary allocation.
|
||||
u32 cmapCountForLayout;
|
||||
|
||||
u32& neededCharacterSizeRef = neededCharacterSize;
|
||||
|
||||
u32 loadedSizeRef;
|
||||
u32 loadedCharacterSize;
|
||||
|
||||
u32 groupOffset;
|
||||
|
||||
@@ -61,46 +59,45 @@ namespace nw4r {
|
||||
return 0;
|
||||
}
|
||||
|
||||
font = (ArchiveFontBinaryLayout*)fontData;
|
||||
font = static_cast<const ArchiveFontBinaryLayout*>(fontData);
|
||||
pGlgr = &font->glgr;
|
||||
|
||||
countName = pGlgr->inner.nameCount;
|
||||
countSheet = pGlgr->inner.sheetCount;
|
||||
count0A = pGlgr->inner.smthCount_0x0a;
|
||||
count0C = pGlgr->inner.smthCount_0x0c;
|
||||
count0CWork = count0C;
|
||||
countCWDH = pGlgr->inner.cwdhCount;
|
||||
countCMAP = pGlgr->inner.cmapCount;
|
||||
cmapCountForLayout = countCMAP;
|
||||
|
||||
stepSheets = ((s32)countSheet + 0x1f) / 32 * 4;
|
||||
step0A = ((s32)count0A + 0x1f) / 32 * 4;
|
||||
step0C = ((s32)count0CWork + 0x1f) / 32 * 4;
|
||||
stepCWDH = ((s32)countCWDH + 0x1f) / 32 * 4;
|
||||
stepCMAP = ((s32)cmapCountForLayout + 0x1f) / 32 * 4;
|
||||
|
||||
dataSheetsOff = ROUNDUP(offsetof(ArchiveFontBinaryLayout, glgr.inner.nameOffsets) + countName * sizeof(u16), 4);
|
||||
data0AOff = ROUNDUP(dataSheetsOff + countSheet * sizeof(u32), 4);
|
||||
data0COff = ROUNDUP(data0AOff + count0A * sizeof(u32), 4);
|
||||
dataSheets = (const u32*)(dataSheetsOff + (u32)fontData);
|
||||
data0A = (const u32*)(data0AOff + (u32)fontData);
|
||||
data0C = (const u32*)(data0COff + (u32)fontData);
|
||||
dataCWDHOff = ROUNDUP(dataSheetsOff + countSheet * sizeof(u32), 4);
|
||||
dataCMAPOff = ROUNDUP(dataCWDHOff + countCWDH * sizeof(u32), 4);
|
||||
dataCWDH = (const u32*)(dataCWDHOff + (u32)fontData);
|
||||
dataCMAP = (const u32*)(dataCMAPOff + (u32)fontData);
|
||||
|
||||
flagsSheetsOff = ROUNDUP(data0COff + count0CWork * sizeof(u32), 4);
|
||||
flags0AOff = ROUNDUP(flagsSheetsOff + stepSheets * countName, 4);
|
||||
flags0COff = ROUNDUP(flags0AOff + step0A * countName, 4);
|
||||
flagsSheetsOff = ROUNDUP(dataCMAPOff + cmapCountForLayout * sizeof(u32), 4);
|
||||
flagsCWDHOff = ROUNDUP(flagsSheetsOff + stepSheets * countName, 4);
|
||||
flagsCMAPOff = ROUNDUP(flagsCWDHOff + stepCWDH * countName, 4);
|
||||
|
||||
flagsSheets = (const u32*)(flagsSheetsOff + (u32)fontData);
|
||||
flags0A = (const u32*)(flags0AOff + (u32)fontData);
|
||||
flags0C = (const u32*)(flags0COff + (u32)fontData);
|
||||
flagsCWDH = (const u32*)(flagsCWDHOff + (u32)fontData);
|
||||
flagsCMAP = (const u32*)(flagsCMAPOff + (u32)fontData);
|
||||
|
||||
loadedSheetCount = 0;
|
||||
loadedSmth0ASize = 0;
|
||||
loadedSmth0CSize = 0;
|
||||
loadedCWDHSize = 0;
|
||||
loadedCMAPSize = 0;
|
||||
|
||||
// Get the NUMBER of sheets that should be loaded
|
||||
for (i = 0, entryI = 0; entryI < pGlgr->inner.sheetCount; entryI += 0x20, i++) {
|
||||
offsetFlags = (const u8*)flagsSheets + i * sizeof(u32);
|
||||
|
||||
flagWord = 0;
|
||||
for (j = 0, offsetPGlgr = pGlgr; j < pGlgr->inner.nameCount;
|
||||
offsetPGlgr = (const HeaderedGlyphGroups*)((const u8*)offsetPGlgr + 2), j++) {
|
||||
groupName = (const char*)((u32)offsetPGlgr->inner.nameOffsets[0] + (u32)fontData);
|
||||
// MWCC needs the header as the induction base for the name-offset loads.
|
||||
for (j = 0, groupHeaderCursor = pGlgr; j < pGlgr->inner.nameCount;
|
||||
groupHeaderCursor = (const HeaderedGlyphGroups*)((const u8*)groupHeaderCursor + 2), j++) {
|
||||
groupName = (const char*)((u32)groupHeaderCursor->inner.nameOffsets[0] + (u32)fontData);
|
||||
if (*includedGroups == '\0' || detail::ArchiveFontBase::IncludeName(includedGroups, groupName)) {
|
||||
flagWord |= *(const u32*)(offsetFlags + ROUNDDOWN(j * stepSheets, 4));
|
||||
}
|
||||
@@ -108,60 +105,52 @@ namespace nw4r {
|
||||
|
||||
loadedSheetCount += math::CntBit1(flagWord);
|
||||
}
|
||||
// getLoadedSheetCount(pGlgr, flagsSheets, stepSheets, fontData, includedGroups, &loadedSheetCount);
|
||||
|
||||
// Get the SIZE of unk_0x0a that should be loaded
|
||||
for (i = 0; i * 32 < pGlgr->inner.smthCount_0x0a; i++) {
|
||||
offsetFlags = (const u8*)flags0A + i * sizeof(u32);
|
||||
for (i = 0; i * 32 < pGlgr->inner.cwdhCount; i++) {
|
||||
offsetFlags = (const u8*)flagsCWDH + i * sizeof(u32);
|
||||
|
||||
flagWord = 0;
|
||||
for (j = 0; j < pGlgr->inner.nameCount; j++) {
|
||||
groupOffset = pGlgr->inner.nameOffsets[j];
|
||||
groupName = (const char*)(groupOffset + (u32)fontData);
|
||||
if (*includedGroups == '\0' || detail::ArchiveFontBase::IncludeName(includedGroups, groupName)) {
|
||||
flagWord |= *(const u32*)(offsetFlags + ROUNDDOWN(j * step0A, 4));
|
||||
flagWord |= *(const u32*)(offsetFlags + ROUNDDOWN(j * stepCWDH, 4));
|
||||
}
|
||||
}
|
||||
|
||||
offsetData = data0A + i * 32;
|
||||
offsetData = dataCWDH + i * 32;
|
||||
for (j = 0; j < 32; j++) {
|
||||
if ((flagWord << j) & 0x80000000U) {
|
||||
loadedSmth0ASize += offsetData[j] - sizeof(BinaryBlockHeader);
|
||||
loadedCWDHSize += offsetData[j] - sizeof(BinaryBlockHeader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the SIZE of unk_0x0C that should be loaded
|
||||
for (i = 0; i * 32 < pGlgr->inner.smthCount_0x0c; i++) {
|
||||
offsetFlags = (const u8*)flags0C + i * sizeof(u32);
|
||||
for (i = 0; i * 32 < pGlgr->inner.cmapCount; i++) {
|
||||
offsetFlags = (const u8*)flagsCMAP + i * sizeof(u32);
|
||||
|
||||
flagWord = 0;
|
||||
for (j = 0; j < pGlgr->inner.nameCount; j++) {
|
||||
groupOffset = pGlgr->inner.nameOffsets[j];
|
||||
groupName = (const char*)(groupOffset + (u32)fontData);
|
||||
if (*includedGroups == '\0' || detail::ArchiveFontBase::IncludeName(includedGroups, groupName)) {
|
||||
flagWord |= *(const u32*)(offsetFlags + ROUNDDOWN(j * step0C, 4));
|
||||
flagWord |= *(const u32*)(offsetFlags + ROUNDDOWN(j * stepCMAP, 4));
|
||||
}
|
||||
}
|
||||
|
||||
offsetData = data0C + i * 32;
|
||||
offsetData = dataCMAP + i * 32;
|
||||
for (j = 0; j < 32; j++) {
|
||||
if ((flagWord << j) & 0x80000000U) {
|
||||
loadedSmth0CSize += offsetData[j] - sizeof(BinaryBlockHeader);
|
||||
loadedCMAPSize += offsetData[j] - sizeof(BinaryBlockHeader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate the final buffer size based on the three previously
|
||||
// accessed components
|
||||
sheetOffsetsSize = ROUNDUP(pGlgr->inner.sheetCount * 2, 4);
|
||||
loadedSheetsSize = ROUNDUP(loadedSheetCount * pGlgr->inner.uncompSheetSize, 4);
|
||||
|
||||
loadedSizeRef = loadedSmth0ASize + loadedSmth0CSize;
|
||||
neededCharacterSizeRef = sizeof(CXUncompContextHuffman);
|
||||
if (loadedSizeRef >= sizeof(CXUncompContextHuffman)) {
|
||||
neededCharacterSize = loadedSizeRef;
|
||||
}
|
||||
loadedCharacterSize = loadedCWDHSize + loadedCMAPSize;
|
||||
neededCharacterSize = ut::Max<u32>(loadedCharacterSize, sizeof(CXUncompContextHuffman));
|
||||
|
||||
baseSize = OSRoundUp32B(sizeof(FontInformation) + sizeof(FontTextureGlyph) + sheetOffsetsSize);
|
||||
return (baseSize + loadedSheetsSize) + neededCharacterSize;
|
||||
|
||||
@@ -74,16 +74,6 @@ namespace nw4r {
|
||||
}
|
||||
}
|
||||
|
||||
// u32 ArchiveFontBase::ConstructContext::updateTextureBlockPtr() {
|
||||
// u32 imgDataOffset;
|
||||
// imgDataOffset = (u32)pFontInfo->pGlyph->sheetImage;
|
||||
|
||||
// pWorkCurr = (u8*)ROUNDUP((u32)pWorkCurr, 0x20);
|
||||
// pFontInfo->pGlyph->sheetImage = pWorkCurr;
|
||||
|
||||
// return imgDataOffset;
|
||||
// }
|
||||
|
||||
ArchiveFontBase::ArchiveFontBase() : pSheetOffsets(NULL) {
|
||||
}
|
||||
|
||||
@@ -126,24 +116,6 @@ namespace nw4r {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check that there is nothing but spaces between the substr
|
||||
// and the preceeding comma
|
||||
// - Fails:
|
||||
// - groupList = "foo, BAD bar, baz"
|
||||
// - substr ^
|
||||
// - Succeeds:
|
||||
// - groupList = "foo, bar, baz"
|
||||
// - substr ^
|
||||
// - Succeeds:
|
||||
// - groupList = "foo,bar,baz"
|
||||
// - substr ^
|
||||
// - Succeeds:
|
||||
// - groupList = "foo,bar,baz"
|
||||
// - substr ^
|
||||
// - Fails (I think this is a bug):
|
||||
// - groupList = " foo, bar, baz"
|
||||
// - substr ^
|
||||
// @bug Should allow for leading spaces in groupList (maybe?)
|
||||
if (substr != groupList) {
|
||||
const char* backsearchStr = substr - 1;
|
||||
while (backsearchStr > groupList && *backsearchStr == ' ') {
|
||||
@@ -154,11 +126,6 @@ namespace nw4r {
|
||||
}
|
||||
}
|
||||
|
||||
// Get the length of the section up until the next comma or
|
||||
// the end
|
||||
// - substr = "foo bar, baz" -> sectionLen = 7
|
||||
// - substr = "foo , baz" -> sectionLen = 11
|
||||
// - substr = "foo" -> sectionLen = 3
|
||||
const char* nextComma = strchr(substr, ',');
|
||||
u32 sectionLen;
|
||||
if (nextComma != NULL) {
|
||||
@@ -167,17 +134,6 @@ namespace nw4r {
|
||||
sectionLen = strlen(substr);
|
||||
}
|
||||
|
||||
// Check to make sure there is nothing except spaces between
|
||||
// the end of the group name and the next comma:
|
||||
// - Fails:
|
||||
// - substr = "foo bar, baz"
|
||||
// - group = "foo"
|
||||
// - Succeeds:
|
||||
// - substr = "foo , baz"
|
||||
// - group = "foo"
|
||||
// - Succeeds:
|
||||
// - substr = "foo, baz"
|
||||
// - group = "foo"
|
||||
const char* sectionEnd = substr + groupLen;
|
||||
while (sectionEnd < substr + sectionLen && (*sectionEnd == ' ')) {
|
||||
sectionEnd++;
|
||||
@@ -313,11 +269,6 @@ namespace nw4r {
|
||||
ctx->pSheetOffsets = (u16*)sheetOffsets;
|
||||
}
|
||||
|
||||
// inline u32 getOffsetSize(void* fontData, u32 remWorkSpace, u16 countSheet, u16** sheetOffsetsScratch) {
|
||||
// u32 sheetOffsetsSize = ROUNDUP(countSheet * sizeof(u16), 4);
|
||||
// *sheetOffsetsScratch = (u16*)ROUNDDOWN((u32)((u8*)fontData + remWorkSpace) - sheetOffsetsSize, 2);
|
||||
// return sheetOffsetsSize;
|
||||
// }
|
||||
class FontGlyphGroupsAcs {
|
||||
public:
|
||||
explicit FontGlyphGroupsAcs(const ArchiveFontBinaryLayout* font)
|
||||
@@ -393,8 +344,8 @@ namespace nw4r {
|
||||
dataBlockCount = font->hdr.dataBlocks;
|
||||
countSheet = gg.GetNumSheet();
|
||||
const u32 stepSheetFlags = detail::CalcSizeFlagSet(countSheet);
|
||||
flagsSheetsOff = detail::CalcOffsetSheetFlags(gg.GetGroups().nameCount, countSheet, gg.GetGroups().smthCount_0x0a,
|
||||
gg.GetGroups().smthCount_0x0c);
|
||||
flagsSheetsOff = detail::CalcOffsetSheetFlags(gg.GetGroups().nameCount, countSheet, gg.GetGroups().cwdhCount,
|
||||
gg.GetGroups().cmapCount);
|
||||
flagsSheets = (const u32*)((flagsSheetsOff & ~3) + (u32)font);
|
||||
gg.SetSheetFlags(stepSheetFlags, flagsSheets);
|
||||
|
||||
|
||||
101
tools/decomp-assist/cleanup2-x7.attempts.md
Normal file
101
tools/decomp-assist/cleanup2-x7.attempts.md
Normal file
@@ -0,0 +1,101 @@
|
||||
# cleanup2-x7 attempts
|
||||
|
||||
Worktree `/mnt/drive2/projects/wii-ipl-workers/data-d5`, branch `agent/w1009/cleanup2-x7`, baseline `c3dd1c08c04a38975b63dded77a7aef6fce385f3`.
|
||||
|
||||
Read cleanup-common.md fully, including wave-2 guidance. Applied unslop and writing-for-agents to this handoff. Initial full 43U build passed; fresh report and completion checker returned DECOMPLETE_OK. DOL SHA1 `26116613f624061ba99c8d1a299aaa6efa85670d`. All 1028 units and 12563 functions match and link completely.
|
||||
|
||||
Scope is all C/C++ and headers in libs/NW4R and libs/EGG. Hand-written assembly stays untouched. Audit and trials proceed largest-first. Each trial compares all allocated section sizes and bytes and normalized relocations with fresh baseline objects. Any changed byte rejects the trial.
|
||||
|
||||
Prior cleanup-c4 tested AxManager pragma removal, pointer iteration, voice local, and loop scope. Those failed because default IRO hoists the voice address and removes one instruction. Do not repeat those trials without a different source hypothesis. Prior fz2 confirms Window assertion colors have distinct constant storage and GetFrameMaterial uses its named quartet.
|
||||
|
||||
## Trials
|
||||
|
||||
- window-direct-constant-colors: REJECT, [{"unit": "libs/NW4R/src/lyt/lyt_window", "sections": [".rela.ctors", ".rela.text", ".text"], "functions": ["GetFrameMaterial__Q34nw4r3lyt6WindowCFUl: 31 diffs, 38/41 instructions"]}]. Restored.
|
||||
- window-declaration-volatile-colors: REJECT, [{"unit": "libs/NW4R/src/lyt/lyt_window", "sections": [".rela.ctors", ".rela.text", ".sbss2", ".sdata2", ".text"], "functions": ["GetFrameMaterial__Q34nw4r3lyt6WindowCFUl: 31 diffs, 39/41 instructions"]}]. Restored.
|
||||
- archivefontbase-remove-commented-implementations: KEEP, all allocated sections and normalized relocations identical.
|
||||
- window-format-and-document-required-byte-loads: KEEP, all allocated sections and normalized relocations identical.
|
||||
- textbox-loop-breaks: KEEP, all allocated sections and normalized relocations identical.
|
||||
- axmanager-default-iro-positive-init-guard: REJECT, [{"unit": "libs/NW4R/src/snd/snd_AxManager", "sections": [".rela.text", ".text"], "functions": ["Init__Q44nw4r3snd6detail9AxManagerFv: 52 diffs, 62/63 instructions"]}]. Restored.
|
||||
- axmanager-default-iro-do-while-init: REJECT, [{"unit": "libs/NW4R/src/snd/snd_AxManager", "sections": [".rela.text", ".text"], "functions": ["Init__Q44nw4r3snd6detail9AxManagerFv: 52 diffs, 62/63 instructions"]}]. Restored.
|
||||
- archivefont-remove-character-size-reference: REJECT, [{"unit": "libs/NW4R/src/ut/ut_ArchiveFont", "sections": [".text"], "functions": ["GetRequireBufferSize__Q34nw4r2ut11ArchiveFontFPCvPCc: 7 diffs, 256/256 instructions"]}]. Restored.
|
||||
- archivefont-stream-reader-direct-member: REJECT, [{"unit": "libs/NW4R/src/ut/ut_ArchiveFont", "sections": [".text"], "functions": ["StreamingConstruct__Q34nw4r2ut11ArchiveFontFPQ54nw4r2ut6detail15ArchiveFontBase16ConstructContextPCvUl: 3 diffs, 142/142 instructions"]}]. Restored.
|
||||
- archivefont-remove-redundant-map-count-copy: REJECT, [{"unit": "libs/NW4R/src/ut/ut_ArchiveFont", "sections": [".text"], "functions": ["GetRequireBufferSize__Q34nw4r2ut11ArchiveFontFPCvPCc: 6 diffs, 256/256 instructions"]}]. Restored.
|
||||
- archivefont-typed-group-name-cursor: REJECT, [{"unit": "libs/NW4R/src/ut/ut_ArchiveFont", "sections": [".text"], "functions": ["GetRequireBufferSize__Q34nw4r2ut11ArchiveFontFPCvPCc: 3 diffs, 256/256 instructions"]}]. Restored.
|
||||
- archivefont-block-buffer-max: KEEP, all allocated sections and normalized relocations identical.
|
||||
- console-structured-draw-exits: KEEP, all allocated sections and normalized relocations identical.
|
||||
- archivefont-max-with-direct-map-count: REJECT, [{"unit": "libs/NW4R/src/ut/ut_ArchiveFont", "sections": [".text"], "functions": ["GetRequireBufferSize__Q34nw4r2ut11ArchiveFontFPCvPCc: 6 diffs, 256/256 instructions"]}]. Restored.
|
||||
- archivefont-indexed-group-name: REJECT, [{"unit": "libs/NW4R/src/ut/ut_ArchiveFont", "sections": [".text"], "functions": ["GetRequireBufferSize__Q34nw4r2ut11ArchiveFontFPCvPCc: 44 diffs, 256/256 instructions"]}]. Restored.
|
||||
- console-remove-redundant-function-scope: REJECT, trial script removed the function closing brace. MWCC error 10121 at Console_DrawDirect. Restored, then corrected the rewrite below.
|
||||
- arcplayer-remove-debug-symbol-pragma: KEEP, all allocated sections and normalized relocations identical.
|
||||
- heap-remove-no-op-statements: REJECT, [{"unit": "libs/EGG/src/core/eggHeap", "sections": [".rela.text", ".text"], "functions": ["__dt__Q23EGG4HeapFv: 11 diffs, 36/35 instructions"]}]. Restored.
|
||||
- heap-remove-stripped-empty-allocation-check: KEEP, all allocated sections and normalized relocations identical.
|
||||
- archivefont-name-CWDH-CMAP-fields-and-layout-helpers: KEEP, all allocated sections and normalized relocations identical.
|
||||
- console-remove-redundant-function-scope-corrected: KEEP, all allocated sections and normalized relocations identical.
|
||||
- heap-delete-never-inline-definition: REJECT, [{"unit": "libs/EGG/src/core/eggHeap", "sections": [".rela.text", ".text"], "functions": ["__dt__Q23EGG4HeapFv: 11 diffs, 36/35 instructions"]}]. Restored.
|
||||
- heap-delete-never-inline-declaration: REJECT, [{"unit": "libs/EGG/src/core/eggHeap", "sections": [".rela.text", ".text"], "functions": ["__dt__Q23EGG4HeapFv: 11 diffs, 36/35 instructions"]}]. Restored.
|
||||
- heap-four-no-op-statements: REJECT, [{"unit": "libs/EGG/src/core/eggHeap", "sections": [".rela.text", ".text"], "functions": ["__dt__Q23EGG4HeapFv: 11 diffs, 36/35 instructions"]}]. Restored.
|
||||
- heap-document-required-delete-boundary: KEEP, all allocated sections and normalized relocations identical.
|
||||
- frameheap-remove-unused-parameter-pragma: KEEP, all allocated sections and normalized relocations identical.
|
||||
- archivefontbase-remove-speculative-boundary-comments: KEEP, all allocated sections and normalized relocations identical.
|
||||
- textbox-direct-font-resource-result: KEEP, all allocated sections and normalized relocations identical.
|
||||
- archivefont-typed-flag-word-indexing: REJECT, [{"unit": "libs/NW4R/src/ut/ut_ArchiveFont", "sections": [".rela.text", ".text"], "functions": ["GetRequireBufferSize__Q34nw4r2ut11ArchiveFontFPCvPCc: 207 diffs, 246/256 instructions"]}]. Restored.
|
||||
- archivefont-remove-unused-sheet-data-pointer: KEEP, all allocated sections and normalized relocations identical.
|
||||
- archivefont-const-resource-cast: KEEP, all allocated sections and normalized relocations identical.
|
||||
- heap-alloc-direct-current-heap-return: KEEP, all allocated sections and normalized relocations identical.
|
||||
- fontresources-align-renamed-field-columns: KEEP, all allocated sections and normalized relocations identical.
|
||||
- arcplayer-separate-includes-from-namespace: KEEP, all allocated sections and normalized relocations identical.
|
||||
|
||||
## Retained cleanup
|
||||
|
||||
- `lyt_textBox.cpp`: both loop exits use break, the end_draw label is gone, and the unused SetResource result is gone. The corresponding SS source also exits the line loop with break.
|
||||
- `db_console.cpp`: all five gotos become an early return or loop breaks. Removed the common label, trailing return, redundant scope, and speculative label comment.
|
||||
- `ut_ArchiveFont.cpp`: Max<u32> replaces the size-reference alias and branch; removed the unused sheet-data pointer and assignment. CWDH/CMAP names replace offsets and unknown sizes. Named the header cursor and used a const resource cast. Widened CMAP count, header-base iteration, and byte-addressed flags remain because typed/direct alternatives change instructions. StreamingConstruct retains the same reader-reference idiom as the News Channel source.
|
||||
- `ut_ArchiveFontBase.cpp`: removed two commented-out implementations and speculative IncludeName examples; uses named CWDH/CMAP counts.
|
||||
- `fontResources.h`: GlyphGroups fields at 0x0A and 0x0C are cwdhCount and cmapCount. News Channel FontGlyphGroups names these numCWDH and numCMAP at the same offsets.
|
||||
- `ArchiveFontBase.h`: layout helper names and parameters identify CWDH/CMAP instead of 0A/0C.
|
||||
- `lyt_window.cpp`: formatted the assertion macro and documented the required byte loads. Direct constants change 31 instructions; declaration-level volatile changes section placement too, so the four casts remain.
|
||||
- `eggAudioArcPlayerMgr.cpp`: removed the debug-symbol pragma.
|
||||
- `eggFrmHeap.cpp`: an unnamed free parameter replaces pragma unused.
|
||||
- `eggHeap.cpp`: removed the empty allocation-failure check and redundant result local. Five no-op statements remain in operator delete. Removing even one, or replacing them with never_inline, makes Heap's destructor inline the delete path and changes 11 instructions. Replaced the vague comment with the measured compiler requirement.
|
||||
- `snd_AxManager.cpp`: unchanged. Positive initialization guard and do/while at default IRO still change 52 instructions and remove one instruction. The SS reference retains the same IRO 0 pragma.
|
||||
- `eggHeap.h`: the two placeholder inline method names remain because their callers are in src/system/iplSystem.cpp, outside this assignment. No aliases or outside-scope edits were added.
|
||||
|
||||
## References
|
||||
|
||||
- https://github.com/zeldaret/ss/blob/main/src/nw4r/lyt/lyt_textBox.cpp
|
||||
- https://github.com/zeldaret/ss/blob/main/src/nw4r/snd/snd_AxManager.cpp
|
||||
- https://github.com/hotlandsoftware/wii-news-channel/blob/main/include/nw4r/ut/ut_ArchiveFontBase.h
|
||||
- https://github.com/hotlandsoftware/wii-news-channel/blob/main/src/nw4r/ut/ut_ArchiveFont.cpp
|
||||
- Compared ogws and mkw Heap sources as additional structure references. Their heap implementations differ from this menu version, so no code was copied.
|
||||
|
||||
## Final verification
|
||||
|
||||
Final gate ran once with --quick over all 96 NW4R and 16 EGG units, including header consumers and reverted AxManager trials. Full build passed; 1324/1324 owned functions remain 100% in objdiff and every owned section is 100%. The gate raw-name count is 1323/1324 because snd_Channel uses __arraydtor$3415 where retail uses __arraydtor$3264, already true in the initial baseline. Comparing those corresponding helpers gives identical instructions, so all 1324 owned functions are instruction-exact after that local-name normalization. Pool checks reproduce the initial baseline for every edited source unit. TextBox and Window each have two preexisting duplicate assertion strings in their raw object pools. These bytes are identical to the initial baseline; the linked DOL and reported code/data remain exact. All other edited pools are identical to retail objects. All 112 owned objects have the same allocated sections and normalized relocations as the initial full-build baseline.
|
||||
|
||||
Fresh report and build/43U/ok passed. Completion checker returned DECOMPLETE_OK. All 1028 global unit measures remain unchanged from the initial report. Focused ctxdiff checks for TextBox line measurement, console drawing, ArchiveFont buffer sizing, Window frame material, Heap destruction, and AxManager initialization have equal instruction counts and diffs 0.
|
||||
|
||||
Gate output `/tmp/cleanup2-x7-final-gate.txt`:
|
||||
|
||||
```text
|
||||
full build: ok
|
||||
main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d
|
||||
regressions vs baseline: 0
|
||||
forbidden patterns added (net, per file): 0
|
||||
readability warnings (net, per file; must be 0 in the final result): 0
|
||||
GATE PASS
|
||||
```
|
||||
|
||||
## Source commits
|
||||
|
||||
- `libs/NW4R/include/nw4r/ut/fontResources.h`: `3bfd2cf8db8a8bc9703bb8f94149ce5369967622`.
|
||||
- `libs/NW4R/include/nw4r/ut/ArchiveFontBase.h`: `aa60f547f3c4683f34289d8677f63ce549fbe8c6`.
|
||||
- `libs/NW4R/src/ut/ut_ArchiveFontBase.cpp`: `c2cc2119930a875833544769595aa22dcfa2593e`.
|
||||
- `libs/NW4R/src/lyt/lyt_window.cpp`: `bc781718f47745f55deb40ae721aa8daed2cd490`.
|
||||
- `libs/NW4R/src/lyt/lyt_textBox.cpp`: `3d747fad0e8353546bd6967d9bb4de778bd0d53e`.
|
||||
- `libs/NW4R/src/ut/ut_ArchiveFont.cpp`: `ba5022222cc88cf402cee7abbf70da01e273cf61`.
|
||||
- `libs/NW4R/src/db/db_console.cpp`: `9dc1c1ddb68ba7d4afc0dc000ed5feebedc5e258`.
|
||||
- `libs/EGG/src/core/eggAudioArcPlayerMgr.cpp`: `d673df55690308d78359a6c093ae558b65ef157d`.
|
||||
- `libs/EGG/src/core/eggHeap.cpp`: `a35ca57371efe83407bd15fe997dd9d78dfb4990`.
|
||||
- `libs/EGG/src/core/eggFrmHeap.cpp`: `b34119321091cb3d5e9b1eb8e57955e220cb9702`.
|
||||
|
||||
Each cleaned file has its own commit. Source scope is restricted to NW4R/EGG; assembly and other worktrees are unchanged. All experiments that changed bytes were restored.
|
||||
Reference in New Issue
Block a user