Difference between revisions of "Modules/clock/Usage"
From MSX Game Library
| Line 1: | Line 1: | ||
| + | For example, display the current year: | ||
| + | <syntaxhighlight lang="c"> | ||
| + | RTC_Initialize(); | ||
| + | u8 year = RTC_GetYear(); | ||
| + | Print_DrawFormat("This year: %i", 1980 + year); | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | Save data to CMOS memory: | ||
| + | <syntaxhighlight lang="c"> | ||
| + | u8 saveData[6]; | ||
| + | saveData[0] = 0xFF; | ||
| + | saveData[1] = 100; | ||
| + | saveData[2] = 0; | ||
| + | RTC_SaveData(saveData); | ||
| + | </syntaxhighlight> | ||
| + | |||
The MSX 2 real-time clock is a Ricoh RP-5C01. For more information about this device: | The MSX 2 real-time clock is a Ricoh RP-5C01. For more information about this device: | ||
* [https://map.grauw.nl/resources/rtc/ricoh_rp5c01.pdf Ricoh RP-5C01 manual] (MSX Assembly Page), | * [https://map.grauw.nl/resources/rtc/ricoh_rp5c01.pdf Ricoh RP-5C01 manual] (MSX Assembly Page), | ||
* [https://www.msx.org/wiki/Real_Time_Clock_Programming Real Time Clock Programming] (MSX Resource Center). | * [https://www.msx.org/wiki/Real_Time_Clock_Programming Real Time Clock Programming] (MSX Resource Center). | ||
Revision as of 19:37, 7 January 2024
For example, display the current year:
RTC_Initialize();
u8 year = RTC_GetYear();
Print_DrawFormat("This year: %i", 1980 + year);
Save data to CMOS memory:
u8 saveData[6]; saveData[0] = 0xFF; saveData[1] = 100; saveData[2] = 0; RTC_SaveData(saveData);
The MSX 2 real-time clock is a Ricoh RP-5C01. For more information about this device:
- Ricoh RP-5C01 manual (MSX Assembly Page),
- Real Time Clock Programming (MSX Resource Center).