laoo Posted January 28 Share Posted January 28 (edited) Sorry for the clickbait title, but what I've found is hard to explain in a title. I don't actually know whether it's genuinely unknown feature, but I haven't read about it in the docs and author of Handy haven't read about it too, so I suspect it's something new. tl;dr: When enabling linking of two timers with higher timer triggering an interrupt and with no reloading, after counter underflows the interrupt is being triggered at each borrow. When using timer without reloading, after counter underflows the interrupt is being triggered at each timer cycle (i.e. decrement try, or borrow from linked timer). Long version: I've wrote a VGM player on Lynx that unintentionally worked on real hardware but did not on Handy nor Felix. I've looked at it with @42bs few days back and found that the initial bug causing Handy to hang wasn't really a bug in the player but a bug in Handy. The player is interrupt driven and new interrupt is being issued each time previous interrupt triggered. I just needed initial interrupt to get started so the player just writes a value to INTSET that should manually trigger an interrupt. It just seems to not work in Handy. But the fun part begins later as the player still did not work on any emulator. After further investigation I've discovered a bug that in one specific place the player did not reissue the next interrupt. No interrupt - no playback. Emulators did the right thing. But the hardware played along anyways. I came up with an hypothesis. I've wrote a piece of software to test it and it confirmed. Emulators behave differently than the real hardware. The test program at each VBL is setting timer5 and timer7 as follows: TIMER7_COUNT = 50; TIMER7_CONTROLA = ENABLE_INT|RESET_DONE|ENABLE_COUNT|AUD_LINKING; TIMER5_BACKUP = 158; TIMER5_CONTROLA = ENABLE_RELOAD|ENABLE_COUNT|AUD_1; Timer5 is counting lines. Just like HCOUNT. It's linked to Timer7 that has no reload (so no backup just count) and triggers an interrupt after finish and is initially set to 50 (about half of the screen). I XOR the green0 color with 15 after timer7 interrupt and reset it to zero at VBL. As you may have guessed it does not behave like this: But rather like this: TIMER_DONE does not prevent triggering an interrupt after borrow from previous timer and the interrupt is being triggered each time the previous timer underflows. That's it. That's the mystery. A minor thing, but a thing. I'll just incorporate the fix into the Felix UPDATE After more experiments it turned out that linking is not necessary. Only one timer without reload is enough to observe this phenomenon. @MicheleS found that it's even documented TimerDone.lyx Edited January 29 by laoo 1 1 Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.