mirror of
https://github.com/abakh/nbsdgames.git
synced 2025-01-03 14:56:23 -05:00
fixed several compilation issues on Plan9
This commit is contained in:
parent
ca39c007d1
commit
25168f6d00
@ -21,7 +21,9 @@ compile with -lncurses
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef signed char byte;
|
typedef signed char byte;
|
||||||
|
#ifndef Plan9
|
||||||
byte size;
|
byte size;
|
||||||
|
#endif
|
||||||
byte py,px;
|
byte py,px;
|
||||||
byte ey,ex; //the empty tile
|
byte ey,ex; //the empty tile
|
||||||
chtype green=A_BOLD; //bold when there is no color
|
chtype green=A_BOLD; //bold when there is no color
|
||||||
@ -192,7 +194,9 @@ int main(int argc, char** argv){
|
|||||||
printf("Usage: %s [size]\n",argv[0]);
|
printf("Usage: %s [size]\n",argv[0]);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
#ifndef Plan9
|
||||||
size=atoi(argv[1]);
|
size=atoi(argv[1]);
|
||||||
|
#endif
|
||||||
if(size<3 || size>7){
|
if(size<3 || size>7){
|
||||||
fprintf(stderr,"3<=size<=7\n");
|
fprintf(stderr,"3<=size<=7\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#define HWID WID/2
|
#define HWID WID/2
|
||||||
|
|
||||||
#ifdef Plan9
|
#ifdef Plan9
|
||||||
#define usleep(1000x) sleep(x) /*milliseconds*/
|
#define usleep(x) sleep(x/1000000)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef signed char byte;
|
typedef signed char byte;
|
||||||
|
@ -23,7 +23,9 @@ compile with -lncurses
|
|||||||
|
|
||||||
typedef signed char byte;
|
typedef signed char byte;
|
||||||
typedef unsigned char ubyte;
|
typedef unsigned char ubyte;
|
||||||
|
#ifndef Plan9
|
||||||
byte size,size2;//size2 is there to avoid a lot of multiplications
|
byte size,size2;//size2 is there to avoid a lot of multiplications
|
||||||
|
#endif
|
||||||
byte py,px;
|
byte py,px;
|
||||||
byte fy,fx; //the first tile
|
byte fy,fx; //the first tile
|
||||||
chtype colors[6]={0};
|
chtype colors[6]={0};
|
||||||
@ -173,7 +175,9 @@ int main(int argc, char** argv){
|
|||||||
size=8;
|
size=8;
|
||||||
#endif
|
#endif
|
||||||
if(argc>=2){
|
if(argc>=2){
|
||||||
|
#ifndef Plan9
|
||||||
size=atoi(argv[1]);
|
size=atoi(argv[1]);
|
||||||
|
#endif
|
||||||
if(size<3 || size>19){
|
if(size<3 || size>19){
|
||||||
fprintf(stderr,"3<=size<=19\n");
|
fprintf(stderr,"3<=size<=19\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -28,6 +28,7 @@ compile with -lncurses
|
|||||||
#ifdef Plan9
|
#ifdef Plan9
|
||||||
#define len 10
|
#define len 10
|
||||||
#define wid 40
|
#define wid 40
|
||||||
|
#define usleep(x) sleep(x/1000000)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef signed char byte;
|
typedef signed char byte;
|
||||||
@ -353,7 +354,11 @@ int main(int argc, char** argv){
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if(argc==3){
|
if(argc==3){
|
||||||
|
#ifndef Plan9
|
||||||
bool lool = sscanf(argv[1],"%d",&len) && sscanf(argv[2],"%d",&wid);
|
bool lool = sscanf(argv[1],"%d",&len) && sscanf(argv[2],"%d",&wid);
|
||||||
|
#else
|
||||||
|
bool lool = sscanf(argv[1],"%d",len) && sscanf(argv[2],"%d",wid);
|
||||||
|
#endif
|
||||||
if(!lool){
|
if(!lool){
|
||||||
puts("Invalid input.");
|
puts("Invalid input.");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -24,7 +24,11 @@ compile with -lncurses
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef signed char byte;
|
typedef signed char byte;
|
||||||
|
#ifndef Plan9
|
||||||
int len,wid,py,px,flags;
|
int len,wid,py,px,flags;
|
||||||
|
#else
|
||||||
|
int py,px,flags;
|
||||||
|
#endif
|
||||||
int untouched;
|
int untouched;
|
||||||
int mscount;
|
int mscount;
|
||||||
chtype colors[6]={0};
|
chtype colors[6]={0};
|
||||||
@ -221,7 +225,11 @@ int main(int argc, char** argv){
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if(argc>=3){
|
if(argc>=3){
|
||||||
|
#ifndef Plan9
|
||||||
bool lool = sscanf(argv[1],"%d",&len) && sscanf(argv[2],"%d",&wid);
|
bool lool = sscanf(argv[1],"%d",&len) && sscanf(argv[2],"%d",&wid);
|
||||||
|
#else
|
||||||
|
bool lool = sscanf(argv[1],"%d",len) && sscanf(argv[2],"%d",wid);
|
||||||
|
#endif
|
||||||
if(!lool){
|
if(!lool){
|
||||||
puts("Invalid input.");
|
puts("Invalid input.");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -8,7 +8,7 @@ TARG=\
|
|||||||
fifteen \
|
fifteen \
|
||||||
fisher \
|
fisher \
|
||||||
jewels \
|
jewels \
|
||||||
memoblocks \
|
# memoblocks \
|
||||||
miketron \
|
miketron \
|
||||||
mines \
|
mines \
|
||||||
muncher \
|
muncher \
|
||||||
|
@ -26,10 +26,15 @@ compile with -lncurses
|
|||||||
#ifdef Plan9
|
#ifdef Plan9
|
||||||
#define len 10
|
#define len 10
|
||||||
#define wid 40
|
#define wid 40
|
||||||
|
#define usleep(x) sleep(x/1000000)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef signed char byte;
|
typedef signed char byte;
|
||||||
|
#ifndef Plan9
|
||||||
int len,wid,py,px;
|
int len,wid,py,px;
|
||||||
|
#else
|
||||||
|
int py,px;
|
||||||
|
#endif
|
||||||
int immunity;
|
int immunity;
|
||||||
byte direction;
|
byte direction;
|
||||||
long score;
|
long score;
|
||||||
@ -293,7 +298,11 @@ int main(int argc, char** argv){
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if(argc==3){
|
if(argc==3){
|
||||||
|
#ifndef Plan9
|
||||||
bool lool = sscanf(argv[1],"%d",&len) && sscanf(argv[2],"%d",&wid);
|
bool lool = sscanf(argv[1],"%d",&len) && sscanf(argv[2],"%d",&wid);
|
||||||
|
#else
|
||||||
|
bool lool = sscanf(argv[1],"%d",len) && sscanf(argv[2],"%d",wid);
|
||||||
|
#endif
|
||||||
if(!lool){
|
if(!lool){
|
||||||
puts("Invalid input.");
|
puts("Invalid input.");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
@ -309,6 +318,7 @@ int main(int argc, char** argv){
|
|||||||
}
|
}
|
||||||
initscr();
|
initscr();
|
||||||
if(autoset){
|
if(autoset){
|
||||||
|
#ifndef Plan9
|
||||||
len=LINES-7;
|
len=LINES-7;
|
||||||
if(len<MINLEN)
|
if(len<MINLEN)
|
||||||
len=MINLEN;
|
len=MINLEN;
|
||||||
@ -320,6 +330,7 @@ int main(int argc, char** argv){
|
|||||||
wid=MINWID;
|
wid=MINWID;
|
||||||
else if(wid>MAXWID)
|
else if(wid>MAXWID)
|
||||||
wid=MAXWID;
|
wid=MAXWID;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
srand(time(NULL)%UINT_MAX);
|
srand(time(NULL)%UINT_MAX);
|
||||||
byte board[len][wid];
|
byte board[len][wid];
|
||||||
|
@ -35,7 +35,11 @@ compile with -lncurses
|
|||||||
|
|
||||||
typedef signed char byte;
|
typedef signed char byte;
|
||||||
typedef unsigned char bitbox;
|
typedef unsigned char bitbox;
|
||||||
|
#ifndef Plan9
|
||||||
int len,wid,py,px,fy,fx;//p: pointer f: fluid
|
int len,wid,py,px,fy,fx;//p: pointer f: fluid
|
||||||
|
#else
|
||||||
|
int py,px,fy,fx;//p: pointer f: fluid
|
||||||
|
#endif
|
||||||
bitbox tocome[5]={0};//the row of pipes in the left side
|
bitbox tocome[5]={0};//the row of pipes in the left side
|
||||||
chtype green=A_BOLD;//will use bold font instead of green if colors are not available
|
chtype green=A_BOLD;//will use bold font instead of green if colors are not available
|
||||||
long score;
|
long score;
|
||||||
@ -356,7 +360,11 @@ int main(int argc, char** argv){
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if(argc==3){
|
if(argc==3){
|
||||||
|
#ifndef Plan9
|
||||||
bool lool = sscanf(argv[1],"%d",&len) && sscanf(argv[2],"%d",&wid);
|
bool lool = sscanf(argv[1],"%d",&len) && sscanf(argv[2],"%d",&wid);
|
||||||
|
#else
|
||||||
|
bool lool = sscanf(argv[1],"%d",len) && sscanf(argv[2],"%d",wid);
|
||||||
|
#endif
|
||||||
if(!lool){
|
if(!lool){
|
||||||
puts("Invalid input.");
|
puts("Invalid input.");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -29,7 +29,11 @@ compile with -lncurses
|
|||||||
|
|
||||||
typedef signed char byte;
|
typedef signed char byte;
|
||||||
typedef unsigned char bitbox;
|
typedef unsigned char bitbox;
|
||||||
|
#ifndef Plan9
|
||||||
int len,wid,py,px;
|
int len,wid,py,px;
|
||||||
|
#else
|
||||||
|
int py,px;
|
||||||
|
#endif
|
||||||
|
|
||||||
chtype colors[6]={0};
|
chtype colors[6]={0};
|
||||||
|
|
||||||
@ -185,7 +189,11 @@ int main(int argc, char** argv){
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if(argc==3){
|
if(argc==3){
|
||||||
|
#ifndef Plan9
|
||||||
bool lool = sscanf(argv[1],"%d",&len) && sscanf(argv[2],"%d",&wid);
|
bool lool = sscanf(argv[1],"%d",&len) && sscanf(argv[2],"%d",&wid);
|
||||||
|
#else
|
||||||
|
bool lool = sscanf(argv[1],"%d",len) && sscanf(argv[2],"%d",wid);
|
||||||
|
#endif
|
||||||
if(!lool){
|
if(!lool){
|
||||||
puts("Invalid input.");
|
puts("Invalid input.");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -22,7 +22,11 @@ compile with -lncurses
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef signed char byte;
|
typedef signed char byte;
|
||||||
|
#ifndef Plan9
|
||||||
int len,wid,py,px;
|
int len,wid,py,px;
|
||||||
|
#else
|
||||||
|
int py,px;
|
||||||
|
#endif
|
||||||
chtype colors[6]={A_BOLD};
|
chtype colors[6]={A_BOLD};
|
||||||
int score[2] ={0};
|
int score[2] ={0};
|
||||||
int computer[2]={0};
|
int computer[2]={0};
|
||||||
@ -250,7 +254,11 @@ int main(int argc, char** argv){
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if(argc>=3){
|
if(argc>=3){
|
||||||
|
#ifndef Plan9
|
||||||
bool lool = sscanf(argv[1],"%d",&len) && sscanf(argv[2],"%d",&wid);
|
bool lool = sscanf(argv[1],"%d",&len) && sscanf(argv[2],"%d",&wid);
|
||||||
|
#else
|
||||||
|
bool lool = sscanf(argv[1],"%d",len) && sscanf(argv[2],"%d",wid);
|
||||||
|
#endif
|
||||||
if(!lool){
|
if(!lool){
|
||||||
puts("Invalid input.");
|
puts("Invalid input.");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -26,7 +26,9 @@ NOTE: This program is only made for entertainment porpuses. The puzzles are gene
|
|||||||
|
|
||||||
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
|
||||||
|
#ifndef Plan9
|
||||||
byte size,s;//s=size*size
|
byte size,s;//s=size*size
|
||||||
|
#endif
|
||||||
byte py,px;
|
byte py,px;
|
||||||
byte diff;
|
byte diff;
|
||||||
unsigned int filled;
|
unsigned int filled;
|
||||||
@ -245,7 +247,9 @@ void mouseinput(int sy, int sx){
|
|||||||
getmouse(&m);
|
getmouse(&m);
|
||||||
#endif
|
#endif
|
||||||
if( m.y < (3+1+size+s)-sy && m.x<(2*s+1)-sx ){//it's a shame to include math.h only for round() but it was the only moral way to make gcc shut up
|
if( m.y < (3+1+size+s)-sy && m.x<(2*s+1)-sx ){//it's a shame to include math.h only for round() but it was the only moral way to make gcc shut up
|
||||||
|
#ifndef Plan9
|
||||||
py= round( (float)(size*(m.y-4-sy))/(size+1) );//these are derived from the formulas in draw() by simple algebra
|
py= round( (float)(size*(m.y-4-sy))/(size+1) );//these are derived from the formulas in draw() by simple algebra
|
||||||
|
#endif
|
||||||
px=(m.x-1-sx)/2;
|
px=(m.x-1-sx)/2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -317,8 +321,10 @@ int main(int argc,char** argv){
|
|||||||
printf("2 <= size <= 7\n");
|
printf("2 <= size <= 7\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
#ifndef Plan9
|
||||||
else
|
else
|
||||||
size = *argv[1]-'0';
|
size = *argv[1]-'0';
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#ifndef Plan9
|
#ifndef Plan9
|
||||||
|
Loading…
Reference in New Issue
Block a user