1
0
mirror of https://github.com/abakh/nbsdgames.git synced 2024-12-04 14:46:22 -05:00

Warnings, errors.

This commit is contained in:
Your Name 2021-01-06 04:08:00 +03:30
parent 181c1d74df
commit b443adf09b
4 changed files with 23 additions and 11 deletions

View File

@ -1,7 +1,9 @@
# -*- Makefile -*-
CFLAGS= -O3 --std=c99 -lncurses
CFLAGS= -O3 -lncurses -Wno-unused-result
#-O3 --std=c99 -lcurses -DNO_MOUSE for BSD curses
#adding --std=c99 makes warnings in GNU, and the blame is upon glibc feature test macros. my code is
all: jewels sudoku mines reversi checkers battleship rabbithole sos pipes fifteen memoblocks fisher muncher miketron redsquare
scorefiles:
touch /usr/games/pp_scores

View File

@ -76,6 +76,9 @@ Linux+xterm+tmux
Plan9
![Screenshot from the games in Plan9](https://raw.githubusercontent.com/abakh/nbsdgames/master/screenshot_plan9.png)
Windows
![Screenshot from the games in Windows 7](https://raw.githubusercontent.com/abakh/nbsdgames/master/screenshot_plan9.png)
## How to contribute
* Share these with your friends and others
* Your stars make the repo more findable in github :star:

View File

@ -26,25 +26,32 @@
//it seems there wasn't mouse support in original curses, and the variants
//developed it indepedently, use if mouse doesn't work in your variant (e.g. BSD curses)
#include <stdlib.h>
#include <unistd.h>
#ifdef __unix__
#define rand() random()
#define srand(x) srandom(x)
//At the time of writing, NetBSD's rand() is damn stupid.
//rand()%4 constantly gives 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3.
#endif
// It seems usleep is obsoleted in favor of nanosleep,
// and some POSIX implementations lack it. but i refuse
// to end using it! what the hell, filling a struct for
// something as trivial as sleeping 0.1 seconds??
// the function is written by Jens Staal for Plan9
int microsleep(long usec){
int second = usec/1000000;
long nano = usec*1000 - second*1000000;
struct timespec sleepy = {0};
sleepy.tv_sec = second;
sleepy.tv_nsec = nano;
nanosleep(&sleepy, (struct timespec *) NULL);
return 0;
}
#define usleep(x) microsleep(x)
#ifdef Plan9
int microsleep(long usec){
int second = usec/1000000;
long nano = usec*1000 - second*1000000;
struct timespec sleepy = {0};
sleepy.tv_sec = second;
sleepy.tv_nsec = nano;
nanosleep(&sleepy, (struct timespec *) NULL);
return 0;
}
#define usleep(x) microsleep(x)
#endif

BIN
screenshot_windows.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB