]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - avr/background.c
Add memory commands (cmp, cp, md, mm, mw, nm)
[z180-stamp.git] / avr / background.c
diff --git a/avr/background.c b/avr/background.c
new file mode 100644 (file)
index 0000000..37e4b02
--- /dev/null
@@ -0,0 +1,31 @@
+#include "common.h"
+#include "background.h"
+
+
+#define BG_FUNC_MAX 5
+
+static bg_func func_tab[BG_FUNC_MAX];
+static int_fast8_t fcount;
+
+int bg_register(bg_func f)
+{
+       if (fcount < BG_FUNC_MAX) { 
+               func_tab[fcount++] = f;
+               return 1;
+       }
+       return 0;
+}
+
+
+void bg_shed(void)
+{
+       static int_fast8_t current;
+       
+       if (func_tab[current]) {
+               func_tab[current](0);
+       }
+       if (++current >= fcount)
+               current = 0;
+}
+
+