mirror of
https://github.com/abakh/nbsdgames.git
synced 2025-06-30 22:19:58 -04:00
trying to fix plan9 compile for all nbsdgames with ifdefs
This commit is contained in:
parent
d7463823d6
commit
ca39c007d1
@ -14,6 +14,12 @@ No rights are reserved and this software comes with no warranties of any kind to
|
|||||||
|
|
||||||
compile with -lncurses
|
compile with -lncurses
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* The Plan9 compiler can not handle VLAs */
|
||||||
|
#ifdef Plan9
|
||||||
|
#define size 4
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef signed char byte;
|
typedef signed char byte;
|
||||||
byte size;
|
byte size;
|
||||||
byte py,px;
|
byte py,px;
|
||||||
@ -178,7 +184,9 @@ void gameplay(void){
|
|||||||
erase();
|
erase();
|
||||||
}
|
}
|
||||||
int main(int argc, char** argv){
|
int main(int argc, char** argv){
|
||||||
|
#ifndef Plan9
|
||||||
size=4;
|
size=4;
|
||||||
|
#endif
|
||||||
if(argc==2){
|
if(argc==2){
|
||||||
if(!strcmp("help",argv[1])){
|
if(!strcmp("help",argv[1])){
|
||||||
printf("Usage: %s [size]\n",argv[0]);
|
printf("Usage: %s [size]\n",argv[0]);
|
||||||
|
@ -14,6 +14,11 @@
|
|||||||
#define HLEN LEN/2
|
#define HLEN LEN/2
|
||||||
#define WID 80
|
#define WID 80
|
||||||
#define HWID WID/2
|
#define HWID WID/2
|
||||||
|
|
||||||
|
#ifdef Plan9
|
||||||
|
#define usleep(1000x) sleep(x) /*milliseconds*/
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef signed char byte;
|
typedef signed char byte;
|
||||||
chtype colors[4]={A_NORMAL,A_STANDOUT};
|
chtype colors[4]={A_NORMAL,A_STANDOUT};
|
||||||
byte fish[10]={0};//positions
|
byte fish[10]={0};//positions
|
||||||
@ -394,7 +399,7 @@ void main(void){
|
|||||||
if(!hooknum)
|
if(!hooknum)
|
||||||
break;
|
break;
|
||||||
if(input!=ERR){
|
if(input!=ERR){
|
||||||
sleep(1);
|
usleep(100000);
|
||||||
flushinp();
|
flushinp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,13 @@ No rights are reserved and this software comes with no warranties of any kind to
|
|||||||
|
|
||||||
compile with -lncurses
|
compile with -lncurses
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* The Plan9 compiler can not handle VLAs */
|
||||||
|
#ifdef Plan9
|
||||||
|
#define size 8
|
||||||
|
#define size2 16
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef signed char byte;
|
typedef signed char byte;
|
||||||
typedef unsigned char ubyte;
|
typedef unsigned char ubyte;
|
||||||
byte size,size2;//size2 is there to avoid a lot of multiplications
|
byte size,size2;//size2 is there to avoid a lot of multiplications
|
||||||
@ -162,7 +169,9 @@ void gameplay(void){
|
|||||||
erase();
|
erase();
|
||||||
}
|
}
|
||||||
int main(int argc, char** argv){
|
int main(int argc, char** argv){
|
||||||
|
#ifndef Plan9
|
||||||
size=8;
|
size=8;
|
||||||
|
#endif
|
||||||
if(argc>=2){
|
if(argc>=2){
|
||||||
size=atoi(argv[1]);
|
size=atoi(argv[1]);
|
||||||
if(size<3 || size>19){
|
if(size<3 || size>19){
|
||||||
@ -199,8 +208,10 @@ int main(int argc, char** argv){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(size>8)//big sizes depend on color display
|
else if(size>8)//big sizes depend on color display
|
||||||
|
#ifndef Plan9
|
||||||
size=8;
|
size=8;
|
||||||
size2=size*2;
|
size2=size*2;
|
||||||
|
#endif
|
||||||
chtype board[size][size2];
|
chtype board[size][size2];
|
||||||
bool show[size][size2];
|
bool show[size][size2];
|
||||||
int input;
|
int input;
|
||||||
|
@ -23,6 +23,13 @@ No rights are reserved and this software comes with no warranties of any kind to
|
|||||||
|
|
||||||
compile with -lncurses
|
compile with -lncurses
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* The Plan9 compiler can not handle VLAs */
|
||||||
|
#ifdef Plan9
|
||||||
|
#define len 10
|
||||||
|
#define wid 40
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef signed char byte;
|
typedef signed char byte;
|
||||||
int len,wid,py,px;
|
int len,wid,py,px;
|
||||||
int immunity,flight,notrail;
|
int immunity,flight,notrail;
|
||||||
|
@ -16,6 +16,13 @@ No rights are reserved and this software comes with no warranties of any kind to
|
|||||||
|
|
||||||
compile with -lncurses
|
compile with -lncurses
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* The Plan9 compiler can not handle VLAs */
|
||||||
|
#ifdef Plan9
|
||||||
|
#define len 8
|
||||||
|
#define wid 8
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef signed char byte;
|
typedef signed char byte;
|
||||||
int len,wid,py,px,flags;
|
int len,wid,py,px,flags;
|
||||||
int untouched;
|
int untouched;
|
||||||
@ -226,7 +233,9 @@ int main(int argc, char** argv){
|
|||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#ifndef Plan9
|
||||||
len=wid=8;
|
len=wid=8;
|
||||||
|
#endif
|
||||||
if(argc==4){
|
if(argc==4){
|
||||||
if( !sscanf(argv[3],"%d",&mscount)){
|
if( !sscanf(argv[3],"%d",&mscount)){
|
||||||
puts("Invalid input.");
|
puts("Invalid input.");
|
||||||
|
@ -5,19 +5,19 @@ APE=/sys/src/ape
|
|||||||
TARG=\
|
TARG=\
|
||||||
battleship \
|
battleship \
|
||||||
checkers \
|
checkers \
|
||||||
# fifteen \
|
fifteen \
|
||||||
fisher \
|
fisher \
|
||||||
jewels \
|
jewels \
|
||||||
# memoblocks \
|
memoblocks \
|
||||||
# miketron \
|
miketron \
|
||||||
# mines \
|
mines \
|
||||||
# muncher \
|
muncher \
|
||||||
# pipes \
|
pipes \
|
||||||
# rabbithole \
|
rabbithole \
|
||||||
redsquare \
|
redsquare \
|
||||||
reversi \
|
reversi \
|
||||||
# sos \
|
sos \
|
||||||
# sudoku
|
sudoku
|
||||||
|
|
||||||
BIN=/$objtype/bin/games
|
BIN=/$objtype/bin/games
|
||||||
|
|
||||||
@ -27,6 +27,7 @@ UPDATE=\
|
|||||||
|
|
||||||
</sys/src/cmd/mkmany
|
</sys/src/cmd/mkmany
|
||||||
|
|
||||||
|
#function draw() conflicts with libdraw
|
||||||
CFLAGS= -c -D_POSIX_SOURCE -D_BSD_EXTENSION -DPlan9 -Ddraw=nb_draw
|
CFLAGS= -c -D_POSIX_SOURCE -D_BSD_EXTENSION -DPlan9 -Ddraw=nb_draw
|
||||||
|
|
||||||
$O.out: /$objtype/lib/ape/libcurses.a
|
$O.out: /$objtype/lib/ape/libcurses.a
|
||||||
|
@ -21,6 +21,13 @@ No rights are reserved and this software comes with no warranties of any kind to
|
|||||||
|
|
||||||
compile with -lncurses
|
compile with -lncurses
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* The Plan9 compiler can not handle VLAs */
|
||||||
|
#ifdef Plan9
|
||||||
|
#define len 10
|
||||||
|
#define wid 40
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef signed char byte;
|
typedef signed char byte;
|
||||||
int len,wid,py,px;
|
int len,wid,py,px;
|
||||||
int immunity;
|
int immunity;
|
||||||
|
@ -26,6 +26,13 @@ No rights are reserved and this software comes with no warranties of any kind to
|
|||||||
|
|
||||||
compile with -lncurses
|
compile with -lncurses
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* The Plan9 compiler can not handle VLAs */
|
||||||
|
#ifdef Plan9
|
||||||
|
#define wid 20
|
||||||
|
#define len 14
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef signed char byte;
|
typedef signed char byte;
|
||||||
typedef unsigned char bitbox;
|
typedef unsigned char bitbox;
|
||||||
int len,wid,py,px,fy,fx;//p: pointer f: fluid
|
int len,wid,py,px,fy,fx;//p: pointer f: fluid
|
||||||
@ -361,8 +368,10 @@ int main(int argc, char** argv){
|
|||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
#ifndef Plan9
|
||||||
wid=20;
|
wid=20;
|
||||||
len=14;
|
len=14;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
initscr();
|
initscr();
|
||||||
mousemask(ALL_MOUSE_EVENTS,NULL);
|
mousemask(ALL_MOUSE_EVENTS,NULL);
|
||||||
|
@ -20,6 +20,13 @@ No rights are reserved and this software comes with no warranties of any kind to
|
|||||||
|
|
||||||
compile with -lncurses
|
compile with -lncurses
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* The Plan9 compiler can not handle VLAs */
|
||||||
|
#ifdef Plan9
|
||||||
|
#define len 10
|
||||||
|
#define wid 20
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef signed char byte;
|
typedef signed char byte;
|
||||||
typedef unsigned char bitbox;
|
typedef unsigned char bitbox;
|
||||||
int len,wid,py,px;
|
int len,wid,py,px;
|
||||||
@ -193,6 +200,7 @@ int main(int argc, char** argv){
|
|||||||
autoset=1;
|
autoset=1;
|
||||||
}
|
}
|
||||||
initscr();
|
initscr();
|
||||||
|
#ifndef Plan9
|
||||||
if(autoset){
|
if(autoset){
|
||||||
if((LINES-7)/2 < 10)
|
if((LINES-7)/2 < 10)
|
||||||
len=10;
|
len=10;
|
||||||
@ -204,6 +212,7 @@ int main(int argc, char** argv){
|
|||||||
else
|
else
|
||||||
wid=(COLS-5)/2;
|
wid=(COLS-5)/2;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
int carrot_count= (len*wid)/50;
|
int carrot_count= (len*wid)/50;
|
||||||
int carrots_found;
|
int carrots_found;
|
||||||
time_t tstart , now, giventime=len*wid/5;
|
time_t tstart , now, giventime=len*wid/5;
|
||||||
|
@ -15,6 +15,12 @@ No rights are reserved and this software comes with no warranties of any kind to
|
|||||||
|
|
||||||
compile with -lncurses
|
compile with -lncurses
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef Plan9
|
||||||
|
#define len 5
|
||||||
|
#define wid 6
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef signed char byte;
|
typedef signed char byte;
|
||||||
int len,wid,py,px;
|
int len,wid,py,px;
|
||||||
chtype colors[6]={A_BOLD};
|
chtype colors[6]={A_BOLD};
|
||||||
@ -256,8 +262,10 @@ int main(int argc, char** argv){
|
|||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
#ifndef Plan9
|
||||||
len=5;
|
len=5;
|
||||||
wid=6;
|
wid=6;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if(argc==4){
|
if(argc==4){
|
||||||
if( !sscanf(argv[3],"%d",&dpt)){
|
if( !sscanf(argv[3],"%d",&dpt)){
|
||||||
|
@ -17,6 +17,13 @@ compile with -lncurses
|
|||||||
|
|
||||||
NOTE: This program is only made for entertainment porpuses. The puzzles are generated by randomly clearing tiles on the table and are guaranteed to have a solution , but are not guaranteed to have only one unique solution.
|
NOTE: This program is only made for entertainment porpuses. The puzzles are generated by randomly clearing tiles on the table and are guaranteed to have a solution , but are not guaranteed to have only one unique solution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* the Plan9 compiler can not handle VLAs */
|
||||||
|
#if defined Plan9
|
||||||
|
#define size 3
|
||||||
|
#define s 9
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef signed char byte;
|
typedef signed char byte;
|
||||||
byte _wait=0, waitcycles=0;//apparently 'wait' conflicts with a variable in a library macOS includes by default
|
byte _wait=0, waitcycles=0;//apparently 'wait' conflicts with a variable in a library macOS includes by default
|
||||||
byte size,s;//s=size*size
|
byte size,s;//s=size*size
|
||||||
@ -314,7 +321,9 @@ int main(int argc,char** argv){
|
|||||||
size = *argv[1]-'0';
|
size = *argv[1]-'0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#ifndef Plan9
|
||||||
size=3;
|
size=3;
|
||||||
|
#endif
|
||||||
if(argc>2){
|
if(argc>2){
|
||||||
if (strlen(argv[2])>1 || argv[2][0]-'0'>4 || argv[2][0]-'0'<= 0 ){
|
if (strlen(argv[2])>1 || argv[2][0]-'0'>4 || argv[2][0]-'0'<= 0 ){
|
||||||
printf("1 <= diff <=4\n");
|
printf("1 <= diff <=4\n");
|
||||||
@ -345,7 +354,9 @@ int main(int argc,char** argv){
|
|||||||
colors[b]=COLOR_PAIR(b+1);
|
colors[b]=COLOR_PAIR(b+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifndef Plan9
|
||||||
s= size*size;
|
s= size*size;
|
||||||
|
#endif
|
||||||
char board[s][s];
|
char board[s][s];
|
||||||
char empty[s][s];
|
char empty[s][s];
|
||||||
char game[s][s];
|
char game[s][s];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user