♥ lp-engine

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:

periodhoursbackdrop
05:00 – 8:00day
18:00 – 12:00day
212:00 – 15:00day
315:00 – 18:00evening
418:00 – 21:00night
521:00 – 5:00night

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):

115fixed dates: the same days every year
16move from year to year: weekday rules and moving holidays
44never on: codes the game defines but doesn't use
28years in the cycle the calendar repeats on

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

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.