Right this bug wasn’t too bad, but a bit obscure. Consider the following statements in live mode (this might be a bit beyond you if you don’t understand the theory behind the Teletype’s programming language):
X 5
Y 7
X; Y
One would expect that the final statement will just print out the value of Y. In fact nothing is displayed and the value of Y has changed to 5!
What’s happening is that first sub command X; adds the value 5 to the command stack, the second sub command Y, sees that there is a single value on the command stack and assumes that it should set the value of Y to it, rather than retrieve the current value of Y.
The solution is fairly straightforward, just reset the command stack between sub commands.
Next up the far more annoying bug, which caused @trickyflemming’s weird scrolling bug, amongst many other weird things. See here for the technical details.
@tehn and @zebra I’ve added -fno-common to the compiler flags to catch ambiguous declarations (i.e. global variables where the compiler is trying to infer if they should be extern or static). These leads to errors with the following variables:
init_teletype.h
I propose the following change to make them both static in init_teletype.c only. (The same issue also in init_ansible.h and init_trilogy.h.)
--- a/src/init_teletype.h
+++ b/src/init_teletype.h
@@ -4,8 +4,4 @@
#include "types.h"
-// global count of uptime, and overflow flag.
-volatile u64 tcTicks;
-volatile u8 tcOverflow;
-
extern void register_interrupts(void);
extern void init_gpio(void);
--- a/src/init_teletype.c
+++ b/src/init_teletype.c
@@ -23,6 +23,6 @@
//----- variables
// timer tick counter
-volatile u64 tcTicks = 0;
-volatile u8 tcOverflow = 0;
+static volatile u64 tcTicks = 0;
+static volatile u8 tcOverflow = 0;
static const u64 tcMax = (U64)0x7fffffff;
static const u64 tcMaxInv = (u64)0x10000000;
kbd.h
Again, I propose to make it static in kbd.c.
--- a/src/kbd.h
+++ b/src/kbd.h
@@ -50,6 +50,4 @@
-s8 old_frame[8];
-
extern u8 hid_to_ascii_raw(u8 data);
extern u8 hid_to_ascii(u8 data, u8 mod);
--- a/src/kbd.c
+++ b/src/kbd.c
@@ -4,4 +4,5 @@
#include "kbd.h"
+static s8 old_frame[8];
bool frame_compare(u8 data) {
edit 2017-04-22: I’ve made these changes on my libavr32 branch. I will post a PR soonish.