git.y1.nz

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.h

      1 #ifndef _RTC_H_INCLUDE
      2 #define _RTC_H_INCLUDE
      3 
      4 #include <gbdk/platform.h>
      5 #include <stdint.h>
      6 
      7 volatile uint8_t AT(0x4000) RTC_SELECT_REG;
      8 volatile uint8_t AT(0x6000) RTC_LATCH_REG;
      9 volatile uint8_t AT(0xA000) RTC_VALUE_REG;
     10 
     11 #define RTC_TIMER_STOP 0b01000000
     12 
     13 typedef enum {
     14     RTC_VALUE_SEC = 0x08,
     15     RTC_VALUE_MIN,
     16     RTC_VALUE_HOUR,
     17     RTC_VALUE_DAY
     18 } rtc_dateparts_e;
     19 
     20 #define RTC_VALUE_FLAGS 0x0c
     21 
     22 #define RAM_BANKS_ONLY 0x0fu
     23 #define RAM_BANKS_AND_FLAGS 0xffu
     24 
     25 extern volatile uint8_t _current_ram_bank;
     26 
     27 inline void SWITCH_RAM_BANK(uint8_t bank, uint8_t mask) { SWITCH_RAM(_current_ram_bank = ((_current_ram_bank & ~mask) | (bank & mask))); }
     28 inline void RTC_SELECT(uint8_t what) { SWITCH_RAM_BANK(what, RAM_BANKS_ONLY); }
     29 inline void RTC_LATCH(void) { RTC_LATCH_REG = 0; RTC_LATCH_REG = 1; }
     30 
     31 uint16_t RTC_GET(const rtc_dateparts_e part);
     32 void RTC_SET(const rtc_dateparts_e part, const uint16_t v);
     33 void RTC_START(const uint8_t start);
     34 
     35 #endif

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.