upd7810: fix and improve timer/event counter