Skip to content

Commit d32dd6d

Browse files
committed
Added an option to set specific flags when warping by an event
The flags that would be set are as follows: 1. Shop tutorial 2. Got first email 3. Read any email 4. Save block tutorial 5. Recovery block tutorial 6. Item tutorial
1 parent a40e413 commit d32dd6d

File tree

7 files changed

+58
-3
lines changed

7 files changed

+58
-3
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 $(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,marioStGetSystemLevel -Wl,--wrap,marioStSystemLevel -Wl,--wrap,marioGetPartyId -Wl,--wrap,marioGetExtraPartyId -Wl,--wrap,marioPartyEntry -Wl,--wrap,marioGetPtr -Wl,--wrap,pouchGetPtr -Wl,--wrap,btlGetScreenPoint -Wl,--wrap,evtGetWork -Wl,--wrap,eventStgNum -Wl,--wrap,eventStgDtPtr -Wl,--wrap,winGetPtr -Wl,--wrap,winOpenEnable -Wl,--wrap,CARDClose -Wl,--wrap,DCFlushRange -Wl,--wrap,ICInvalidateRange -Wl,--wrap,__udivdi3 -Wl,--wrap,__umoddi3
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,marioPartyEntry -Wl,--wrap,marioGetPtr -Wl,--wrap,pouchGetPtr -Wl,--wrap,btlGetScreenPoint -Wl,--wrap,evtGetWork -Wl,--wrap,eventStgNum -Wl,--wrap,eventStgDtPtr -Wl,--wrap,winGetPtr -Wl,--wrap,winOpenEnable -Wl,--wrap,CARDClose -Wl,--wrap,DCFlushRange -Wl,--wrap,ICInvalidateRange -Wl,--wrap,__udivdi3 -Wl,--wrap,__umoddi3
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/global.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ enum WARPS_EVENT_OPTIONS
407407
{
408408
EVENT_SELECT_EVENT = 1,
409409
EVENT_KEEP_INVENTORY,
410+
EVENT_SET_FLAGS,
410411
EVENT_WARP_NOW,
411412
};
412413

@@ -692,11 +693,13 @@ struct WarpByEventStruct
692693
{
693694
int32_t CurrentIndex;
694695
bool ShouldKeepInventory;
696+
bool ShouldSetFlags;
695697
bool ShouldInit;
696698

697699
WarpByEventStruct()
698700
{
699701
ShouldKeepInventory = true;
702+
ShouldSetFlags = true;
700703
}
701704
};
702705

ttyd-tools/rel/source/draw.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3408,7 +3408,7 @@ void drawWarpByEventMenuDetails()
34083408
drawText(ExplainText, PosX, PosY, Alpha, Color, Scale);
34093409
PosY -= 60;
34103410

3411-
// Draw the text for whether the standard inventory is being kept or not
3411+
// Draw the text for whether the standard inventory should be kept or not
34123412
const char *String;
34133413
if (WarpByEvent.ShouldKeepInventory)
34143414
{
@@ -3421,12 +3421,27 @@ void drawWarpByEventMenuDetails()
34213421
String = "No";
34223422
}
34233423

3424-
int32_t tempPosX = PosX + 222;
3424+
int32_t tempPosX = PosX + 232;
34253425

34263426
#ifdef TTYD_JP
34273427
tempPosX -= 10;
34283428
#endif
34293429

3430+
drawText(String, tempPosX, PosY, Alpha, Color, Scale);
3431+
PosY -= 20;
3432+
3433+
// Draw the text for whether specific flags should be set or not
3434+
if (WarpByEvent.ShouldSetFlags)
3435+
{
3436+
Color = 0x1BBE23FF;
3437+
String = "Yes";
3438+
}
3439+
else
3440+
{
3441+
Color = 0xFF1414FF;
3442+
String = "No";
3443+
}
3444+
34303445
drawText(String, tempPosX, PosY, Alpha, Color, Scale);
34313446
PosY -= 60;
34323447

ttyd-tools/rel/source/global.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,6 +1590,7 @@ const char *WarpEventLines[] =
15901590
{
15911591
"Select Event",
15921592
"Keep Standard Inventory",
1593+
"Set Flags",
15931594
"Warp",
15941595
};
15951596

ttyd-tools/rel/source/menu.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2746,6 +2746,13 @@ void menuCheckButton()
27462746
WarpByEvent.ShouldKeepInventory = !ShouldKeepInventory;
27472747
break;
27482748
}
2749+
case EVENT_SET_FLAGS:
2750+
{
2751+
// Flip the bool
2752+
bool ShouldSetFlags = WarpByEvent.ShouldSetFlags;
2753+
WarpByEvent.ShouldSetFlags = !ShouldSetFlags;
2754+
break;
2755+
}
27492756
case EVENT_WARP_NOW:
27502757
{
27512758
int32_t ReturnCode = warpToMapByEvent(WarpByEvent.CurrentIndex);

ttyd-tools/rel/source/menufunctions.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3496,6 +3496,28 @@ void *initStageEvents()
34963496
}
34973497
}
34983498

3499+
// Set specific flags if desired
3500+
if (WarpByEvent.ShouldSetFlags)
3501+
{
3502+
// Set up the flags to set
3503+
static const uint16_t FlagsToSet[] =
3504+
{
3505+
0, // Shop tutorial
3506+
37, // Got first email
3507+
38, // Read any email
3508+
233, // Save block tutorial
3509+
234, // Recovery block tutorial
3510+
235, // Item tutorial
3511+
};
3512+
3513+
// Set the flags
3514+
uint32_t Size = sizeof(FlagsToSet) / sizeof(FlagsToSet[0]);
3515+
for (uint32_t i = 0; i < Size; i++)
3516+
{
3517+
ttyd::swdrv::swSet(FlagsToSet[i]);
3518+
}
3519+
}
3520+
34993521
// Set the Sequence to the value for the current event
35003522
setSequencePosition(getGsw0ForEvent(StageId, EventId));
35013523

ttyd-tools/rel/source/wrappers.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ extern "C"
2929
uint32_t __real_swByteGet(uint32_t gsw);
3030
void __real_swByteSet(uint32_t gsw, uint32_t value);
3131
void __real_swClear(uint32_t gswf);
32+
void __real_swSet(uint32_t gswf);
3233
uint32_t __real_marioStGetSystemLevel();
3334
void __real_marioStSystemLevel(uint32_t level);
3435
int32_t __real_marioGetPartyId();
@@ -155,6 +156,12 @@ extern "C"
155156
__real_swClear(gswf);
156157
}
157158

159+
// swSet
160+
__attribute__((noinline)) void __wrap_swSet(uint32_t gswf)
161+
{
162+
__real_swSet(gswf);
163+
}
164+
158165
// marioStGetSystemLevel
159166
__attribute__((noinline)) uint32_t __wrap_marioStGetSystemLevel()
160167
{

0 commit comments

Comments
 (0)