Hello all, been busy for the last few weeks. Hoping to get a bit more time for some teletype hacking.
Probably. There is a bunch of stuff in main.c which is part of the teletype algorithm rather than IO handling (which is all it should contain ideally).
I’d like scene_state_t to contain everything that tele_scene_t contains. The eventual plan is that the global variable scene_state will disappear entirely, it’s just there as shim to help with the transition. Then each function in teletype.h will accept a scene_state_t variable as it’s first argument. It will then be up to each implementation to decide how to instantiate this variable. So on the module we might go with a statically allocated global variable (this time in main.c rather than teletype.c), but the unit tests will probably stack allocate a new instance for each test run.
There are a few other things than need moving over too, like script running, currently that’s handled by main.c. Also, a lot of the data access needs to be wrapped in function calls so that we can make changes to the underlying data structure without have to change lots of source code.
The handler_KeyTimer function in main.c needs inverting and breaking up (if anyone wants to volunteer!), currently it’s key code then mode, rather than mode then key code. Also handler_ScreenRefresh needs breaking up too.
And there is still the list I posted above (I’ve started on some of it now though).
Truthfully it’s going to take me a while to do all that, if I ever finish it, so I’m trying to do things in such a way that I can stop and still leave things in a useful state.