[FEATURE] RTC clock implementation
Opened this issue · 1 comments
RichardBrown384 commented
Is your feature request related to a problem? Please describe.
It would be great if the RTC clock actually worked instead of returning zero.
Describe the solution you'd like
When RISC OS asks for the time it gets an approximation thereof.
Describe alternatives you've considered
N/A
Additional context
There are a few ways that have been considered to implement this problem
- Query the host for the time on each call. This has the problem that the emulator is running faster than
a real archimedes. This can lead to the situation where the archimedes has simulated 2ms of time but on the host only 900ns has elapsed - At the start of each frame sample the time from the host and then use CPU time events to drive the clock in the intervening time. This has the problem that the clock might roll back (e.g. we simulate 17ms of time in a 16ms frame, and resynchronising the clock will result in time jumping backwards).
- We sample the host clock on application start and use the CPU time events to drive the clock for the duration of the application run. This will guarantee a monotonic clock but it will eventually drift away from the host time.
RichardBrown384 commented
RISC OS 2 setting the date
11:14pm Sat, 8 October 1988
; c0 - 64 = 128 which according to the docs is part of the current year
; c1 - 64 = 129 which according to the docs is part of the current year
RTC8583 write to c0 (58) ; (88, remember this is hex)
RTC8583 write to c1 (13) ; (19, remember this is hex)
RTC8583 write to 01 (00) ; hundredths
RTC8583 write to 02 (12) ; seconds
RTC8583 write to 03 (14) ; minutes
RTC8583 write to 04 (23) ; hours (upper two bits am/pm control flags)
RTC8583 write to 05 (08) ; year/date (upper two bits are year)
RTC8583 write to 06 (10) ; weekdays/months (upper 3 bits are weekdays)
RTC8583 read from 01 (00)
RTC8583 read from c0 (58)
RTC8583 read from c1 (13)