Previous: General Illumination, Up: Core APIs


5.7 Real-Time Clock

On machines with a realtime clock, these APIs let you set and get the current time of day. At present, only WPC is supported.

The WPC ASIC provides three registers for counting minutes, hours, and days. FreeWPC keeps the calendar time in persistent memory. About once per minute, it polls the RTC and updates the calendar time to reflect any changes. The battery provides power to the ASIC even when the game is off so the real-time clock remains updated.

Game code does not need to call the following APIs. The current date and time can simply be read from memory, in the variable current_date.

rtc_hw_read
Update the hour/minute in memory from the value in the hardware registers.
rtc_hw_write
Update the hour/memory in the hardware from the value in memory. This is only used when setting the time.