While working on TI-Trek, I found that an event-based system made networking within the game a lot more stable. I began work on a custom event library, mostly to use within Trek, but the API is public and the library can be used by anyone who needs to implement events into their projects.

The source code/headers/lib file can be found here: https://github.com/acagliano/eventlib-ce/tree/stable with the latest version available for download from the Releases. Note that while it is tested, it is not tested extensively and may have some issues... please report them on the Github.

The API allows you to Register an event consisting of an event identifier, a callback function, and optional callback data. The callback data is passed by copy (via malloc) to ensure it is in scope at the time of the execution. The registration returns the slot id of the registered event so that in future you may delete or modify the slot if necessary. You can also enable and disable watching for particular events, trigger an event in code, purge all registrations of a certain event, and check for triggered events.

For a full API overview, see: https://acagliano.github.io/eventlib-ce/

Any suggestions, recommendations, or criticisms, feel free to comment.
This is a good thing to exist!

If I understand correctly, you use this by registering listeners that want to be notified of events asynchronously. Event generators then raise events with ev_Trigger() and events get processed when convenient with ev_HandleEvents(), which should be called in your idle loop.

It looks like there is no support for asynchronous polling, which would be necessary for simulating interrupts. This means that the main idle loop needs to handle polling for things like crystal timer events. It also means you can't have long-running event handlers or other long-running synchronous tasks because they'll block polling.

Where is the C source code that generated the assembly?
DrDnar wrote:

It looks like there is no support for asynchronous polling, which would be necessary for simulating interrupts. This means that the main idle loop needs to handle polling for things like crystal timer events. It also means you can't have long-running event handlers or other long-running synchronous tasks because they'll block polling.

Correct, this part I wasn't sure how to do, and given it's targetted for the Trek use-case, I didn't feel the need to add it. Someone who knows how to implement it is welcome to do so as a pull or a fork.

DrDnar wrote:
Where is the C source code that generated the assembly?

Checkout the `dev` branch.
This is very cool and I'm glad you were able to abstract it enough from your project so that others can use it too Smile.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement