Skip to content

Commit 14148ef

Browse files
committed
Adjusted the drawText functions to only call FontDrawStart_alpha and FontDrawEdge when necessary
These changes use slightly more memory, but reduce a lot of slowdown in a lot of places. It's important to note that every time a window or icon is drawn, FontDrawStart_alpha has to be called again before more text can be drawn.
1 parent 3e94e8d commit 14148ef

File tree

6 files changed

+462
-296
lines changed

6 files changed

+462
-296
lines changed

ttyd-tools/rel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ MACHDEP = -mno-sdata -mgcn -DGEKKO -mcpu=750 -meabi -mhard-float
5454
CFLAGS = -nostdlib -ffreestanding -ffunction-sections -fdata-sections -g -Os -Wall -Werror -Wno-address-of-packed-member $(MACHDEP) $(INCLUDE)
5555
CXXFLAGS = -fno-exceptions -fno-rtti -std=gnu++17 $(CFLAGS)
5656

57-
FUNCWRAPS = -Wl,--wrap,sprintf -Wl,--wrap,strcmp -Wl,--wrap,strncmp -Wl,--wrap,strcpy -Wl,--wrap,strncpy -Wl,--wrap,strcat -Wl,--wrap,strlen -Wl,--wrap,memcpy -Wl,--wrap,memset -Wl,--wrap,sysMsec2Frame -Wl,--wrap,keyGetButton -Wl,--wrap,keyGetButtonTrg -Wl,--wrap,seqGetSeq -Wl,--wrap,seqGetNextSeq -Wl,--wrap,swByteGet -Wl,--wrap,swByteSet -Wl,--wrap,swClear -Wl,--wrap,swSet -Wl,--wrap,marioStGetSystemLevel -Wl,--wrap,marioStSystemLevel -Wl,--wrap,marioGetPartyId -Wl,--wrap,marioGetExtraPartyId -Wl,--wrap,marioGetPtr -Wl,--wrap,partyGetPtr -Wl,--wrap,pouchGetPtr -Wl,--wrap,btlGetScreenPoint -Wl,--wrap,evtGetWork -Wl,--wrap,eventStgNum -Wl,--wrap,eventStgDtPtr -Wl,--wrap,winGetPtr -Wl,--wrap,winOpenDisable -Wl,--wrap,winOpenEnable -Wl,--wrap,CARDClose -Wl,--wrap,DCFlushRange -Wl,--wrap,ICInvalidateRange -Wl,--wrap,__udivdi3 -Wl,--wrap,__umoddi3 -Wl,--wrap,dispEntry
57+
FUNCWRAPS = -Wl,--wrap,sprintf -Wl,--wrap,strcmp -Wl,--wrap,strncmp -Wl,--wrap,strcpy -Wl,--wrap,strncpy -Wl,--wrap,strcat -Wl,--wrap,strlen -Wl,--wrap,memcpy -Wl,--wrap,memset -Wl,--wrap,sysMsec2Frame -Wl,--wrap,keyGetButton -Wl,--wrap,keyGetButtonTrg -Wl,--wrap,seqGetSeq -Wl,--wrap,seqGetNextSeq -Wl,--wrap,swByteGet -Wl,--wrap,swByteSet -Wl,--wrap,swClear -Wl,--wrap,swSet -Wl,--wrap,marioStGetSystemLevel -Wl,--wrap,marioStSystemLevel -Wl,--wrap,marioGetPartyId -Wl,--wrap,marioGetExtraPartyId -Wl,--wrap,marioGetPtr -Wl,--wrap,partyGetPtr -Wl,--wrap,pouchGetPtr -Wl,--wrap,btlGetScreenPoint -Wl,--wrap,evtGetWork -Wl,--wrap,eventStgNum -Wl,--wrap,eventStgDtPtr -Wl,--wrap,winGetPtr -Wl,--wrap,winOpenDisable -Wl,--wrap,winOpenEnable -Wl,--wrap,DCFlushRange -Wl,--wrap,ICInvalidateRange -Wl,--wrap,__udivdi3 -Wl,--wrap,__umoddi3 -Wl,--wrap,dispEntry -Wl,--wrap,FontDrawStart_alpha -Wl,--wrap,FontDrawEdge
5858

5959
LDFLAGS = -r -e _prolog -u _prolog -u _epilog -u _unresolved -Wl,--gc-sections -nostdlib -g $(MACHDEP) -Wl,-Map,$(notdir $@).map $(FUNCWRAPS)
6060

ttyd-tools/rel/include/draw.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,21 @@ void drawWindow(uint32_t color, int32_t x, int32_t y, int32_t width, int32_t hei
1515

1616
int32_t *drawIcon(int32_t position[3], int16_t iconNum, float scale);
1717
int32_t *drawIconFromItem(int32_t position[3], int16_t itemNum, float scale);
18+
1819
void drawStringMultiline(float x, float y, const char *text);
20+
void drawText(const char *text, int32_t x, int32_t y, uint32_t color, float scale);
21+
void drawTextInit(uint8_t alpha, bool drawFontEdge);
1922

20-
void drawText(const char *text, int32_t x, int32_t y, uint8_t alpha,
21-
uint32_t color, float scale);
23+
void drawTextAndInit(const char *text, int32_t x, int32_t y,
24+
uint8_t alpha, uint32_t color, bool drawDontEdge, float scale);
2225

2326
uint16_t getMessageWidth(const char *text, float scale);
2427
void getOnOffTextAndColor(bool valueToCheck, const char **textOut, uint32_t *colorOut);
2528
void getYesNoTextAndColor(bool valueToCheck, const char **textOut, uint32_t *colorOut);
2629
uint32_t getSelectedTextColor(bool valueToCheck);
2730

28-
void drawTextWithWindow(const char *text, int32_t textPosX, int32_t textPosY, uint8_t alpha,
29-
uint32_t textColor, float textScale, int32_t windowWidth, uint32_t windowColor, float windowCurve);
31+
void drawTextWithWindow(const char *text, int32_t textPosX, int32_t textPosY, uint32_t textColor,
32+
float textScale, int32_t windowWidth, uint32_t windowColor, float windowCurve);
3033

3134
void drawSingleColumnMain();
3235
void drawSingleColumnSelectedOption();
@@ -44,8 +47,8 @@ void drawInventoryIconAndTextColumns();
4447
void drawItemIconsColumn(uint32_t indexStart, uint32_t indexIncrement, uint32_t size,
4548
int32_t posX, int32_t posY, uint32_t address, float scale);
4649

47-
void drawItemTextColumn(uint32_t indexStart, uint32_t indexIncrement, uint32_t size,
48-
int32_t posX, int32_t posY, uint32_t address, uint8_t alpha, float scale);
50+
void drawItemTextColumn(uint32_t indexStart, uint32_t indexIncrement,
51+
uint32_t size, int32_t posX, int32_t posY, uint32_t address, float scale);
4952

5053
void drawMarioSpecialMovesOptions();
5154
void drawFollowersOptions();
@@ -57,7 +60,7 @@ void drawBattlesActorsHeldItem();
5760
void drawCurrentFollowerOut();
5861

5962
void drawMemoryWatchValueString(int32_t slot, int32_t posX,
60-
int32_t posY, uint8_t alpha, uint32_t color, float scale);
63+
int32_t posY, uint32_t color, bool drawFontEdge, float scale);
6164

6265
void drawMemoryWatches();
6366
void drawMemoryModifyList();
@@ -122,10 +125,12 @@ void drawOnScreenTimerButtonCombos(uint16_t *buttonCombo);
122125
void drawOnScreenTimer();
123126
void drawFrameCounter();
124127
void drawSequenceInPauseMenu();
128+
void drawMarioCoordinatesInit();
125129
void drawMarioCoordinates();
126130
void drawMarioSpeedXZ();
127131
void drawJumpStorageDetails();
128132
void drawButtonInputs();
133+
void drawStickAngleInit();
129134
void drawStickAngle();
130135
void drawMemoryWatchesOnOverworld();
131136

ttyd-tools/rel/source/assembly/WrappersAsm.s

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@
3030
.global __wrap_winGetPtr
3131
.global __wrap_winOpenDisable
3232
.global __wrap_winOpenEnable
33-
.global __wrap_CARDClose
3433
.global __wrap_DCFlushRange
3534
.global __wrap_ICInvalidateRange
3635
.global __wrap___udivdi3
3736
.global __wrap___umoddi3
3837
.global __wrap_dispEntry
38+
.global __wrap_FontDrawStart_alpha
39+
.global __wrap_FontDrawEdge
3940

4041
__wrap_sprintf:
4142
b __real_sprintf
@@ -133,9 +134,6 @@ b __real_winOpenDisable
133134
__wrap_winOpenEnable:
134135
b __real_winOpenEnable
135136

136-
__wrap_CARDClose:
137-
b __real_CARDClose
138-
139137
__wrap_DCFlushRange:
140138
b __real_DCFlushRange
141139

@@ -149,4 +147,10 @@ __wrap___umoddi3:
149147
b __real___umoddi3
150148

151149
__wrap_dispEntry:
152-
b __real_dispEntry
150+
b __real_dispEntry
151+
152+
__wrap_FontDrawStart_alpha:
153+
b __real_FontDrawStart_alpha
154+
155+
__wrap_FontDrawEdge:
156+
b __real_FontDrawEdge

ttyd-tools/rel/source/codes.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ void displayMarioCoordinates()
10571057
return;
10581058
}
10591059

1060-
drawFunctionOnDebugLayer(drawMarioCoordinates);
1060+
drawFunctionOnDebugLayer(drawMarioCoordinatesInit);
10611061
}
10621062

10631063
void displayMarioSpeedXZ()
@@ -1116,7 +1116,7 @@ void displayStickAngle()
11161116
return;
11171117
}
11181118

1119-
drawFunctionOnDebugLayer(drawStickAngle);
1119+
drawFunctionOnDebugLayer(drawStickAngleInit);
11201120
}
11211121

11221122
void displayMemoryWatches()

0 commit comments

Comments
 (0)