gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/examples/gb/mbc3_rtc/src/mbc3_rtc.c
1 #include <gbdk/platform.h>
2
3 #include "mbc3_rtc.h"
4
5 volatile uint8_t _current_ram_bank;
6
7 uint16_t RTC_GET(const rtc_dateparts_e part) {
8 uint16_t v;
9 RTC_SELECT(part);
10 v = RTC_VALUE_REG;
11 if (part == RTC_VALUE_DAY) {
12 RTC_SELECT(RTC_VALUE_FLAGS);
13 if (RTC_VALUE_REG & 0x01) v |= 0x0100u;
14 }
15 return v;
16 }
17
18 void RTC_SET(const rtc_dateparts_e part, const uint16_t v) {
19 RTC_SELECT(part);
20 RTC_VALUE_REG = v;
21 if (part == RTC_VALUE_DAY) {
22 RTC_SELECT(RTC_VALUE_FLAGS);
23 RTC_VALUE_REG = (RTC_VALUE_REG & 0x0e) | (uint8_t)((v >> 8) & 0x01);
24 }
25 }
26
27 void RTC_START(const uint8_t start) {
28 RTC_SELECT(RTC_VALUE_FLAGS);
29 if (start) RTC_VALUE_REG &= ~RTC_TIMER_STOP; else RTC_VALUE_REG |= RTC_TIMER_STOP;
30 }
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.