diff options
author | Ben Bridle <ben@derelict.engineering> | 2025-09-19 13:17:14 +1200 |
---|---|---|
committer | Ben Bridle <ben@derelict.engineering> | 2025-09-19 13:32:32 +1200 |
commit | bb1aa5958d1b67707dcf0f6b08bfaf0b408bd46e (patch) | |
tree | b26d07ed58aaf7a5230fc3e28c103d616abfa9b8 /arm9/source/devices/clock.h | |
parent | 9612c307f00c4313d73fe0c3a86c05c8d8cd514e (diff) | |
download | bedrock-nds-bb1aa5958d1b67707dcf0f6b08bfaf0b408bd46e.zip |
Massive rewrite
This commit rewrites the emulator halfway from scratch to make it
easier to change and maintain in the future. The emulator core was
rewritten to adhere to the released Bedrock specification (earlier
versions implemented an older prototype specification, which is no
longer relevant).
This commit also adds proper support for running multiple concurrent
Bedrock instances. This was previously supported in a limited manner
for the on-screen keyboard, but now works for any regular program as
well, with switching being performed by pressing the L or R bumper
buttons. This is disabled by default, as programs will still need to
be baked into the emulator and hand-loaded.
Diffstat (limited to 'arm9/source/devices/clock.h')
-rw-r--r-- | arm9/source/devices/clock.h | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/arm9/source/devices/clock.h b/arm9/source/devices/clock.h index 04c4d5d..4dc4b41 100644 --- a/arm9/source/devices/clock.h +++ b/arm9/source/devices/clock.h @@ -1,18 +1,24 @@ -#include <time.h> - #ifndef CLOCK_H_ #define CLOCK_H_ + #include <time.h> + #include "../bang.h" + + + // A 16-bit countdown timer. typedef struct { - u32 end; // real end time - u16 read, write; // read write caches + u32 end; // End time as an uptime value, zero if inactive + u16 read, write; // Read write caches for remaining duration } ClockTimer; + // Bedrock clock device. typedef struct { - ClockTimer t1, t2, t3, t4; // timers - u32 start; // uptime offset + ClockTimer t1, t2, t3, t4; // Timers + u16 uptime; // Read cache for uptime + u32 start; // Uptime offset } ClockDevice; + // Extract fields from a tm struct. #define YEAR(tm) (tm->tm_year - 100) #define MONTH(tm) (tm->tm_mon) #define DAY(tm) (tm->tm_mday - 1) @@ -20,16 +26,16 @@ #define MINUTE(tm) (tm->tm_min) #define SECOND(tm) (tm->tm_sec) - u32 get_uptime(void); - void uptime_handler(void); - void init_clock(void); + // Functions. + void init_nds_clock(void); struct tm* get_datetime(void); - bool check_timers(ClockDevice *clk); - - u8 get_timer_high(ClockTimer *t); - u8 get_timer_low( ClockTimer *t); - void set_timer_high(ClockTimer *t, u8 high); - void set_timer_low( ClockTimer *t, u8 low); + // Timer methods. + void timer_read(ClockTimer *timer); + void timer_write(ClockTimer *timer); + // Clock methods. + void clock_reset(ClockDevice *clock); + void clock_uptime_read(ClockDevice *clock); + bool clock_check_timers(ClockDevice *clock); #endif |