#include "misc.h"
#include "tape.h"
#include "joystick.h"
+#include "network.h"
void EventLoop(void)
{
while(1)
{
- if (XPending(display)) /* got an event */
+ if (XPending(display)) /* got event from X server */
{
XEvent event;
break;
}
}
+
+ HandleNoXEvent();
+
+ /* don't use all CPU time when idle; the main loop while playing
+ has its own synchronization and is CPU friendly, too */
+
+ if (game_status != PLAYING)
+ {
+ XSync(display, FALSE);
+ Delay(10);
+ }
+
+
+
+#if 0
else /* got no event, but don't be lazy... */
{
HandleNoXEvent();
Delay(10);
}
}
+#endif
+
+
if (game_status == EXITGAME)
return;
{
if ((event->window == window) &&
(event->data.l[0] == XInternAtom(display, "WM_DELETE_WINDOW", FALSE)))
- CloseAll();
+ game_status = EXITGAME;
}
void HandleButton(int mx, int my, int button)
HandleSetupScreen(mx,my,0,0,button);
break;
case PLAYING:
+
+ /* --> NoXEvent() will follow */
+
+ /*
HandleGameActions(0);
+ */
+
break;
default:
break;
return;
}
+ if (network)
+ HandleNetworking();
+
switch(game_status)
{
case MAINMENU:
{
int joystick = Joystick();
int keyboard = key_joystick_mapping;
-
- /*
- int joy = (tape.playing ? TapePlayAction() : (joystick | keyboard));
- */
-
int joy = (joystick | keyboard);
int left = joy & JOY_LEFT;
int right = joy & JOY_RIGHT;
if (tape.pausing || AllPlayersGone)
joy = 0;
- HandleGameActions(joy);
+ HandleGameActions((byte)joy);
break;
default: