Index: init/init.c
===================================================================
--- init/init.c	(revision 854387b48c1405befa1109b49cef5c35e39767b3)
+++ init/init.c	(revision f25b73d69b88ecc993955369731abb88eb39810e)
@@ -45,5 +45,5 @@
 #include <ipc/fb.h>
 #include <async.h>
-#include <time.h>
+#include <sys/time.h>
 
 int a;
Index: libc/generic/time.c
===================================================================
--- libc/generic/time.c	(revision 854387b48c1405befa1109b49cef5c35e39767b3)
+++ libc/generic/time.c	(revision f25b73d69b88ecc993955369731abb88eb39810e)
@@ -27,5 +27,5 @@
  */ 
 
-#include <time.h>
+#include <sys/time.h>
 #include <unistd.h>
 #include <ipc/ipc.h>
Index: libc/include/async.h
===================================================================
--- libc/include/async.h	(revision 854387b48c1405befa1109b49cef5c35e39767b3)
+++ libc/include/async.h	(revision f25b73d69b88ecc993955369731abb88eb39810e)
@@ -4,5 +4,5 @@
 #include <ipc/ipc.h>
 #include <psthread.h>
-#include <time.h>
+#include <sys/time.h>
 
 typedef ipc_callid_t aid_t;
Index: libc/include/sys/time.h
===================================================================
--- libc/include/sys/time.h	(revision f25b73d69b88ecc993955369731abb88eb39810e)
+++ libc/include/sys/time.h	(revision f25b73d69b88ecc993955369731abb88eb39810e)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2006 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */ 
+
+#ifndef __libc_sys_TIME_H__
+#define __libc_sys_TIME_H__
+
+#include <types.h>
+
+#define DST_NONE 0
+
+typedef sysarg_t time_t;
+typedef sysarg_t suseconds_t;
+
+struct timeval {
+	time_t         tv_sec;        /* seconds */
+	suseconds_t    tv_usec;  /* microseconds */
+};
+
+struct timezone {
+	int  tz_minuteswest; /* minutes W of Greenwich */
+	int  tz_dsttime;     /* type of dst correction */
+};
+
+int gettimeofday(struct timeval *tv, struct timezone *tz);
+
+#endif
Index: libc/include/time.h
===================================================================
--- libc/include/time.h	(revision 854387b48c1405befa1109b49cef5c35e39767b3)
+++ libc/include/time.h	(revision f25b73d69b88ecc993955369731abb88eb39810e)
@@ -30,22 +30,3 @@
 #define __libc_TIME_H__
 
-#include <types.h>
-
-#define DST_NONE 0
-
-typedef sysarg_t time_t;
-typedef sysarg_t suseconds_t;
-
-struct timeval {
-	time_t         tv_sec;        /* seconds */
-	suseconds_t    tv_usec;  /* microseconds */
-};
-
-struct timezone {
-	int  tz_minuteswest; /* minutes W of Greenwich */
-	int  tz_dsttime;     /* type of dst correction */
-};
-
-int gettimeofday(struct timeval *tv, struct timezone *tz);
-
 #endif
Index: tetris/Makefile
===================================================================
--- tetris/Makefile	(revision 854387b48c1405befa1109b49cef5c35e39767b3)
+++ tetris/Makefile	(revision f25b73d69b88ecc993955369731abb88eb39810e)
@@ -1,18 +1,35 @@
-#	$OpenBSD: Makefile,v 1.7 2002/05/31 03:46:35 pjanzen Exp $
+LIBC_PREFIX = ../libc
+SOFTINT_PREFIX = ../softint
+include $(LIBC_PREFIX)/Makefile.toolchain
 
-PROG=	tetris
-SRCS=	input.c screen.c shapes.c scores.c tetris.c
-MAN=	tetris.6
-DPADD=	${LIBCURSES}
-LDADD=	-lcurses
-BINMODE=2555
+LIBS = $(LIBC_PREFIX)/libc.a
 
-beforeinstall:
-	@if [ ! -f ${DESTDIR}/var/games/tetris.scores ]; then \
-	    ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 664 \
-		/dev/null ${DESTDIR}/var/games/tetris.scores ; \
-	else \
-		true ; \
-	fi
+OUTPUT = tetris
+SOURCES = shapes.c tetris.c scores.c input.c screen.c
+OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
 
-.include <bsd.prog.mk>
+.PHONY: all clean depend disasm
+
+all: $(OUTPUT)
+
+-include Makefile.depend
+
+depend:
+	$(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
+
+$(OUTPUT): $(OBJECTS) $(LIBS)
+	$(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
+
+clean:
+	-rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend *.o
+disasm:
+	$(OBJDUMP) -d $(OUTPUT) >$(OUTPUT).disasm
+
+%.o: %.S
+	$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
+
+%.o: %.s
+	$(AS) $(AFLAGS) $< -o $@
+
+%.o: %.c
+	$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
Index: tetris/tetris.c
===================================================================
--- tetris/tetris.c	(revision 854387b48c1405befa1109b49cef5c35e39767b3)
+++ tetris/tetris.c	(revision f25b73d69b88ecc993955369731abb88eb39810e)
@@ -51,5 +51,5 @@
 
 #include <err.h>
-#include <signal.h>
+//#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -68,5 +68,5 @@
 long	fallrate;
 int	score;
-gid_t	gid, egid;
+//gid_t	gid, egid;
 char	key_msg[100];
 int	showpreview, classic;
@@ -166,45 +166,46 @@
 	keys = "jkl pq";
 
-	gid = getgid();
-	egid = getegid();
-	setegid(gid);
+//	gid = getgid();
+//	egid = getegid();
+//	setegid(gid);
 
 	classic = showpreview = 0;
-	while ((ch = getopt(argc, argv, "ck:l:ps")) != -1)
-		switch(ch) {
-		case 'c':
-			/*
-			 * this means:
-			 *	- rotate the other way;
-			 *	- no reverse video.
-			 */
-			classic = 1;
-			break;
-		case 'k':
-			if (strlen(keys = optarg) != 6)
-				usage();
-			break;
-		case 'l':
-			level = (int)strtonum(optarg, MINLEVEL, MAXLEVEL,
-			    &errstr);
-			if (errstr)
-				errx(1, "level must be from %d to %d",
-				    MINLEVEL, MAXLEVEL);
-			break;
-		case 'p':
-			showpreview = 1;
-			break;
-		case 's':
-			showscores(0);
-			exit(0);
-		default:
-			usage();
-		}
-
-	argc -= optind;
-	argv += optind;
-
-	if (argc)
-		usage();
+
+/* 	while ((ch = getopt(argc, argv, "ck:l:ps")) != -1) */
+/* 		switch(ch) { */
+/* 		case 'c': */
+/* 			/\* */
+/* 			 * this means: */
+/* 			 *	- rotate the other way; */
+/* 			 *	- no reverse video. */
+/* 			 *\/ */
+/* 			classic = 1; */
+/* 			break; */
+/* 		case 'k': */
+/* 			if (strlen(keys = optarg) != 6) */
+/* 				usage(); */
+/* 			break; */
+/* 		case 'l': */
+/* 			level = (int)strtonum(optarg, MINLEVEL, MAXLEVEL, */
+/* 			    &errstr); */
+/* 			if (errstr) */
+/* 				errx(1, "level must be from %d to %d", */
+/* 				    MINLEVEL, MAXLEVEL); */
+/* 			break; */
+/* 		case 'p': */
+/* 			showpreview = 1; */
+/* 			break; */
+/* 		case 's': */
+/* 			showscores(0); */
+/* 			exit(0); */
+/* 		default: */
+/* 			usage(); */
+/* 		} */
+
+/* 	argc -= optind; */
+/* 	argv += optind; */
+
+/* 	if (argc) */
+/* 		usage(); */
 
 	fallrate = 1000000 / level;
@@ -228,5 +229,5 @@
 		key_write[4], key_write[5]);
 
-	(void)signal(SIGINT, onintr);
+//	(void)signal(SIGINT, onintr);
 	scr_init();
 	setup_board();
@@ -358,11 +359,11 @@
 }
 
-void
-onintr(int signo)
-{
-	scr_clear();		/* XXX signal race */
-	scr_end();		/* XXX signal race */
-	_exit(0);
-}
+/* void */
+/* onintr(int signo) */
+/* { */
+/* 	scr_clear();		/\* XXX signal race *\/ */
+/* 	scr_end();		/\* XXX signal race *\/ */
+/* 	_exit(0); */
+/* } */
 
 void
Index: tetris/tetris.h
===================================================================
--- tetris/tetris.h	(revision 854387b48c1405befa1109b49cef5c35e39767b3)
+++ tetris/tetris.h	(revision f25b73d69b88ecc993955369731abb88eb39810e)
@@ -168,5 +168,5 @@
 
 extern int	score;		/* the obvious thing */
-extern gid_t	gid, egid;
+//extern gid_t	gid, egid;
 
 extern char	key_msg[100];
