Skip to content

Commit

Permalink
Makefile in root dir, executable in bin, and clean up warnings.
Browse files Browse the repository at this point in the history
--HG--
rename : src/Makefile => Makefile
  • Loading branch information
cpressey committed Sep 5, 2014
1 parent db20a14 commit f92643e
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,2 +1,2 @@
src/rube
bin
*.o
5 changes: 1 addition & 4 deletions .hgignore
@@ -1,7 +1,4 @@
syntax: regexp

^src/rube

syntax: glob

bin
*.o
44 changes: 44 additions & 0 deletions Makefile
@@ -0,0 +1,44 @@
# GNU Makefile for RUBE.

PROG=bin/rube$(EXE)
CC?=gcc
O?=.o
EXE?=

WARNS= -W -Wall -Wstrict-prototypes -Wmissing-prototypes \
-Wpointer-arith -Wno-uninitialized -Wreturn-type -Wcast-qual \
-Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wchar-subscripts \
-Winline -Wnested-externs -Wredundant-decls

ifdef ANSI
CFLAGS+= -ansi -pedantic -D_BSD_SOURCE
else
CFLAGS+= -std=c99 -D_POSIX_C_SOURCE=200809L
endif

CFLAGS+= ${WARNS} ${EXTRA_CFLAGS}

ifdef DEBUG
CFLAGS+= -g
endif

OBJ=src/rube$(O)
OBJS=$(OBJ)

all: $(PROG)

bin/.exists:
mkdir -p bin
touch bin/.exists

$(PROG): bin/.exists $(OBJS)
$(CC) $(OBJS) -o $(PROG) $(LIBS)

$(OBJ): src/rube.c
$(CC) $(CFLAGS) -c src/rube.c -o $(OBJ)

clean:
rm -f $(OBJS)

distclean:
rm -f $(PROG)
32 changes: 0 additions & 32 deletions src/Makefile

This file was deleted.

67 changes: 31 additions & 36 deletions src/rube.c
Expand Up @@ -51,6 +51,8 @@
#include <time.h>
#if __BORLANDC__
#include <dos.h>
#else
#include <unistd.h>
#endif
#ifdef _POSIX_C_SOURCE
#include <sys/time.h>
Expand All @@ -65,44 +67,39 @@
#define SCREENHEIGHT 22

#define nex pg2[y * LINEWIDTH + x].c
#define nexv pg2[y * LINEWIDTH + x].v
#define nexd(dx,dy) pg2[(y+dy) * LINEWIDTH + (x+dx)].c

#define shrink(s) s[strlen(s)-1]=0

typedef struct cellstruct
{
char c;
signed long int v;
} cell;

/*************************************************** GLOBAL VARIABLES */

cell pg[LINEWIDTH * PAGEHEIGHT]; /* playfield */
cell pg2[LINEWIDTH * PAGEHEIGHT];/* playfield' */

cell *head = NULL;
static cell pg[LINEWIDTH * PAGEHEIGHT]; /* playfield */
static cell pg2[LINEWIDTH * PAGEHEIGHT];/* playfield' */

int x = 0, y = 0; /* x and y looping */
int dx = 1, dy = 0; /* direction of looping */
int debug = 1; /* flag: display ANSI debugging? */
int interactive = 0; /* flag: ask for input each frame? */
int deldur = 0; /* debugging delay in milliseconds */
int debskip = 1; /* frame skip in debug view */
int debopos = 1; /* output column in debugger */
int frame = 1;
int quiet = 0;
static int x = 0, y = 0; /* x and y looping */
static int debug = 1; /* flag: display ANSI debugging? */
static int interactive = 0; /* flag: ask for input each frame? */
static int deldur = 0; /* debugging delay in milliseconds */
static int debskip = 1; /* frame skip in debug view */
static int debopos = 1; /* output column in debugger */
static int frame = 1;
static int quiet = 0;

/********************************************************* PROTOTYPES */

int curd(int dx, int dy);
int isramp(char c);
int isblock(char c);
int issupport(char c);
int iscrate(char c);
int ctoh(char c);
char htoc(int i);
int rube_delay(int msec);
int curd(int, int);
int isramp(char);
int isblock(char);
int issupport(char);
int iscrate(char);
int ctoh(char);
char htoc(int);
void rube_delay(int);

/******************************************************* MAIN PROGRAM */

Expand Down Expand Up @@ -206,7 +203,6 @@ __asm
for (y=0; y<=(maxy); y++)
{
int cur = pg[y * LINEWIDTH + x].c;
int curv = pg[y * LINEWIDTH + x].v;
if (cur <= 32) {
if (iscrate(curd(0,-1))) nex = curd(0,-1); /* falling in from above */
if (curd(0,-1) == '(') nex = '(';
Expand Down Expand Up @@ -248,21 +244,21 @@ __asm
{
if (iscrate(curd(1,0)) && iscrate(curd(2,0)))
{
int i;
i = ctoh(curd(2,0)) - ctoh(curd(1,0));
while (i < 0) i += 16;
nex = htoc(i);
int z;
z = ctoh(curd(2,0)) - ctoh(curd(1,0));
while (z < 0) z += 16;
nex = htoc(z);
}
}

if (curd(-1,-1) == '-')
{
if (iscrate(curd(-1,0)) && iscrate(curd(-2,0)))
{
int i;
i = ctoh(curd(-2,0)) - ctoh(curd(-1,0));
while (i < 0) i += 16;
nex = htoc(i);
int z;
z = ctoh(curd(-2,0)) - ctoh(curd(-1,0));
while (z < 0) z += 16;
nex = htoc(z);
}
}

Expand Down Expand Up @@ -448,7 +444,6 @@ __asm
for (y=0; y<=(maxy); y++)
{
int cur = pg[y * LINEWIDTH + x].c;
int curv = pg[y * LINEWIDTH + x].v;
switch (cur)
{
case '*':
Expand Down Expand Up @@ -541,9 +536,9 @@ __asm
exit (0);
}

int curd(int dx, int dy)
int curd(int zdx, int zdy)
{
int r = (y+dy) * LINEWIDTH + (x+dx);
int r = (y+zdy) * LINEWIDTH + (x+zdx);
if (r < 0 || r >= LINEWIDTH * PAGEHEIGHT)
return 0;
return pg[r].c;
Expand Down Expand Up @@ -585,7 +580,7 @@ char htoc(int i)
if((i>=0) && (i<=9)) return ((char)(i+'0')); else return ((char)(i+'a')-10);
}

int rube_delay(int msec)
void rube_delay(int msec)
{
#if __BORLANDC__
delay (msec);
Expand Down

0 comments on commit f92643e

Please sign in to comment.