Skip to content

Commit ac13242

Browse files
committed
Defined local variables for the Font variables that get used multiple times in the error handler
This saves a bit of memory.
1 parent d795e5f commit ac13242

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

ttyd-tools/rel/source/draw.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5034,12 +5034,15 @@ void Mod::errorHandler(uint16_t error, gc::OSContext::OSContext *context, uint32
50345034
&ImageWidth);
50355035

50365036
// Set up and load the texture object
5037+
uint16_t SheetWidth = tempFontData->sheetWidth;
5038+
uint16_t SheetHeight = tempFontData->sheetHeight;
5039+
50375040
gc::gx::GXTexObj TexObj;
50385041
gc::gx::GXInitTexObj(
50395042
&TexObj,
50405043
Image,
5041-
tempFontData->sheetWidth,
5042-
tempFontData->sheetHeight,
5044+
SheetWidth,
5045+
SheetHeight,
50435046
static_cast<gc::gx::GXTexFmt>(tempFontData->sheetFormat),
50445047
gc::gx::GXTexWrapMode::GX_CLAMP,
50455048
gc::gx::GXTexWrapMode::GX_CLAMP,
@@ -5052,8 +5055,8 @@ void Mod::errorHandler(uint16_t error, gc::OSContext::OSContext *context, uint32
50525055
gc::mtx::mtx34 MtxTextImage;
50535056
gc::mtx::PSMTXScale(
50545057
MtxTextImage,
5055-
1.f / static_cast<float>(tempFontData->sheetWidth),
5056-
1.f / static_cast<float>(tempFontData->sheetHeight),
5058+
1.f / static_cast<float>(SheetWidth),
5059+
1.f / static_cast<float>(SheetHeight),
50575060
1.f);
50585061

50595062
gc::gx::GXLoadTexMtxImm(
@@ -5082,15 +5085,18 @@ void Mod::errorHandler(uint16_t error, gc::OSContext::OSContext *context, uint32
50825085
4);
50835086

50845087
// Get the positions for the images and text
5088+
uint16_t CellWidth = tempFontData->cellWidth;
5089+
uint16_t CellHeight = tempFontData->cellHeight;
5090+
50855091
int16_t ImagePosLeft = static_cast<int16_t>(ImagePosX);
5086-
int16_t ImagePosRight = static_cast<int16_t>(ImagePosLeft + tempFontData->cellWidth);
5092+
int16_t ImagePosRight = static_cast<int16_t>(ImagePosLeft + CellWidth);
50875093
int16_t ImagePosTop = static_cast<int16_t>(ImagePosY);
5088-
int16_t ImagePosBottom = static_cast<int16_t>(ImagePosTop + tempFontData->cellHeight);
5094+
int16_t ImagePosBottom = static_cast<int16_t>(ImagePosTop + CellHeight);
50895095

50905096
int16_t TextPosLeft = static_cast<int16_t>(textPosX);
5091-
int16_t TextPosRight = static_cast<int16_t>(TextPosLeft + tempFontData->cellWidth);
5097+
int16_t TextPosRight = static_cast<int16_t>(TextPosLeft + CellWidth);
50925098
int16_t TextPosTop = static_cast<int16_t>(textPosY);
5093-
int16_t TextPosBottom = static_cast<int16_t>(TextPosTop + tempFontData->cellHeight);
5099+
int16_t TextPosBottom = static_cast<int16_t>(TextPosTop + CellHeight);
50945100

50955101
// Draw the images and text
50965102
gc::ppc::writeGatherPipe.s16 = TextPosLeft;

0 commit comments

Comments
 (0)