rocks_n_diamonds-0.9b
authorHolger Schemel <info@artsoft.org>
Sun, 5 Nov 1995 21:29:59 +0000 (22:29 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:30:14 +0000 (10:30 +0200)
28 files changed:
CHANGES
REGISTRATION [changed from file to symlink]
THIS_IS_NOW_FREEWARE [new file with mode: 0644]
src/Makefile
src/buttons.c [new file with mode: 0644]
src/buttons.h [new file with mode: 0644]
src/editor.c
src/editor.h
src/events.c
src/events.h
src/files.c [new file with mode: 0644]
src/files.h [new file with mode: 0644]
src/game.c
src/game.h
src/images.c [deleted file]
src/images.h [deleted file]
src/init.c
src/init.h
src/main.c
src/main.h
src/misc.c
src/misc.h
src/screens.c
src/screens.h
src/sound.c
src/sound.h
src/tools.c
src/tools.h

diff --git a/CHANGES b/CHANGES
index 0dafe5d..5ad2b64 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,20 @@
 
+Prerelease Version 0.9b [4 NOV 95]
+------------------------------------
+       - the game is now completely Freeware
+       - the game is now better playable by keyboard
+         (in the last version, the player was making more than
+          one step for one keystroke in some cases -- thanks to
+         Warwick Allison for the hint with "XSync()"!)
+       - new amoeba type with configurable content (like in the
+         original C64 version, when aboeba cannot grow anymore
+         and explodes to diamonds or some other elements)
+       - compile error with ONE_PER_NAME in high score function
+         removed (thanks to Dmitry Kohmanyuk)
+       - little code cleanup (to get some new bugs ;)
+       - FreeBSD sound and joystick support (thanks to Jean-Marc
+         Zucconi)
+
 Prerelease Version 0.9 [23 OCT 95]
 ----------------------------------
        - first (pre)release version
deleted file mode 100644 (file)
index 00233a6aa57a65581ebcebc8ac62403dc13486b7..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,65 +0,0 @@
-
-How to (and why) become a registered user of Rocks'n'Diamonds
-=============================================================
-
-It was much fun writing this game, and I hope that it is much fun playing
-it, too.
-
-Writing it was much work, too, and if you like this game, please think about
-becoming a registered user. Registered users will get a keyfile which allows
-them to use registered-users-only level series, starting with 50 new levels
-when version 1.0 come out (around December '95 or January '96). If you own
-the Amiga game "Emerald Mine", you can use its levels with the registered
-version of Rocks'n'Diamonds, too.
-
-There are some other plans for future versions of Rocks'n'Diamonds which
-will be only available for registered users, like support for more than
-one player on one machine, multi-player support for games over a network
-or Dyna-Blaster like levels (especially for multi player modes).
-
-If you want to become a registered user, send $20 or DM 20 to the
-following Snail-Mail address:
-
-       Holger Schemel
-       Sennehof 28
-       33659 Bielefeld
-       GERMANY
-
-... and send the filled-out registration form (at the end of this file)
-to the following E-Mail address:
-
-       aeglos@valinor.owl.de
-
-If you live outside Europe, you can use an international money order
-or just send a banknote, if you live in Europe, you can send an Euro-
-Cheque or remit the registration fee directly to my bank account in
-Germany (please write a short e-mail note and I'll send you the bank
-account information).
-
-You will then get a patch to change the program to a registered version
-(together with each main release version, if needed), a keyfile to use
-the registered-users-only level series and a little program to convert
-old "Emerald Mine" levels to Rocks'n'Diamonds levels.
-
----------- 8< ---------- cut here ---------- 8< ----------
-
-Name:
-----------------------------------------------------------
-Street:
-----------------------------------------------------------
-City:
-----------------------------------------------------------
-Country:
-----------------------------------------------------------
-E-Mail:
-----------------------------------------------------------
-Username:
-----------------------------------------------------------
-
-(All informations will only be used to create a personalized
-keyfile. The game will work for the user in "Username", the
-fields "Name" to "Country" will appear in the info screen
-and your e-mail address will be used to inform you of new
-main release versions of Rocks'n'Diamonds.)
-
----------- 8< ---------- cut here ---------- 8< ----------
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..5f4a260cb06c7792883aed240f50c8bae984ba8a
--- /dev/null
@@ -0,0 +1 @@
+THIS_IS_NOW_FREEWARE
\ No newline at end of file
diff --git a/THIS_IS_NOW_FREEWARE b/THIS_IS_NOW_FREEWARE
new file mode 100644 (file)
index 0000000..c0e5098
--- /dev/null
@@ -0,0 +1,23 @@
+
+THIS GAME IS NOW COMPLETELY FREEWARE!
+=====================================
+
+In version 0.9, I planned to offer the possibility to become a
+registered user and get special level series for registered users
+only and some more things.
+
+Now I have decided that it is better to distribute it as Freeware,
+that means: Freely distributable, but still copyrighted software.
+
+If you like this game, please send me mail about it!
+
+       aeglos@valinor.owl.de
+
+or SnailMail:
+
+       Holger Schemel
+       Sennehof 28
+       33659 Bielefeld
+       GERMANY
+
+Have fun!
index fffe019..7333fb2 100644 (file)
@@ -6,6 +6,7 @@ PROGNAME = rocksndiamonds
 
 RM = rm -f
 CC = gcc
+CPP = $(CC) -E
 # CC = cc                              # for HP-UX and others
 
 GAME_DIR = -DGAME_DIR=\".\"            # path of the game and its data
@@ -35,15 +36,28 @@ LIBS = -lXpm -lXpm -lXpm -lX11 -lm  # triple -lXpm; else I got an error...
 # CFLAGS = -O2 $(CONFIG) $(SYSTEM)
 CFLAGS = $(DEBUG) $(CONFIG) $(SYSTEM) $(INCL)
 
-OBJS = main.o \
-       init.o \
-       images.o \
-       events.o \
-       tools.o \
-       screens.o \
-       misc.o \
-       game.o \
-       editor.o \
+SRCS = main.c          \
+       init.c          \
+       events.c        \
+       tools.c         \
+       screens.c       \
+       misc.c          \
+       game.c          \
+       editor.c        \
+       buttons.c       \
+       files.c         \
+       sound.c
+
+OBJS = main.o          \
+       init.o          \
+       events.o        \
+       tools.o         \
+       screens.o       \
+       misc.o          \
+       game.o          \
+       editor.o        \
+       buttons.o       \
+       files.o         \
        sound.o
 
 all:   $(OBJS)
@@ -54,3 +68,10 @@ all: $(OBJS)
 
 clean:
        $(RM) $(OBJS)
+
+depend:
+       for i in $(SRCS); do $(CPP) $(CFLAGS) -M $$i; done > .depend
+
+ifeq (.depend,$(wildcard .depend))
+include .depend
+endif
diff --git a/src/buttons.c b/src/buttons.c
new file mode 100644 (file)
index 0000000..8b82545
--- /dev/null
@@ -0,0 +1,963 @@
+/***********************************************************
+*  Rocks'n'Diamonds -- McDuffin Strikes Back!              *
+*----------------------------------------------------------*
+*  ©1995 Artsoft Development                               *
+*        Holger Schemel                                    *
+*        33659 Bielefeld-Senne                             *
+*        Telefon: (0521) 493245                            *
+*        eMail: aeglos@valinor.owl.de                      *
+*               aeglos@uni-paderborn.de                    *
+*               q99492@pbhrzx.uni-paderborn.de             *
+*----------------------------------------------------------*
+*  buttons.c                                               *
+***********************************************************/
+
+#include "buttons.h"
+#include "tools.h"
+#include "misc.h"
+#include "editor.h"
+
+/****************************************************************/
+/********** drawing buttons and corresponding displays **********/
+/****************************************************************/
+
+void DrawVideoDisplay(unsigned long state, unsigned long value)
+{
+  int i;
+  int part1 = 0, part2 = 1;
+  int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
+  static char *monatsname[12] =
+  {
+    "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
+    "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
+  };
+  static int video_pos[10][2][4] =
+  {
+    VIDEO_PLAY_LABEL_XPOS, VIDEO_PLAY_LABEL_YPOS,
+    VIDEO_PLAY_LABEL_XSIZE,VIDEO_PLAY_LABEL_YSIZE,
+    VIDEO_PLAY_SYMBOL_XPOS, VIDEO_PLAY_SYMBOL_YPOS,
+    VIDEO_PLAY_SYMBOL_XSIZE,VIDEO_PLAY_SYMBOL_YSIZE,
+
+    VIDEO_REC_LABEL_XPOS, VIDEO_REC_LABEL_YPOS,
+    VIDEO_REC_LABEL_XSIZE,VIDEO_REC_LABEL_YSIZE,
+    VIDEO_REC_SYMBOL_XPOS, VIDEO_REC_SYMBOL_YPOS,
+    VIDEO_REC_SYMBOL_XSIZE,VIDEO_REC_SYMBOL_YSIZE,
+
+    VIDEO_PAUSE_LABEL_XPOS, VIDEO_PAUSE_LABEL_YPOS,
+    VIDEO_PAUSE_LABEL_XSIZE,VIDEO_PAUSE_LABEL_YSIZE,
+    VIDEO_PAUSE_SYMBOL_XPOS, VIDEO_PAUSE_SYMBOL_YPOS,
+    VIDEO_PAUSE_SYMBOL_XSIZE,VIDEO_PAUSE_SYMBOL_YSIZE,
+
+    VIDEO_DATE_LABEL_XPOS, VIDEO_DATE_LABEL_YPOS,
+    VIDEO_DATE_LABEL_XSIZE,VIDEO_DATE_LABEL_YSIZE,
+    VIDEO_DATE_XPOS, VIDEO_DATE_YPOS,
+    VIDEO_DATE_XSIZE,VIDEO_DATE_YSIZE,
+
+    0,0,
+    0,0,
+    VIDEO_TIME_XPOS, VIDEO_TIME_YPOS,
+    VIDEO_TIME_XSIZE,VIDEO_TIME_YSIZE,
+
+    VIDEO_BUTTON_PLAY_XPOS, VIDEO_BUTTON_ANY_YPOS,
+    VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE,
+    0,0,
+    0,0,
+
+    VIDEO_BUTTON_REC_XPOS, VIDEO_BUTTON_ANY_YPOS,
+    VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE,
+    0,0,
+    0,0,
+
+    VIDEO_BUTTON_PAUSE_XPOS, VIDEO_BUTTON_ANY_YPOS,
+    VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE,
+    0,0,
+    0,0,
+
+    VIDEO_BUTTON_STOP_XPOS, VIDEO_BUTTON_ANY_YPOS,
+    VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE,
+    0,0,
+    0,0,
+
+    VIDEO_BUTTON_EJECT_XPOS, VIDEO_BUTTON_ANY_YPOS,
+    VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE,
+    0,0,
+    0,0
+  };
+
+  for(i=0;i<20;i++)
+  {
+    if (state & (1<<i))
+    {
+      int pos = i/2, cx, cy = DOOR_GFX_PAGEY2;
+
+      if (i%2)                 /* i ungerade => STATE_ON / PRESS_OFF */
+       cx = DOOR_GFX_PAGEX4;
+      else
+       cx = DOOR_GFX_PAGEX3;   /* i gerade => STATE_OFF / PRESS_ON */
+
+      if (video_pos[pos][part1][0])
+       XCopyArea(display,pix[PIX_DOOR],drawto,gc,
+                 cx + video_pos[pos][part1][xpos],
+                 cy + video_pos[pos][part1][ypos],
+                 video_pos[pos][part1][xsize],
+                 video_pos[pos][part1][ysize],
+                 VX + video_pos[pos][part1][xpos],
+                 VY + video_pos[pos][part1][ypos]);
+      if (video_pos[pos][part2][0])
+       XCopyArea(display,pix[PIX_DOOR],drawto,gc,
+                 cx + video_pos[pos][part2][xpos],
+                 cy + video_pos[pos][part2][ypos],
+                 video_pos[pos][part2][xsize],
+                 video_pos[pos][part2][ysize],
+                 VX + video_pos[pos][part2][xpos],
+                 VY + video_pos[pos][part2][ypos]);
+    }
+  }
+
+  if (state & VIDEO_STATE_DATE_ON)
+  {
+    int tag = value % 100;
+    int monat = (value/100) % 100;
+    int jahr = (value/10000);
+
+    DrawText(VX+VIDEO_DATE_XPOS,VY+VIDEO_DATE_YPOS,
+            int2str(tag,2),FS_SMALL,FC_SPECIAL1);
+    DrawText(VX+VIDEO_DATE_XPOS+27,VY+VIDEO_DATE_YPOS,
+            monatsname[monat],FS_SMALL,FC_SPECIAL1);
+    DrawText(VX+VIDEO_DATE_XPOS+64,VY+VIDEO_DATE_YPOS,
+            int2str(jahr,2),FS_SMALL,FC_SPECIAL1);
+  }
+
+  if (state & VIDEO_STATE_TIME_ON)
+  {
+    int min = value / 60;
+    int sec = value % 60;
+
+    DrawText(VX+VIDEO_TIME_XPOS,VY+VIDEO_TIME_YPOS,
+            int2str(min,2),FS_SMALL,FC_SPECIAL1);
+    DrawText(VX+VIDEO_TIME_XPOS+27,VY+VIDEO_TIME_YPOS,
+            int2str(sec,2),FS_SMALL,FC_SPECIAL1);
+  }
+
+  if (state & VIDEO_STATE_DATE)
+    redraw_mask |= REDRAW_VIDEO_1;
+  if ((state & ~VIDEO_STATE_DATE) & VIDEO_STATE)
+    redraw_mask |= REDRAW_VIDEO_2;
+  if (state & VIDEO_PRESS)
+    redraw_mask |= REDRAW_VIDEO_3;
+}
+
+void DrawCompleteVideoDisplay()
+{
+  XCopyArea(display,pix[PIX_DOOR],drawto,gc,
+           DOOR_GFX_PAGEX3,DOOR_GFX_PAGEY2, VXSIZE,VYSIZE, VX,VY);
+  XCopyArea(display,pix[PIX_DOOR],drawto,gc,
+           DOOR_GFX_PAGEX4+VIDEO_CONTROL_XPOS,
+           DOOR_GFX_PAGEY2+VIDEO_CONTROL_YPOS,
+           VIDEO_CONTROL_XSIZE,VIDEO_CONTROL_YSIZE,
+           VX+VIDEO_CONTROL_XPOS,VY+VIDEO_CONTROL_YPOS);
+
+  DrawVideoDisplay(VIDEO_ALL_OFF,0);
+  if (tape.date && tape.length)
+  {
+    DrawVideoDisplay(VIDEO_STATE_DATE_ON,tape.date);
+    DrawVideoDisplay(VIDEO_STATE_TIME_ON,0);
+  }
+
+  XCopyArea(display,drawto,pix[PIX_DB_DOOR],gc,
+           VX,VY, VXSIZE,VYSIZE, DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY2);
+}
+
+void DrawSoundDisplay(unsigned long state)
+{
+  int pos, cx = DOOR_GFX_PAGEX4, cy = 0;
+
+  pos = (state & BUTTON_SOUND_MUSIC ? SOUND_BUTTON_MUSIC_XPOS :
+        state & BUTTON_SOUND_LOOPS ? SOUND_BUTTON_LOOPS_XPOS :
+        SOUND_BUTTON_SOUND_XPOS);
+
+  if (state & BUTTON_ON)
+    cy -= SOUND_BUTTON_YSIZE;
+
+  if (state & BUTTON_PRESSED)
+    cx = DOOR_GFX_PAGEX3;
+
+  XCopyArea(display,pix[PIX_DOOR],drawto,gc,
+           cx + pos,cy + SOUND_BUTTON_ANY_YPOS,
+           SOUND_BUTTON_XSIZE,SOUND_BUTTON_YSIZE,
+           DX + pos,DY + SOUND_BUTTON_ANY_YPOS);
+
+  redraw_mask |= REDRAW_DOOR_1;
+}
+
+void DrawGameButton(unsigned long state)
+{
+  int pos, cx = DOOR_GFX_PAGEX4, cy = -GAME_BUTTON_YSIZE;
+
+  pos = (state & BUTTON_GAME_STOP ? GAME_BUTTON_STOP_XPOS :
+        state & BUTTON_GAME_PAUSE ? GAME_BUTTON_PAUSE_XPOS :
+        GAME_BUTTON_PLAY_XPOS);
+
+  if (state & BUTTON_PRESSED)
+    cx = DOOR_GFX_PAGEX3;
+
+  XCopyArea(display,pix[PIX_DOOR],drawto,gc,
+           cx + pos,cy + GAME_BUTTON_ANY_YPOS,
+           GAME_BUTTON_XSIZE,GAME_BUTTON_YSIZE,
+           DX + pos,DY + GAME_BUTTON_ANY_YPOS);
+
+  redraw_mask |= REDRAW_DOOR_1;
+}
+
+void DrawChooseButton(unsigned long state)
+{
+  int pos, cx = DOOR_GFX_PAGEX4, cy = 0;
+
+  pos = (state & BUTTON_OK ? OK_BUTTON_XPOS : NO_BUTTON_XPOS);
+
+  if (state & BUTTON_PRESSED)
+    cx = DOOR_GFX_PAGEX3;
+
+  XCopyArea(display,pix[PIX_DOOR],drawto,gc,
+           cx + pos,cy + OK_BUTTON_GFX_YPOS,
+           OK_BUTTON_XSIZE,OK_BUTTON_YSIZE,
+           DX + pos,DY + OK_BUTTON_YPOS);
+
+  redraw_mask |= REDRAW_DOOR_1;
+}
+
+void DrawConfirmButton(unsigned long state)
+{
+  int cx = DOOR_GFX_PAGEX4, cy = 0;
+
+  if (state & BUTTON_PRESSED)
+    cx = DOOR_GFX_PAGEX3;
+
+  XCopyArea(display,pix[PIX_DOOR],drawto,gc,
+           cx + CONFIRM_BUTTON_XPOS,cy + CONFIRM_BUTTON_GFX_YPOS,
+           CONFIRM_BUTTON_XSIZE,CONFIRM_BUTTON_YSIZE,
+           DX + CONFIRM_BUTTON_XPOS,DY + CONFIRM_BUTTON_YPOS);
+
+  redraw_mask |= REDRAW_DOOR_1;
+}
+
+/* several buttons in the level editor */
+
+void DrawEditButton(unsigned long state)
+{
+  int i;
+  int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
+  int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY2;
+  static int edit_pos[6][4] =
+  {
+    ED_BUTTON_CTRL_XPOS,ED_BUTTON_CTRL_YPOS,
+    ED_BUTTON_CTRL_XSIZE,ED_BUTTON_CTRL_YSIZE,
+
+    ED_BUTTON_FILL_XPOS,ED_BUTTON_FILL_YPOS,
+    ED_BUTTON_FILL_XSIZE,ED_BUTTON_FILL_YSIZE,
+
+    ED_BUTTON_LEFT_XPOS,ED_BUTTON_LEFT_YPOS,
+    ED_BUTTON_LEFT_XSIZE,ED_BUTTON_LEFT_YSIZE,
+
+    ED_BUTTON_UP_XPOS,ED_BUTTON_UP_YPOS,
+    ED_BUTTON_UP_XSIZE,ED_BUTTON_UP_YSIZE,
+
+    ED_BUTTON_DOWN_XPOS,ED_BUTTON_DOWN_YPOS,
+    ED_BUTTON_DOWN_XSIZE,ED_BUTTON_DOWN_YSIZE,
+
+    ED_BUTTON_RIGHT_XPOS,ED_BUTTON_RIGHT_YPOS,
+    ED_BUTTON_RIGHT_XSIZE,ED_BUTTON_RIGHT_YSIZE
+  };
+
+  if (state & ED_BUTTON_PRESSED)
+    cx = DOOR_GFX_PAGEX5;
+
+  for(i=0;i<6;i++)
+  {
+    if (state & (1<<i))
+      XCopyArea(display,pix[PIX_DOOR],drawto,gc,
+               cx + edit_pos[i][xpos],
+               cy + edit_pos[i][ypos],
+               edit_pos[i][xsize],
+               edit_pos[i][ysize],
+               VX + edit_pos[i][xpos],
+               VY + edit_pos[i][ypos]);
+  }
+
+  redraw_mask |= REDRAW_DOOR_2;
+}
+
+void DrawCtrlButton(unsigned long state)
+{
+  int i;
+  int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
+  int cx = DOOR_GFX_PAGEX4, cy = DOOR_GFX_PAGEY1+80;
+  static int edit_pos[4][4] =
+  {
+    ED_BUTTON_EDIT_XPOS,ED_BUTTON_EDIT_YPOS,
+    ED_BUTTON_EDIT_XSIZE,ED_BUTTON_EDIT_YSIZE,
+
+    ED_BUTTON_CLEAR_XPOS,ED_BUTTON_CLEAR_YPOS,
+    ED_BUTTON_CLEAR_XSIZE,ED_BUTTON_CLEAR_YSIZE,
+
+    ED_BUTTON_UNDO_XPOS,ED_BUTTON_UNDO_YPOS,
+    ED_BUTTON_UNDO_XSIZE,ED_BUTTON_UNDO_YSIZE,
+
+    ED_BUTTON_EXIT_XPOS,ED_BUTTON_EXIT_YPOS,
+    ED_BUTTON_EXIT_XSIZE,ED_BUTTON_EXIT_YSIZE
+  };
+
+  if (state & ED_BUTTON_PRESSED)
+    cx = DOOR_GFX_PAGEX3;
+
+  for(i=0;i<4;i++)
+  {
+    if (state & (1<<(i+6)))
+      XCopyArea(display,pix[PIX_DOOR],drawto,gc,
+               cx + edit_pos[i][xpos],
+               cy + edit_pos[i][ypos],
+               edit_pos[i][xsize],
+               edit_pos[i][ysize],
+               VX + edit_pos[i][xpos],
+               VY + edit_pos[i][ypos]);
+  }
+
+  redraw_mask |= REDRAW_DOOR_2;
+}
+
+void DrawElemButton(int button_nr, int button_state)
+{
+  int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
+  int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY1;
+  int from_x, from_y, to_x,to_y, size_x, size_y;
+  static int edit_pos[3][4] =
+  {
+    ED_BUTTON_EUP_XPOS,ED_BUTTON_EUP_YPOS,
+    ED_BUTTON_EUP_XSIZE,ED_BUTTON_EUP_YSIZE,
+
+    ED_BUTTON_EDOWN_XPOS,ED_BUTTON_EDOWN_YPOS,
+    ED_BUTTON_EDOWN_XSIZE,ED_BUTTON_EDOWN_YSIZE,
+
+    ED_BUTTON_ELEM_XPOS,ED_BUTTON_ELEM_YPOS,
+    ED_BUTTON_ELEM_XSIZE,ED_BUTTON_ELEM_YSIZE
+  };
+
+  if (button_nr<ED_BUTTON_ELEM)
+  {
+    int pos = button_nr;
+
+    from_x = cx + edit_pos[pos][xpos];
+    from_y = cy + edit_pos[pos][ypos];
+    size_x = edit_pos[pos][xsize];
+    size_y = edit_pos[pos][ysize];
+    to_x   = DX + edit_pos[pos][xpos];
+    to_y   = DY + edit_pos[pos][ypos];
+
+    if (button_state & ED_BUTTON_PRESSED)
+    {
+      if (button_nr==ED_BUTTON_EUP)
+       from_y = cy + ED_BUTTON_EUP_Y2POS;
+      else
+       from_y = cy + ED_BUTTON_EDOWN_Y2POS;
+    }
+
+    XCopyArea(display,pix[PIX_DOOR],drawto,gc,
+             from_x,from_y, size_x,size_y, to_x,to_y);
+  }
+  else
+  {
+    int pos = ED_BUTTON_ELEM;
+    int elem_pos = button_nr-ED_BUTTON_ELEM;
+    int x = elem_pos % MAX_ELEM_X;
+    int y = elem_pos / MAX_ELEM_X;
+    int graphic;
+    int shift = 0;
+
+    if (elem_pos+element_shift < elements_in_list)
+      graphic = el2gfx(editor_element[elem_pos+element_shift]);
+    else
+      graphic = GFX_LEERRAUM;
+
+    from_x = cx + edit_pos[pos][xpos];
+    from_y = cy + edit_pos[pos][ypos];
+    size_x = edit_pos[pos][xsize];
+    size_y = edit_pos[pos][ysize];
+    to_x   = DX + edit_pos[pos][xpos] + x * ED_BUTTON_ELEM_XSIZE;
+    to_y   = DY + edit_pos[pos][ypos] + y * ED_BUTTON_ELEM_YSIZE;
+
+    if (button_state & ED_BUTTON_PRESSED)
+    {
+      from_y = ED_BUTTON_ELEM_Y2POS;
+      shift = 1;
+    }
+
+    XCopyArea(display,pix[PIX_DOOR],drawto,gc,
+             from_x,from_y, size_x,size_y, to_x,to_y);
+
+    DrawMiniGraphicExtHiRes(drawto,gc,
+                           DX+ED_BUTTON_ELEM_XPOS+3+shift + 
+                           (elem_pos % MAX_ELEM_X)*ED_BUTTON_ELEM_XSIZE,
+                           DY+ED_BUTTON_ELEM_YPOS+3-shift +
+                           (elem_pos / MAX_ELEM_X)*ED_BUTTON_ELEM_YSIZE,
+                           graphic);
+  }
+
+  redraw_mask |= REDRAW_DOOR_1;
+}
+
+void DrawCountButton(int button_nr, int button_state)
+{
+  int from_x, from_y, to_x,to_y, size_x, size_y;
+
+  from_x =
+    DOOR_GFX_PAGEX4+(button_nr%2 ? ED_BUTTON_PLUS_XPOS : ED_BUTTON_MINUS_XPOS);
+  from_y = DOOR_GFX_PAGEY1 + ED_BUTTON_MINUS_YPOS;
+  size_x = ED_BUTTON_MINUS_XSIZE;
+  size_y = ED_BUTTON_MINUS_YSIZE;
+  to_x = (button_nr<32 ? ED_COUNT_GADGET_XPOS : ED_SIZE_GADGET_XPOS);
+  if (button_nr % 2)
+    to_x += (ED_BUTTON_PLUS_XPOS - ED_BUTTON_MINUS_XPOS);
+  to_y = (button_nr<32 ? ED_COUNT_GADGET_YPOS : ED_SIZE_GADGET_YPOS) +
+    ((button_nr<32 ? button_nr : button_nr-32)/2)*ED_COUNT_GADGET_YSIZE;
+
+  if (button_state & ED_BUTTON_PRESSED)
+    from_x -= DXSIZE;
+
+  XCopyArea(display,pix[PIX_DOOR],drawto,gc,
+           from_x,from_y, size_x,size_y, to_x,to_y);
+  XCopyArea(display,pix[PIX_DOOR],window,gc,
+           from_x,from_y, size_x,size_y, to_x,to_y);
+}
+
+/**********************************************************************/
+/********** checking buttons (and redrawing them, if needed) **********/
+/**********************************************************************/
+
+int CheckVideoButtons(int mx, int my, int button)
+{
+  int return_code = 0;
+  static int choice = -1;
+  static BOOL pressed = FALSE;
+  static int video_button[5] =
+  {
+    VIDEO_PRESS_EJECT_ON,
+    VIDEO_PRESS_STOP_ON,
+    VIDEO_PRESS_PAUSE_ON,
+    VIDEO_PRESS_REC_ON,
+    VIDEO_PRESS_PLAY_ON
+  };
+
+  if (button)
+  {
+    if (!motion_status)                /* Maustaste neu gedrückt */
+    {
+      if (ON_VIDEO_BUTTON(mx,my))
+      {
+       choice = VIDEO_BUTTON(mx);
+       pressed = TRUE;
+       DrawVideoDisplay(video_button[choice],0);
+      }
+    }
+    else                       /* Mausbewegung bei gedrückter Maustaste */
+    {
+      if ((!ON_VIDEO_BUTTON(mx,my) || VIDEO_BUTTON(mx)!=choice) &&
+         choice>=0 && pressed)
+      {
+       pressed = FALSE;
+       DrawVideoDisplay(video_button[choice]<<1,0);
+      }
+      else if (ON_VIDEO_BUTTON(mx,my) && VIDEO_BUTTON(mx)==choice && !pressed)
+      {
+       pressed = TRUE;
+       DrawVideoDisplay(video_button[choice],0);
+      }
+    }
+  }
+  else                         /* Maustaste wieder losgelassen */
+  {
+    if (ON_VIDEO_BUTTON(mx,my) && VIDEO_BUTTON(mx)==choice && pressed)
+    {
+      DrawVideoDisplay(video_button[choice]<<1,0);
+      return_code = choice+1;
+      choice = -1;
+      pressed = FALSE;
+    }
+    else
+    {
+      choice = -1;
+      pressed = FALSE;
+    }
+  }
+
+  BackToFront();
+  return(return_code);
+}
+
+int CheckSoundButtons(int mx, int my, int button)
+{
+  int return_code = 0;
+  static int choice = -1;
+  static BOOL pressed = FALSE;
+  int sound_state[3];
+
+  sound_state[0] = BUTTON_SOUND_MUSIC | (BUTTON_ON * sound_music_on);
+  sound_state[1] = BUTTON_SOUND_LOOPS | (BUTTON_ON * sound_loops_on);
+  sound_state[2] = BUTTON_SOUND_SOUND | (BUTTON_ON * sound_on);
+
+  if (button)
+  {
+    if (!motion_status)                /* Maustaste neu gedrückt */
+    {
+      if (ON_SOUND_BUTTON(mx,my))
+      {
+       choice = SOUND_BUTTON(mx);
+       pressed = TRUE;
+       DrawSoundDisplay(sound_state[choice] | BUTTON_PRESSED);
+      }
+    }
+    else                       /* Mausbewegung bei gedrückter Maustaste */
+    {
+      if ((!ON_SOUND_BUTTON(mx,my) || SOUND_BUTTON(mx)!=choice) &&
+         choice>=0 && pressed)
+      {
+       pressed = FALSE;
+       DrawSoundDisplay(sound_state[choice] | BUTTON_RELEASED);
+      }
+      else if (ON_SOUND_BUTTON(mx,my) && SOUND_BUTTON(mx)==choice && !pressed)
+      {
+       pressed = TRUE;
+       DrawSoundDisplay(sound_state[choice] | BUTTON_PRESSED);
+      }
+    }
+  }
+  else                         /* Maustaste wieder losgelassen */
+  {
+    if (ON_SOUND_BUTTON(mx,my) && SOUND_BUTTON(mx)==choice && pressed)
+    {
+      DrawSoundDisplay(sound_state[choice] | BUTTON_RELEASED);
+      return_code = 1<<choice;
+      choice = -1;
+      pressed = FALSE;
+    }
+    else
+    {
+      choice = -1;
+      pressed = FALSE;
+    }
+  }
+
+  BackToFront();
+  return(return_code);
+}
+
+int CheckGameButtons(int mx, int my, int button)
+{
+  int return_code = 0;
+  static int choice = -1;
+  static BOOL pressed = FALSE;
+  int game_state[3] =
+  {
+    BUTTON_GAME_STOP,
+    BUTTON_GAME_PAUSE,
+    BUTTON_GAME_PLAY
+  };
+
+  if (button)
+  {
+    if (!motion_status)                /* Maustaste neu gedrückt */
+    {
+      if (ON_GAME_BUTTON(mx,my))
+      {
+       choice = GAME_BUTTON(mx);
+       pressed = TRUE;
+       DrawGameButton(game_state[choice] | BUTTON_PRESSED);
+      }
+    }
+    else                       /* Mausbewegung bei gedrückter Maustaste */
+    {
+      if ((!ON_GAME_BUTTON(mx,my) || GAME_BUTTON(mx)!=choice) &&
+         choice>=0 && pressed)
+      {
+       pressed = FALSE;
+       DrawGameButton(game_state[choice] | BUTTON_RELEASED);
+      }
+      else if (ON_GAME_BUTTON(mx,my) && GAME_BUTTON(mx)==choice && !pressed)
+      {
+       pressed = TRUE;
+       DrawGameButton(game_state[choice] | BUTTON_PRESSED);
+      }
+    }
+  }
+  else                         /* Maustaste wieder losgelassen */
+  {
+    if (ON_GAME_BUTTON(mx,my) && GAME_BUTTON(mx)==choice && pressed)
+    {
+      DrawGameButton(game_state[choice] | BUTTON_RELEASED);
+      return_code = 1<<choice;
+      choice = -1;
+      pressed = FALSE;
+    }
+    else
+    {
+      choice = -1;
+      pressed = FALSE;
+    }
+  }
+
+  BackToFront();
+  return(return_code);
+}
+
+int CheckChooseButtons(int mx, int my, int button)
+{
+  int return_code = 0;
+  static int choice = -1;
+  static BOOL pressed = FALSE;
+  static int choose_button[5] =
+  {
+    BUTTON_OK,
+    BUTTON_NO
+  };
+
+  if (button)
+  {
+    if (!motion_status)                /* Maustaste neu gedrückt */
+    {
+      if (ON_CHOOSE_BUTTON(mx,my))
+      {
+       choice = CHOOSE_BUTTON(mx);
+       pressed = TRUE;
+       DrawChooseButton(choose_button[choice] | BUTTON_PRESSED);
+      }
+    }
+    else                       /* Mausbewegung bei gedrückter Maustaste */
+    {
+      if ((!ON_CHOOSE_BUTTON(mx,my) || CHOOSE_BUTTON(mx)!=choice) &&
+         choice>=0 && pressed)
+      {
+       pressed = FALSE;
+       DrawChooseButton(choose_button[choice] | BUTTON_RELEASED);
+      }
+      else if (ON_CHOOSE_BUTTON(mx,my) &&CHOOSE_BUTTON(mx)==choice && !pressed)
+      {
+       pressed = TRUE;
+       DrawChooseButton(choose_button[choice] | BUTTON_PRESSED);
+      }
+    }
+  }
+  else                         /* Maustaste wieder losgelassen */
+  {
+    if (ON_CHOOSE_BUTTON(mx,my) && CHOOSE_BUTTON(mx)==choice && pressed)
+    {
+      DrawChooseButton(choose_button[choice] | BUTTON_RELEASED);
+      return_code = choice+1;
+      choice = -1;
+      pressed = FALSE;
+    }
+    else
+    {
+      choice = -1;
+      pressed = FALSE;
+    }
+  }
+
+  BackToFront();
+  return(return_code);
+}
+
+int CheckConfirmButton(int mx, int my, int button)
+{
+  int return_code = 0;
+  static int choice = -1;
+  static BOOL pressed = FALSE;
+
+  if (button)
+  {
+    if (!motion_status)                /* Maustaste neu gedrückt */
+    {
+      if (ON_CONFIRM_BUTTON(mx,my))
+      {
+       choice = 0;
+       pressed = TRUE;
+       DrawConfirmButton(BUTTON_PRESSED);
+      }
+    }
+    else                       /* Mausbewegung bei gedrückter Maustaste */
+    {
+      if (!ON_CONFIRM_BUTTON(mx,my) && choice>=0 && pressed)
+      {
+       pressed = FALSE;
+       DrawConfirmButton(BUTTON_RELEASED);
+      }
+      else if (ON_CONFIRM_BUTTON(mx,my) && !pressed)
+      {
+       pressed = TRUE;
+       DrawConfirmButton(BUTTON_PRESSED);
+      }
+    }
+  }
+  else                         /* Maustaste wieder losgelassen */
+  {
+    if (ON_CONFIRM_BUTTON(mx,my) && pressed)
+    {
+      DrawConfirmButton(BUTTON_RELEASED);
+      return_code = BUTTON_CONFIRM;
+      choice = -1;
+      pressed = FALSE;
+    }
+    else
+    {
+      choice = -1;
+      pressed = FALSE;
+    }
+  }
+
+  BackToFront();
+  return(return_code);
+}
+
+/* several buttons in the level editor */
+
+int CheckEditButtons(int mx, int my, int button)
+{
+  int return_code = 0;
+  static int choice = -1;
+  static BOOL pressed = FALSE;
+  static int edit_button[6] =
+  {
+    ED_BUTTON_CTRL,
+    ED_BUTTON_FILL,
+    ED_BUTTON_LEFT,
+    ED_BUTTON_UP,
+    ED_BUTTON_DOWN,
+    ED_BUTTON_RIGHT
+  };
+
+  if (button)
+  {
+    if (!motion_status)                /* Maustaste neu gedrückt */
+    {
+      if (ON_EDIT_BUTTON(mx,my))
+      {
+       choice = EDIT_BUTTON(mx,my);
+       pressed = TRUE;
+       DrawEditButton(edit_button[choice] | ED_BUTTON_PRESSED);
+       if (edit_button[choice]!=ED_BUTTON_CTRL &&
+           edit_button[choice]!=ED_BUTTON_FILL)
+         return_code = 1<<choice;
+      }
+    }
+    else                       /* Mausbewegung bei gedrückter Maustaste */
+    {
+      if ((!ON_EDIT_BUTTON(mx,my) || EDIT_BUTTON(mx,my)!=choice) &&
+         choice>=0 && pressed)
+      {
+       pressed = FALSE;
+       DrawEditButton(edit_button[choice] | ED_BUTTON_RELEASED);
+      }
+      else if (ON_EDIT_BUTTON(mx,my) && EDIT_BUTTON(mx,my)==choice)
+      {
+       if (!pressed)
+         DrawEditButton(edit_button[choice] | ED_BUTTON_PRESSED);
+       pressed = TRUE;
+       if (edit_button[choice]!=ED_BUTTON_CTRL &&
+           edit_button[choice]!=ED_BUTTON_FILL)
+         return_code = 1<<choice;
+      }
+    }
+  }
+  else                         /* Maustaste wieder losgelassen */
+  {
+    if (ON_EDIT_BUTTON(mx,my) && EDIT_BUTTON(mx,my)==choice && pressed)
+    {
+      DrawEditButton(edit_button[choice] | ED_BUTTON_RELEASED);
+      if (edit_button[choice]==ED_BUTTON_CTRL ||
+         edit_button[choice]==ED_BUTTON_FILL)
+       return_code = 1<<choice;
+      choice = -1;
+      pressed = FALSE;
+    }
+    else
+    {
+      choice = -1;
+      pressed = FALSE;
+    }
+  }
+
+  BackToFront();
+  return(return_code);
+}
+
+int CheckCtrlButtons(int mx, int my, int button)
+{
+  int return_code = 0;
+  static int choice = -1;
+  static BOOL pressed = FALSE;
+  static int ctrl_button[4] =
+  {
+    ED_BUTTON_EDIT,
+    ED_BUTTON_CLEAR,
+    ED_BUTTON_UNDO,
+    ED_BUTTON_EXIT
+  };
+
+  if (button)
+  {
+    if (!motion_status)                /* Maustaste neu gedrückt */
+    {
+      if (ON_CTRL_BUTTON(mx,my))
+      {
+       choice = CTRL_BUTTON(mx,my);
+       pressed = TRUE;
+       DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_PRESSED);
+      }
+    }
+    else                       /* Mausbewegung bei gedrückter Maustaste */
+    {
+      if ((!ON_CTRL_BUTTON(mx,my) || CTRL_BUTTON(mx,my)!=choice) &&
+         choice>=0 && pressed)
+      {
+       pressed = FALSE;
+       DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_RELEASED);
+      }
+      else if (ON_CTRL_BUTTON(mx,my) && CTRL_BUTTON(mx,my)==choice && !pressed)
+      {
+       pressed = TRUE;
+       DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_PRESSED);
+      }
+    }
+  }
+  else                         /* Maustaste wieder losgelassen */
+  {
+    if (ON_CTRL_BUTTON(mx,my) && CTRL_BUTTON(mx,my)==choice && pressed)
+    {
+      DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_RELEASED);
+      return_code = 1<<(choice+6);
+      choice = -1;
+      pressed = FALSE;
+    }
+    else
+    {
+      choice = -1;
+      pressed = FALSE;
+    }
+  }
+
+  BackToFront();
+  return(return_code);
+}
+
+int CheckElemButtons(int mx, int my, int button)
+{
+  int return_code = -1;
+  static int choice = -1;
+  static BOOL pressed = FALSE;
+
+  if (button)
+  {
+    if (!motion_status)                /* Maustaste neu gedrückt */
+    {
+      if (ON_ELEM_BUTTON(mx,my))
+      {
+       choice = ELEM_BUTTON(mx,my);
+       pressed = TRUE;
+       DrawElemButton(choice,ED_BUTTON_PRESSED);
+       if (choice==ED_BUTTON_EUP ||
+           choice==ED_BUTTON_EDOWN)
+         return_code = choice;
+      }
+    }
+    else                       /* Mausbewegung bei gedrückter Maustaste */
+    {
+      if ((!ON_ELEM_BUTTON(mx,my) || ELEM_BUTTON(mx,my)!=choice) &&
+         choice>=0 && pressed)
+      {
+       pressed = FALSE;
+       DrawElemButton(choice,ED_BUTTON_RELEASED);
+      }
+      else if (ON_ELEM_BUTTON(mx,my) && ELEM_BUTTON(mx,my)==choice)
+      {
+       if (!pressed)
+         DrawElemButton(choice,ED_BUTTON_PRESSED);
+       pressed = TRUE;
+       if (choice==ED_BUTTON_EUP ||
+           choice==ED_BUTTON_EDOWN)
+         return_code = choice;
+      }
+    }
+  }
+  else                         /* Maustaste wieder losgelassen */
+  {
+    if (ON_ELEM_BUTTON(mx,my) && ELEM_BUTTON(mx,my)==choice && pressed)
+    {
+      DrawElemButton(choice,ED_BUTTON_RELEASED);
+      if (choice!=ED_BUTTON_EUP &&
+         choice!=ED_BUTTON_EDOWN)
+       return_code = choice;
+      choice = -1;
+      pressed = FALSE;
+    }
+    else
+    {
+      choice = -1;
+      pressed = FALSE;
+    }
+  }
+
+  BackToFront();
+  return(return_code);
+}
+
+int CheckCountButtons(int mx, int my, int button)
+{
+  int return_code = -1;
+  static int choice = -1;
+  static BOOL pressed = FALSE;
+
+  if (button)
+  {
+    if (!motion_status)                /* Maustaste neu gedrückt */
+    {
+      if (ON_COUNT_BUTTON(mx,my))
+      {
+       choice = COUNT_BUTTON(mx,my);
+       pressed = TRUE;
+       DrawCountButton(choice,ED_BUTTON_PRESSED);
+       return_code = choice;
+      }
+    }
+    else                       /* Mausbewegung bei gedrückter Maustaste */
+    {
+      if ((!ON_COUNT_BUTTON(mx,my) || COUNT_BUTTON(mx,my)!=choice) &&
+         choice>=0 && pressed)
+      {
+       pressed = FALSE;
+       DrawCountButton(choice,ED_BUTTON_RELEASED);
+      }
+      else if (ON_COUNT_BUTTON(mx,my) && COUNT_BUTTON(mx,my)==choice)
+      {
+       if (!pressed)
+         DrawCountButton(choice,ED_BUTTON_PRESSED);
+       pressed = TRUE;
+       return_code = choice;
+      }
+    }
+  }
+  else                         /* Maustaste wieder losgelassen */
+  {
+    if (ON_COUNT_BUTTON(mx,my) && COUNT_BUTTON(mx,my)==choice && pressed)
+    {
+      DrawCountButton(choice,ED_BUTTON_RELEASED);
+      choice = -1;
+      pressed = FALSE;
+    }
+    else
+    {
+      choice = -1;
+      pressed = FALSE;
+    }
+  }
+
+  BackToFront();
+  return(return_code);
+}
diff --git a/src/buttons.h b/src/buttons.h
new file mode 100644 (file)
index 0000000..98ac5ca
--- /dev/null
@@ -0,0 +1,509 @@
+/***********************************************************
+*  Rocks'n'Diamonds -- McDuffin Strikes Back!              *
+*----------------------------------------------------------*
+*  ©1995 Artsoft Development                               *
+*        Holger Schemel                                    *
+*        33659 Bielefeld-Senne                             *
+*        Telefon: (0521) 493245                            *
+*        eMail: aeglos@valinor.owl.de                      *
+*               aeglos@uni-paderborn.de                    *
+*               q99492@pbhrzx.uni-paderborn.de             *
+*----------------------------------------------------------*
+*  buttons.h                                               *
+***********************************************************/
+
+#ifndef BUTTONS_H
+#define BUTTONS_H
+
+#include "main.h"
+
+/* some positions in the video tape control window */
+#define VIDEO_DISPLAY1_XPOS    5
+#define VIDEO_DISPLAY1_YPOS    5
+#define VIDEO_DISPLAY2_XPOS    5
+#define VIDEO_DISPLAY2_YPOS    41
+#define VIDEO_DISPLAY_XSIZE    90
+#define VIDEO_DISPLAY_YSIZE    31
+#define VIDEO_BUTTON_XSIZE     18
+#define VIDEO_BUTTON_YSIZE     18
+#define VIDEO_CONTROL_XPOS     5
+#define VIDEO_CONTROL_YPOS     77
+#define VIDEO_CONTROL_XSIZE    (VIDEO_DISPLAY_XSIZE)
+#define VIDEO_CONTROL_YSIZE    (VIDEO_BUTTON_YSIZE)
+#define VIDEO_BUTTON_EJECT_XPOS        (VIDEO_CONTROL_XPOS + 0 * VIDEO_BUTTON_XSIZE)
+#define VIDEO_BUTTON_STOP_XPOS (VIDEO_CONTROL_XPOS + 1 * VIDEO_BUTTON_XSIZE)
+#define VIDEO_BUTTON_PAUSE_XPOS        (VIDEO_CONTROL_XPOS + 2 * VIDEO_BUTTON_XSIZE)
+#define VIDEO_BUTTON_REC_XPOS  (VIDEO_CONTROL_XPOS + 3 * VIDEO_BUTTON_XSIZE)
+#define VIDEO_BUTTON_PLAY_XPOS (VIDEO_CONTROL_XPOS + 4 * VIDEO_BUTTON_XSIZE)
+#define VIDEO_BUTTON_ANY_YPOS  (VIDEO_CONTROL_YPOS)
+#define VIDEO_DATE_LABEL_XPOS  (VIDEO_DISPLAY1_XPOS)
+#define VIDEO_DATE_LABEL_YPOS  (VIDEO_DISPLAY1_YPOS)
+#define VIDEO_DATE_LABEL_XSIZE (VIDEO_DISPLAY_XSIZE)
+#define VIDEO_DATE_LABEL_YSIZE (VIDEO_DISPLAY_YSIZE)
+#define VIDEO_DATE_XPOS                (VIDEO_DISPLAY1_XPOS+1)
+#define VIDEO_DATE_YPOS                (VIDEO_DISPLAY1_YPOS+14)
+#define VIDEO_DATE_XSIZE       (VIDEO_DISPLAY_XSIZE)
+#define VIDEO_DATE_YSIZE       16
+#define VIDEO_REC_LABEL_XPOS   (VIDEO_DISPLAY2_XPOS)
+#define VIDEO_REC_LABEL_YPOS   (VIDEO_DISPLAY2_YPOS)
+#define VIDEO_REC_LABEL_XSIZE  20
+#define VIDEO_REC_LABEL_YSIZE  12
+#define VIDEO_REC_SYMBOL_XPOS  (VIDEO_DISPLAY2_XPOS+20)
+#define VIDEO_REC_SYMBOL_YPOS  (VIDEO_DISPLAY2_YPOS)
+#define VIDEO_REC_SYMBOL_XSIZE 16
+#define VIDEO_REC_SYMBOL_YSIZE 16
+#define VIDEO_PLAY_LABEL_XPOS  (VIDEO_DISPLAY2_XPOS+65)
+#define VIDEO_PLAY_LABEL_YPOS  (VIDEO_DISPLAY2_YPOS)
+#define VIDEO_PLAY_LABEL_XSIZE 22
+#define VIDEO_PLAY_LABEL_YSIZE 12
+#define VIDEO_PLAY_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS+50)
+#define VIDEO_PLAY_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS)
+#define VIDEO_PLAY_SYMBOL_XSIZE        13
+#define VIDEO_PLAY_SYMBOL_YSIZE        13
+#define VIDEO_PAUSE_LABEL_XPOS (VIDEO_DISPLAY2_XPOS)
+#define VIDEO_PAUSE_LABEL_YPOS (VIDEO_DISPLAY2_YPOS+20)
+#define VIDEO_PAUSE_LABEL_XSIZE        35
+#define VIDEO_PAUSE_LABEL_YSIZE        8
+#define VIDEO_PAUSE_SYMBOL_XPOS        (VIDEO_DISPLAY2_XPOS+35)
+#define VIDEO_PAUSE_SYMBOL_YPOS        (VIDEO_DISPLAY2_YPOS)
+#define VIDEO_PAUSE_SYMBOL_XSIZE 13
+#define VIDEO_PAUSE_SYMBOL_YSIZE 13
+#define VIDEO_TIME_XPOS                (VIDEO_DISPLAY2_XPOS+38)
+#define VIDEO_TIME_YPOS                (VIDEO_DISPLAY2_YPOS+14)
+#define VIDEO_TIME_XSIZE       50
+#define VIDEO_TIME_YSIZE       16
+
+#define ON_VIDEO_BUTTON(x,y)   ((x)>=(VX+VIDEO_CONTROL_XPOS) &&        \
+                                (x)< (VX+VIDEO_CONTROL_XPOS +          \
+                                      VIDEO_CONTROL_XSIZE) &&          \
+                                (y)>=(VY+VIDEO_CONTROL_YPOS) &&        \
+                                (y)< (VY+VIDEO_CONTROL_YPOS +          \
+                                      VIDEO_CONTROL_YSIZE))
+#define VIDEO_BUTTON(x)                (((x)-(VX+VIDEO_CONTROL_XPOS))/VIDEO_BUTTON_XSIZE)
+
+/* values for video tape control */
+#define VIDEO_STATE_PLAY_OFF   (1L<<0)
+#define VIDEO_STATE_PLAY_ON    (1L<<1)
+#define VIDEO_STATE_PLAY       (VIDEO_STATE_PLAY_OFF   | VIDEO_STATE_PLAY_ON)
+#define VIDEO_STATE_REC_OFF    (1L<<2)
+#define VIDEO_STATE_REC_ON     (1L<<3)
+#define VIDEO_STATE_REC                (VIDEO_STATE_REC_OFF    | VIDEO_STATE_REC_ON)
+#define VIDEO_STATE_PAUSE_OFF  (1L<<4)
+#define VIDEO_STATE_PAUSE_ON   (1L<<5)
+#define VIDEO_STATE_PAUSE      (VIDEO_STATE_PAUSE_OFF  | VIDEO_STATE_PAUSE_ON)
+#define VIDEO_STATE_DATE_OFF   (1L<<6)
+#define VIDEO_STATE_DATE_ON    (1L<<7)
+#define VIDEO_STATE_DATE       (VIDEO_STATE_DATE_OFF   | VIDEO_STATE_DATE_ON)
+#define VIDEO_STATE_TIME_OFF   (1L<<8)
+#define VIDEO_STATE_TIME_ON    (1L<<9)
+#define VIDEO_STATE_TIME       (VIDEO_STATE_TIME_OFF   | VIDEO_STATE_TIME_ON)
+#define VIDEO_PRESS_PLAY_ON    (1L<<10)
+#define VIDEO_PRESS_PLAY_OFF   (1L<<11)
+#define VIDEO_PRESS_PLAY       (VIDEO_PRESS_PLAY_OFF   | VIDEO_PRESS_PLAY_ON)
+#define VIDEO_PRESS_REC_ON     (1L<<12)
+#define VIDEO_PRESS_REC_OFF    (1L<<13)
+#define VIDEO_PRESS_REC                (VIDEO_PRESS_REC_OFF    | VIDEO_PRESS_REC_ON)
+#define VIDEO_PRESS_PAUSE_ON   (1L<<14)
+#define VIDEO_PRESS_PAUSE_OFF  (1L<<15)
+#define VIDEO_PRESS_PAUSE      (VIDEO_PRESS_PAUSE_OFF  | VIDEO_PRESS_PAUSE_ON)
+#define VIDEO_PRESS_STOP_ON    (1L<<16)
+#define VIDEO_PRESS_STOP_OFF   (1L<<17)
+#define VIDEO_PRESS_STOP       (VIDEO_PRESS_STOP_OFF   | VIDEO_PRESS_STOP_ON)
+#define VIDEO_PRESS_EJECT_ON   (1L<<18)
+#define VIDEO_PRESS_EJECT_OFF  (1L<<19)
+#define VIDEO_PRESS_EJECT      (VIDEO_PRESS_EJECT_OFF  | VIDEO_PRESS_EJECT_ON)
+
+#define BUTTON_VIDEO_EJECT     1
+#define BUTTON_VIDEO_STOP      2
+#define BUTTON_VIDEO_PAUSE     3
+#define BUTTON_VIDEO_REC       4
+#define BUTTON_VIDEO_PLAY      5
+
+#define VIDEO_STATE_OFF                (VIDEO_STATE_PLAY_OFF   |       \
+                                VIDEO_STATE_REC_OFF    |       \
+                                VIDEO_STATE_PAUSE_OFF  |       \
+                                VIDEO_STATE_DATE_OFF   |       \
+                                VIDEO_STATE_TIME_OFF)
+#define VIDEO_PRESS_OFF                (VIDEO_PRESS_PLAY_OFF   |       \
+                                VIDEO_PRESS_REC_OFF    |       \
+                                VIDEO_PRESS_PAUSE_OFF  |       \
+                                VIDEO_PRESS_STOP_OFF   |       \
+                                VIDEO_PRESS_EJECT_OFF)
+#define VIDEO_ALL_OFF          (VIDEO_STATE_OFF | VIDEO_PRESS_OFF)
+
+#define VIDEO_STATE_ON         (VIDEO_STATE_PLAY_ON    |       \
+                                VIDEO_STATE_REC_ON     |       \
+                                VIDEO_STATE_PAUSE_ON   |       \
+                                VIDEO_STATE_DATE_ON    |       \
+                                VIDEO_STATE_TIME_ON)
+#define VIDEO_PRESS_ON         (VIDEO_PRESS_PLAY_ON    |       \
+                                VIDEO_PRESS_REC_ON     |       \
+                                VIDEO_PRESS_PAUSE_ON   |       \
+                                VIDEO_PRESS_STOP_ON    |       \
+                                VIDEO_PRESS_EJECT_ON)
+#define VIDEO_ALL_ON           (VIDEO_STATE_ON | VIDEO_PRESS_ON)
+
+#define VIDEO_STATE            (VIDEO_STATE_ON | VIDEO_STATE_OFF)
+#define VIDEO_PRESS            (VIDEO_PRESS_ON | VIDEO_PRESS_OFF)
+#define VIDEO_ALL              (VIDEO_ALL_ON | VIDEO_ALL_OFF)
+
+
+/* some positions in the sound control window */
+#define SOUND_BUTTON_XSIZE     30
+#define SOUND_BUTTON_YSIZE     30
+#define SOUND_CONTROL_XPOS     5
+#define SOUND_CONTROL_YPOS     245
+#define SOUND_CONTROL_XSIZE    90
+#define SOUND_CONTROL_YSIZE    (SOUND_BUTTON_YSIZE)
+#define SOUND_BUTTON_MUSIC_XPOS        (SOUND_CONTROL_XPOS + 0 * SOUND_BUTTON_XSIZE)
+#define SOUND_BUTTON_LOOPS_XPOS        (SOUND_CONTROL_XPOS + 1 * SOUND_BUTTON_XSIZE)
+#define SOUND_BUTTON_SOUND_XPOS        (SOUND_CONTROL_XPOS + 2 * SOUND_BUTTON_XSIZE)
+#define SOUND_BUTTON_ANY_YPOS  (SOUND_CONTROL_YPOS)
+
+#define ON_SOUND_BUTTON(x,y)   ((x)>=(DX+SOUND_CONTROL_XPOS) &&        \
+                                (x)< (DX+SOUND_CONTROL_XPOS +          \
+                                      SOUND_CONTROL_XSIZE) &&          \
+                                (y)>=(DY+SOUND_CONTROL_YPOS) &&        \
+                                (y)< (DY+SOUND_CONTROL_YPOS +          \
+                                      SOUND_CONTROL_YSIZE))
+#define SOUND_BUTTON(x)                (((x)-(DX+SOUND_CONTROL_XPOS))/SOUND_BUTTON_XSIZE)
+
+/* values for sound control */
+#define BUTTON_SOUND_MUSIC     (1L<<0)
+#define BUTTON_SOUND_LOOPS     (1L<<1)
+#define BUTTON_SOUND_SOUND     (1L<<2)
+#define BUTTON_RELEASED                0
+#define BUTTON_PRESSED         (1L<<3)
+#define BUTTON_OFF             0
+#define BUTTON_ON              (1L<<4)
+#define BUTTON_SOUND_MUSIC_OFF (BUTTON_SOUND_MUSIC | BUTTON_OFF)
+#define BUTTON_SOUND_LOOPS_OFF (BUTTON_SOUND_LOOPS | BUTTON_OFF)
+#define BUTTON_SOUND_SOUND_OFF (BUTTON_SOUND_SOUND | BUTTON_OFF)
+#define BUTTON_SOUND_MUSIC_ON  (BUTTON_SOUND_MUSIC | BUTTON_ON)
+#define BUTTON_SOUND_LOOPS_ON  (BUTTON_SOUND_LOOPS | BUTTON_ON)
+#define BUTTON_SOUND_SOUND_ON  (BUTTON_SOUND_SOUND | BUTTON_ON)
+
+
+/* some positions in the game control window */
+#define GAME_BUTTON_XSIZE      30
+#define GAME_BUTTON_YSIZE      30
+#define GAME_CONTROL_XPOS      5
+#define GAME_CONTROL_YPOS      215
+#define GAME_CONTROL_XSIZE     90
+#define GAME_CONTROL_YSIZE     (GAME_BUTTON_YSIZE)
+#define GAME_BUTTON_STOP_XPOS  (GAME_CONTROL_XPOS + 0 * GAME_BUTTON_XSIZE)
+#define GAME_BUTTON_PAUSE_XPOS (GAME_CONTROL_XPOS + 1 * GAME_BUTTON_XSIZE)
+#define GAME_BUTTON_PLAY_XPOS  (GAME_CONTROL_XPOS + 2 * GAME_BUTTON_XSIZE)
+#define GAME_BUTTON_ANY_YPOS   (GAME_CONTROL_YPOS)
+
+#define ON_GAME_BUTTON(x,y)    ((x)>=(DX+GAME_CONTROL_XPOS) && \
+                                (x)< (DX+GAME_CONTROL_XPOS +           \
+                                      GAME_CONTROL_XSIZE) &&           \
+                                (y)>=(DY+GAME_CONTROL_YPOS) && \
+                                (y)< (DY+GAME_CONTROL_YPOS +           \
+                                      GAME_CONTROL_YSIZE))
+#define GAME_BUTTON(x)         (((x)-(DX+GAME_CONTROL_XPOS))/GAME_BUTTON_XSIZE)
+
+/* values for game control */
+#define BUTTON_GAME_STOP       (1L<<0)
+#define BUTTON_GAME_PAUSE      (1L<<1)
+#define BUTTON_GAME_PLAY       (1L<<2)
+
+
+/* some positions in the asking window */
+#define OK_BUTTON_XPOS         2
+#define OK_BUTTON_YPOS         250
+#define OK_BUTTON_GFX_YPOS     0
+#define OK_BUTTON_XSIZE                46
+#define OK_BUTTON_YSIZE                28
+#define NO_BUTTON_XPOS         52
+#define NO_BUTTON_YPOS         OK_BUTTON_YPOS
+#define NO_BUTTON_XSIZE                OK_BUTTON_XSIZE
+#define NO_BUTTON_YSIZE                OK_BUTTON_YSIZE
+#define CONFIRM_BUTTON_XPOS    2
+#define CONFIRM_BUTTON_GFX_YPOS        30
+#define CONFIRM_BUTTON_YPOS    OK_BUTTON_YPOS
+#define CONFIRM_BUTTON_XSIZE   96
+#define CONFIRM_BUTTON_YSIZE   OK_BUTTON_YSIZE
+
+#define ON_CHOOSE_BUTTON(x,y)  (((x)>=(DX+OK_BUTTON_XPOS) &&           \
+                                 (x)< (DX+OK_BUTTON_XPOS +             \
+                                       OK_BUTTON_XSIZE) &&             \
+                                 (y)>=(DY+OK_BUTTON_YPOS) &&           \
+                                 (y)< (DY+OK_BUTTON_YPOS +             \
+                                       OK_BUTTON_YSIZE)) ||            \
+                                ((x)>=(DX+NO_BUTTON_XPOS) &&           \
+                                 (x)< (DX+NO_BUTTON_XPOS +             \
+                                       NO_BUTTON_XSIZE) &&             \
+                                 (y)>=(DY+NO_BUTTON_YPOS) &&           \
+                                 (y)< (DY+NO_BUTTON_YPOS +             \
+                                       NO_BUTTON_YSIZE)))
+#define ON_CONFIRM_BUTTON(x,y) (((x)>=(DX+CONFIRM_BUTTON_XPOS) &&      \
+                                 (x)< (DX+CONFIRM_BUTTON_XPOS +        \
+                                       CONFIRM_BUTTON_XSIZE) &&        \
+                                 (y)>=(DY+CONFIRM_BUTTON_YPOS) &&      \
+                                 (y)< (DY+CONFIRM_BUTTON_YPOS +        \
+                                       CONFIRM_BUTTON_YSIZE)))
+#define CHOOSE_BUTTON(x)       (((x)-(DX+OK_BUTTON_XPOS))/OK_BUTTON_XSIZE)
+
+/* values for asking control */
+#define BUTTON_OK              (1L<<0)
+#define BUTTON_NO              (1L<<1)
+#define BUTTON_CONFIRM         (1L<<2)
+
+
+/* some positions in the editor control window */
+#define ED_BUTTON_EUP_XPOS     35
+#define ED_BUTTON_EUP_YPOS     5
+#define ED_BUTTON_EUP_XSIZE    30
+#define ED_BUTTON_EUP_YSIZE    25
+#define ED_BUTTON_EDOWN_XPOS   35
+#define ED_BUTTON_EDOWN_YPOS   250
+#define ED_BUTTON_EDOWN_XSIZE  30
+#define ED_BUTTON_EDOWN_YSIZE  25
+#define ED_BUTTON_ELEM_XPOS    6
+#define ED_BUTTON_ELEM_YPOS    30
+#define ED_BUTTON_ELEM_XSIZE   22
+#define ED_BUTTON_ELEM_YSIZE   22
+
+#define ED_BUTTON_EUP_Y2POS    140
+#define ED_BUTTON_EDOWN_Y2POS  165
+#define ED_BUTTON_ELEM_Y2POS   190
+
+#define ED_BUTTON_CTRL_XPOS    5
+#define ED_BUTTON_CTRL_YPOS    5
+#define ED_BUTTON_CTRL_XSIZE   90
+#define ED_BUTTON_CTRL_YSIZE   30
+#define ED_BUTTON_FILL_XPOS    5
+#define ED_BUTTON_FILL_YPOS    35
+#define ED_BUTTON_FILL_XSIZE   90
+#define ED_BUTTON_FILL_YSIZE   20
+#define ED_BUTTON_LEFT_XPOS    5
+#define ED_BUTTON_LEFT_YPOS    65
+#define ED_BUTTON_LEFT_XSIZE   30
+#define ED_BUTTON_LEFT_YSIZE   20
+#define ED_BUTTON_UP_XPOS      35
+#define ED_BUTTON_UP_YPOS      55
+#define ED_BUTTON_UP_XSIZE     30
+#define ED_BUTTON_UP_YSIZE     20
+#define ED_BUTTON_DOWN_XPOS    35
+#define ED_BUTTON_DOWN_YPOS    75
+#define ED_BUTTON_DOWN_XSIZE   30
+#define ED_BUTTON_DOWN_YSIZE   20
+#define ED_BUTTON_RIGHT_XPOS   65
+#define ED_BUTTON_RIGHT_YPOS   65
+#define ED_BUTTON_RIGHT_XSIZE  30
+#define ED_BUTTON_RIGHT_YSIZE  20
+
+#define ED_BUTTON_EDIT_XPOS    5
+#define ED_BUTTON_EDIT_YPOS    5
+#define ED_BUTTON_EDIT_XSIZE   90
+#define ED_BUTTON_EDIT_YSIZE   30
+#define ED_BUTTON_CLEAR_XPOS   5
+#define ED_BUTTON_CLEAR_YPOS   35
+#define ED_BUTTON_CLEAR_XSIZE  90
+#define ED_BUTTON_CLEAR_YSIZE  20
+#define ED_BUTTON_UNDO_XPOS    5
+#define ED_BUTTON_UNDO_YPOS    55
+#define ED_BUTTON_UNDO_XSIZE   90
+#define ED_BUTTON_UNDO_YSIZE   20
+#define ED_BUTTON_EXIT_XPOS    5
+#define ED_BUTTON_EXIT_YPOS    75
+#define ED_BUTTON_EXIT_XSIZE   90
+#define ED_BUTTON_EXIT_YSIZE   20
+
+#define ED_BUTTON_MINUS_XPOS   2
+#define ED_BUTTON_MINUS_YPOS   60
+#define ED_BUTTON_MINUS_XSIZE  20
+#define ED_BUTTON_MINUS_YSIZE  20
+#define ED_WIN_COUNT_XPOS      (ED_BUTTON_MINUS_XPOS+ED_BUTTON_MINUS_XSIZE+2)
+#define ED_WIN_COUNT_YPOS      ED_BUTTON_MINUS_YPOS
+#define ED_WIN_COUNT_XSIZE     52
+#define ED_WIN_COUNT_YSIZE     ED_BUTTON_MINUS_YSIZE
+#define ED_BUTTON_PLUS_XPOS    (ED_WIN_COUNT_XPOS+ED_WIN_COUNT_XSIZE+2)
+#define ED_BUTTON_PLUS_YPOS    ED_BUTTON_MINUS_YPOS
+#define ED_BUTTON_PLUS_XSIZE   ED_BUTTON_MINUS_XSIZE
+#define ED_BUTTON_PLUS_YSIZE   ED_BUTTON_MINUS_YSIZE
+
+#define ED_COUNT_GADGET_XPOS   16
+#define ED_COUNT_GADGET_YPOS   (16+3*MINI_TILEY+64)
+#define ED_COUNT_GADGET_YSIZE  (ED_BUTTON_MINUS_YSIZE+4)
+#define ED_COUNT_TEXT_XPOS     (ED_COUNT_GADGET_XPOS+DXSIZE+10)
+#define ED_COUNT_TEXT_YPOS     (ED_COUNT_GADGET_YPOS+3)
+#define ED_COUNT_TEXT_YSIZE    ED_COUNT_GADGET_YSIZE
+#define ED_COUNT_VALUE_XPOS    (ED_COUNT_GADGET_XPOS+ED_BUTTON_MINUS_XSIZE+7)
+#define ED_COUNT_VALUE_YPOS    ED_COUNT_TEXT_YPOS
+#define ED_SIZE_GADGET_XPOS    (SX+21*MINI_TILEX)
+#define ED_SIZE_GADGET_YPOS    (SY+4*MINI_TILEY)
+#define ED_SIZE_GADGET_YSIZE   (ED_BUTTON_MINUS_YSIZE+4)
+#define ED_SIZE_TEXT_XPOS      (ED_SIZE_GADGET_XPOS+DXSIZE+10)
+#define ED_SIZE_TEXT_YPOS      (ED_SIZE_GADGET_YPOS+3)
+#define ED_SIZE_TEXT_YSIZE     ED_COUNT_GADGET_YSIZE
+#define ED_SIZE_VALUE_XPOS     (ED_SIZE_GADGET_XPOS+ED_BUTTON_MINUS_XSIZE+7)
+#define ED_SIZE_VALUE_YPOS     ED_SIZE_TEXT_YPOS
+
+#define ON_EDIT_BUTTON(x,y)    (((x)>=(VX+ED_BUTTON_CTRL_XPOS) &&      \
+                                 (x)< (VX+ED_BUTTON_CTRL_XPOS +        \
+                                       ED_BUTTON_CTRL_XSIZE) &&        \
+                                 (y)>=(VY+ED_BUTTON_CTRL_YPOS) &&      \
+                                 (y)< (VY+ED_BUTTON_CTRL_YPOS +        \
+                                       ED_BUTTON_CTRL_YSIZE +          \
+                                       ED_BUTTON_FILL_YSIZE)) ||       \
+                                ((x)>=(VX+ED_BUTTON_LEFT_XPOS) &&      \
+                                 (x)< (VX+ED_BUTTON_LEFT_XPOS +        \
+                                       ED_BUTTON_LEFT_XSIZE +          \
+                                       ED_BUTTON_UP_XSIZE +            \
+                                       ED_BUTTON_RIGHT_XSIZE) &&       \
+                                 (y)>=(VY+ED_BUTTON_LEFT_YPOS) &&      \
+                                 (y)< (VY+ED_BUTTON_LEFT_YPOS +        \
+                                       ED_BUTTON_LEFT_YSIZE)) ||       \
+                                ((x)>=(VX+ED_BUTTON_UP_XPOS) &&        \
+                                 (x)< (VX+ED_BUTTON_UP_XPOS +          \
+                                       ED_BUTTON_UP_XSIZE) &&          \
+                                 (y)>=(VY+ED_BUTTON_UP_YPOS) &&        \
+                                 (y)< (VY+ED_BUTTON_UP_YPOS +          \
+                                       ED_BUTTON_UP_YSIZE +            \
+                                       ED_BUTTON_DOWN_YSIZE)))
+
+#define ON_CTRL_BUTTON(x,y)    ((x)>=(VX+ED_BUTTON_EDIT_XPOS) &&       \
+                                (x)< (VX+ED_BUTTON_EDIT_XPOS +         \
+                                      ED_BUTTON_EDIT_XSIZE) &&         \
+                                (y)>=(VY+ED_BUTTON_EDIT_YPOS) &&       \
+                                (y)< (VY+ED_BUTTON_EDIT_YPOS +         \
+                                      ED_BUTTON_EDIT_YSIZE +           \
+                                      ED_BUTTON_CLEAR_YSIZE +          \
+                                      ED_BUTTON_UNDO_YSIZE +           \
+                                      ED_BUTTON_EXIT_YSIZE))
+
+#define ON_ELEM_BUTTON(x,y)    (((x)>=(DX+ED_BUTTON_EUP_XPOS) &&       \
+                                 (x)< (DX+ED_BUTTON_EUP_XPOS +         \
+                                       ED_BUTTON_EUP_XSIZE) &&         \
+                                 (y)>=(DY+ED_BUTTON_EUP_YPOS) &&       \
+                                 (y)< (DY+ED_BUTTON_EUP_YPOS +         \
+                                       ED_BUTTON_EUP_YSIZE)) ||        \
+                                ((x)>=(DX+ED_BUTTON_EDOWN_XPOS) &&     \
+                                 (x)< (DX+ED_BUTTON_EDOWN_XPOS +       \
+                                       ED_BUTTON_EDOWN_XSIZE) &&       \
+                                 (y)>=(DY+ED_BUTTON_EDOWN_YPOS) &&     \
+                                 (y)< (DY+ED_BUTTON_EDOWN_YPOS +       \
+                                       ED_BUTTON_EDOWN_YSIZE)) ||      \
+                                ((x)>=(DX+ED_BUTTON_ELEM_XPOS) &&      \
+                                 (x)< (DX+ED_BUTTON_ELEM_XPOS +        \
+                                       MAX_ELEM_X*ED_BUTTON_ELEM_XSIZE) && \
+                                 (y)>=(DY+ED_BUTTON_ELEM_YPOS) &&      \
+                                 (y)< (DY+ED_BUTTON_ELEM_YPOS +        \
+                                       MAX_ELEM_Y*ED_BUTTON_ELEM_YSIZE)))
+
+#define ON_COUNT_BUTTON(x,y)   (((((x)>=ED_COUNT_GADGET_XPOS &&        \
+                                   (x)<(ED_COUNT_GADGET_XPOS +         \
+                                        ED_BUTTON_MINUS_XSIZE)) ||     \
+                                  ((x)>=(ED_COUNT_GADGET_XPOS +        \
+                                         (ED_BUTTON_PLUS_XPOS -        \
+                                          ED_BUTTON_MINUS_XPOS)) &&    \
+                                   (x)<(ED_COUNT_GADGET_XPOS +         \
+                                        (ED_BUTTON_PLUS_XPOS -         \
+                                         ED_BUTTON_MINUS_XPOS) +       \
+                                        ED_BUTTON_PLUS_XSIZE))) &&     \
+                                 ((y)>=ED_COUNT_GADGET_YPOS &&         \
+                                  (y)<(ED_COUNT_GADGET_YPOS +          \
+                                       16*ED_COUNT_GADGET_YSIZE)) &&   \
+                                 (((y)-ED_COUNT_GADGET_YPOS) %         \
+                                  ED_COUNT_GADGET_YSIZE) <             \
+                                 ED_BUTTON_MINUS_YSIZE) ||             \
+                                ((((x)>=ED_SIZE_GADGET_XPOS &&         \
+                                   (x)<(ED_SIZE_GADGET_XPOS +          \
+                                        ED_BUTTON_MINUS_XSIZE)) ||     \
+                                  ((x)>=(ED_SIZE_GADGET_XPOS +         \
+                                         (ED_BUTTON_PLUS_XPOS -        \
+                                          ED_BUTTON_MINUS_XPOS)) &&    \
+                                   (x)<(ED_SIZE_GADGET_XPOS +          \
+                                        (ED_BUTTON_PLUS_XPOS -         \
+                                         ED_BUTTON_MINUS_XPOS) +       \
+                                        ED_BUTTON_PLUS_XSIZE))) &&     \
+                                 ((y)>=ED_SIZE_GADGET_YPOS &&          \
+                                  (y)<(ED_SIZE_GADGET_YPOS +           \
+                                       2*ED_SIZE_GADGET_YSIZE)) &&     \
+                                 (((y)-ED_SIZE_GADGET_YPOS) %          \
+                                  ED_SIZE_GADGET_YSIZE) <              \
+                                 ED_BUTTON_MINUS_YSIZE))
+
+#define EDIT_BUTTON(x,y)       (((y) < (VY + ED_BUTTON_CTRL_YPOS +     \
+                                        ED_BUTTON_CTRL_YSIZE)) ? 0 :   \
+                                ((y) < (VY + ED_BUTTON_CTRL_YPOS +     \
+                                        ED_BUTTON_CTRL_YSIZE +         \
+                                        ED_BUTTON_FILL_YSIZE)) ? 1 :   \
+                                ((x) < (VX + ED_BUTTON_LEFT_XPOS +     \
+                                        ED_BUTTON_LEFT_XSIZE) ? 2 :    \
+                                 (x) > (VX + ED_BUTTON_LEFT_XPOS +     \
+                                        ED_BUTTON_LEFT_XSIZE +         \
+                                        ED_BUTTON_UP_XSIZE) ? 5 :      \
+                                 3+(((y)-(VY + ED_BUTTON_CTRL_YPOS +   \
+                                          ED_BUTTON_CTRL_YSIZE +       \
+                                          ED_BUTTON_FILL_YSIZE)) /     \
+                                    ED_BUTTON_UP_YSIZE)))
+
+#define CTRL_BUTTON(x,y)       (((y) < (VY + ED_BUTTON_EDIT_YPOS +     \
+                                        ED_BUTTON_EDIT_YSIZE)) ? 0 :   \
+                                1+(((y)-(VY + ED_BUTTON_EDIT_YPOS +    \
+                                        ED_BUTTON_EDIT_YSIZE)) /       \
+                                   ED_BUTTON_CLEAR_YSIZE))
+
+#define ELEM_BUTTON(x,y)       (((y) < (DY + ED_BUTTON_EUP_YPOS +      \
+                                        ED_BUTTON_EUP_YSIZE)) ? 0 :    \
+                                ((y) > (DY + ED_BUTTON_EDOWN_YPOS)) ? 1 : \
+                                2+(((y) - (DY + ED_BUTTON_ELEM_YPOS)) /   \
+                                ED_BUTTON_ELEM_YSIZE)*MAX_ELEM_X +     \
+                                ((x) - (DX + ED_BUTTON_ELEM_XPOS)) /   \
+                                ED_BUTTON_ELEM_XSIZE)
+
+#define COUNT_BUTTON(x,y)      ((x) < ED_SIZE_GADGET_XPOS ?            \
+                                ((((y) - ED_COUNT_GADGET_YPOS) /       \
+                                  ED_COUNT_GADGET_YSIZE)*2 +           \
+                                 ((x) < (ED_COUNT_GADGET_XPOS +        \
+                                         ED_BUTTON_MINUS_XSIZE) ? 0 : 1)) : \
+                                32+((((y) - ED_SIZE_GADGET_YPOS) /     \
+                                     ED_SIZE_GADGET_YSIZE)*2 +         \
+                                    ((x) < (ED_SIZE_GADGET_XPOS +      \
+                                            ED_BUTTON_MINUS_XSIZE) ? 0 : 1)))
+
+/* values for asking control */
+#define ED_BUTTON_CTRL         (1L<<0)
+#define ED_BUTTON_FILL         (1L<<1)
+#define ED_BUTTON_LEFT         (1L<<2)
+#define ED_BUTTON_UP           (1L<<3)
+#define ED_BUTTON_DOWN         (1L<<4)
+#define ED_BUTTON_RIGHT                (1L<<5)
+#define ED_BUTTON_EDIT         (1L<<6)
+#define ED_BUTTON_CLEAR                (1L<<7)
+#define ED_BUTTON_UNDO         (1L<<8)
+#define ED_BUTTON_EXIT         (1L<<9)
+
+#define ED_BUTTON_PRESSED      (1L<<10)
+#define ED_BUTTON_RELEASED     (1L<<11)
+
+#define ED_BUTTON_EUP          0
+#define ED_BUTTON_EDOWN                1
+#define ED_BUTTON_ELEM         2
+
+
+void DrawVideoDisplay(unsigned long, unsigned long);
+void DrawCompleteVideoDisplay(void);
+void DrawSoundDisplay(unsigned long);
+void DrawGameButton(unsigned long);
+void DrawChooseButton(unsigned long);
+void DrawConfirmButton(unsigned long);
+void DrawEditButton(unsigned long state);
+void DrawCtrlButton(unsigned long state);
+void DrawElemButton(int, int);
+void DrawCountButton(int, int);
+int CheckVideoButtons(int, int, int);
+int CheckSoundButtons(int, int, int);
+int CheckGameButtons(int, int, int);
+int CheckChooseButtons(int, int, int);
+int CheckConfirmButton(int, int, int);
+int CheckEditButtons(int, int, int);
+int CheckCtrlButtons(int, int, int);
+int CheckElemButtons(int, int, int);
+int CheckCountButtons(int, int, int);
+
+#endif
index ee7fe4e..454fb74 100644 (file)
 *               q99492@pbhrzx.uni-paderborn.de             *
 *----------------------------------------------------------*
 *  editor.c                                                *
-*                                                          *
-*  Letzte Aenderung: 15.06.1995                            *
 ***********************************************************/
 
 #include "editor.h"
 #include "screens.h"
-#include "game.h"
 #include "tools.h"
 #include "misc.h"
+#include "buttons.h"
+#include "files.h"
 
 static int level_xpos,level_ypos;
 static BOOL edit_mode;
 static BOOL name_typing;
-static int element_shift;
 static int new_element1 = EL_MAUERWERK;
 static int new_element2 = EL_LEERRAUM;
 static int new_element3 = EL_ERDREICH;
-static int editor_element[] =
+
+int element_shift;
+int editor_element[] =
 {
   EL_SPIELFIGUR,
   EL_LEERRAUM,
@@ -70,20 +70,24 @@ static int editor_element[] =
   EL_UNSICHTBAR,
 
   EL_TROPFEN,
-  EL_AMOEBE1,
-  EL_AMOEBE2,
-  EL_AMOEBE3,
+  EL_AMOEBE_TOT,
+  EL_AMOEBE_NASS,
+  EL_AMOEBE_NORM,
+
+  EL_AMOEBE_VOLL,
 
+/*
   EL_LIFE,
+*/
   EL_LIFE_ASYNC,
 
-  EL_ERZ_1,
-  EL_ERZ_2,
+  EL_ERZ_EDEL,
+  EL_ERZ_DIAM,
 
-/*
+  EL_ZEIT_VOLL,
+  EL_ZEIT_LEER,
   EL_BIRNE_AUS,
   EL_BIRNE_EIN,
-*/
 
   EL_SCHLUESSEL1,
   EL_SCHLUESSEL2,
@@ -189,7 +193,7 @@ static int editor_element[] =
   EL_CHAR_UE,
   EL_CHAR_COPY
 };
-static int elements_in_list = sizeof(editor_element)/sizeof(int);
+int elements_in_list = sizeof(editor_element)/sizeof(int);
 
 void DrawLevelEd()
 {
@@ -275,20 +279,21 @@ void DrawControlWindow()
 
   ClearWindow();
 
+  /* Inhalt der Mampfer */
   DrawText(ED_COUNT_GADGET_XPOS+1,SY+6,
           "Contents of a smashed cruncher:",FS_SMALL,FC_YELLOW);
   for(i=0;i<4;i++) for(y=0;y<4;y++) for(x=0;x<4;x++)
   {
     DrawMiniElement(1+5*i+x,2+y,EL_ERDREICH);
     XFillRectangle(display,drawto,gc,
-                  SX+(2+5*i)*MINI_TILEX-MINI_TILEX/2-1,
-                  SY+(3)*MINI_TILEY-MINI_TILEY/2-1,
+                  SX+(1+5*i)*MINI_TILEX+MINI_TILEX/2-1,
+                  SY+(2)*MINI_TILEY+MINI_TILEY/2-1,
                   3*MINI_TILEX+2,3*MINI_TILEY+2);
   }
   XCopyArea(display,drawto,drawto,gc,
-           SX+MINI_TILEX,SY+2*MINI_TILEY,
+           SX+1*MINI_TILEX,SY+2*MINI_TILEY,
            4*5*MINI_TILEX,5*MINI_TILEY,
-           SX+MINI_TILEX-MINI_TILEX/2,SY+2*MINI_TILEY-MINI_TILEY/2);
+           SX+1*MINI_TILEX-MINI_TILEX/2,SY+2*MINI_TILEY-MINI_TILEY/2);
   for(i=0;i<4;i++)
   {
     for(y=0;y<3;y++) for(x=0;x<3;x++)
@@ -299,6 +304,21 @@ void DrawControlWindow()
             int2str(i+1,1),FS_SMALL,FC_YELLOW);
   }
 
+  /* Inhalt der Amöbe */
+  for(y=0;y<2;y++) for(x=0;x<2;x++)
+  {
+    DrawMiniElement(29+x,26+y,EL_ERDREICH);
+    XFillRectangle(display,drawto,gc,
+                  SX+29*MINI_TILEX+MINI_TILEX/2-1,
+                  SY+26*MINI_TILEY+MINI_TILEY/2-1,
+                  MINI_TILEX+2,MINI_TILEY+2);
+  }
+  XCopyArea(display,drawto,drawto,gc,
+           SX+29*MINI_TILEX,SY+26*MINI_TILEY,
+           3*MINI_TILEX,3*MINI_TILEY,
+           SX+29*MINI_TILEX-MINI_TILEX/2,SY+26*MINI_TILEY-MINI_TILEY/2);
+  DrawMiniElement(29,26,level.amoebe_inhalt);
+
   for(i=0;i<11+3+2;i++)
   {
     XCopyArea(display,pix[PIX_DOOR],drawto,gc,
@@ -357,7 +377,7 @@ void DrawControlWindow()
   DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+10*ED_COUNT_TEXT_YSIZE,
           "Score for each 10 seconds left",FS_SMALL,FC_YELLOW);
   DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+11*ED_COUNT_TEXT_YSIZE,
-          "Speed of the amoeba",FS_SMALL,FC_YELLOW);
+          "Speed of the amoeba / Content",FS_SMALL,FC_YELLOW);
   DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+12*ED_COUNT_TEXT_YSIZE,
           "Time for magic wall",FS_SMALL,FC_YELLOW);
   DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+13*ED_COUNT_TEXT_YSIZE,
@@ -952,6 +972,25 @@ void LevelEd(int mx, int my, int button)
        }
       }
 
+      if (mx>=SX+29*MINI_TILEX && mx<SX+30*MINI_TILEX &&
+         my>=SY+26*MINI_TILEY && my<SY+27*MINI_TILEY)
+      {
+       int new_element;
+
+       if (!button || button<1 || button>3)
+         return;
+
+       new_element = (button==1 ? new_element1 :
+                      button==2 ? new_element2 :
+                      button==3 ? new_element3 : 0);
+
+       if (new_element != level.amoebe_inhalt)
+       {
+         level.amoebe_inhalt = new_element;
+         DrawMiniElement(29,26,new_element);
+       }
+      }
+
       if (mx>=SX+1*MINI_TILEX && mx<SX+(1+4*5)*MINI_TILEX &&
          my>=SY+2*MINI_TILEY && my<SY+(2+3)*MINI_TILEY)
       {
@@ -976,7 +1015,7 @@ void LevelEd(int mx, int my, int button)
          if (new_element != level.mampfer_inhalt[i][x][y])
          {
            level.mampfer_inhalt[i][x][y] = new_element;
-           DrawMiniElement(1+5*i+x,2+y,level.mampfer_inhalt[i][x][y]);
+           DrawMiniElement(1+5*i+x,2+y,new_element);
          }
        }
        else if (!motion_status)/* Mauszeiger nicht im Cruncher-Feld */
@@ -1084,433 +1123,3 @@ void LevelNameTyping(KeySym key)
     name_typing = FALSE;
   }
 }
-
-void DrawEditButton(unsigned long state)
-{
-  int i;
-  int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
-  int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY2;
-  static int edit_pos[6][4] =
-  {
-    ED_BUTTON_CTRL_XPOS,ED_BUTTON_CTRL_YPOS,
-    ED_BUTTON_CTRL_XSIZE,ED_BUTTON_CTRL_YSIZE,
-
-    ED_BUTTON_FILL_XPOS,ED_BUTTON_FILL_YPOS,
-    ED_BUTTON_FILL_XSIZE,ED_BUTTON_FILL_YSIZE,
-
-    ED_BUTTON_LEFT_XPOS,ED_BUTTON_LEFT_YPOS,
-    ED_BUTTON_LEFT_XSIZE,ED_BUTTON_LEFT_YSIZE,
-
-    ED_BUTTON_UP_XPOS,ED_BUTTON_UP_YPOS,
-    ED_BUTTON_UP_XSIZE,ED_BUTTON_UP_YSIZE,
-
-    ED_BUTTON_DOWN_XPOS,ED_BUTTON_DOWN_YPOS,
-    ED_BUTTON_DOWN_XSIZE,ED_BUTTON_DOWN_YSIZE,
-
-    ED_BUTTON_RIGHT_XPOS,ED_BUTTON_RIGHT_YPOS,
-    ED_BUTTON_RIGHT_XSIZE,ED_BUTTON_RIGHT_YSIZE
-  };
-
-  if (state & ED_BUTTON_PRESSED)
-    cx = DOOR_GFX_PAGEX5;
-
-  for(i=0;i<6;i++)
-  {
-    if (state & (1<<i))
-      XCopyArea(display,pix[PIX_DOOR],drawto,gc,
-               cx + edit_pos[i][xpos],
-               cy + edit_pos[i][ypos],
-               edit_pos[i][xsize],
-               edit_pos[i][ysize],
-               VX + edit_pos[i][xpos],
-               VY + edit_pos[i][ypos]);
-  }
-
-  redraw_mask |= REDRAW_DOOR_2;
-}
-
-void DrawCtrlButton(unsigned long state)
-{
-  int i;
-  int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
-  int cx = DOOR_GFX_PAGEX4, cy = DOOR_GFX_PAGEY1+80;
-  static int edit_pos[4][4] =
-  {
-    ED_BUTTON_EDIT_XPOS,ED_BUTTON_EDIT_YPOS,
-    ED_BUTTON_EDIT_XSIZE,ED_BUTTON_EDIT_YSIZE,
-
-    ED_BUTTON_CLEAR_XPOS,ED_BUTTON_CLEAR_YPOS,
-    ED_BUTTON_CLEAR_XSIZE,ED_BUTTON_CLEAR_YSIZE,
-
-    ED_BUTTON_UNDO_XPOS,ED_BUTTON_UNDO_YPOS,
-    ED_BUTTON_UNDO_XSIZE,ED_BUTTON_UNDO_YSIZE,
-
-    ED_BUTTON_EXIT_XPOS,ED_BUTTON_EXIT_YPOS,
-    ED_BUTTON_EXIT_XSIZE,ED_BUTTON_EXIT_YSIZE
-  };
-
-  if (state & ED_BUTTON_PRESSED)
-    cx = DOOR_GFX_PAGEX3;
-
-  for(i=0;i<4;i++)
-  {
-    if (state & (1<<(i+6)))
-      XCopyArea(display,pix[PIX_DOOR],drawto,gc,
-               cx + edit_pos[i][xpos],
-               cy + edit_pos[i][ypos],
-               edit_pos[i][xsize],
-               edit_pos[i][ysize],
-               VX + edit_pos[i][xpos],
-               VY + edit_pos[i][ypos]);
-  }
-
-  redraw_mask |= REDRAW_DOOR_2;
-}
-
-void DrawElemButton(int button_nr, int button_state)
-{
-  int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
-  int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY1;
-  int from_x, from_y, to_x,to_y, size_x, size_y;
-  static int edit_pos[3][4] =
-  {
-    ED_BUTTON_EUP_XPOS,ED_BUTTON_EUP_YPOS,
-    ED_BUTTON_EUP_XSIZE,ED_BUTTON_EUP_YSIZE,
-
-    ED_BUTTON_EDOWN_XPOS,ED_BUTTON_EDOWN_YPOS,
-    ED_BUTTON_EDOWN_XSIZE,ED_BUTTON_EDOWN_YSIZE,
-
-    ED_BUTTON_ELEM_XPOS,ED_BUTTON_ELEM_YPOS,
-    ED_BUTTON_ELEM_XSIZE,ED_BUTTON_ELEM_YSIZE
-  };
-
-  if (button_nr<ED_BUTTON_ELEM)
-  {
-    int pos = button_nr;
-
-    from_x = cx + edit_pos[pos][xpos];
-    from_y = cy + edit_pos[pos][ypos];
-    size_x = edit_pos[pos][xsize];
-    size_y = edit_pos[pos][ysize];
-    to_x   = DX + edit_pos[pos][xpos];
-    to_y   = DY + edit_pos[pos][ypos];
-
-    if (button_state & ED_BUTTON_PRESSED)
-    {
-      if (button_nr==ED_BUTTON_EUP)
-       from_y = cy + ED_BUTTON_EUP_Y2POS;
-      else
-       from_y = cy + ED_BUTTON_EDOWN_Y2POS;
-    }
-
-    XCopyArea(display,pix[PIX_DOOR],drawto,gc,
-             from_x,from_y, size_x,size_y, to_x,to_y);
-  }
-  else
-  {
-    int pos = ED_BUTTON_ELEM;
-    int elem_pos = button_nr-ED_BUTTON_ELEM;
-    int x = elem_pos % MAX_ELEM_X;
-    int y = elem_pos / MAX_ELEM_X;
-    int graphic;
-    int shift = 0;
-
-    if (elem_pos+element_shift < elements_in_list)
-      graphic = el2gfx(editor_element[elem_pos+element_shift]);
-    else
-      graphic = GFX_LEERRAUM;
-
-    from_x = cx + edit_pos[pos][xpos];
-    from_y = cy + edit_pos[pos][ypos];
-    size_x = edit_pos[pos][xsize];
-    size_y = edit_pos[pos][ysize];
-    to_x   = DX + edit_pos[pos][xpos] + x * ED_BUTTON_ELEM_XSIZE;
-    to_y   = DY + edit_pos[pos][ypos] + y * ED_BUTTON_ELEM_YSIZE;
-
-    if (button_state & ED_BUTTON_PRESSED)
-    {
-      from_y = ED_BUTTON_ELEM_Y2POS;
-      shift = 1;
-    }
-
-    XCopyArea(display,pix[PIX_DOOR],drawto,gc,
-             from_x,from_y, size_x,size_y, to_x,to_y);
-
-    DrawMiniGraphicExtHiRes(drawto,gc,
-                           DX+ED_BUTTON_ELEM_XPOS+3+shift + 
-                           (elem_pos % MAX_ELEM_X)*ED_BUTTON_ELEM_XSIZE,
-                           DY+ED_BUTTON_ELEM_YPOS+3-shift +
-                           (elem_pos / MAX_ELEM_X)*ED_BUTTON_ELEM_YSIZE,
-                           graphic);
-  }
-
-  redraw_mask |= REDRAW_DOOR_1;
-}
-
-void DrawCountButton(int button_nr, int button_state)
-{
-  int from_x, from_y, to_x,to_y, size_x, size_y;
-
-  from_x =
-    DOOR_GFX_PAGEX4+(button_nr%2 ? ED_BUTTON_PLUS_XPOS : ED_BUTTON_MINUS_XPOS);
-  from_y = DOOR_GFX_PAGEY1 + ED_BUTTON_MINUS_YPOS;
-  size_x = ED_BUTTON_MINUS_XSIZE;
-  size_y = ED_BUTTON_MINUS_YSIZE;
-  to_x = (button_nr<32 ? ED_COUNT_GADGET_XPOS : ED_SIZE_GADGET_XPOS);
-  if (button_nr % 2)
-    to_x += (ED_BUTTON_PLUS_XPOS - ED_BUTTON_MINUS_XPOS);
-  to_y = (button_nr<32 ? ED_COUNT_GADGET_YPOS : ED_SIZE_GADGET_YPOS) +
-    ((button_nr<32 ? button_nr : button_nr-32)/2)*ED_COUNT_GADGET_YSIZE;
-
-  if (button_state & ED_BUTTON_PRESSED)
-    from_x -= DXSIZE;
-
-  XCopyArea(display,pix[PIX_DOOR],drawto,gc,
-           from_x,from_y, size_x,size_y, to_x,to_y);
-  XCopyArea(display,pix[PIX_DOOR],window,gc,
-           from_x,from_y, size_x,size_y, to_x,to_y);
-}
-
-int CheckEditButtons(int mx, int my, int button)
-{
-  int return_code = 0;
-  static int choice = -1;
-  static BOOL pressed = FALSE;
-  static int edit_button[6] =
-  {
-    ED_BUTTON_CTRL,
-    ED_BUTTON_FILL,
-    ED_BUTTON_LEFT,
-    ED_BUTTON_UP,
-    ED_BUTTON_DOWN,
-    ED_BUTTON_RIGHT
-  };
-
-  if (button)
-  {
-    if (!motion_status)                /* Maustaste neu gedrückt */
-    {
-      if (ON_EDIT_BUTTON(mx,my))
-      {
-       choice = EDIT_BUTTON(mx,my);
-       pressed = TRUE;
-       DrawEditButton(edit_button[choice] | ED_BUTTON_PRESSED);
-       if (edit_button[choice]!=ED_BUTTON_CTRL &&
-           edit_button[choice]!=ED_BUTTON_FILL)
-         return_code = 1<<choice;
-      }
-    }
-    else                       /* Mausbewegung bei gedrückter Maustaste */
-    {
-      if ((!ON_EDIT_BUTTON(mx,my) || EDIT_BUTTON(mx,my)!=choice) &&
-         choice>=0 && pressed)
-      {
-       pressed = FALSE;
-       DrawEditButton(edit_button[choice] | ED_BUTTON_RELEASED);
-      }
-      else if (ON_EDIT_BUTTON(mx,my) && EDIT_BUTTON(mx,my)==choice)
-      {
-       if (!pressed)
-         DrawEditButton(edit_button[choice] | ED_BUTTON_PRESSED);
-       pressed = TRUE;
-       if (edit_button[choice]!=ED_BUTTON_CTRL &&
-           edit_button[choice]!=ED_BUTTON_FILL)
-         return_code = 1<<choice;
-      }
-    }
-  }
-  else                         /* Maustaste wieder losgelassen */
-  {
-    if (ON_EDIT_BUTTON(mx,my) && EDIT_BUTTON(mx,my)==choice && pressed)
-    {
-      DrawEditButton(edit_button[choice] | ED_BUTTON_RELEASED);
-      if (edit_button[choice]==ED_BUTTON_CTRL ||
-         edit_button[choice]==ED_BUTTON_FILL)
-       return_code = 1<<choice;
-      choice = -1;
-      pressed = FALSE;
-    }
-    else
-    {
-      choice = -1;
-      pressed = FALSE;
-    }
-  }
-
-  BackToFront();
-  return(return_code);
-}
-
-int CheckCtrlButtons(int mx, int my, int button)
-{
-  int return_code = 0;
-  static int choice = -1;
-  static BOOL pressed = FALSE;
-  static int ctrl_button[4] =
-  {
-    ED_BUTTON_EDIT,
-    ED_BUTTON_CLEAR,
-    ED_BUTTON_UNDO,
-    ED_BUTTON_EXIT
-  };
-
-  if (button)
-  {
-    if (!motion_status)                /* Maustaste neu gedrückt */
-    {
-      if (ON_CTRL_BUTTON(mx,my))
-      {
-       choice = CTRL_BUTTON(mx,my);
-       pressed = TRUE;
-       DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_PRESSED);
-      }
-    }
-    else                       /* Mausbewegung bei gedrückter Maustaste */
-    {
-      if ((!ON_CTRL_BUTTON(mx,my) || CTRL_BUTTON(mx,my)!=choice) &&
-         choice>=0 && pressed)
-      {
-       pressed = FALSE;
-       DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_RELEASED);
-      }
-      else if (ON_CTRL_BUTTON(mx,my) && CTRL_BUTTON(mx,my)==choice && !pressed)
-      {
-       pressed = TRUE;
-       DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_PRESSED);
-      }
-    }
-  }
-  else                         /* Maustaste wieder losgelassen */
-  {
-    if (ON_CTRL_BUTTON(mx,my) && CTRL_BUTTON(mx,my)==choice && pressed)
-    {
-      DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_RELEASED);
-      return_code = 1<<(choice+6);
-      choice = -1;
-      pressed = FALSE;
-    }
-    else
-    {
-      choice = -1;
-      pressed = FALSE;
-    }
-  }
-
-  BackToFront();
-  return(return_code);
-}
-
-int CheckElemButtons(int mx, int my, int button)
-{
-  int return_code = -1;
-  static int choice = -1;
-  static BOOL pressed = FALSE;
-
-  if (button)
-  {
-    if (!motion_status)                /* Maustaste neu gedrückt */
-    {
-      if (ON_ELEM_BUTTON(mx,my))
-      {
-       choice = ELEM_BUTTON(mx,my);
-       pressed = TRUE;
-       DrawElemButton(choice,ED_BUTTON_PRESSED);
-       if (choice==ED_BUTTON_EUP ||
-           choice==ED_BUTTON_EDOWN)
-         return_code = choice;
-      }
-    }
-    else                       /* Mausbewegung bei gedrückter Maustaste */
-    {
-      if ((!ON_ELEM_BUTTON(mx,my) || ELEM_BUTTON(mx,my)!=choice) &&
-         choice>=0 && pressed)
-      {
-       pressed = FALSE;
-       DrawElemButton(choice,ED_BUTTON_RELEASED);
-      }
-      else if (ON_ELEM_BUTTON(mx,my) && ELEM_BUTTON(mx,my)==choice)
-      {
-       if (!pressed)
-         DrawElemButton(choice,ED_BUTTON_PRESSED);
-       pressed = TRUE;
-       if (choice==ED_BUTTON_EUP ||
-           choice==ED_BUTTON_EDOWN)
-         return_code = choice;
-      }
-    }
-  }
-  else                         /* Maustaste wieder losgelassen */
-  {
-    if (ON_ELEM_BUTTON(mx,my) && ELEM_BUTTON(mx,my)==choice && pressed)
-    {
-      DrawElemButton(choice,ED_BUTTON_RELEASED);
-      if (choice!=ED_BUTTON_EUP &&
-         choice!=ED_BUTTON_EDOWN)
-       return_code = choice;
-      choice = -1;
-      pressed = FALSE;
-    }
-    else
-    {
-      choice = -1;
-      pressed = FALSE;
-    }
-  }
-
-  BackToFront();
-  return(return_code);
-}
-
-int CheckCountButtons(int mx, int my, int button)
-{
-  int return_code = -1;
-  static int choice = -1;
-  static BOOL pressed = FALSE;
-
-  if (button)
-  {
-    if (!motion_status)                /* Maustaste neu gedrückt */
-    {
-      if (ON_COUNT_BUTTON(mx,my))
-      {
-       choice = COUNT_BUTTON(mx,my);
-       pressed = TRUE;
-       DrawCountButton(choice,ED_BUTTON_PRESSED);
-       return_code = choice;
-      }
-    }
-    else                       /* Mausbewegung bei gedrückter Maustaste */
-    {
-      if ((!ON_COUNT_BUTTON(mx,my) || COUNT_BUTTON(mx,my)!=choice) &&
-         choice>=0 && pressed)
-      {
-       pressed = FALSE;
-       DrawCountButton(choice,ED_BUTTON_RELEASED);
-      }
-      else if (ON_COUNT_BUTTON(mx,my) && COUNT_BUTTON(mx,my)==choice)
-      {
-       if (!pressed)
-         DrawCountButton(choice,ED_BUTTON_PRESSED);
-       pressed = TRUE;
-       return_code = choice;
-      }
-    }
-  }
-  else                         /* Maustaste wieder losgelassen */
-  {
-    if (ON_COUNT_BUTTON(mx,my) && COUNT_BUTTON(mx,my)==choice && pressed)
-    {
-      DrawCountButton(choice,ED_BUTTON_RELEASED);
-      choice = -1;
-      pressed = FALSE;
-    }
-    else
-    {
-      choice = -1;
-      pressed = FALSE;
-    }
-  }
-
-  BackToFront();
-  return(return_code);
-}
index d01f813..b4ebfed 100644 (file)
@@ -10,8 +10,6 @@
 *               q99492@pbhrzx.uni-paderborn.de             *
 *----------------------------------------------------------*
 *  editor.h                                                *
-*                                                          *
-*  Letzte Aenderung: 15.06.1995                            *
 ***********************************************************/
 
 #ifndef EDITOR_H
@@ -19,8 +17,7 @@
 
 #include "main.h"
 
-/* sizes in the level editor */
-/* edit window */
+/* positions in the level editor */
 #define ED_WIN_MB_LEFT_XPOS    7
 #define ED_WIN_MB_LEFT_YPOS    6
 #define ED_WIN_LEVELNR_XPOS    77
 #define ED_WIN_MB_RIGHT_XPOS   77
 #define ED_WIN_MB_RIGHT_YPOS   258
 
-#define ED_BUTTON_EUP_XPOS     35
-#define ED_BUTTON_EUP_YPOS     5
-#define ED_BUTTON_EUP_XSIZE    30
-#define ED_BUTTON_EUP_YSIZE    25
-#define ED_BUTTON_EDOWN_XPOS   35
-#define ED_BUTTON_EDOWN_YPOS   250
-#define ED_BUTTON_EDOWN_XSIZE  30
-#define ED_BUTTON_EDOWN_YSIZE  25
-#define ED_BUTTON_ELEM_XPOS    6
-#define ED_BUTTON_ELEM_YPOS    30
-#define ED_BUTTON_ELEM_XSIZE   22
-#define ED_BUTTON_ELEM_YSIZE   22
-
 #define MAX_ELEM_X             4
 #define MAX_ELEM_Y             10
 
-#define ED_BUTTON_EUP_Y2POS    140
-#define ED_BUTTON_EDOWN_Y2POS  165
-#define ED_BUTTON_ELEM_Y2POS   190
-
-#define ED_BUTTON_CTRL_XPOS    5
-#define ED_BUTTON_CTRL_YPOS    5
-#define ED_BUTTON_CTRL_XSIZE   90
-#define ED_BUTTON_CTRL_YSIZE   30
-#define ED_BUTTON_FILL_XPOS    5
-#define ED_BUTTON_FILL_YPOS    35
-#define ED_BUTTON_FILL_XSIZE   90
-#define ED_BUTTON_FILL_YSIZE   20
-#define ED_BUTTON_LEFT_XPOS    5
-#define ED_BUTTON_LEFT_YPOS    65
-#define ED_BUTTON_LEFT_XSIZE   30
-#define ED_BUTTON_LEFT_YSIZE   20
-#define ED_BUTTON_UP_XPOS      35
-#define ED_BUTTON_UP_YPOS      55
-#define ED_BUTTON_UP_XSIZE     30
-#define ED_BUTTON_UP_YSIZE     20
-#define ED_BUTTON_DOWN_XPOS    35
-#define ED_BUTTON_DOWN_YPOS    75
-#define ED_BUTTON_DOWN_XSIZE   30
-#define ED_BUTTON_DOWN_YSIZE   20
-#define ED_BUTTON_RIGHT_XPOS   65
-#define ED_BUTTON_RIGHT_YPOS   65
-#define ED_BUTTON_RIGHT_XSIZE  30
-#define ED_BUTTON_RIGHT_YSIZE  20
-
-#define ED_BUTTON_EDIT_XPOS    5
-#define ED_BUTTON_EDIT_YPOS    5
-#define ED_BUTTON_EDIT_XSIZE   90
-#define ED_BUTTON_EDIT_YSIZE   30
-#define ED_BUTTON_CLEAR_XPOS   5
-#define ED_BUTTON_CLEAR_YPOS   35
-#define ED_BUTTON_CLEAR_XSIZE  90
-#define ED_BUTTON_CLEAR_YSIZE  20
-#define ED_BUTTON_UNDO_XPOS    5
-#define ED_BUTTON_UNDO_YPOS    55
-#define ED_BUTTON_UNDO_XSIZE   90
-#define ED_BUTTON_UNDO_YSIZE   20
-#define ED_BUTTON_EXIT_XPOS    5
-#define ED_BUTTON_EXIT_YPOS    75
-#define ED_BUTTON_EXIT_XSIZE   90
-#define ED_BUTTON_EXIT_YSIZE   20
-
-#define ED_BUTTON_MINUS_XPOS   2
-#define ED_BUTTON_MINUS_YPOS   60
-#define ED_BUTTON_MINUS_XSIZE  20
-#define ED_BUTTON_MINUS_YSIZE  20
-#define ED_WIN_COUNT_XPOS      (ED_BUTTON_MINUS_XPOS+ED_BUTTON_MINUS_XSIZE+2)
-#define ED_WIN_COUNT_YPOS      ED_BUTTON_MINUS_YPOS
-#define ED_WIN_COUNT_XSIZE     52
-#define ED_WIN_COUNT_YSIZE     ED_BUTTON_MINUS_YSIZE
-#define ED_BUTTON_PLUS_XPOS    (ED_WIN_COUNT_XPOS+ED_WIN_COUNT_XSIZE+2)
-#define ED_BUTTON_PLUS_YPOS    ED_BUTTON_MINUS_YPOS
-#define ED_BUTTON_PLUS_XSIZE   ED_BUTTON_MINUS_XSIZE
-#define ED_BUTTON_PLUS_YSIZE   ED_BUTTON_MINUS_YSIZE
-
-#define ED_COUNT_GADGET_XPOS   16
-#define ED_COUNT_GADGET_YPOS   (16+3*MINI_TILEY+64)
-#define ED_COUNT_GADGET_YSIZE  (ED_BUTTON_MINUS_YSIZE+4)
-#define ED_COUNT_TEXT_XPOS     (ED_COUNT_GADGET_XPOS+DXSIZE+10)
-#define ED_COUNT_TEXT_YPOS     (ED_COUNT_GADGET_YPOS+3)
-#define ED_COUNT_TEXT_YSIZE    ED_COUNT_GADGET_YSIZE
-#define ED_COUNT_VALUE_XPOS    (ED_COUNT_GADGET_XPOS+ED_BUTTON_MINUS_XSIZE+7)
-#define ED_COUNT_VALUE_YPOS    ED_COUNT_TEXT_YPOS
-#define ED_SIZE_GADGET_XPOS    (SX+21*MINI_TILEX)
-#define ED_SIZE_GADGET_YPOS    (SY+4*MINI_TILEY)
-#define ED_SIZE_GADGET_YSIZE   (ED_BUTTON_MINUS_YSIZE+4)
-#define ED_SIZE_TEXT_XPOS      (ED_SIZE_GADGET_XPOS+DXSIZE+10)
-#define ED_SIZE_TEXT_YPOS      (ED_SIZE_GADGET_YPOS+3)
-#define ED_SIZE_TEXT_YSIZE     ED_COUNT_GADGET_YSIZE
-#define ED_SIZE_VALUE_XPOS     (ED_SIZE_GADGET_XPOS+ED_BUTTON_MINUS_XSIZE+7)
-#define ED_SIZE_VALUE_YPOS     ED_SIZE_TEXT_YPOS
-
-#define ON_EDIT_BUTTON(x,y)    (((x)>=(VX+ED_BUTTON_CTRL_XPOS) &&      \
-                                 (x)< (VX+ED_BUTTON_CTRL_XPOS +        \
-                                       ED_BUTTON_CTRL_XSIZE) &&        \
-                                 (y)>=(VY+ED_BUTTON_CTRL_YPOS) &&      \
-                                 (y)< (VY+ED_BUTTON_CTRL_YPOS +        \
-                                       ED_BUTTON_CTRL_YSIZE +          \
-                                       ED_BUTTON_FILL_YSIZE)) ||       \
-                                ((x)>=(VX+ED_BUTTON_LEFT_XPOS) &&      \
-                                 (x)< (VX+ED_BUTTON_LEFT_XPOS +        \
-                                       ED_BUTTON_LEFT_XSIZE +          \
-                                       ED_BUTTON_UP_XSIZE +            \
-                                       ED_BUTTON_RIGHT_XSIZE) &&       \
-                                 (y)>=(VY+ED_BUTTON_LEFT_YPOS) &&      \
-                                 (y)< (VY+ED_BUTTON_LEFT_YPOS +        \
-                                       ED_BUTTON_LEFT_YSIZE)) ||       \
-                                ((x)>=(VX+ED_BUTTON_UP_XPOS) &&        \
-                                 (x)< (VX+ED_BUTTON_UP_XPOS +          \
-                                       ED_BUTTON_UP_XSIZE) &&          \
-                                 (y)>=(VY+ED_BUTTON_UP_YPOS) &&        \
-                                 (y)< (VY+ED_BUTTON_UP_YPOS +          \
-                                       ED_BUTTON_UP_YSIZE +            \
-                                       ED_BUTTON_DOWN_YSIZE)))
-
-#define ON_CTRL_BUTTON(x,y)    ((x)>=(VX+ED_BUTTON_EDIT_XPOS) &&       \
-                                (x)< (VX+ED_BUTTON_EDIT_XPOS +         \
-                                      ED_BUTTON_EDIT_XSIZE) &&         \
-                                (y)>=(VY+ED_BUTTON_EDIT_YPOS) &&       \
-                                (y)< (VY+ED_BUTTON_EDIT_YPOS +         \
-                                      ED_BUTTON_EDIT_YSIZE +           \
-                                      ED_BUTTON_CLEAR_YSIZE +          \
-                                      ED_BUTTON_UNDO_YSIZE +           \
-                                      ED_BUTTON_EXIT_YSIZE))
-
-#define ON_ELEM_BUTTON(x,y)    (((x)>=(DX+ED_BUTTON_EUP_XPOS) &&       \
-                                 (x)< (DX+ED_BUTTON_EUP_XPOS +         \
-                                       ED_BUTTON_EUP_XSIZE) &&         \
-                                 (y)>=(DY+ED_BUTTON_EUP_YPOS) &&       \
-                                 (y)< (DY+ED_BUTTON_EUP_YPOS +         \
-                                       ED_BUTTON_EUP_YSIZE)) ||        \
-                                ((x)>=(DX+ED_BUTTON_EDOWN_XPOS) &&     \
-                                 (x)< (DX+ED_BUTTON_EDOWN_XPOS +       \
-                                       ED_BUTTON_EDOWN_XSIZE) &&       \
-                                 (y)>=(DY+ED_BUTTON_EDOWN_YPOS) &&     \
-                                 (y)< (DY+ED_BUTTON_EDOWN_YPOS +       \
-                                       ED_BUTTON_EDOWN_YSIZE)) ||      \
-                                ((x)>=(DX+ED_BUTTON_ELEM_XPOS) &&      \
-                                 (x)< (DX+ED_BUTTON_ELEM_XPOS +        \
-                                       MAX_ELEM_X*ED_BUTTON_ELEM_XSIZE) && \
-                                 (y)>=(DY+ED_BUTTON_ELEM_YPOS) &&      \
-                                 (y)< (DY+ED_BUTTON_ELEM_YPOS +        \
-                                       MAX_ELEM_Y*ED_BUTTON_ELEM_YSIZE)))
-
-#define ON_COUNT_BUTTON(x,y)   (((((x)>=ED_COUNT_GADGET_XPOS &&        \
-                                   (x)<(ED_COUNT_GADGET_XPOS +         \
-                                        ED_BUTTON_MINUS_XSIZE)) ||     \
-                                  ((x)>=(ED_COUNT_GADGET_XPOS +        \
-                                         (ED_BUTTON_PLUS_XPOS -        \
-                                          ED_BUTTON_MINUS_XPOS)) &&    \
-                                   (x)<(ED_COUNT_GADGET_XPOS +         \
-                                        (ED_BUTTON_PLUS_XPOS -         \
-                                         ED_BUTTON_MINUS_XPOS) +       \
-                                        ED_BUTTON_PLUS_XSIZE))) &&     \
-                                 ((y)>=ED_COUNT_GADGET_YPOS &&         \
-                                  (y)<(ED_COUNT_GADGET_YPOS +          \
-                                       16*ED_COUNT_GADGET_YSIZE)) &&   \
-                                 (((y)-ED_COUNT_GADGET_YPOS) %         \
-                                  ED_COUNT_GADGET_YSIZE) <             \
-                                 ED_BUTTON_MINUS_YSIZE) ||             \
-                                ((((x)>=ED_SIZE_GADGET_XPOS &&         \
-                                   (x)<(ED_SIZE_GADGET_XPOS +          \
-                                        ED_BUTTON_MINUS_XSIZE)) ||     \
-                                  ((x)>=(ED_SIZE_GADGET_XPOS +         \
-                                         (ED_BUTTON_PLUS_XPOS -        \
-                                          ED_BUTTON_MINUS_XPOS)) &&    \
-                                   (x)<(ED_SIZE_GADGET_XPOS +          \
-                                        (ED_BUTTON_PLUS_XPOS -         \
-                                         ED_BUTTON_MINUS_XPOS) +       \
-                                        ED_BUTTON_PLUS_XSIZE))) &&     \
-                                 ((y)>=ED_SIZE_GADGET_YPOS &&          \
-                                  (y)<(ED_SIZE_GADGET_YPOS +           \
-                                       2*ED_SIZE_GADGET_YSIZE)) &&     \
-                                 (((y)-ED_SIZE_GADGET_YPOS) %          \
-                                  ED_SIZE_GADGET_YSIZE) <              \
-                                 ED_BUTTON_MINUS_YSIZE))
-
-#define EDIT_BUTTON(x,y)       (((y) < (VY + ED_BUTTON_CTRL_YPOS +     \
-                                        ED_BUTTON_CTRL_YSIZE)) ? 0 :   \
-                                ((y) < (VY + ED_BUTTON_CTRL_YPOS +     \
-                                        ED_BUTTON_CTRL_YSIZE +         \
-                                        ED_BUTTON_FILL_YSIZE)) ? 1 :   \
-                                ((x) < (VX + ED_BUTTON_LEFT_XPOS +     \
-                                        ED_BUTTON_LEFT_XSIZE) ? 2 :    \
-                                 (x) > (VX + ED_BUTTON_LEFT_XPOS +     \
-                                        ED_BUTTON_LEFT_XSIZE +         \
-                                        ED_BUTTON_UP_XSIZE) ? 5 :      \
-                                 3+(((y)-(VY + ED_BUTTON_CTRL_YPOS +   \
-                                          ED_BUTTON_CTRL_YSIZE +       \
-                                          ED_BUTTON_FILL_YSIZE)) /     \
-                                    ED_BUTTON_UP_YSIZE)))
-
-#define CTRL_BUTTON(x,y)       (((y) < (VY + ED_BUTTON_EDIT_YPOS +     \
-                                        ED_BUTTON_EDIT_YSIZE)) ? 0 :   \
-                                1+(((y)-(VY + ED_BUTTON_EDIT_YPOS +    \
-                                        ED_BUTTON_EDIT_YSIZE)) /       \
-                                   ED_BUTTON_CLEAR_YSIZE))
-
-#define ELEM_BUTTON(x,y)       (((y) < (DY + ED_BUTTON_EUP_YPOS +      \
-                                        ED_BUTTON_EUP_YSIZE)) ? 0 :    \
-                                ((y) > (DY + ED_BUTTON_EDOWN_YPOS)) ? 1 : \
-                                2+(((y) - (DY + ED_BUTTON_ELEM_YPOS)) /   \
-                                ED_BUTTON_ELEM_YSIZE)*MAX_ELEM_X +     \
-                                ((x) - (DX + ED_BUTTON_ELEM_XPOS)) /   \
-                                ED_BUTTON_ELEM_XSIZE)
-
-#define COUNT_BUTTON(x,y)      ((x) < ED_SIZE_GADGET_XPOS ?            \
-                                ((((y) - ED_COUNT_GADGET_YPOS) /       \
-                                  ED_COUNT_GADGET_YSIZE)*2 +           \
-                                 ((x) < (ED_COUNT_GADGET_XPOS +        \
-                                         ED_BUTTON_MINUS_XSIZE) ? 0 : 1)) : \
-                                32+((((y) - ED_SIZE_GADGET_YPOS) /     \
-                                     ED_SIZE_GADGET_YSIZE)*2 +         \
-                                    ((x) < (ED_SIZE_GADGET_XPOS +      \
-                                            ED_BUTTON_MINUS_XSIZE) ? 0 : 1)))
-
-/* values for asking control */
-#define ED_BUTTON_CTRL         (1L<<0)
-#define ED_BUTTON_FILL         (1L<<1)
-#define ED_BUTTON_LEFT         (1L<<2)
-#define ED_BUTTON_UP           (1L<<3)
-#define ED_BUTTON_DOWN         (1L<<4)
-#define ED_BUTTON_RIGHT                (1L<<5)
-#define ED_BUTTON_EDIT         (1L<<6)
-#define ED_BUTTON_CLEAR                (1L<<7)
-#define ED_BUTTON_UNDO         (1L<<8)
-#define ED_BUTTON_EXIT         (1L<<9)
-
-#define ED_BUTTON_PRESSED      (1L<<10)
-#define ED_BUTTON_RELEASED     (1L<<11)
-
-#define ED_BUTTON_EUP          0
-#define ED_BUTTON_EDOWN                1
-#define ED_BUTTON_ELEM         2
-
-#if 0
-
-/* OBSOLETE *********************** */
-
-/* sizes in the level editor */
-#define ED_PFEIL_XSIZE  46
-#define ED_PFEIL_YSIZE  19
-#define ED_ZEIT_XSIZE   20
-#define ED_ZEIT_YSIZE   20
-#define ED_CLEX_XSIZE   46
-#define ED_CLEX_YSIZE   18
-#define ED_BUT_CLEX_Y   (DYSIZE-2-ED_CLEX_YSIZE)
-#define ED_BUT_ZEIT_Y   (ED_BUT_CLEX_Y-2-ED_ZEIT_YSIZE)
-#define ED_BUT_PFEIL_Y  (ED_BUT_ZEIT_Y-2-ED_PFEIL_YSIZE)
-#define ED_BUT_ZEIT2_X  (ED_ZEIT_XSIZE+10)
-#define ED_BUT_ZEIT2_Y  (ED_BUT_ZEIT_Y+4)
-#define ED_BUT_X        2
-#define ED_BUT_Y        ED_BUT_PFEIL_Y
-
-/* OBSOLETE *********************** */
-
-#endif
-
-
 /* other constants for the editor */
 #define ED_SCROLL_NO           0
 #define ED_SCROLL_LEFT         1
 #define ED_SCROLL_UP           4
 #define ED_SCROLL_DOWN         8
 
+extern int element_shift;
+extern int editor_element[];
+extern int elements_in_list;
+
 void DrawLevelEd(void);
 void ScrollMiniLevel(int, int, int);
 void LevelEd(int, int, int);
 void LevelNameTyping(KeySym);
-void DrawEditButton(unsigned long state);
-void DrawCtrlButton(unsigned long state);
-void DrawElemButton(int, int);
-void DrawCountButton(int, int);
-int CheckEditButtons(int, int, int);
-int CheckCtrlButtons(int, int, int);
-int CheckElemButtons(int, int, int);
-int CheckCountButtons(int, int, int);
 
 #endif
index 1e8fcd1..9eb8d62 100644 (file)
@@ -10,8 +10,6 @@
 *               q99492@pbhrzx.uni-paderborn.de             *
 *----------------------------------------------------------*
 *  events.c                                                *
-*                                                          *
-*  Letzte Aenderung: 15.06.1995                            *
 ***********************************************************/
 
 #include "events.h"
@@ -19,6 +17,7 @@
 #include "tools.h"
 #include "game.h"
 #include "editor.h"
+#include "misc.h"
 
 void EventLoop(void)
 {
@@ -67,6 +66,8 @@ void EventLoop(void)
     {
       HandleNoXEvent();
 
+      XSync(display,FALSE);
+
       if (game_status!=PLAYING)
        Delay(10000);           /* don't use all CPU time when idle */
     }
@@ -658,7 +659,7 @@ void HandleJoystick()
        break;
       }
 
-      if ((GameOver || LevelSolved) && newbutton)
+      if (GameOver && newbutton)
       {
        CloseDoor(DOOR_CLOSE_1);
        game_status = MAINMENU;
index 539db84..1916ea3 100644 (file)
@@ -10,8 +10,6 @@
 *               q99492@pbhrzx.uni-paderborn.de             *
 *----------------------------------------------------------*
 *  events.h                                                *
-*                                                          *
-*  Letzte Aenderung: 15.06.1995                            *
 ***********************************************************/
 
 #ifndef EVENTS_H
diff --git a/src/files.c b/src/files.c
new file mode 100644 (file)
index 0000000..e349c06
--- /dev/null
@@ -0,0 +1,703 @@
+/***********************************************************
+*  Rocks'n'Diamonds -- McDuffin Strikes Back!              *
+*----------------------------------------------------------*
+*  ©1995 Artsoft Development                               *
+*        Holger Schemel                                    *
+*        33659 Bielefeld-Senne                             *
+*        Telefon: (0521) 493245                            *
+*        eMail: aeglos@valinor.owl.de                      *
+*               aeglos@uni-paderborn.de                    *
+*               q99492@pbhrzx.uni-paderborn.de             *
+*----------------------------------------------------------*
+*  files.h                                                 *
+***********************************************************/
+
+#include "files.h"
+#include "tools.h"
+#include "misc.h"
+
+BOOL CreateNewScoreFile()
+{
+  int i,j,k;
+  char filename[MAX_FILENAME];
+  char empty_alias[MAX_NAMELEN];
+  FILE *file;
+
+  sprintf(filename,"%s/%s/%s",
+         SCORE_PATH,leveldir[leveldir_nr].filename,SCORE_FILENAME);
+
+  if (!(file=fopen(filename,"w")))
+    return(FALSE);
+
+  for(i=0;i<MAX_NAMELEN;i++)
+    empty_alias[i] = 0;
+  strncpy(empty_alias,EMPTY_ALIAS,MAX_NAMELEN-1);
+
+  fputs(SCORE_COOKIE,file);            /* Formatkennung */
+  for(i=0;i<LEVELDIR_SIZE(leveldir[leveldir_nr]);i++)
+  {
+    for(j=0;j<MAX_SCORE_ENTRIES;j++)
+    {
+      for(k=0;k<MAX_NAMELEN;k++)
+       fputc(empty_alias[k],file);
+      fputc(0,file);
+      fputc(0,file);
+    }
+  }
+  fclose(file);
+
+  chmod(filename, SCORE_PERMS);
+  return(TRUE);
+}
+
+BOOL CreateNewNamesFile(int mode)
+{
+  char filename[MAX_FILENAME];
+  FILE *file;
+
+  if (mode==PLAYER_LEVEL)
+    sprintf(filename,"%s/%s/%s",
+           NAMES_PATH,leveldir[leveldir_nr].filename,NAMES_FILENAME);
+  else
+    sprintf(filename,"%s/%s",CONFIG_PATH,NAMES_FILENAME);
+
+  if (!(file=fopen(filename,"w")))
+    return(FALSE);
+
+  fputs(NAMES_COOKIE,file);            /* Formatkennung */
+  fclose(file);
+
+  chmod(filename, NAMES_PERMS);
+  return(TRUE);
+}
+
+BOOL LoadLevelInfo()
+{
+  int i;
+  char filename[MAX_FILENAME];
+  char cookie[MAX_FILENAME];
+  FILE *file;
+
+  sprintf(filename,"%s/%s",LEVEL_PATH,LEVDIR_FILENAME);
+
+  if (!(file=fopen(filename,"r")))
+  {
+    fprintf(stderr,"%s: cannot load level info '%s'!\n",progname,filename);
+    return(FALSE);
+  }
+
+  fscanf(file,"%s\n",cookie);
+  if (strcmp(cookie,LEVELDIR_COOKIE))  /* ungültiges Format? */
+  {
+    fprintf(stderr,"%s: wrong format of level info file!\n",progname);
+    fclose(file);
+    return(FALSE);
+  }
+
+  num_leveldirs = 0;
+  leveldir_nr = 0;
+  for(i=0;i<MAX_LEVDIR_ENTRIES;i++)
+  {
+    fscanf(file,"%s",leveldir[i].filename);
+    fscanf(file,"%s",leveldir[i].name);
+    fscanf(file,"%d",&leveldir[i].num_ready);
+    fscanf(file,"%d",&leveldir[i].num_free);
+    if (feof(file))
+      break;
+
+    num_leveldirs++;
+  }
+
+  if (!num_leveldirs)
+  {
+    fprintf(stderr,"%s: empty level info '%s'!\n",progname,filename);
+    return(FALSE);
+  }
+
+  return(TRUE);
+}
+
+void LoadLevel(int level_nr)
+{
+  int i,x,y;
+  char filename[MAX_FILENAME];
+  char cookie[MAX_FILENAME];
+  FILE *file;
+
+  sprintf(filename,"%s/%s/%d",
+         LEVEL_PATH,leveldir[leveldir_nr].filename,level_nr);
+
+  if (!(file=fopen(filename,"r")))
+  {
+/*
+    fprintf(stderr,"%s: cannot load level '%s'!\n",progname,filename);
+*/
+  }
+  else
+  {
+    fgets(cookie,LEVEL_COOKIE_LEN,file);
+    fgetc(file);
+    if (strcmp(cookie,LEVEL_COOKIE))   /* ungültiges Format? */
+    {
+      fprintf(stderr,"%s: wrong format of level file '%s'!\n",
+             progname,filename);
+      fclose(file);
+      file = NULL;
+    }
+  }
+
+  if (file)
+  {
+    lev_fieldx = level.fieldx = fgetc(file);
+    lev_fieldy = level.fieldy = fgetc(file);
+
+    level.time         = (fgetc(file)<<8) | fgetc(file);
+    level.edelsteine   = (fgetc(file)<<8) | fgetc(file);
+    for(i=0;i<MAX_LEVNAMLEN;i++)
+      level.name[i]    = fgetc(file);
+    for(i=0;i<MAX_SC_ENTRIES;i++)
+      level.score[i]   = fgetc(file);
+    level.amoebe_inhalt = fgetc(file);
+    for(i=0;i<4;i++)
+      for(y=0;y<3;y++)
+       for(x=0;x<3;x++)
+         level.mampfer_inhalt[i][x][y] = fgetc(file);
+    level.tempo_amoebe = fgetc(file);
+    level.dauer_sieb   = fgetc(file);
+    level.dauer_ablenk = fgetc(file);
+
+    for(i=0;i<19;i++)  /* Rest reserviert / Headergröße 80 Bytes */
+      fgetc(file);
+
+    for(y=0;y<MAX_LEV_FIELDY;y++) 
+      for(x=0;x<MAX_LEV_FIELDX;x++) 
+       Feld[x][y] = Ur[x][y] = EL_ERDREICH;
+
+    for(y=0;y<lev_fieldy;y++) 
+      for(x=0;x<lev_fieldx;x++) 
+       Feld[x][y] = Ur[x][y] = fgetc(file);
+
+    fclose(file);
+
+    if (level.time<=10)        /* Mindestspieldauer */
+      level.time = 10;
+  }
+  else
+  {
+    lev_fieldx = level.fieldx = STD_LEV_FIELDX;
+    lev_fieldy = level.fieldy = STD_LEV_FIELDY;
+
+    level.time         = 100;
+    level.edelsteine   = 0;
+    strncpy(level.name,"Nameless Level",MAX_LEVNAMLEN-1);
+    for(i=0;i<MAX_SC_ENTRIES;i++)
+      level.score[i]   = 10;
+    level.amoebe_inhalt = EL_DIAMANT;
+    for(i=0;i<4;i++)
+      for(y=0;y<3;y++)
+       for(x=0;x<3;x++)
+         level.mampfer_inhalt[i][x][y] = EL_FELSBROCKEN;
+    level.tempo_amoebe = 10;
+    level.dauer_sieb   = 10;
+    level.dauer_ablenk = 10;
+
+    for(y=0;y<STD_LEV_FIELDY;y++) 
+      for(x=0;x<STD_LEV_FIELDX;x++) 
+       Feld[x][y] = Ur[x][y] = EL_ERDREICH;
+    Feld[0][0] = Ur[0][0] = EL_SPIELFIGUR;
+    Feld[STD_LEV_FIELDX-1][STD_LEV_FIELDY-1] =
+      Ur[STD_LEV_FIELDX-1][STD_LEV_FIELDY-1] = EL_AUSGANG_ZU;
+  }
+}
+
+void LoadLevelTape(int level_nr)
+{
+  int i;
+  char filename[MAX_FILENAME];
+  char cookie[MAX_FILENAME];
+  FILE *file;
+
+  sprintf(filename,"%s/%s/%d.tape",
+         LEVEL_PATH,leveldir[leveldir_nr].filename,level_nr);
+
+  if ((file=fopen(filename,"r")))
+  {
+    fgets(cookie,LEVELREC_COOKIE_LEN,file);
+    fgetc(file);
+    if (strcmp(cookie,LEVELREC_COOKIE))        /* ungültiges Format? */
+    {
+      fprintf(stderr,"%s: wrong format of level recording file '%s'!\n",
+             progname,filename);
+      fclose(file);
+      file = NULL;
+    }
+  }
+
+  if (!file)
+    return;
+
+  tape.random_seed =
+    (fgetc(file)<<24) | (fgetc(file)<<16) | (fgetc(file)<<8) | fgetc(file);
+  tape.date =
+    (fgetc(file)<<24) | (fgetc(file)<<16) | (fgetc(file)<<8) | fgetc(file);
+  tape.length =
+    (fgetc(file)<<24) | (fgetc(file)<<16) | (fgetc(file)<<8) | fgetc(file);
+
+  tape.level_nr = level_nr;
+  tape.counter = 0;
+  tape.recording = FALSE;
+  tape.playing = FALSE;
+  tape.pausing = FALSE;
+
+  for(i=0;i<tape.length;i++)
+  {
+    if (i>=MAX_TAPELEN)
+      break;
+    tape.pos[i].joystickdata = fgetc(file);
+    tape.pos[i].delay        = fgetc(file);
+    if (feof(file))
+      break;
+  }
+
+  if (i != tape.length)
+    fprintf(stderr,"%s: level recording file '%s' corrupted!\n",
+           progname,filename);
+
+  fclose(file);
+
+  master_tape = tape;
+}
+
+void LoadScore(int level_nr)
+{
+  int i,j;
+  char filename[MAX_FILENAME];
+  char cookie[MAX_FILENAME];
+  FILE *file;
+
+  sprintf(filename,"%s/%s/%s",
+         SCORE_PATH,leveldir[leveldir_nr].filename,SCORE_FILENAME);
+
+  if (!(file=fopen(filename,"r")))
+  {
+    if (!CreateNewScoreFile())
+    {
+      fprintf(stderr,"%s: cannot create score file '%s'!\n",
+             progname,filename);
+    }
+    else if (!(file=fopen(filename,"r"))) 
+    {
+      fprintf(stderr,"%s: cannot load score for level %d!\n",
+             progname,level_nr);
+    }
+  }
+
+  if (file)
+  {
+    fgets(cookie,SCORE_COOKIE_LEN,file);
+    if (strcmp(cookie,SCORE_COOKIE))   /* ungültiges Format? */
+    {
+      fprintf(stderr,"%s: wrong format of score file!\n",progname);
+      fclose(file);
+      file = NULL;
+    }
+  }
+
+  if (file)
+  {
+    fseek(file,
+         SCORE_COOKIE_LEN-1+level_nr*(MAX_SCORE_ENTRIES*(MAX_NAMELEN+2)),
+         SEEK_SET);
+    for(i=0;i<MAX_SCORE_ENTRIES;i++)
+    {
+      for(j=0;j<MAX_NAMELEN;j++)
+       highscore[i].Name[j] = fgetc(file);
+      highscore[i].Score = (fgetc(file)<<8) | fgetc(file);
+    }
+    fclose(file);
+  }
+  else
+  {
+    for(i=0;i<MAX_SCORE_ENTRIES;i++)
+    {
+      strcpy(highscore[i].Name,EMPTY_ALIAS);
+      highscore[i].Score = 0;
+    }
+  }
+}
+
+void LoadPlayerInfo(int mode)
+{
+  int i;
+  char filename[MAX_FILENAME];
+  char cookie[MAX_FILENAME];
+  FILE *file;
+  char *login_name = GetLoginName();
+  struct PlayerInfo default_player, new_player;
+
+  if (mode==PLAYER_LEVEL)
+    sprintf(filename,"%s/%s/%s",
+           NAMES_PATH,leveldir[leveldir_nr].filename,NAMES_FILENAME);
+  else
+    sprintf(filename,"%s/%s",CONFIG_PATH,NAMES_FILENAME);
+
+  for(i=0;i<MAX_NAMELEN;i++)
+    default_player.login_name[i] = default_player.alias_name[i] = 0;
+  strncpy(default_player.login_name,login_name,MAX_NAMELEN-1);
+  strncpy(default_player.alias_name,login_name,MAX_NAMELEN-1);
+  default_player.handicap = 0;
+  default_player.setup = DEFAULT_SETUP;
+  default_player.leveldir_nr = 0;
+
+  new_player = default_player;
+
+  if (!(file=fopen(filename,"r")))
+  {
+    if (!CreateNewNamesFile(mode))
+    {
+      fprintf(stderr,"%s: cannot create names file '%s'!\n",
+             progname,filename);
+    }
+    else if (!(file=fopen(filename,"r"))) 
+    {
+      fprintf(stderr,"%s: cannot load player information '%s'!\n",
+             progname,filename);
+    }
+  }
+
+  if (file)
+  {
+    fgets(cookie,NAMES_COOKIE_LEN,file);
+    if (strcmp(cookie,NAMES_COOKIE))   /* ungültiges Format? */
+    {
+      fprintf(stderr,"%s: wrong format of names file '%s'!\n",
+             progname,filename);
+      fclose(file);
+      file = NULL;
+    }
+  }
+
+  if (!file)
+  {
+    player = default_player;
+    level_nr = default_player.handicap;
+    return;
+  }
+
+  while(1)
+  {
+    for(i=0;i<MAX_NAMELEN;i++)
+      new_player.login_name[i] = fgetc(file);
+    for(i=0;i<MAX_NAMELEN;i++)
+      new_player.alias_name[i] = fgetc(file);
+    new_player.handicap = fgetc(file);
+    new_player.setup = (fgetc(file)<<8) | fgetc(file);
+    new_player.leveldir_nr = fgetc(file);
+
+    if (feof(file))            /* Spieler noch nicht in Liste enthalten */
+    {
+      new_player = default_player;
+
+      fclose(file);
+      if (!(file=fopen(filename,"a")))
+      {
+       fprintf(stderr,"%s: cannot append new player to names file '%s'!\n",
+               progname,filename);
+      }
+      else
+      {
+       for(i=0;i<MAX_NAMELEN;i++)
+         fputc(new_player.login_name[i],file);
+       for(i=0;i<MAX_NAMELEN;i++)
+         fputc(new_player.alias_name[i],file);
+       fputc(new_player.handicap,file);
+       fputc(new_player.setup / 256,file);
+       fputc(new_player.setup % 256,file);
+       fputc(new_player.leveldir_nr,file);
+      }
+      break;
+    }
+    else                       /* prüfen, ob Spieler in Liste enthalten */
+      if (!strncmp(new_player.login_name,login_name,MAX_NAMELEN-1))
+       break;
+  }
+
+  if (mode==PLAYER_SETUP)
+  {
+    player = new_player;
+    if (player.leveldir_nr < num_leveldirs)
+      leveldir_nr = player.leveldir_nr;
+    else
+      leveldir_nr = 0;
+  }
+  else
+    player.handicap = new_player.handicap;
+
+  level_nr = player.handicap;
+  fclose(file);
+}
+
+void SaveLevel(int level_nr)
+{
+  int i,x,y;
+  char filename[MAX_FILENAME];
+  FILE *file;
+
+  sprintf(filename,"%s/%s/%d",
+         LEVEL_PATH,leveldir[leveldir_nr].filename,level_nr);
+
+  if (!(file=fopen(filename,"w")))
+  {
+    fprintf(stderr,"%s: cannot save level file '%s'!\n",progname,filename);
+    return;
+  }
+
+  fputs(LEVEL_COOKIE,file);            /* Formatkennung */
+  fputc(0x0a,file);
+
+  fputc(level.fieldx,file);
+  fputc(level.fieldy,file);
+  fputc(level.time / 256,file);
+  fputc(level.time % 256,file);
+  fputc(level.edelsteine / 256,file);
+  fputc(level.edelsteine % 256,file);
+
+  for(i=0;i<MAX_LEVNAMLEN;i++)
+    fputc(level.name[i],file);
+  for(i=0;i<MAX_SC_ENTRIES;i++)
+    fputc(level.score[i],file);
+  fputc(level.amoebe_inhalt,file);
+  for(i=0;i<4;i++)
+    for(y=0;y<3;y++)
+      for(x=0;x<3;x++)
+       fputc(level.mampfer_inhalt[i][x][y],file);
+  fputc(level.tempo_amoebe,file);
+  fputc(level.dauer_sieb,file);
+  fputc(level.dauer_ablenk,file);
+
+  for(i=0;i<19;i++)    /* Rest reserviert / Headergröße 80 Bytes */
+    fputc(0,file);
+
+  for(y=0;y<lev_fieldy;y++) 
+    for(x=0;x<lev_fieldx;x++) 
+      fputc(Ur[x][y],file);
+
+  fclose(file);
+
+  chmod(filename, LEVEL_PERMS);
+}
+
+void SaveLevelTape(int level_nr)
+{
+  int i;
+  char filename[MAX_FILENAME];
+  FILE *file;
+  BOOL new_tape = TRUE;
+
+  sprintf(filename,"%s/%s/%d.tape",
+         LEVEL_PATH,leveldir[leveldir_nr].filename,level_nr);
+
+  /* Testen, ob bereits eine Aufnahme existiert */
+  if ((file=fopen(filename,"r")))
+  {
+    new_tape = FALSE;
+    fclose(file);
+
+    if (!AreYouSure("Replace old tape ?",AYS_ASK))
+      return;
+  }
+
+  if (!(file=fopen(filename,"w")))
+  {
+    fprintf(stderr,"%s: cannot save level recording file '%s'!\n",
+           progname,filename);
+    return;
+  }
+
+  fputs(LEVELREC_COOKIE,file);         /* Formatkennung */
+  fputc(0x0a,file);
+
+  tape = master_tape;
+
+  fputc((tape.random_seed >> 24) & 0xff,file);
+  fputc((tape.random_seed >> 16) & 0xff,file);
+  fputc((tape.random_seed >>  8) & 0xff,file);
+  fputc((tape.random_seed >>  0) & 0xff,file);
+
+  fputc((tape.date >>  24) & 0xff,file);
+  fputc((tape.date >>  16) & 0xff,file);
+  fputc((tape.date >>   8) & 0xff,file);
+  fputc((tape.date >>   0) & 0xff,file);
+
+  fputc((tape.length >>  24) & 0xff,file);
+  fputc((tape.length >>  16) & 0xff,file);
+  fputc((tape.length >>   8) & 0xff,file);
+  fputc((tape.length >>   0) & 0xff,file);
+
+  for(i=0;i<tape.length;i++)
+  {
+    fputc(tape.pos[i].joystickdata,file);
+    fputc(tape.pos[i].delay,file);
+  }
+
+  fclose(file);
+
+  chmod(filename, LEVREC_PERMS);
+
+  if (new_tape)
+    AreYouSure("tape saved !",AYS_CONFIRM);
+}
+
+void SaveScore(int level_nr)
+{
+  int i,j;
+  char filename[MAX_FILENAME];
+  FILE *file;
+
+  sprintf(filename,"%s/%s/%s",
+         SCORE_PATH,leveldir[leveldir_nr].filename,SCORE_FILENAME);
+
+  if (!(file=fopen(filename,"r+")))
+  {
+    fprintf(stderr,"%s: cannot save score for level %d!\n",
+           progname,level_nr);
+    return;
+  }
+
+  fseek(file,
+       SCORE_COOKIE_LEN-1+level_nr*(MAX_SCORE_ENTRIES*(MAX_NAMELEN+2)),
+       SEEK_SET);
+  for(i=0;i<MAX_SCORE_ENTRIES;i++)
+  {
+    for(j=0;j<MAX_NAMELEN;j++)
+      fputc(highscore[i].Name[j],file);
+    fputc(highscore[i].Score / 256,file);
+    fputc(highscore[i].Score % 256,file);
+  }
+  fclose(file);
+}
+
+void SavePlayerInfo(int mode)
+{
+  int i;
+  char filename[MAX_FILENAME];
+  char cookie[MAX_FILENAME];
+  FILE *file;
+  struct PlayerInfo default_player;
+
+  if (mode==PLAYER_LEVEL)
+    sprintf(filename,"%s/%s/%s",
+           NAMES_PATH,leveldir[leveldir_nr].filename,NAMES_FILENAME);
+  else
+    sprintf(filename,"%s/%s",CONFIG_PATH,NAMES_FILENAME);
+
+  if (!(file=fopen(filename,"r+")))
+  {
+    fprintf(stderr,"%s: cannot save player information '%s'!\n",
+           progname,filename);
+    return;
+  }
+
+  fgets(cookie,NAMES_COOKIE_LEN,file);
+  if (strcmp(cookie,NAMES_COOKIE))     /* ungültiges Format? */
+  {
+    fprintf(stderr,"%s: wrong format of names file '%s'!\n",
+           progname,filename);
+    fclose(file);
+    return;
+  }
+
+  while(1)
+  {
+    for(i=0;i<MAX_NAMELEN;i++)
+      default_player.login_name[i] = fgetc(file);
+    for(i=0;i<MAX_NAMELEN;i++)
+      default_player.alias_name[i] = fgetc(file);
+    default_player.handicap = fgetc(file);
+    default_player.setup = (fgetc(file)<<8) | fgetc(file);
+    default_player.leveldir_nr = fgetc(file);
+
+    if (feof(file))            /* Spieler noch nicht in Liste enthalten */
+      break;
+    else                       /* prüfen, ob Spieler in Liste enthalten */
+      if (!strncmp(default_player.login_name,player.login_name,MAX_NAMELEN-1))
+      {
+       fseek(file,-(2*MAX_NAMELEN+1+2+1),SEEK_CUR);
+       break;
+      }
+  }
+
+  for(i=0;i<MAX_NAMELEN;i++)
+    fputc(player.login_name[i],file);
+  for(i=0;i<MAX_NAMELEN;i++)
+    fputc(player.alias_name[i],file);
+  fputc(player.handicap,file);
+  fputc(player.setup / 256,file);
+  fputc(player.setup % 256,file);
+  fputc(player.leveldir_nr,file);
+
+  fclose(file);
+}
+
+void LoadJoystickData()
+{
+  int i;
+  char cookie[256];
+  FILE *file;
+
+  if (joystick_status==JOYSTICK_OFF)
+    return;
+
+  if (!(file=fopen(JOYDAT_FILE,"r")))
+    return;
+
+  fscanf(file,"%s",cookie);
+  if (strcmp(cookie,JOYSTICK_COOKIE))  /* ungültiges Format? */
+  {
+    fprintf(stderr,"%s: wrong format of joystick file!\n",progname);
+    fclose(file);
+    return;
+  }
+
+  for(i=0;i<2;i++)
+  {
+    fscanf(file,"%s",cookie);
+    fscanf(file, "%d %d %d \n",
+          &joystick[i].xleft, &joystick[i].xmiddle, &joystick[i].xright);
+    fscanf(file, "%d %d %d \n",
+          &joystick[i].yupper, &joystick[i].ymiddle, &joystick[i].ylower);
+  }
+  fclose(file);
+
+  CheckJoystickData();
+}
+
+void SaveJoystickData()
+{
+  int i;
+  FILE *file;
+
+  if (joystick_status==JOYSTICK_OFF)
+    return;
+
+  CheckJoystickData();
+
+  if (!(file=fopen(JOYDAT_FILE,"w")))
+  {
+    fprintf(stderr,"%s: cannot save joystick calibration data!\n",progname);
+    return;
+  }
+
+  fprintf(file,"%s\n",JOYSTICK_COOKIE);        /* Formatkennung */
+  for(i=0;i<2;i++)
+  {
+    fprintf(file,"JOYSTICK_%d_DATA\n",i);
+    fprintf(file, "%d %d %d \n",
+           joystick[i].xleft, joystick[i].xmiddle, joystick[i].xright);
+    fprintf(file, "%d %d %d \n",
+           joystick[i].yupper, joystick[i].ymiddle, joystick[i].ylower);
+  }
+  fclose(file);
+
+  chmod(JOYDAT_FILE, JOYDAT_PERMS);
+}
diff --git a/src/files.h b/src/files.h
new file mode 100644 (file)
index 0000000..aee5e42
--- /dev/null
@@ -0,0 +1,65 @@
+/***********************************************************
+*  Rocks'n'Diamonds -- McDuffin Strikes Back!              *
+*----------------------------------------------------------*
+*  ©1995 Artsoft Development                               *
+*        Holger Schemel                                    *
+*        33659 Bielefeld-Senne                             *
+*        Telefon: (0521) 493245                            *
+*        eMail: aeglos@valinor.owl.de                      *
+*               aeglos@uni-paderborn.de                    *
+*               q99492@pbhrzx.uni-paderborn.de             *
+*----------------------------------------------------------*
+*  files.h                                                 *
+***********************************************************/
+
+#ifndef FILES_H
+#define FILES_H
+
+#include "main.h"
+
+/* names file mode: level or setup */
+#define PLAYER_LEVEL   0
+#define PLAYER_SETUP   1
+
+/* Setup-Bits */
+#define SETUP_TOONS                    (1<<0)
+#define SETUP_SOUND                    (1<<1)
+#define SETUP_SOUND_LOOPS              (1<<2)
+#define SETUP_SOUND_MUSIC              (1<<3)
+#define SETUP_DIRECT_DRAW              (1<<4)
+#define SETUP_FADING                   (1<<5)
+#define SETUP_RECORD_EACH_GAME         (1<<6)
+#define SETUP_2ND_JOYSTICK             (1<<7)
+#define SETUP_QUICK_DOORS              (1<<8)
+
+#define DEFAULT_SETUP                  (SETUP_TOONS |          \
+                                        SETUP_SOUND |          \
+                                        SETUP_SOUND_LOOPS |    \
+                                        SETUP_SOUND_MUSIC)
+
+/* Setup-Voreinstellungen */
+#define SETUP_TOONS_ON(x)              (((x) & SETUP_TOONS) != 0)
+#define SETUP_SOUND_ON(x)              (((x) & SETUP_SOUND) != 0)
+#define SETUP_SOUND_LOOPS_ON(x)                (((x) & SETUP_SOUND_LOOPS) != 0)
+#define SETUP_SOUND_MUSIC_ON(x)                (((x) & SETUP_SOUND_MUSIC) != 0)
+#define SETUP_DIRECT_DRAW_ON(x)                (((x) & SETUP_DIRECT_DRAW) != 0)
+#define SETUP_FADING_ON(x)             (((x) & SETUP_FADING) != 0)
+#define SETUP_RECORD_EACH_GAME_ON(x)   (((x) & SETUP_RECORD_EACH_GAME) != 0)
+#define SETUP_2ND_JOYSTICK_ON(x)       (((x) & SETUP_2ND_JOYSTICK) != 0)
+#define SETUP_QUICK_DOORS_ON(x)                (((x) & SETUP_QUICK_DOORS) != 0)
+
+BOOL CreateNewScoreFile(void);
+BOOL CreateNewNamesFile(int);
+BOOL LoadLevelInfo(void);
+void LoadLevel(int);
+void LoadLevelTape(int);
+void LoadScore(int);
+void LoadPlayerInfo(int);
+void SaveLevel(int);
+void SaveLevelTape(int);
+void SaveScore(int);
+void SavePlayerInfo(int);
+void LoadJoystickData(void);
+void SaveJoystickData(void);
+
+#endif
index 6d5ca5b..8d88167 100644 (file)
@@ -10,8 +10,6 @@
 *               q99492@pbhrzx.uni-paderborn.de             *
 *----------------------------------------------------------*
 *  game.c                                                  *
-*                                                          *
-*  Letzte Aenderung: 15.06.1995                            *
 ***********************************************************/
 
 #include "game.h"
 #include "screens.h"
 #include "sound.h"
 #include "init.h"
-
-BOOL CreateNewScoreFile()
-{
-  int i,j,k;
-  char filename[MAX_FILENAME];
-  char empty_alias[MAX_NAMELEN];
-  FILE *file;
-
-  sprintf(filename,"%s/%s/%s",
-         SCORE_PATH,leveldir[leveldir_nr].filename,SCORE_FILENAME);
-
-  if (!(file=fopen(filename,"w")))
-    return(FALSE);
-
-  for(i=0;i<MAX_NAMELEN;i++)
-    empty_alias[i] = 0;
-  strncpy(empty_alias,EMPTY_ALIAS,MAX_NAMELEN-1);
-
-  fputs(SCORE_COOKIE,file);            /* Formatkennung */
-  for(i=0;i<LEVELDIR_SIZE(leveldir[leveldir_nr]);i++)
-  {
-    for(j=0;j<MAX_SCORE_ENTRIES;j++)
-    {
-      for(k=0;k<MAX_NAMELEN;k++)
-       fputc(empty_alias[k],file);
-      fputc(0,file);
-      fputc(0,file);
-    }
-  }
-  fclose(file);
-
-  chmod(filename, SCORE_PERMS);
-  return(TRUE);
-}
-
-BOOL CreateNewNamesFile(int mode)
-{
-  char filename[MAX_FILENAME];
-  FILE *file;
-
-  if (mode==PLAYER_LEVEL)
-    sprintf(filename,"%s/%s/%s",
-           NAMES_PATH,leveldir[leveldir_nr].filename,NAMES_FILENAME);
-  else
-    sprintf(filename,"%s/%s",CONFIG_PATH,NAMES_FILENAME);
-
-  if (!(file=fopen(filename,"w")))
-    return(FALSE);
-
-  fputs(NAMES_COOKIE,file);            /* Formatkennung */
-  fclose(file);
-
-  chmod(filename, NAMES_PERMS);
-  return(TRUE);
-}
-
-void LoadLevelInfo()
-{
-  int i;
-  char filename[MAX_FILENAME];
-  char cookie[MAX_FILENAME];
-  FILE *file;
-
-  sprintf(filename,"%s/%s",LEVEL_PATH,LEVDIR_FILENAME);
-
-  if (!(file=fopen(filename,"r")))
-  {
-    fprintf(stderr,"%s: cannot load level info '%s'!\n",progname,filename);
-    CloseAll();
-  }
-
-  fscanf(file,"%s\n",cookie);
-  if (strcmp(cookie,LEVELDIR_COOKIE))  /* ungültiges Format? */
-  {
-    fprintf(stderr,"%s: wrong format of level info file!\n",progname);
-    fclose(file);
-    CloseAll();
-  }
-
-  num_leveldirs = 0;
-  leveldir_nr = 0;
-  for(i=0;i<MAX_LEVDIR_ENTRIES;i++)
-  {
-    fscanf(file,"%s",leveldir[i].filename);
-    fscanf(file,"%s",leveldir[i].name);
-    fscanf(file,"%d",&leveldir[i].num_ready);
-    fscanf(file,"%d",&leveldir[i].num_free);
-    if (feof(file))
-      break;
-
-    num_leveldirs++;
-  }
-
-  if (!num_leveldirs)
-  {
-    fprintf(stderr,"%s: empty level info '%s'!\n",progname,filename);
-    CloseAll();
-  }
-}
-
-void LoadLevel(int level_nr)
-{
-  int i,x,y;
-  char filename[MAX_FILENAME];
-  char cookie[MAX_FILENAME];
-  FILE *file;
-
-  sprintf(filename,"%s/%s/%d",
-         LEVEL_PATH,leveldir[leveldir_nr].filename,level_nr);
-
-  if (!(file=fopen(filename,"r")))
-  {
-/*
-    fprintf(stderr,"%s: cannot load level '%s'!\n",progname,filename);
-*/
-  }
-  else
-  {
-    fgets(cookie,LEVEL_COOKIE_LEN,file);
-    fgetc(file);
-    if (strcmp(cookie,LEVEL_COOKIE))   /* ungültiges Format? */
-    {
-      fprintf(stderr,"%s: wrong format of level file '%s'!\n",
-             progname,filename);
-      fclose(file);
-      file = NULL;
-    }
-  }
-
-  if (file)
-  {
-    lev_fieldx = level.fieldx = fgetc(file);
-    lev_fieldy = level.fieldy = fgetc(file);
-
-    level.time         = (fgetc(file)<<8) | fgetc(file);
-    level.edelsteine   = (fgetc(file)<<8) | fgetc(file);
-    for(i=0;i<MAX_LEVNAMLEN;i++)
-      level.name[i]    = fgetc(file);
-    for(i=0;i<MAX_SC_ENTRIES;i++)
-      level.score[i]   = fgetc(file);
-    for(i=0;i<4;i++)
-      for(y=0;y<3;y++)
-       for(x=0;x<3;x++)
-         level.mampfer_inhalt[i][x][y] = fgetc(file);
-    level.tempo_amoebe = fgetc(file);
-    level.dauer_sieb   = fgetc(file);
-    level.dauer_ablenk = fgetc(file);
-
-    for(i=0;i<19;i++)  /* Rest reserviert / Headergröße 80 Bytes */
-      fgetc(file);
-
-    for(y=0;y<lev_fieldy;y++) 
-      for(x=0;x<lev_fieldx;x++) 
-       Feld[x][y] = Ur[x][y] = fgetc(file);
-
-    fclose(file);
-
-    if (level.time<=10)        /* Mindestspieldauer */
-      level.time = 10;
-  }
-  else
-  {
-    lev_fieldx = level.fieldx = STD_LEV_FIELDX;
-    lev_fieldy = level.fieldy = STD_LEV_FIELDY;
-
-    level.time         = 100;
-    level.edelsteine   = 0;
-    strncpy(level.name,"Nameless Level",MAX_LEVNAMLEN-1);
-    for(i=0;i<MAX_SC_ENTRIES;i++)
-      level.score[i]   = 10;
-    for(i=0;i<4;i++)
-      for(y=0;y<3;y++)
-       for(x=0;x<3;x++)
-         level.mampfer_inhalt[i][x][y] = EL_FELSBROCKEN;
-    level.tempo_amoebe = 10;
-    level.dauer_sieb   = 10;
-    level.dauer_ablenk = 10;
-
-    for(y=0;y<STD_LEV_FIELDY;y++) 
-      for(x=0;x<STD_LEV_FIELDX;x++) 
-       Feld[x][y] = Ur[x][y] = EL_ERDREICH;
-    Feld[0][0] = Ur[0][0] = EL_SPIELFIGUR;
-    Feld[STD_LEV_FIELDX-1][STD_LEV_FIELDY-1] =
-      Ur[STD_LEV_FIELDX-1][STD_LEV_FIELDY-1] = EL_AUSGANG_ZU;
-  }
-}
-
-void LoadLevelTape(int level_nr)
-{
-  int i;
-  char filename[MAX_FILENAME];
-  char cookie[MAX_FILENAME];
-  FILE *file;
-
-  sprintf(filename,"%s/%s/%d.tape",
-         LEVEL_PATH,leveldir[leveldir_nr].filename,level_nr);
-
-  if ((file=fopen(filename,"r")))
-  {
-    fgets(cookie,LEVELREC_COOKIE_LEN,file);
-    fgetc(file);
-    if (strcmp(cookie,LEVELREC_COOKIE))        /* ungültiges Format? */
-    {
-      fprintf(stderr,"%s: wrong format of level recording file '%s'!\n",
-             progname,filename);
-      fclose(file);
-      file = NULL;
-    }
-  }
-
-  if (!file)
-    return;
-
-  tape.random_seed =
-    (fgetc(file)<<24) | (fgetc(file)<<16) | (fgetc(file)<<8) | fgetc(file);
-  tape.date =
-    (fgetc(file)<<24) | (fgetc(file)<<16) | (fgetc(file)<<8) | fgetc(file);
-  tape.length =
-    (fgetc(file)<<24) | (fgetc(file)<<16) | (fgetc(file)<<8) | fgetc(file);
-
-  tape.level_nr = level_nr;
-  tape.counter = 0;
-  tape.recording = FALSE;
-  tape.playing = FALSE;
-  tape.pausing = FALSE;
-
-  for(i=0;i<tape.length;i++)
-  {
-    if (i>=MAX_TAPELEN)
-      break;
-    tape.pos[i].joystickdata = fgetc(file);
-    tape.pos[i].delay        = fgetc(file);
-    if (feof(file))
-      break;
-  }
-
-  if (i != tape.length)
-    fprintf(stderr,"%s: level recording file '%s' corrupted!\n",
-           progname,filename);
-
-  fclose(file);
-
-  master_tape = tape;
-}
-
-void LoadScore(int level_nr)
-{
-  int i,j;
-  char filename[MAX_FILENAME];
-  char cookie[MAX_FILENAME];
-  FILE *file;
-
-  sprintf(filename,"%s/%s/%s",
-         SCORE_PATH,leveldir[leveldir_nr].filename,SCORE_FILENAME);
-
-  if (!(file=fopen(filename,"r")))
-  {
-    if (!CreateNewScoreFile())
-    {
-      fprintf(stderr,"%s: cannot create score file '%s'!\n",
-             progname,filename);
-    }
-    else if (!(file=fopen(filename,"r"))) 
-    {
-      fprintf(stderr,"%s: cannot load score for level %d!\n",
-             progname,level_nr);
-    }
-  }
-
-  if (file)
-  {
-    fgets(cookie,SCORE_COOKIE_LEN,file);
-    if (strcmp(cookie,SCORE_COOKIE))   /* ungültiges Format? */
-    {
-      fprintf(stderr,"%s: wrong format of score file!\n",progname);
-      fclose(file);
-      file = NULL;
-    }
-  }
-
-  if (file)
-  {
-    fseek(file,
-         SCORE_COOKIE_LEN-1+level_nr*(MAX_SCORE_ENTRIES*(MAX_NAMELEN+2)),
-         SEEK_SET);
-    for(i=0;i<MAX_SCORE_ENTRIES;i++)
-    {
-      for(j=0;j<MAX_NAMELEN;j++)
-       highscore[i].Name[j] = fgetc(file);
-      highscore[i].Score = (fgetc(file)<<8) | fgetc(file);
-    }
-    fclose(file);
-  }
-  else
-  {
-    for(i=0;i<MAX_SCORE_ENTRIES;i++)
-    {
-      strcpy(highscore[i].Name,EMPTY_ALIAS);
-      highscore[i].Score = 0;
-    }
-  }
-}
-
-void LoadPlayerInfo(int mode)
-{
-  int i;
-  char filename[MAX_FILENAME];
-  char cookie[MAX_FILENAME];
-  FILE *file;
-  char *login_name = GetLoginName();
-  struct PlayerInfo default_player, new_player;
-
-  if (mode==PLAYER_LEVEL)
-    sprintf(filename,"%s/%s/%s",
-           NAMES_PATH,leveldir[leveldir_nr].filename,NAMES_FILENAME);
-  else
-    sprintf(filename,"%s/%s",CONFIG_PATH,NAMES_FILENAME);
-
-  for(i=0;i<MAX_NAMELEN;i++)
-    default_player.login_name[i] = default_player.alias_name[i] = 0;
-  strncpy(default_player.login_name,login_name,MAX_NAMELEN-1);
-  strncpy(default_player.alias_name,login_name,MAX_NAMELEN-1);
-  default_player.handicap = 0;
-  default_player.setup = DEFAULT_SETUP;
-  default_player.leveldir_nr = 0;
-
-  new_player = default_player;
-
-  if (!(file=fopen(filename,"r")))
-  {
-    if (!CreateNewNamesFile(mode))
-    {
-      fprintf(stderr,"%s: cannot create names file '%s'!\n",
-             progname,filename);
-    }
-    else if (!(file=fopen(filename,"r"))) 
-    {
-      fprintf(stderr,"%s: cannot load player information '%s'!\n",
-             progname,filename);
-    }
-  }
-
-  if (file)
-  {
-    fgets(cookie,NAMES_COOKIE_LEN,file);
-    if (strcmp(cookie,NAMES_COOKIE))   /* ungültiges Format? */
-    {
-      fprintf(stderr,"%s: wrong format of names file '%s'!\n",
-             progname,filename);
-      fclose(file);
-      file = NULL;
-    }
-  }
-
-  if (!file)
-  {
-    player = default_player;
-    level_nr = default_player.handicap;
-    return;
-  }
-
-  while(1)
-  {
-    for(i=0;i<MAX_NAMELEN;i++)
-      new_player.login_name[i] = fgetc(file);
-    for(i=0;i<MAX_NAMELEN;i++)
-      new_player.alias_name[i] = fgetc(file);
-    new_player.handicap = fgetc(file);
-    new_player.setup = (fgetc(file)<<8) | fgetc(file);
-    new_player.leveldir_nr = fgetc(file);
-
-    if (feof(file))            /* Spieler noch nicht in Liste enthalten */
-    {
-      new_player = default_player;
-
-      fclose(file);
-      if (!(file=fopen(filename,"a")))
-      {
-       fprintf(stderr,"%s: cannot append new player to names file '%s'!\n",
-               progname,filename);
-      }
-      else
-      {
-       for(i=0;i<MAX_NAMELEN;i++)
-         fputc(new_player.login_name[i],file);
-       for(i=0;i<MAX_NAMELEN;i++)
-         fputc(new_player.alias_name[i],file);
-       fputc(new_player.handicap,file);
-       fputc(new_player.setup / 256,file);
-       fputc(new_player.setup % 256,file);
-       fputc(new_player.leveldir_nr,file);
-      }
-      break;
-    }
-    else                       /* prüfen, ob Spieler in Liste enthalten */
-      if (!strncmp(new_player.login_name,login_name,MAX_NAMELEN-1))
-       break;
-  }
-
-  if (mode==PLAYER_SETUP)
-  {
-    player = new_player;
-    if (player.leveldir_nr < num_leveldirs)
-      leveldir_nr = player.leveldir_nr;
-    else
-      leveldir_nr = 0;
-  }
-  else
-    player.handicap = new_player.handicap;
-
-  level_nr = player.handicap;
-  fclose(file);
-}
-
-void SaveLevel(int level_nr)
-{
-  int i,x,y;
-  char filename[MAX_FILENAME];
-  FILE *file;
-
-  sprintf(filename,"%s/%s/%d",
-         LEVEL_PATH,leveldir[leveldir_nr].filename,level_nr);
-
-  if (!(file=fopen(filename,"w")))
-  {
-    fprintf(stderr,"%s: cannot save level file '%s'!\n",progname,filename);
-    return;
-  }
-
-  fputs(LEVEL_COOKIE,file);            /* Formatkennung */
-  fputc(0x0a,file);
-
-  fputc(level.fieldx,file);
-  fputc(level.fieldy,file);
-  fputc(level.time / 256,file);
-  fputc(level.time % 256,file);
-  fputc(level.edelsteine / 256,file);
-  fputc(level.edelsteine % 256,file);
-
-  for(i=0;i<MAX_LEVNAMLEN;i++)
-    fputc(level.name[i],file);
-  for(i=0;i<MAX_SC_ENTRIES;i++)
-    fputc(level.score[i],file);
-  for(i=0;i<4;i++)
-    for(y=0;y<3;y++)
-      for(x=0;x<3;x++)
-       fputc(level.mampfer_inhalt[i][x][y],file);
-  fputc(level.tempo_amoebe,file);
-  fputc(level.dauer_sieb,file);
-  fputc(level.dauer_ablenk,file);
-
-  for(i=0;i<19;i++)    /* Rest reserviert / Headergröße 80 Bytes */
-    fputc(0,file);
-
-  for(y=0;y<lev_fieldy;y++) 
-    for(x=0;x<lev_fieldx;x++) 
-      fputc(Ur[x][y],file);
-
-  fclose(file);
-
-  chmod(filename, LEVEL_PERMS);
-}
-
-void SaveLevelTape(int level_nr)
-{
-  int i;
-  char filename[MAX_FILENAME];
-  FILE *file;
-  BOOL new_tape = TRUE;
-
-  sprintf(filename,"%s/%s/%d.tape",
-         LEVEL_PATH,leveldir[leveldir_nr].filename,level_nr);
-
-  /* Testen, ob bereits eine Aufnahme existiert */
-  if ((file=fopen(filename,"r")))
-  {
-    new_tape = FALSE;
-    fclose(file);
-
-    if (!AreYouSure("Replace old tape ?",AYS_ASK))
-      return;
-  }
-
-  if (!(file=fopen(filename,"w")))
-  {
-    fprintf(stderr,"%s: cannot save level recording file '%s'!\n",
-           progname,filename);
-    return;
-  }
-
-  fputs(LEVELREC_COOKIE,file);         /* Formatkennung */
-  fputc(0x0a,file);
-
-  tape = master_tape;
-
-  fputc((tape.random_seed >> 24) & 0xff,file);
-  fputc((tape.random_seed >> 16) & 0xff,file);
-  fputc((tape.random_seed >>  8) & 0xff,file);
-  fputc((tape.random_seed >>  0) & 0xff,file);
-
-  fputc((tape.date >>  24) & 0xff,file);
-  fputc((tape.date >>  16) & 0xff,file);
-  fputc((tape.date >>   8) & 0xff,file);
-  fputc((tape.date >>   0) & 0xff,file);
-
-  fputc((tape.length >>  24) & 0xff,file);
-  fputc((tape.length >>  16) & 0xff,file);
-  fputc((tape.length >>   8) & 0xff,file);
-  fputc((tape.length >>   0) & 0xff,file);
-
-  for(i=0;i<tape.length;i++)
-  {
-    fputc(tape.pos[i].joystickdata,file);
-    fputc(tape.pos[i].delay,file);
-  }
-
-  fclose(file);
-
-  chmod(filename, LEVREC_PERMS);
-
-  if (new_tape)
-    AreYouSure("tape saved !",AYS_CONFIRM);
-}
-
-void SaveScore(int level_nr)
-{
-  int i,j;
-  char filename[MAX_FILENAME];
-  FILE *file;
-
-  sprintf(filename,"%s/%s/%s",
-         SCORE_PATH,leveldir[leveldir_nr].filename,SCORE_FILENAME);
-
-  if (!(file=fopen(filename,"r+")))
-  {
-    fprintf(stderr,"%s: cannot save score for level %d!\n",
-           progname,level_nr);
-    return;
-  }
-
-  fseek(file,
-       SCORE_COOKIE_LEN-1+level_nr*(MAX_SCORE_ENTRIES*(MAX_NAMELEN+2)),
-       SEEK_SET);
-  for(i=0;i<MAX_SCORE_ENTRIES;i++)
-  {
-    for(j=0;j<MAX_NAMELEN;j++)
-      fputc(highscore[i].Name[j],file);
-    fputc(highscore[i].Score / 256,file);
-    fputc(highscore[i].Score % 256,file);
-  }
-  fclose(file);
-}
-
-void SavePlayerInfo(int mode)
-{
-  int i;
-  char filename[MAX_FILENAME];
-  char cookie[MAX_FILENAME];
-  FILE *file;
-  struct PlayerInfo default_player;
-
-  if (mode==PLAYER_LEVEL)
-    sprintf(filename,"%s/%s/%s",
-           NAMES_PATH,leveldir[leveldir_nr].filename,NAMES_FILENAME);
-  else
-    sprintf(filename,"%s/%s",CONFIG_PATH,NAMES_FILENAME);
-
-  if (!(file=fopen(filename,"r+")))
-  {
-    fprintf(stderr,"%s: cannot save player information '%s'!\n",
-           progname,filename);
-    return;
-  }
-
-  fgets(cookie,NAMES_COOKIE_LEN,file);
-  if (strcmp(cookie,NAMES_COOKIE))     /* ungültiges Format? */
-  {
-    fprintf(stderr,"%s: wrong format of names file '%s'!\n",
-           progname,filename);
-    fclose(file);
-    return;
-  }
-
-  while(1)
-  {
-    for(i=0;i<MAX_NAMELEN;i++)
-      default_player.login_name[i] = fgetc(file);
-    for(i=0;i<MAX_NAMELEN;i++)
-      default_player.alias_name[i] = fgetc(file);
-    default_player.handicap = fgetc(file);
-    default_player.setup = (fgetc(file)<<8) | fgetc(file);
-    default_player.leveldir_nr = fgetc(file);
-
-    if (feof(file))            /* Spieler noch nicht in Liste enthalten */
-      break;
-    else                       /* prüfen, ob Spieler in Liste enthalten */
-      if (!strncmp(default_player.login_name,player.login_name,MAX_NAMELEN-1))
-      {
-       fseek(file,-(2*MAX_NAMELEN+1+2+1),SEEK_CUR);
-       break;
-      }
-  }
-
-  for(i=0;i<MAX_NAMELEN;i++)
-    fputc(player.login_name[i],file);
-  for(i=0;i<MAX_NAMELEN;i++)
-    fputc(player.alias_name[i],file);
-  fputc(player.handicap,file);
-  fputc(player.setup / 256,file);
-  fputc(player.setup % 256,file);
-  fputc(player.leveldir_nr,file);
-
-  fclose(file);
-}
+#include "buttons.h"
+#include "files.h"
 
 void GetPlayerConfig()
 {
@@ -655,6 +41,7 @@ void GetPlayerConfig()
   fading_on = SETUP_FADING_ON(player.setup);
   autorecord_on = SETUP_RECORD_EACH_GAME_ON(player.setup);
   joystick_nr = SETUP_2ND_JOYSTICK_ON(player.setup);
+  quick_doors = SETUP_QUICK_DOORS_ON(player.setup);
 
   if (joystick_nr != old_joystick_nr)
   {
@@ -666,7 +53,7 @@ void GetPlayerConfig()
 
 void InitGame()
 {
-  int x,y;
+  int i,x,y;
 
   Dynamite = Score = 0;
   Gems = level.edelsteine;
@@ -687,11 +74,14 @@ void InitGame()
   DigField(0,0,DF_NO_PUSH);
   SnapField(0,0);
 
+  for(i=0;i<MAX_NUM_AMOEBA;i++)
+    AmoebaCnt[i] = 0;
+
   for(y=0;y<lev_fieldy;y++) for(x=0;x<lev_fieldx;x++)
   {
-    Feld[x][y]=Ur[x][y];
-    MovPos[x][y]=MovDir[x][y]=MovDelay[x][y]=0;
-    Store[x][y]=Store2[x][y]=Frame[x][y]=0;
+    Feld[x][y] = Ur[x][y];
+    MovPos[x][y] = MovDir[x][y] = MovDelay[x][y] = 0;
+    Store[x][y] = Store2[x][y] = Frame[x][y] = AmoebaNr[x][y] = 0;
 
     switch(Feld[x][y])
     {
@@ -735,6 +125,16 @@ void InitGame()
       case EL_PACMAN:
        InitMovDir(x,y);
        break;
+      case EL_AMOEBE_VOLL:
+       InitAmoebaNr(x,y);
+       break;
+      case EL_TROPFEN:
+       if (y==lev_fieldy-1)
+       {
+         Feld[x][y] = EL_AMOEBING;
+         Store[x][y] = EL_AMOEBE_NASS;
+       }
+       break;
       default:
        break;
     }
@@ -860,6 +260,27 @@ void InitMovDir(int x, int y)
   }
 }
 
+void InitAmoebaNr(int x, int y)
+{
+  int i;
+  int group_nr = AmoebeNachbarNr(x,y);
+
+  if (group_nr==0)
+  {
+    for(i=1;i<MAX_NUM_AMOEBA;i++)
+    {
+      if (AmoebaCnt[i]==0)
+      {
+       group_nr = i;
+       break;
+      }
+    }
+  }
+
+  AmoebaNr[x][y] = group_nr;
+  AmoebaCnt[group_nr]++;
+}
+
 void GameWon()
 {
   int hi_pos;
@@ -958,13 +379,14 @@ BOOL NewHiScore()
       position = k;
       break;
     }
-  }
 
 #ifdef ONE_PER_NAME
-  else if (!strcmp(player.alias_name,highscore[k].Name))
-    break;     /* Spieler schon mit besserer Punktzahl in der Liste */
+    else if (!strcmp(player.alias_name,highscore[k].Name))
+      break;   /* Spieler schon mit besserer Punktzahl in der Liste */
 #endif
 
+  }
+
   if (position>=0) 
     SaveScore(level_nr);
 
@@ -1123,6 +545,9 @@ void Explode(int ex, int ey, int phase)
       if (!IN_LEV_FIELD(x,y) || IS_MASSIV(element))
        continue;
 
+      if (center_element==EL_AMOEBA2DIAM && (x!=ex || y!=ey))
+       continue;
+
       if (element==EL_EXPLODING)
        element = Store2[x][y];
 
@@ -1130,19 +555,25 @@ void Explode(int ex, int ey, int phase)
        Store[x][y] = ((x==ex && y==ey) ? EL_DIAMANT : EL_EDELSTEIN);
       else if (center_element==EL_MAMPFER)
        Store[x][y] = level.mampfer_inhalt[MampferNr][x-ex+1][y-ey+1];
-      else if (Feld[x][y]==EL_ERZ_1)
+      else if (center_element==EL_AMOEBA2DIAM)
+       Store[x][y] = level.amoebe_inhalt;
+      else if (element==EL_ERZ_EDEL)
        Store[x][y] = EL_EDELSTEIN;
-      else if (Feld[x][y]==EL_ERZ_2)
+      else if (element==EL_ERZ_DIAM)
        Store[x][y] = EL_DIAMANT;
       else if (!IS_PFORTE(Store[x][y]))
        Store[x][y] = EL_LEERRAUM;
 
-      if (x!=ex || y!=ey)
+      if (x!=ex || y!=ey || center_element==EL_AMOEBA2DIAM)
        Store2[x][y] = element;
 
+      if (AmoebaNr[x][y] && (element==EL_AMOEBE_VOLL || element==EL_AMOEBING))
+       AmoebaCnt[AmoebaNr[x][y]]--;
+
       RemoveMovingField(x,y);
       Feld[x][y] = EL_EXPLODING;
       MovDir[x][y] = MovPos[x][y] = 0;
+      AmoebaNr[x][y] = 0;
       Frame[x][y] = 1;
       Stop[x][y] = TRUE;
     }
@@ -1176,6 +607,8 @@ void Explode(int ex, int ey, int phase)
       Store2[x][y] = 0;
       Bang(x,y);
     }
+    else if (element==EL_AMOEBA2DIAM)
+      AmoebeUmwandeln(x,y);
   }
 
   if (phase==last_phase)
@@ -1307,7 +740,10 @@ void Impact(int x, int y)
     if (object_hit && PLAYER(x,y+1))
       KillHero();
     else
-      Feld[x][y] = EL_AMOEBING2;
+    {
+      Feld[x][y] = EL_AMOEBING;
+      Store[x][y] = EL_AMOEBE_NASS;
+    }
     return;
   }
 
@@ -1380,6 +816,10 @@ void Impact(int x, int y)
       case EL_SCHLUESSEL4:
        sound = SND_KINK;
        break;
+      case EL_ZEIT_VOLL:
+      case EL_ZEIT_LEER:
+       sound = SND_DENG;
+       break;
       default:
        sound = -1;
         break;
@@ -1623,9 +1063,10 @@ void StartMoving(int x, int y)
     }
     else if (element==EL_TROPFEN)
     {
-      Feld[x][y] = EL_AMOEBING2;
+      Feld[x][y] = EL_AMOEBING;
+      Store[x][y] = EL_AMOEBE_NASS;
     }
-    else if (SLIPPERY(Feld[x][y+1]) && !Store[x][y+1])
+    else if (IS_SLIPPERY(Feld[x][y+1]) && !Store[x][y+1])
     {
       int left  = (x>0 && IS_FREE(x-1,y) &&
                   (IS_FREE(x-1,y+1) || Feld[x-1][y+1]==EL_SALZSAEURE));
@@ -1701,12 +1142,20 @@ void StartMoving(int x, int y)
     else if (element==EL_MAMPFER && IN_LEV_FIELD(newx,newy) &&
             Feld[newx][newy]==EL_DIAMANT)
     {
-      Feld[newx][newy] = EL_LEERRAUM;
-      DrawLevelField(newx,newy);
+      if (IS_MOVING(newx,newy))
+       RemoveMovingField(newx,newy);
+      else
+      {
+       Feld[newx][newy] = EL_LEERRAUM;
+       DrawLevelField(newx,newy);
+      }
     }
     else if (element==EL_PACMAN && IN_LEV_FIELD(newx,newy) &&
             IS_AMOEBOID(Feld[newx][newy]))
     {
+      if (AmoebaNr[newx][newy] && Feld[newx][newy]==EL_AMOEBE_VOLL)
+       AmoebaCnt[AmoebaNr[newx][newy]]--;
+
       Feld[newx][newy] = EL_LEERRAUM;
       DrawLevelField(newx,newy);
     }
@@ -1782,10 +1231,10 @@ void ContinueMoving(int x, int y)
       Feld[newx][newy] = EL_SALZSAEURE;
       element = EL_SALZSAEURE;
     }
-    else if (Store[x][y]==EL_AMOEBE2)
+    else if (Store[x][y]==EL_AMOEBE_NASS)
     {
       Store[x][y] = 0;
-      Feld[x][y] = EL_AMOEBE2;
+      Feld[x][y] = EL_AMOEBE_NASS;
     }
 
     MovPos[x][y] = MovDir[x][y] = 0;
@@ -1816,6 +1265,112 @@ void ContinueMoving(int x, int y)
   }
 }
 
+int AmoebeNachbarNr(int ax, int ay)
+{
+  int i;
+  int element = Feld[ax][ay];
+  int group_nr = 0;
+  static int xy[4][2] =
+  {
+    0,-1,
+    -1,0,
+    +1,0,
+    0,+1
+  };
+
+  for(i=0;i<4;i++)
+  {
+    int x = ax+xy[i%4][0];
+    int y = ay+xy[i%4][1];
+
+    if (!IN_LEV_FIELD(x,y))
+      continue;
+
+    if (Feld[x][y]==element && AmoebaNr[x][y]>0)
+      group_nr = AmoebaNr[x][y];
+  }
+
+  return(group_nr);
+}
+
+void AmoebenVereinigen(int ax, int ay)
+{
+  int i,x,y,xx,yy;
+  int new_group_nr = AmoebaNr[ax][ay];
+  static int xy[4][2] =
+  {
+    0,-1,
+    -1,0,
+    +1,0,
+    0,+1
+  };
+
+  if (!new_group_nr)
+    return;
+
+  for(i=0;i<4;i++)
+  {
+    x = ax+xy[i%4][0];
+    y = ay+xy[i%4][1];
+
+    if (!IN_LEV_FIELD(x,y))
+      continue;
+
+    if ((Feld[x][y]==EL_AMOEBE_VOLL || Feld[x][y]==EL_AMOEBE_TOT) &&
+       AmoebaNr[x][y] != new_group_nr)
+    {
+      int old_group_nr = AmoebaNr[x][y];
+
+      AmoebaCnt[new_group_nr] += AmoebaCnt[old_group_nr];
+      AmoebaCnt[old_group_nr] = 0;
+
+      for(yy=0;yy<lev_fieldy;yy++) for(xx=0;xx<lev_fieldx;xx++)
+       if (AmoebaNr[xx][yy]==old_group_nr)
+         AmoebaNr[xx][yy] = new_group_nr;
+    }
+  }
+}
+
+void AmoebeUmwandeln(int ax, int ay)
+{
+  int i,x,y;
+  int group_nr = AmoebaNr[ax][ay];
+  static int xy[4][2] =
+  {
+    0,-1,
+    -1,0,
+    +1,0,
+    0,+1
+  };
+
+  if (Feld[ax][ay]==EL_AMOEBE_TOT)
+  {
+    for(y=0;y<lev_fieldy;y++) for(x=0;x<lev_fieldx;x++)
+    {
+      if (Feld[x][y]==EL_AMOEBE_TOT && AmoebaNr[x][y]==group_nr)
+      {
+       AmoebaNr[x][y] = 0;
+       Feld[x][y] = EL_AMOEBA2DIAM;
+      }
+    }
+    Bang(ax,ay);
+  }
+  else
+  {
+    for(i=0;i<4;i++)
+    {
+      x = ax+xy[i%4][0];
+      y = ay+xy[i%4][1];
+
+      if (!IN_LEV_FIELD(x,y))
+       continue;
+
+      if (Feld[x][y]==EL_AMOEBA2DIAM)
+       Bang(x,y);
+    }
+  }
+}
+
 void AmoebeWaechst(int x, int y)
 {
   static long sound_delay = 0;
@@ -1842,7 +1397,8 @@ void AmoebeWaechst(int x, int y)
 
     if (!MovDelay[x][y])
     {
-      Feld[x][y] = (Feld[x][y]==EL_AMOEBING2 ? EL_AMOEBE2 : EL_AMOEBE3);
+      Feld[x][y] = Store[x][y];
+      Store[x][y] = 0;
       DrawLevelField(x,y);
     }
   }
@@ -1850,9 +1406,9 @@ void AmoebeWaechst(int x, int y)
 
 void AmoebeAbleger(int ax, int ay)
 {
-  int i,j,start;
+  int i;
+  int element = Feld[ax][ay];
   int newax = ax, neway = ay;
-  BOOL waiting_for_player = FALSE;
   static int xy[4][2] =
   {
     0,-1,
@@ -1865,7 +1421,7 @@ void AmoebeAbleger(int ax, int ay)
 
   if (!level.tempo_amoebe)
   {
-    Feld[ax][ay] = EL_AMOEBE1;
+    Feld[ax][ay] = EL_AMOEBE_TOT;
     DrawLevelField(ax,ay);
     return;
   }
@@ -1880,24 +1436,44 @@ void AmoebeAbleger(int ax, int ay)
       return;
   }
 
-  if (Feld[ax][ay]==EL_AMOEBE3)
+  if (element==EL_AMOEBE_NASS) /* tropfende Amöbe */
+  {
+    int start = RND(4);
+    int x = ax+xy[start][0];
+    int y = ay+xy[start][1];
+
+    if (!IN_LEV_FIELD(x,y))
+      return;
+
+    if (IS_FREE(x,y) ||
+       Feld[x][y]==EL_ERDREICH || Feld[x][y]==EL_MORAST_LEER)
+    {
+      newax = x;
+      neway = y;
+    }
+
+    if (newax==ax && neway==ay)
+      return;
+  }
+  else                         /* normale oder "gefüllte" Amöbe */
   {
-    start = RND(4);
+    int start = RND(4);
+    BOOL waiting_for_player = FALSE;
+
     for(i=0;i<4;i++)
     {
-      int x,y;
+      int j = (start+i)%4;
+      int x = ax+xy[j][0];
+      int y = ay+xy[j][1];
 
-      j = (start+i)%4;
-      x = ax+xy[j][0];
-      y = ay+xy[j][1];
       if (!IN_LEV_FIELD(x,y))
        continue;
 
       if (IS_FREE(x,y) ||
          Feld[x][y]==EL_ERDREICH || Feld[x][y]==EL_MORAST_LEER)
       {
-       newax=x;
-       neway=y;
+       newax = x;
+       neway = y;
        break;
       }
       else if (PLAYER(x,y))
@@ -1906,46 +1482,39 @@ void AmoebeAbleger(int ax, int ay)
 
     if (newax==ax && neway==ay)
     {
-      if (Feld[ax][ay]==EL_AMOEBE3 && i==4 && !waiting_for_player)
+      if (i==4 && !waiting_for_player)
       {
-       Feld[ax][ay] = EL_AMOEBE1;
+       Feld[ax][ay] = EL_AMOEBE_TOT;
        DrawLevelField(ax,ay);
+
+       if (element==EL_AMOEBE_VOLL && --AmoebaCnt[AmoebaNr[ax][ay]]<=0)
+         AmoebeUmwandeln(ax,ay);
       }
       return;
     }
-  }
-  else
-  {
-    int x,y;
-
-    start = RND(4);
-    x = ax+xy[start][0];
-    y = ay+xy[start][1];
-    if (!IN_LEV_FIELD(x,y))
-      return;
-
-    if (IS_FREE(x,y) ||
-         Feld[x][y]==EL_ERDREICH || Feld[x][y]==EL_MORAST_LEER)
+    else if (element==EL_AMOEBE_VOLL)
     {
-      newax=x;
-      neway=y;
-    }
+      int new_group_nr = AmoebaNr[ax][ay];
 
-    if (newax==ax && neway==ay)
-      return;
+      AmoebaNr[newax][neway] = new_group_nr;
+      AmoebaCnt[new_group_nr]++;
+      AmoebenVereinigen(newax,neway);
+    }
   }
 
-  if (Feld[ax][ay]==EL_AMOEBE3)
-    Feld[newax][neway] = EL_AMOEBING3;
-  else if (neway==lev_fieldy-1)
-    Feld[newax][neway] = EL_AMOEBING2;
-  else if (neway<=ay || !IS_FREE(newax,neway))
+  if (element!=EL_AMOEBE_NASS || neway<ay || !IS_FREE(newax,neway) ||
+      (neway==lev_fieldy-1 && newax!=ax))
+  {
+    Feld[newax][neway] = EL_AMOEBING;
+    Store[newax][neway] = element;
+  }
+  else if (neway==ay)
     Feld[newax][neway] = EL_TROPFEN;
   else
   {
     InitMovingField(ax,ay,MV_DOWN);
-    Feld[ax][ay]=EL_TROPFEN;
-    Store[ax][ay]=EL_AMOEBE2;
+    Feld[ax][ay] = EL_TROPFEN;
+    Store[ax][ay] = EL_AMOEBE_NASS;
     ContinueMoving(ax,ay);
     return;
   }
@@ -1990,7 +1559,8 @@ void Life(int ax, int ay)
       if (!IN_LEV_FIELD(x,y) || (x==xx && y==yy))
        continue;
 
-      if ((Feld[x][y]==element && !Stop[x][y]) ||
+      if (((Feld[x][y]==element || (element==EL_LIFE && PLAYER(x,y))) &&
+          !Stop[x][y]) ||
          (IS_FREE(x,y) && Stop[x][y]))
        nachbarn++;
     }
@@ -2224,9 +1794,9 @@ int GameActions(int mx, int my, int button)
        CheckDynamite(x,y);
       else if (element==EL_EXPLODING)
        Explode(x,y,Frame[x][y]);
-      else if (element==EL_AMOEBING2 || element==EL_AMOEBING3)
+      else if (element==EL_AMOEBING)
        AmoebeWaechst(x,y);
-      else if (element==EL_AMOEBE2 || element==EL_AMOEBE3)
+      else if (IS_AMOEBALIVE(element))
        AmoebeAbleger(x,y);
       else if (element==EL_LIFE || element==EL_LIFE_ASYNC)
        Life(x,y);
@@ -2286,7 +1856,7 @@ void ScrollLevel(int dx, int dy)
 
 BOOL MoveFigureOneStep(int dx, int dy)
 {
-  int oldJX,oldJY, newJX=JX+dx,newJY=JY+dy;
+  int oldJX,oldJY, newJX = JX+dx,newJY = JY+dy;
   int element;
   int can_move;
 
@@ -2309,8 +1879,8 @@ BOOL MoveFigureOneStep(int dx, int dy)
 
       PlaySoundLevel(JX,JY,SND_AUTSCH);
       PlaySoundLevel(JX,JY,SND_LACHEN);
-      GameOver=TRUE;
-      JX=JY=-1;
+      GameOver = TRUE;
+      JX = JY = -1;
     }
     else
       KillHero();
@@ -2459,7 +2029,7 @@ void TestIfBadThingHitsOtherBadThing(int badx, int bady)
 
     element=Feld[x][y];
     if (IS_AMOEBOID(element) || element==EL_LIFE ||
-       element==EL_AMOEBING2 || element==EL_AMOEBING3 || element==EL_TROPFEN)
+       element==EL_AMOEBING || element==EL_TROPFEN)
     {
       killx=x;
       killy=y;
@@ -2561,19 +2131,17 @@ int DigField(int x, int y, int mode)
       break;
     }
     case EL_ABLENK_AUS:
-      Feld[x][y]=EL_ABLENK_EIN;
+      Feld[x][y] = EL_ABLENK_EIN;
       CheckExploding=TRUE;
       ZX=x;
       ZY=y;
       DrawLevelField(x,y);
-/*
-      PlaySoundLevel(x,y,SND_DENG);
-*/
       return(MF_ACTION);
       break;
     case EL_FELSBROCKEN:
     case EL_BOMBE:
     case EL_KOKOSNUSS:
+    case EL_ZEIT_LEER:
       if (mode==DF_SNAP)
        return(MF_NO_ACTION);
       if (dy || !IN_LEV_FIELD(x+dx,y+dy) || Feld[x+dx][y+dy]!=EL_LEERRAUM)
@@ -2618,9 +2186,21 @@ int DigField(int x, int y, int mode)
     case EL_AUSGANG_AUF:
       if (mode==DF_SNAP || Gems>0)
        return(MF_NO_ACTION);
-      LevelSolved = TRUE;
+      LevelSolved = GameOver = TRUE;
       PlaySoundLevel(x,y,SND_BUING);
       break;
+    case EL_BIRNE_AUS:
+      Feld[x][y] = EL_BIRNE_EIN;
+      DrawLevelField(x,y);
+      PlaySoundLevel(x,y,SND_DENG);
+      return(MF_ACTION);
+      break;
+    case EL_ZEIT_VOLL:
+      Feld[x][y] = EL_ZEIT_LEER;
+      DrawLevelField(x,y);
+      PlaySoundStereo(SND_GONG,PSND_MAX_RIGHT);
+      return(MF_ACTION);
+      break;
     default:
       return(MF_NO_ACTION);
       break;
@@ -2897,202 +2477,3 @@ void TapeErase()
 {
   tape.length = 0;
 }
-
-void DrawVideoDisplay(unsigned long state, unsigned long value)
-{
-  int i;
-  int part1 = 0, part2 = 1;
-  int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
-  static char *monatsname[12] =
-  {
-    "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
-    "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
-  };
-  static int video_pos[10][2][4] =
-  {
-    VIDEO_PLAY_LABEL_XPOS, VIDEO_PLAY_LABEL_YPOS,
-    VIDEO_PLAY_LABEL_XSIZE,VIDEO_PLAY_LABEL_YSIZE,
-    VIDEO_PLAY_SYMBOL_XPOS, VIDEO_PLAY_SYMBOL_YPOS,
-    VIDEO_PLAY_SYMBOL_XSIZE,VIDEO_PLAY_SYMBOL_YSIZE,
-
-    VIDEO_REC_LABEL_XPOS, VIDEO_REC_LABEL_YPOS,
-    VIDEO_REC_LABEL_XSIZE,VIDEO_REC_LABEL_YSIZE,
-    VIDEO_REC_SYMBOL_XPOS, VIDEO_REC_SYMBOL_YPOS,
-    VIDEO_REC_SYMBOL_XSIZE,VIDEO_REC_SYMBOL_YSIZE,
-
-    VIDEO_PAUSE_LABEL_XPOS, VIDEO_PAUSE_LABEL_YPOS,
-    VIDEO_PAUSE_LABEL_XSIZE,VIDEO_PAUSE_LABEL_YSIZE,
-    VIDEO_PAUSE_SYMBOL_XPOS, VIDEO_PAUSE_SYMBOL_YPOS,
-    VIDEO_PAUSE_SYMBOL_XSIZE,VIDEO_PAUSE_SYMBOL_YSIZE,
-
-    VIDEO_DATE_LABEL_XPOS, VIDEO_DATE_LABEL_YPOS,
-    VIDEO_DATE_LABEL_XSIZE,VIDEO_DATE_LABEL_YSIZE,
-    VIDEO_DATE_XPOS, VIDEO_DATE_YPOS,
-    VIDEO_DATE_XSIZE,VIDEO_DATE_YSIZE,
-
-    0,0,
-    0,0,
-    VIDEO_TIME_XPOS, VIDEO_TIME_YPOS,
-    VIDEO_TIME_XSIZE,VIDEO_TIME_YSIZE,
-
-    VIDEO_BUTTON_PLAY_XPOS, VIDEO_BUTTON_ANY_YPOS,
-    VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE,
-    0,0,
-    0,0,
-
-    VIDEO_BUTTON_REC_XPOS, VIDEO_BUTTON_ANY_YPOS,
-    VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE,
-    0,0,
-    0,0,
-
-    VIDEO_BUTTON_PAUSE_XPOS, VIDEO_BUTTON_ANY_YPOS,
-    VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE,
-    0,0,
-    0,0,
-
-    VIDEO_BUTTON_STOP_XPOS, VIDEO_BUTTON_ANY_YPOS,
-    VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE,
-    0,0,
-    0,0,
-
-    VIDEO_BUTTON_EJECT_XPOS, VIDEO_BUTTON_ANY_YPOS,
-    VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE,
-    0,0,
-    0,0
-  };
-
-  for(i=0;i<20;i++)
-  {
-    if (state & (1<<i))
-    {
-      int pos = i/2, cx, cy = DOOR_GFX_PAGEY2;
-
-      if (i%2)                 /* i ungerade => STATE_ON / PRESS_OFF */
-       cx = DOOR_GFX_PAGEX4;
-      else
-       cx = DOOR_GFX_PAGEX3;   /* i gerade => STATE_OFF / PRESS_ON */
-
-      if (video_pos[pos][part1][0])
-       XCopyArea(display,pix[PIX_DOOR],drawto,gc,
-                 cx + video_pos[pos][part1][xpos],
-                 cy + video_pos[pos][part1][ypos],
-                 video_pos[pos][part1][xsize],
-                 video_pos[pos][part1][ysize],
-                 VX + video_pos[pos][part1][xpos],
-                 VY + video_pos[pos][part1][ypos]);
-      if (video_pos[pos][part2][0])
-       XCopyArea(display,pix[PIX_DOOR],drawto,gc,
-                 cx + video_pos[pos][part2][xpos],
-                 cy + video_pos[pos][part2][ypos],
-                 video_pos[pos][part2][xsize],
-                 video_pos[pos][part2][ysize],
-                 VX + video_pos[pos][part2][xpos],
-                 VY + video_pos[pos][part2][ypos]);
-    }
-  }
-
-  if (state & VIDEO_STATE_DATE_ON)
-  {
-    int tag = value % 100;
-    int monat = (value/100) % 100;
-    int jahr = (value/10000);
-
-    DrawText(VX+VIDEO_DATE_XPOS,VY+VIDEO_DATE_YPOS,
-            int2str(tag,2),FS_SMALL,FC_SPECIAL1);
-    DrawText(VX+VIDEO_DATE_XPOS+27,VY+VIDEO_DATE_YPOS,
-            monatsname[monat],FS_SMALL,FC_SPECIAL1);
-    DrawText(VX+VIDEO_DATE_XPOS+64,VY+VIDEO_DATE_YPOS,
-            int2str(jahr,2),FS_SMALL,FC_SPECIAL1);
-  }
-
-  if (state & VIDEO_STATE_TIME_ON)
-  {
-    int min = value / 60;
-    int sec = value % 60;
-
-    DrawText(VX+VIDEO_TIME_XPOS,VY+VIDEO_TIME_YPOS,
-            int2str(min,2),FS_SMALL,FC_SPECIAL1);
-    DrawText(VX+VIDEO_TIME_XPOS+27,VY+VIDEO_TIME_YPOS,
-            int2str(sec,2),FS_SMALL,FC_SPECIAL1);
-  }
-
-  if (state & VIDEO_STATE_DATE)
-    redraw_mask |= REDRAW_VIDEO_1;
-  if ((state & ~VIDEO_STATE_DATE) & VIDEO_STATE)
-    redraw_mask |= REDRAW_VIDEO_2;
-  if (state & VIDEO_PRESS)
-    redraw_mask |= REDRAW_VIDEO_3;
-}
-
-void DrawSoundDisplay(unsigned long state)
-{
-  int pos, cx = DOOR_GFX_PAGEX4, cy = 0;
-
-  pos = (state & BUTTON_SOUND_MUSIC ? SOUND_BUTTON_MUSIC_XPOS :
-        state & BUTTON_SOUND_LOOPS ? SOUND_BUTTON_LOOPS_XPOS :
-        SOUND_BUTTON_SOUND_XPOS);
-
-  if (state & BUTTON_ON)
-    cy -= SOUND_BUTTON_YSIZE;
-
-  if (state & BUTTON_PRESSED)
-    cx = DOOR_GFX_PAGEX3;
-
-  XCopyArea(display,pix[PIX_DOOR],drawto,gc,
-           cx + pos,cy + SOUND_BUTTON_ANY_YPOS,
-           SOUND_BUTTON_XSIZE,SOUND_BUTTON_YSIZE,
-           DX + pos,DY + SOUND_BUTTON_ANY_YPOS);
-
-  redraw_mask |= REDRAW_DOOR_1;
-}
-
-void DrawGameButton(unsigned long state)
-{
-  int pos, cx = DOOR_GFX_PAGEX4, cy = -GAME_BUTTON_YSIZE;
-
-  pos = (state & BUTTON_GAME_STOP ? GAME_BUTTON_STOP_XPOS :
-        state & BUTTON_GAME_PAUSE ? GAME_BUTTON_PAUSE_XPOS :
-        GAME_BUTTON_PLAY_XPOS);
-
-  if (state & BUTTON_PRESSED)
-    cx = DOOR_GFX_PAGEX3;
-
-  XCopyArea(display,pix[PIX_DOOR],drawto,gc,
-           cx + pos,cy + GAME_BUTTON_ANY_YPOS,
-           GAME_BUTTON_XSIZE,GAME_BUTTON_YSIZE,
-           DX + pos,DY + GAME_BUTTON_ANY_YPOS);
-
-  redraw_mask |= REDRAW_DOOR_1;
-}
-
-void DrawChooseButton(unsigned long state)
-{
-  int pos, cx = DOOR_GFX_PAGEX4, cy = 0;
-
-  pos = (state & BUTTON_OK ? OK_BUTTON_XPOS : NO_BUTTON_XPOS);
-
-  if (state & BUTTON_PRESSED)
-    cx = DOOR_GFX_PAGEX3;
-
-  XCopyArea(display,pix[PIX_DOOR],drawto,gc,
-           cx + pos,cy + OK_BUTTON_GFX_YPOS,
-           OK_BUTTON_XSIZE,OK_BUTTON_YSIZE,
-           DX + pos,DY + OK_BUTTON_YPOS);
-
-  redraw_mask |= REDRAW_DOOR_1;
-}
-
-void DrawConfirmButton(unsigned long state)
-{
-  int cx = DOOR_GFX_PAGEX4, cy = 0;
-
-  if (state & BUTTON_PRESSED)
-    cx = DOOR_GFX_PAGEX3;
-
-  XCopyArea(display,pix[PIX_DOOR],drawto,gc,
-           cx + CONFIRM_BUTTON_XPOS,cy + CONFIRM_BUTTON_GFX_YPOS,
-           CONFIRM_BUTTON_XSIZE,CONFIRM_BUTTON_YSIZE,
-           DX + CONFIRM_BUTTON_XPOS,DY + CONFIRM_BUTTON_YPOS);
-
-  redraw_mask |= REDRAW_DOOR_1;
-}
index 422343d..e7150b6 100644 (file)
@@ -10,8 +10,6 @@
 *               q99492@pbhrzx.uni-paderborn.de             *
 *----------------------------------------------------------*
 *  game.h                                                  *
-*                                                          *
-*  Letzte Aenderung: 15.06.1995                            *
 ***********************************************************/
 
 #ifndef GAME_H
@@ -19,9 +17,6 @@
 
 #include "main.h"
 
-#define PLAYER_LEVEL   0
-#define PLAYER_SETUP   1
-
 #define DF_DIG         0
 #define DF_SNAP                1
 #define DF_NO_PUSH     2
 #define MF_MOVING      1
 #define MF_ACTION      2
 
-BOOL CreateNewScoreFile(void);
-BOOL CreateNewNamesFile(int);
-void LoadLevelInfo(void);
-void LoadLevel(int);
-void LoadLevelTape(int);
-void LoadScore(int);
-void LoadPlayerInfo(int);
-void SaveLevel(int);
-void SaveLevelTape(int);
-void SaveScore(int);
-void SavePlayerInfo(int);
 void GetPlayerConfig(void);
 void InitGame(void);
 void InitMovDir(int, int);
+void InitAmoebaNr(int, int);
 void GameWon(void);
 BOOL NewHiScore(void);
 void InitMovingField(int, int, int);
@@ -60,6 +45,8 @@ void Impact(int, int);
 void TurnRound(int, int);
 void StartMoving(int, int);
 void ContinueMoving(int, int);
+int AmoebeNachbarNr(int, int);
+void AmoebeUmwandeln(int, int);
 void AmoebeWaechst(int, int);
 void AmoebeAbleger(int, int);
 void Life(int, int);
@@ -94,10 +81,5 @@ int TapePlayAction(void);
 BOOL TapePlayDelay(void);
 void TapeStop(void);
 void TapeErase(void);
-void DrawVideoDisplay(unsigned long, unsigned long);
-void DrawSoundDisplay(unsigned long);
-void DrawGameButton(unsigned long);
-void DrawChooseButton(unsigned long);
-void DrawConfirmButton(unsigned long);
 
 #endif
diff --git a/src/images.c b/src/images.c
deleted file mode 100644 (file)
index 83c7ae9..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/***********************************************************
-*  Rocks'n'Diamonds -- McDuffin Strikes Back!              *
-*----------------------------------------------------------*
-*  ©1995 Artsoft Development                               *
-*        Holger Schemel                                    *
-*        33659 Bielefeld-Senne                             *
-*        Telefon: (0521) 493245                            *
-*        eMail: aeglos@valinor.owl.de                      *
-*               aeglos@uni-paderborn.de                    *
-*               q99492@pbhrzx.uni-paderborn.de             *
-*----------------------------------------------------------*
-*  images.c                                                *
-*                                                          *
-*  Letzte Aenderung: 15.06.1995                            *
-***********************************************************/
-
-#include "images.h"
-
-struct PictureFile icon_pic =
-{
-  "rocks_icon.xbm",
-  "rocks_iconmask.xbm"
-};
-
-struct PictureFile pic[NUM_PICTURES] =
-{
-  "RocksScreen.xpm",
-  "RocksScreenMaske.xbm",
-
-  "RocksDoor.xpm",
-  "RocksDoorMaske.xbm",
-
-  "RocksToons.xpm",
-  "RocksToonsMaske.xbm",
-
-  "RocksFont.xpm",
-  NULL,
-
-  "RocksFont2.xpm",
-  NULL
-}; 
diff --git a/src/images.h b/src/images.h
deleted file mode 100644 (file)
index 6a83841..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/***********************************************************
-*  Rocks'n'Diamonds -- McDuffin Strikes Back!              *
-*----------------------------------------------------------*
-*  ©1995 Artsoft Development                               *
-*        Holger Schemel                                    *
-*        33659 Bielefeld-Senne                             *
-*        Telefon: (0521) 493245                            *
-*        eMail: aeglos@valinor.owl.de                      *
-*               aeglos@uni-paderborn.de                    *
-*               q99492@pbhrzx.uni-paderborn.de             *
-*----------------------------------------------------------*
-*  images.h                                                *
-*                                                          *
-*  Letzte Aenderung: 15.06.1995                            *
-***********************************************************/
-
-#ifndef IMAGES_H
-#define IMAGES_H
-
-#include "main.h"
-
-extern struct PictureFile icon_pic;
-extern struct PictureFile pic[];
-
-#endif
index ec0a1c7..8032ffb 100644 (file)
 *               q99492@pbhrzx.uni-paderborn.de             *
 *----------------------------------------------------------*
 *  init.c                                                  *
-*                                                          *
-*  Letzte Aenderung: 15.06.1995                            *
 ***********************************************************/
 
 #include "init.h"
-#include "images.h"
+#include "misc.h"
 #include "sound.h"
 #include "screens.h"
-#include "tools.h"
-#include "game.h"
-#include "misc.h"
-
+#include "files.h"
 #include <signal.h>
 
-int sound_process_id=0;
+static int sound_process_id = 0;
 
 void OpenAll(int argc, char *argv[])
 {
-  LoadLevelInfo();
-  LoadPlayerInfo(PLAYER_SETUP);
-  LoadPlayerInfo(PLAYER_LEVEL);
+  InitLevelAndPlayerInfo();
 
   InitCounter();
   InitSound();
@@ -44,6 +37,7 @@ void OpenAll(int argc, char *argv[])
   InitDisplay(argc, argv);
   InitWindow(argc, argv);
   InitGfx();
+  InitElementProperties();
 
   DrawMainMenu();
 
@@ -51,6 +45,15 @@ void OpenAll(int argc, char *argv[])
   XFlush(display);
 }
 
+void InitLevelAndPlayerInfo()
+{
+  if (!LoadLevelInfo())                        /* global level info */
+    CloseAll();
+
+  LoadPlayerInfo(PLAYER_SETUP);                /* global setup info */
+  LoadPlayerInfo(PLAYER_LEVEL);                /* level specific info */
+}
+
 void InitSound()
 {
   int i;
@@ -124,7 +127,7 @@ void InitJoystick()
   if (access(joystick_device_name[joystick_nr],R_OK)<0)
   {
     fprintf(stderr,"%s: cannot access joystick device '%s'\n",
-           joystick_device_name[joystick_nr],progname);
+           progname,joystick_device_name[joystick_nr]);
     joystick_status = JOYSTICK_OFF;
     return;
   }
@@ -132,7 +135,7 @@ void InitJoystick()
   if ((joystick_device=open(joystick_device_name[joystick_nr],O_RDONLY))<0)
   {
     fprintf(stderr,"%s: cannot open joystick device '%s'\n",
-           joystick_device_name[joystick_nr],progname);
+           progname,joystick_device_name[joystick_nr]);
     joystick_status = JOYSTICK_OFF;
     return;
   }
@@ -191,6 +194,11 @@ void InitWindow(int argc, char *argv[])
   char *window_name = "Rocks'n'Diamonds";
   char *icon_name = "Rocks'n'Diamonds";
   long window_event_mask;
+  static struct PictureFile icon_pic =
+  {
+    "rocks_icon.xbm",
+    "rocks_iconmask.xbm"
+  };
 
   width = WIN_XSIZE;
   height = WIN_YSIZE;
@@ -282,6 +290,15 @@ void InitGfx()
   char filename[256];
   Pixmap shapemask;
 
+  static struct PictureFile pic[NUM_PICTURES] =
+  {
+    "RocksScreen.xpm",         "RocksScreenMaske.xbm",
+    "RocksDoor.xpm",           "RocksDoorMaske.xbm",
+    "RocksToons.xpm",          "RocksToonsMaske.xbm",
+    "RocksFont.xpm",           NULL,
+    "RocksFont2.xpm",          NULL
+  }; 
+
   for(i=0;i<NUM_PICTURES;i++)
   {
     if (pic[i].picture_filename)
@@ -416,6 +433,289 @@ void InitGfx()
   redraw_mask=REDRAW_ALL;
 }
 
+void InitElementProperties()
+{
+  int i,j;
+
+  static int ep_amoebalive[] =
+  {
+    EL_AMOEBE_NASS,
+    EL_AMOEBE_NORM,
+    EL_AMOEBE_VOLL
+  };
+  static int ep_amoebalive_num = sizeof(ep_amoebalive)/sizeof(int);
+
+  static int ep_amoeboid[] =
+  {
+    EL_AMOEBE_TOT,
+    EL_AMOEBE_NASS,
+    EL_AMOEBE_NORM,
+    EL_AMOEBE_VOLL
+  };
+  static int ep_amoeboid_num = sizeof(ep_amoeboid)/sizeof(int);
+
+  static int ep_badewannoid[] =
+  {
+    EL_BADEWANNE1,
+    EL_BADEWANNE2,
+    EL_BADEWANNE3,
+    EL_BADEWANNE4,
+    EL_BADEWANNE5
+  };
+  static int ep_badewannoid_num = sizeof(ep_badewannoid)/sizeof(int);
+
+  static int ep_schluessel[] =
+  {
+    EL_SCHLUESSEL1,
+    EL_SCHLUESSEL2,
+    EL_SCHLUESSEL3,
+    EL_SCHLUESSEL4
+  };
+  static int ep_schluessel_num = sizeof(ep_schluessel)/sizeof(int);
+
+  static int ep_pforte[] =
+  {
+    EL_PFORTE1,
+    EL_PFORTE2,
+    EL_PFORTE3,
+    EL_PFORTE4,
+    EL_PFORTE1X,
+    EL_PFORTE2X,
+    EL_PFORTE3X,
+    EL_PFORTE4X
+  };
+  static int ep_pforte_num = sizeof(ep_pforte)/sizeof(int);
+
+  static int ep_solid[] =
+  {
+    EL_BETON,
+    EL_MAUERWERK,
+    EL_FELSBODEN,
+    EL_AUSGANG_ZU,
+    EL_AUSGANG_ACT,
+    EL_AUSGANG_AUF,
+    EL_AMOEBE_TOT,
+    EL_AMOEBE_NASS,
+    EL_AMOEBE_NORM,
+    EL_AMOEBE_VOLL,
+    EL_MORAST_VOLL,
+    EL_MORAST_LEER,
+    EL_SIEB_VOLL,
+    EL_SIEB_LEER,
+    EL_LIFE,
+    EL_LIFE_ASYNC,
+    EL_BADEWANNE1,
+    EL_BADEWANNE2,
+    EL_BADEWANNE3,
+    EL_BADEWANNE4,
+    EL_BADEWANNE5
+  };
+  static int ep_solid_num = sizeof(ep_solid)/sizeof(int);
+
+  static int ep_massiv[] =
+  {
+    EL_BETON,
+    EL_SALZSAEURE,
+    EL_BADEWANNE1,
+    EL_BADEWANNE2,
+    EL_BADEWANNE3,
+    EL_BADEWANNE4,
+    EL_BADEWANNE5,
+    EL_PFORTE1,
+    EL_PFORTE2,
+    EL_PFORTE3,
+    EL_PFORTE4,
+    EL_PFORTE1X,
+    EL_PFORTE2X,
+    EL_PFORTE3X,
+    EL_PFORTE4X
+  };
+  static int ep_massiv_num = sizeof(ep_massiv)/sizeof(int);
+
+  static int ep_slippery[] =
+  {
+    EL_FELSBODEN,
+    EL_FELSBROCKEN,
+    EL_EDELSTEIN,
+    EL_DIAMANT,
+    EL_BOMBE,
+    EL_KOKOSNUSS,
+    EL_ABLENK_EIN,
+    EL_ABLENK_AUS,
+    EL_ZEIT_VOLL,
+    EL_ZEIT_LEER,
+    EL_BIRNE_EIN,
+    EL_BIRNE_AUS,
+    EL_BADEWANNE1,
+    EL_BADEWANNE2
+  };
+  static int ep_slippery_num = sizeof(ep_slippery)/sizeof(int);
+
+  static int ep_enemy[] =
+  {
+    EL_KAEFER,
+    EL_FLIEGER,
+    EL_MAMPFER,
+    EL_ZOMBIE,
+    EL_PACMAN
+  };
+  static int ep_enemy_num = sizeof(ep_enemy)/sizeof(int);
+
+  static int ep_can_fall[] =
+  {
+    EL_FELSBROCKEN,
+    EL_EDELSTEIN,
+    EL_DIAMANT,
+    EL_BOMBE,
+    EL_KOKOSNUSS,
+    EL_TROPFEN,
+    EL_MORAST_VOLL,
+    EL_SIEB_VOLL,
+    EL_ZEIT_VOLL,
+    EL_ZEIT_LEER
+  };
+  static int ep_can_fall_num = sizeof(ep_can_fall)/sizeof(int);
+
+  static int ep_can_smash[] =
+  {
+    EL_FELSBROCKEN,
+    EL_EDELSTEIN,
+    EL_DIAMANT,
+    EL_SCHLUESSEL1,
+    EL_SCHLUESSEL2,
+    EL_SCHLUESSEL3,
+    EL_SCHLUESSEL4,
+    EL_BOMBE,
+    EL_KOKOSNUSS,
+    EL_TROPFEN,
+    EL_ZEIT_VOLL,
+    EL_ZEIT_LEER
+  };
+  static int ep_can_smash_num = sizeof(ep_can_smash)/sizeof(int);
+
+  static int ep_can_change[] =
+  {
+    EL_FELSBROCKEN,
+    EL_EDELSTEIN,
+    EL_DIAMANT
+  };
+  static int ep_can_change_num = sizeof(ep_can_change)/sizeof(int);
+
+  static int ep_can_move[] =
+  {
+    EL_KAEFER,
+    EL_FLIEGER,
+    EL_MAMPFER,
+    EL_ZOMBIE,
+    EL_PACMAN
+  };
+  static int ep_can_move_num = sizeof(ep_can_move)/sizeof(int);
+
+  static int ep_could_move[] =
+  {
+    EL_KAEFER_R,
+    EL_KAEFER_O,
+    EL_KAEFER_L,
+    EL_KAEFER_U,
+    EL_FLIEGER_R,
+    EL_FLIEGER_O,
+    EL_FLIEGER_L,
+    EL_FLIEGER_U,
+    EL_PACMAN_R,
+    EL_PACMAN_O,
+    EL_PACMAN_L,
+    EL_PACMAN_U
+  };
+  static int ep_could_move_num = sizeof(ep_could_move)/sizeof(int);
+
+  static int ep_dont_touch[] =
+  {
+    EL_KAEFER,
+    EL_FLIEGER
+  };
+  static int ep_dont_touch_num = sizeof(ep_dont_touch)/sizeof(int);
+
+  static int ep_dont_go_to[] =
+  {
+    EL_KAEFER,
+    EL_FLIEGER,
+    EL_MAMPFER,
+    EL_ZOMBIE,
+    EL_PACMAN,
+    EL_TROPFEN,
+    EL_SALZSAEURE
+  };
+  static int ep_dont_go_to_num = sizeof(ep_dont_go_to)/sizeof(int);
+
+  static long ep_bit[] =
+  {
+    EP_BIT_AMOEBALIVE,
+    EP_BIT_AMOEBOID,
+    EP_BIT_BADEWANNOID,
+    EP_BIT_SCHLUESSEL,
+    EP_BIT_PFORTE,
+    EP_BIT_SOLID,
+    EP_BIT_MASSIV,
+    EP_BIT_SLIPPERY,
+    EP_BIT_ENEMY,
+    EP_BIT_CAN_FALL,
+    EP_BIT_CAN_SMASH,
+    EP_BIT_CAN_CHANGE,
+    EP_BIT_CAN_MOVE,
+    EP_BIT_COULD_MOVE,
+    EP_BIT_DONT_TOUCH,
+    EP_BIT_DONT_GO_TO
+  };
+  static int *ep_array[] =
+  {
+    ep_amoebalive,
+    ep_amoeboid,
+    ep_badewannoid,
+    ep_schluessel,
+    ep_pforte,
+    ep_solid,
+    ep_massiv,
+    ep_slippery,
+    ep_enemy,
+    ep_can_fall,
+    ep_can_smash,
+    ep_can_change,
+    ep_can_move,
+    ep_could_move,
+    ep_dont_touch,
+    ep_dont_go_to
+  };
+  static int *ep_num[] =
+  {
+    &ep_amoebalive_num,
+    &ep_amoeboid_num,
+    &ep_badewannoid_num,
+    &ep_schluessel_num,
+    &ep_pforte_num,
+    &ep_solid_num,
+    &ep_massiv_num,
+    &ep_slippery_num,
+    &ep_enemy_num,
+    &ep_can_fall_num,
+    &ep_can_smash_num,
+    &ep_can_change_num,
+    &ep_can_move_num,
+    &ep_could_move_num,
+    &ep_dont_touch_num,
+    &ep_dont_go_to_num
+  };
+  static int num_properties = sizeof(ep_num)/sizeof(int *);
+
+  for(i=0;i<MAX_ELEMENTS;i++)
+    Elementeigenschaften[i] = 0;
+
+  for(i=0;i<num_properties;i++)
+    for(j=0;j<*(ep_num[i]);j++)
+      Elementeigenschaften[(ep_array[i])[j]] |= ep_bit[i];
+  for(i=EL_CHAR_START;i<EL_CHAR_END;i++)
+    Elementeigenschaften[i] |= EP_BIT_CHAR;
+}
+
 void CloseAll()
 {
   int i;
index f292c53..c96f484 100644 (file)
@@ -10,8 +10,6 @@
 *               q99492@pbhrzx.uni-paderborn.de             *
 *----------------------------------------------------------*
 *  init.h                                                  *
-*                                                          *
-*  Letzte Aenderung: 15.06.1995                            *
 ***********************************************************/
 
 #ifndef INIT_H
 #include "main.h"
 
 void OpenAll(int, char **);
+void InitLevelAndPlayerInfo(void);
 void InitDisplay(int, char **);
 void InitSound(void);
 void InitSoundProcess(void);
 void InitJoystick(void);
 void InitWindow(int, char **);
 void InitGfx(void);
+void InitElementProperties(void);
 void CloseAll();
 
 #endif
index 2c237ce..0e3f612 100644 (file)
@@ -10,8 +10,6 @@
 *               q99492@pbhrzx.uni-paderborn.de             *
 *----------------------------------------------------------*
 *  main.c                                                  *
-*                                                          *
-*  Letzte Aenderung: 15.06.1995                            *
 ***********************************************************/
 
 #include "main.h"
@@ -51,6 +49,7 @@ int           direct_draw_on = FALSE;
 int            fading_on = FALSE;
 int            autorecord_on = FALSE;
 int            joystick_nr = 0;
+int            quick_doors = FALSE;
 
 BOOL           redraw[SCR_FIELDX][SCR_FIELDY];
 int            redraw_mask;
@@ -65,6 +64,10 @@ int          Store[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
 int            Store2[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
 int            Frame[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
 int            Stop[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
+int            AmoebaNr[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
+int            AmoebaCnt[MAX_NUM_AMOEBA];
+long           Elementeigenschaften[MAX_ELEMENTS];
+
 int            level_nr, leveldir_nr, num_leveldirs;
 int            lev_fieldx,lev_fieldy, scroll_x,scroll_y;
 
@@ -79,6 +82,15 @@ struct HiScore               highscore[MAX_SCORE_ENTRIES];
 struct SoundInfo       Sound[NUM_SOUNDS];
 struct RecordingInfo   tape,master_tape;
 
+struct JoystickInfo joystick[2] =
+{
+  JOYSTICK_XLEFT, JOYSTICK_XRIGHT, JOYSTICK_XMIDDLE,
+  JOYSTICK_YUPPER, JOYSTICK_YLOWER, JOYSTICK_YMIDDLE,
+
+  JOYSTICK_XLEFT, JOYSTICK_XRIGHT, JOYSTICK_XMIDDLE,
+  JOYSTICK_YUPPER, JOYSTICK_YLOWER, JOYSTICK_YMIDDLE
+};
+
 /* data needed for playing sounds */
 char *sound_name[NUM_SOUNDS] =
 {
index 761bc9f..905688b 100644 (file)
@@ -10,8 +10,6 @@
 *               q99492@pbhrzx.uni-paderborn.de             *
 *----------------------------------------------------------*
 *  main.h                                                  *
-*                                                          *
-*  Letzte Aenderung: 15.06.1995                            *
 ***********************************************************/
 
 #ifndef MAIN_H
@@ -47,13 +45,6 @@ typedef int BOOL;
 #define SCR_FIELDX     17
 #define SCR_FIELDY     17
 
-/*
-
-#define LEV_FIELDX     64
-#define LEV_FIELDY     32
-
-*/
-
 #define MIN_LEV_FIELDX (SCR_FIELDX-2)
 #define MIN_LEV_FIELDY (SCR_FIELDY-2)
 #define STD_LEV_FIELDX 64
@@ -75,41 +66,83 @@ typedef int BOOL;
 #define IS_FREE(x,y)   (Feld[x][y]==EL_LEERRAUM && !PLAYER(x,y))
 #define IS_MOVING(x,y) (MovPos[x][y]!=0)
 #define IS_BLOCKED(x,y)        (Feld[x][y]==EL_BLOCKED)
-#define IS_AMOEBOID(e) ((e)==EL_AMOEBE1 || (e)==EL_AMOEBE2 || (e)==EL_AMOEBE3)
+
+/*
+
+#define IS_AMOEBALIVE(e) ((e)==EL_AMOEBE_NASS || (e)==EL_AMOEBE_NORM || (e)==EL_AMOEBE_VOLL)
+#define IS_AMOEBOID(e) ((e)==EL_AMOEBE_TOT || IS_AMOEBALIVE(e))
 #define IS_BADEWANNOID(e) ((e)>=EL_BADEWANNE1 && (e)<=EL_BADEWANNE5)
 #define IS_SCHLUESSEL(e) ((e)>=EL_SCHLUESSEL1 && (e)<=EL_SCHLUESSEL4)
 #define IS_PFORTE(e)   ((e)>=EL_PFORTE1 && (e)<=EL_PFORTE4X)
-#define IS_CHAR(e)     ((e)>=EL_CHAR_START && (e)<=EL_CHAR_END)
 
 #define IS_SOLID(e)    ((e)==EL_BETON || (e)==EL_MAUERWERK || (e)==EL_FELSBODEN || (e)==EL_AUSGANG_ZU || (e)==EL_AUSGANG_ACT || (e)==EL_AUSGANG_AUF || IS_AMOEBOID(e) || (e)==EL_MORAST_VOLL || (e)==EL_MORAST_LEER || (e)==EL_SIEB_VOLL || (e)==EL_SIEB_LEER || (e)==EL_LIFE || (e)==EL_LIFE_ASYNC || IS_BADEWANNOID(e))
 
 #define IS_MASSIV(e)   ((e)==EL_BETON || (e)==EL_SALZSAEURE || IS_BADEWANNOID(e) || IS_PFORTE(e))
 
-#define CAN_FALL(e)    ((e)==EL_FELSBROCKEN || (e)==EL_EDELSTEIN || (e)==EL_DIAMANT || (e)==EL_BOMBE || (e)==EL_KOKOSNUSS || (e)==EL_TROPFEN || (e)==EL_MORAST_VOLL || (e)==EL_SIEB_VOLL)
+#define IS_SLIPPERY(e) ((e)==EL_FELSBODEN || (e)==EL_FELSBROCKEN || (e)==EL_EDELSTEIN || (e)==EL_DIAMANT || (e)==EL_BOMBE || (e)==EL_KOKOSNUSS || (e)==EL_ABLENK_EIN || (e)==EL_ABLENK_AUS || (e)==EL_ZEIT_VOLL || (e)==EL_ZEIT_LEER || (e)==EL_BIRNE_EIN || (e)==EL_BIRNE_AUS || (e)==EL_BADEWANNE1 || (e)==EL_BADEWANNE2)
+
+#define IS_ENEMY(e)    ((e)==EL_KAEFER || (e)==EL_FLIEGER || (e)==EL_MAMPFER || (e)==EL_ZOMBIE || (e)==EL_PACMAN)
+
+#define CAN_FALL(e)    ((e)==EL_FELSBROCKEN || (e)==EL_EDELSTEIN || (e)==EL_DIAMANT || (e)==EL_BOMBE || (e)==EL_KOKOSNUSS || (e)==EL_TROPFEN || (e)==EL_MORAST_VOLL || (e)==EL_SIEB_VOLL || (e)==EL_ZEIT_VOLL || (e)==EL_ZEIT_LEER)
 
-#define CAN_SMASH(e)   ((e)==EL_FELSBROCKEN || (e)==EL_EDELSTEIN || (e)==EL_DIAMANT || IS_SCHLUESSEL(e) || (e)==EL_BOMBE || (e)==EL_KOKOSNUSS || (e)==EL_TROPFEN)
+#define CAN_SMASH(e)   ((e)==EL_FELSBROCKEN || (e)==EL_EDELSTEIN || (e)==EL_DIAMANT || IS_SCHLUESSEL(e) || (e)==EL_BOMBE || (e)==EL_KOKOSNUSS || (e)==EL_TROPFEN || (e)==EL_ZEIT_VOLL || (e)==EL_ZEIT_LEER)
 
 #define CAN_CHANGE(e)  ((e)==EL_FELSBROCKEN || (e)==EL_EDELSTEIN || (e)==EL_DIAMANT)
 
 #define CAN_MOVE(e)    ((e)==EL_KAEFER || (e)==EL_FLIEGER || (e)==EL_MAMPFER || (e)==EL_ZOMBIE || (e)==EL_PACMAN)
 
-#define COULD_MOVE(e)  (((e)>=EL_KAEFER_R && (e)<=EL_KAEFER_U) || ((e)>=EL_FLIEGER_R && (e)<=EL_FLIEGER_U) || ((e)>=EL_PACMAN && (e)==EL_PACMAN_U))
+#define COULD_MOVE(e)  (((e)>=EL_KAEFER_R && (e)<=EL_KAEFER_U) || ((e)>=EL_FLIEGER_R && (e)<=EL_FLIEGER_U) || ((e)>=EL_PACMAN_R && (e)==EL_PACMAN_U))
 
-/*
-#define CAN_KILL(e)    ((e)==EL_KAEFER || (e)==EL_FLIEGER || (e)==EL_MAMPFER || (e)==EL_ZOMBIE || (e)==EL_PACMAN || (e)==EL_TROPFEN)
-*/
-
-#define IS_ENEMY(e)    ((e)==EL_KAEFER || (e)==EL_FLIEGER || (e)==EL_MAMPFER || (e)==EL_ZOMBIE || (e)==EL_PACMAN)
 #define DONT_TOUCH(e)  ((e)==EL_KAEFER || (e)==EL_FLIEGER)
 #define DONT_GO_TO(e)  (IS_ENEMY(e) || (e)==EL_TROPFEN || (e)==EL_SALZSAEURE)
 
-#define SLIPPERY(e)    ((e)==EL_FELSBODEN || (e)==EL_FELSBROCKEN || (e)==EL_EDELSTEIN || (e)==EL_DIAMANT || (e)==EL_BOMBE || (e)==EL_KOKOSNUSS || (e)==EL_ABLENK_EIN || (e)==EL_ABLENK_AUS || (e)==EL_BADEWANNE1 || (e)==EL_BADEWANNE2)
+#define IS_CHAR(e)     ((e)>=EL_CHAR_START && (e)<=EL_CHAR_END)
+
+*/
+
 
-#define EL_CHANGED(e)  ((e)==EL_FELSBROCKEN ? EL_EDELSTEIN : (e)==EL_EDELSTEIN ? EL_DIAMANT : EL_FELSBROCKEN)
+#define EP_BIT_AMOEBALIVE      (1<<0)
+#define EP_BIT_AMOEBOID                (1<<1)
+#define EP_BIT_BADEWANNOID     (1<<2)
+#define EP_BIT_SCHLUESSEL      (1<<3)
+#define EP_BIT_PFORTE          (1<<4)
+#define EP_BIT_SOLID           (1<<5)
+#define EP_BIT_MASSIV          (1<<6)
+#define EP_BIT_SLIPPERY                (1<<7)
+#define EP_BIT_ENEMY           (1<<8)
+#define EP_BIT_CAN_FALL                (1<<9)
+#define EP_BIT_CAN_SMASH       (1<<10)
+#define EP_BIT_CAN_CHANGE      (1<<11)
+#define EP_BIT_CAN_MOVE                (1<<12)
+#define EP_BIT_COULD_MOVE      (1<<13)
+#define EP_BIT_DONT_TOUCH      (1<<14)
+#define EP_BIT_DONT_GO_TO      (1<<15)
+#define EP_BIT_CHAR            (1<<16)
+
+#define IS_AMOEBALIVE(e)       (Elementeigenschaften[e] & EP_BIT_AMOEBALIVE)
+#define IS_AMOEBOID(e)         (Elementeigenschaften[e] & EP_BIT_AMOEBOID)
+#define IS_BADEWANNOID(e)      (Elementeigenschaften[e] & EP_BIT_BADEWANNOID)
+#define IS_SCHLUESSEL(e)       (Elementeigenschaften[e] & EP_BIT_SCHLUESSEL)
+#define IS_PFORTE(e)           (Elementeigenschaften[e] & EP_BIT_PFORTE)
+#define IS_SOLID(e)            (Elementeigenschaften[e] & EP_BIT_SOLID)
+#define IS_MASSIV(e)           (Elementeigenschaften[e] & EP_BIT_MASSIV)
+#define IS_SLIPPERY(e)         (Elementeigenschaften[e] & EP_BIT_SLIPPERY)
+#define IS_ENEMY(e)            (Elementeigenschaften[e] & EP_BIT_ENEMY)
+#define CAN_FALL(e)            (Elementeigenschaften[e] & EP_BIT_CAN_FALL)
+#define CAN_SMASH(e)           (Elementeigenschaften[e] & EP_BIT_CAN_SMASH)
+#define CAN_CHANGE(e)          (Elementeigenschaften[e] & EP_BIT_CAN_CHANGE)
+#define CAN_MOVE(e)            (Elementeigenschaften[e] & EP_BIT_CAN_MOVE)
+#define COULD_MOVE(e)          (Elementeigenschaften[e] & EP_BIT_COULD_MOVE)
+#define DONT_TOUCH(e)          (Elementeigenschaften[e] & EP_BIT_DONT_TOUCH)
+#define DONT_GO_TO(e)          (Elementeigenschaften[e] & EP_BIT_DONT_GO_TO)
+#define IS_CHAR(e)             (Elementeigenschaften[e] & EP_BIT_CHAR)
+
+#define EL_CHANGED(e)          ((e)==EL_FELSBROCKEN ? EL_EDELSTEIN :   \
+                                (e)==EL_EDELSTEIN   ? EL_DIAMANT :     \
+                                EL_FELSBROCKEN)
 #define IS_DRAWABLE(e)         ((e)<EL_BLOCKED)
 #define IS_NOT_DRAWABLE(e)     ((e)>=EL_BLOCKED)
-#define TIMESIZE       (TimeLeft*100/level.time)
-
+#define TIMESIZE               (TimeLeft*100/level.time)
 #define LEVELDIR_SIZE(x)       ((x).num_ready + (x).num_free)
 #define TAPE_IS_EMPTY(x)       ((x).length == 0)
 
@@ -127,10 +160,11 @@ typedef int BOOL;
 #define NUM_PICTURES           5
 #define NUM_PIXMAPS            8
 
+/* boundaries of arrays etc. */
 #define MAX_NAMELEN            (10+1)
 
 #define MAX_LEVNAMLEN          32
-#define MAX_SC_ENTRIES         16
+#define MAX_SC_ENTRIES         15
 #define MAX_TAPELEN            10000
 
 #define MAX_LEVDIR_FILENAME    (64+1)
@@ -139,6 +173,8 @@ typedef int BOOL;
 #define MAX_SCORE_ENTRIES      15
 
 #define MAX_FILENAME           256
+#define MAX_NUM_AMOEBA         100
+#define MAX_ELEMENTS           512
 
 struct PictureFile
 {
@@ -169,6 +205,7 @@ struct LevelInfo
   int edelsteine;
   char name[MAX_LEVNAMLEN];
   int score[MAX_SC_ENTRIES];
+  int amoebe_inhalt;
   int mampfer_inhalt[4][3][3];
   int tempo_amoebe;
   int dauer_sieb;
@@ -236,6 +273,7 @@ extern int          direct_draw_on;
 extern int             fading_on;
 extern int             autorecord_on;
 extern int             joystick_nr;
+extern int             quick_doors;
 
 extern BOOL            redraw[SCR_FIELDX][SCR_FIELDY];
 extern int             redraw_mask;
@@ -250,6 +288,10 @@ extern int         Store[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
 extern int             Store2[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
 extern int             Frame[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
 extern int             Stop[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
+extern int             AmoebaNr[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
+extern int             AmoebaCnt[MAX_NUM_AMOEBA];
+extern long            Elementeigenschaften[MAX_ELEMENTS];
+
 extern int             level_nr, leveldir_nr, num_leveldirs;
 extern int             lev_fieldx,lev_fieldy, scroll_x,scroll_y;
 
@@ -262,6 +304,7 @@ extern struct LevelInfo             level;
 extern struct PlayerInfo       player;
 extern struct HiScore          highscore[];
 extern struct RecordingInfo    tape, master_tape;
+extern struct JoystickInfo     joystick[];
 
 extern int             background_loop[];
 extern int             num_bg_loops;
@@ -321,8 +364,8 @@ extern char        *progname;
 #define FONT_LINES_PER_FONT    4
 
 /* game elements:
-**     0 - 255: real elements, stored in level file
-**     256 - ?: flag elements, only used at runtime
+**       0 - 255: real elements, stored in level file
+**     256 - 511: flag elements, only used at runtime
 */
 /* "real" level elements */
 #define EL_LEERRAUM    0
@@ -340,7 +383,7 @@ extern char        *progname;
 #define EL_ZOMBIE      12
 #define EL_BETON       13
 #define EL_DIAMANT     14
-#define EL_AMOEBE1     15
+#define EL_AMOEBE_TOT  15
 #define EL_MORAST_LEER 16
 #define EL_MORAST_VOLL 17
 #define EL_TROPFEN     18
@@ -348,8 +391,8 @@ extern char        *progname;
 #define EL_SIEB_LEER   20
 #define EL_SIEB_VOLL   21
 #define EL_SALZSAEURE  22
-#define EL_AMOEBE2     23
-#define EL_AMOEBE3     24
+#define EL_AMOEBE_NASS 23
+#define EL_AMOEBE_NORM 24
 #define EL_KOKOSNUSS   25
 #define EL_LIFE                26
 #define EL_LIFE_ASYNC  27
@@ -374,8 +417,12 @@ extern char               *progname;
 #define EL_UNSICHTBAR  46
 #define EL_BIRNE_AUS   47
 #define EL_BIRNE_EIN   48
-#define EL_ERZ_1       49
-#define EL_ERZ_2       50
+#define EL_ERZ_EDEL    49
+#define EL_ERZ_DIAM    50
+#define EL_AMOEBE_VOLL 51
+#define EL_AMOEBA2DIAM 52
+#define EL_ZEIT_VOLL   53
+#define EL_ZEIT_LEER   54
 
 #define EL_SPIELER1    80
 #define EL_SPIELER2    81
@@ -440,8 +487,7 @@ extern char        *progname;
 #define EL_CRACKINGNUT 302
 #define EL_BLURB_LEFT  303
 #define EL_BLURB_RIGHT 304
-#define EL_AMOEBING2   305
-#define EL_AMOEBING3   306
+#define EL_AMOEBING    305
 
 /* names for the graphic objects */
 /* Zeile 0 (0) */
@@ -515,23 +561,26 @@ extern char              *progname;
 #define GFX_ABLENK     96
 #define GFX_ABLENK_EIN GFX_ABLENK
 #define GFX_ABLENK_AUS GFX_ABLENK
-#define GFX_AMOEBE2    100
+#define GFX_AMOEBE_NASS        100
 #define GFX_TROPFEN    101
 #define GFX_AMOEBING   GFX_TROPFEN
 #define GFX_AMOEBE_LEBT        104
-#define GFX_AMOEBE3    GFX_AMOEBE_LEBT
+#define GFX_AMOEBE_NORM        GFX_AMOEBE_LEBT
 #define GFX_AMOEBE_TOT 108
-#define GFX_AMOEBE1    GFX_AMOEBE_TOT
+#define GFX_AMOEBA2DIAM        GFX_AMOEBE_TOT
+#define GFX_ZEIT_VOLL  114
+#define GFX_ZEIT_LEER  115
 /* Zeile 7 (112) */
 #define GFX_GEBLUBBER  124
 /* Zeile 8 (128) */
 #define GFX_SIEB_LEER  128
 #define GFX_SIEB_VOLL  GFX_SIEB_LEER
 #define GFX_SIEB_TOT   GFX_SIEB_LEER
-#define GFX_ERZ_1      132
-#define GFX_ERZ_2      133
+#define GFX_ERZ_EDEL   132
+#define GFX_ERZ_DIAM   133
 #define GFX_BIRNE_AUS  134
 #define GFX_BIRNE_EIN  135
+#define GFX_AMOEBE_VOLL        136
 #define GFX_KUGEL_ROT  140
 #define GFX_KUGEL_BLAU 141
 #define GFX_KUGEL_GELB 142
@@ -695,8 +744,13 @@ extern struct SoundInfo Sound[NUM_SOUNDS];
 /* values for the joystick */
 #define JOYSTICK_OFF           0
 #define        JOYSTICK_AVAILABLE      1
+#ifdef __FreeBSD__
+#define DEV_JOYSTICK_0         "/dev/joy0"
+#define DEV_JOYSTICK_1         "/dev/joy1"
+#else
 #define DEV_JOYSTICK_0         "/dev/js0"
 #define DEV_JOYSTICK_1         "/dev/js1"
+#endif
 
 /* get these values from the program 'js' from the joystick package, */
 /* set JOYSTICK_PERCENT to a threshold appropriate for your joystick */
@@ -859,235 +913,4 @@ extern struct SoundInfo Sound[NUM_SOUNDS];
 #define DOOR_GFX_PAGEY1                0
 #define DOOR_GFX_PAGEY2                DYSIZE
 
-/* some positions in the video tape control window */
-#define VIDEO_DISPLAY1_XPOS    5
-#define VIDEO_DISPLAY1_YPOS    5
-#define VIDEO_DISPLAY2_XPOS    5
-#define VIDEO_DISPLAY2_YPOS    41
-#define VIDEO_DISPLAY_XSIZE    90
-#define VIDEO_DISPLAY_YSIZE    31
-#define VIDEO_BUTTON_XSIZE     18
-#define VIDEO_BUTTON_YSIZE     18
-#define VIDEO_CONTROL_XPOS     5
-#define VIDEO_CONTROL_YPOS     77
-#define VIDEO_CONTROL_XSIZE    (VIDEO_DISPLAY_XSIZE)
-#define VIDEO_CONTROL_YSIZE    (VIDEO_BUTTON_YSIZE)
-#define VIDEO_BUTTON_EJECT_XPOS        (VIDEO_CONTROL_XPOS + 0 * VIDEO_BUTTON_XSIZE)
-#define VIDEO_BUTTON_STOP_XPOS (VIDEO_CONTROL_XPOS + 1 * VIDEO_BUTTON_XSIZE)
-#define VIDEO_BUTTON_PAUSE_XPOS        (VIDEO_CONTROL_XPOS + 2 * VIDEO_BUTTON_XSIZE)
-#define VIDEO_BUTTON_REC_XPOS  (VIDEO_CONTROL_XPOS + 3 * VIDEO_BUTTON_XSIZE)
-#define VIDEO_BUTTON_PLAY_XPOS (VIDEO_CONTROL_XPOS + 4 * VIDEO_BUTTON_XSIZE)
-#define VIDEO_BUTTON_ANY_YPOS  (VIDEO_CONTROL_YPOS)
-#define VIDEO_DATE_LABEL_XPOS  (VIDEO_DISPLAY1_XPOS)
-#define VIDEO_DATE_LABEL_YPOS  (VIDEO_DISPLAY1_YPOS)
-#define VIDEO_DATE_LABEL_XSIZE (VIDEO_DISPLAY_XSIZE)
-#define VIDEO_DATE_LABEL_YSIZE (VIDEO_DISPLAY_YSIZE)
-#define VIDEO_DATE_XPOS                (VIDEO_DISPLAY1_XPOS+1)
-#define VIDEO_DATE_YPOS                (VIDEO_DISPLAY1_YPOS+14)
-#define VIDEO_DATE_XSIZE       (VIDEO_DISPLAY_XSIZE)
-#define VIDEO_DATE_YSIZE       16
-#define VIDEO_REC_LABEL_XPOS   (VIDEO_DISPLAY2_XPOS)
-#define VIDEO_REC_LABEL_YPOS   (VIDEO_DISPLAY2_YPOS)
-#define VIDEO_REC_LABEL_XSIZE  20
-#define VIDEO_REC_LABEL_YSIZE  12
-#define VIDEO_REC_SYMBOL_XPOS  (VIDEO_DISPLAY2_XPOS+20)
-#define VIDEO_REC_SYMBOL_YPOS  (VIDEO_DISPLAY2_YPOS)
-#define VIDEO_REC_SYMBOL_XSIZE 16
-#define VIDEO_REC_SYMBOL_YSIZE 16
-#define VIDEO_PLAY_LABEL_XPOS  (VIDEO_DISPLAY2_XPOS+65)
-#define VIDEO_PLAY_LABEL_YPOS  (VIDEO_DISPLAY2_YPOS)
-#define VIDEO_PLAY_LABEL_XSIZE 22
-#define VIDEO_PLAY_LABEL_YSIZE 12
-#define VIDEO_PLAY_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS+50)
-#define VIDEO_PLAY_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS)
-#define VIDEO_PLAY_SYMBOL_XSIZE        13
-#define VIDEO_PLAY_SYMBOL_YSIZE        13
-#define VIDEO_PAUSE_LABEL_XPOS (VIDEO_DISPLAY2_XPOS)
-#define VIDEO_PAUSE_LABEL_YPOS (VIDEO_DISPLAY2_YPOS+20)
-#define VIDEO_PAUSE_LABEL_XSIZE        35
-#define VIDEO_PAUSE_LABEL_YSIZE        8
-#define VIDEO_PAUSE_SYMBOL_XPOS        (VIDEO_DISPLAY2_XPOS+35)
-#define VIDEO_PAUSE_SYMBOL_YPOS        (VIDEO_DISPLAY2_YPOS)
-#define VIDEO_PAUSE_SYMBOL_XSIZE 13
-#define VIDEO_PAUSE_SYMBOL_YSIZE 13
-#define VIDEO_TIME_XPOS                (VIDEO_DISPLAY2_XPOS+38)
-#define VIDEO_TIME_YPOS                (VIDEO_DISPLAY2_YPOS+14)
-#define VIDEO_TIME_XSIZE       50
-#define VIDEO_TIME_YSIZE       16
-
-#define ON_VIDEO_BUTTON(x,y)   ((x)>=(VX+VIDEO_CONTROL_XPOS) &&        \
-                                (x)< (VX+VIDEO_CONTROL_XPOS +          \
-                                      VIDEO_CONTROL_XSIZE) &&          \
-                                (y)>=(VY+VIDEO_CONTROL_YPOS) &&        \
-                                (y)< (VY+VIDEO_CONTROL_YPOS +          \
-                                      VIDEO_CONTROL_YSIZE))
-#define VIDEO_BUTTON(x)                (((x)-(VX+VIDEO_CONTROL_XPOS))/VIDEO_BUTTON_XSIZE)
-
-/* values for video tape control */
-#define VIDEO_STATE_PLAY_OFF   (1L<<0)
-#define VIDEO_STATE_PLAY_ON    (1L<<1)
-#define VIDEO_STATE_PLAY       (VIDEO_STATE_PLAY_OFF   | VIDEO_STATE_PLAY_ON)
-#define VIDEO_STATE_REC_OFF    (1L<<2)
-#define VIDEO_STATE_REC_ON     (1L<<3)
-#define VIDEO_STATE_REC                (VIDEO_STATE_REC_OFF    | VIDEO_STATE_REC_ON)
-#define VIDEO_STATE_PAUSE_OFF  (1L<<4)
-#define VIDEO_STATE_PAUSE_ON   (1L<<5)
-#define VIDEO_STATE_PAUSE      (VIDEO_STATE_PAUSE_OFF  | VIDEO_STATE_PAUSE_ON)
-#define VIDEO_STATE_DATE_OFF   (1L<<6)
-#define VIDEO_STATE_DATE_ON    (1L<<7)
-#define VIDEO_STATE_DATE       (VIDEO_STATE_DATE_OFF   | VIDEO_STATE_DATE_ON)
-#define VIDEO_STATE_TIME_OFF   (1L<<8)
-#define VIDEO_STATE_TIME_ON    (1L<<9)
-#define VIDEO_STATE_TIME       (VIDEO_STATE_TIME_OFF   | VIDEO_STATE_TIME_ON)
-#define VIDEO_PRESS_PLAY_ON    (1L<<10)
-#define VIDEO_PRESS_PLAY_OFF   (1L<<11)
-#define VIDEO_PRESS_PLAY       (VIDEO_PRESS_PLAY_OFF   | VIDEO_PRESS_PLAY_ON)
-#define VIDEO_PRESS_REC_ON     (1L<<12)
-#define VIDEO_PRESS_REC_OFF    (1L<<13)
-#define VIDEO_PRESS_REC                (VIDEO_PRESS_REC_OFF    | VIDEO_PRESS_REC_ON)
-#define VIDEO_PRESS_PAUSE_ON   (1L<<14)
-#define VIDEO_PRESS_PAUSE_OFF  (1L<<15)
-#define VIDEO_PRESS_PAUSE      (VIDEO_PRESS_PAUSE_OFF  | VIDEO_PRESS_PAUSE_ON)
-#define VIDEO_PRESS_STOP_ON    (1L<<16)
-#define VIDEO_PRESS_STOP_OFF   (1L<<17)
-#define VIDEO_PRESS_STOP       (VIDEO_PRESS_STOP_OFF   | VIDEO_PRESS_STOP_ON)
-#define VIDEO_PRESS_EJECT_ON   (1L<<18)
-#define VIDEO_PRESS_EJECT_OFF  (1L<<19)
-#define VIDEO_PRESS_EJECT      (VIDEO_PRESS_EJECT_OFF  | VIDEO_PRESS_EJECT_ON)
-
-#define BUTTON_VIDEO_EJECT     1
-#define BUTTON_VIDEO_STOP      2
-#define BUTTON_VIDEO_PAUSE     3
-#define BUTTON_VIDEO_REC       4
-#define BUTTON_VIDEO_PLAY      5
-
-#define VIDEO_STATE_OFF                (VIDEO_STATE_PLAY_OFF   |       \
-                                VIDEO_STATE_REC_OFF    |       \
-                                VIDEO_STATE_PAUSE_OFF  |       \
-                                VIDEO_STATE_DATE_OFF   |       \
-                                VIDEO_STATE_TIME_OFF)
-#define VIDEO_PRESS_OFF                (VIDEO_PRESS_PLAY_OFF   |       \
-                                VIDEO_PRESS_REC_OFF    |       \
-                                VIDEO_PRESS_PAUSE_OFF  |       \
-                                VIDEO_PRESS_STOP_OFF   |       \
-                                VIDEO_PRESS_EJECT_OFF)
-#define VIDEO_ALL_OFF          (VIDEO_STATE_OFF | VIDEO_PRESS_OFF)
-
-#define VIDEO_STATE_ON         (VIDEO_STATE_PLAY_ON    |       \
-                                VIDEO_STATE_REC_ON     |       \
-                                VIDEO_STATE_PAUSE_ON   |       \
-                                VIDEO_STATE_DATE_ON    |       \
-                                VIDEO_STATE_TIME_ON)
-#define VIDEO_PRESS_ON         (VIDEO_PRESS_PLAY_ON    |       \
-                                VIDEO_PRESS_REC_ON     |       \
-                                VIDEO_PRESS_PAUSE_ON   |       \
-                                VIDEO_PRESS_STOP_ON    |       \
-                                VIDEO_PRESS_EJECT_ON)
-#define VIDEO_ALL_ON           (VIDEO_STATE_ON | VIDEO_PRESS_ON)
-
-#define VIDEO_STATE            (VIDEO_STATE_ON | VIDEO_STATE_OFF)
-#define VIDEO_PRESS            (VIDEO_PRESS_ON | VIDEO_PRESS_OFF)
-#define VIDEO_ALL              (VIDEO_ALL_ON | VIDEO_ALL_OFF)
-
-/* some positions in the sound control window */
-#define SOUND_BUTTON_XSIZE     30
-#define SOUND_BUTTON_YSIZE     30
-#define SOUND_CONTROL_XPOS     5
-#define SOUND_CONTROL_YPOS     245
-#define SOUND_CONTROL_XSIZE    90
-#define SOUND_CONTROL_YSIZE    (SOUND_BUTTON_YSIZE)
-#define SOUND_BUTTON_MUSIC_XPOS        (SOUND_CONTROL_XPOS + 0 * SOUND_BUTTON_XSIZE)
-#define SOUND_BUTTON_LOOPS_XPOS        (SOUND_CONTROL_XPOS + 1 * SOUND_BUTTON_XSIZE)
-#define SOUND_BUTTON_SOUND_XPOS        (SOUND_CONTROL_XPOS + 2 * SOUND_BUTTON_XSIZE)
-#define SOUND_BUTTON_ANY_YPOS  (SOUND_CONTROL_YPOS)
-
-#define ON_SOUND_BUTTON(x,y)   ((x)>=(DX+SOUND_CONTROL_XPOS) &&        \
-                                (x)< (DX+SOUND_CONTROL_XPOS +          \
-                                      SOUND_CONTROL_XSIZE) &&          \
-                                (y)>=(DY+SOUND_CONTROL_YPOS) &&        \
-                                (y)< (DY+SOUND_CONTROL_YPOS +          \
-                                      SOUND_CONTROL_YSIZE))
-#define SOUND_BUTTON(x)                (((x)-(DX+SOUND_CONTROL_XPOS))/SOUND_BUTTON_XSIZE)
-
-/* values for sound control */
-#define BUTTON_SOUND_MUSIC     (1L<<0)
-#define BUTTON_SOUND_LOOPS     (1L<<1)
-#define BUTTON_SOUND_SOUND     (1L<<2)
-#define BUTTON_RELEASED                0
-#define BUTTON_PRESSED         (1L<<3)
-#define BUTTON_OFF             0
-#define BUTTON_ON              (1L<<4)
-#define BUTTON_SOUND_MUSIC_OFF (BUTTON_SOUND_MUSIC | BUTTON_OFF)
-#define BUTTON_SOUND_LOOPS_OFF (BUTTON_SOUND_LOOPS | BUTTON_OFF)
-#define BUTTON_SOUND_SOUND_OFF (BUTTON_SOUND_SOUND | BUTTON_OFF)
-#define BUTTON_SOUND_MUSIC_ON  (BUTTON_SOUND_MUSIC | BUTTON_ON)
-#define BUTTON_SOUND_LOOPS_ON  (BUTTON_SOUND_LOOPS | BUTTON_ON)
-#define BUTTON_SOUND_SOUND_ON  (BUTTON_SOUND_SOUND | BUTTON_ON)
-
-/* some positions in the game control window */
-#define GAME_BUTTON_XSIZE      30
-#define GAME_BUTTON_YSIZE      30
-#define GAME_CONTROL_XPOS      5
-#define GAME_CONTROL_YPOS      215
-#define GAME_CONTROL_XSIZE     90
-#define GAME_CONTROL_YSIZE     (GAME_BUTTON_YSIZE)
-#define GAME_BUTTON_STOP_XPOS  (GAME_CONTROL_XPOS + 0 * GAME_BUTTON_XSIZE)
-#define GAME_BUTTON_PAUSE_XPOS (GAME_CONTROL_XPOS + 1 * GAME_BUTTON_XSIZE)
-#define GAME_BUTTON_PLAY_XPOS  (GAME_CONTROL_XPOS + 2 * GAME_BUTTON_XSIZE)
-#define GAME_BUTTON_ANY_YPOS   (GAME_CONTROL_YPOS)
-
-#define ON_GAME_BUTTON(x,y)    ((x)>=(DX+GAME_CONTROL_XPOS) && \
-                                (x)< (DX+GAME_CONTROL_XPOS +           \
-                                      GAME_CONTROL_XSIZE) &&           \
-                                (y)>=(DY+GAME_CONTROL_YPOS) && \
-                                (y)< (DY+GAME_CONTROL_YPOS +           \
-                                      GAME_CONTROL_YSIZE))
-#define GAME_BUTTON(x)         (((x)-(DX+GAME_CONTROL_XPOS))/GAME_BUTTON_XSIZE)
-
-/* values for game control */
-#define BUTTON_GAME_STOP       (1L<<0)
-#define BUTTON_GAME_PAUSE      (1L<<1)
-#define BUTTON_GAME_PLAY       (1L<<2)
-
-/* some positions in the asking window */
-#define OK_BUTTON_XPOS         2
-#define OK_BUTTON_YPOS         250
-#define OK_BUTTON_GFX_YPOS     0
-#define OK_BUTTON_XSIZE                46
-#define OK_BUTTON_YSIZE                28
-#define NO_BUTTON_XPOS         52
-#define NO_BUTTON_YPOS         OK_BUTTON_YPOS
-#define NO_BUTTON_XSIZE                OK_BUTTON_XSIZE
-#define NO_BUTTON_YSIZE                OK_BUTTON_YSIZE
-#define CONFIRM_BUTTON_XPOS    2
-#define CONFIRM_BUTTON_GFX_YPOS        30
-#define CONFIRM_BUTTON_YPOS    OK_BUTTON_YPOS
-#define CONFIRM_BUTTON_XSIZE   96
-#define CONFIRM_BUTTON_YSIZE   OK_BUTTON_YSIZE
-
-#define ON_CHOOSE_BUTTON(x,y)  (((x)>=(DX+OK_BUTTON_XPOS) &&           \
-                                 (x)< (DX+OK_BUTTON_XPOS +             \
-                                       OK_BUTTON_XSIZE) &&             \
-                                 (y)>=(DY+OK_BUTTON_YPOS) &&           \
-                                 (y)< (DY+OK_BUTTON_YPOS +             \
-                                       OK_BUTTON_YSIZE)) ||            \
-                                ((x)>=(DX+NO_BUTTON_XPOS) &&           \
-                                 (x)< (DX+NO_BUTTON_XPOS +             \
-                                       NO_BUTTON_XSIZE) &&             \
-                                 (y)>=(DY+NO_BUTTON_YPOS) &&           \
-                                 (y)< (DY+NO_BUTTON_YPOS +             \
-                                       NO_BUTTON_YSIZE)))
-#define ON_CONFIRM_BUTTON(x,y) (((x)>=(DX+CONFIRM_BUTTON_XPOS) &&      \
-                                 (x)< (DX+CONFIRM_BUTTON_XPOS +        \
-                                       CONFIRM_BUTTON_XSIZE) &&        \
-                                 (y)>=(DY+CONFIRM_BUTTON_YPOS) &&      \
-                                 (y)< (DY+CONFIRM_BUTTON_YPOS +        \
-                                       CONFIRM_BUTTON_YSIZE)))
-#define CHOOSE_BUTTON(x)       (((x)-(DX+OK_BUTTON_XPOS))/OK_BUTTON_XSIZE)
-
-/* values for asking control */
-#define BUTTON_OK              (1L<<0)
-#define BUTTON_NO              (1L<<1)
-#define BUTTON_CONFIRM         (1L<<2)
-
 #endif
index a066cff..a17b1da 100644 (file)
@@ -10,8 +10,6 @@
 *               q99492@pbhrzx.uni-paderborn.de             *
 *----------------------------------------------------------*
 *  misc.c                                                  *
-*                                                          *
-*  Letzte Aenderung: 15.06.1995                            *
 ***********************************************************/
 
 #include "misc.h"
@@ -36,6 +34,74 @@ void microsleep(unsigned long usec)
            progname);
 }
 
+long mainCounter(int mode)
+{
+  static struct timeval base_time = { 0, 0 };
+  struct timeval current_time;
+  long counter_ms;
+
+  gettimeofday(&current_time,NULL);
+  if (mode==0 || current_time.tv_sec<base_time.tv_sec)
+    base_time = current_time;
+
+  counter_ms = (current_time.tv_sec - base_time.tv_sec)*1000
+             + (current_time.tv_usec - base_time.tv_usec)/1000;
+
+  if (mode==1)
+    return(counter_ms/10);     /* return 1/100 secs since last init */
+  else
+    return(counter_ms);                /* return 1/1000 secs since last init */
+}
+
+void InitCounter() /* set counter back to zero */
+{
+  mainCounter(0);
+}
+
+long Counter() /* returns 1/100 secs since last call of InitCounter() */
+{
+  return(mainCounter(1));
+}
+
+long Counter2()        /* returns 1/1000 secs since last call of InitCounter() */
+{
+  return(mainCounter(2));
+}
+
+void WaitCounter(long value)   /* wait for counter to reach value */
+{
+  long wait;
+
+  while((wait=value-Counter())>0)
+    microsleep(wait*10000);
+}
+
+void WaitCounter2(long value)  /* wait for counter to reach value */
+{
+  long wait;
+
+  while((wait=value-Counter2())>0)
+    microsleep(wait*1000);
+}
+
+void Delay(long value)
+{
+  microsleep(value);
+}
+
+BOOL DelayReached(long *counter_var, int delay)
+{
+  long actual_counter = Counter();
+
+  if (actual_counter>*counter_var+delay || actual_counter<*counter_var)
+  {
+    *counter_var = actual_counter;
+    return(TRUE);
+  }
+  else
+    return(FALSE);
+}
+
 unsigned long be2long(unsigned long *be)       /* big-endian -> longword */
 {
   unsigned char *ptr = (unsigned char *)be;
@@ -83,63 +149,6 @@ char *GetLoginName()
     return(pwd->pw_name);
 }
 
-static struct AnimInfo toon[NUM_TOONS] =
-{
-  DWARF_XSIZE, DWARF_YSIZE,
-  DWARF_X, DWARF_Y,
-  DWARF_FRAMES,
-  DWARF_FPS,
-  DWARF_STEPSIZE,
-  FALSE,
-  ANIMDIR_RIGHT,
-  ANIMPOS_DOWN,
-
-  DWARF_XSIZE, DWARF_YSIZE,
-  DWARF_X, DWARF2_Y,
-  DWARF_FRAMES,
-  DWARF_FPS,
-  DWARF_STEPSIZE,
-  FALSE,
-  ANIMDIR_LEFT,
-  ANIMPOS_DOWN,
-
-  JUMPER_XSIZE, JUMPER_YSIZE,
-  JUMPER_X, JUMPER_Y,
-  JUMPER_FRAMES,
-  JUMPER_FPS,
-  JUMPER_STEPSIZE,
-  FALSE,
-  ANIMDIR_LEFT,
-  ANIMPOS_DOWN,
-
-  CLOWN_XSIZE, CLOWN_YSIZE,
-  CLOWN_X, CLOWN_Y,
-  CLOWN_FRAMES,
-  CLOWN_FPS,
-  CLOWN_STEPSIZE,
-  FALSE,
-  ANIMDIR_UP,
-  ANIMPOS_ANY,
-
-  BIRD_XSIZE, BIRD_YSIZE,
-  BIRD1_X, BIRD1_Y,
-  BIRD_FRAMES,
-  BIRD_FPS,
-  BIRD_STEPSIZE,
-  TRUE,
-  ANIMDIR_RIGHT,
-  ANIMPOS_UPPER,
-
-  BIRD_XSIZE, BIRD_YSIZE,
-  BIRD2_X, BIRD2_Y,
-  BIRD_FRAMES,
-  BIRD_FPS,
-  BIRD_STEPSIZE,
-  TRUE,
-  ANIMDIR_LEFT,
-  ANIMPOS_UPPER
-};
-
 void InitAnimation()
 {
   HandleAnimation(ANIM_START);
@@ -210,12 +219,68 @@ BOOL AnimateToon(int toon_nr, BOOL restart)
   static BOOL horiz_move, vert_move;
   static long anim_delay = 0;
   static int anim_delay_value = 0;
-  struct AnimInfo *anim = &toon[toon_nr];
   static int width,height;
   static int pad_x,pad_y;
   static int cut_x,cut_y;
   static int src_x, src_y;
   static int dest_x, dest_y;
+  static struct AnimInfo toon[NUM_TOONS] =
+  {
+    DWARF_XSIZE, DWARF_YSIZE,
+    DWARF_X, DWARF_Y,
+    DWARF_FRAMES,
+    DWARF_FPS,
+    DWARF_STEPSIZE,
+    FALSE,
+    ANIMDIR_RIGHT,
+    ANIMPOS_DOWN,
+
+    DWARF_XSIZE, DWARF_YSIZE,
+    DWARF_X, DWARF2_Y,
+    DWARF_FRAMES,
+    DWARF_FPS,
+    DWARF_STEPSIZE,
+    FALSE,
+    ANIMDIR_LEFT,
+    ANIMPOS_DOWN,
+
+    JUMPER_XSIZE, JUMPER_YSIZE,
+    JUMPER_X, JUMPER_Y,
+    JUMPER_FRAMES,
+    JUMPER_FPS,
+    JUMPER_STEPSIZE,
+    FALSE,
+    ANIMDIR_LEFT,
+    ANIMPOS_DOWN,
+
+    CLOWN_XSIZE, CLOWN_YSIZE,
+    CLOWN_X, CLOWN_Y,
+    CLOWN_FRAMES,
+    CLOWN_FPS,
+    CLOWN_STEPSIZE,
+    FALSE,
+    ANIMDIR_UP,
+    ANIMPOS_ANY,
+
+    BIRD_XSIZE, BIRD_YSIZE,
+    BIRD1_X, BIRD1_Y,
+    BIRD_FRAMES,
+    BIRD_FPS,
+    BIRD_STEPSIZE,
+    TRUE,
+    ANIMDIR_RIGHT,
+    ANIMPOS_UPPER,
+
+    BIRD_XSIZE, BIRD_YSIZE,
+    BIRD2_X, BIRD2_Y,
+    BIRD_FRAMES,
+    BIRD_FPS,
+    BIRD_STEPSIZE,
+    TRUE,
+    ANIMDIR_LEFT,
+    ANIMPOS_UPPER
+  };
+  struct AnimInfo *anim = &toon[toon_nr];
 
   if (restart)
   {
@@ -348,6 +413,8 @@ void DrawAnim(int src_x, int src_y, int width, int height,
 {
   int buf_x = DOOR_GFX_PAGEX3, buf_y = DOOR_GFX_PAGEY1;
 
+#if 1
+  /* special method to avoid flickering interference with BackToFront() */
   XCopyArea(display,backbuffer,pix[PIX_DB_DOOR],gc,dest_x-pad_x,dest_y-pad_y,
            width+2*pad_x,height+2*pad_y, buf_x,buf_y);
   XSetClipOrigin(display,clip_gc[PIX_TOONS],dest_x-src_x,dest_y-src_y);
@@ -355,13 +422,11 @@ void DrawAnim(int src_x, int src_y, int width, int height,
            src_x,src_y, width,height, dest_x,dest_y);
   XCopyArea(display,backbuffer,window,gc, dest_x-pad_x,dest_y-pad_y,
            width+2*pad_x,height+2*pad_y, dest_x-pad_x,dest_y-pad_y);
-
   BackToFront();
-
   XCopyArea(display,pix[PIX_DB_DOOR],backbuffer,gc, buf_x,buf_y,
            width+2*pad_x,height+2*pad_y, dest_x-pad_x,dest_y-pad_y);
-
-/*
+#else
+  /* normal method, causing flickering interference with BackToFront() */
   XCopyArea(display,backbuffer,pix[PIX_DB_DOOR],gc,dest_x-pad_x,dest_y-pad_y,
            width+2*pad_x,height+2*pad_y, buf_x,buf_y);
   XSetClipOrigin(display,clip_gc[PIX_TOONS],
@@ -370,7 +435,7 @@ void DrawAnim(int src_x, int src_y, int width, int height,
            src_x,src_y, width,height, buf_x+pad_x,buf_y+pad_y);
   XCopyArea(display,pix[PIX_DB_DOOR],window,gc, buf_x,buf_y,
            width+2*pad_x,height+2*pad_y, dest_x-pad_x,dest_y-pad_y);
-*/
+#endif
 
   XFlush(display);
 }
index c4cba8d..dba3801 100644 (file)
@@ -10,8 +10,6 @@
 *               q99492@pbhrzx.uni-paderborn.de             *
 *----------------------------------------------------------*
 *  misc.h                                                  *
-*                                                          *
-*  Letzte Aenderung: 15.06.1995                            *
 ***********************************************************/
 
 #ifndef MISC_H
@@ -85,6 +83,14 @@ struct AnimInfo
 #define NEW_RANDOMIZE  -1
 
 void microsleep(unsigned long);
+long mainCounter(int);
+void InitCounter(void);
+long Counter(void);
+long Counter2(void);
+void WaitCounter(long);
+void WaitCounter2(long);
+void Delay(long);
+BOOL DelayReached(long *, int);
 unsigned long be2long(unsigned long *);
 char *int2str(int, int);
 unsigned int RND(unsigned int);
index 2d5d17c..5246fa8 100644 (file)
@@ -10,8 +10,6 @@
 *               q99492@pbhrzx.uni-paderborn.de             *
 *----------------------------------------------------------*
 *  screens.c                                               *
-*                                                          *
-*  Letzte Aenderung: 15.06.1995                            *
 ***********************************************************/
 
 #include "screens.h"
@@ -21,6 +19,8 @@
 #include "tools.h"
 #include "editor.h"
 #include "misc.h"
+#include "files.h"
+#include "buttons.h"
 
 void DrawMainMenu()
 {
@@ -244,8 +244,8 @@ static int helpscreen_action[] =
   GFX_FELSBROCKEN,4,5,                                         HA_NEXT,
   GFX_BOMBE,1,50, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10,                HA_NEXT,
   GFX_KOKOSNUSS,1,50, GFX_CRACKINGNUT,3,1, GFX_EDELSTEIN,1,10, HA_NEXT,
-  GFX_ERZ_1,1,50, GFX_EXPLOSION,8,1, GFX_EDELSTEIN,1,10,       HA_NEXT,
-  GFX_ERZ_2,1,50, GFX_EXPLOSION,8,1, GFX_DIAMANT,1,10,         HA_NEXT,
+  GFX_ERZ_EDEL,1,50, GFX_EXPLOSION,8,1, GFX_EDELSTEIN,1,10,    HA_NEXT,
+  GFX_ERZ_DIAM,1,50, GFX_EXPLOSION,8,1, GFX_DIAMANT,1,10,      HA_NEXT,
   GFX_GEBLUBBER,4,4,                                           HA_NEXT,
   GFX_SCHLUESSEL1,4,33,                                                HA_NEXT,
   GFX_PFORTE1,4,33,                                            HA_NEXT,
@@ -452,7 +452,7 @@ void DrawHelpScreenMusicText(int num)
   PlaySoundLoop(background_loop[num]);
 }
 
-void DrawHelpScreenRegistrationText()
+void DrawHelpScreenCreditsText()
 {
   int ystart = 150, ystep = 30;
   char text[FULL_SXSIZE/FONT2_XSIZE+10];
@@ -463,13 +463,34 @@ void DrawHelpScreenRegistrationText()
   DrawText(SX+25+16, SY+46, "Copyright ^1995 by Holger Schemel",
           FS_SMALL,FC_RED);
 
-  sprintf(text,"Registration information:");
+  sprintf(text,"Program information:");
   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+100,
           text,FS_SMALL,FC_GREEN);
 
-  sprintf(text,"Unregistered version");
-  DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep,
+  sprintf(text,"This game is Freeware!");
+  DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+0*ystep,
+          text,FS_SMALL,FC_YELLOW);
+  sprintf(text,"If you like it, send e-mail to:");
+  DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+1*ystep,
           text,FS_SMALL,FC_YELLOW);
+  sprintf(text,"aeglos@valinor.owl.de");
+  DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+2*ystep,
+          text,FS_SMALL,FC_RED);
+  sprintf(text,"or SnailMail to:");
+  DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+3*ystep,
+          text,FS_SMALL,FC_YELLOW);
+  sprintf(text,"Holger Schemel");
+  DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep,
+          text,FS_SMALL,FC_RED);
+  sprintf(text,"Sennehof 28");
+  DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep+20,
+          text,FS_SMALL,FC_RED);
+  sprintf(text,"33659 Bielefeld");
+  DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep+40,
+          text,FS_SMALL,FC_RED);
+  sprintf(text,"Germany");
+  DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep+60,
+          text,FS_SMALL,FC_RED);
 
   sprintf(text,"Press any key or button for main menu");
   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+SYSIZE-20,
@@ -520,7 +541,7 @@ void HandleHelpScreen(int button)
     else if (helpscreen_state==num_helpscreen_els_pages+num_bg_loops-1)
     {
       helpscreen_state++;
-      DrawHelpScreenRegistrationText();
+      DrawHelpScreenCreditsText();
     }
     else
     {
@@ -609,6 +630,8 @@ void DrawChooseLevel()
 {
   int i;
 
+  CloseDoor(DOOR_CLOSE_2);
+
   ClearWindow();
   DrawText(SX,SY,"Level Directories",FS_BIG,FC_GREEN);
   for(i=0;i<num_leveldirs;i++)
@@ -743,11 +766,13 @@ void DrawSetupScreen()
   DrawText(SX+32, SY+5*32,"Toons:",FS_BIG,FC_GREEN);
   DrawText(SX+32, SY+6*32,"Buffered gfx:",FS_BIG,FC_GREEN);
   DrawText(SX+32, SY+7*32,"Fading:",FS_BIG,FC_GREEN);
-  DrawText(SX+32, SY+8*32,"Auto-Record:",FS_BIG,FC_GREEN);
-  DrawText(SX+32, SY+9*32,"Joystick:",FS_BIG,FC_GREEN);
-  DrawText(SX+32, SY+10*32,"Cal. Joystick",FS_BIG,FC_GREEN);
-  DrawText(SX+32, SY+12*32,"Exit",FS_BIG,FC_GREEN);
-  DrawText(SX+32, SY+13*32,"Save and exit",FS_BIG,FC_GREEN);
+  DrawText(SX+32, SY+8*32,"Quick Doors:",FS_BIG,FC_GREEN);
+  DrawText(SX+32, SY+9*32,"Auto-Record:",FS_BIG,FC_GREEN);
+  DrawText(SX+32, SY+10*32,"Joystick:",FS_BIG,FC_GREEN);
+  DrawText(SX+32, SY+11*32,"Cal. Joystick",FS_BIG,FC_GREEN);
+
+  DrawText(SX+32, SY+13*32,"Exit",FS_BIG,FC_GREEN);
+  DrawText(SX+32, SY+14*32,"Save and exit",FS_BIG,FC_GREEN);
 
   if (SETUP_SOUND_ON(player.setup))
     DrawText(SX+14*32, SY+2*32,"on",FS_BIG,FC_YELLOW);
@@ -779,18 +804,23 @@ void DrawSetupScreen()
   else
     DrawText(SX+14*32, SY+7*32,"off",FS_BIG,FC_BLUE);
 
-  if (SETUP_RECORD_EACH_GAME_ON(player.setup))
+  if (SETUP_QUICK_DOORS_ON(player.setup))
     DrawText(SX+14*32, SY+8*32,"on",FS_BIG,FC_YELLOW);
   else
     DrawText(SX+14*32, SY+8*32,"off",FS_BIG,FC_BLUE);
 
+  if (SETUP_RECORD_EACH_GAME_ON(player.setup))
+    DrawText(SX+14*32, SY+9*32,"on",FS_BIG,FC_YELLOW);
+  else
+    DrawText(SX+14*32, SY+9*32,"off",FS_BIG,FC_BLUE);
+
   if (SETUP_2ND_JOYSTICK_ON(player.setup))
-    DrawText(SX+14*32, SY+9*32,"2nd",FS_BIG,FC_YELLOW);
+    DrawText(SX+14*32, SY+10*32,"2nd",FS_BIG,FC_YELLOW);
   else
-    DrawText(SX+14*32, SY+9*32,"1st",FS_BIG,FC_YELLOW);
+    DrawText(SX+14*32, SY+10*32,"1st",FS_BIG,FC_YELLOW);
 
-  for(i=2;i<14;i++)
-    if (i!=11)
+  for(i=2;i<15;i++)
+    if (i!=12)
       DrawGraphic(0,i,GFX_KUGEL_BLAU);
 
   FadeToFront();
@@ -820,13 +850,13 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
     else
       x = y = 0;
 
-    if (y==12)
-      y = (dy>0 ? 13 : 11);
+    if (y==13)
+      y = (dy>0 ? 14 : 12);
 
     if (y<3)
       y = 3;
-    else if (y>14)
-      y = 14;
+    else if (y>15)
+      y = 15;
   }
 
   if (!mx && !my && !dx && !dy)
@@ -835,7 +865,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
     y = choice;
   }
 
-  if (x==1 && y>=3 && y<=14 && y!=12)
+  if (x==1 && y>=3 && y<=15 && y!=13)
   {
     if (button)
     {
@@ -899,6 +929,14 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
        player.setup ^= SETUP_FADING;
       }
       else if (y==9)
+      {
+       if (SETUP_QUICK_DOORS_ON(player.setup))
+         DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
+       else
+         DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
+       player.setup ^= SETUP_QUICK_DOORS;
+      }
+      else if (y==10)
       {
        if (SETUP_RECORD_EACH_GAME_ON(player.setup))
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
@@ -906,7 +944,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
        player.setup ^= SETUP_RECORD_EACH_GAME;
       }
-      else if (y==10)
+      else if (y==11)
       {
        if (SETUP_2ND_JOYSTICK_ON(player.setup))
          DrawText(SX+14*32, SY+yy*32,"1st",FS_BIG,FC_YELLOW);
@@ -914,14 +952,14 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
          DrawText(SX+14*32, SY+yy*32,"2nd",FS_BIG,FC_YELLOW);
        player.setup ^= SETUP_2ND_JOYSTICK;
       }
-      else if (y==11)
+      else if (y==12)
       {
        CalibrateJoystick();
        redraw = TRUE;
       }
-      else if (y==13 || y==14)
+      else if (y==14 || y==15)
       {
-        if (y==14)
+        if (y==15)
        {
          SavePlayerInfo(PLAYER_SETUP);
          SaveJoystickData();
@@ -939,6 +977,133 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
     DoAnimation();
 }
 
+void CalibrateJoystick()
+{
+#ifdef __FreeBSD__
+  struct joystick joy_ctrl;
+#else
+  struct joystick_control
+  {
+    int buttons;
+    int x;
+    int y;
+  } joy_ctrl;
+#endif
+
+  int new_joystick_xleft, new_joystick_xright, new_joystick_xmiddle;
+  int new_joystick_yupper, new_joystick_ylower, new_joystick_ymiddle;
+
+  if (joystick_status==JOYSTICK_OFF)
+    goto error_out;
+
+  ClearWindow();
+  DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
+  DrawText(SX+16, SY+8*32, " THE UPPER LEFT ",FS_BIG,FC_YELLOW);
+  DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
+  BackToFront();
+
+#ifdef __FreeBSD__
+  joy_ctrl.b1 = joy_ctrl.b2 = 0;
+#else
+  joy_ctrl.buttons = 0;
+#endif
+  while(Joystick() & JOY_BUTTON);
+#ifdef __FreeBSD__
+  while(!(joy_ctrl.b1||joy_ctrl.b2))
+#else
+  while(!joy_ctrl.buttons)
+#endif
+  {
+    if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
+    {
+      joystick_status=JOYSTICK_OFF;
+      goto error_out;
+    }
+    Delay(10000);
+  }
+
+  new_joystick_xleft = joy_ctrl.x;
+  new_joystick_yupper = joy_ctrl.y;
+
+  ClearWindow();
+  DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
+  DrawText(SX+32, SY+8*32, "THE LOWER RIGHT",FS_BIG,FC_YELLOW);
+  DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
+  BackToFront();
+
+#ifdef __FreeBSD__
+  joy_ctrl.b1 = joy_ctrl.b2 = 0;
+#else
+  joy_ctrl.buttons = 0;
+#endif
+  while(Joystick() & JOY_BUTTON);
+#ifdef __FreeBSD__
+  while(!(joy_ctrl.b1||joy_ctrl.b2))
+#else
+  while(!joy_ctrl.buttons)
+#endif
+  {
+    if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
+    {
+      joystick_status=JOYSTICK_OFF;
+      goto error_out;
+    }
+    Delay(10000);
+  }
+
+  new_joystick_xright = joy_ctrl.x;
+  new_joystick_ylower = joy_ctrl.y;
+
+  ClearWindow();
+  DrawText(SX+32, SY+16+7*32, "CENTER JOYSTICK",FS_BIG,FC_YELLOW);
+  DrawText(SX+16, SY+16+8*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
+  BackToFront();
+
+#ifdef __FreeBSD__
+  joy_ctrl.b1 = joy_ctrl.b2 = 0;
+#else
+  joy_ctrl.buttons = 0;
+#endif
+  while(Joystick() & JOY_BUTTON);
+#ifdef __FreeBSD__
+  while(!(joy_ctrl.b1||joy_ctrl.b2))
+#else
+  while(!joy_ctrl.buttons)
+#endif
+  {
+    if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
+    {
+      joystick_status=JOYSTICK_OFF;
+      goto error_out;
+    }
+    Delay(10000);
+  }
+
+  new_joystick_xmiddle = joy_ctrl.x;
+  new_joystick_ymiddle = joy_ctrl.y;
+
+  joystick[joystick_nr].xleft = new_joystick_xleft;
+  joystick[joystick_nr].yupper = new_joystick_yupper;
+  joystick[joystick_nr].xright = new_joystick_xright;
+  joystick[joystick_nr].ylower = new_joystick_ylower;
+  joystick[joystick_nr].xmiddle = new_joystick_xmiddle;
+  joystick[joystick_nr].ymiddle = new_joystick_ymiddle;
+
+  CheckJoystickData();
+
+  DrawSetupScreen();
+  while(Joystick() & JOY_BUTTON);
+  return;
+
+  error_out:
+
+  ClearWindow();
+  DrawText(SX+16, SY+16, "NO JOYSTICK",FS_BIG,FC_YELLOW);
+  DrawText(SX+16, SY+48, " AVAILABLE ",FS_BIG,FC_YELLOW);
+  Delay(3000000);
+  DrawSetupScreen();
+}
+
 void HandleVideoButtons(int mx, int my, int button)
 {
   if (game_status!=MAINMENU && game_status!=PLAYING)
@@ -1079,307 +1244,3 @@ void HandleGameButtons(int mx, int my, int button)
       break;
   }
 }
-
-int CheckVideoButtons(int mx, int my, int button)
-{
-  int return_code = 0;
-  static int choice = -1;
-  static BOOL pressed = FALSE;
-  static int video_button[5] =
-  {
-    VIDEO_PRESS_EJECT_ON,
-    VIDEO_PRESS_STOP_ON,
-    VIDEO_PRESS_PAUSE_ON,
-    VIDEO_PRESS_REC_ON,
-    VIDEO_PRESS_PLAY_ON
-  };
-
-  if (button)
-  {
-    if (!motion_status)                /* Maustaste neu gedrückt */
-    {
-      if (ON_VIDEO_BUTTON(mx,my))
-      {
-       choice = VIDEO_BUTTON(mx);
-       pressed = TRUE;
-       DrawVideoDisplay(video_button[choice],0);
-      }
-    }
-    else                       /* Mausbewegung bei gedrückter Maustaste */
-    {
-      if ((!ON_VIDEO_BUTTON(mx,my) || VIDEO_BUTTON(mx)!=choice) &&
-         choice>=0 && pressed)
-      {
-       pressed = FALSE;
-       DrawVideoDisplay(video_button[choice]<<1,0);
-      }
-      else if (ON_VIDEO_BUTTON(mx,my) && VIDEO_BUTTON(mx)==choice && !pressed)
-      {
-       pressed = TRUE;
-       DrawVideoDisplay(video_button[choice],0);
-      }
-    }
-  }
-  else                         /* Maustaste wieder losgelassen */
-  {
-    if (ON_VIDEO_BUTTON(mx,my) && VIDEO_BUTTON(mx)==choice && pressed)
-    {
-      DrawVideoDisplay(video_button[choice]<<1,0);
-      return_code = choice+1;
-      choice = -1;
-      pressed = FALSE;
-    }
-    else
-    {
-      choice = -1;
-      pressed = FALSE;
-    }
-  }
-
-  BackToFront();
-  return(return_code);
-}
-
-int CheckSoundButtons(int mx, int my, int button)
-{
-  int return_code = 0;
-  static int choice = -1;
-  static BOOL pressed = FALSE;
-  int sound_state[3];
-
-  sound_state[0] = BUTTON_SOUND_MUSIC | (BUTTON_ON * sound_music_on);
-  sound_state[1] = BUTTON_SOUND_LOOPS | (BUTTON_ON * sound_loops_on);
-  sound_state[2] = BUTTON_SOUND_SOUND | (BUTTON_ON * sound_on);
-
-  if (button)
-  {
-    if (!motion_status)                /* Maustaste neu gedrückt */
-    {
-      if (ON_SOUND_BUTTON(mx,my))
-      {
-       choice = SOUND_BUTTON(mx);
-       pressed = TRUE;
-       DrawSoundDisplay(sound_state[choice] | BUTTON_PRESSED);
-      }
-    }
-    else                       /* Mausbewegung bei gedrückter Maustaste */
-    {
-      if ((!ON_SOUND_BUTTON(mx,my) || SOUND_BUTTON(mx)!=choice) &&
-         choice>=0 && pressed)
-      {
-       pressed = FALSE;
-       DrawSoundDisplay(sound_state[choice] | BUTTON_RELEASED);
-      }
-      else if (ON_SOUND_BUTTON(mx,my) && SOUND_BUTTON(mx)==choice && !pressed)
-      {
-       pressed = TRUE;
-       DrawSoundDisplay(sound_state[choice] | BUTTON_PRESSED);
-      }
-    }
-  }
-  else                         /* Maustaste wieder losgelassen */
-  {
-    if (ON_SOUND_BUTTON(mx,my) && SOUND_BUTTON(mx)==choice && pressed)
-    {
-      DrawSoundDisplay(sound_state[choice] | BUTTON_RELEASED);
-      return_code = 1<<choice;
-      choice = -1;
-      pressed = FALSE;
-    }
-    else
-    {
-      choice = -1;
-      pressed = FALSE;
-    }
-  }
-
-  BackToFront();
-  return(return_code);
-}
-
-int CheckGameButtons(int mx, int my, int button)
-{
-  int return_code = 0;
-  static int choice = -1;
-  static BOOL pressed = FALSE;
-  int game_state[3] =
-  {
-    BUTTON_GAME_STOP,
-    BUTTON_GAME_PAUSE,
-    BUTTON_GAME_PLAY
-  };
-
-  if (button)
-  {
-    if (!motion_status)                /* Maustaste neu gedrückt */
-    {
-      if (ON_GAME_BUTTON(mx,my))
-      {
-       choice = GAME_BUTTON(mx);
-       pressed = TRUE;
-       DrawGameButton(game_state[choice] | BUTTON_PRESSED);
-      }
-    }
-    else                       /* Mausbewegung bei gedrückter Maustaste */
-    {
-      if ((!ON_GAME_BUTTON(mx,my) || GAME_BUTTON(mx)!=choice) &&
-         choice>=0 && pressed)
-      {
-       pressed = FALSE;
-       DrawGameButton(game_state[choice] | BUTTON_RELEASED);
-      }
-      else if (ON_GAME_BUTTON(mx,my) && GAME_BUTTON(mx)==choice && !pressed)
-      {
-       pressed = TRUE;
-       DrawGameButton(game_state[choice] | BUTTON_PRESSED);
-      }
-    }
-  }
-  else                         /* Maustaste wieder losgelassen */
-  {
-    if (ON_GAME_BUTTON(mx,my) && GAME_BUTTON(mx)==choice && pressed)
-    {
-      DrawGameButton(game_state[choice] | BUTTON_RELEASED);
-      return_code = 1<<choice;
-      choice = -1;
-      pressed = FALSE;
-    }
-    else
-    {
-      choice = -1;
-      pressed = FALSE;
-    }
-  }
-
-  BackToFront();
-  return(return_code);
-}
-
-int CheckChooseButtons(int mx, int my, int button)
-{
-  int return_code = 0;
-  static int choice = -1;
-  static BOOL pressed = FALSE;
-  static int choose_button[5] =
-  {
-    BUTTON_OK,
-    BUTTON_NO
-  };
-
-  if (button)
-  {
-    if (!motion_status)                /* Maustaste neu gedrückt */
-    {
-      if (ON_CHOOSE_BUTTON(mx,my))
-      {
-       choice = CHOOSE_BUTTON(mx);
-       pressed = TRUE;
-       DrawChooseButton(choose_button[choice] | BUTTON_PRESSED);
-      }
-    }
-    else                       /* Mausbewegung bei gedrückter Maustaste */
-    {
-      if ((!ON_CHOOSE_BUTTON(mx,my) || CHOOSE_BUTTON(mx)!=choice) &&
-         choice>=0 && pressed)
-      {
-       pressed = FALSE;
-       DrawChooseButton(choose_button[choice] | BUTTON_RELEASED);
-      }
-      else if (ON_CHOOSE_BUTTON(mx,my) &&CHOOSE_BUTTON(mx)==choice && !pressed)
-      {
-       pressed = TRUE;
-       DrawChooseButton(choose_button[choice] | BUTTON_PRESSED);
-      }
-    }
-  }
-  else                         /* Maustaste wieder losgelassen */
-  {
-    if (ON_CHOOSE_BUTTON(mx,my) && CHOOSE_BUTTON(mx)==choice && pressed)
-    {
-      DrawChooseButton(choose_button[choice] | BUTTON_RELEASED);
-      return_code = choice+1;
-      choice = -1;
-      pressed = FALSE;
-    }
-    else
-    {
-      choice = -1;
-      pressed = FALSE;
-    }
-  }
-
-  BackToFront();
-  return(return_code);
-}
-
-int CheckConfirmButton(int mx, int my, int button)
-{
-  int return_code = 0;
-  static int choice = -1;
-  static BOOL pressed = FALSE;
-
-  if (button)
-  {
-    if (!motion_status)                /* Maustaste neu gedrückt */
-    {
-      if (ON_CONFIRM_BUTTON(mx,my))
-      {
-       choice = 0;
-       pressed = TRUE;
-       DrawConfirmButton(BUTTON_PRESSED);
-      }
-    }
-    else                       /* Mausbewegung bei gedrückter Maustaste */
-    {
-      if (!ON_CONFIRM_BUTTON(mx,my) && choice>=0 && pressed)
-      {
-       pressed = FALSE;
-       DrawConfirmButton(BUTTON_RELEASED);
-      }
-      else if (ON_CONFIRM_BUTTON(mx,my) && !pressed)
-      {
-       pressed = TRUE;
-       DrawConfirmButton(BUTTON_PRESSED);
-      }
-    }
-  }
-  else                         /* Maustaste wieder losgelassen */
-  {
-    if (ON_CONFIRM_BUTTON(mx,my) && pressed)
-    {
-      DrawConfirmButton(BUTTON_RELEASED);
-      return_code = BUTTON_CONFIRM;
-      choice = -1;
-      pressed = FALSE;
-    }
-    else
-    {
-      choice = -1;
-      pressed = FALSE;
-    }
-  }
-
-  BackToFront();
-  return(return_code);
-}
-
-void DrawCompleteVideoDisplay()
-{
-  XCopyArea(display,pix[PIX_DOOR],drawto,gc,
-           DOOR_GFX_PAGEX3,DOOR_GFX_PAGEY2, VXSIZE,VYSIZE, VX,VY);
-  XCopyArea(display,pix[PIX_DOOR],drawto,gc,
-           DOOR_GFX_PAGEX4+VIDEO_CONTROL_XPOS,
-           DOOR_GFX_PAGEY2+VIDEO_CONTROL_YPOS,
-           VIDEO_CONTROL_XSIZE,VIDEO_CONTROL_YSIZE,
-           VX+VIDEO_CONTROL_XPOS,VY+VIDEO_CONTROL_YPOS);
-
-  DrawVideoDisplay(VIDEO_ALL_OFF,0);
-  if (tape.date && tape.length)
-  {
-    DrawVideoDisplay(VIDEO_STATE_DATE_ON,tape.date);
-    DrawVideoDisplay(VIDEO_STATE_TIME_ON,0);
-  }
-
-  XCopyArea(display,drawto,pix[PIX_DB_DOOR],gc,
-           VX,VY, VXSIZE,VYSIZE, DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY2);
-}
index c76ade7..32a5840 100644 (file)
@@ -10,8 +10,6 @@
 *               q99492@pbhrzx.uni-paderborn.de             *
 *----------------------------------------------------------*
 *  screens.h                                               *
-*                                                          *
-*  Letzte Aenderung: 15.06.1995                            *
 ***********************************************************/
 
 #ifndef SCREENS_H
 
 #include "main.h"
 
-/* Setup-Bits */
-#define SETUP_TOONS                    (1<<0)
-#define SETUP_SOUND                    (1<<1)
-#define SETUP_SOUND_LOOPS              (1<<2)
-#define SETUP_SOUND_MUSIC              (1<<3)
-#define SETUP_DIRECT_DRAW              (1<<4)
-#define SETUP_FADING                   (1<<5)
-#define SETUP_RECORD_EACH_GAME         (1<<6)
-#define SETUP_2ND_JOYSTICK             (1<<7)
-
-#define DEFAULT_SETUP                  (SETUP_TOONS |          \
-                                        SETUP_SOUND |          \
-                                        SETUP_SOUND_LOOPS |    \
-                                        SETUP_SOUND_MUSIC)
-
-/* Setup-Voreinstellungen */
-#define SETUP_TOONS_ON(x)              (((x) & SETUP_TOONS) != 0)
-#define SETUP_SOUND_ON(x)              (((x) & SETUP_SOUND) != 0)
-#define SETUP_SOUND_LOOPS_ON(x)                (((x) & SETUP_SOUND_LOOPS) != 0)
-#define SETUP_SOUND_MUSIC_ON(x)                (((x) & SETUP_SOUND_MUSIC) != 0)
-#define SETUP_DIRECT_DRAW_ON(x)                (((x) & SETUP_DIRECT_DRAW) != 0)
-#define SETUP_FADING_ON(x)             (((x) & SETUP_FADING) != 0)
-#define SETUP_RECORD_EACH_GAME_ON(x)   (((x) & SETUP_RECORD_EACH_GAME) != 0)
-#define SETUP_2ND_JOYSTICK_ON(x)       (((x) & SETUP_2ND_JOYSTICK) != 0)
-
 void DrawMainMenu();
 void HandleMainMenu(int, int, int, int, int);
 void DrawHelpScreenElAction(int);
 void DrawHelpScreenElText(int);
 void DrawHelpScreenMusicText(int);
-void DrawHelpScreenRegistrationText(void);
+void DrawHelpScreenCreditsText(void);
 void DrawHelpScreen();
 void HandleHelpScreen(int);
 void HandleTypeName(int, KeySym);
@@ -59,14 +32,9 @@ void DrawHallOfFame(int);
 void HandleHallOfFame(int);
 void DrawSetupScreen();
 void HandleSetupScreen(int, int, int, int, int);
+void CalibrateJoystick(void);
 void HandleVideoButtons(int, int, int);
 void HandleSoundButtons(int, int, int);
 void HandleGameButtons(int, int, int);
-int CheckVideoButtons(int, int, int);
-int CheckSoundButtons(int, int, int);
-int CheckGameButtons(int, int, int);
-int CheckChooseButtons(int, int, int);
-int CheckConfirmButton(int, int, int);
-void DrawCompleteVideoDisplay(void);
 
 #endif
index b234a89..dc14ad5 100644 (file)
@@ -10,8 +10,6 @@
 *               q99492@pbhrzx.uni-paderborn.de             *
 *----------------------------------------------------------*
 *  sound.c                                                 *
-*                                                          *
-*  Letzte Aenderung: 15.06.1995                            *
 ***********************************************************/
 
 #include "sound.h"
index be853f8..384f77c 100644 (file)
@@ -10,8 +10,6 @@
 *               q99492@pbhrzx.uni-paderborn.de             *
 *----------------------------------------------------------*
 *  sound.c                                                 *
-*                                                          *
-*  Letzte Aenderung: 15.06.1995                            *
 ***********************************************************/
 
 #ifndef SOUND_H
 extern void ioctl(long, long, void *);
 #endif
 
+#ifdef __FreeBSD__
+#include <machine/soundcard.h>
+#endif
+
 #define SND_BLOCKSIZE 4096
 
 #ifdef _HPUX_SOURCE
index f1d2e25..625159f 100644 (file)
 *               q99492@pbhrzx.uni-paderborn.de             *
 *----------------------------------------------------------*
 *  tools.c                                                 *
-*                                                          *
-*  Letzte Aenderung: 15.06.1995                            *
 ***********************************************************/
 
+#ifdef __FreeBSD__
+#include <machine/joystick.h>
+#endif
+
 #include "tools.h"
 #include "game.h"
 #include "events.h"
 #include "sound.h"
-#include "screens.h"
 #include "misc.h"
+#include "buttons.h"
+#include <math.h>
 
 void BackToFront()
 {
@@ -116,6 +119,35 @@ void FadeToFront()
 
   if (fading_on && (redraw_mask & REDRAW_FIELD))
   {
+
+/*
+    int x,y;
+
+    XFillRectangle(display,window,gc,
+                  REAL_SX,REAL_SY,FULL_SXSIZE,FULL_SYSIZE);
+    XFlush(display);
+
+    for(i=0;i<2*FULL_SYSIZE;i++)
+    {
+      for(y=0;y<FULL_SYSIZE;y++)
+      {
+       XCopyArea(display,backbuffer,window,gc,
+                 REAL_SX,REAL_SY+i, FULL_SXSIZE,1, REAL_SX,REAL_SY+i);
+      }
+      XFlush(display);
+      Delay(10000);
+    }
+*/
+
+/*
+    for(i=1;i<FULL_SYSIZE;i+=2)
+      XCopyArea(display,backbuffer,window,gc,
+               REAL_SX,REAL_SY+i, FULL_SXSIZE,1, REAL_SX,REAL_SY+i);
+    XFlush(display);
+    Delay(fading_delay);
+*/
+
+
     XSetClipOrigin(display,clip_gc[PIX_FADEMASK],0,0);
     XCopyArea(display,backbuffer,window,clip_gc[PIX_FADEMASK],
              REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE, REAL_SX,REAL_SY);
@@ -310,95 +342,6 @@ void DrawMiniGraphicExtHiRes(Drawable d, GC gc, int x, int y, int graphic)
   }
 }
 
-int el2gfx(int element)
-{
-  switch(element)
-  {
-    case EL_LEERRAUM:          return(-1);
-    case EL_ERDREICH:          return(GFX_ERDREICH);
-    case EL_MAUERWERK:         return(GFX_MAUERWERK);
-    case EL_FELSBODEN:         return(GFX_FELSBODEN);
-    case EL_FELSBROCKEN:       return(GFX_FELSBROCKEN);
-    case EL_SCHLUESSEL:                return(GFX_SCHLUESSEL);
-    case EL_EDELSTEIN:         return(GFX_EDELSTEIN);
-    case EL_AUSGANG_ZU:                return(GFX_AUSGANG_ZU);
-    case EL_AUSGANG_ACT:       return(GFX_AUSGANG_ACT);
-    case EL_AUSGANG_AUF:       return(GFX_AUSGANG_AUF);
-    case EL_SPIELFIGUR:                return(GFX_SPIELFIGUR);
-    case EL_SPIELER1:          return(GFX_SPIELER1);
-    case EL_SPIELER2:          return(GFX_SPIELER2);
-    case EL_SPIELER3:          return(GFX_SPIELER3);
-    case EL_SPIELER4:          return(GFX_SPIELER4);
-    case EL_KAEFER:            return(GFX_KAEFER);
-    case EL_KAEFER_R:          return(GFX_KAEFER_R);
-    case EL_KAEFER_O:          return(GFX_KAEFER_O);
-    case EL_KAEFER_L:          return(GFX_KAEFER_L);
-    case EL_KAEFER_U:          return(GFX_KAEFER_U);
-    case EL_FLIEGER:           return(GFX_FLIEGER);
-    case EL_FLIEGER_R:         return(GFX_FLIEGER_R);
-    case EL_FLIEGER_O:         return(GFX_FLIEGER_O);
-    case EL_FLIEGER_L:         return(GFX_FLIEGER_L);
-    case EL_FLIEGER_U:         return(GFX_FLIEGER_U);
-    case EL_MAMPFER:           return(GFX_MAMPFER);
-    case EL_ZOMBIE:            return(GFX_ZOMBIE);
-    case EL_BETON:             return(GFX_BETON);
-    case EL_DIAMANT:           return(GFX_DIAMANT);
-    case EL_MORAST_LEER:       return(GFX_MORAST_LEER);
-    case EL_MORAST_VOLL:       return(GFX_MORAST_VOLL);
-    case EL_TROPFEN:           return(GFX_TROPFEN);
-    case EL_BOMBE:             return(GFX_BOMBE);
-    case EL_SIEB_LEER:         return(GFX_SIEB_LEER);
-    case EL_SIEB_VOLL:         return(GFX_SIEB_VOLL);
-    case EL_SIEB_TOT:          return(GFX_SIEB_TOT);
-    case EL_SALZSAEURE:                return(GFX_SALZSAEURE);
-    case EL_AMOEBE1:           return(GFX_AMOEBE1);
-    case EL_AMOEBE2:           return(GFX_AMOEBE2);
-    case EL_AMOEBE3:           return(GFX_AMOEBE3);
-    case EL_KOKOSNUSS:         return(GFX_KOKOSNUSS);
-    case EL_LIFE:              return(GFX_LIFE);
-    case EL_LIFE_ASYNC:                return(GFX_LIFE_ASYNC);
-    case EL_DYNAMIT:           return(GFX_DYNAMIT);
-    case EL_BADEWANNE:         return(GFX_BADEWANNE);
-    case EL_BADEWANNE1:                return(GFX_BADEWANNE1);
-    case EL_BADEWANNE2:                return(GFX_BADEWANNE2);
-    case EL_BADEWANNE3:                return(GFX_BADEWANNE3);
-    case EL_BADEWANNE4:                return(GFX_BADEWANNE4);
-    case EL_BADEWANNE5:                return(GFX_BADEWANNE5);
-    case EL_ABLENK_AUS:                return(GFX_ABLENK_AUS);
-    case EL_ABLENK_EIN:                return(GFX_ABLENK_EIN);
-    case EL_SCHLUESSEL1:       return(GFX_SCHLUESSEL1);
-    case EL_SCHLUESSEL2:       return(GFX_SCHLUESSEL2);
-    case EL_SCHLUESSEL3:       return(GFX_SCHLUESSEL3);
-    case EL_SCHLUESSEL4:       return(GFX_SCHLUESSEL4);
-    case EL_PFORTE1:           return(GFX_PFORTE1);
-    case EL_PFORTE2:           return(GFX_PFORTE2);
-    case EL_PFORTE3:           return(GFX_PFORTE3);
-    case EL_PFORTE4:           return(GFX_PFORTE4);
-    case EL_PFORTE1X:          return(GFX_PFORTE1X);
-    case EL_PFORTE2X:          return(GFX_PFORTE2X);
-    case EL_PFORTE3X:          return(GFX_PFORTE3X);
-    case EL_PFORTE4X:          return(GFX_PFORTE4X);
-    case EL_DYNAMIT_AUS:       return(GFX_DYNAMIT_AUS);
-    case EL_PACMAN:            return(GFX_PACMAN);
-    case EL_PACMAN_R:          return(GFX_PACMAN_R);
-    case EL_PACMAN_O:          return(GFX_PACMAN_O);
-    case EL_PACMAN_L:          return(GFX_PACMAN_L);
-    case EL_PACMAN_U:          return(GFX_PACMAN_U);
-    case EL_UNSICHTBAR:                return(GFX_UNSICHTBAR);
-    case EL_ERZ_1:             return(GFX_ERZ_1);
-    case EL_ERZ_2:             return(GFX_ERZ_2);
-    case EL_BIRNE_AUS:         return(GFX_BIRNE_AUS);
-    case EL_BIRNE_EIN:         return(GFX_BIRNE_EIN);
-    default:
-    {
-      if (IS_CHAR(element))
-       return(GFX_CHAR_START + (element-EL_CHAR_START));
-      else
-       return(-1);
-    }
-  }
-}
-
 void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, int cut_mode)
 {
   int width = TILEX, height = TILEY;
@@ -524,7 +467,7 @@ void DrawElementShifted(int x, int y, int dx, int dy, int element,int cut_mode)
   }
   else if (IS_AMOEBOID(element))
   {
-    graphic = (element==EL_AMOEBE1 ? GFX_AMOEBE_TOT : GFX_AMOEBE_LEBT);
+    graphic = (element==EL_AMOEBE_TOT ? GFX_AMOEBE_TOT : GFX_AMOEBE_LEBT);
     graphic += (x+2*y) % 4;
   }
 
@@ -682,7 +625,7 @@ void DrawScreenField(int x, int y)
 
     if (Store[ux][uy]==EL_MORAST_LEER ||
        Store[ux][uy]==EL_SIEB_LEER ||
-       Store[ux][uy]==EL_AMOEBE2)
+       Store[ux][uy]==EL_AMOEBE_NASS)
       cut_mode = CUT_ABOVE;
     else if (Store[ux][uy]==EL_MORAST_VOLL ||
        Store[ux][uy]==EL_SIEB_VOLL ||
@@ -713,7 +656,7 @@ void DrawScreenField(int x, int y)
 
     if (Store[oldx][oldy]==EL_MORAST_LEER ||
        Store[oldx][oldy]==EL_SIEB_LEER ||
-       Store[oldx][oldy]==EL_AMOEBE2)
+       Store[oldx][oldy]==EL_AMOEBE_NASS)
       cut_mode = CUT_ABOVE;
 
     DrawScreenElement(x,y,EL_LEERRAUM);
@@ -1072,9 +1015,9 @@ void CloseDoor(unsigned int door_state)
 
 void MoveDoor(unsigned int door_state)
 {
-  static int door1 = DOOR_CLOSE_1;
-  static int door2 = DOOR_OPEN_2;
-  int x, start, stepsize = 4;
+  static int door1 = DOOR_OPEN_1;
+  static int door2 = DOOR_CLOSE_2;
+  int x, start, stepsize = 4, door_anim_delay = stepsize*5000;
 
   if (door1==DOOR_OPEN_1 && door_state & DOOR_OPEN_1)
     door_state &= ~DOOR_OPEN_1;
@@ -1085,31 +1028,15 @@ void MoveDoor(unsigned int door_state)
   else if (door2==DOOR_CLOSE_2 && door_state & DOOR_CLOSE_2)
     door_state &= ~DOOR_CLOSE_2;
 
-  if (door_state & DOOR_ACTION)
+  if (quick_doors)
   {
-    if (door_state & DOOR_OPEN_1)
-    {
-      XCopyArea(display,pix[PIX_DOOR],pix[PIX_DOOR],gc,
-               104,136, 8,8, 146,136);
-      if (!(door_state & DOOR_NO_DELAY))
-      {
-       int i;
-
-       XCopyArea(display,pix[PIX_DOOR],window,gc,
-                 104,136, 8,8, DX+46,DY+136);
-       XFlush(display);
-       for(i=0;i<30;i++)
-       {
-         if (game_status==MAINMENU)
-           DoAnimation();
-         Delay(10000);
-       }
-      }
-    }
-    else if (door_state & DOOR_CLOSE_1)
-      XCopyArea(display,pix[PIX_DOOR],pix[PIX_DOOR],gc,
-               88,136, 8,8, 146,136);
+    stepsize = 20;
+    door_anim_delay = 0;
+    StopSound(SND_OEFFNEN);
+  }
 
+  if (door_state & DOOR_ACTION)
+  {
     if (!(door_state & DOOR_NO_DELAY))
       PlaySoundStereo(SND_OEFFNEN,PSND_MAX_RIGHT);
 
@@ -1120,6 +1047,7 @@ void MoveDoor(unsigned int door_state)
       if (door_state & DOOR_ACTION_1)
       {
        int i = (door_state & DOOR_OPEN_1 ? DXSIZE-x : x);
+       int j = (DXSIZE - i)/3;
 
        XCopyArea(display,pix[PIX_DB_DOOR],drawto,gc,
                  DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY1+i/2,
@@ -1127,31 +1055,41 @@ void MoveDoor(unsigned int door_state)
 
        XFillRectangle(display,drawto,gc,DX,DY+DYSIZE-i/2,DXSIZE,i/2);
 
-       XSetClipOrigin(display,clip_gc[PIX_DOOR],DX-DXSIZE+i,DY);
+       XSetClipOrigin(display,clip_gc[PIX_DOOR],
+                      DX-i,(DY+j)-DOOR_GFX_PAGEY1);
        XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
-                 DXSIZE-i,0, i,30, DX,DY);
+                 DXSIZE,DOOR_GFX_PAGEY1, i,77, DX+DXSIZE-i,DY+j);
        XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
-                 DXSIZE-i,DYSIZE-30, i,30, DX,DY+DYSIZE-30);
-       XSetClipOrigin(display,clip_gc[PIX_DOOR],DX-i,DY);
+                 DXSIZE,DOOR_GFX_PAGEY1+140, i,63, DX+DXSIZE-i,DY+140+j);
+       XSetClipOrigin(display,clip_gc[PIX_DOOR],
+                      DX-DXSIZE+i,DY-(DOOR_GFX_PAGEY1+j));
        XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
-                 DXSIZE,0, i,30, DX+DXSIZE-i,DY);
+                 DXSIZE-i,DOOR_GFX_PAGEY1+j, i,77-j, DX,DY);
        XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
-                 DXSIZE,DYSIZE-30, i,30, DX+DXSIZE-i,DY+DYSIZE-30);
-       if (i>14)
-       {
-         XSetClipOrigin(display,clip_gc[PIX_DOOR],DX-i,DY);
-         XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
-                   DXSIZE+14,30,i-14,DYSIZE-60,DX+DXSIZE+14-i,DY+30);
-         XSetClipOrigin(display,clip_gc[PIX_DOOR],DX-DXSIZE+i,DY);
-         XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
-                   DXSIZE-i,30,i-14,DYSIZE-60,DX,DY+30);
-       }
+                 DXSIZE-i,DOOR_GFX_PAGEY1+140, i,63, DX,DY+140-j);
+
+       XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
+                 DXSIZE-i,DOOR_GFX_PAGEY1+77, i,63,
+                 DX,DY+77-j);
+       XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
+                 DXSIZE-i,DOOR_GFX_PAGEY1+203, i,77,
+                 DX,DY+203-j);
+       XSetClipOrigin(display,clip_gc[PIX_DOOR],
+                      DX-i,(DY+j)-DOOR_GFX_PAGEY1);
+       XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
+                 DXSIZE,DOOR_GFX_PAGEY1+77, i,63,
+                 DX+DXSIZE-i,DY+77+j);
+       XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
+                 DXSIZE,DOOR_GFX_PAGEY1+203, i,77-j,
+                 DX+DXSIZE-i,DY+203+j);
+
        redraw_mask |= REDRAW_DOOR_1;
       }
 
       if (door_state & DOOR_ACTION_2)
       {
        int i = (door_state & DOOR_OPEN_2 ? VXSIZE-x : x);
+       int j = (VXSIZE - i)/3;
 
        XCopyArea(display,pix[PIX_DB_DOOR],drawto,gc,
                  DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY2+i/2,
@@ -1160,19 +1098,28 @@ void MoveDoor(unsigned int door_state)
        XFillRectangle(display,drawto,gc,VX,VY+VYSIZE-i/2,VXSIZE,i/2);
 
        XSetClipOrigin(display,clip_gc[PIX_DOOR],
-                      VX-VXSIZE+i,VY-DOOR_GFX_PAGEY2);
+                      VX-i,(VY+j)-DOOR_GFX_PAGEY2);
+       XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
+                 VXSIZE,DOOR_GFX_PAGEY2, i,VYSIZE/2, VX+VXSIZE-i,VY+j);
+       XSetClipOrigin(display,clip_gc[PIX_DOOR],
+                      VX-VXSIZE+i,VY-(DOOR_GFX_PAGEY2+j));
+       XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
+                 VXSIZE-i,DOOR_GFX_PAGEY2+j, i,VYSIZE/2-j, VX,VY);
+
        XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
-                 VXSIZE-i,DOOR_GFX_PAGEY2, i,VYSIZE, VX,VY);
+                 VXSIZE-i,DOOR_GFX_PAGEY2+VYSIZE/2, i,VYSIZE/2,
+                 VX,VY+VYSIZE/2-j);
        XSetClipOrigin(display,clip_gc[PIX_DOOR],
-                      VX-i,VY-DOOR_GFX_PAGEY2);
+                      VX-i,(VY+j)-DOOR_GFX_PAGEY2);
        XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR],
-                 VXSIZE,DOOR_GFX_PAGEY2, i,VYSIZE, VX+VXSIZE-i,VY);
+                 VXSIZE,DOOR_GFX_PAGEY2+VYSIZE/2, i,VYSIZE/2-j,
+                 VX+VXSIZE-i,VY+VYSIZE/2+j);
 
        redraw_mask |= REDRAW_DOOR_2;
       }
 
       BackToFront();
-      Delay(stepsize*5000);
+      Delay(door_anim_delay);
 
       if (game_status==MAINMENU)
        DoAnimation();
@@ -1185,74 +1132,6 @@ void MoveDoor(unsigned int door_state)
     door2 = door_state & DOOR_ACTION_2;
 }
 
-long mainCounter(int mode)
-{
-  static struct timeval base_time = { 0, 0 };
-  struct timeval current_time;
-  long counter_ms;
-
-  gettimeofday(&current_time,NULL);
-  if (mode==0 || current_time.tv_sec<base_time.tv_sec)
-    base_time = current_time;
-
-  counter_ms = (current_time.tv_sec - base_time.tv_sec)*1000
-             + (current_time.tv_usec - base_time.tv_usec)/1000;
-
-  if (mode==1)
-    return(counter_ms/10);     /* return 1/100 secs since last init */
-  else
-    return(counter_ms);                /* return 1/1000 secs since last init */
-}
-
-void InitCounter() /* set counter back to zero */
-{
-  mainCounter(0);
-}
-
-long Counter() /* returns 1/100 secs since last call of InitCounter() */
-{
-  return(mainCounter(1));
-}
-
-long Counter2()        /* returns 1/1000 secs since last call of InitCounter() */
-{
-  return(mainCounter(2));
-}
-
-void WaitCounter(long value)   /* wait for counter to reach value */
-{
-  long wait;
-
-  while((wait=value-Counter())>0)
-    microsleep(wait*10000);
-}
-
-void WaitCounter2(long value)  /* wait for counter to reach value */
-{
-  long wait;
-
-  while((wait=value-Counter2())>0)
-    microsleep(wait*1000);
-}
-
-void Delay(long value)
-{
-  microsleep(value);
-}
-
-BOOL DelayReached(long *counter_var, int delay)
-{
-  long actual_counter = Counter();
-
-  if (actual_counter>*counter_var+delay || actual_counter<*counter_var)
-  {
-    *counter_var = actual_counter;
-    return(TRUE);
-  }
-  else
-    return(FALSE);
-}
-
 int ReadPixel(Drawable d, int x, int y)
 {
   static XImage *pixelimage;
@@ -1261,78 +1140,6 @@ int ReadPixel(Drawable d, int x, int y)
   return(XGetPixel(pixelimage,0,0));
 }
 
-static struct JoystickInfo joystick[2] =
-{
-  JOYSTICK_XLEFT, JOYSTICK_XRIGHT, JOYSTICK_XMIDDLE,
-  JOYSTICK_YUPPER, JOYSTICK_YLOWER, JOYSTICK_YMIDDLE,
-
-  JOYSTICK_XLEFT, JOYSTICK_XRIGHT, JOYSTICK_XMIDDLE,
-  JOYSTICK_YUPPER, JOYSTICK_YLOWER, JOYSTICK_YMIDDLE
-};
-
-void LoadJoystickData()
-{
-  int i;
-  char cookie[256];
-  FILE *file;
-
-  if (joystick_status==JOYSTICK_OFF)
-    return;
-
-  if (!(file=fopen(JOYDAT_FILE,"r")))
-    return;
-
-  fscanf(file,"%s",cookie);
-  if (strcmp(cookie,JOYSTICK_COOKIE))  /* ungültiges Format? */
-  {
-    fprintf(stderr,"%s: wrong format of joystick file!\n",progname);
-    fclose(file);
-    return;
-  }
-
-  for(i=0;i<2;i++)
-  {
-    fscanf(file,"%s",cookie);
-    fscanf(file, "%d %d %d \n",
-          &joystick[i].xleft, &joystick[i].xmiddle, &joystick[i].xright);
-    fscanf(file, "%d %d %d \n",
-          &joystick[i].yupper, &joystick[i].ymiddle, &joystick[i].ylower);
-  }
-  fclose(file);
-
-  CheckJoystickData();
-}
-
-void SaveJoystickData()
-{
-  int i;
-  FILE *file;
-
-  if (joystick_status==JOYSTICK_OFF)
-    return;
-
-  CheckJoystickData();
-
-  if (!(file=fopen(JOYDAT_FILE,"w")))
-  {
-    fprintf(stderr,"%s: cannot save joystick calibration data!\n",progname);
-    return;
-  }
-
-  fprintf(file,"%s\n",JOYSTICK_COOKIE);        /* Formatkennung */
-  for(i=0;i<2;i++)
-  {
-    fprintf(file,"JOYSTICK_%d_DATA\n",i);
-    fprintf(file, "%d %d %d \n",
-           joystick[i].xleft, joystick[i].xmiddle, joystick[i].xright);
-    fprintf(file, "%d %d %d \n",
-           joystick[i].yupper, joystick[i].ymiddle, joystick[i].ylower);
-  }
-  fclose(file);
-
-  chmod(JOYDAT_FILE, JOYDAT_PERMS);
-}
-
 void CheckJoystickData()
 {
   int i;
@@ -1367,23 +1174,27 @@ int JoystickPosition(int middle, int margin, int actual)
   if (margin>middle && actual<middle)
     return(0);
 
-  range=ABS(margin-middle);
-  pos=ABS(actual-middle);
-  percentage=(int)(pos*100/range);
+  range = ABS(margin-middle);
+  pos = ABS(actual-middle);
+  percentage = (int)(pos*100/range);
   if (percentage>100)
-    percentage=100;
+    percentage = 100;
 
   return(percentage);
 }
 
 int Joystick()
 {
+#ifdef __FreeBSD__
+  struct joystick joy_ctrl;
+#else
   struct joystick_control
   {
     int buttons;
     int x;
     int y;
   } joy_ctrl;
+#endif
 
   int js_x,js_y, js_b1,js_b2;
   int left, right, up, down;
@@ -1394,15 +1205,21 @@ int Joystick()
 
   if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
   {
-    fprintf(stderr,"%s: cannot read joystick settings - no joystick support\n",progname);
+    fprintf(stderr,"%s: cannot read joystick settings - no joystick support\n",
+           progname);
     joystick_status = JOYSTICK_OFF;
     return(0);
   }
 
   js_x  = joy_ctrl.x;
   js_y  = joy_ctrl.y;
+#ifdef __FreeBSD__
+  js_b1 = joy_ctrl.b1;
+  js_b2 = joy_ctrl.b2;
+#else
   js_b1 = joy_ctrl.buttons & 1;
   js_b2 = joy_ctrl.buttons & 2;
+#endif
 
   left = JoystickPosition(joystick[joystick_nr].xmiddle,
                          joystick[joystick_nr].xleft,  js_x);
@@ -1431,124 +1248,118 @@ int Joystick()
 
 int JoystickButton()
 {
-  static int last_joy_button=0;
-  int joy_button=(Joystick() & JOY_BUTTON);
+  static int last_joy_button = 0;
+  int joy_button = (Joystick() & JOY_BUTTON);
   int result;
 
   if (joy_button)
   {
     if (last_joy_button)
-      result=JOY_BUTTON_PRESSED;
+      result = JOY_BUTTON_PRESSED;
     else
-      result=JOY_BUTTON_NEW_PRESSED;
+      result = JOY_BUTTON_NEW_PRESSED;
   }
   else
   {
     if (last_joy_button)
-      result=JOY_BUTTON_NEW_RELEASED;
+      result = JOY_BUTTON_NEW_RELEASED;
     else
-      result=JOY_BUTTON_NOT_PRESSED;
+      result = JOY_BUTTON_NOT_PRESSED;
   }
 
   last_joy_button = joy_button;
   return(result);
 }
 
-void CalibrateJoystick()
+int el2gfx(int element)
 {
-  struct joystick_control
-  {
-    int buttons;
-    int x;
-    int y;
-  } joy_ctrl;
-
-  int new_joystick_xleft, new_joystick_xright, new_joystick_xmiddle;
-  int new_joystick_yupper, new_joystick_ylower, new_joystick_ymiddle;
-
-  if (joystick_status==JOYSTICK_OFF)
-    goto error_out;
-
-  ClearWindow();
-  DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
-  DrawText(SX+16, SY+8*32, " THE UPPER LEFT ",FS_BIG,FC_YELLOW);
-  DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
-  BackToFront();
-
-  joy_ctrl.buttons = 0;
-  while(Joystick() & JOY_BUTTON);
-  while(!joy_ctrl.buttons)
-  {
-    if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
-    {
-      joystick_status=JOYSTICK_OFF;
-      goto error_out;
-    }
-    Delay(10000);
-  }
-
-  new_joystick_xleft = joy_ctrl.x;
-  new_joystick_yupper = joy_ctrl.y;
-
-  ClearWindow();
-  DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
-  DrawText(SX+32, SY+8*32, "THE LOWER RIGHT",FS_BIG,FC_YELLOW);
-  DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
-  BackToFront();
-
-  joy_ctrl.buttons = 0;
-  while(Joystick() & JOY_BUTTON);
-  while(!joy_ctrl.buttons)
-  {
-    if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
-    {
-      joystick_status=JOYSTICK_OFF;
-      goto error_out;
-    }
-    Delay(10000);
-  }
-
-  new_joystick_xright = joy_ctrl.x;
-  new_joystick_ylower = joy_ctrl.y;
-
-  ClearWindow();
-  DrawText(SX+32, SY+16+7*32, "CENTER JOYSTICK",FS_BIG,FC_YELLOW);
-  DrawText(SX+16, SY+16+8*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
-  BackToFront();
-
-  joy_ctrl.buttons = 0;
-  while(Joystick() & JOY_BUTTON);
-  while(!joy_ctrl.buttons)
+  switch(element)
   {
-    if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
+    case EL_LEERRAUM:          return(-1);
+    case EL_ERDREICH:          return(GFX_ERDREICH);
+    case EL_MAUERWERK:         return(GFX_MAUERWERK);
+    case EL_FELSBODEN:         return(GFX_FELSBODEN);
+    case EL_FELSBROCKEN:       return(GFX_FELSBROCKEN);
+    case EL_SCHLUESSEL:                return(GFX_SCHLUESSEL);
+    case EL_EDELSTEIN:         return(GFX_EDELSTEIN);
+    case EL_AUSGANG_ZU:                return(GFX_AUSGANG_ZU);
+    case EL_AUSGANG_ACT:       return(GFX_AUSGANG_ACT);
+    case EL_AUSGANG_AUF:       return(GFX_AUSGANG_AUF);
+    case EL_SPIELFIGUR:                return(GFX_SPIELFIGUR);
+    case EL_SPIELER1:          return(GFX_SPIELER1);
+    case EL_SPIELER2:          return(GFX_SPIELER2);
+    case EL_SPIELER3:          return(GFX_SPIELER3);
+    case EL_SPIELER4:          return(GFX_SPIELER4);
+    case EL_KAEFER:            return(GFX_KAEFER);
+    case EL_KAEFER_R:          return(GFX_KAEFER_R);
+    case EL_KAEFER_O:          return(GFX_KAEFER_O);
+    case EL_KAEFER_L:          return(GFX_KAEFER_L);
+    case EL_KAEFER_U:          return(GFX_KAEFER_U);
+    case EL_FLIEGER:           return(GFX_FLIEGER);
+    case EL_FLIEGER_R:         return(GFX_FLIEGER_R);
+    case EL_FLIEGER_O:         return(GFX_FLIEGER_O);
+    case EL_FLIEGER_L:         return(GFX_FLIEGER_L);
+    case EL_FLIEGER_U:         return(GFX_FLIEGER_U);
+    case EL_MAMPFER:           return(GFX_MAMPFER);
+    case EL_ZOMBIE:            return(GFX_ZOMBIE);
+    case EL_BETON:             return(GFX_BETON);
+    case EL_DIAMANT:           return(GFX_DIAMANT);
+    case EL_MORAST_LEER:       return(GFX_MORAST_LEER);
+    case EL_MORAST_VOLL:       return(GFX_MORAST_VOLL);
+    case EL_TROPFEN:           return(GFX_TROPFEN);
+    case EL_BOMBE:             return(GFX_BOMBE);
+    case EL_SIEB_LEER:         return(GFX_SIEB_LEER);
+    case EL_SIEB_VOLL:         return(GFX_SIEB_VOLL);
+    case EL_SIEB_TOT:          return(GFX_SIEB_TOT);
+    case EL_SALZSAEURE:                return(GFX_SALZSAEURE);
+    case EL_AMOEBE_TOT:                return(GFX_AMOEBE_TOT);
+    case EL_AMOEBE_NASS:       return(GFX_AMOEBE_NASS);
+    case EL_AMOEBE_NORM:       return(GFX_AMOEBE_NORM);
+    case EL_AMOEBE_VOLL:       return(GFX_AMOEBE_VOLL);
+    case EL_AMOEBA2DIAM:       return(GFX_AMOEBA2DIAM);
+    case EL_KOKOSNUSS:         return(GFX_KOKOSNUSS);
+    case EL_LIFE:              return(GFX_LIFE);
+    case EL_LIFE_ASYNC:                return(GFX_LIFE_ASYNC);
+    case EL_DYNAMIT:           return(GFX_DYNAMIT);
+    case EL_BADEWANNE:         return(GFX_BADEWANNE);
+    case EL_BADEWANNE1:                return(GFX_BADEWANNE1);
+    case EL_BADEWANNE2:                return(GFX_BADEWANNE2);
+    case EL_BADEWANNE3:                return(GFX_BADEWANNE3);
+    case EL_BADEWANNE4:                return(GFX_BADEWANNE4);
+    case EL_BADEWANNE5:                return(GFX_BADEWANNE5);
+    case EL_ABLENK_AUS:                return(GFX_ABLENK_AUS);
+    case EL_ABLENK_EIN:                return(GFX_ABLENK_EIN);
+    case EL_SCHLUESSEL1:       return(GFX_SCHLUESSEL1);
+    case EL_SCHLUESSEL2:       return(GFX_SCHLUESSEL2);
+    case EL_SCHLUESSEL3:       return(GFX_SCHLUESSEL3);
+    case EL_SCHLUESSEL4:       return(GFX_SCHLUESSEL4);
+    case EL_PFORTE1:           return(GFX_PFORTE1);
+    case EL_PFORTE2:           return(GFX_PFORTE2);
+    case EL_PFORTE3:           return(GFX_PFORTE3);
+    case EL_PFORTE4:           return(GFX_PFORTE4);
+    case EL_PFORTE1X:          return(GFX_PFORTE1X);
+    case EL_PFORTE2X:          return(GFX_PFORTE2X);
+    case EL_PFORTE3X:          return(GFX_PFORTE3X);
+    case EL_PFORTE4X:          return(GFX_PFORTE4X);
+    case EL_DYNAMIT_AUS:       return(GFX_DYNAMIT_AUS);
+    case EL_PACMAN:            return(GFX_PACMAN);
+    case EL_PACMAN_R:          return(GFX_PACMAN_R);
+    case EL_PACMAN_O:          return(GFX_PACMAN_O);
+    case EL_PACMAN_L:          return(GFX_PACMAN_L);
+    case EL_PACMAN_U:          return(GFX_PACMAN_U);
+    case EL_UNSICHTBAR:                return(GFX_UNSICHTBAR);
+    case EL_ERZ_EDEL:          return(GFX_ERZ_EDEL);
+    case EL_ERZ_DIAM:          return(GFX_ERZ_DIAM);
+    case EL_BIRNE_AUS:         return(GFX_BIRNE_AUS);
+    case EL_BIRNE_EIN:         return(GFX_BIRNE_EIN);
+    case EL_ZEIT_VOLL:         return(GFX_ZEIT_VOLL);
+    case EL_ZEIT_LEER:         return(GFX_ZEIT_LEER);
+    default:
     {
-      joystick_status=JOYSTICK_OFF;
-      goto error_out;
+      if (IS_CHAR(element))
+       return(GFX_CHAR_START + (element-EL_CHAR_START));
+      else
+       return(-1);
     }
-    Delay(10000);
   }
-
-  new_joystick_xmiddle = joy_ctrl.x;
-  new_joystick_ymiddle = joy_ctrl.y;
-
-  joystick[joystick_nr].xleft = new_joystick_xleft;
-  joystick[joystick_nr].yupper = new_joystick_yupper;
-  joystick[joystick_nr].xright = new_joystick_xright;
-  joystick[joystick_nr].ylower = new_joystick_ylower;
-  joystick[joystick_nr].xmiddle = new_joystick_xmiddle;
-  joystick[joystick_nr].ymiddle = new_joystick_ymiddle;
-
-  CheckJoystickData();
-
-  DrawSetupScreen();
-  while(Joystick() & JOY_BUTTON);
-  return;
-
-  error_out:
-
-  ClearWindow();
-  DrawText(SX+16, SY+16, "NO JOYSTICK",FS_BIG,FC_YELLOW);
-  DrawText(SX+16, SY+48, " AVAILABLE ",FS_BIG,FC_YELLOW);
-  Delay(3000000);
-  DrawSetupScreen();
 }
index b3fa84e..bec2205 100644 (file)
@@ -10,8 +10,6 @@
 *               q99492@pbhrzx.uni-paderborn.de             *
 *----------------------------------------------------------*
 *  tools.h                                                 *
-*                                                          *
-*  Letzte Aenderung: 15.06.1995                            *
 ***********************************************************/
 
 #ifndef TOOLS_H
@@ -62,7 +60,6 @@ void DrawElementThruMask(int, int, int);
 void DrawMiniGraphic(int, int, int);
 void DrawMiniGraphicExt(Drawable, GC, int, int, int);
 void DrawMiniGraphicExtHiRes(Drawable, GC, int, int, int);
-int el2gfx(int);
 void DrawGraphicShifted(int, int, int, int, int, int);
 void DrawElementShifted(int, int, int, int, int, int);
 void ErdreichAnbroeckeln(int, int);
@@ -80,22 +77,11 @@ BOOL AreYouSure(char *, unsigned int);
 void OpenDoor(unsigned int);
 void CloseDoor(unsigned int);
 void MoveDoor(unsigned int);
-long mainCounter(int);
-void InitCounter(void);
-long Counter(void);
-long Counter2(void);
-void WaitCounter(long);
-void WaitCounter2(long);
-void Delay(long);
-BOOL DelayReached(long *, int);
 int ReadPixel(Drawable, int, int);
-int el2gfx(int);
-void LoadJoystickData(void);
-void SaveJoystickData(void);
 void CheckJoystickData(void);
 int JoystickPosition(int, int, int);
 int Joystick(void);
 int JoystickButton(void);
-void CalibrateJoystick(void);
+int el2gfx(int);
 
 #endif