summaryrefslogtreecommitdiff
path: root/userspace
diff options
context:
space:
mode:
Diffstat (limited to 'userspace')
-rw-r--r--userspace/err.c2
-rw-r--r--userspace/snake2.c55
2 files changed, 56 insertions, 1 deletions
diff --git a/userspace/err.c b/userspace/err.c
index 7a33e69..8e5d819 100644
--- a/userspace/err.c
+++ b/userspace/err.c
@@ -1,6 +1,6 @@
#include <stdio.h>
-int main()
+int main(int argc, char **argv)
{
char buf[]="This is a line written to stderr.\n";
int l=fwrite(buf,sizeof(char),strlen(buf),stderr); // write stderr;
diff --git a/userspace/snake2.c b/userspace/snake2.c
new file mode 100644
index 0000000..78be50d
--- /dev/null
+++ b/userspace/snake2.c
@@ -0,0 +1,55 @@
+#include <stdio.h>
+
+int data4[100];
+
+// syscall will be move to newlib?
+#define SYSCALL_CLONE 83
+
+int _clone(void)
+{
+ return syscall(SYSCALL_CLONE,0,0,0);
+}
+
+static char lastc='d';
+
+int main()
+{
+ printf("setvbuf returned %i\n",setvbuf(stdin,NULL,_IONBF,0));
+ printf("setvbuf returned %i\n",setvbuf(stdout,NULL,_IONBF,0));
+
+ printf("\033c");
+ printf("\033HFOOL-SNAKE");
+ //printf("\033d\033d\033dFOOL-SNAKE");
+ printf("\033d");
+ char snake[]="FOOLSNAKESFOOL";
+
+ int thr=_clone();
+ if(thr==0)
+ {
+ uint64_t x=0;
+
+ while(1)
+ {
+ for(int i=0;i<10000000;i++);
+
+ x++;
+ if(lastc=='d')printf("\033f");
+ if(lastc=='a')printf("\033b");
+ if(lastc=='w')printf("\033u");
+ if(lastc=='s')printf("\033d");
+
+ printf("\033[0;%im\033b%c",31+(uint8_t)(x%6),snake[x%10]);
+
+ }
+
+ }
+ else
+ {
+ while(1)
+ {
+ char c=fgetc(stdin);
+ lastc=c;
+ }
+ }
+
+}