# HG changeset patch # User Laurens Holst # Date 1430768023 -7200 # Mon May 04 21:33:43 2015 +0200 # Node ID 94a126e3f17817ed28aabc314c4ba125a39cb71b # Parent 62ff055eb3038b7a4540d27005c3cabc9d7d63e7 System: Do not return values in the past from GetHighResTimerValue. If an interrupt would occur between reading the timer LSB and MSB, it could result in incorrect results. E.g. when the timer is 1FFH before the interrupt and it is 280H after, the value returned would be 180H and time would run backwards. With this fix, if the MSB between two reads differs, it always returns 0 as the LSB which must have been true somewhere between the MSB reads. diff --git a/src/System.asm b/src/System.asm --- a/src/System.asm +++ b/src/System.asm @@ -166,10 +166,11 @@ ld h,a in a,(0E6H) ld l,a - and a - ret m in a,(0E7H) + cp h + ret z ld h,a + ld l,0 ret System_Stop: