rnd-20040821-2-src
authorHolger Schemel <info@artsoft.org>
Sat, 21 Aug 2004 12:12:19 +0000 (14:12 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:47:46 +0000 (10:47 +0200)
src/conftime.h
src/game_em/game_em.h
src/game_em/global.h
src/game_em/graphics.c
src/game_em/input.c
src/game_em/main.c
src/init.c

index 6b937c143d0eda36266f6e6b025cfc4525888805..8d2eb1b5fce980dd16ae6d9f0b1d027d938b4a52 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2004-08-21 12:08]"
+#define COMPILE_DATE_STRING "[2004-08-21 14:11]"
index 50d64e7e5ef6b9cf48fa544b76566f4a808767ad..80aae3ee69211e296b78f15f7a2a58c98ccccaac 100644 (file)
@@ -16,6 +16,8 @@
 
 #define GAME_EM_VERSION_1_0_0
 
+extern void em_open_all();
 extern void em_main();
+extern void em_close_all();
 
 #endif /* GAME_EM_H */
index 81792061d7430383b287d0c99a140856dba7b463..5f8b18215e96c54ebc4d3148038e29a2ce53e3da 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef GLOBAL_H
 #define GLOBAL_H
 
+#include "../libgame/libgame.h"
+
 #define EM_GFX_DIR     "graphics.EM"
 #define EM_SND_DIR     "sounds.EM"
 #define EM_LVL_DIR     "levels.EM"
index 92bcb49a971c922b1f8735453877febf600dc50e..483d63b5044a43be5cbcb29c414a0b2a004bf68e 100644 (file)
@@ -185,6 +185,58 @@ static void blitplayer(struct PLAYER *ply)
       screentiles[y / TILEY][x / TILEX] = -1; /* mark screen as dirty */
       screentiles[dy / TILEY][dx / TILEX] = -1;
 
+#if 1
+
+
+#if 1
+
+      SetClipMask(sprBitmap, sprBitmap->stored_clip_gc, spriteBitmap);
+
+      SetClipOrigin(sprBitmap, sprBitmap->stored_clip_gc, x, y);
+      BlitBitmapMasked(sprBitmap, screenBitmap,
+                      (spr / 8) * TILEX, (spr % 8) * TILEY, TILEX, TILEY,
+                      x, y);
+
+      SetClipOrigin(sprBitmap, sprBitmap->stored_clip_gc, x - 22 * TILEX, y);
+      BlitBitmapMasked(sprBitmap, screenBitmap,
+                      (spr / 8) * TILEX, (spr % 8) * TILEY, TILEX, TILEY,
+                      x - 22 * TILEX, y);
+
+      SetClipOrigin(sprBitmap, sprBitmap->stored_clip_gc, x, y - 14 * TILEY);
+      BlitBitmapMasked(sprBitmap, screenBitmap,
+                      (spr / 8) * TILEX, (spr % 8) * TILEY, TILEX, TILEY,
+                      x, y - 14 * TILEY);
+
+      SetClipMask(sprBitmap, sprBitmap->stored_clip_gc, None);
+
+#else
+
+      XSetClipMask(display, sprBitmap->stored_clip_gc, spriteBitmap);
+
+      XSetClipOrigin(display, sprBitmap->stored_clip_gc, x, y);
+      XCopyArea(display, sprBitmap->drawable, screenBitmap->drawable,
+               sprBitmap->stored_clip_gc,
+               (spr / 8) * TILEX, (spr % 8) * TILEY, TILEX, TILEY,
+               x, y);
+
+      XSetClipOrigin(display, sprBitmap->stored_clip_gc, x - 22 * TILEX, y);
+      XCopyArea(display, sprBitmap->drawable, screenBitmap->drawable,
+               sprBitmap->stored_clip_gc,
+               (spr / 8) * TILEX, (spr % 8) * TILEY, TILEX, TILEY,
+               x - 22 * TILEX, y);
+
+      XSetClipOrigin(display, sprBitmap->stored_clip_gc, x, y - 14 * TILEY);
+      XCopyArea(display, sprBitmap->drawable, screenBitmap->drawable,
+               sprBitmap->stored_clip_gc,
+               (spr / 8) * TILEX, (spr % 8) * TILEY, TILEX, TILEY,
+               x, y - 14 * TILEY);
+
+      XSetClipMask(display, sprBitmap->stored_clip_gc, None);
+
+#endif
+
+#else
+
       XSetClipMask(display, screenGC, spriteBitmap);
       XSetClipOrigin(display, screenGC, x, y);
       XCopyArea(display, sprPixmap, screenPixmap, screenGC,
@@ -199,6 +251,8 @@ static void blitplayer(struct PLAYER *ply)
                (spr / 8) * TILEX, (spr % 8) * TILEY, TILEX, TILEY,
                x, y - 14 * TILEY);
       XSetClipMask(display, screenGC, None);
+
+#endif
     }
   }
 }
@@ -367,6 +421,25 @@ void title_initscreen(void)
   colours[1] += 8;
   colour_anim = 0;
 
+#if 1
+
+  BlitBitmap(ttlBitmap, screenBitmap,
+            0, 0, 20 * TILEX, 12 * TILEY, 0, 0);
+
+  if (botmaskBitmap)
+  {
+    BlitBitmap(botBitmap, scoreBitmap,
+             0, colours[1] * SCOREY, 20 * TILEX, SCOREY, 0, 0);
+
+    SetClipOrigin(botBitmap, botBitmap->stored_clip_gc,
+                 0, 0 - colours[0] * SCOREY);
+  }
+
+  BlitBitmapMasked(botBitmap, scoreBitmap,
+                  0, colours[0] * SCOREY, 20 * TILEX, SCOREY, 0, 0);
+
+#else
+
   XCopyArea(display, ttlPixmap, screenPixmap, screenGC,
            0, 0, 20 * TILEX, 12 * TILEY, 0, 0);
 
@@ -383,6 +456,8 @@ void title_initscreen(void)
 
   if (botmaskBitmap)
     XSetClipMask(display, scoreGC, None);
+
+#endif
 }
 
 void title_blitscore(void)
@@ -398,6 +473,22 @@ void title_blitscore(void)
   x = (i / 8 + 18) * 2 * SCOREX;
   y = (i % 8 + 16) * SCOREY;
 
+#if 1
+  if (botmaskBitmap)
+  {
+    BlitBitmap(botBitmap, scoreBitmap,
+              32 * SCOREX, colours[1] * SCOREY, 2 * SCOREX, SCOREY,
+              32 * SCOREX, 0);
+
+    SetClipOrigin(botBitmap, botBitmap->stored_clip_gc,
+                 32 * SCOREX - x, 0 - y);
+  }
+
+  BlitBitmapMasked(botBitmap, scoreBitmap,
+                  x, y, 2 * SCOREX, SCOREY, 32 * SCOREX, 0);
+
+#else
+
   if (botmaskBitmap)
   {
     XCopyArea(display, botPixmap, scorePixmap, scoreGC,
@@ -412,6 +503,7 @@ void title_blitscore(void)
 
   if (botmaskBitmap)
     XSetClipMask(display, scoreGC, None);
+#endif
 }
 
 void title_blitants(unsigned int y)
index 9bcc5c109060b299f6c61b15bc8a71bd3d9d7350..ada3aba4f7e3726427b6f628d6924878c7350110 100644 (file)
@@ -52,279 +52,346 @@ static int player_level;
 
 static void drawmenu(int pos)
 {
-       char buffer[256];
-       switch(pos) {
-       case 0:
-               switch(player_mode) {
-               case 0: strcpy(buffer, "quit emerald mine"); break;
-               case 1: strcpy(buffer, "single player"); break;
-               case 2: strcpy(buffer, "teamwork"); break;
-               }
-               title_string(4, 0, 40, buffer);
-               break;
-       case 1:
-               sprintf(buffer, "name: %s", player_name);
-               title_string(5, 0, 40, buffer);
-               break;
-       case 2:
-               sprintf(buffer, "level: %d", player_level);
-               title_string(6, 0, 40, buffer);
-               break;
-       case 3:
-               title_string(7, 0, 40, "highscores");
-               break;
-       case 4:
-               title_string(8, 0, 40, "start");
-               break;
-       case 5:
-               title_string(10, 1, 13, "played");
-               title_string(10, 14, 26, "score");
-               title_string(10, 27, 39, "won");
-               break;
-       case 6:
-               sprintf(buffer, "%d", 0);
-               title_string(11, 1, 13, buffer);
-               sprintf(buffer, "%d", 0);
-               title_string(11, 14, 26, buffer);
-               sprintf(buffer, "%d", 0);
-               title_string(11, 27, 39, buffer);
-               break;
-       }
+  char buffer[256];
+
+  switch(pos)
+  {
+    case 0:
+      switch(player_mode)
+      {
+        case 0:
+         strcpy(buffer, "quit emerald mine");
+         break;
+
+        case 1:
+         strcpy(buffer, "single player");
+         break;
+
+        case 2:
+         strcpy(buffer, "teamwork");
+         break;
+      }
+
+      title_string(4, 0, 40, buffer);
+      break;
+
+    case 1:
+      sprintf(buffer, "name: %s", player_name);
+      title_string(5, 0, 40, buffer);
+      break;
+
+    case 2:
+      sprintf(buffer, "level: %d", player_level);
+      title_string(6, 0, 40, buffer);
+      break;
+
+    case 3:
+      title_string(7, 0, 40, "highscores");
+      break;
+
+    case 4:
+      title_string(8, 0, 40, "start");
+      break;
+
+    case 5:
+      title_string(10, 1, 13, "played");
+      title_string(10, 14, 26, "score");
+      title_string(10, 27, 39, "won");
+      break;
+
+    case 6:
+      sprintf(buffer, "%d", 0);
+      title_string(11, 1, 13, buffer);
+      sprintf(buffer, "%d", 0);
+      title_string(11, 14, 26, buffer);
+      sprintf(buffer, "%d", 0);
+      title_string(11, 27, 39, buffer);
+      break;
+  }
 }
 
 /* bring it all together */
 int game_start(void)
 {
-       int x,y;
-       char name[MAXNAME+2];
-       int temp;
-       int pos;
-
-       Random = 1684108901;
-
-       for(y = 0; y < HEIGHT; y++) for(x = 0; x < WIDTH; x++) Array[0][y][x] = ZBORDER;
-       for(y = 0; y < HEIGHT; y++) for(x = 0; x < WIDTH; x++) Array[1][y][x] = ZBORDER;
-       for(y = 0; y < HEIGHT; y++) for(x = 0; x < WIDTH; x++) Array[2][y][x] = ZBORDER;
-       for(y = 0; y < HEIGHT; y++) for(x = 0; x < WIDTH; x++) Array[3][y][x] = Xblank;
-
-       for(y = 0; y < HEIGHT; y++) Index[0][y] = Array[0][y];
-       for(y = 0; y < HEIGHT; y++) Index[1][y] = Array[1][y];
-       for(y = 0; y < HEIGHT; y++) Index[2][y] = Array[2][y];
-       for(y = 0; y < HEIGHT; y++) Index[3][y] = Array[3][y];
-
-       Cave = Index[0];
-       Next = Index[1];
-       Draw = Index[2];
-       Boom = Index[3];
-
-       player_mode = 1; /* start off as single player */
-       strcpy(player_name, "dave");
-       player_level = 0;
-
-       input_pause = 1    * 0;
-
-       for(;;) {
-
-               pos = 4;
-
-               title_initscreen();
-
-               for(temp = 0; temp < 7; temp++) drawmenu(temp); /* display all lines */
-               title_blitants(4 + pos);
+  int x,y;
+  char name[MAXNAME+2];
+  int temp;
+  int pos;
+
+  Random = 1684108901;
+
+  for (y = 0; y < HEIGHT; y++)
+    for (x = 0; x < WIDTH; x++)
+      Array[0][y][x] = ZBORDER;
+  for (y = 0; y < HEIGHT; y++)
+    for (x = 0; x < WIDTH; x++)
+      Array[1][y][x] = ZBORDER;
+  for (y = 0; y < HEIGHT; y++)
+    for (x = 0; x < WIDTH; x++)
+      Array[2][y][x] = ZBORDER;
+  for (y = 0; y < HEIGHT; y++)
+    for (x = 0; x < WIDTH; x++)
+      Array[3][y][x] = Xblank;
+
+  for (y = 0; y < HEIGHT; y++)
+    Index[0][y] = Array[0][y];
+  for (y = 0; y < HEIGHT; y++)
+    Index[1][y] = Array[1][y];
+  for (y = 0; y < HEIGHT; y++)
+    Index[2][y] = Array[2][y];
+  for (y = 0; y < HEIGHT; y++)
+    Index[3][y] = Array[3][y];
+
+  Cave = Index[0];
+  Next = Index[1];
+  Draw = Index[2];
+  Boom = Index[3];
+
+  player_mode = 1;                     /* start off as single player */
+  strcpy(player_name, "dave");
+  player_level = 0;
+
+  input_pause = 1    * 0;
+
+  while (1)
+  {
+    pos = 4;
+
+    title_initscreen();
+
+    for (temp = 0; temp < 7; temp++)
+      drawmenu(temp);                  /* display all lines */
+
+    title_blitants(4 + pos);
+
+    title_blitscore();
+    title_animscreen();
+
+    temp = 1;
+    while (1)
+    {
+      input_eventloop();
+      if (input_die) return(0);
+      if (input_refresh) blitscreen();
+
+      if (!input_pause)
+      {
+       title_blitants(4 + pos);
+       title_blitscore();
+       title_animscreen();
+
+       ply1.joy_n = ply1.joy_e = ply1.joy_s = ply1.joy_w = 0;
+
+       readjoy();
+
+       if (temp == 0)
+       {
+         if (ply1.joy_fire)
+           break;
+
+         if (ply1.joy_e && player_level < 99)
+         {
+           player_level++;
+           drawmenu(2);
+         }
+
+         if (ply1.joy_w && player_level > 0)
+         {
+           player_level--;
+           drawmenu(2);
+         }
+
+         if (ply1.joy_n && pos > 0)
+         {
+           drawmenu(pos);
+           pos--;
+           title_blitants(4 + pos);
+         }
+
+         if (ply1.joy_s && pos < 4)
+         {
+           drawmenu(pos);
+           pos++;
+           title_blitants(4 + pos);
+         }
+       }
 
-               title_blitscore();
-               title_animscreen();
+       temp = (ply1.joy_n ||
+               ply1.joy_e ||
+               ply1.joy_s ||
+               ply1.joy_w ||
+               ply1.joy_fire);
+      }
+    }
 
-#if 0
-               printf("--> M1: xwindow == %ld\n", xwindow);
-#endif
+    name[MAXNAME] = 0;
+    snprintf(name, MAXNAME+2, "%s/lev%02d", EM_LVL_DIR, player_level);
 
-               temp = 1;
-               for(;;) {
-                       input_eventloop();
-                       if(input_die) return(0);
-                       if(input_refresh) blitscreen();
+    if (name[MAXNAME])
+      snprintf_overflow("read a level in cave/");
 
-#if 0
-                       printf("--> M2: xwindow == %ld\n", xwindow);
-#endif
+    if (cave_convert(name))
+      continue;
 
-                       if(!input_pause) {
-                               title_blitants(4 + pos);
-                               title_blitscore();
-                               title_animscreen();
+    game_initscreen();
+    game_blitscore();
+    game_animscreen();
 
-#if 0
-                               printf("--> M3: xwindow == %ld\n", xwindow);
-#endif
+    while (1)
+    {
+      input_eventloop();
 
-                               ply1.joy_n = ply1.joy_e = ply1.joy_s = ply1.joy_w = 0;
-
-                               readjoy();
-
-                               if(temp == 0) {
-                                       if(ply1.joy_fire) break;
-
-                                       if(ply1.joy_e && player_level < 99) {
-                                               player_level++;
-                                               drawmenu(2);
-                                       }
-                                       if(ply1.joy_w && player_level > 0) {
-                                               player_level--;
-                                               drawmenu(2);
-                                       }
-                                       if(ply1.joy_n && pos > 0) {
-                                               drawmenu(pos);
-                                               pos--;
-                                               title_blitants(4 + pos);
-                                       }
-                                       if(ply1.joy_s && pos < 4) {
-                                               drawmenu(pos);
-                                               pos++;
-                                               title_blitants(4 + pos);
-                                       }
-                               }
-                               temp = (ply1.joy_n || ply1.joy_e || ply1.joy_s || ply1.joy_w || ply1.joy_fire);
-                       }
-               }
-
-#if 0
-               printf("--> M4: xwindow == %ld\n", xwindow);
-#endif
+      if (input_die || input_esc)
+       break;
 
-               name[MAXNAME] = 0;
-               snprintf(name, MAXNAME+2, "%s/lev%02d", EM_LVL_DIR, player_level);
-               if(name[MAXNAME]) snprintf_overflow("read a level in cave/");
+      if (input_refresh)
+       blitscreen();
 
-               if(cave_convert(name)) continue;
+      if (!input_pause)
+      {
+       game_animscreen();
 
-#if 0
-               printf("--> M5: xwindow == %ld\n", xwindow);
-#endif
+       frame = (frame - 1) & 7;
 
-               game_initscreen();
-#if 0
-               printf("--> M6: xwindow == %ld\n", xwindow);
-#endif
-               game_blitscore();
-#if 0
-               printf("--> M7: xwindow == %ld\n", xwindow);
-#endif
-               game_animscreen();
+       readjoy();
 
-#if 0
-               printf("--> M8: xwindow == %ld\n", xwindow);
-#endif
+       if (frame == 7)
+       {
+         synchro_1();
+         synchro_2();
+       }
 
-               for(;;) {
-                       input_eventloop();
-                       if(input_die || input_esc) break;
-                       if(input_refresh) blitscreen();
-
-                       if(!input_pause) {
-                               game_animscreen();
-
-                               frame = (frame - 1) & 7;
-
-                               readjoy();
-
-                               if(frame == 7) {
-                                       synchro_1();
-                                       synchro_2();
-                               }
-                               if(frame == 6) {
-                                       synchro_3();
-                                       sound_play();
-                                       game_blitscore();
-                               }
-                       }
-               }
+       if (frame == 6)
+       {
+         synchro_3();
+         sound_play();
+         game_blitscore();
        }
+      }
+    }
+  }
 }
 
 /* read input device for players
  */
 void readjoy(void)
 {
-       unsigned int i;
-       unsigned int north = 0, east = 0, south = 0, west = 0, fire = 0;
-
-       for(i = 0; i < 3; i++) if(keymatrix[northKeyCode[i] >> 3] & 1 << (northKeyCode[i] & 7)) north = 1;
-       for(i = 0; i < 3; i++) if(keymatrix[eastKeyCode[i] >> 3] & 1 << (eastKeyCode[i] & 7)) east = 1;
-       for(i = 0; i < 3; i++) if(keymatrix[southKeyCode[i] >> 3] & 1 << (southKeyCode[i] & 7)) south = 1;
-       for(i = 0; i < 3; i++) if(keymatrix[westKeyCode[i] >> 3] & 1 << (westKeyCode[i] & 7)) west = 1;
-       for(i = 0; i < 3; i++) if(keymatrix[fireKeyCode[i] >> 3] & 1 << (fireKeyCode[i] & 7)) fire = 1;
-
-       ply1.joy_fire = fire;
-       if(ply1.joy_stick || (north | east | south | west)) {
-               ply1.joy_n = north;
-               ply1.joy_e = east;
-               ply1.joy_s = south;
-               ply1.joy_w = west;
-       }
-
-#if 0
-       printf("::: JOY == %d/%d/%d/%d/%d\n",
-              north, east, south, west, fire);
-#endif
+  unsigned int i;
+  unsigned int north = 0, east = 0, south = 0, west = 0, fire = 0;
+
+  for (i = 0; i < 3; i++)
+    if (keymatrix[northKeyCode[i] >> 3] & 1 << (northKeyCode[i] & 7))
+      north = 1;
+
+  for (i = 0; i < 3; i++)
+    if (keymatrix[eastKeyCode[i] >> 3] & 1 << (eastKeyCode[i] & 7))
+      east = 1;
+
+  for (i = 0; i < 3; i++)
+    if (keymatrix[southKeyCode[i] >> 3] & 1 << (southKeyCode[i] & 7))
+      south = 1;
+
+  for (i = 0; i < 3; i++)
+    if (keymatrix[westKeyCode[i] >> 3] & 1 << (westKeyCode[i] & 7))
+      west = 1;
+
+  for (i = 0; i < 3; i++)
+    if (keymatrix[fireKeyCode[i] >> 3] & 1 << (fireKeyCode[i] & 7))
+      fire = 1;
+
+  ply1.joy_fire = fire;
+  if (ply1.joy_stick || (north | east | south | west))
+  {
+    ply1.joy_n = north;
+    ply1.joy_e = east;
+    ply1.joy_s = south;
+    ply1.joy_w = west;
+  }
 }
 
 /* handle events from x windows and block until the next frame
  */
 void input_eventloop(void)
 {
-       XEvent event;
-       unsigned int i;
-       unsigned long count;
-
-       if(input_pause) {
-               XPeekEvent(display, &event); /* block until an event arrives */
-
-               if(gettimeofday(&tv1, 0) == -1) tv1.tv_usec = 0;
-       } else {
-               XSync(display, False); /* block until all graphics are drawn */
-
-               if(gettimeofday(&tv2, 0) == -1) tv2.tv_usec = 0;
-               count = tv2.tv_usec + 1000000 - tv1.tv_usec; if(count >= 1000000) count -= 1000000;
-               tv1.tv_usec = tv2.tv_usec;
-               if(count < 25000) {
-                       tv2.tv_sec = 0;
-                       tv2.tv_usec = 25000 - count;
+  XEvent event;
+  unsigned int i;
+  unsigned long count;
+
+  if (input_pause)
+  {
+    XPeekEvent(display, &event); /* block until an event arrives */
+
+    if (gettimeofday(&tv1, 0) == -1)
+      tv1.tv_usec = 0;
+  }
+  else
+  {
+    XSync(display, False); /* block until all graphics are drawn */
+
+    if (gettimeofday(&tv2, 0) == -1)
+      tv2.tv_usec = 0;
+
+    count = tv2.tv_usec + 1000000 - tv1.tv_usec;
+    if (count >= 1000000)
+      count -= 1000000;
+
+    tv1.tv_usec = tv2.tv_usec;
+    if (count < 25000)
+    {
+      tv2.tv_sec = 0;
+      tv2.tv_usec = 25000 - count;
 #if 1
-                       select(0, 0, 0, 0, &tv2); /* sleep a bit */
+      select(0, 0, 0, 0, &tv2); /* sleep a bit */
 #else
-                       usleep(tv2.tv_usec);
+      usleep(tv2.tv_usec);
 #endif
-               }
-       }
-
-       input_die = 0;
-       input_refresh = 0;
-       lastKeySym = NoSymbol;
-       while(XPending(display)) { /* drain the event queue */
-               XNextEvent(display, &event);
-               switch(event.xany.type) {
-               case KeyPress:
-                       XLookupString(&event.xkey, (char *)&count, 1, &lastKeySym, 0);
-                       break;
-               case Expose:
-                       if(event.xexpose.window == xwindow && event.xexpose.count == 0) input_refresh = 1;
-                       break;
-               case ClientMessage:
-                       if(event.xclient.window == xwindow && (Atom)event.xclient.data.l[0] == deleteAtom) input_die = 1;
-                       break;
-               case EnterNotify:
-                       if(event.xcrossing.window == xwindow) input_pause = 0;
-                       break;
-               case LeaveNotify:
-                       if(event.xcrossing.window == xwindow) input_pause = 1;
-                       break;
-               }
-       }
-       XQueryKeymap(display, keymatrix); /* read the keyboard */
-
-       input_esc = 0;
-       for(i = 0; i < 1; i++) if(keymatrix[escKeyCode[i] >> 3] & 1 << (escKeyCode[i] & 7)) input_esc = 1;
+    }
+  }
+
+  input_die = 0;
+  input_refresh = 0;
+  lastKeySym = NoSymbol;
+
+  while (XPending(display))
+  {
+    /* drain the event queue */
+    XNextEvent(display, &event);
+
+    switch(event.xany.type)
+    {
+      case KeyPress:
+       XLookupString(&event.xkey, (char *)&count, 1, &lastKeySym, 0);
+       break;
+
+      case Expose:
+       if (event.xexpose.window == xwindow && event.xexpose.count == 0)
+         input_refresh = 1;
+       break;
+
+      case ClientMessage:
+       if (event.xclient.window == xwindow &&
+           (Atom)event.xclient.data.l[0] == deleteAtom)
+         input_die = 1;
+       break;
+
+      case EnterNotify:
+       if (event.xcrossing.window == xwindow)
+         input_pause = 0;
+       break;
+
+      case LeaveNotify:
+       if (event.xcrossing.window == xwindow)
+         input_pause = 1;
+       break;
+    }
+  }
+
+  XQueryKeymap(display, keymatrix); /* read the keyboard */
+
+  input_esc = 0;
+  for (i = 0; i < 1; i++)
+    if (keymatrix[escKeyCode[i] >> 3] & 1 << (escKeyCode[i] & 7))
+      input_esc = 1;
 }
 
 #endif
index dc29189eb85deb8e4f08e81b12de039189570564..a477d1035c583fefaa526af624fe48a7ff1e1b62 100644 (file)
@@ -28,68 +28,35 @@ int arg_silence;
 extern void tab_generate();
 extern void ulaw_generate();
 
-int em_main_OLD(int argc, char **argv)
+void em_open_all()
 {
-       int result;
-       int option;
-       extern char *optarg;
-
-       /* pre-calculate some data */
-       tab_generate();
-       ulaw_generate();
-
-       progname = strrchr(argv[0], '/'); progname = progname ? progname + 1 : argv[0];
-
-       while((option = getopt(argc, argv, "b:d:g:in")) != -1) {
-               switch(option) {
-               case 'b': arg_basedir = optarg; break;
-               case 'd': arg_display = optarg; break;
-               case 'g': arg_geometry = optarg; break;
-               case 'i': arg_install = 1; break;
-               case 'n': arg_silence = 1; break;
-               default:
-                       printf("Emerald Mine for X11 © 2000,2001 David Tritscher\n\n");
-                       printf("usage: %s [options]\n", progname);
-                       printf("\t-b    set base directory\n");
-                       printf("\t-d    server to contact\n");
-                       printf("\t-g    geometry\n");
-                       printf("\t-i    install colourmap\n");
-                       printf("\t-n    no sounds\n");
-                       exit(option == 'h' ? 0 : 1);
-               }
-       }
-       if(arg_basedir == 0) arg_basedir = getenv("EMERALD_BASE");
-
-       result = open_all(); if(result) goto fail;
-       result = game_start(); if(result) goto fail;
-       result = 0;
-fail:
-       close_all();
-       return(result);
-}
+  /* pre-calculate some data */
+  tab_generate();
+  ulaw_generate();
 
-int em_main()
-{
-       int result;
+  progname = "emerald mine";
 
-       /* pre-calculate some data */
-       tab_generate();
-       ulaw_generate();
+  if (open_all() != 0)
+    Error(ERR_EXIT, "em_open_all(): open_all() failed");
+}
 
-       progname = "emerald mine";
+void em_close_all()
+{
+  close_all();
+}
 
-       result = open_all();
-       if(result)
-         goto fail;
+void em_main()
+{
+#if 0
+  em_open_all();
+#endif
 
-       result = game_start();
-       if(result)
-         goto fail;
+  if (game_start() != 0)
+    Error(ERR_EXIT, "em_main(): game_start() failed");
 
-       result = 0;
-fail:
-       close_all();
-       return(result);
+#if 0
+  em_close_all();
+#endif
 }
 
 /* massive kludge for buffer overflows
@@ -98,9 +65,11 @@ fail:
  */
 void snprintf_overflow(char *description)
 {
-       fprintf(stderr, "%s: %s\n", progname, "buffer overflow; check EMERALD_BASE environment variable");
-       fprintf(stderr, "%s %s\n", "Fault occured while attempting to", description);
-       abort();
+  fprintf(stderr, "%s: %s\n", progname,
+         "buffer overflow; check EMERALD_BASE environment variable");
+  fprintf(stderr, "%s %s\n", "Fault occured while attempting to", description);
+
+  abort();
 }
 
 #else
index 0e69d6621f79242720e0a9d991e8f07dff14dab3..cdfac29bb3094b75b54c9c212dff24d8c2e4dff5 100644 (file)
@@ -4437,10 +4437,20 @@ void OpenAll()
   DrawMainMenu();
 
   InitNetworkServer();
+
+#if 1
+  em_open_all();
+#endif
+
 }
 
 void CloseAllAndExit(int exit_value)
 {
+
+#if 1
+  em_close_all();
+#endif
+
   StopSounds();
   FreeAllSounds();
   FreeAllMusic();