Chapter 4
Real time
LovePlus+ runs on your time. If it's Tuesday evening where you are, it's Tuesday evening for her. She'll be at school in the morning, free after class, and asleep late at night. Christmas Eve comes when it comes. The game's clock is the DS's own.
Where the time comes from
The DS has a battery-backed clock chip, read by the ARM7. The game asks for the date and time through the SDK (RTC_GetDateTime) and keeps a copy (GameClock_InitializeFromRtc, GameClock_Sync).
Every part of the game that wants to know the hour, the day or the weekday goes through a small family of getters such as GameClock_GetHour. Each one can answer from three places: a date set by hand (some scenes pin the clock), a date stored in the game's own clock block, or the clock chip, shifted by an offset the game keeps. Most of the time it's the clock chip.
Six periods a day
The game cuts the day into six periods. TimePeriod_FromHour turns the hour into one of them with a five-entry table of boundaries:
| period | hours | backdrop |
|---|---|---|
| 0 | 5:00 – 8:00 | day |
| 1 | 8:00 – 12:00 | day |
| 2 | 12:00 – 15:00 | day |
| 3 | 15:00 – 18:00 | evening |
| 4 | 18:00 – 21:00 | night |
| 5 | 21:00 – 5:00 | night |
The period decides a lot: which scenes can play (chapter 3's context word carries it, and 482 scene conditions test it directly) and which picture hangs behind the room. The evening backdrop starts at three in the afternoon. That isn't a rendering quirk: it's the period table.
The calendar
A calendar module, Calendar_IsEventActive, answers one question: is calendar event N on today? To find out what every code means, we ran the game's own module for each of its 175 codes, on every day of 28 consecutive years (a 28-year cycle covers every way weekdays and leap years line up):
The fixed dates read like a year in Japan: New Year's Day (1/1), Valentine's Day (2/14), the doll festival (3/3), White Day (3/14), the Golden Week holidays (4/29 – 5/5), Tanabata (7/7), Halloween (10/31), Christmas Eve and Christmas (12/24, 12/25), New Year's Eve (12/31). Others cover a week, a month or a whole season, such as the summer stretch from 7/19 to 8/31.
Every day, CalendarRule_RunDailyEventLogic works out today's rule, and stage 12 of the event pipeline (chapter 3) uses it to choose a holiday or school-event scene over an ordinary one.
A new day
The top state machine has a state for a new day, 0xF0 (chapter 2), which updates the schedule, the calendar and the day's random events when the room reports a day change. The everyday route is quieter: going to sleep in the room, and the next morning, happen entirely inside the room's own overlay, without the top machine ever leaving its hub state.
When you've been away
Because time is real, you can stay away for days, and the game notices. Continuing a saved game goes through state 0x20, which loads overlay 43 and reconciles the game's time with the clock (Ov43_ReconcileGameTimeState). The save keeps dates of its own, and the game compares them with the clock to work out what has passed.
Time away also feeds the scene rules. One of the conditions in the candidate lists from chapter 3 is weeks elapsed: whether at least n weeks lie between two dates the game keeps. It's used 720 times, the sixth most common of all 107.
Chance, from the clock
The game's random numbers (Rand_Next, a 64-bit linear generator) are seeded from the clock. So the clock decides not only which scenes are possible, but which of them you get.
In lp-engine
- The DS clock is your computer's local time, read every frame.
- Game > Clock shifts it by whole hours, for players whose day doesn't line up with hers. The game sees a shifted clock exactly as it would see a DS whose clock was set differently, and it reacts the same way.
- Closing the lid (minimizing the window) puts the game to sleep. The clock keeps running, as the DS's did.
- Because the clock steers both the scenes and the random numbers, each recorded session logs the time every frame, so a problem can be replayed exactly. For tests, the clock can be pinned to a fixed start.
Still open. The calendar's codes are mapped to their days, but not all are named: some year-dependent codes cover 8 to 23 days a year in patterns that still need a reading. The full table is in docs/CALENDAR.md.