rnd-20010715-1-src
authorHolger Schemel <info@artsoft.org>
Sun, 15 Jul 2001 15:47:27 +0000 (17:47 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:36:00 +0000 (10:36 +0200)
Makefile
src/Makefile
src/game.c

index a4db1d9dc90ee599842e812c5a4241e3caba8171..4da272c5b5d28980543322dc1ecb5335373f4406 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -57,7 +57,10 @@ sdl:
        @$(MAKE_CMD) TARGET=sdl
 
 solaris:
-       @$(MAKE_CMD) PLATFORM=solaris
+       @$(MAKE_CMD) PLATFORM=solaris TARGET=x11
+
+solaris-sdl:
+       @$(MAKE_CMD) PLATFORM=solaris TARGET=sdl
 
 msdos:
        @$(MAKE_CMD) PLATFORM=msdos
index 21c753a3a715ccd3ffd3da6619a1939f5224fbd4..3269ec511fb22024e3707d44f0496ddd932cc87a 100644 (file)
@@ -23,10 +23,15 @@ endif
 AR = ar
 RANLIB = ranlib
 
+BMP2ICO = bmp2ico
+WINDRES = windres
+
 ifeq ($(PLATFORM),msdos)       # MS-DOS native compiling
 
 RM = del
-PROGNAME = ../rocks.exe
+
+PROGBASE = rocks
+PROGNAME = ../$(PROGBASE).exe
 
 SYS_CFLAGS = -DTARGET_X11
 SYS_LDFLAGS = -s -lalleg
@@ -34,7 +39,9 @@ SYS_LDFLAGS = -s -lalleg
 else                           # Unix or cross-compiling for MS-DOS and Win32
 
 RM = rm -f
-PROGNAME = ../rocksndiamonds
+
+PROGBASE = rocksndiamonds
+PROGNAME = ../$(PROGBASE)
 
 ifeq ($(PLATFORM),solaris)
 EXTRA_LDFLAGS = -lnsl -lsocket -R$(XLIB_PATH)
@@ -46,12 +53,13 @@ PROFILING_FLAGS = -pg
 endif
 
 ifeq ($(PLATFORM),cross-msdos)
-PROGNAME = ../rocks.exe
+PROGBASE = rocks
+PROGNAME = ../$(PROGBASE).exe
 TARGET = allegro
 endif
 
 ifeq ($(PLATFORM),cross-win32)
-PROGNAME = ../rocksndiamonds.exe
+PROGNAME = ../$(PROGBASE).exe
 TARGET = sdl
 endif
 
@@ -135,15 +143,25 @@ OBJS =    main.o          \
 LIBDIR = libgame
 LIBGAME = $(LIBDIR)/libgame.a
 
+ICONBASE = windows_icon
+ifeq ($(PLATFORM),cross-win32)
+ICON32X32 = ../graphics/$(ICONBASE)_32x32.bmp
+ICON = $(ICONBASE).o
+endif
+
 
 all: $(PROGNAME)
 
-$(PROGNAME): $(LIBGAME) $(OBJS)
-       $(CC) $(PROFILING) $(OBJS) $(LIBGAME) $(LDFLAGS) -o $(PROGNAME)
+$(PROGNAME): $(LIBGAME) $(OBJS) $(ICON)
+       $(CC) $(PROFILING) $(OBJS) $(ICON) $(LIBGAME) $(LDFLAGS) -o $(PROGNAME)
 
 $(LIBGAME):
        $(MAKE) -C $(LIBDIR)
 
+$(ICON):
+       $(BMP2ICO) -transparent $(ICONBASE).ico $(ICON32X32)
+       echo "$(ICONBASE) ICON $(ICONBASE).ico" | $(WINDRES) -o $(ICON)
+
 .c.o:
        $(CC) $(PROFILING) $(CFLAGS) -c $*.c
 
@@ -152,11 +170,15 @@ clean-obj:
        $(RM) $(OBJS)
        $(RM) $(LIBGAME)
 
+clean-ico:
+       $(RM) $(ICONBASE).ico
+       $(RM) $(ICONBASE).o
+
 clean-bin:
        $(RM) $(PROGNAME)
        $(RM) ../*.exe
 
-clean: clean-obj clean-bin
+clean: clean-obj clean-ico clean-bin
 
 
 #-----------------------------------------------------------------------------#
index 3db4e1bc77d9d44717e3c7e1b913be7b625fbe07..37608e5d5152f84946ad85f2d1c5e92a344d5606 100644 (file)
@@ -4292,6 +4292,51 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action)
   }
 }
 
+static void sleep_milliseconds_x(unsigned long milliseconds_delay)
+{
+  boolean do_busy_waiting = (milliseconds_delay < 5 ? TRUE : FALSE);
+
+#if defined(PLATFORM_MSDOS)
+  /* don't use select() to perform waiting operations under DOS/Windows
+     environment; always use a busy loop for waiting instead */
+  do_busy_waiting = TRUE;
+#endif
+
+
+
+  do_busy_waiting = TRUE;
+
+
+
+  if (do_busy_waiting)
+  {
+    /* we want to wait only a few ms -- if we assume that we have a
+       kernel timer resolution of 10 ms, we would wait far to long;
+       therefore it's better to do a short interval of busy waiting
+       to get our sleeping time more accurate */
+
+    unsigned long base_counter = Counter(), actual_counter = Counter();
+
+    while (actual_counter < base_counter + milliseconds_delay &&
+          actual_counter >= base_counter)
+      actual_counter = Counter();
+  }
+  else
+  {
+#if defined(TARGET_SDL)
+    SDL_Delay(milliseconds_delay);
+#else
+    struct timeval delay;
+
+    delay.tv_sec  = milliseconds_delay / 1000;
+    delay.tv_usec = 1000 * (milliseconds_delay % 1000);
+
+    if (select(0, NULL, NULL, NULL, &delay) != 0)
+      Error(ERR_WARN, "sleep_milliseconds(): select() failed");
+#endif
+  }
+}
+
 void GameActions()
 {
   static unsigned long action_delay = 0;
@@ -4309,7 +4354,45 @@ void GameActions()
 
   /* ---------- main game synchronization point ---------- */
 
-  WaitUntilDelayReached(&action_delay, action_delay_value);
+
+
+#if 1
+    WaitUntilDelayReached(&action_delay, action_delay_value);
+#else
+  {
+    unsigned long count1 = SDL_GetTicks(), count2, current_ms, test;
+
+    /*
+    WaitUntilDelayReached(&action_delay, action_delay_value);
+    */
+
+    /*
+    SDL_Delay(20);
+    */
+
+    /*
+    sleep_milliseconds_x(20);
+    */
+
+    current_ms = SDL_GetTicks();
+    test = -1;
+    while (current_ms < count1 + 20)
+    {
+      current_ms = SDL_GetTicks();             /* busy wait! */
+
+      if (test != current_ms)
+      {
+       Error(ERR_RETURN, "current_ms == %ld", current_ms);
+       test = current_ms;
+      }
+    }
+
+    count2 = SDL_GetTicks();
+    Error(ERR_RETURN, "delay == %ld", count2 - count1);
+  }
+#endif
+
+
 
   if (network_playing && !network_player_action_received)
   {