Timemacros (#6696)

This commit is contained in:
Ruby 2025-05-11 18:34:54 +08:00 committed by GitHub
parent eadf89e6f9
commit 2740fdd6e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 120 additions and 2 deletions

View File

@ -341,7 +341,7 @@
@ Sets the values of variable VAR_0x8000 to the time of day according to those found in rtc.h.
@ 0 = MORNING, 1 = DAY, 2 = EVENING, 3 = NIGHT
.macro gettimeofday
callnative ScrCmd_gettimeofday
callnative ScrCmd_gettimeofday, requests_effects=1
.endm
@ Plays the specified sound. Only one sound may play at a time, with newer ones interrupting older ones.
@ -2308,7 +2308,11 @@
callnative ScriptSetDoubleBattleFlag, requests_effects=1
.endm
@ When OW_USE_FAKE_RTC and OW_FLAG_PAUSE_TIME is assigned, this macro will stop the flow of time.
@ ============================ @
@ FAKE RTC MACROS
@ Will only function if OW_USE_FAKE_RTC is true. If it has any additional requirements, it will be listed accordingly.
@ When OW_USE_FAKE_RTC is true and OW_FLAG_PAUSE_TIME is assigned, this macro will stop the flow of time.
.macro pausefakertc
callnative Script_PauseFakeRtc, requests_effects=1
.endm
@ -2323,6 +2327,46 @@
callnative Script_ToggleFakeRtc, requests_effects=1
.endm
@ When OW_USE_FAKE_RTC is true, adds a specified amount of time.
.macro addtime days:req, hours:req, minutes:req
callnative ScrCmd_addtime, requests_effects=1
.4byte \days
.4byte \hours
.4byte \minutes
.endm
@ When OW_USE_FAKE_RTC is true, adds a specified number of days to the time.
.macro adddays days:req
callnative ScrCmd_adddays, requests_effects=1
.4byte \days
.endm
@ When OW_USE_FAKE_RTC is true, adds a specified number of days, hours, and minutes to the time.
.macro addhours hours:req
callnative ScrCmd_addhours, requests_effects=1
.4byte \hours
.endm
@ When OW_USE_FAKE_RTC is true, adds a specified number of days, hours, and minutes to the time.
.macro addminutes minutes:req
callnative ScrCmd_addminutes, requests_effects=1
.4byte \minutes
.endm
@ Forwards the time to a specified hour and minute.
@ This causes the time to go to the next day if the time has already been past.
.macro fwdtime hours:req, minutes:req
callnative ScrCmd_fwdtime, requests_effects=1
.4byte \hours
.4byte \minutes
.endm
@ Forwards the time to a specified day of the week. Uses a 0-index starting from Sunday.
.macro fwdweekday weekday:req
callnative ScrCmd_fwdweekday, requests_effects=1
.4byte \weekday
.endm
@ ============================ @
@ ITEM DESCRIPTION HEADER MACROS
@ Used with OW_SHOW_ITEM_DESCRIPTIONS config

View File

@ -17,6 +17,7 @@
#include "event_object_lock.h"
#include "event_object_movement.h"
#include "event_scripts.h"
#include "fake_rtc.h"
#include "field_message_box.h"
#include "field_player_avatar.h"
#include "field_screen_effect.h"
@ -905,6 +906,8 @@ bool8 ScrCmd_gettime(struct ScriptContext *ctx)
bool8 ScrCmd_gettimeofday(struct ScriptContext *ctx)
{
Script_RequestEffects(SCREFF_V1);
gSpecialVar_0x8000 = GetTimeOfDay();
return FALSE;
}
@ -3163,6 +3166,77 @@ bool8 ScrFunc_hidefollower(struct ScriptContext *ctx)
return TRUE;
}
bool8 ScrCmd_addtime(struct ScriptContext *ctx)
{
u32 days = ScriptReadWord(ctx);
u32 hours = ScriptReadWord(ctx);
u32 minutes = ScriptReadWord(ctx);
Script_RequestEffects(SCREFF_V1 | SCREFF_SAVE);
FakeRtc_AdvanceTimeBy(days, hours, minutes, 0);
return FALSE;
}
bool8 ScrCmd_adddays(struct ScriptContext *ctx)
{
u32 days = ScriptReadWord(ctx);
Script_RequestEffects(SCREFF_V1 | SCREFF_SAVE);
FakeRtc_AdvanceTimeBy(days, 0, 0, 0);
return FALSE;
}
bool8 ScrCmd_addhours(struct ScriptContext *ctx)
{
u32 hours = ScriptReadWord(ctx);
Script_RequestEffects(SCREFF_V1 | SCREFF_SAVE);
FakeRtc_AdvanceTimeBy(0, hours, 0, 0);
return FALSE;
}
bool8 ScrCmd_addminutes(struct ScriptContext *ctx)
{
u32 minutes = ScriptReadWord(ctx);
Script_RequestEffects(SCREFF_V1 | SCREFF_SAVE);
FakeRtc_AdvanceTimeBy(0, 0, minutes, 0);
return FALSE;
}
bool8 ScrCmd_fwdtime(struct ScriptContext *ctx)
{
u32 hours = ScriptReadWord(ctx);
u32 minutes = ScriptReadWord(ctx);
Script_RequestEffects(SCREFF_V1 | SCREFF_SAVE);
FakeRtc_ForwardTimeTo(hours, minutes, 0);
return FALSE;
}
bool8 ScrCmd_fwdweekday(struct ScriptContext *ctx)
{
struct SiiRtcInfo *rtc = FakeRtc_GetCurrentTime();
u32 weekdayTarget = ScriptReadWord(ctx);
u32 daysToAdd = ((weekdayTarget - rtc->dayOfWeek) + WEEKDAY_COUNT) % WEEKDAY_COUNT;
Script_RequestEffects(SCREFF_V1 | SCREFF_SAVE);
FakeRtc_AdvanceTimeBy(daysToAdd, 0, 0, 0);
return FALSE;
}
void Script_EndTrainerCanSeeIf(struct ScriptContext *ctx)
{
u8 condition = ScriptReadByte(ctx);