Prev: BFD9 Up: Map Next: C03B
C00C: Get Time Period
Used by the routines at ContinueAtTheNextToken and CheckObjectVisibility.
Handles calculating a time-period code for scheduling events.
Time Period Code Meaning
01 Late night/ evening (8 PM - 5 AM)
02 7 PM
03 Afternoon (1 PM - 6 PM)
04 Morning/ Midday (7 AM - 12 PM)
05 6 AM
Output
A Time period code
GetTimePeriod C00C LD A,($9FE2) Fetch *Messaging_AM_PM.
C00F CP $61 Check if its "A" for AM.
C011 LD A,($9FE0) Read the hour.
C014 JR Z,TimePeriod_AM Go to TimePeriod_AM if the period letter is 61 (morning).
It's the afternoon (as in, "PM").
C016 CP $0C Go to TimePeriod_Morning if the hour is twelve (noon).
C018 JR Z,TimePeriod_Morning
C01A CP $08 Go to TimePeriod_BeforeEightPM if the hour is before eight.
C01C JR C,TimePeriod_BeforeEightPM
It's late PM/ evening; 8 PM - 11 PM.
TimePeriod_LateEvening C01E LD A,$01 Leave 01 as the result.
C020 RET Return.
Seven in the evening leaves time-of-day code 2.
It's before 8 PM, but break this down further.
TimePeriod_BeforeEightPM C021 CP $07 Go to TimePeriod_Afternoon unless the hour is seven.
C023 JR NZ,TimePeriod_Afternoon
It's 7 PM.
C025 LD A,$02 Leave 02 as the result.
C027 RET Return.
The afternoon, from one until six, leaves time-of-day code 3.
It's afternoon/ early PM; 1 PM - 6 PM.
TimePeriod_Afternoon C028 LD A,$03 Leave 03 as the result.
C02A RET Return.
The morning checks leave time-of-day code 4, or continue into early morning.
It's morning, but break this down further.
TimePeriod_AM C02B CP $0C Go to TimePeriod_LateEvening if the hour is twelve.
C02D JR Z,TimePeriod_LateEvening
C02F CP $06 Go to TimePeriod_LateEvening if the hour is before six.
C031 JR C,TimePeriod_LateEvening
C033 JR Z,TimePeriod_EarlyMorning Go to TimePeriod_EarlyMorning if the hour is six.
It's morning; 7 AM - noon (12 PM).
TimePeriod_Morning C035 LD A,$04 Leave 04 as the result.
C037 RET Return.
Six in the morning leaves time-of-day code 5.
It's early morning; 6 AM.
TimePeriod_EarlyMorning C038 LD A,$05 Leave 05 as the result.
C03A RET Return.
Prev: BFD9 Up: Map Next: C03B