summaryrefslogtreecommitdiff
path: root/engine/overworld/time.asm
diff options
context:
space:
mode:
Diffstat (limited to 'engine/overworld/time.asm')
-rw-r--r--engine/overworld/time.asm117
1 files changed, 39 insertions, 78 deletions
diff --git a/engine/overworld/time.asm b/engine/overworld/time.asm
index 0f83447cc..abb12d87d 100644
--- a/engine/overworld/time.asm
+++ b/engine/overworld/time.asm
@@ -1,21 +1,19 @@
-_InitializeStartDay: ; 113d6
+_InitializeStartDay:
call InitializeStartDay
ret
-; 113da
-ClearDailyTimers: ; 113da
+ClearDailyTimers:
xor a
ld [wLuckyNumberDayBuffer], a
ld [wUnusedTwoDayTimer], a
ld [wDailyResetTimer], a
ret
-; 113e5
-InitCallReceiveDelay:: ; 113e5
+InitCallReceiveDelay::
xor a
ld [wTimeCyclesSinceLastCall], a
-NextCallReceiveDelay: ; 113e9
+NextCallReceiveDelay:
ld a, [wTimeCyclesSinceLastCall]
cp 3
jr c, .okay
@@ -28,13 +26,11 @@ NextCallReceiveDelay: ; 113e9
add hl, de
ld a, [hl]
jp RestartReceiveCallDelay
-; 113fd
.ReceiveCallDelays:
db 20, 10, 5, 3
-; 11401
-CheckReceiveCallTimer: ; 11401
+CheckReceiveCallTimer:
call CheckReceiveCallDelay ; check timer
ret nc
ld hl, wTimeCyclesSinceLastCall
@@ -47,12 +43,11 @@ CheckReceiveCallTimer: ; 11401
call NextCallReceiveDelay ; restart timer
scf
ret
-; 11413
-InitOneDayCountdown: ; 11413
+InitOneDayCountdown:
ld a, 1
-InitNDaysCountdown: ; 11415
+InitNDaysCountdown:
ld [hl], a
push hl
call UpdateTime
@@ -60,9 +55,8 @@ InitNDaysCountdown: ; 11415
inc hl
call CopyDayToHL
ret
-; 11420
-CheckDayDependentEventHL: ; 11420
+CheckDayDependentEventHL:
inc hl
push hl
call CalcDaysSince
@@ -71,32 +65,28 @@ CheckDayDependentEventHL: ; 11420
dec hl
call UpdateTimeRemaining
ret
-; 1142e
-RestartReceiveCallDelay: ; 1142e
+RestartReceiveCallDelay:
ld hl, wReceiveCallDelay_MinsRemaining
ld [hl], a
call UpdateTime
ld hl, wReceiveCallDelay_StartTime
call CopyDayHourMinToHL
ret
-; 1143c
-CheckReceiveCallDelay: ; 1143c
+CheckReceiveCallDelay:
ld hl, wReceiveCallDelay_StartTime
call CalcMinsHoursDaysSince
call GetMinutesSinceIfLessThan60
ld hl, wReceiveCallDelay_MinsRemaining
call UpdateTimeRemaining
ret
-; 1144c
-RestartDailyResetTimer: ; 1144c
+RestartDailyResetTimer:
ld hl, wDailyResetTimer
jp InitOneDayCountdown
-; 11452
-CheckDailyResetTimer:: ; 11452
+CheckDailyResetTimer::
ld hl, wDailyResetTimer
call CheckDayDependentEventHL
ret nc
@@ -128,18 +118,16 @@ endr
call SampleKenjiBreakCountdown
.DontRestartKenjiBreakCountdown:
jr RestartDailyResetTimer
-; 11485
-SampleKenjiBreakCountdown: ; 11485
+SampleKenjiBreakCountdown:
; Generate a random number between 3 and 6
call Random
and %11
add 3
ld [wKenjiBreakTimer], a
ret
-; 11490
-StartBugContestTimer: ; 11490
+StartBugContestTimer:
ld a, BUG_CONTEST_MINUTES
ld [wBugContestMinsRemaining], a
ld a, BUG_CONTEST_SECONDS
@@ -148,10 +136,8 @@ StartBugContestTimer: ; 11490
ld hl, wBugContestStartTime
call CopyDayHourMinSecToHL
ret
-; 114a4
-
-CheckBugContestTimer:: ; 114a4 (4:54a4)
+CheckBugContestTimer::
ld hl, wBugContestStartTime
call CalcSecsMinsHoursDaysSince
ld a, [wDaysSince]
@@ -185,15 +171,13 @@ CheckBugContestTimer:: ; 114a4 (4:54a4)
scf
ret
-
-InitializeStartDay: ; 114dd
+InitializeStartDay:
call UpdateTime
ld hl, wTimerEventStartDay
call CopyDayToHL
ret
-; 114e7
-CheckPokerusTick:: ; 114e7
+CheckPokerusTick::
ld hl, wTimerEventStartDay
call CalcDaysSince
call GetDaysSince
@@ -204,9 +188,8 @@ CheckPokerusTick:: ; 114e7
.done
xor a
ret
-; 114fc
-SetUnusedTwoDayTimer: ; 114fc
+SetUnusedTwoDayTimer:
ld a, 2
ld hl, wUnusedTwoDayTimer
ld [hl], a
@@ -214,22 +197,19 @@ SetUnusedTwoDayTimer: ; 114fc
ld hl, wUnusedTwoDayTimerStartDate
call CopyDayToHL
ret
-; 1150c
-CheckUnusedTwoDayTimer: ; 1150c
+CheckUnusedTwoDayTimer:
ld hl, wUnusedTwoDayTimerStartDate
call CalcDaysSince
call GetDaysSince
ld hl, wUnusedTwoDayTimer
call UpdateTimeRemaining
ret
-; 1151c
; unused
ld hl, wDailyFlags
set DAILYFLAGS_FISH_SWARM_F, [hl]
ret
-; 11522
; unused
and a
@@ -238,15 +218,13 @@ CheckUnusedTwoDayTimer: ; 1150c
ret nz
scf
ret
-; 1152b
-RestartLuckyNumberCountdown: ; 1152b
+RestartLuckyNumberCountdown:
call .GetDaysUntilNextFriday
ld hl, wLuckyNumberDayBuffer
jp InitNDaysCountdown
-; 11534
-.GetDaysUntilNextFriday: ; 11534
+.GetDaysUntilNextFriday:
call GetWeekday
ld c, a
ld a, FRIDAY
@@ -259,14 +237,12 @@ RestartLuckyNumberCountdown: ; 1152b
.earlier
ret
-; 11542
-_CheckLuckyNumberShowFlag: ; 11542
+_CheckLuckyNumberShowFlag:
ld hl, wLuckyNumberDayBuffer
jp CheckDayDependentEventHL
-; 11548
-DoMysteryGiftIfDayHasPassed: ; 11548
+DoMysteryGiftIfDayHasPassed:
ld a, BANK(sMysteryGiftTimer)
call GetSRAMBank
ld hl, sMysteryGiftTimer
@@ -294,9 +270,8 @@ DoMysteryGiftIfDayHasPassed: ; 11548
ld [sMysteryGiftTimer + 1], a
call CloseSRAM
ret
-; 11586
-UpdateTimeRemaining: ; 11586
+UpdateTimeRemaining:
; If the amount of time elapsed exceeds the capacity of its
; unit, skip this part.
cp -1
@@ -318,9 +293,8 @@ UpdateTimeRemaining: ; 11586
ld [hl], a
scf
ret
-; 11599
-GetSecondsSinceIfLessThan60: ; 11599
+GetSecondsSinceIfLessThan60:
ld a, [wDaysSince]
and a
jr nz, GetTimeElapsed_ExceedsUnitLimit
@@ -331,9 +305,8 @@ GetSecondsSinceIfLessThan60: ; 11599
jr nz, GetTimeElapsed_ExceedsUnitLimit
ld a, [wSecondsSince]
ret
-; 115ae
-GetMinutesSinceIfLessThan60: ; 115ae
+GetMinutesSinceIfLessThan60:
ld a, [wDaysSince]
and a
jr nz, GetTimeElapsed_ExceedsUnitLimit
@@ -342,45 +315,38 @@ GetMinutesSinceIfLessThan60: ; 115ae
jr nz, GetTimeElapsed_ExceedsUnitLimit
ld a, [wMinutesSince]
ret
-; 115be
-GetHoursSinceIfLessThan24: ; 115be
+GetHoursSinceIfLessThan24:
ld a, [wDaysSince]
and a
jr nz, GetTimeElapsed_ExceedsUnitLimit
ld a, [wHoursSince]
ret
-; 115c8
-GetDaysSince: ; 115c8
+GetDaysSince:
ld a, [wDaysSince]
ret
-; 115cc
-GetTimeElapsed_ExceedsUnitLimit: ; 115cc
+GetTimeElapsed_ExceedsUnitLimit:
ld a, -1
ret
-; 115cf
-CalcDaysSince: ; 115cf
+CalcDaysSince:
xor a
jr _CalcDaysSince
-; 115d2
-CalcHoursDaysSince: ; 115d2
+CalcHoursDaysSince:
inc hl
xor a
jr _CalcHoursDaysSince
-; 115d6
-CalcMinsHoursDaysSince: ; 115d6
+CalcMinsHoursDaysSince:
inc hl
inc hl
xor a
jr _CalcMinsHoursDaysSince
-; 115db
-CalcSecsMinsHoursDaysSince: ; 115db
+CalcSecsMinsHoursDaysSince:
inc hl
inc hl
inc hl
@@ -394,7 +360,7 @@ CalcSecsMinsHoursDaysSince: ; 115db
dec hl
ld [wSecondsSince], a ; seconds since
-_CalcMinsHoursDaysSince: ; 115eb
+_CalcMinsHoursDaysSince:
ld a, [hMinutes]
ld c, a
sbc [hl]
@@ -405,7 +371,7 @@ _CalcMinsHoursDaysSince: ; 115eb
dec hl
ld [wMinutesSince], a ; minutes since
-_CalcHoursDaysSince: ; 115f8
+_CalcHoursDaysSince:
ld a, [hHours]
ld c, a
sbc [hl]
@@ -426,9 +392,8 @@ _CalcDaysSince:
ld [hl], c ; current days
ld [wDaysSince], a ; days since
ret
-; 11613
-CopyDayHourMinSecToHL: ; 11613
+CopyDayHourMinSecToHL:
ld a, [wCurDay]
ld [hli], a
ld a, [hHours]
@@ -438,23 +403,20 @@ CopyDayHourMinSecToHL: ; 11613
ld a, [hSeconds]
ld [hli], a
ret
-; 11621
-CopyDayToHL: ; 11621
+CopyDayToHL:
ld a, [wCurDay]
ld [hl], a
ret
-; 11626
-CopyDayHourToHL: ; 11626
+CopyDayHourToHL:
ld a, [wCurDay]
ld [hli], a
ld a, [hHours]
ld [hli], a
ret
-; 1162e
-CopyDayHourMinToHL: ; 1162e
+CopyDayHourMinToHL:
ld a, [wCurDay]
ld [hli], a
ld a, [hHours]
@@ -462,4 +424,3 @@ CopyDayHourMinToHL: ; 1162e
ld a, [hMinutes]
ld [hli], a
ret
-; 11639