dol: initial dol commit
[jump.git] / dol / examples / examplecell / src / generator.c
diff --git a/dol/examples/examplecell/src/generator.c b/dol/examples/examplecell/src/generator.c
new file mode 100644 (file)
index 0000000..237f54e
--- /dev/null
@@ -0,0 +1,23 @@
+#include <stdio.h>
+
+#include "generator.h"
+
+void generator_init(DOLProcess *p) {
+    sprintf(p->local->name, "generator");
+    p->local->index = 0;
+    p->local->len = LENGTH;
+}
+
+int generator_fire(DOLProcess *p) {
+    if (p->local->index < p->local->len) {
+        p->local->x = (float)p->local->index;
+        DOL_write((void*)PORT_OUT, &p->local->x, sizeof(float), p);
+        p->local->index++;
+    } else {
+        DOL_detach(p);
+        return -1;
+    }
+
+    return 0;
+}
+