From fbbbc75200008e2b603e5b7df8cd2e1a5d17483b Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Sun, 24 May 2015 03:32:14 +0200 Subject: syscalls and terminal functionality for GAMING mode --- userspace/snake.c | 16 ++++++++++++++-- userspace/sys/libfool.a | Bin 35776 -> 37292 bytes userspace/sys/syscalls.c | 12 ++++++++++++ userspace/sys/syscalls.o | Bin 17092 -> 18572 bytes 4 files changed, 26 insertions(+), 2 deletions(-) (limited to 'userspace') diff --git a/userspace/snake.c b/userspace/snake.c index aedf191..8352d1b 100644 --- a/userspace/snake.c +++ b/userspace/snake.c @@ -3,11 +3,23 @@ int main() { printf("Hello I am FoolSnake 0.1\n"); - printf("setvbuf returned %i",setvbuf(stdin,NULL,_IONBF,0)); + printf("setvbuf returned %i\n",setvbuf(stdin,NULL,_IONBF,0)); + + fool_tune(1,0,0); // activate gaming mode while(1) { - printf("%c",fgetc(stdin)); + while(!has_data_waiting()) + { + + } + + char c=fgetc(stdin); + printf("[%c]\n",c); + if(c=='q')break; + } + + fool_tune(0,0,0); // de-activate gaming mode } diff --git a/userspace/sys/libfool.a b/userspace/sys/libfool.a index 7c47ee4..81a4f16 100644 Binary files a/userspace/sys/libfool.a and b/userspace/sys/libfool.a differ diff --git a/userspace/sys/syscalls.c b/userspace/sys/syscalls.c index 9dfd313..4b29451 100644 --- a/userspace/sys/syscalls.c +++ b/userspace/sys/syscalls.c @@ -35,6 +35,18 @@ int readdir(const char *name,fs_dirent *dirs,int max) return syscall(SYSCALL_READDIR,name,dirs,max); } +int has_data_waiting() +{ + + return syscall(SYSCALL_HAS_DATA,0,0,0); +} + +int fool_tune(int v1, int v2, int v3) +{ + + return syscall(SYSCALL_TUNE,v1,v2,v3); +} + void _exit(int ret) { _exit2(ret,environ); diff --git a/userspace/sys/syscalls.o b/userspace/sys/syscalls.o index 2176036..f8fd94b 100644 Binary files a/userspace/sys/syscalls.o and b/userspace/sys/syscalls.o differ -- cgit v1.2.3