Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

TOTP without a real time clock is ambitious :)


(author) The CIA TOD clock is okay for this. It uses wall mains voltage, so it's about as accurate as your average office clock. You can use a CMD-compatible device to seed the time; I'll be adding Ultimate-II+ support as soon as it's off backorder.


>about as accurate as your average office clock

That's underselling it, mains frequency is deliberately controlled to keep average frequency very accurately in long-term periods.


Right, but this uses a 30-second period, which could be affected by smaller variations. In this case the use of the TOD is unavoidable because if I used the Timer A interrupt (50Hz or 60Hz depending on video standard), it would be slowed when interrupts were disabled for doing BCD calculations - the C64's IRQ routine at $ea31 can't handle the situation if an IRQ occurs while decimal mode is on. This is a known Kernal bug. I suppose I could hack around that but this was simpler.


Do you need to configure the Hz? Otherwise it'll run faster in the USA va Europe.


(author) Yes, it accounts for 50Hz vs 60Hz, see https://github.com/classilla/totp-c64/blob/main/totp.xa#L129 . Basically it uses the other CIA as a cycle counter to see how many cycles elapse between TOD ticks, and then adjusts accordingly (from https://codebase64.org/doku.php?id=base:efficient_tod_initia... ).


See here: http://codebase64.org/doku.php?id=base:initialize_tod_clock_...

I don’t understand it completely, so would appreciate an explanation.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: