Closed ivan-pi closed 1 year ago
I guess the signed int could also work (assuming wraparound behaviour), as long as the comparison is performed correctly:
if ((uint8_t) delay_timer > 0U)
delay_timer--;
I suppose the timer could be represented with anything really, but it needs to be able to perform up to 2^8 = 256 ticks before it stops changing.
Yes, interesting issue. And you're welcome! 😄
I'm not sure if this is a class of problem that many people struggle with. I haven't seen it happen often. I'm also not entirely sure how we would test this in a friendly way.
Do you have any suggestions?
First of all, thank you very much for these incredible tests!
I ran into the following issue with my CHIP-8 implementation. The timers were accidentally signed integers, meaning their range was from -128 to 127.
Since the timers were only decremented when
delay_timer > 0
, my interpreter would freeze any timeV[x]
contained a value larger than 127. (This happened for instance with the the5-quirks.ch8
test.)I'm not sure what would be the right way to catch this?