diff options
| author | Miguel <m.i@gmx.at> | 2018-09-02 03:53:32 +0200 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2018-09-02 03:53:32 +0200 |
| commit | ab6b44f5197e4c6c19f225f909035385d37883b4 (patch) | |
| tree | 2c07e5bc65cf8e19a6433a7c0c5135eabb56a59c /userspace/snake2.c | |
| parent | c459fab7662eaf45df9994c828065b9fc8d4a8ac (diff) | |
foolsnake showcasing multithreading and our console
Diffstat (limited to 'userspace/snake2.c')
| -rw-r--r-- | userspace/snake2.c | 55 |
1 files changed, 55 insertions, 0 deletions
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; + } + } + +} |
