thomasokken / free42

Free42 : An HP-42S Calculator Simulator
https://thomasokken.com/free42/
GNU General Public License v2.0
280 stars 54 forks source link

Minimal documentation to study sources #51

Closed daitangio closed 1 year ago

daitangio commented 1 year ago

Hi, first of all thank you for writing free42! I am digging in the source code to study how it works, for my personal interest and to play a bit with the code. Can you give me some insight on how to implement a new "shell". I mean, as far as I can understand there is the core libraries, and then the gtk/android/windows versions implement a set of functions declared inside files called shell_*.h Where can I find some comment explaining the overall structure? I will be happy to produce a small markdown file to collect all the information I can find out. I only need some overview to start with. Thank you!

thomasokken commented 1 year ago

The most important files to look at are shell.h and core_main.h. The shell.h file declares the shell functions that are called by the core, and core_main.h declares the core functions that are called by the shell (and a few other things, after line 332).

There is no documentation on the core/shell interface beyond those two files, but it should be enough to get started. The architecture is pretty straightforward: the shell reports keystrokes to the core and the core responds by painting the display. The tricky parts are the behavior of keys that are held down, and how the core requests and yields the CPU when running programs.

I don't feel like writing documentation beyond what already exists. I think studying the GTK or Windows shells is the best way to get started, since they best reflect the original, purely procedural architecture.

I'll be happy to answer any questions, just contact me via email!