Import uqm 0.2; submitted by Jolan Luff <jolan@cryptonomicon.org>

The Ur-Quan Masters is an SDL-based port of the 3DO version of the
popular game Star Control 2.
This commit is contained in:
wilfried 2003-04-11 09:12:52 +00:00
parent dfd02bf536
commit 0b538d3bd2
14 changed files with 555 additions and 0 deletions

52
games/uqm/Makefile Normal file
View File

@ -0,0 +1,52 @@
# $OpenBSD: Makefile,v 1.1.1.1 2003/04/11 09:12:52 wilfried Exp $
ONLY_FOR_ARCHS= i386 macppc
COMMENT= "ur-quan masters: sdl port of star control 2"
DISTNAME= uqm-0.2-source
EXTRACT_SUFX= .tgz
PKGNAME= uqm-0.2
CATEGORIES= games x11
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=sc2/}
HOMEPAGE= http://sc2.sourceforge.net/
MAINTAINER= Jolan Luff <jolan@cryptonomicon.org>
# GPL
PERMIT_PACKAGE_CDROM= Yes
PERMIT_PACKAGE_FTP= Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
LIB_DEPENDS= SDL_image::devel/sdl-image \
vorbis.0,vorbisfile.1::audio/libvorbis
RUN_DEPENDS= :uqmcontent-*:games/uqmcontent
NO_REGRESS= Yes
USE_GMAKE= Yes
USE_X11= Yes
do-configure:
.if (${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "i386" || \
${MACHINE_ARCH} == "vax")
@sed -e "s|@PREFIX@|${PREFIX}|g" ${FILESDIR}/config.h-lilendian \
> ${WRKSRC}/src/config.h
.else
@sed -e "s|@PREFIX@|${PREFIX}|g" ${FILESDIR}/config.h-bigendian \
> ${WRKSRC}/src/config.h
.endif
@sed -e "s|@CC@|${CC}|g ; s|@CFLAGS@|${CFLAGS}|g ; \
s|@LOCALBASE@|${LOCALBASE}|g ; s|@PREFIX@|${PREFIX}|g ; \
s|@X11BASE@|${X11BASE}|g" ${FILESDIR}/build.vars \
> ${WRKSRC}/build.vars
do-build:
cd ${WRKSRC}; ./build.sh uqm
do-install:
${INSTALL_DATA_DIR} ${PREFIX}/share/doc/uqm
${INSTALL_DATA} ${WRKSRC}/doc/users/manual.txt ${PREFIX}/share/doc/uqm
${INSTALL_PROGRAM} ${WRKSRC}/uqm ${PREFIX}/bin
.include <bsd.port.mk>

3
games/uqm/distinfo Normal file
View File

@ -0,0 +1,3 @@
MD5 (uqm-0.2-source.tgz) = 8b95dda6ed73802cee18a44f56322076
RMD160 (uqm-0.2-source.tgz) = 453065429cb7d90194b6922ff36f27fdd5413988
SHA1 (uqm-0.2-source.tgz) = 031d9d6041768ddf4ee63fe3e0760d9b72c78864

View File

@ -0,0 +1,33 @@
# Variables for the build procedure
# Copyright (c) 2002 Serge van den Boom
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
COMPILE="@CC@"
MKDEPEND="@CC@ -MM"
MAKE="gmake"
uqm_CFLAGS="@CFLAGS@ -I@LOCALBASE@/include/SDL -I@LOCALBASE@/include -D_REENTRANT -DGFXMODULE_SDL -DSOUNDMODULE_SDL"
uqm_LDFLAGS=" -L@LOCALBASE@/lib -L@X11BASE@/lib -lSDL -lm -lX11 -lXext -lusbhid -lSDL -pthread -lusbhid -lSDL_image -lvorbisfile -lvorbis"
DEBUG="0"
uqm_INSTALL_BINDIR="@PREFIX@/bin/"
uqm_INSTALL_LIBDIR="@PREFIX@/share/uqm/"
# Exported variables are available from all the Makeinfo files
# Non-exported files only where build.vars is explicitely included.
uqm_SOUNDMODULE="mixsdl"
uqm_HAVE_OPENGL="0"
WINDRES=""
export uqm_SOUNDMODULE uqm_HAVE_OPENGL WINDRES

View File

@ -0,0 +1,44 @@
/* This file contains some compile-time configuration options for *nix
* systems.
* src/config.h is generated from src/config.h.in by build.sh
* For windows, you'll have to edit src/msvc++/config.h manually
* if you want anything else than the defaults.
*/
#ifdef WIN32
/* If we're compiling in windows, we want the other config.h */
# include "msvc++/config.h"
#endif
#ifndef _CONFIG_H
#define _CONFIG_H
/* Directory where the UQM game data is located */
#define CONTENTDIR "@PREFIX@/share/uqm/"
/* Directory where game data will be stored */
#define USERDIR "~/.uqm/"
/* Directory where supermelee teams will be stored */
#define MELEEDIR USERDIR "teams/"
/* Directory where save games will be stored */
#define SAVEDIR USERDIR "save/"
/* Directory where config files will be stored */
#define CONFIGDIR USERDIR
/* Defined if words are stored with the most significant byte first */
#define WORDS_BIGENDIAN
/* Defined if your system has strupr of its own */
#undef HAVE_STRUPR
/* Defined if your system has stricmp of its own */
#undef HAVE_STRICMP
/* Defined if your system has getopt.h */
#define HAVE_GETOPT_H
#endif /* _CONFIG_H */

View File

@ -0,0 +1,44 @@
/* This file contains some compile-time configuration options for *nix
* systems.
* src/config.h is generated from src/config.h.in by build.sh
* For windows, you'll have to edit src/msvc++/config.h manually
* if you want anything else than the defaults.
*/
#ifdef WIN32
/* If we're compiling in windows, we want the other config.h */
# include "msvc++/config.h"
#endif
#ifndef _CONFIG_H
#define _CONFIG_H
/* Directory where the UQM game data is located */
#define CONTENTDIR "@PREFIX@/share/uqm/"
/* Directory where game data will be stored */
#define USERDIR "~/.uqm/"
/* Directory where supermelee teams will be stored */
#define MELEEDIR USERDIR "teams/"
/* Directory where save games will be stored */
#define SAVEDIR USERDIR "save/"
/* Directory where config files will be stored */
#define CONFIGDIR USERDIR
/* Defined if words are stored with the most significant byte first */
#undef WORDS_BIGENDIAN
/* Defined if your system has strupr of its own */
#undef HAVE_STRUPR
/* Defined if your system has stricmp of its own */
#undef HAVE_STRICMP
/* Defined if your system has getopt.h */
#define HAVE_GETOPT_H
#endif /* _CONFIG_H */

View File

@ -0,0 +1,11 @@
$OpenBSD: patch-src_sc2code_shipyard_c,v 1.1.1.1 2003/04/11 09:12:52 wilfried Exp $
--- src/sc2code/shipyard.c.orig Mon Feb 17 16:54:37 2003
+++ src/sc2code/shipyard.c Thu Mar 6 01:12:59 2003
@@ -422,6 +422,7 @@ StartFinalPass:
pship_win_info->rtdoor_s.origin.x = 0;
AllDoorsFinished = TRUE;
}
+ TaskSwitch();
goto StartFinalPass;
}

View File

@ -0,0 +1,21 @@
$OpenBSD: patch-src_sc2code_libs_graphics_tfb_draw_c,v 1.1.1.1 2003/04/11 09:12:52 wilfried Exp $
--- src/sc2code/libs/graphics/tfb_draw.c.orig Fri Feb 14 18:17:16 2003
+++ src/sc2code/libs/graphics/tfb_draw.c Tue Mar 4 01:16:07 2003
@@ -197,14 +197,14 @@ void
TFB_DrawScreen_WaitForSignal (void)
{
TFB_DrawCommand DrawCommand;
+ int channel;
DrawCommand.Type = TFB_DRAWCOMMANDTYPE_SENDSIGNAL;
- // We need to lock the mutex before enqueueing the DC to prevent races
- LockSignalMutex ();
Lock_DCQ (1);
+ channel = FindSignalChannel ();
TFB_BatchReset ();
TFB_EnqueueDrawCommand(&DrawCommand);
Unlock_DCQ();
- WaitForSignal ();
+ WaitForSignal (channel);
}
void

View File

@ -0,0 +1,20 @@
$OpenBSD: patch-src_sc2code_libs_threadlib_h,v 1.1.1.1 2003/04/11 09:12:52 wilfried Exp $
--- src/sc2code/libs/threadlib.h.orig Fri Feb 14 18:17:16 2003
+++ src/sc2code/libs/threadlib.h Tue Mar 4 01:04:00 2003
@@ -137,13 +137,14 @@ typedef void *CondVar;
extern CondVar CreateCondVar (void);
extern void DestroyCondVar (CondVar);
extern void WaitCondVar (CondVar);
+extern void WaitProtectedCondVar (CondVar, Mutex);
extern void SignalCondVar (CondVar);
extern void BroadcastCondVar (CondVar);
extern DWORD CurrentThreadID (void);
-extern void LockSignalMutex(void);
-extern void WaitForSignal (void);
+extern int FindSignalChannel ();
+extern void WaitForSignal (int);
extern void SignalThread (DWORD);
#endif /* _THREADLIB_H */

View File

@ -0,0 +1,127 @@
$OpenBSD: patch-src_sc2code_libs_threads_condbank_c,v 1.1.1.1 2003/04/11 09:12:52 wilfried Exp $
--- src/sc2code/libs/threads/condbank.c.orig Sat Jan 4 10:55:31 2003
+++ src/sc2code/libs/threads/condbank.c Tue Mar 4 01:06:16 2003
@@ -30,12 +30,12 @@
#define CONDVAR_BANK_SIZE 10
static Mutex bank_mutex;
-static int wait = 0, signal = 0;
static struct {
- Semaphore var;
- DWORD id;
- int used;
+ CondVar var;
+ DWORD id;
+ int used;
+ Mutex control;
} bank[CONDVAR_BANK_SIZE];
void
@@ -45,10 +45,9 @@ init_cond_bank ()
bank_mutex = CreateMutex ();
for (i = 0; i < CONDVAR_BANK_SIZE; i++)
{
- char str[20];
- sprintf (str, "bank sem %d", i);
- bank[i].var = CreateSemaphore (0, str);
+ bank[i].var = CreateCondVar ();
bank[i].id = bank[i].used = 0;
+ bank[i].control = CreateMutex ();
}
}
@@ -59,33 +58,37 @@ uninit_cond_bank ()
for (i = 0; i < CONDVAR_BANK_SIZE; i++)
{
DestroyCondVar (bank[i].var);
+ DestroyMutex (bank[i].control);
}
DestroyMutex (bank_mutex);
}
-void
-LockSignalMutex ()
-{
- LockMutex (bank_mutex);
-}
-void
-WaitForSignal ()
+int
+FindSignalChannel ()
{
int i;
- int index = -1;
- DWORD me = CurrentThreadID ();
+
+ LockMutex (bank_mutex);
for (i = 0; i < CONDVAR_BANK_SIZE; i++)
{
if (!bank[i].used)
{
- index = i;
- break;
+ LockMutex (bank[i].control);
+ return i;
}
}
- if (index == -1)
+ return -1;
+}
+
+void
+WaitForSignal (int i)
+{
+ DWORD me = CurrentThreadID ();
+
+ if (i == -1)
{
/* The bank is full! */
- fprintf(stderr, "Condvar bank is full, %ul is waiting on DCQ.", me);
+ fprintf(stderr, "Condvar bank is full, %lu is waiting on DCQ.\n", me);
UnlockMutex (bank_mutex);
WaitCondVar (RenderingCond);
}
@@ -93,12 +96,14 @@ WaitForSignal ()
{
bank[i].used = 1;
bank[i].id = me;
- // Initialize the Semaphore to a value of '0' in case it isn't already
- while (SemaphoreValue (bank[i].var))
- SetSemaphore (bank[i].var);
UnlockMutex (bank_mutex);
- // Block on Semaphore until it is cleared by the Signal
- SetSemaphore (bank[i].var);
+ // fprintf (stderr, "Thread %lu waiting on cond var %d (control: %p)\n", me, i, bank[i].control);
+ WaitProtectedCondVar (bank[i].var, bank[i].control);
+ // fprintf (stderr, "Thread %lu signaled via cond var %d\n", me, i);
+ UnlockMutex (bank[i].control);
+ LockMutex (bank_mutex);
+ bank[i].used = bank[i].id = 0;
+ UnlockMutex (bank_mutex);
}
}
@@ -111,14 +116,15 @@ SignalThread (DWORD id)
{
if (bank[i].used && bank[i].id == id)
{
- bank[i].id = bank[i].used = 0;
- ResetSemaphoreOwner (bank[i].var);
- ClearSemaphore (bank[i].var);
- break;
+ UnlockMutex (bank_mutex);
+ // fprintf (stderr, "Blocking on var %d's control: %p\n", i, bank[i].control);
+ LockMutex (bank[i].control);
+ // fprintf (stderr, "Signaling var %d, thread %lu, control %p\n", i, id, bank[i].control);
+ SignalCondVar (bank[i].var);
+ UnlockMutex (bank[i].control);
+ return;
}
}
- if (i == CONDVAR_BANK_SIZE)
- fprintf (stderr, "Warning: Couldn't find thread to signal!\n");
+ fprintf (stderr, "Warning: Couldn't find thread to signal!\n");
UnlockMutex (bank_mutex);
}
-

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-src_sc2code_libs_threads_sdl_sdlthreads_h,v 1.1.1.1 2003/04/11 09:12:52 wilfried Exp $
--- src/sc2code/libs/threads/sdl/sdlthreads.h.orig Mon Feb 3 14:12:04 2003
+++ src/sc2code/libs/threads/sdl/sdlthreads.h Tue Mar 4 01:07:04 2003
@@ -91,6 +91,8 @@ typedef SDL_cond *NativeCondVar;
extern void SDLWrapper_WaitCondVar (CondVar candvar);
#define NativeWaitCondVar(condvar) \
SDLWrapper_WaitCondVar ((condvar))
+#define NativeWaitProtectedCondVar(condvar, mutex) \
+ SDL_CondWait ((condvar), (mutex))
#define NativeSignalCondVar(condvar) \
SDL_CondSignal ((condvar))
#define NativeBroadcastCondVar(condvar) \

View File

@ -0,0 +1,68 @@
$OpenBSD: patch-src_sc2code_libs_threads_thrcommon_c,v 1.1.1.1 2003/04/11 09:12:52 wilfried Exp $
--- src/sc2code/libs/threads/thrcommon.c.orig Mon Feb 3 14:12:03 2003
+++ src/sc2code/libs/threads/thrcommon.c Tue Mar 4 01:08:36 2003
@@ -553,6 +553,7 @@ ClearSemaphore (Semaphore sem)
sem_name = SemMon[i].Name;
if (SemMon[i].Thread && SemMon[i].Thread != NativeThreadID ())
#if defined (THREAD_QUEUE) && defined (THREAD_NAMES)
+ {
if (ThreadNameNative (SemMon[i].Thread) == NULL)
fprintf( stderr, "Freeing %s Semaphore in '%s' set by defunct thread '%s'!\n",
sem_name,
@@ -563,6 +564,7 @@ ClearSemaphore (Semaphore sem)
sem_name,
ThreadNameNative (NativeThreadID ()),
ThreadNameNative (SemMon[i].Thread));
+ }
SemMon[i].ThreadName[0] = 0;
#else
fprintf (stderr, "Freeing %s Semaphore that was set by a different thread\n",
@@ -606,27 +608,39 @@ CreateCondVar ()
{
return NativeCreateCondVar ();
}
-void DestroyCondVar (CondVar cv)
+
+void
+DestroyCondVar (CondVar cv)
{
- NativeDestroyCondVar (cv);
+ NativeDestroyCondVar ((CondVar)cv);
}
-void WaitCondVar (CondVar cv)
+void
+WaitCondVar (CondVar cv)
{
- NativeWaitCondVar (cv);
+ NativeWaitCondVar ((NativeCondVar)cv);
}
-void SignalCondVar (CondVar cv)
+void
+WaitProtectedCondVar (CondVar cv, Mutex m)
{
- NativeSignalCondVar (cv);
+ NativeWaitProtectedCondVar ((NativeCondVar)cv, (NativeMutex)m);
}
-void BroadcastCondVar (CondVar cv)
+void
+SignalCondVar (CondVar cv)
+{
+ NativeSignalCondVar ((NativeCondVar)cv);
+}
+
+void
+BroadcastCondVar (CondVar cv)
{
- NativeBroadcastCondVar (cv);
+ NativeBroadcastCondVar ((NativeCondVar)cv);
}
-DWORD CurrentThreadID ()
+DWORD
+CurrentThreadID ()
{
return (DWORD)NativeThreadID ();
}

View File

@ -0,0 +1,101 @@
$OpenBSD: patch-src_sc2code_shipyard_c,v 1.1.1.1 2003/04/11 09:12:52 wilfried Exp $
--- src/sc2code/shipyard.c.orig Mon Feb 17 16:54:37 2003
+++ src/sc2code/shipyard.c Fri Mar 7 00:23:39 2003
@@ -382,49 +382,45 @@ ShowCombatShip (COUNT which_window, SHIP
CONTEXT OldContext;
int j;
- SetSemaphore (GraphicsSem);
- OldContext = SetContext (OffScreenContext);
- SetContextFGFrame (Screen);
- SetContextBackGroundColor (BLACK_COLOR);
-
AllDoorsFinished = FALSE;
r.corner.x = r.corner.y = 0;
r.extent.width = SHIP_WIN_WIDTH;
r.extent.height = SHIP_WIN_HEIGHT;
ButtonState = AnyButtonPress (FALSE) ? 1 : 0;
+ if (ButtonState)
+ {
+ while (ButtonState)
+ if (!AnyButtonPress (FALSE))
+ ButtonState = 0;
+ else
+ TaskSwitch();
+ }
TimeIn = GetTimeCounter ();
for (j = 0; (j < SHIP_WIN_FRAMES) && !AllDoorsFinished; j++)
{
- ClearSemaphore (GraphicsSem);
SleepThreadUntil (TimeIn + ONE_SECOND / 24);
TimeIn = GetTimeCounter ();
+ if (AnyButtonPress (FALSE))
+ {
+ if (YankedStarShipPtr != 0)
+ {
+ ship_win_info[0].lfdoor_s.origin.x = 0;
+ ship_win_info[0].rtdoor_s.origin.x = 0;
+ }
+ AllDoorsFinished = TRUE;
+ while (AnyButtonPress (FALSE))
+ TaskSwitch();
+ }
SetSemaphore (GraphicsSem);
+ OldContext = SetContext (OffScreenContext);
+ SetContextFGFrame (Screen);
+ SetContextBackGroundColor (BLACK_COLOR);
+
BatchGraphics ();
-StartFinalPass:
pship_win_info = &ship_win_info[0];
for (i = 0; i < num_ships; ++i)
{
- if (ButtonState)
- {
- if (!AnyButtonPress (FALSE))
- ButtonState = 0;
- }
- else if (AnyButtonPress (FALSE))
- {
- if (YankedStarShipPtr == 0)
- {
- AllDoorsFinished = TRUE;
- }
- else
- {
- pship_win_info->lfdoor_s.origin.x = 0;
- pship_win_info->rtdoor_s.origin.x = 0;
- AllDoorsFinished = TRUE;
- }
- goto StartFinalPass;
- }
-
{
RECT ClipRect;
@@ -457,11 +453,10 @@ StartFinalPass:
}
UnbatchGraphics ();
+ SetContextClipRect (NULL_PTR);
+ SetContext (OldContext);
+ ClearSemaphore (GraphicsSem);
}
-
- SetContextClipRect (NULL_PTR);
- SetContext (OldContext);
- ClearSemaphore (GraphicsSem);
}
}
@@ -668,7 +663,9 @@ DoModifyShips (INPUT_STATE InputState, P
{
ShowCombatShip ((COUNT)pMS->CurState, (SHIP_FRAGMENTPTR)0);
//Reset flash rectangle
+ SetSemaphore (GraphicsSem);
SetFlashRect ((PRECT)~0L, (FRAME)0);
+ ClearSemaphore (GraphicsSem);
DrawMenuStateStrings (PM_CREW, SHIPYARD_CREW);
SetSemaphore (GraphicsSem);

15
games/uqm/pkg/DESCR Normal file
View File

@ -0,0 +1,15 @@
The Ur-Quan Masters is an SDL-based port of the 3DO version of the
popular game Star Control 2. This port is for only the program.
The uqmcontent port which contains all the graphics and sounds is
needed as well. For a richer game experience, you may wish to
install the uqmcontent port with a non-default FLAVOR, which will
add enjoyable extras.
At this time, the introduction is not played. It is highly
recommended to at least skim through the text version of the
introduction, a copy of which may be found here:
http://www.classicgaming.com/starcontrol/sc2/sc2_hist.shtml
WWW: ${HOMEPAGE}

4
games/uqm/pkg/PLIST Normal file
View File

@ -0,0 +1,4 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2003/04/11 09:12:52 wilfried Exp $
bin/uqm
share/doc/uqm/manual.txt
@dirrm share/doc/uqm