home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
x
/
volume6
/
xplumb
/
part01
/
main.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-04-11
|
3KB
|
107 lines
/*
* Copyright 1990 Digital Equipment Corporation
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notice appear in all copies and that
* both that copyright notice and this permission notice appear in
* supporting documentation, and that the name of Digital Equipment
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior
* permission. Digital Equipment Corporation makes no representations
* about the suitability of this software for any purpose. It is
* provided "as is" without express or implied warranty.
*
* DIGITAL EQUIPMENT CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR
* ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Terry Weissman
* weissman@wsl.dec.com
*/
#define MAIN
#include <stream.h>
#include "plumbing.h"
#include <sys/time.h>
#include <string.h>
extern int select(int, int *, int *, int *, struct timeval *);
static void Usage() {
cout << "Usage: " << progname << " [-d display]\n";
exit(1);
}
void Punt(char *str) {
cout << progname << ": " << str << "\n";
exit(1);
}
main(int argc, char **argv) {
char *displayname = NULL;
Bool sync = False;
int i;
progname = argv[0];
for (i=1 ; i<argc ; i++) {
if (i < argc - 1 && (strcmp(argv[i], "-d") == 0 ||
strcmp(argv[i], "-display") == 0)) {
displayname = argv[++i];
} else if (strcmp(argv[i], "-sync") == 0) {
sync = True;
} else {
Usage();
}
}
TimerInit();
numscreens = 0;
Display *dpy = XOpenDisplay(displayname);
if (!dpy) {
Punt("Can't open display.");
}
XSynchronize(dpy, sync);
screen[0] = new ScrnRec(dpy);
numscreens = 1;
BoardInit();
PieceInit();
QueueInit();
ScoreInit();
prevscore = -1;
queue = new QueueRec();
score = new ScoreRec();
mode = ModeEndOfGame;
struct timeval *timerec;
XEvent event;
int readmask = 0;
for (;;) {
for (i=0 ; i<numscreens ; i++) {
while (XPending(screen[i]->GetDpy())) {
XNextEvent(dpy, &event);
screen[i]->HandleEvent(&event);
}
readmask |= (1 << ConnectionNumber(screen[i]->GetDpy()));
}
timerec = TimerGetInterval();
if (select(32, &readmask, NULL, NULL, timerec) == 0) {
TimerHandleTimeout();
}
}
}