Next, we want to make programming mode useable. It should display the program memory when we’re in programming mode, not the stack and memory registers. It will also display more valid keys, but that code was already in place, it just happened automatically when we entered programming mode.
The HP-67 calculator doesn’t have a key to press to enter programming mode. Instead, it has a slider that switches between interactive and programming modes. The Curses CLI needs a key definition for this operation, as anything the user can do will be through logical keypresses. So, we’ve defined a key for that, with a location that is not part of the normal calculator keypad. You’ll note that we haven’t actually defined a key yet for the reverse operation, but we will get to that soon.
With the latest changes, keypresses entered in program mode are stored into program memory, and not executed. They are then available for display in the UI. Here is a screenshot of this behaviour:
This is a program that, when “gosub A” is executed, adds 10 to X and stores the result in memory register 4. It then returns to the calling context.
The current version of the code can be found in the git repository under the tag v2014-12-14.