rpms/d1x/F-8 d1x-assert.patch, NONE, 1.1 d1x-config.patch, NONE, 1.1 d1x-cvs-fixes.patch, NONE, 1.1 d1x-cvs-fixes2.patch, NONE, 1.1 d1x-fix-rebirth-ogl.patch, NONE, 1.1 d1x-fix.patch, NONE, 1.1 d1x-fixc.patch, NONE, 1.1 d1x-gcc3.patch, NONE, 1.1 d1x-gcc34.patch, NONE, 1.1 d1x-gcc43.patch, NONE, 1.1 d1x-gnuasm.patch, NONE, 1.1 d1x-help.patch, NONE, 1.1 d1x-joystick.patch, NONE, 1.1 d1x-maths.patch, NONE, 1.1 d1x-miscfixes.patch, NONE, 1.1 d1x-music.patch, NONE, 1.1 d1x-new-sdl.patch, NONE, 1.1 d1x-opt.patch, NONE, 1.1 d1x-paths.patch, NONE, 1.1 d1x-playerfile-compat-fix.patch, NONE, 1.1 d1x-playerfile-compat.patch, NONE, 1.1 d1x-post-rebirth-fixes.patch, NONE, 1.1 d1x-rebirth-fixes.patch, NONE, 1.1 d1x-rebirth-highresbrief.patch, NONE, 1.1 d1x-rebirth-mode-handling.patch, NONE, 1.1 d1x-rebirth-mouselook.patch, NONE, 1.1 d1x-rebirth-ogl.patch, NONE, 1.1 d1x-shareware-fixes.patch, NONE, 1.1 d1x-store-res-in-plx.patch, NONE, 1.1 d1x-types.patch, NONE, 1.1 d1x-unixify.patch, NONE, 1.1 d1x-use-reg-save-in-sw.patch, NONE, 1.1 d1x.spec, NONE, 1.1 .cvsignore, 1.1, 1.2 sources, 1.1, 1.2

Hans de Goede jwrdegoede at rpmfusion.org
Wed Jul 23 16:28:11 CEST 2008


Author: jwrdegoede

Update of /cvs/nonfree/rpms/d1x/F-8
In directory se02.es.rpmfusion.net:/tmp/cvs-serv1905

Modified Files:
	.cvsignore sources 
Added Files:
	d1x-assert.patch d1x-config.patch d1x-cvs-fixes.patch 
	d1x-cvs-fixes2.patch d1x-fix-rebirth-ogl.patch d1x-fix.patch 
	d1x-fixc.patch d1x-gcc3.patch d1x-gcc34.patch d1x-gcc43.patch 
	d1x-gnuasm.patch d1x-help.patch d1x-joystick.patch 
	d1x-maths.patch d1x-miscfixes.patch d1x-music.patch 
	d1x-new-sdl.patch d1x-opt.patch d1x-paths.patch 
	d1x-playerfile-compat-fix.patch d1x-playerfile-compat.patch 
	d1x-post-rebirth-fixes.patch d1x-rebirth-fixes.patch 
	d1x-rebirth-highresbrief.patch d1x-rebirth-mode-handling.patch 
	d1x-rebirth-mouselook.patch d1x-rebirth-ogl.patch 
	d1x-shareware-fixes.patch d1x-store-res-in-plx.patch 
	d1x-types.patch d1x-unixify.patch d1x-use-reg-save-in-sw.patch 
	d1x.spec 
Log Message:
* Wed Jul 23 2008 Hans de Goede <j.w.r.degoede at hhs.nl> 1.43-6
- Release bump for rpmfusion build


d1x-assert.patch:

--- NEW FILE d1x-assert.patch ---
--- d1x/main/ip_base.cpp.orig	2000-03-06 02:42:09.000000000 +0100
+++ d1x/main/ip_base.cpp	2004-01-18 19:06:04.996772376 +0100
@@ -9,6 +9,7 @@
 }
 #include <string.h>
 #include "ip_base.h"
+#include <assert.h>
 
 int myport=-1;
 

d1x-config.patch:

--- NEW FILE d1x-config.patch ---
--- d1x/defines.in.orig	Mon Jun 19 23:26:12 2000
+++ d1x/defines.in	Sun Jun  2 01:18:27 2002
@@ -1,11 +1,11 @@
 # NOERROR:       make sure there are no warnings in compile
-NOERROR = 1
+#NOERROR = 1
 
 # NO_ASM:       don't use assembler
 #NO_ASM = 1
 
 # MAKE_EDITOR:  build editor into game  be sure to comment RELEASE
-#MAKE_EDITOR = 1
+#MAKE_EDITOR = 1 # not enabled by default - causes SEGVs...
 
 # DEBUG:	enable asserts, int3, etc. and include debugger data
 #DEBUG = 1
@@ -35,12 +35,12 @@
 RELEASE = 1
 
 # environment
-ENV_DJGPP = 1
+#ENV_DJGPP = 1
 #ENV_DJGPP_REALDOS =1
 #ENV_MINGW32 = 1
 #ENV_CYGWIN = 1
 #ENV_MSVC = 1
-#ENV_LINUX = 1
+ENV_LINUX = 1
 
 # if compiling with Cygwin, you need extra mingw compatible c++ libraries (see compile.txt)
 #MINGW_EXTRA = /Cygnus/mingw/
@@ -79,7 +79,7 @@
 #GLX_IO = 1
 
 # linux audio options (chose one)
-#SDL_AUDIO = 1
+SDL_AUDIO = 1
 #ALSA_AUDIO = 1
 
 # secondary compiler options
@@ -93,7 +93,7 @@
 #sound options for dos: choose which
 #MIKMOD = 1     #MikMod digital, can be used with allg_midi
 #ALLG_MIDI = 1  #Allegro midi, can be used with mikmod
-ALLEGRO = 1     #Allegro for midi and digi, should be used alone
+#ALLEGRO = 1    #Allegro for midi and digi, should be used alone
 
 #music options for linux:
 #HMIPLAY = 1

d1x-cvs-fixes.patch:

--- NEW FILE d1x-cvs-fixes.patch ---
--- d1x/include/d_glob.h.cvs-fixes	2005-01-06 19:50:58.276099128 +0100
+++ d1x/include/d_glob.h	2005-01-06 19:51:02.949388680 +0100
@@ -4,7 +4,12 @@
 #define _D_GLOB
 
 #include <stdlib.h>
-
+#if defined(__DJGPP__) || defined(__LINUX__)
+#include <glob.h>
+typedef glob_t d_glob_t;
+#define d_glob(p,g) glob(p,0,NULL,g)
+#define d_globfree(g) globfree(g)
+#else
 typedef struct
   {
     size_t gl_pathc;
@@ -14,5 +19,6 @@
 
 int d_glob (const char *pattern, d_glob_t * g);
 void d_globfree (d_glob_t * g);
+#endif
 
 #endif
--- d1x/include/gr.h.cvs-fixes	2005-01-06 19:50:58.279098672 +0100
+++ d1x/include/gr.h	2005-01-06 19:51:02.950388528 +0100
@@ -760,4 +760,4 @@
 int gr_toggle_fullscreen_menu(void);//returns state after toggling (ie, same as if you had called check_fullscreen immediatly after)
 
 //make this a define, since its used in several places
-#define KEYS_GR_TOGGLE_FULLSCREEN KEY_CTRLED+KEY_SHIFTED+KEY_PADENTER: case KEY_ALTED+KEY_CTRLED+KEY_PADENTER: case KEY_ALTED+KEY_SHIFTED+KEY_PADENTER
+#define KEYS_GR_TOGGLE_FULLSCREEN KEY_CTRLED+KEY_SHIFTED+KEY_PADENTER: case KEY_ALTED+KEY_CTRLED+KEY_PADENTER: case KEY_ALTED+KEY_SHIFTED+KEY_PADENTER: case KEY_ALTED+KEY_ENTER
--- d1x/misc/d_glob.c.cvs-fixes	2005-01-06 19:50:58.320092440 +0100
+++ d1x/misc/d_glob.c	2005-01-06 19:51:02.987382904 +0100
@@ -8,37 +8,8 @@
 //end addition -MM
 
 #if defined(__DJGPP__) || defined(__LINUX__)
-#include <glob.h>
 
-int d_glob(const char *pattern, d_glob_t *g)
-{
- glob_t a;
- int r;
-
- Assert(g!=NULL);
-
- a.gl_offs=0;
-
- r=glob(pattern,0,NULL,&a);
- g->gl_pathc=a.gl_pathc;
- g->gl_pathv=a.gl_pathv;
- return r;
-}
-
-void d_globfree(d_glob_t *g)
-{
-#ifndef __LINUX__ // Linux doesn't believe in freeing glob structures... :-)
- glob_t a;
-
- Assert (g!=NULL);
-
- a.gl_offs=0;
- a.gl_pathc=g->gl_pathc;
- a.gl_pathv=g->gl_pathv;
-
- globfree(&a);
-#endif
-}
+//nothing to do, but we don't want to fall into the #error below.
 
 #elif defined(__WINDOWS__)
 
--- d1x/arch/ogl/include/ogl_init.h.cvs-fixes	2005-01-06 19:50:58.311093808 +0100
+++ d1x/arch/ogl/include/ogl_init.h	2005-01-06 19:51:02.977384424 +0100
@@ -133,6 +133,8 @@
 void ogl_freetexture(ogl_texture *gltexture);
 void ogl_freebmtexture(grs_bitmap *bm);
 void ogl_do_palfx(void);
+void ogl_start_offscreen_render(int x, int y, int w, int h);
+void ogl_end_offscreen_render(void);
 void ogl_start_frame(void);
 void ogl_end_frame(void);
 void ogl_swap_buffers(void);
--- d1x/arch/ogl/ogl.c.cvs-fixes	2005-01-06 19:50:58.314093352 +0100
+++ d1x/arch/ogl/ogl.c	2005-01-06 19:51:02.979384120 +0100
@@ -1119,6 +1119,32 @@
 	return 0;
 }
 
+grs_canvas *offscreen_save_canv=NULL, *offscreen_canv=NULL;
+void ogl_start_offscreen_render(int x, int y, int w, int h) {
+	if (offscreen_canv) Error("ogl_start_offscreen_render: offscreen_canv!=NULL");
+	offscreen_save_canv = grd_curcanv;
+	offscreen_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
+	gr_set_current_canvas(offscreen_canv);
+	glDrawBuffer(GL_BACK);
+}
+void ogl_end_offscreen_render(void) {
+	int y;
+	if (!offscreen_canv) Error("ogl_end_offscreen_render: no offscreen_canv");
+
+	glDrawBuffer(GL_FRONT);
+	glReadBuffer(GL_BACK);
+	OGL_DISABLE(TEXTURE_2D);
+
+	y = last_height - offscreen_canv->cv_bitmap.bm_y - offscreen_canv->cv_bitmap.bm_h;
+	glRasterPos2f(offscreen_canv->cv_bitmap.bm_x/(float)last_width, y/(float)last_height);
+	glCopyPixels(offscreen_canv->cv_bitmap.bm_x, y,
+			offscreen_canv->cv_bitmap.bm_w, offscreen_canv->cv_bitmap.bm_h, GL_COLOR);
+
+	gr_free_sub_canvas(offscreen_canv);
+	gr_set_current_canvas(offscreen_save_canv);
+	offscreen_canv=NULL;
+}
+
 void ogl_start_frame(void){
 	r_polyc=0;r_tpolyc=0;r_bitmapc=0;r_ubitmapc=0;r_ubitbltc=0;r_upixelc=0;
 //	gl_badtexture=500;
--- d1x/arch/sdl/digi.c.cvs-fixes	2005-01-06 19:50:58.272099736 +0100
+++ d1x/arch/sdl/digi.c	2005-01-06 19:51:02.945389288 +0100
@@ -179,6 +179,7 @@
 {
  Uint8 *streamend = stream + len;
  struct sound_slot *sl;
+ if (!digi_initialised) return;
   
  for (sl = SoundSlots; sl < SoundSlots + MAX_SOUND_SLOTS; sl++)
  {
@@ -226,6 +227,9 @@
 /* Initialise audio devices. */
 int digi_init()
 {
+ if (SDL_InitSubSystem(SDL_INIT_AUDIO)<0){
+    Error("SDL audio initialisation failed: %s.",SDL_GetError());
+ }
  //added on 980905 by adb to init sound kill system
  memset(SampleHandles, 255, sizeof(SampleHandles));
  //end edit by adb
@@ -739,7 +743,10 @@
 }
 //end edit by adb
 
-void digi_set_volume( int dvolume, int mvolume ) { }
+void digi_set_volume( int dvolume, int mvolume ) {
+	digi_set_digi_volume(dvolume);
+	digi_set_midi_volume(mvolume);
+}
 
 int digi_is_sound_playing(int soundno)
 {
@@ -756,7 +763,18 @@
 
 void digi_pause_all() { }
 void digi_resume_all() { }
-void digi_stop_all() { }
+void digi_stop_all() {
+	int i;
+	// ... Ano. The lack of this was causing ambient sounds to crash.
+	// fixed, added digi_stop_all 07/19/01 - bluecow
+	
+	for (i=0; i<MAX_SOUND_OBJECTS; i++ )	{
+		if ( SoundObjects[i].flags & SOF_USED )	{
+			SoundSlots[SoundObjects[i].handle].playing = 0;
+			SoundObjects[i].flags = 0;
+		}
+	}
+}
 
  //added on 980905 by adb to make sound channel setting work
 void digi_set_max_channels(int n) { 
--- d1x/arch/sdl/init.c.cvs-fixes	2005-01-06 19:50:58.272099736 +0100
+++ d1x/arch/sdl/init.c	2005-01-06 19:51:02.946389136 +0100
@@ -19,12 +19,6 @@
  // Initialise the library
 //edited on 01/03/99 by Matt Mueller - if we use SDL_INIT_EVERYTHING, cdrom is initialized even if -nocdaudio is used
  if (SDL_Init(
-#ifdef SDL_AUDIO
-	SDL_INIT_AUDIO
-#else
-	0
-#endif
-	|
 #if SDL_VIDEO || SDL_GL
 	SDL_INIT_VIDEO
 #else
--- d1x/arch/linux/alsadigi.c.cvs-fixes	2005-01-06 19:50:58.273099584 +0100
+++ d1x/arch/linux/alsadigi.c	2005-01-06 19:51:02.948388832 +0100
@@ -3,7 +3,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/asoundlib.h>
+#include <alsa/asoundlib.h>
 #include <pthread.h>
 
 #include "error.h"
@@ -173,7 +173,7 @@
 /* Threading/ALSA stuff */
 #define LOCK() pthread_mutex_lock(&mutex)
 #define UNLOCK() pthread_mutex_unlock(&mutex)
-void *snd_devhandle;
+snd_pcm_t *snd_devhandle;
 pthread_t thread_id;
 pthread_mutex_t mutex;
 
@@ -222,8 +222,12 @@
      sldata = sl->samples;
     }
     v = *(sldata++) - 0x80;
-    *(sp++) = mix8[ *sp + fixmul(v, vl) + 0x80 ];
-    *(sp++) = mix8[ *sp + fixmul(v, vr) + 0x80 ];
+
+    *sp = mix8[ *sp + fixmul(v, vl) + 0x80 ];
+    sp++;
+
+    *sp = mix8[ *sp + fixmul(v, vr) + 0x80 ];
+    sp++;
    }
    sl->position = sldata - sl->samples;
   }
@@ -232,17 +236,34 @@
 //end changes by adb
 
 void *mixer_thread(void *data) {
-// int i=0;
- ubyte buffer[512];
+ int err;
+ ubyte buffer[SOUND_BUFFER_SIZE];
+
  /* Allow ourselves to be asynchronously cancelled */
  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
  while (1) {
-//   printf("i=%d\n",i++);
-   memset(buffer, 0x80, 512);
+
+   memset(buffer, 0x80, SOUND_BUFFER_SIZE);
    LOCK();
-   audio_mixcallback(NULL,buffer,512);
+   audio_mixcallback(NULL,buffer,SOUND_BUFFER_SIZE);
    UNLOCK();
-   snd_pcm_write(snd_devhandle, buffer, 512);
+again:
+   err = snd_pcm_writei(snd_devhandle, buffer, SOUND_BUFFER_SIZE/2);
+
+   if (err == -EPIPE) {
+        // Sound buffer underrun
+        err = snd_pcm_prepare(snd_devhandle);
+        if (err < 0) {
+            fprintf(stderr, "Can't recover from underrun: %s\n",
+                    snd_strerror(err));
+        }
+   } else if (err == -EAGAIN) {
+        goto again;
+   } else if (err != SOUND_BUFFER_SIZE/2) {
+        // Each frame has size 2 bytes - hence we expect SOUND_BUFFER_SIZE/2
+        // frames to be written.
+        fprintf(stderr, "Unknown err %d: %s\n", err, snd_strerror(err));
+   }
  } 
  return 0;
 }
@@ -251,9 +272,9 @@
 /* Initialise audio devices. */
 int digi_init()
 {
- int card=0, device=0, err;
- snd_pcm_format_t format;
- snd_pcm_playback_params_t params;
+ int err, tmp;
+ char *device = "plughw:0,0";
+ snd_pcm_hw_params_t *params;
  pthread_attr_t attr;
  pthread_mutexattr_t mutexattr;
 
@@ -262,30 +283,45 @@
  //end edit by adb
 
  /* Open the ALSA sound device */
- if ((err = snd_pcm_open(&snd_devhandle, card, device, 
-     SND_PCM_OPEN_PLAYBACK)) < 0) {  
+ if ((err = snd_pcm_open(&snd_devhandle,device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) {  
      fprintf(stderr, "open failed: %s\n", snd_strerror( err ));  
      return -1; 
  } 
 
- memset(&format, 0, sizeof(format));
- format.format = SND_PCM_SFMT_U8;
- format.rate = 11025;
- format.channels = 2;
- if ((err = snd_pcm_playback_format(snd_devhandle, &format)) < 0) { 
-    fprintf(stderr, "format setup failed: %s\n", snd_strerror( err ));
-    snd_pcm_close( snd_devhandle ); 
-    return -1; 
- } 
+ snd_pcm_hw_params_alloca(&params);
+ err = snd_pcm_hw_params_any(snd_devhandle, params);
+ if (err < 0) {
+     printf("ALSA: Error %s\n", snd_strerror(err));
+     return -1;
+ }
+ err = snd_pcm_hw_params_set_access(snd_devhandle, params, SND_PCM_ACCESS_RW_INTERLEAVED);
+ if (err < 0) {
+     printf("ALSA: Error %s\n", snd_strerror(err));
+     return -1;
+ }
+ err = snd_pcm_hw_params_set_format(snd_devhandle, params, SND_PCM_FORMAT_U8);
+ if (err < 0) {
+     printf("ALSA: Error %s\n", snd_strerror(err));
+     return -1;
+ }
+ err = snd_pcm_hw_params_set_channels(snd_devhandle, params, 2);
+ if (err < 0) {
+     printf("ALSA: Error %s\n", snd_strerror(err));
+     return -1;
+ }
+ tmp = 11025;
+ err = snd_pcm_hw_params_set_rate_near(snd_devhandle, params, &tmp, NULL);
+ if (err < 0) {
+     printf("ALSA: Error %s\n", snd_strerror(err));
+     return -1;
+ }
+ snd_pcm_hw_params_set_periods(snd_devhandle, params, 3, 0);
+ snd_pcm_hw_params_set_buffer_size(snd_devhandle,params, (SOUND_BUFFER_SIZE*3)/2);
 
- memset(&params, 0, sizeof(params));
- params.fragment_size=512;
- params.fragments_max=2;
- params.fragments_room=1;
- if ((err = snd_pcm_playback_params(snd_devhandle, &params)) < 0) { 
-    fprintf(stderr, "params setup failed: %s\n", snd_strerror( err ));
-    snd_pcm_close( snd_devhandle ); 
-    return -1; 
+ err = snd_pcm_hw_params(snd_devhandle, params);
+ if (err < 0) {
+     printf("ALSA: Error %s\n", snd_strerror(err));
+     return -1;
  }
 
  /* Start the mixer thread */
@@ -318,10 +354,10 @@
 void digi_close()
 {
  if (!digi_initialised) return;
+ pthread_cancel(thread_id);
  digi_initialised = 0;
- snd_pcm_close(snd_devhandle);
  pthread_mutex_destroy(&mutex);
- pthread_cancel(thread_id);
+ snd_pcm_close(snd_devhandle);
 }
 
 static int get_free_slot()
@@ -586,7 +622,7 @@
 int digi_link_sound_to_pos2( int soundnum, short segnum, short sidenum, vms_vector * pos, int forever, fix max_volume, fix max_distance )
 {
 	int i, volume, pan;
-	int soundnum;
+//	int soundnum;
 
 	if ( max_volume < 0 ) return -1;
 //	if ( max_volume > F1_0 ) max_volume = F1_0;
--- d1x/2d/bitblt.c.cvs-fixes	2005-01-06 19:50:58.322092136 +0100
+++ d1x/2d/bitblt.c	2005-01-06 19:51:02.998381232 +0100
@@ -191,8 +191,10 @@
 		if (nbytes&1)
 			*dest++=*source++;
 		else {
+		        unsigned short *sp=(unsigned short *)dest;
 			c=*source++;
-			*((unsigned short *)dest)++=((short)c<<8)|(short)c;
+			*sp=((short)c<<8)|(short)c;
+			dest+=2;
 		}
 	}
 }
--- d1x/main/titles.c.cvs-fixes	2005-01-06 19:50:58.318092744 +0100
+++ d1x/main/titles.c	2005-01-06 19:51:02.985383208 +0100
@@ -11,14 +11,20 @@
 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 */
 /*
- * $Source: /usr/src/cvsroot/d1x/main/titles.c,v $
- * $Revision: 1.4 $
+ * $Source: /var/cvs/d1x/d1x/main/titles.c,v $
+ * $Revision: 1.6 $
  * $Author: donut $
- * $Date: 1999/11/20 10:05:19 $
+ * $Date: 2003/03/09 06:41:01 $
  * 
  * Routines to display title screens...
  * 
  * $Log: titles.c,v $
+ * Revision 1.6  2003/03/09 06:41:01  donut
+ * change byte typedef to sbyte to avoid conflict with win32 byte which is unsigned
+ *
+ * Revision 1.5  2002/03/26 08:37:40  donut
+ * fix position of briefing animated door bitmap at non 320x200 resolutions
+ *
  * Revision 1.4  1999/11/20 10:05:19  donut
  * variable size menu patch from Jan Bobrowski.  Variable menu font size support and a bunch of fixes for menus that didn't work quite right, by me (MPM).
  *
@@ -464,8 +470,8 @@
 		}
 
 		switch (Animating_bitmap_type) {
-			case 0:	bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 64, 64);	break;
-			case 1:	bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 94, 94);	break;	//	Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
+			case 0:	bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_y(45), 64, 64);	break;
+			case 1:	bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_y(45), 94, 94);	break;	//	Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
 			default:	Int3();	//	Impossible, illegal value for Animating_bitmap_type
 		}
 
--- d1x/main/bm.c.cvs-fixes	2005-01-06 19:50:58.282098216 +0100
+++ d1x/main/bm.c	2005-01-06 19:51:02.950388528 +0100
@@ -164,7 +164,7 @@
 	
 	cfread( &N_polygon_models, sizeof(int), 1, fp );
 
-#ifdef __alpha__
+#if defined(__alpha__) || defined(_LP64)
        for (i=0; i<N_polygon_models; i++ ) {
                cfread( &Polygon_models[i], sizeof(polymodel)-4, 1, fp );
                /* this is a dirty hack */
--- d1x/main/credits.c.cvs-fixes	2005-01-06 19:50:58.287097456 +0100
+++ d1x/main/credits.c	2005-01-06 19:51:02.956387616 +0100
@@ -397,6 +397,7 @@
 					cfclose(file);
 					songs_play_song( SONG_TITLE, 1 );
 					free(fade_values_scalled);
+					free(buffer);
 					return;
 			}
 		}
--- d1x/main/playsave.c.cvs-fixes	2005-01-06 19:50:58.306094568 +0100
+++ d1x/main/playsave.c	2005-01-06 19:51:02.971385336 +0100
@@ -11,14 +11,17 @@
 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 */
 /*
- * $Source: /usr/src/cvsroot/d1x/main/playsave.c,v $
- * $Revision: 1.2 $
+ * $Source: /var/cvs/d1x/d1x/main/playsave.c,v $
+ * $Revision: 1.3 $
  * $Author: donut $
- * $Date: 1999/06/14 23:44:12 $
+ * $Date: 2003/02/16 10:44:56 $
  * 
  * Functions to load & save player games
  * 
  * $Log: playsave.c,v $
+ * Revision 1.3  2003/02/16 10:44:56  donut
+ * fix the weird bug where joystick fire button would do all the d1x key functions at once, when joining a udp game. (but going into config menu would fix it.)  It was due to kc_set_controls() being called before read_player_d1x, so the d1x settings weren't getting noticed.
+ *
  * Revision 1.2  1999/06/14 23:44:12  donut
  * Orulz' svgalib/ggi/noerror patches.
  *
@@ -227,7 +230,7 @@
 
 #ifdef RCS
 #pragma off (unreferenced)
-static char rcsid[] = "$Id: playsave.c,v 1.2 1999/06/14 23:44:12 donut Exp $";
+static char rcsid[] = "$Id: playsave.c,v 1.3 2003/02/16 10:44:56 donut Exp $";
 #pragma on (unreferenced)
 #endif
 
@@ -1343,10 +1346,6 @@
 		else if (fread(&Config_joystick_sensitivity, sizeof(ubyte), 1, file )!=1)
 			errno_ret=errno;
                 }
-
-		if (errno_ret==EZERO)	{
-                        kc_set_controls();
-		}
 	}
 
 	if (fclose(file) && errno_ret==EZERO)
@@ -1386,6 +1385,9 @@
              highest_secondary++;
          }
 
+	if (errno_ret==EZERO)	{
+		kc_set_controls();
+	}
 	return errno_ret;
 
 }
--- d1x/main/controls.c.cvs-fixes	2005-01-06 19:50:58.285097760 +0100
+++ d1x/main/controls.c	2005-01-06 19:51:02.952388224 +0100
@@ -11,14 +11,17 @@
 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 */
 /*
- * $Source: /usr/src/cvsroot/d1x/main/controls.c,v $
- * $Revision: 1.3 $
- * $Author: sekmu $
- * $Date: 2000/04/19 21:30:00 $
+ * $Source: /var/cvs/d1x/d1x/main/controls.c,v $
+ * $Revision: 1.4 $
+ * $Author: donut $
+ * $Date: 2003/07/11 21:32:28 $
  * 
  * Code for controlling player movement
  * 
  * $Log: controls.c,v $
+ * Revision 1.4  2003/07/11 21:32:28  donut
+ * make ship bobbing fps-independant
+ *
  * Revision 1.3  2000/04/19 21:30:00  sekmu
  * movable death-cam from WraithX
  *
@@ -197,7 +200,7 @@
 
 #ifdef RCS
 #pragma off (unreferenced)
-static char rcsid[] = "$Id: controls.c,v 1.3 2000/04/19 21:30:00 sekmu Exp $";
+static char rcsid[] = "$Id: controls.c,v 1.4 2003/07/11 21:32:28 donut Exp $";
 #pragma on (unreferenced)
 #endif
 
@@ -271,6 +274,8 @@
 	if (obj->mtype.phys_info.flags & PF_WIGGLE) {
 		fix swiggle;
 		fix_fastsincos(GameTime, &swiggle, NULL);
+		if (FrameTime < F1_0) // Only scale wiggle if getting at least 1 FPS, to avoid causing the opposite problem.
+			swiggle = fixmul(swiggle*20, FrameTime); //make wiggle fps-independant (based on pre-scaled amount of wiggle at 20 FPS)
 		vm_vec_scale_add2(&obj->mtype.phys_info.velocity,&obj->orient.uvec,fixmul(swiggle,Player_ship->wiggle));
 	}
 
--- d1x/main/powerup.c.cvs-fixes	2005-01-06 19:50:58.316093048 +0100
+++ d1x/main/powerup.c	2005-01-06 19:51:02.981383816 +0100
@@ -11,14 +11,17 @@
 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 */
 /*
- * $Source: /usr/src/cvsroot/d1x/main/powerup.c,v $
- * $Revision: 1.2 $
- * $Author: sekmu $
- * $Date: 1999/09/01 01:09:10 $
+ * $Source: /var/cvs/d1x/d1x/main/powerup.c,v $
+ * $Revision: 1.3 $
+ * $Author: donut $
+ * $Date: 2000/11/13 07:15:38 $
  * 
  * Code for powerup objects.
  * 
  * $Log: powerup.c,v $
+ * Revision 1.3  2000/11/13 07:15:38  donut
+ * fix autoselecting lasers even if primary autoselect turned off
+ *
  * Revision 1.2  1999/09/01 01:09:10  sekmu
  * forgot update for quad powerup for new hud views
  *
@@ -156,7 +159,7 @@
 
 #ifdef RCS
 #pragma off (unreferenced)
-static char rcsid[] = "$Id: powerup.c,v 1.2 1999/09/01 01:09:10 sekmu Exp $";
+static char rcsid[] = "$Id: powerup.c,v 1.3 2000/11/13 07:15:38 donut Exp $";
 #pragma on (unreferenced)
 #endif
 
@@ -428,10 +431,12 @@
                                 gauge_update_hud_mode=1;
                                 //end this section addition -VR
 				used=1;
+        			if (Allow_primary_cycle){//fix laser select even if autoselect off -MPM
                                  if(Players[Player_num].flags&PLAYER_FLAGS_QUAD_LASERS)
                                   maybe_select_primary(9+Players[Player_num].laser_level);
                                  else
                                   maybe_select_primary(5+Players[Player_num].laser_level);
+				}
 			}
 			if (!used && !(Game_mode & GM_MULTI) )
 				used = pick_up_energy();
@@ -495,7 +500,8 @@
                                 //end this section addition -VR
                                 //added on 10/8/98 by Victor Rachels for quad autoselect
                                 //changed on 10/21/98 by Victor Rachels to add other lasers
-                                maybe_select_primary(9+Players[Player_num].laser_level);
+        			if (Allow_primary_cycle)//fix laser select even if autoselect off -MPM
+                                	maybe_select_primary(9+Players[Player_num].laser_level);
                                 //end change
                                 //end this section addition
 				used=1;
--- d1x/main/netlist.c.cvs-fixes	2005-01-06 19:50:58.296096088 +0100
+++ d1x/main/netlist.c	2005-01-06 19:51:02.964386400 +0100
@@ -686,6 +686,7 @@
 			case KEY_ESC:
 				selected_game = -1;
 				done = 1;
+				break;
 			case KEYS_GR_TOGGLE_FULLSCREEN:
 				gr_toggle_fullscreen_menu();
 				break;
--- d1x/main/physics.c.cvs-fixes	2005-01-06 19:50:58.302095176 +0100
+++ d1x/main/physics.c	2005-01-06 19:51:02.967385944 +0100
@@ -633,7 +633,7 @@
 	if (obj == debug_obj) {
 		printf("object %d:\n  start pos = %x %x %x\n",objnum,XYZ(&obj->pos));
 		printf("  thrust = %x %x %x\n",XYZ(&obj->mtype.phys_info.thrust));
-		printf("  sim_time = %lx\n",sim_time);
+		printf("  sim_time = %x\n",sim_time);
 	}
 
 	//check for correct object segment 
@@ -749,7 +749,7 @@
 
 		#ifdef EXTRA_DEBUG
 		if (obj == debug_obj) {
-			printf("   FVI parms: p0 = %8x %8x %8x, segnum=%x, size=%lx\n",XYZ(&obj->pos),obj->segnum,obj->size);
+			printf("   FVI parms: p0 = %8x %8x %8x, segnum=%x, size=%x\n",XYZ(&obj->pos),obj->segnum,obj->size);
 			printf("              p1 = %8x %8x %8x\n",XYZ(&new_pos));
 		}
 		#endif
@@ -909,7 +909,7 @@
 					#ifndef NDEBUG
 					mprintf((0,"Bogus sim_time = %x, old = %x\n",sim_time,old_sim_time));
 					if (obj == debug_obj)
-						printf("   Bogus sim_time = %lx, old = %lx, attempted_dist = %lx, actual_dist = %lx\n",sim_time,old_sim_time,attempted_dist,actual_dist);
+						printf("   Bogus sim_time = %x, old = %x, attempted_dist = %x, actual_dist = %x\n",sim_time,old_sim_time,attempted_dist,actual_dist);
 					//Int3(); Removed by Rob
 					#endif
 					sim_time = old_sim_time;
@@ -921,7 +921,7 @@
 
 			#ifdef EXTRA_DEBUG
 			if (obj == debug_obj)
-				printf("   new sim_time = %lx\n",sim_time);
+				printf("   new sim_time = %x\n",sim_time);
 			#endif
 
 		}
@@ -977,7 +977,7 @@
 						#ifdef EXTRA_DEBUG
 						if (obj == debug_obj) {
 							printf("   sliding - wall_norm %x %x %x\n",XYZ(&hit_info.hit_wallnorm));
-							printf("   wall_part %lx, new velocity = %x %x %x\n",wall_part,XYZ(&obj->mtype.phys_info.velocity));
+							printf("   wall_part %x, new velocity = %x %x %x\n",wall_part,XYZ(&obj->mtype.phys_info.velocity));
 						}
 						#endif
 
--- d1x/main/polyobj.c.cvs-fixes	2005-01-06 19:50:58.309094112 +0100
+++ d1x/main/polyobj.c	2005-01-06 19:51:02.975384728 +0100
@@ -11,14 +11,17 @@
 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 */
 /*
- * $Source: /usr/src/cvsroot/d1x/main/polyobj.c,v $
- * $Revision: 1.1.1.1 $
+ * $Source: /var/cvs/d1x/d1x/main/polyobj.c,v $
+ * $Revision: 1.2 $
  * $Author: donut $
- * $Date: 1999/06/14 22:11:08 $
+ * $Date: 2002/03/26 08:20:01 $
  * 
  * Hacked-in polygon objects
  * 
  * $Log: polyobj.c,v $
+ * Revision 1.2  2002/03/26 08:20:01  donut
+ * fix briefing spinning robot display in OGL
+ *
  * Revision 1.1.1.1  1999/06/14 22:11:08  donut
  * Import of d1x 1.37 source.
  *
@@ -106,7 +109,7 @@
 
 #ifdef RCS
 #pragma off (unreferenced)
-static char rcsid[] = "$Id: polyobj.c,v 1.1.1.1 1999/06/14 22:11:08 donut Exp $";
+static char rcsid[] = "$Id: polyobj.c,v 1.2 2002/03/26 08:20:01 donut Exp $";
 #pragma on (unreferenced)
 #endif
 
@@ -139,6 +142,10 @@
 #include "piggy.h"
 #endif
 
+#ifdef OGL
+#include "ogl_init.h"
+#endif
+
 polymodel Polygon_models[MAX_POLYGON_MODELS];	// = {&bot11,&bot17,&robot_s2,&robot_b2,&bot11,&bot17,&robot_s2,&robot_b2};
 
 int N_polygon_models = 0;
@@ -755,13 +762,19 @@
 {
 	vms_vector	temp_pos=ZERO_VECTOR;
 	vms_matrix	temp_orient = IDENTITY_MATRIX;
+#ifndef OGL
 	grs_canvas	*save_canv = grd_curcanv,*temp_canv;
+#endif
 	//int			save_light;
 
 	Assert(mn>=0 && mn<N_polygon_models);
 
+#ifdef OGL
+	ogl_start_offscreen_render(0, 0, grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h);
+#else
 	temp_canv = gr_create_canvas(save_canv->cv_bitmap.bm_w,save_canv->cv_bitmap.bm_h);
 	gr_set_current_canvas(temp_canv);
+#endif
 	gr_clear_canvas( BM_XRGB(0,0,0) );
 
 	g3_start_frame();
@@ -778,11 +791,17 @@
 	//Lighting_on = 0;
 	draw_polygon_model(&temp_pos,&temp_orient,NULL,mn,0,f1_0,NULL,NULL);
 	//Lighting_on = save_light;
+	
+	g3_end_frame();
 
+#ifdef OGL
+	ogl_end_offscreen_render();
+#else
 	gr_set_current_canvas(save_canv);
 
 	gr_bitmap(0,0,&temp_canv->cv_bitmap);
 
 	gr_free_canvas(temp_canv);
+#endif
 }
 
--- d1x/main/game.c.cvs-fixes	2005-01-06 19:50:58.294096392 +0100
+++ d1x/main/game.c	2005-01-06 19:51:02.961386856 +0100
@@ -1348,6 +1348,7 @@
 	i=arch_toggle_fullscreen_menu();
 
 	generic_key_handler(KEY_PADENTER,0);
+	generic_key_handler(KEY_ENTER,0);
 	key_flush();
 
 	return i;

d1x-cvs-fixes2.patch:

--- NEW FILE d1x-cvs-fixes2.patch ---
diff -urbBwN d1x.orig/arch/linux/hmiplay.c d1x/arch/linux/hmiplay.c
--- d1x.orig/arch/linux/hmiplay.c	2000-02-07 11:13:12.000000000 +0100
+++ d1x/arch/linux/hmiplay.c	2005-08-04 14:37:08.000000000 +0200
@@ -16,12 +16,14 @@
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/ipc.h>
+#define __USE_GNU //in recent glibc versions msgbuf is only defined if you have __USE_GNU defined
 #include <sys/msg.h>
 #include "music.h"
 #include "cfile.h"
 #include "u_mem.h"
+#include "args.h"
 
-#include <SDL_thread.h>
+#include <SDL/SDL_thread.h>
 
 //#define WANT_AWE32 1
 
@@ -32,6 +34,19 @@
 //#define WANT_MPU401 1
 
 #ifdef WANT_MPU401
+
+unsigned char reset_genmidi[5] =
+	{ 0x7e, 0x7f, 0x09, 0x01, 0xf7 };
+
+#define MIDI_RESET {					\
+	SEQ_MIDIOUT(synth_dev,MIDI_SYSTEM_PREFIX);	\
+	SEQ_MIDIOUT(synth_dev,reset_genmidi[0]);	\
+	SEQ_MIDIOUT(synth_dev,reset_genmidi[1]);	\
+	SEQ_MIDIOUT(synth_dev,reset_genmidi[2]);	\
+	SEQ_MIDIOUT(synth_dev,reset_genmidi[3]);	\
+	SEQ_MIDIOUT(synth_dev,reset_genmidi[4]);	\
+}
+
 #define MIDI_MESSAGE2(a,b) {		\
 	SEQ_MIDIOUT(synth_dev,a);	\
 	SEQ_MIDIOUT(synth_dev,b);	\
@@ -60,6 +75,7 @@
 
 Voice_info *voices;
 unsigned char *data=NULL;
+char digi_last_midi_song[16] = "";
 
 struct synth_info card_info;
 
@@ -180,7 +196,8 @@
 	}
 	
 	if (card_info.synth_type==SYNTH_TYPE_MIDI) {
-		// Insert some sort of midi reset here later.
+		MIDI_RESET;
+		SEQ_DUMPBUF();
 	} else
 #endif
 #ifdef WANT_AWE32    
@@ -380,6 +397,8 @@
 #endif
 #ifdef WANT_MPU401
 	  if (card_info.synth_type==SYNTH_TYPE_MIDI) {
+		MIDI_RESET;
+		SEQ_DUMPBUF();
 	  } else
 #endif
 	{
@@ -527,7 +546,7 @@
 				     IPC_CREAT | 0660);
 		snd=malloc(sizeof(long) + 32);
 		snd->mtype=1;
-		player_thread=SDL_CreateThread(play_hmi, NULL);
+		player_thread=SDL_CreateThread((int (*)(void *))play_hmi, NULL);
 //		player_pid = play_hmi();
 	}    
 	if (strlen(message) < 16)
@@ -550,7 +569,8 @@
 int do_ipc(int qid, struct msgbuf *buf, int flags)
 {
 	int ipc_read;
-	CFILE *fptr;
+	CFILE *fptr=NULL;
+	float last_volume = volume;
 	int l=0;
 	
 	ipc_read = msgrcv(qid,buf,16,0,flags | MSG_NOERROR);
@@ -569,10 +589,24 @@
 		switch (buf->mtext[0])
 		{
 		 case 'v':
-			volume=(double) ((double) buf->mtext[0]/127.0);
+			volume=(double) (atof(buf->mtext+1)/128.0);
+			printf("vol %f->%f\n",last_volume,volume);
+			if (last_volume<=0 && volume>0) {
+				buf->mtext[0]='p';//start playing again if volume raised above 0
+				strcpy(buf->mtext+1, digi_last_midi_song);
+				//fall through to case 'p'
+			}else if (last_volume>0 && volume<=0) {
+				strcpy(buf->mtext, "s"); //stop playing if volume reduced to 0
+				stop = 2;
+				break;
+			}else
 			break;
 		 case 'p':
+			if (buf->mtext[1]) {
+				strcpy(digi_last_midi_song, buf->mtext+1);
+				if (volume>0)
 			fptr=cfopen((buf->mtext+1),"rb");		
+			}
 			if(fptr != NULL)
 			{
 				l = cfilelength(fptr);
@@ -580,8 +614,11 @@
 				cfread(data, l, 1, fptr);
 				cfclose(fptr);
 				printf ("good. fpr=%p l=%i data=%p\n", fptr, l, data);//##########3
-			}
 			stop = 0;
+			} else {
+				strcpy(buf->mtext, "s"); //not playing, thus "stop".
+				stop = 2;
+			}
 			break;
 		 case 's':
 			stop = 2;
@@ -590,6 +627,7 @@
 //			SDL_KillThread(player_thread);
 			break;  
 		}
+//		printf ("do_ipc %s ret %i\n", buf->mtext, ipc_read);//##########3
 	}
 	
 	return ipc_read;
@@ -602,7 +640,7 @@
 	int n_chunks = 0;
 	int low_dtime;
 	int low_chunk;
-	int csec;
+	int csec,lcsec;
 //	pid_t loc_pid;
 	int qid;
 	int ipc_read = 0;
@@ -635,8 +673,6 @@
 	rcv->mtype=1;
 	rcv->mtext[0]='0';
 	
-	sleep(2);
-	
 	qid=msgget ((key_t) ('l'<<24) | ('d'<<16) | ('e'<<8) | 's', 0660);
 	if(qid == -1)
 	{	
@@ -669,6 +705,8 @@
 			pos += (( (0xff & data[pos + 5]) << 8 ) + (0xff & data[pos + 4]));
 		}
 		
+		lcsec=0;
+		
 		SEQ_START_TIMER();
 		do
 		{
@@ -710,7 +748,11 @@
 				k = 0;
 			}
 			
+			if (csec != lcsec) {
 			SEQ_WAIT_TIME(csec);
+			}
+			
+			lcsec = csec;
 			
 			t_info[low_chunk].status = do_track_event(data,&t_info[low_chunk].position);
 			
@@ -761,13 +803,21 @@
 }
 
 void digi_play_midi_song( char * filename, char * melodic_bank, char * drum_bank, int loop ) {
-        char buf[128];
+	if(FindArg("-nomusic"))
+		return;
     
+	if (!filename)
+		send_ipc("p");
+	else {
+		char buf[128];
         sprintf(buf,"p%s",filename);
         send_ipc(buf);
 }
+}
 void digi_set_midi_volume( int mvolume ) { 
         char buf[128];
+	if(FindArg("-nomusic"))
+		return;
     
         sprintf(buf,"v%i",mvolume);
         send_ipc(buf);
diff -urbBwN d1x.orig/arch/linux/joystick.c d1x/arch/linux/joystick.c
--- d1x.orig/arch/linux/joystick.c	2000-10-27 06:49:22.000000000 +0200
+++ d1x/arch/linux/joystick.c	2005-08-04 14:37:08.000000000 +0200
@@ -1,6 +1,6 @@
 #include <stdlib.h>
 #include <stdio.h>
-#include "joystick.h"
+#include <linux/joystick.h>
 #include <sys/ioctl.h>
 #include <fcntl.h>
 #include <unistd.h>
@@ -162,6 +162,7 @@
 ubyte joystick_read_raw_axis (ubyte mask, int *axes) {
 	int i;
 	
+	if (!joy_installed) return 0;
 	j_Update_state();
 
 	for (i = 0; i <= j_num_axes; i++) {
@@ -339,6 +340,7 @@
 
 
 int joy_get_button_state (int btn) {
+	if (!joy_installed) return 0;
   if(btn >= j_num_buttons)
    return 0;
         j_Update_state ();
@@ -350,6 +352,7 @@
 int joy_get_button_down_cnt (int btn) {
 	int downcount;
 
+	if (!joy_installed) return 0;
 	j_Update_state ();
 
 	downcount = j_button[btn].downcount;
@@ -362,6 +365,7 @@
 //changed 6/24/99 to finally squish the timedown bug - Owen Evans
 fix joy_get_button_down_time(int btn)  {
 	fix downtime;
+	if (!joy_installed) return 0;
 	j_Update_state ();
 
 	if (j_button[btn].state) {
diff -urbBwN d1x.orig/arch/sdl/clipboard.c d1x/arch/sdl/clipboard.c
--- d1x.orig/arch/sdl/clipboard.c	1970-01-01 01:00:00.000000000 +0100
+++ d1x/arch/sdl/clipboard.c	2005-08-04 14:37:08.000000000 +0200
@@ -0,0 +1,89 @@
+#include "clipboard.h"
+
+#include <SDL/SDL.h>
+#include <SDL/SDL_syswm.h>
+#include <limits.h>
+#include <string.h>
+
+//adapted by Matthew Mueller from the Scrap 1.0 example by Sam Lantinga
+// ( see http://www.libsdl.org/projects/scrap/ )
+int getClipboardText(char *text, int strlength)
+{
+	int retval = 0;
+	SDL_SysWMinfo info;
+	SDL_VERSION(&info.version);
+	if ( SDL_GetWMInfo(&info) )
+	{
+		if ( info.subsystem == SDL_SYSWM_X11 )
+		{
+			Display *SDL_Display = info.info.x11.display;
+			Window SDL_Window = info.info.x11.window;
+			void (*Lock_Display)(void) = info.info.x11.lock_func;
+			void (*Unlock_Display)(void) = info.info.x11.unlock_func;
+			
+			Window owner;
+			Atom selection;
+			Atom seln_type;
+			int seln_format;
+			unsigned long nbytes;
+			unsigned long overflow;
+			unsigned char *src;
+
+			/* Enable the special window hook events */
+			SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
+
+			Lock_Display();
+			owner = XGetSelectionOwner(SDL_Display, XA_PRIMARY);
+			Unlock_Display();
+			if ( (owner == None) || (owner == SDL_Window) )
+			{
+				owner = DefaultRootWindow(SDL_Display);
+				selection = XA_CUT_BUFFER0;
+			}
+			else
+			{
+				int selection_response = 0;
+				SDL_Event event;
+
+				owner = SDL_Window;
+				Lock_Display();
+				selection = XInternAtom(SDL_Display, "SDL_SELECTION", False);
+				XConvertSelection(SDL_Display, XA_PRIMARY, XA_STRING,
+						selection, owner, CurrentTime);
+				Unlock_Display();
+				while ( ! selection_response )
+				{
+					SDL_WaitEvent(&event);
+					if ( event.type == SDL_SYSWMEVENT )
+					{
+						XEvent xevent = event.syswm.msg->event.xevent;
+
+						if ( (xevent.type == SelectionNotify) &&
+								(xevent.xselection.requestor == owner) )
+							selection_response = 1;
+					}
+				}
+			}
+			Lock_Display();
+			if ( XGetWindowProperty(SDL_Display, owner, selection, 0, INT_MAX/4,
+						False, XA_STRING, &seln_type, &seln_format,
+						&nbytes, &overflow, &src) == Success )
+			{
+				if ( seln_type == XA_STRING )
+				{
+					strncpy(text, src, strlength);
+					retval = nbytes;
+				}
+				XFree(src);
+			}
+			Unlock_Display();
+
+			SDL_EventState(SDL_SYSWMEVENT, SDL_DISABLE);
+		}
+		//else
+		//	SDL is not running on X11
+
+	}
+
+	return retval;
+}
diff -urbBwN d1x.orig/arch/sdl/makefile d1x/arch/sdl/makefile
--- d1x.orig/arch/sdl/makefile	2000-01-17 06:58:38.000000000 +0100
+++ d1x/arch/sdl/makefile	2005-08-04 14:37:08.000000000 +0200
@@ -9,7 +9,7 @@
 endif
 
 ifdef SDL_INPUT
-OBJECTS += event.$(OBJ) key_arch.$(OBJ) mouse.$(OBJ)
+OBJECTS += event.$(OBJ) key_arch.$(OBJ) mouse.$(OBJ) clipboard.$(OBJ)
 endif
 
 ifdef SDL_VIDEO
diff -urbBwN d1x.orig/include/clipboard.h d1x/include/clipboard.h
--- d1x.orig/include/clipboard.h	1970-01-01 01:00:00.000000000 +0100
+++ d1x/include/clipboard.h	2005-08-04 14:37:42.000000000 +0200
@@ -0,0 +1,9 @@
+#ifndef _CLIPBOARD_H
+#define _CLIPBOARD_H
+
+#define MAX_PASTE_SIZE 36
+
+// fills the specified buffer with clipboard text. returns number chars copied
+extern int getClipboardText(char *text, int strlength);
+
+#endif
diff -urbBwN d1x.orig/main/credits.c d1x/main/credits.c
--- d1x.orig/main/credits.c	2005-07-31 11:47:39.000000000 +0200
+++ d1x/main/credits.c	2005-08-04 14:37:08.000000000 +0200
@@ -11,14 +11,17 @@
 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 */
 /*
- * $Source: /usr/src/cvsroot/d1x/main/credits.c,v $
- * $Revision: 1.3 $
+ * $Source: /var/cvs/d1x/d1x/main/credits.c,v $
+ * $Revision: 1.4 $
  * $Author: donut $
- * $Date: 1999/11/20 10:05:16 $
+ * $Date: 2001/07/27 19:54:35 $
  * 
  * Routines to display the credits.
  * 
  * $Log: credits.c,v $
+ * Revision 1.4  2001/07/27 19:54:35  donut
+ * fix minor memleaks in credits
+ *
  * Revision 1.3  1999/11/20 10:05:16  donut
  * variable size menu patch from Jan Bobrowski.  Variable menu font size support and a bunch of fixes for menus that didn't work quite right, by me (MPM).
  *
@@ -150,7 +153,7 @@
 
 #ifdef RCS
 #pragma off (unreferenced)
-static char rcsid[] = "$Id: credits.c,v 1.3 1999/11/20 10:05:16 donut Exp $";
+static char rcsid[] = "$Id: credits.c,v 1.4 2001/07/27 19:54:35 donut Exp $";
 #pragma on (unreferenced)
 #endif
 
@@ -230,18 +233,8 @@
 	ROW_SPACING=names_font->ft_h+1;
 	
 	l = SHEIGHT;
-	fade_values_scalled = malloc(l);
-	scale_line(fade_values, fade_values_scalled, 200, l);//hey, why not?  Its just a one dimensional bitmap :) -MPM
-	
-//	memset(fade_values_scalled, 31, l);
-//	memcpy(fade_values_scalled, fade_values, 100);
-//	memcpy(fade_values_scalled+l-100, fade_values+100, 100);
 	set_screen_mode(SCREEN_MENU);
 	num_lines = l/ROW_SPACING + 1;
-	buffer = malloc(num_lines*80);// l*80); <--typo? -MPM
-
-	// Clear out all tex buffer lines.
-	for (i=0; i<num_lines; i++ ) buffer[i][0] = 0;
 
 	have_bin_file = 0;
 	file = cfopen( "credits.tex", "rb" );
@@ -260,6 +253,16 @@
 		return;
 	}
 
+	fade_values_scalled = malloc(l);
+	scale_line(fade_values, fade_values_scalled, 200, l);//hey, why not?  Its just a one dimensional bitmap :) -MPM
+//	memset(fade_values_scalled, 31, l);
+//	memcpy(fade_values_scalled, fade_values, 100);
+//	memcpy(fade_values_scalled+l-100, fade_values+100, 100);
+	
+	buffer = malloc(num_lines*80);
+	// Clear out all tex buffer lines.
+	for (i=0; i<num_lines; i++ ) buffer[i][0] = 0;
+
 	songs_play_song( SONG_CREDITS, 0 );
 
 	gr_remap_bitmap_good( &backdrop,backdrop_palette, -1, -1 );
diff -urbBwN d1x.orig/main/game.c d1x/main/game.c
--- d1x.orig/main/game.c	2005-07-31 11:47:39.000000000 +0200
+++ d1x/main/game.c	2005-08-04 14:37:08.000000000 +0200
@@ -1333,6 +1333,7 @@
 	//added 2000/06/19 Matthew Mueller - hack to fix "infinite toggle" problem
 	//it seems to be that the screen mode change takes long enough that the key has already sent repeat codes, or that its unpress event gets dropped, etc.  This is a somewhat ugly fix, but it works.
 	generic_key_handler(KEY_PADENTER,0);
+	generic_key_handler(KEY_ENTER,0);
 	key_flush();
 	//end addition -MM
 	return i;
diff -urbBwN d1x.orig/main/kmatrix.c d1x/main/kmatrix.c
--- d1x.orig/main/kmatrix.c	1999-06-15 00:08:16.000000000 +0200
+++ d1x/main/kmatrix.c	2005-08-04 14:37:08.000000000 +0200
@@ -11,14 +11,17 @@
 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 */
 /*
- * $Source: /usr/src/cvsroot/d1x/main/kmatrix.c,v $
- * $Revision: 1.1.1.1 $
+ * $Source: /var/cvs/d1x/d1x/main/kmatrix.c,v $
+ * $Revision: 1.2 $
  * $Author: donut $
- * $Date: 1999/06/14 22:08:16 $
+ * $Date: 2002/03/26 22:10:09 $
  * 
  * Kill matrix displayed at end of level.
  * 
  * $Log: kmatrix.c,v $
+ * Revision 1.2  2002/03/26 22:10:09  donut
+ * fix multiplayer endlevel score display in high res
+ *
  * Revision 1.1.1.1  1999/06/14 22:08:16  donut
  * Import of d1x 1.37 source.
  *
@@ -99,7 +102,7 @@
 
 #ifdef RCS
 #pragma off (unreferenced)
-static char rcsid[] = "$Id: kmatrix.c,v 1.1.1.1 1999/06/14 22:08:16 donut Exp $";
+static char rcsid[] = "$Id: kmatrix.c,v 1.2 2002/03/26 22:10:09 donut Exp $";
 #pragma on (unreferenced)
 #endif
 
@@ -139,6 +142,16 @@
 #include "hudlog.h"
 //end addition -MM
 
+static int rescale_x(int x)
+{
+	return x * GWIDTH / 320;
+}
+
+static int rescale_y(int y)
+{
+	return y * GHEIGHT / 200;
+}
+
 #define CENTERING_OFFSET(x) ((300 - (70 + (x)*25 ))/2)
 
 int kmatrix_kills_changed = 0;
@@ -147,15 +160,15 @@
 {
 	int j, x, y;
 
-	y = 50+i*9;
+	y = rescale_y(50+i*9);
 
 	// Print player name.
 
-	gr_printf( CENTERING_OFFSET(N_players), y, "%s", Players[sorted[i]].callsign );
+	gr_printf( rescale_x(CENTERING_OFFSET(N_players)), y, "%s", Players[sorted[i]].callsign );
 
 	for (j=0; j<N_players; j++) {
 
-		x = 70 + CENTERING_OFFSET(N_players) + j*25;
+		x = rescale_x(70 + CENTERING_OFFSET(N_players) + j*25);
 
 		if (sorted[i]==sorted[j]) {
 			if (kill_matrix[sorted[i]][sorted[j]] == 0) {
@@ -177,7 +190,7 @@
 
 	}
 	
-	x = 70 + CENTERING_OFFSET(N_players) + N_players*25;
+	x = rescale_x(70 + CENTERING_OFFSET(N_players) + N_players*25);
 	gr_set_fontcolor( BM_XRGB(25,25,25),-1 );
 	gr_printf( x ,y,"%4d",Players[sorted[i]].net_kills_total);
 }
@@ -195,14 +208,14 @@
 		else
 			color = sorted[j];
 
-		x = 70 + CENTERING_OFFSET(N_players) + j*25;
+		x = rescale_x(70 + CENTERING_OFFSET(N_players) + j*25);
 		gr_set_fontcolor(gr_getcolor(player_rgb[color].r,player_rgb[color].g,player_rgb[color].b),-1 );
-		gr_printf( x, 40, "%c", Players[sorted[j]].callsign[0] );
+		gr_printf( x, rescale_y(40), "%c", Players[sorted[j]].callsign[0] );
 	}
 
-	x = 70 + CENTERING_OFFSET(N_players) + N_players*25;
+	x = rescale_x(70 + CENTERING_OFFSET(N_players) + N_players*25);
 	gr_set_fontcolor( BM_XRGB(31,31,31),-1 );
-	gr_printf( x, 40, TXT_KILLS);
+	gr_printf( x, rescale_y(40), TXT_KILLS);
 
 		
 }
@@ -212,26 +225,26 @@
 {
 	int j, x, y;
 	
-	y = 55 + N_players * 9;
+	y = rescale_y(55 + N_players * 9);
 
 //	gr_set_fontcolor(gr_getcolor(player_rgb[j].r,player_rgb[j].g,player_rgb[j].b),-1 );
 	gr_set_fontcolor( BM_XRGB(31,31,31),-1 );
 
-	x = CENTERING_OFFSET(N_players);
+	x = rescale_x(CENTERING_OFFSET(N_players));
 	gr_printf( x, y, TXT_DEATHS );
 
 	for (j=0; j<N_players; j++) {
-		x = 70 + CENTERING_OFFSET(N_players) + j*25;
+		x = rescale_x(70 + CENTERING_OFFSET(N_players) + j*25);
 		gr_printf( x, y, "%d", Players[sorted[j]].net_killed_total );
 	}
 
-	y = 55 + 72 + 12;
-	x = 35;
+	y = rescale_y(55 + 72 + 12);
+	x = rescale_x(35);
 
 	{
 		int sw, sh, aw;
 		gr_get_string_size(TXT_PRESS_ANY_KEY2, &sw, &sh, &aw);	
-		gr_printf( 160-(sw/2), y, TXT_PRESS_ANY_KEY2);
+		gr_printf( rescale_x(160)-(sw/2), y, TXT_PRESS_ANY_KEY2);
 	}
 }
 
@@ -246,12 +259,12 @@
 
 	gr_set_current_canvas(NULL);
 	
-	pcx_error = pcx_read_bitmap("STARS.PCX",&grd_curcanv->cv_bitmap,grd_curcanv->cv_bitmap.bm_type,NULL);
+	pcx_error = pcx_read_fullscr("STARS.PCX", NULL);
 	Assert(pcx_error == PCX_ERROR_NONE);
 
 	grd_curcanv->cv_font = Gamefonts[GFONT_MEDIUM_3];
 
-	gr_string( 0x8000, 15, TXT_KILL_MATRIX_TITLE	);
+	gr_string( 0x8000, rescale_y(15), TXT_KILL_MATRIX_TITLE	);
 
 	grd_curcanv->cv_font = Gamefonts[GFONT_SMALL];
 
diff -urbBwN d1x.orig/main/newmenu.c d1x/main/newmenu.c
--- d1x.orig/main/newmenu.c	2005-08-03 19:29:19.000000000 +0200
+++ d1x/main/newmenu.c	2005-08-04 14:37:08.000000000 +0200
@@ -11,14 +11,17 @@
 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 */
 /*
- * $Source: /usr/src/cvsroot/d1x/main/newmenu.c,v $
- * $Revision: 1.13 $
+ * $Source: /var/cvs/d1x/d1x/main/newmenu.c,v $
+ * $Revision: 1.14 $
  * $Author: donut $
- * $Date: 2000/10/28 10:02:48 $
+ * $Date: 2003/06/27 10:06:59 $
  * 
  * Routines for menus.
  * 
  * $Log: newmenu.c,v $
+ * Revision 1.14  2003/06/27 10:06:59  donut
+ * make keypad enter numbers in input fields, and allow pasting from clipboard (patch from sekmu)
+ *
  * Revision 1.13  2000/10/28 10:02:48  donut
  * scale menu bevels too
  *
@@ -518,7 +521,7 @@
 
 #ifdef RCS
 #pragma off (unreferenced)
-static char rcsid[] = "$Id: newmenu.c,v 1.13 2000/10/28 10:02:48 donut Exp $";
+static char rcsid[] = "$Id: newmenu.c,v 1.14 2003/06/27 10:06:59 donut Exp $";
 #pragma on (unreferenced)
 #endif
 
@@ -528,6 +531,8 @@
 #include <stdarg.h>
 #include <ctype.h>
 
+#include "clipboard.h"
+
 #include "error.h"
 #include "types.h"
 #include "gr.h"
@@ -1288,6 +1293,21 @@
 
 		k = key_inkey();
 
+                switch( k )
+                {
+                  case KEY_PAD0: k = KEY_0;  break;
+                  case KEY_PAD1: k = KEY_1;  break;
+                  case KEY_PAD2: k = KEY_2;  break;
+                  case KEY_PAD3: k = KEY_3;  break;
+                  case KEY_PAD4: k = KEY_4;  break;
+                  case KEY_PAD5: k = KEY_5;  break;
+                  case KEY_PAD6: k = KEY_6;  break;
+                  case KEY_PAD7: k = KEY_7;  break;
+                  case KEY_PAD8: k = KEY_8;  break;
+                  case KEY_PAD9: k = KEY_9;  break;
+                  case KEY_PADPERIOD: k = KEY_PERIOD; break;
+                }
+
 		if (subfunction)
 			(*subfunction)(nitems,item,&k,choice);
 
@@ -1327,6 +1347,45 @@
 		old_choice = choice;
 	
 		switch( k )	{
+		case KEY_V + KEY_CTRLED:
+                case KEY_INSERT + KEY_SHIFTED:
+                          if(item[choice].type==NM_TYPE_INPUT)
+                           {
+                            char cbtext[MAX_PASTE_SIZE+1];
+                            memset(cbtext,0,MAX_PASTE_SIZE+1);
+                            int ret = getClipboardText(cbtext,MAX_PASTE_SIZE);
+                              if(ret)
+                               {
+                                int idx;
+
+                                  if (item[choice].value==-1)
+                                   {
+                                     item[choice].value = 0;
+                                   }
+
+                                  for(idx = 0 ; (idx < ret) && (item[choice].value < item[choice].text_len ) ; idx++ )
+                                   {
+                                    int ascii = cbtext[idx];
+                                    int allowed;
+
+                                     allowed = char_allowed(ascii);
+                                      if (!allowed && ascii==' ' && char_allowed('_'))
+                                       {
+                                         ascii = '_';
+                                         allowed=1;
+                                       }
+
+                                      if (allowed)
+                                       {
+                                         item[choice].text[item[choice].value++] = ascii;
+                                         item[choice].text[item[choice].value] = 0;
+                                         item[choice].redraw=1;	
+                                       }
+                                   }
+                                 k = -1;
+                               }
+                           }
+                        break;
 		case KEY_TAB + KEY_SHIFTED:
 		case KEY_UP:
 		case KEY_PAD8:
@@ -1437,7 +1496,7 @@
 
 		}
 
-		if ( choice > -1 )	{
+		if ( (choice > -1) && (k != -1))	{
 			int ascii;
 
 			if ( ((item[choice].type==NM_TYPE_INPUT)||((item[choice].type==NM_TYPE_INPUT_MENU)&&(item[choice].group==1)) )&& (old_choice==choice) )	{

d1x-fix-rebirth-ogl.patch:

--- NEW FILE d1x-fix-rebirth-ogl.patch ---
diff -ur d1x.orig/arch/ogl/gr.c d1x/arch/ogl/gr.c
--- d1x.orig/arch/ogl/gr.c	2006-08-20 23:13:25.000000000 +0200
+++ d1x/arch/ogl/gr.c	2006-08-20 23:14:01.000000000 +0200
@@ -64,7 +64,8 @@
 int gr_toggle_fullscreen(void){
 	gr_do_fullscreen(!ogl_fullscreen);
 	//	grd_curscreen->sc_mode=0;//hack to get it to reset screen mode
-	glFlush(); // ZICO - prevents black screen, screen glitches etc.
+	if (gl_initialized)
+		glFlush(); // ZICO - prevents black screen, screen glitches etc.
  
 	return ogl_fullscreen;
 }

d1x-fix.patch:

--- NEW FILE d1x-fix.patch ---
--- d1x/main/gameseg.h.orig	Sun Jun 25 10:34:29 2000
+++ d1x/main/gameseg.h	Sun Jun  2 01:25:12 2002
@@ -170,7 +170,7 @@
 segmasks get_seg_masks(vms_vector *checkp,int segnum,fix rad, char *calling_file, int calling_linenum);
 
 //this macro returns true if the segnum for an object is correct
-#define check_obj_seg(obj) (get_seg_masks(&(obj)->pos,(obj)->segnum,0).centermask == 0)
+#define check_obj_seg(obj) (get_seg_masks(&(obj)->pos,(obj)->segnum,0,__FILE__,__LINE__).centermask == 0)
 
 //Tries to find a segment for a point, in the following way:
 // 1. Check the given segment
--- d1x/main/gamesave.c.orig	Thu Sep  2 15:50:13 1999
+++ d1x/main/gamesave.c	Sun Jun  2 01:30:58 2002
@@ -302,6 +302,7 @@
 #include "inferno.h"
 #ifdef EDITOR
 #include "editor/editor.h"
+#include "strutil.h"
 #endif
 #include "error.h"
 #include "object.h"
--- d1x/editor/med.c.orig	Tue Jun 15 00:03:43 1999
+++ d1x/editor/med.c	Sun Jun  2 01:33:50 2002
@@ -765,7 +765,7 @@
 
 int DosShell()
 {
-	int ok, w, h;
+	int w, h;
 	grs_bitmap * save_bitmap;
 
 	// Save the current graphics state.
--- d1x/editor/autosave.c.orig	Tue Jun 15 00:02:47 1999
+++ d1x/editor/autosave.c	Sun Jun  2 01:35:05 2002
@@ -130,6 +130,7 @@
 #include "mono.h"
 #include "u_mem.h"
 #include "ui.h"
+#include "strutil.h"
 
 #define AUTOSAVE_PERIOD 5			// Number of minutes for timed autosave
 
--- d1x/editor/eobject.c.orig	Tue Jun 15 00:03:00 1999
+++ d1x/editor/eobject.c	Sun Jun  2 01:36:22 2002
@@ -569,7 +569,7 @@
 	int segnum;
 
 	for (segnum=0;segnum <= Highest_segment_index; segnum++) {
-		segmasks	result = get_seg_masks(&obj->pos,segnum,0);
+		segmasks	result = get_seg_masks(&obj->pos,segnum,0,__FILE__,__LINE__);
 		if (result.centermask == 0) {
 			int	fate;
 			fvi_info	hit_info;
@@ -604,7 +604,7 @@
 //	Return 0 if object is in expected segment, else return 1
 int verify_object_seg(object *objp, vms_vector *newpos)
 {
-	segmasks	result = get_seg_masks(newpos, objp->segnum, objp->size);
+	segmasks	result = get_seg_masks(newpos, objp->segnum, objp->size, __FILE__, __LINE__);
 
 	if (result.facemask == 0)
 		return 0;
@@ -974,7 +974,7 @@
 {
 	object	*objp = &Objects[objnum];
 
-	segmasks	result = get_seg_masks(newpos, objp->segnum, objp->size);
+	segmasks	result = get_seg_masks(newpos, objp->segnum, objp->size, __FILE__, __LINE__);
 
 	if (result.facemask == 0) {
 		//mprintf((0, "Object #%i moved from (%7.3f %7.3f %7.3f) to (%7.3f %7.3f %7.3f)\n", objnum, f2fl(objp->pos.x), f2fl(objp->pos.y), f2fl(objp->pos.z), f2fl(newpos->x), f2fl(newpos->y), f2fl(newpos->z)));
--- d1x/editor/kgame.c.orig	Tue Jun 15 00:03:24 1999
+++ d1x/editor/kgame.c	Sun Jun  2 01:37:10 2002
@@ -177,7 +177,7 @@
 			Perm_player_segnum = -1;
 
 		if (Perm_player_segnum!=-1) {
-			if (get_seg_masks(&Perm_player_position,Perm_player_segnum,0).centermask==0) {
+			if (get_seg_masks(&Perm_player_position,Perm_player_segnum,0,__FILE__,__LINE__).centermask==0) {
 				ConsoleObject->pos = Perm_player_position;
 				obj_relink(ConsoleObject-Objects,Perm_player_segnum);
 				ConsoleObject->orient = Perm_player_orient;
--- d1x/editor/segment.c.orig	Thu Sep  2 15:37:06 1999
+++ d1x/editor/segment.c	Sun Jun  2 01:38:12 2002
@@ -2223,7 +2223,7 @@
 
 	for (i=0;i<=Highest_segment_index; i++) {
 		if (i != segnum) {
-			masks = get_seg_masks(&segcenter, i, 0);
+			masks = get_seg_masks(&segcenter, i, 0, __FILE__, __LINE__);
 			if (masks.centermask == 0) {
 				mprintf((0, "Segment %i center is contained in segment %i\n", segnum, i));
 				continue;
@@ -2234,7 +2234,7 @@
 
 				vm_vec_sub(&pdel, &Vertices[Segments[segnum].verts[v]], &segcenter);
 				vm_vec_scale_add(&presult, &segcenter, &pdel, (F1_0*15)/16);
-				masks = get_seg_masks(&presult, i, 0);
+				masks = get_seg_masks(&presult, i, 0, __FILE__, __LINE__);
 				if (masks.centermask == 0) {
 					mprintf((0, "Segment %i near vertex %i is contained in segment %i\n", segnum, v, i));
 					break;
--- d1x/editor/func.c.orig	Tue Jun 15 00:03:05 1999
+++ d1x/editor/func.c	Sun Jun  2 01:39:06 2002
@@ -40,6 +40,7 @@
 #include <string.h>
 
 #include "func.h"
+#include "strutil.h"
 
 #define MAX_PARAMS 10
 
--- d1x/ui/mouse.c.orig	Tue Jun 15 00:14:39 1999
+++ d1x/ui/mouse.c	Sun Jun  2 01:41:23 2002
@@ -55,7 +55,7 @@
 
 #include <stdlib.h>
 #ifdef __SDL__
-#include "SDL.h"
+#include <SDL/SDL.h>
 #endif
 
 #include "u_mem.h"
@@ -168,7 +168,7 @@
 {   
         int buttons,w,h;
 #ifdef __LINUX__
-	Uint16 new_x, new_y;
+	int new_x, new_y;
 	buttons = SDL_GetMouseState(&new_x,&new_y);
 	Mouse.dx = new_x - Mouse.x;
 	Mouse.dy = new_y - Mouse.y;

d1x-fixc.patch:

--- NEW FILE d1x-fixc.patch ---
--- d1x/2d/2dsline.c.orig	1999-10-14 06:48:21.000000000 +0200
+++ d1x/2d/2dsline.c	2004-01-18 19:48:31.746835235 +0100
@@ -131,8 +131,10 @@
 void gr_linear_darken(ubyte * dest, int darkening_level, int count, ubyte * fade_table) {
 	register int i;
 
-	for (i=0;i<count;i++)
-		*dest=fade_table[(*dest++)+(darkening_level*256)];
+	for (i=0;i<count;i++) {
+		*dest=fade_table[(*dest)+(darkening_level*256)];
+		dest++;
+	}
 }
 #endif
 

d1x-gcc3.patch:

--- NEW FILE d1x-gcc3.patch ---
--- d1x/include/vecmat.h.orig	Tue Jun 15 00:02:28 1999
+++ d1x/include/vecmat.h	Sat Oct 12 02:00:57 2002
@@ -247,8 +247,8 @@
 
 #ifdef __WATCOMC__
 #pragma aux vm_vec_make "*_" parm [eax] [edx] [ebx] [ecx] value [eax] modify exact [] = \
-"mov 0[eax],edx" \ 
-"mov 4[eax],ebx" \ 
+"mov 0[eax],edx" \
+"mov 4[eax],ebx" \
 "mov 8[eax],ecx";
 
 #endif
@@ -258,8 +258,8 @@
 
 #ifdef __WATCOMC__
 #pragma aux vm_angvec_make "*_" parm [eax] [dx] [bx] [cx] value [eax] modify exact [] = \
-"mov 0[eax],dx" \ 
-"mov 2[eax],bx" \ 
+"mov 0[eax],dx" \
+"mov 2[eax],bx" \
 "mov 4[eax],cx";
 
 #endif
@@ -470,20 +470,20 @@
 #ifdef INLINE
 #ifdef __WATCOMC__
 #pragma aux vm_vec_dotprod parm [esi] [edi] value [eax] modify exact [eax ebx ecx edx] = \
-"mov	eax,[esi]" \ 
-"imul	dword ptr [edi]" \ 
-"mov	ebx,eax" \ 
-"mov	ecx,edx" \ 
-\
-"mov	eax,4[esi]" \ 
-"imul	dword ptr 4[edi]" \ 
-"add	ebx,eax" \ 
-"adc	ecx,edx" \ 
-\
-"mov	eax,8[esi]" \ 
-"imul	dword ptr 8[edi]" \ 
-"add	eax,ebx" \ 
-"adc	edx,ecx" \ 
+"mov	eax,[esi]" \
+"imul	dword ptr [edi]" \
+"mov	ebx,eax" \
+"mov	ecx,edx" \
+\
+"mov	eax,4[esi]" \
+"imul	dword ptr 4[edi]" \
+"add	ebx,eax" \
+"adc	ecx,edx" \
+\
+"mov	eax,8[esi]" \
+"imul	dword ptr 8[edi]" \
+"add	eax,ebx" \
+"adc	edx,ecx" \
 \
 "shrd	eax,edx,16";
 
--- d1x/arch/linux/linuxnet.c.orig	Mon Feb  7 11:26:06 2000
+++ d1x/arch/linux/linuxnet.c	Sat Oct 12 02:03:10 2002
@@ -1,5 +1,6 @@
 
 #include "types.h"
+#include <string.h>
 
 #include "ipx_drv.h"
 #include "ipx_bsd.h"
--- d1x/arch/linux/include/ukali.h.orig	Tue Jun 15 00:01:50 1999
+++ d1x/arch/linux/include/ukali.h	Sat Oct 12 02:03:39 2002
@@ -69,4 +69,4 @@
 int KaliSendPacket(int hand, char *data, int len, kaliaddr_ipx *to);
 int KaliReceivePacket(int hand, char *data, int len, kaliaddr_ipx *from);
 
-#endif  __UKALI_H__
+#endif
--- d1x/main/ip_base.h.orig	Wed Mar  1 10:21:46 2000
+++ d1x/main/ip_base.h	Sat Oct 12 02:10:39 2002
@@ -5,9 +5,9 @@
 #ifndef ___IP_BASE_H
 #define ___IP_BASE_H
 
-#include <map.h>
-#include <list.h>
-#include <algo.h>
+#include <map>
+#include <list>
+#include <algorithm>
 extern "C" {
 #include "ip_basec.h"
 #include "fix.h"
@@ -17,6 +17,8 @@
 #include "timer.h"
 }
 
+using namespace std;
+
 class ip_addr;//prototype for arch_ip_queryhost
 
 #include "ipclient.h"
--- d1x/arch/sdl/digi.c.orig	Thu May 25 03:11:50 2000
+++ d1x/arch/sdl/digi.c	Sat Oct 12 02:12:19 2002
@@ -214,8 +214,8 @@
      sldata = sl->samples;
     }
     v = *(sldata++) - 0x80;
-    *(sp++) = mix8[ *sp + fixmul(v, vl) + 0x80 ];
-    *(sp++) = mix8[ *sp + fixmul(v, vr) + 0x80 ];
+    *(sp) = mix8[ *sp + fixmul(v, vl) + 0x80 ]; sp++;
+    *(sp) = mix8[ *sp + fixmul(v, vr) + 0x80 ]; sp++;
    }
    sl->position = sldata - sl->samples;
   }
--- d1x/texmap/scanline.c.orig	Wed Dec  8 02:08:10 1999
+++ d1x/texmap/scanline.c	Sat Oct 12 02:13:27 2002
@@ -86,7 +86,7 @@
 
 	fade = tmap_flat_shade_value<<8;
 	for (x= fx_xright-fx_xleft+1 ; x > 0; --x ) {
-		*dest++ = gr_fade_table[ fade |(*dest)];
+		*dest = gr_fade_table[ fade |(*dest)]; dest++;
 	}
 }
 
--- d1x/main/game.c.orig	Sat Oct 12 02:13:49 2002
+++ d1x/main/game.c	Sat Oct 12 02:15:14 2002
@@ -2710,7 +2710,7 @@
 
 //DEFINE_CHEAT needs to be done this weird way since stupid c macros can't (portably) handle multiple args, nor can they realize that within {}'s should all be the same arg.  blah.
 #define DEFINE_CHEAT(name) int cheat_ ## name ## _index;\
-	ubyte cheat_ ## name ## []
+	ubyte cheat_ ## name []
 
 DEFINE_CHEAT(frametime)={KEY_F, KEY_R, KEY_A, KEY_M, KEY_E, KEY_T, KEY_I, KEY_M, KEY_E};
 int gr_renderstats=0;
--- d1x/main/netlist.c.orig	Sat Oct 28 11:31:08 2000
+++ d1x/main/netlist.c	Sat Oct 12 02:18:28 2002
@@ -297,7 +297,7 @@
            if(game.flags & NETFLAG_ENABLE_ALT_VULCAN)
                    info+=sprintf(info,"\n Alt Vulcan");
 	   info+=sprintf(info,"\n Banned");
-#define NETFLAG_SHOW_BANNED(D,V) if (!(game.flags&NETFLAG_DO ## D)) {if (i>3) i=0; else i++; info+=sprintf(info,"%c " ## #V,i?sep0:'\n');b++;sep0=',';}
+#define NETFLAG_SHOW_BANNED(D,V) if (!(game.flags&NETFLAG_DO ## D)) {if (i>3) i=0; else i++; info+=sprintf(info,"%c " #V,i?sep0:'\n');b++;sep0=',';}
 	   NETFLAG_SHOW_BANNED(LASER,laser);
 	   NETFLAG_SHOW_BANNED(QUAD,quad);
 	   NETFLAG_SHOW_BANNED(VULCAN,vulcan);

d1x-gcc34.patch:

--- NEW FILE d1x-gcc34.patch ---
--- d1x/main/custom.c.gcc34	2004-11-27 15:26:06.953447136 +0100
+++ d1x/main/custom.c	2004-11-27 15:28:38.088471120 +0100
@@ -279,7 +279,9 @@
 		    Error( "Error modifying selector base in custom.c\n" );
 	    #endif
 	    if ( cip->flags & BM_FLAG_RLE ) {
-		*(((int *)p)++) = j;
+	        int *ip = (int *)p;
+		*ip = j;
+		p += 4;
 		j -= 4;
 	    }
 	    if (cfread(p, 1, j, f) < 1)

d1x-gcc43.patch:

--- NEW FILE d1x-gcc43.patch ---
diff -up d1x/main/ipclient.cpp~ d1x/main/ipclient.cpp
--- d1x/main/ipclient.cpp~	2008-07-23 15:53:27.000000000 +0200
+++ d1x/main/ipclient.cpp	2008-07-23 15:53:27.000000000 +0200
@@ -2,6 +2,8 @@
  * ipclient.cpp - udp/ip client code
  * added 2000/02/07 Matt Mueller
  */
+#include <string.h> 
+
 extern "C"{
 #include "mono.h"
 #include "key.h"
diff -up d1x/main/ipserver.cpp~ d1x/main/ipserver.cpp
--- d1x/main/ipserver.cpp~	2008-07-23 15:56:10.000000000 +0200
+++ d1x/main/ipserver.cpp	2008-07-23 15:56:10.000000000 +0200
@@ -4,6 +4,7 @@
  */
 
 #include <stdlib.h>
+#include <string.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include <signal.h>
diff -up d1x/2d/bitblt.c~ d1x/2d/bitblt.c
--- d1x/2d/bitblt.c~	2008-07-23 16:02:36.000000000 +0200
+++ d1x/2d/bitblt.c	2008-07-23 16:02:36.000000000 +0200
@@ -1026,7 +1026,7 @@ void gr_bm_ubitblt0x_rle(int w, int h, i
 
 // rescalling bitmaps, 10/14/99 Jan Bobrowski jb at wizard.ae.krakow.pl
 
-inline void scale_line(byte *in, byte *out, int ilen, int olen)
+void scale_line(byte *in, byte *out, int ilen, int olen)
 {
 	int a = olen/ilen, b = olen%ilen;
 	int c = 0, i;
diff -up d1x/arch/sdl/digi.c~ d1x/arch/sdl/digi.c
--- d1x/arch/sdl/digi.c~	2008-07-23 16:31:07.000000000 +0200
+++ d1x/arch/sdl/digi.c	2008-07-23 16:31:07.000000000 +0200
@@ -32,7 +32,8 @@
 	    : "rm"(y), "i"(16), "0"(x));	\
 	_ax;					\
 })
-extern inline fix fixmul(fix x, fix y) { return do_fixmul(x,y); }
+static inline fix inlinefixmul(fix x, fix y) { return do_fixmul(x,y); }
+#define fixmul(a, b) inlinefixmul(a, b)
 #endif
 #endif
 //end edit by adb

d1x-gnuasm.patch:

--- NEW FILE d1x-gnuasm.patch ---
diff -ur d1x.orig/texmap/tmappent.S d1x/texmap/tmappent.S
--- d1x.orig/texmap/tmappent.S	1999-12-08 02:03:51.000000000 +0100
+++ d1x/texmap/tmappent.S	2005-08-07 11:28:04.000000000 +0200
@@ -110,7 +110,7 @@
 
 // This is used to abbreviate an annoying external variable name.
 
-.equ    fadetbl, _gr_fade_table
+#define    fadetbl _gr_fade_table
 
 
 // The following macro encapsulates the floating-point instructions
@@ -153,22 +153,22 @@
 .endm
 
 #ifdef __LINUX__
-.equ _pixptr, pixptr
-.equ _gr_fade_table, gr_fade_table
-.equ _write_buffer, write_buffer
-.equ _bytes_per_row,bytes_per_row
-.equ _fx_xleft, fx_xleft
-.equ _fx_xright, fx_xright
-.equ _fx_y, fx_y
-.equ _fx_u, fx_u
-.equ _fx_v, fx_v
-.equ _fx_z, fx_z
-.equ _fx_l, fx_l
-.equ _fx_du_dx, fx_du_dx
-.equ _fx_dv_dx, fx_dv_dx
-.equ _fx_dz_dx, fx_dz_dx
-.equ _fx_dl_dx, fx_dl_dx
-.equ _Transparency_on, Transparency_on
+#define _pixptr pixptr
+#define _gr_fade_table gr_fade_table
+#define _write_buffer write_buffer
+#define _bytes_per_row bytes_per_row
+#define _fx_xleft fx_xleft
+#define _fx_xright fx_xright
+#define _fx_y fx_y
+#define _fx_u fx_u
+#define _fx_v fx_v
+#define _fx_z fx_z
+#define _fx_l fx_l
+#define _fx_du_dx fx_du_dx
+#define _fx_dv_dx fx_dv_dx
+#define _fx_dz_dx fx_dz_dx
+#define _fx_dl_dx fx_dl_dx
+#define _Transparency_on Transparency_on
 
 .globl asm_pent_tmap_scanline_per
 #else
diff -ur d1x.orig/texmap/tmapppro.S d1x/texmap/tmapppro.S
--- d1x.orig/texmap/tmapppro.S	1999-12-08 02:03:51.000000000 +0100
+++ d1x/texmap/tmapppro.S	2005-08-07 11:27:08.000000000 +0200
@@ -109,7 +109,7 @@
 
 // This is used to abbreviate an annoying external variable name.
 
-.equ    fadetbl, _gr_fade_table
+#define fadetbl _gr_fade_table
 
 
 // The following macro encapsulates the floating-point instructions
@@ -121,7 +121,7 @@
 // dzdx to z, and finally puts 64 back onto the stack. At the end of
 // the macro, the stack contains: 64, z, u, v.
 
-.macro DoFPCalcs 0		// The FP stack after each instruction:
+.macro DoFPCalcs		// The FP stack after each instruction:
 				//		 64/z  z    u    v
 	fst	%st(4)		//		 64/z  z    u    v  64/z
 	fxch	%st(2)		//		   u   z  64/z   v  64/z
@@ -143,22 +143,22 @@
 
 
 #ifdef __LINUX__
-.equ _pixptr, pixptr
-.equ _gr_fade_table, gr_fade_table
-.equ _write_buffer, write_buffer
-.equ _bytes_per_row, bytes_per_row
-.equ _fx_xleft, fx_xleft
-.equ _fx_xright, fx_xright
-.equ _fx_y, fx_y
-.equ _fx_u, fx_u
-.equ _fx_v, fx_v
-.equ _fx_z, fx_z
-.equ _fx_l, fx_l
-.equ _fx_du_dx, fx_du_dx
-.equ _fx_dv_dx, fx_dv_dx
-.equ _fx_dz_dx, fx_dz_dx
-.equ _fx_dl_dx, fx_dl_dx
-.equ _Transparency_on, Transparency_on
+#define _pixptr pixptr
+#define _gr_fade_table gr_fade_table
+#define _write_buffer write_buffer
+#define _bytes_per_row bytes_per_row
+#define _fx_xleft fx_xleft
+#define _fx_xright fx_xright
+#define _fx_y fx_y
+#define _fx_u fx_u
+#define _fx_v fx_v
+#define _fx_z fx_z
+#define _fx_l fx_l
+#define _fx_du_dx fx_du_dx
+#define _fx_dv_dx fx_dv_dx
+#define _fx_dz_dx fx_dz_dx
+#define _fx_dl_dx fx_dl_dx
+#define _Transparency_on Transparency_on
 
 .globl asm_ppro_tmap_scanline_per
 #else

d1x-help.patch:

--- NEW FILE d1x-help.patch ---
--- d1x/main/inferno.c.help	2006-08-26 09:55:27.000000000 +0200
+++ d1x/main/inferno.c	2006-08-26 09:57:03.000000000 +0200
@@ -928,35 +928,24 @@
 
 void show_cmdline_help() {
 	printf( "%s\n", TXT_COMMAND_LINE_0 );
-        printf( "  -<X>x<Y>       %s\n", "Change screen resolution. Options:");
-        printf( "                    320x100;320x200;320x240;320x400;640x400;640x480;800x600;1024x768\n");
+	printf( "  -<X>x<Y>       %s\n",
+	  "Change screen resolution. Options: 320x100;320x200;320x240;");
+	printf( "                 %s\n",
+	  "320x400;640x400;640x480;800x600;1024x768");
 	printf( "%s\n", TXT_COMMAND_LINE_5 );
 	printf( "%s\n", TXT_COMMAND_LINE_6 );
-	printf( "%s\n", TXT_COMMAND_LINE_7 );
 	printf( "%s\n", TXT_COMMAND_LINE_8 );
-
-	printf( "\n%s\n",TXT_PRESS_ANY_KEY3);
-	getch();
-	printf( "\n" );
 	printf( "%s\n", TXT_COMMAND_LINE_9);
-	printf( "%s\n", TXT_COMMAND_LINE_10);
 	printf( "%s\n", TXT_COMMAND_LINE_11);
 	printf( "%s\n", TXT_COMMAND_LINE_12);
-	printf( "%s\n", TXT_COMMAND_LINE_13);
-	printf( "%s\n", TXT_COMMAND_LINE_14);
 	printf( "%s\n", TXT_COMMAND_LINE_15);
 	printf( "%s\n", TXT_COMMAND_LINE_16);
 	printf( "%s\n", TXT_COMMAND_LINE_17);
-	printf( "%s\n", TXT_COMMAND_LINE_18);
 	//printf( "  -DynamicSockets %s\n", TXT_SOCKET);
 	#ifdef __MSDOS__
 	printf( "  -NoFileCheck    %s\n", TXT_NOFILECHECK);
-	#endif
 	printf( "  -GamePort       %s\n", "Use Colorado Spectrum's Notebook Gameport" );
-//moved ifdef on 9/30/98 by Matt Mueller for linux doesn't use double buffering ever, so this is redundant
-	#ifdef __MSDOS__
 	printf( "  -NoDoubleBuffer %s\n", "Use only one page of video memory" );
-//end change -MM
 	printf( "  -JoyNice        %s\n", "Joystick poller allows interrupts to occur" );
 	#endif
 	printf( "\n%s\n",TXT_PRESS_ANY_KEY3);
@@ -979,10 +968,6 @@
         printf( "  -pilot <pilot>  %s\n", "Select this pilot automatically");
 	printf( "  -cockpit <n>    %s\n", "Set initial cockpit");
 	printf( "                  %s\n", "0=full 2=status bar 3=full screen");
-
-	printf( "\n%s\n",TXT_PRESS_ANY_KEY3);
-	getch();
-        printf( "\n\n");
 //added 02/07/99 Matt Mueller
         printf( "  -hud <h>        %s\n", "Set hud mode.  0=normal 1-3=new");
 //end addition -MM
@@ -994,7 +979,7 @@
         printf( "  -handicap <n>   %s\n", "Start game with <n> shields. Must be < 100 for multi");
         printf( "  -hudlog         %s\n", "Start hudlog immediatly");
 
-#ifdef SUPPORTS_NICEFPS
+#if 0 /* def SUPPORTS_NICEFPS, these default to on now */
         printf( "  -nicefps        %s\n", "Free cpu while waiting for next frame");
         printf( "  -niceautomap    %s\n", "Free cpu while doing automap");
 #endif
@@ -1002,11 +987,6 @@
         printf( "  -automap_gameres %s\n", "Set automap to use the same resolution as in game");
         printf( "  -menu<X>x<Y>    %s\n", "Set menu resolution to <X> by <Y>");
         printf( "  -menu_gameres   %s\n", "Set menus to use the same resolution as in game");
-
-	printf( "\n%s\n",TXT_PRESS_ANY_KEY3);
-	getch();
-        printf( "\n\n");
-
 //added/edited on 11/01/98 by Matthew Mueller
         printf( "  -hudlog_multi   %s\n", "Start hudlog upon entering multiplayer games");
         printf( "  -hudlogdir <d>  %s\n", "Log hud messages in directory <d>");
@@ -1024,10 +1004,13 @@
         printf( "  -font320 <f>    %s\n", "font to use for res 320x* and above (default font3-1.fnt)");
         printf( "  -font640 <f>    %s\n", "font to use for res 640x* and above (default pc6x8.fnt)");
         printf( "  -font800 <f>    %s\n", "font to use for res 800x* and above");
-        printf( "  -font1024 <f>    %s\n", "font to use for res 1024x* and above (default pc8x16.fnt)");
+        printf( "  -font1024 <f>   %s\n", "font to use for res 1024x* and above (default pc8x16.fnt)");
 		printf( "  -tmap <t>       %s\n","select texmapper to use (c,fp,i386,pent,ppro)");
-        printf( "\n\n");
-
+	printf( "  -mouselook      %s\n","Activate fast mouselook. Works in singleplayer only"); // ZICO - added for mouselook
+#ifdef __LINUX__
+	printf( "  -grabmouse      %s\n","Keeps the mouse from wandering out of the window"); // ZICO - added for mouse capture
+#endif
+	printf( "\n");
 	printf( "\n%s\n",TXT_PRESS_ANY_KEY3);
 	getch();
         printf( " System options:\n");
@@ -1036,13 +1019,16 @@
         printf( "  -joy209         %s\n", "Use alternate port 209 for joystick");
 #endif
 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE 
-        printf( "  -fullscreen     %s\n", "Use fullscreen mode if available");
+	printf( "  -window         %s\n", "Run the game in a window"); // ZICO - from window to fullscreen
 #endif
 #ifdef OGL
+	printf( "  -16to9          %s\n", "use 16/9 widescreen");
+	printf( "  -16to10         %s\n", "use 16/10 widescreen");
         printf( "  -gl_texmaxfilt <f> %s\n","set GL_TEXTURE_MAX_FILTER (see readme.d1x)");
         printf( "  -gl_texminfilt <f> %s\n","set GL_TEXTURE_MIN_FILTER (see readme.d1x)");
         printf( "  -gl_mipmap      %s\n","set gl texture filters to \"standard\" options for mipmapping");
-        printf( "  -gl_simple      %s\n","set gl texture filters to gl_nearest for \"original\" look. (default)");
+	printf( "  -gl_trilinear   %s\n","set gl texture filters to trilinear mipmapping");
+        printf( "  -gl_simple      %s\n","set gl texture filters to gl_nearest for \"original\" look");
         printf( "  -gl_alttexmerge %s\n","use new texmerge, usually uses less ram (default)");
         printf( "  -gl_stdtexmerge %s\n","use old texmerge, uses more ram, but _might_ be a bit faster");
         printf( "  -gl_voodoo      %s\n","force fullscreen mode only");
@@ -1061,15 +1047,17 @@
 #ifdef SUPPORTS_NET_IP
         printf( "  -ip_nogetmyaddr %s\n","prevent autodetection of local ip address");
         printf( "  -ip_myaddr <a>  %s\n","use <a> as local ip address");
-        printf( "  -ip_baseport <p> %s\n","use <p> as offset from normal port (allows multiple instances of d1x to be run on a single computer)");
+        printf( "  -ip_baseport <p> %s\n","use <p> as offset from normal port");
 #endif
 #ifdef __LINUX__
 //added 02/06/99 Matthew Mueller
         printf( "  -serialdevice <s> %s\n", "Set serial/modem device to <s>");
 //end addition -MM
 //added 03/07/99 Matthew Mueller
-        printf( "  -serialread <r>   %s\n", "Set serial/modem to read from <r>");
+        printf( "  -serialread <r> %s\n", "Set serial/modem to read from <r>");
 //end addition -MM
+	printf( "  -playmus        %s\n", "Use playmus to play music (default)");
+	printf( "  -timidity       %s\n", "Use timidity to play music (better but much slower)");
 #endif
         printf( "\n");
 }

d1x-joystick.patch:

--- NEW FILE d1x-joystick.patch ---
--- d1x/arch/linux/include/joystick.h.orig	1999-06-15 00:01:49.000000000 +0200
+++ d1x/arch/linux/include/joystick.h	2004-01-18 19:00:52.424290616 +0100
@@ -8,7 +8,6 @@
  */
 
 #include <asm/types.h>
-#include <linux/module.h>
 
 /*
  * Version

d1x-maths.patch:

--- NEW FILE d1x-maths.patch ---
diff -uNr d1x.orig/maths/fixc.c d1x/maths/fixc.c
--- d1x.orig/maths/fixc.c	Mon Oct 18 02:31:01 1999
+++ d1x/maths/fixc.c	Sun Aug 25 10:13:09 2002
@@ -69,13 +69,13 @@
 #include "error.h"
 #include "maths.h"
 
-#ifdef NO_FIX_INLINE
+/* #ifdef NO_FIX_INLINE
 #ifdef _MSC_VER
 #pragma message ("warning: FIX NOT INLINED")
 #else
 #warning "FIX NOT INLINED"
 #endif
-#endif
+#endif */
 
 extern ubyte guess_table[];
 extern short sincos_table[];

d1x-miscfixes.patch:

--- NEW FILE d1x-miscfixes.patch ---
--- d1x/main/inferno.c.miscfixes	2000-04-22 00:15:34.000000000 +0200
+++ d1x/main/inferno.c	2005-08-06 10:38:22.000000000 +0200
@@ -845,6 +845,9 @@
 #ifdef SCRIPT
 #include "script.h"
 #endif
+#ifdef OGL
+#include "ogl_init.h"
+#endif
 
 void check_joystick_calibration();
 void show_order_form();
@@ -1142,7 +1145,7 @@
 	if ((t = FindArg( "-missiondir" )))
 		cfile_use_alternate_hogdir(Args[t+1]);
         else
-                cfile_use_alternate_hogdir("");
+                cfile_use_alternate_hogdir(D1XDATAPATH);
 
 	if ((t=FindArg("-tmap"))){
 		select_tmap(Args[t+1]);
@@ -1399,6 +1402,15 @@
 	// Load the palette stuff. Returns non-zero if error.
 	mprintf( (0, "Going into graphics mode..." ));
 	gr_set_mode(MENU_SCREEN_MODE);
+#ifdef OGL
+	/* hack to fix initial screens with ogl */
+	{
+ 		int old_screen_mode = Screen_mode;
+		Screen_mode = MENU_SCREEN_MODE;
+		ogl_set_screen_mode();
+		Screen_mode = old_screen_mode;
+	}
+#endif	
 	mprintf( (0, "\nInitializing palette system..." ));
 	gr_use_palette_table( "PALETTE.256" );
 	mprintf( (0, "\nInitializing font system..." ));
--- d1x/main/fvi.c.miscfixes	2000-06-25 10:34:29.000000000 +0200
+++ d1x/main/fvi.c	2005-08-06 10:38:22.000000000 +0200
@@ -1036,7 +1036,7 @@
 	int centermask;			//where the center point is
 	int objnum;
 	segmasks masks;
-	vms_vector hit_point,closest_hit_point; 	//where we hit
+	vms_vector hit_point,closest_hit_point = { 0, 0, 0 }; 	//where we hit
 	fix d,closest_d=0x7fffffff;					//distance to hit point
 	int hit_type=HIT_NONE;							//what sort of hit
 	int hit_seg=-1;
--- d1x/main/network.c.miscfixes	2000-02-07 11:26:05.000000000 +0100
+++ d1x/main/network.c	2005-08-06 10:38:22.000000000 +0200
@@ -2161,7 +2161,7 @@
         //added on 10/18/98 by Victor Rachels to add multiplayer profiles
         int multivalues[40];
 
-        memset(&multivalues,0,sizeof(int *) * 40);
+        memset(multivalues,0,sizeof(int) * 40);
         //end this section addition - Victor
 
 #ifndef SHAREWARE
--- d1x/main/game.c.miscfixes	2005-08-06 10:38:22.000000000 +0200
+++ d1x/main/game.c	2005-08-06 10:38:22.000000000 +0200
@@ -3489,7 +3489,7 @@
 			#ifndef I_AM_NOT_A_CHEATER_BUT_MY_KEYBOARD_THINKS_I_PRESS_DEL
 			if ((key&KEY_DEBUGGED)&&(Game_mode&GM_MULTI))	{
 				Network_message_reciever = 100;		// Send to everyone...
-				sprintf( Network_message, "%s %s", TXT_I_AM_A, TXT_CHEATER);
+				snprintf( Network_message, MAX_MESSAGE_LEN, "%s %s", TXT_I_AM_A, TXT_CHEATER);
 			}
 			#endif
 			#endif
@@ -4165,7 +4165,7 @@
 //						if ( Game_mode & GM_MULTI )	{
 //							nm_messagebox( NULL, 1, "Damn", "CHEATER!\nYou cannot use the\nmega-thing in network mode." );
 //							Network_message_reciever = 100;		// Send to everyone...
-//							sprintf( Network_message, "%s cheated!", Players[Player_num].callsign);
+//							snprintf( Network_message, MAX_MESSAGE_LEN, "%s cheated!", Players[Player_num].callsign);
 //						} else {
 //							do_megawow_powerup();
 //						}
--- d1x/main/command.c.miscfixes	1999-10-08 00:40:29.000000000 +0200
+++ d1x/main/command.c	2005-08-06 10:38:22.000000000 +0200
@@ -112,7 +112,7 @@
         {
           handicap = MAX_SHIELDS;
           Network_message_reciever = 100;
-          sprintf(Network_message,"I am no longer handicapped.");
+          snprintf(Network_message, MAX_MESSAGE_LEN, "I am no longer handicapped.");
           hud_message(MSGC_GAME_FEEDBACK, "Handicap reset. Other players notified");
           multi_send_message();
           multi_message_feedback();
@@ -126,7 +126,7 @@
             else
              Lhandicap = 0;
            Network_message_reciever = 100;
-           sprintf(Network_message,"I am using a handicap of %i.",t);
+           snprintf(Network_message, MAX_MESSAGE_LEN, "I am using a handicap of %i.",t);
            hud_message(MSGC_GAME_FEEDBACK, "Handicap set. Other players notified");
            multi_send_message();
            multi_message_feedback();
@@ -137,7 +137,7 @@
             if(Lhandicap)
              {
                Network_message_reciever = 100;
-               sprintf(Network_message,"I am using handicap of %i.",t);
+               snprintf(Network_message, MAX_MESSAGE_LEN, "I am using handicap of %i.",t);
                hud_message(MSGC_GAME_FEEDBACK, "Handicap set. Other players notified");
                multi_send_message();
                multi_message_feedback();
@@ -147,11 +147,11 @@
               int netmaster=network_whois_master();
                hud_message(MSGC_GAME_FEEDBACK, "Master permission required. Requesting...");
                Network_message_reciever = netmaster;
-               sprintf(Network_message,"%s requests handicap of %i",Players[Player_num].callsign,t);
+               snprintf(Network_message, MAX_MESSAGE_LEN, "%s requests handicap of %i",Players[Player_num].callsign,t);
                multi_send_message();
                multi_message_feedback();
                Network_message_reciever = netmaster;
-               sprintf(Network_message,"Send %s:handicap %i to allow",Players[Player_num].callsign,t);
+               snprintf(Network_message, MAX_MESSAGE_LEN, "Send %s:handicap %i to allow",Players[Player_num].callsign,t);
                multi_send_message();
                multi_message_feedback();
              }
--- d1x/main/nncoms.c.miscfixes	1999-10-14 06:48:20.000000000 +0200
+++ d1x/main/nncoms.c	2005-08-06 10:38:22.000000000 +0200
@@ -51,7 +51,7 @@
               hud_message(MSGC_GAME_FEEDBACK,"You cannot kick players! You are not master!");
               strcpy(name, bootname);
               Network_message_reciever = 100;         // Let everyone know that I'm trying to kick someone, but am not master...
-              sprintf( Network_message, "I'm trying to kick %s!", name);
+              snprintf( Network_message, MAX_MESSAGE_LEN, "I'm trying to kick %s!", name);
               multi_send_message();
               return;
         }
@@ -100,7 +100,7 @@
         {
                 hud_message(MSGC_GAME_FEEDBACK,"You cannot kick players! You are not master!");
                 Network_message_reciever = 100;         // Let everyone know that I'm trying to kick someone, but am not master...
-                sprintf( Network_message, "I'm trying to kick %s!", Players[player_list[bootnum - 1]].callsign);
+                snprintf( Network_message, MAX_MESSAGE_LEN, "I'm trying to kick %s!", Players[player_list[bootnum - 1]].callsign);
                 multi_send_message();
                 return;
         }
--- d1x/main/gamefont.c.miscfixes	1999-11-20 11:05:17.000000000 +0100
+++ d1x/main/gamefont.c	2005-08-06 10:40:36.000000000 +0200
@@ -200,11 +200,13 @@
 	for (i=0;i<MAX_FONTS;i++){
 		Gamefonts[i]=NULL;
 		addfontconf(i,0,Gamefont_filenames_l[i]);
-		addfontconf(i,640,Gamefont_filenames_h[i]);
+		// HDG: commented, these files are not available in the normal
+		// d1data files since they are d2 files
+		// addfontconf(i,640,Gamefont_filenames_h[i]);
 	}
-
-//	addfontconf(640,"pc6x8.fnt");
-//	addfontconf(1024,"pc8x16.fnt");
+	// HDG: uncommented, these addon files can be easily added
+	addfontconf(4, 640,"pc6x8.fnt");
+	addfontconf(4, 1024,"pc8x16.fnt");
 	if ((i=FindArg("-font320")))
 		addfontconf(4,320,Args[i+1]);
 	if ((i=FindArg("-font640")))
--- d1x/main/newmenu.c.miscfixes	2005-08-06 10:38:22.000000000 +0200
+++ d1x/main/newmenu.c	2005-08-06 10:38:22.000000000 +0200
@@ -862,14 +862,14 @@
 		nm_string( b, item->w, item->x, item->y, item->text );
 		break;
 	case NM_TYPE_SLIDER:	{
-		int j;
+		int i,j;
 		if (item->value < item->min_value) item->value=item->min_value;
 		if (item->value > item->max_value) item->value=item->max_value;
-		sprintf( item->saved_text, "%s\t%s", item->text, SLIDER_LEFT );
+		i = sprintf( item->saved_text, "%s\t%s", item->text, SLIDER_LEFT );
 		for (j=0; j<(item->max_value-item->min_value+1); j++ )	{
-			sprintf( item->saved_text, "%s%s", item->saved_text,SLIDER_MIDDLE );
+			i += sprintf( item->saved_text + i, "%s", SLIDER_MIDDLE );
 		}
-		sprintf( item->saved_text, "%s%s", item->saved_text,SLIDER_RIGHT );
+		sprintf( item->saved_text + i, "%s", SLIDER_RIGHT );
 		
 		item->saved_text[item->value+1+strlen(item->text)+1] = SLIDER_MARKER[0];
 		
@@ -1036,13 +1036,13 @@
 		item[i].saved_text[0] = '\0';
 
 		if ( item[i].type == NM_TYPE_SLIDER )	{
-			int w1,h1,aw1;
+			int index,w1,h1,aw1;
 			nothers++;
-			sprintf( item[i].saved_text, "%s", SLIDER_LEFT );
+			index = sprintf( item[i].saved_text, "%s", SLIDER_LEFT );
 			for (j=0; j<(item[i].max_value-item[i].min_value+1); j++ )	{
-				sprintf( item[i].saved_text, "%s%s", item[i].saved_text,SLIDER_MIDDLE );
+				index+= sprintf( item[i].saved_text + index, "%s", SLIDER_MIDDLE );
 			}
-			sprintf( item[i].saved_text, "%s%s", item[i].saved_text,SLIDER_RIGHT );
+			sprintf( item[i].saved_text + index, "%s", SLIDER_RIGHT );
 			gr_get_string_size(item[i].saved_text,&w1,&h1,&aw1 );
 			string_width += w1 + aw;
 		}
--- d1x/main/multi.c.miscfixes	1999-11-30 07:11:11.000000000 +0100
+++ d1x/main/multi.c	2005-08-06 10:38:22.000000000 +0200
@@ -1270,7 +1270,7 @@
 		return;
 	}
 
-	strcpy(Network_message, Network_message_macro[key]);
+	snprintf(Network_message, MAX_MESSAGE_LEN, "%s", Network_message_macro[key]);
 
 //added/replaced on 11/10/98 by Victor Rachels to make macros act like normal msgs
         multi_send_message_end();
@@ -1305,7 +1305,7 @@
 
 void mekh_resend_last()
 {
-        strcpy(Network_message, &mekh_msg_last_sent[0]);
+        snprintf(Network_message, MAX_MESSAGE_LEN, "%s", mekh_msg_last_sent);
         multi_send_message_end();
 };
 //======================================================
@@ -1806,7 +1806,7 @@
                Lhandicap = 0;
              hud_message(MSGC_GAME_FEEDBACK, "Handicap set to %i by game master",t);
              Network_message_reciever = 100;
-             sprintf(Network_message,"Handicap set to %i by game master.",t);
+             snprintf(Network_message, MAX_MESSAGE_LEN, "Handicap set to %i by game master.",t);
              multi_send_message();
              multi_message_feedback();
             }
@@ -1840,7 +1840,7 @@
                            multi_send_data(multibuf,message_length[MULTI_MESSAGE],1);
                           }
 //                         Network_message_reciever = buf[1];  // Send to the player who pinged you
-//                         sprintf(Network_message, "pong:%s", colon + 1);
+//                         snprintf(Network_message, MAX_MESSAGE_LEN, "pong:%s", colon + 1);
                          
 		}
 		if (!strncasecmp("pong", buf+loc, 4))
--- d1x/main/ban.c.miscfixes	1999-06-15 01:44:11.000000000 +0200
+++ d1x/main/ban.c	2005-08-06 10:38:22.000000000 +0200
@@ -40,7 +40,7 @@
     {
       hud_message(MSGC_GAME_FEEDBACK,"You cannot ban players! You are not master!");
       Network_message_reciever=100;
-      sprintf( Network_message, "I'm trying to ban %s!", banname);
+      snprintf( Network_message, MAX_MESSAGE_LEN, "I'm trying to ban %s!", banname);
       multi_send_message();
       return;
     }
@@ -107,7 +107,7 @@
     {
       hud_message(MSGC_GAME_FEEDBACK,"You cannot ban players. You are not master");
       Network_message_reciever=100;
-      sprintf( Network_message, "I'm trying to ban %s!", Players[pl].callsign);
+      snprintf( Network_message, MAX_MESSAGE_LEN, "I'm trying to ban %s!", Players[pl].callsign);
       multi_send_message();
       return;
     }
--- d1x/main/ignore.c.miscfixes	1999-06-15 01:44:12.000000000 +0200
+++ d1x/main/ignore.c	2005-08-06 10:38:22.000000000 +0200
@@ -54,7 +54,7 @@
                                         hud_message(MSGC_GAME_FEEDBACK,"Now ignoring %s!", ignorename);
                                         strcpy(name, ignorename);
                                         Network_message_reciever = 100; // Let everyone know that I'm ignoring someone...
-                                        sprintf( Network_message, "I'm now ignoring %s!", name);
+                                        snprintf( Network_message, MAX_MESSAGE_LEN, "I'm now ignoring %s!", name);
                                         multi_send_message();
 
                                         network_disconnect_player(iPlayerLoop);
@@ -107,7 +107,7 @@
                         strcpy(ignorelist[ignoreloop], Players[player_list[ignorenum - 1]].callsign);
                         hud_message(MSGC_GAME_FEEDBACK,"Now ignoring %s!", Players[player_list[ignorenum - 1]].callsign);
                         Network_message_reciever = 100; // Let everyone know that I'm ignoring someone...
-                        sprintf( Network_message, "I'm now ignoring %s!", Players[player_list[ignorenum - 1]].callsign);
+                        snprintf( Network_message, MAX_MESSAGE_LEN, "I'm now ignoring %s!", Players[player_list[ignorenum - 1]].callsign);
                         multi_send_message();
 
                         network_disconnect_player(player_list[ignorenum - 1]);

d1x-music.patch:

--- NEW FILE d1x-music.patch ---
diff -urN d1x.orig/arch/linux/COPYING.LIB d1x/arch/linux/COPYING.LIB
--- d1x.orig/arch/linux/COPYING.LIB	1970-01-01 01:00:00.000000000 +0100
+++ d1x/arch/linux/COPYING.LIB	2006-08-18 13:43:22.000000000 +0200
@@ -0,0 +1,510 @@
+
+                  GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations
+below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+^L
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it
+becomes a de-facto standard.  To achieve this, non-free programs must
+be allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+^L
+                  GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control
+compilation and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+^L
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+^L
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at least
+    three years, to give the same user the materials specified in
+    Subsection 6a, above, for a charge no more than the cost of
+    performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+^L
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+^L
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply, and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License
+may add an explicit geographical distribution limitation excluding those
+countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+^L
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                            NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+^L
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms
+of the ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.
+It is safest to attach them to the start of each source file to most
+effectively convey the exclusion of warranty; and each file should
+have at least the "copyright" line and a pointer to where the full
+notice is found.
+
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library 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
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or
+your school, if any, to sign a "copyright disclaimer" for the library,
+if necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James
+  Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff -urN d1x.orig/arch/linux/hmistub.c d1x/arch/linux/hmistub.c
--- d1x.orig/arch/linux/hmistub.c	1999-06-15 00:01:32.000000000 +0200
+++ d1x/arch/linux/hmistub.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-void digi_set_midi_volume( int mvolume ) { }
-void digi_play_midi_song( char * filename, char * melodic_bank, char * drum_bank, int loop ) {}
diff -urN d1x.orig/arch/linux/hmp2mid.c d1x/arch/linux/hmp2mid.c
--- d1x.orig/arch/linux/hmp2mid.c	1970-01-01 01:00:00.000000000 +0100
+++ d1x/arch/linux/hmp2mid.c	2006-08-18 13:43:02.000000000 +0200
@@ -0,0 +1,232 @@
+/* hmp 2 midi file conversion. The conversion algorithm is based on the
+   conversion algorithms found in d1x, d2x-xl and jjffe. The code is mine.
+   
+   Copyright 2006 Hans de Goede
+   
+   This file and the acompanying hmp2mid.h file are free software;
+   you can redistribute them and/or modify them under the terms of the GNU
+   Library General Public License as published by the Free Software Foundation;
+   either version 2 of the License, or (at your option) any later version.
+
+   These files are distributed in the hope that they will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with these files; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+*/
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include "hmp2mid.h"
+
+/* Some convience macros to keep the code below more readable */
+
+#define HMP_READ(buf, count) \
+  {\
+    if (read_func(buf, 1, count, hmp_in) != (count)) \
+    { \
+      free(mid_track_buf); \
+      return hmp_read_error; \
+    } \
+    /* notice that when we are not actually in the track reading code this \
+       is bogus, but does no harm. And in the track code it helps :) */ \
+    track_length -= count; \
+  }
+
+#define HMP_READ_DWORD(dest) \
+  { \
+    unsigned char _buf[4]; \
+    HMP_READ(_buf, 4); \
+    *(dest) = (_buf[3] << 24) | (_buf[2] << 16) | (_buf[1] << 8) | _buf[0]; \
+  }
+
+#define MID_WRITE(buf, count) \
+  if (fwrite(buf, 1, count, mid_out) != (count)) \
+  { \
+    free(mid_track_buf); \
+    snprintf(hmp2mid_error, sizeof(hmp2mid_error), mid_write_error_templ, \
+      strerror(errno)); \
+    return hmp2mid_error; \
+  }
+
+#define MID_TRACK_BUF(buf, count) \
+  { \
+    if ((mid_track_buf_used + count) > mid_track_buf_size) \
+    { \
+      void *tmp = mid_track_buf; \
+      mid_track_buf = realloc(mid_track_buf, mid_track_buf_size + 65536); \
+      if (!mid_track_buf) \
+      { \
+        free(tmp); \
+        return "Error could not allocate midi track memory"; \
+      } \
+    } \
+    memcpy(mid_track_buf + mid_track_buf_used, buf, count); \
+    mid_track_buf_used += count; \
+  }
+    
+  
+static const char *hmp_read_error = "Error reading from hmp file";
+static const char *mid_write_error_templ = "Error writing to mid file: %s";
+static char hmp2mid_error[512];
+/* The beginning of the midi header */
+static const char midi_header1[10] = { 'M', 'T', 'h', 'd', 0, 0, 0, 6, 0, 1 };
+/* The last 2 bytes of the midi header and track0 */
+static const char midi_header2[21] = { 0, 0xC0, 'M', 'T', 'r', 'k', 0, 0, 0,
+  0x0B, 0, 0xFF, 0x51, 0x03, 0x18, 0x80, 0, 0, 0xFF, 0x2F, 0 };
+  
+const char *hmp2mid(hmp2mid_read_func_t read_func, void *hmp_in, FILE* mid_out)
+{
+  unsigned char last_com = 0, buf[0x300];
+  unsigned int num_tracks, track_length = 0, i, t;
+  unsigned char *mid_track_buf = NULL;
+  int n1, n2, mid_track_buf_used, mid_track_buf_size = 0;
+  
+  /* Read the header and verify that this is a hmp file */
+  HMP_READ(buf, 8);
+  buf[8] = 0;
+  if (strcmp((char *)buf, "HMIMIDIP"))
+    return "Error not a hmp file";
+  
+  /* Discard the next 0x28 bytes, taking us to location 0x30 and read the
+     number of tracks there */
+  HMP_READ(buf, 0x30 - 8);
+  HMP_READ_DWORD(&num_tracks);
+  
+  /* Discard bytes taking us to location 0x300 around which track 1 starts */
+  HMP_READ(buf, 0x300 - 0x34);
+  
+  /* Now search for the end of track marker of track 0 */
+  HMP_READ(buf, 3);
+  while ((buf[0] != 0xFF) || (buf[1] != 0x2F) || (buf[2] != 0x00))
+  {
+    buf[0] = buf[1];
+    buf[1] = buf[2];
+    HMP_READ(buf + 2, 1);
+  }
+  
+  /* Sofar so good, write out the midi header */
+  MID_WRITE(midi_header1, sizeof(midi_header1));
+  /* number of tracks is a 16 bit MSB word, better not have more then 65535
+     tracks :) */
+  buf[0] = (num_tracks >> 8) & 0xFF;
+  buf[1] = num_tracks & 0xFF;
+  MID_WRITE(buf, 2);
+  /* Write the last word of the header and track0 */
+  MID_WRITE(midi_header2, sizeof(midi_header2));
+  
+  /* Read and convert all the tracks */
+  for (i = 1; i < num_tracks; i++)
+  {
+    /* Read and verify hmp track number */
+    HMP_READ_DWORD(&t);
+    if (t != i)
+    {
+      free(mid_track_buf);
+      return "Error invalid hmp track number";
+    }
+    /* Read number of bytes in this track */
+    HMP_READ_DWORD(&track_length);
+    /* Above we've already read the first 8 bytes of this track, adjust
+       track_lenght accordingly. */
+    track_length -= 8;
+    /* Read and skip the next 4 unidentified header bytes */
+    HMP_READ(buf, 4);
+    
+    /* Sofar so good write midi track header */
+    MID_WRITE("MTrk", 4);
+
+    /* Now we need to write the track length, but we don't know that yet, so
+       the track gets written to a dynamicly growing buffer (which is hidden
+       in the MID_TRACK_BUF macro) */
+    mid_track_buf_used = 0;
+
+    /* And finally start the real conversion */
+    while (track_length > 0)
+    {
+      n1 = -1; /* -1 to "counter" the intital n1++ */
+      do
+      {
+        n1++;
+        HMP_READ(buf + n1, 1);
+      } while (!(buf[n1] & 0x80));
+      
+      if (n1 >= 4)
+      {
+        free(mid_track_buf);
+        return "Error parsing hmp track";
+      }
+
+      for (n2 = 0; n2 <= n1; n2++)
+      {
+        unsigned char u = buf[n1-n2] & 0x7F;
+        
+        if (n2 != n1)
+          u |= 0x80;
+        MID_TRACK_BUF(&u, 1);
+      }
+
+      HMP_READ(buf, 1);
+
+      if (buf[0] == 0xFF) /* meta? */
+      {
+        HMP_READ(buf + 1, 2);
+        HMP_READ(buf + 3, buf[2]);
+        MID_TRACK_BUF(buf, 3 + buf[2]);
+        if (buf[1] == 0x2F) /* end of track? */
+        {
+          if (buf[2] != 0x00)
+          {
+            free(mid_track_buf);
+            return "Error hmp meta end of track with non zero size";
+          }
+          break;
+        }
+        else
+          continue;
+      }
+
+      switch (buf[0] & 0xF0)
+      {
+        case 0x80:
+        case 0x90:
+        case 0xA0:
+        case 0xB0:
+        case 0xE0:
+          t = 2;
+          break;
+        case 0xC0:
+        case 0xD0:
+          t = 1;
+          break;
+        default:
+          free(mid_track_buf);
+          return "Error invalid hmp command";
+      }
+      if (buf[0] != last_com)
+        MID_TRACK_BUF(buf, 1);
+      HMP_READ(buf + 1, t);
+      MID_TRACK_BUF(buf + 1, t);
+      last_com = buf[0];
+    }
+    if (track_length != 0)
+    {
+      free(mid_track_buf);
+      return "Error invalid track length";
+    }
+    /* write the midi track length */
+    buf [0] = mid_track_buf_used >> 24;
+    buf [1] = (mid_track_buf_used >> 16) & 0xFF;
+    buf [2] = (mid_track_buf_used >> 8) & 0xFF;
+    buf [3] = mid_track_buf_used & 0xFF;
+    MID_WRITE(buf, 4);
+    /* and the track itself */
+    MID_WRITE(mid_track_buf, mid_track_buf_used);
+  }
+  free (mid_track_buf);
+  return NULL;
+}
diff -urN d1x.orig/arch/linux/hmp2mid.h d1x/arch/linux/hmp2mid.h
--- d1x.orig/arch/linux/hmp2mid.h	1970-01-01 01:00:00.000000000 +0100
+++ d1x/arch/linux/hmp2mid.h	2006-08-18 13:43:02.000000000 +0200
@@ -0,0 +1,31 @@
+/* hmp 2 midi file conversion. The conversion algorithm is based on the
+   conversion algorithms found in d1x, d2x-xl and jjffe. The code is mine.
+   
+   Copyright 2006 Hans de Goede
+   
+   This file and the acompanying hmp2mid.c file are free software;
+   you can redistribute them and/or modify them under the terms of the GNU
+   Library General Public License as published by the Free Software Foundation;
+   either version 2 of the License, or (at your option) any later version.
+
+   These files are distributed in the hope that they will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with these files; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+*/
+#ifndef __HMP2MID_H
+#define __HMP2MID_H
+#include <stdio.h>
+
+typedef size_t (*hmp2mid_read_func_t)(void *ptr, size_t size, size_t nmemb,
+  void *stream);
+
+/* Returns NULL on success, otherwise a c-string with an error message */
+const char *hmp2mid(hmp2mid_read_func_t read_func, void *hmp_in, FILE* mid_out);
+
+#endif
diff -urN d1x.orig/arch/linux/makefile d1x/arch/linux/makefile
--- d1x.orig/arch/linux/makefile	2000-03-06 02:42:09.000000000 +0100
+++ d1x/arch/linux/makefile	2006-08-19 09:52:40.000000000 +0200
@@ -21,7 +21,7 @@
 ifdef HMIPLAY
 OBJECTS += hmiplay.$(OBJ)
 else
-OBJECTS += hmistub.$(OBJ)
+OBJECTS += midiplay.$(OBJ) hmp2mid.$(OBJ)
 endif
 
 ifdef SVGALIB
diff -urN d1x.orig/arch/linux/midiplay.c d1x/arch/linux/midiplay.c
--- d1x.orig/arch/linux/midiplay.c	1970-01-01 01:00:00.000000000 +0100
+++ d1x/arch/linux/midiplay.c	2006-08-19 10:30:03.000000000 +0200
@@ -0,0 +1,157 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include "hmp2mid.h"
+#include "cfile.h"
+#include "args.h"
+#include "digi.h"
+
+enum { NO_MUSIC, TIMIDITY, PLAYMUS };
+
+/* Use playmus by default because playmus is much CPU friendlier. Timidity has
+   the best sound, but timidity's CPU-usage is too much, especially when
+   (re)starting a song. This makes the game all stuttery. */
+static int midi_driver = PLAYMUS;
+
+/* Volumes are 0-127, timidity's volume is in % but allows volume > 100%
+   and is a bit soft by default */
+static int timidity_volume;
+static int midi_volume = 127;
+static void digi_stop_current_song();
+
+FILE *midiplayer_stdin = NULL;
+
+void digi_play_midi_song(char * filename, char *melodic_bank, char *drum_bank,
+  int loop)
+{
+  static int first_time = 1;
+  char *p, mid_filename[512], command[512];
+
+  if (first_time)
+  {
+    if(FindArg("-nomusic"))
+      midi_driver = NO_MUSIC;
+
+    if(FindArg("-timidity"))
+      midi_driver = TIMIDITY;
+
+    if(FindArg("-playmus"))
+      midi_driver = PLAYMUS;
+    
+    atexit(digi_stop_current_song);
+    first_time = 0;
+  }
+
+  if (midi_driver == NO_MUSIC)  
+    return;
+  
+  /* Stop current playing song */
+  digi_stop_current_song();
+  if (!filename)
+    return;
+  
+  /* We need to write the converted hmp to a file, to avoid tmpfile problems
+     we store the converted files under ~/.d1x, where we can use them as
+     a cache too, speeding things up a bit. */
+  p = getenv("HOME");
+  snprintf(mid_filename, sizeof(mid_filename), "%s/.d1x/%s", p? p:".",
+    filename);
+  if ((p = strstr(mid_filename, ".hmp"))) strcpy(p, ".mid");
+  if (access(mid_filename, R_OK) != 0)
+  {
+    const char *err;
+    CFILE *hmp_in;
+    FILE *mid_out = fopen(mid_filename, "w");
+    if (!mid_out)
+    {
+      fprintf(stderr, "Error could not open: %s for writing: %s\n",
+        mid_filename, strerror(errno));
+      return;
+    }
+    hmp_in = cfopen(filename, "rb");
+    if (!hmp_in)
+    {
+      fprintf(stderr, "Error could not open: %s\n", filename);
+      fclose(mid_out);
+      return;
+    }
+    err = hmp2mid((hmp2mid_read_func_t)cfread, hmp_in, mid_out);
+    fclose(mid_out);
+    cfclose(hmp_in);
+    if (err)
+    {
+      fprintf(stderr, "%s\n", err);
+      unlink(mid_filename);
+      return;
+    }
+  }
+  
+  /* And execute our midiplayer with the found or created midi file */
+  switch (midi_driver)
+  {
+    case TIMIDITY:
+      snprintf(command, sizeof(command),
+        "timidity -in%s -A %d %s > /dev/null",
+          loop? "l":"", midi_volume, mid_filename);
+      timidity_volume = midi_volume;
+      break;
+    case PLAYMUS:
+      snprintf(command, sizeof(command),
+        "playmus -i%s -r 44100 -v %d %s > /dev/null",
+          loop? " -l":"", midi_volume, mid_filename);
+      break;
+  }
+  midiplayer_stdin = popen(command, "w");
+  if (!midiplayer_stdin)
+    fprintf(stderr, "Error couldn't execute: %s\n", command);
+}
+
+void digi_stop_current_song()
+{
+  if (midiplayer_stdin)
+  {
+    switch (midi_driver)
+    {
+      case TIMIDITY:
+        fputc('q', midiplayer_stdin);
+        break;
+      case PLAYMUS:
+        fputs("h\r", midiplayer_stdin);
+        break;
+    }
+    fflush(midiplayer_stdin);
+    pclose(midiplayer_stdin);
+    midiplayer_stdin = NULL;
+  }
+}
+
+void digi_set_midi_volume(int mvolume)
+{
+  midi_volume = mvolume;
+  if (midiplayer_stdin)
+  {
+    switch (midi_driver)
+    {
+      case TIMIDITY:
+        while((timidity_volume + 5) < midi_volume)
+        {
+          fputc('V', midiplayer_stdin);
+          fflush(midiplayer_stdin);
+          timidity_volume += 10;
+        }
+        while((timidity_volume - 5) > midi_volume)
+        {
+          fputc('v', midiplayer_stdin);
+          fflush(midiplayer_stdin);
+          timidity_volume -= 10;
+        }
+        break;
+      case PLAYMUS:
+        fprintf(midiplayer_stdin, "v%d\r", midi_volume);
+        fflush(midiplayer_stdin);
+        break;
+    }
+  }
+}

d1x-new-sdl.patch:

--- NEW FILE d1x-new-sdl.patch ---
--- d1x/rules.mak~	2006-09-26 08:47:44.000000000 +0200
+++ d1x/rules.mak	2006-09-26 08:47:44.000000000 +0200
@@ -162,7 +162,8 @@
 LINKLIBS += $(STATICSDL) -ldl -L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm
 CFLAGS += -D_SDL_STATIC_LIB
 else
-LINKLIBS += -ldl -lSDL
+# -lX11 to resolve the Xlib symbols used directly by the clipboard code
+LINKLIBS += -ldl -lSDL -lX11
 endif
 endif
 ifdef SVGALIB

d1x-opt.patch:

--- NEW FILE d1x-opt.patch ---
--- d1x/rules.mak.orig	Thu Nov  2 04:17:27 2000
+++ d1x/rules.mak	Sun May 19 01:00:44 2002
@@ -45,9 +45,9 @@
 LINKLIBS += -lm
 endif
 ifdef DEBUG
-CFLAGS = -g -c -Wall -O -funsigned-char -I$(TOPDIR)/include
+CFLAGS = -c -Wall $(OPTFLAGS) -funsigned-char -I$(TOPDIR)/include
 else #!DEBUG
-CFLAGS = -g -c -Wall -O3  -funsigned-char -I$(TOPDIR)/include -DNDEBUG
+CFLAGS = -c -Wall $(OPTFLAGS) -funsigned-char -I$(TOPDIR)/include -DNDEBUG
 ifndef DEBUGABLE
 CFLAGS += -fomit-frame-pointer
 endif #!DEBUGABLE

d1x-paths.patch:

--- NEW FILE d1x-paths.patch ---
--- d1x/main/piggy.c.orig	Tue Apr 18 03:17:58 2000
+++ d1x/main/piggy.c	Sun Jun  2 02:09:06 2002
@@ -715,7 +715,7 @@
 		GameBitmapOffset[0] = 0;
 	}
 
-        filename = "descent.pig";
+        filename = D1XDATAPATH "descent.pig";
 	
 	if ( FindArg( "-bigpig" ))
 		BigPig = 1;
@@ -1138,7 +1138,7 @@
 	piggy_close_file();
 
 	mprintf( (0, "Creating DESCENT.PIG..." ));
-        filename = "descent.pig";
+        filename = D1XDATAPATH "descent.pig";
 	if ( (i=FindArg( "-piggy" )) )	{
 		filename	= Args[i+1];
 		mprintf( (0, "Dumping alternate pigfile, '%s'\n", filename ));
--- d1x/cfile/cfile.c.orig	Sun Sep  5 13:22:31 1999
+++ d1x/cfile/cfile.c	Sun Jun  2 02:09:30 2002
@@ -277,13 +277,13 @@
 	}
 
 	if ( !Hogfile_initialized ) 	{
-                cfile_init_hogfile( "descent.hog", HogFiles, &Num_hogfiles );
+                cfile_init_hogfile( D1XDATAPATH "descent.hog", HogFiles, &Num_hogfiles );
 		Hogfile_initialized = 1;
 	}
 
 	for (i=0; i<Num_hogfiles; i++ )	{
 		if ( !stricmp( HogFiles[i].name, name ))	{
-			fp = cfile_get_filehandle( "descent.hog", "rb" );
+			fp = cfile_get_filehandle( D1XDATAPATH "descent.hog", "rb" );
 			if ( fp == NULL ) return NULL;
 			fseek( fp,  HogFiles[i].offset, SEEK_SET );
 			*length = HogFiles[i].length;

d1x-playerfile-compat-fix.patch:

--- NEW FILE d1x-playerfile-compat-fix.patch ---
--- d1x/main/playsave.c~	2006-10-14 09:24:09.000000000 +0200
+++ d1x/main/playsave.c	2006-10-14 09:24:09.000000000 +0200
@@ -1350,25 +1350,25 @@
 			break;
 		case 7:
 			/* version 7 doesn't have the saved games array */
-			if (player_file_size == (2222 - sizeof(saved_games)))
+			if (player_file_size == ((2212 - sizeof(saved_games)) + info.n_highest_levels * sizeof(hli)))
 				shareware_file = 1;
-			if (player_file_size == (2262 - sizeof(saved_games)))
+			if (player_file_size == ((2252 - sizeof(saved_games)) + info.n_highest_levels * sizeof(hli)))
 				shareware_file = 0;
 			break;
 		case 8:
-			if (player_file_size == 2222)
+			if (player_file_size == (2212 + info.n_highest_levels * sizeof(hli)))
 				shareware_file = 1;
-			if (player_file_size == 2262)
+			if (player_file_size == (2252 + info.n_highest_levels * sizeof(hli)))
 				shareware_file = 0;
 			/* d1x-rebirth broke things by adding stuff to the
 			   player struct without thinking (sigh) */
-			if (player_file_size == (2222 + 2*sizeof(int)))
+			if (player_file_size == (2212 + 2*sizeof(int) + info.n_highest_levels * sizeof(hli)))
 			{
 				shareware_file = 1;
 				/* skip the cruft added to the player_info struct */
 				fseek(file, 2*sizeof(int), SEEK_CUR);
 			}
-			if (player_file_size == (2262 + 2*sizeof(int)))
+			if (player_file_size == (2252 + 2*sizeof(int) + info.n_highest_levels * sizeof(hli)))
 			{
 				shareware_file = 0;
 				/* skip the cruft added to the player_info struct */

d1x-playerfile-compat.patch:

--- NEW FILE d1x-playerfile-compat.patch ---
--- d1x/main/playsave.c.aap	2006-09-23 14:55:57.000000000 +0200
+++ d1x/main/playsave.c	2006-09-23 15:27:25.000000000 +0200
@@ -1280,6 +1280,8 @@
 	FILE *file;
 	save_info info;
 	int errno_ret = EZERO;
+	int player_file_size;
+	int shareware_file = -1;
 
 	Assert(Player_num>=0 && Player_num<MAX_PLAYERS);
 
@@ -1303,6 +1305,20 @@
 	if (!file) {
 		return errno;
 	}
+	
+	// Unfortunatly d1x has been writing both shareware and registered
+	// player files with a saved_game_version of 7 and 8, whereas the
+	// original decent used 4 for shareware games and 7 for registered
+	// games. Because of this the player files didn't get properly read
+	// when reading d1x shareware player files in d1x registered or
+	// vica versa. The problem is that the sizeof of the taunt macros
+	// differ between the share and registered versions, causing the
+	// reading of the player file to go wrong. Thus we now determine the
+	// sizeof the player file to determine what kinda player file we are
+	// dealing with so that we can do the right thing
+	fseek(file, 0, SEEK_END);
+	player_file_size = ftell(file);
+	rewind(file);
 
 	if (fread(&info,sizeof(info),1,file) != 1) {
 		errno_ret = errno;
@@ -1321,6 +1337,50 @@
 		return -1;
 	}
 
+	/* determine if we're dealing with a shareware or registered playerfile */
+	switch (info.saved_game_version)
+	{
+		case 4:
+			shareware_file = 1;
+			break;
+		case 5:
+		case 6:
+			shareware_file = 0;
+			break;
+		case 7:
+			/* version 7 doesn't have the saved games array */
+			if (player_file_size == (2222 - sizeof(saved_games)))
+				shareware_file = 1;
+			if (player_file_size == (2262 - sizeof(saved_games)))
+				shareware_file = 0;
+			break;
+		case 8:
+			if (player_file_size == 2222)
+				shareware_file = 1;
+			if (player_file_size == 2262)
+				shareware_file = 0;
+			/* d1x-rebirth broke things by adding stuff to the
+			   player struct without thinking (sigh) */
+			if (player_file_size == (2222 + 2*sizeof(int)))
+			{
+				shareware_file = 1;
+				/* skip the cruft added to the player_info struct */
+				fseek(file, 2*sizeof(int), SEEK_CUR);
+			}
+			if (player_file_size == (2262 + 2*sizeof(int)))
+			{
+				shareware_file = 0;
+				/* skip the cruft added to the player_info struct */
+				fseek(file, 2*sizeof(int), SEEK_CUR);
+			}
+	}
+	
+	if (shareware_file == -1) {
+		nm_messagebox(TXT_ERROR, 1, TXT_OK, "Error invalid or unknown playerfile-size");
+		fclose(file);
+		return -1;
+	}
+	
 	if (info.saved_game_version <= 5) {
 
 		//deal with old-style highest level info
@@ -1363,14 +1423,23 @@
 
 	//read taunt macros
 	{
-		int i,len;
-
-		#ifdef SHAREWARE
-		len = MAX_MESSAGE_LEN;
+		int i;
+		#if defined SHAREWARE && defined NETWORK
+		for (i = 0; i < 4; i++)
+		{
+			if (fread(Network_message_macro[i], MAX_MESSAGE_LEN, 1, file) != 1)
+				{errno_ret = errno; break;}
+			/* if this is not a shareware file, make sure what we've
+			   read is 0 terminated and skip the 10 additional bytes
+			   of the registered version */
+			if (!shareware_file)
+			{
+				Network_message_macro[i][MAX_MESSAGE_LEN-1] = 0;
+				fseek(file, 10, SEEK_CUR);
+			}
+		}
 		#else
-		len = (info.saved_game_version == 4)?SHAREWARE_MAX_MESSAGE_LEN:MAX_MESSAGE_LEN;
-		#endif
-
+		int len = shareware_file? 25:35;
 		#ifdef NETWORK
 		for (i = 0; i < 4; i++)
 			if (fread(Network_message_macro[i], len, 1, file) != 1)
@@ -1379,6 +1448,7 @@
 		i = 0;
 		fseek( file, 4*len, SEEK_CUR );
 		#endif
+		#endif
 	}
 
 

d1x-post-rebirth-fixes.patch:

--- NEW FILE d1x-post-rebirth-fixes.patch ---
diff -up d1x/main/game.c.foo d1x/main/game.c
--- d1x/main/game.c.foo	2008-07-23 15:33:30.000000000 +0200
+++ d1x/main/game.c	2008-07-23 15:34:07.000000000 +0200
@@ -554,7 +554,6 @@ u_int32_t			VR_screen_mode		= 0;
 int			VR_render_width	= 0;
 int			VR_render_height	= 0;
 int			VR_render_mode		= VR_NONE;
-int			VR_compatible_menus	= 0;
 int			VR_low_res 			= 3;				// Default to low res
 int 			VR_show_hud = 1;
 int			VR_sensitivity     = 1;		// 0 - 2
@@ -1136,16 +1135,15 @@ void game_init_render_sub_buffers( int x
 
 
 // Sets up the canvases we will be rendering to
-void game_init_render_buffers(u_int32_t screen_mode, int render_w, int render_h, int use_paging, int render_method, int compatible_menus )
+void game_init_render_buffers(u_int32_t screen_mode, int render_w, int render_h, int render_method)
 {
 	if (!VR_offscreen_buffer)	{
-		VR_use_paging 		= use_paging;
+		VR_use_paging 		= FindArg("-doublebuffer");
 
 		VR_screen_mode		= screen_mode;
-		VR_render_mode 	= render_method;
-		VR_render_width	= render_w;
+		VR_render_mode 		= render_method;
+		VR_render_width		= render_w;
 		VR_render_height	= render_h;
-		VR_compatible_menus = compatible_menus;
 
 		Game_window_w 		= render_w;
 		Game_window_h		= render_h;
@@ -1208,12 +1206,6 @@ void game_init_render_buffers(u_int32_t 
 int set_screen_mode(int sm)
 {
 stop_time();
-#ifndef OGL //ogl needs Screen_mode set correctly, or menus do not work.
-	if ( (sm==SCREEN_MENU) && (Screen_mode==SCREEN_GAME) && VR_compatible_menus )	{
-		sm = SCREEN_GAME;
-	}
-#endif
-
 #ifdef EDITOR
 	if ( (sm==SCREEN_MENU) && (Screen_mode==SCREEN_EDITOR) )	{
 		gr_set_current_canvas( Canv_editor );
@@ -1221,7 +1213,11 @@ stop_time();
 	}
 #endif
 
-        if ( (Screen_mode == sm) && !((sm==SCREEN_GAME) && (grd_curscreen->sc_mode != Game_screen_mode) && (Screen_mode == SCREEN_GAME))) {
+	if ( (Screen_mode == sm) &&
+		!((sm==SCREEN_GAME) &&
+			(grd_curscreen->sc_mode != Game_screen_mode)) &&
+		!((sm==SCREEN_MENU) &&
+			(grd_curscreen->sc_mode != MENU_SCREEN_MODE)) ) {
 		gr_set_current_canvas( &VR_screen_pages[VR_current_page] );
 //		if ( VR_use_paging )	gr_show_canvas( &VR_screen_pages[VR_current_page] );
 #ifdef OGL
diff -up d1x/main/game.h.foo d1x/main/game.h
--- d1x/main/game.h.foo	1999-11-21 14:00:08.000000000 +0100
+++ d1x/main/game.h	2008-07-23 15:34:07.000000000 +0200
@@ -435,7 +435,7 @@ extern grs_canvas VR_screen_pages[2];	//
 extern grs_canvas VR_screen_sub_pages[2];	//  Two sub pages of VRAM if paging is available
 extern grs_canvas *VR_offscreen_menu;		// The offscreen data buffer for menus
 
-void game_init_render_buffers (u_int32_t screen_mode, int render_max_w, int render_max_h, int use_paging, int render_method, int compatible_menus);
+void game_init_render_buffers (u_int32_t screen_mode, int render_max_w, int render_max_h, int render_method);
 extern int maxfps;
 extern int use_nice_fps;
 extern int Allow_primary_cycle;
diff -up d1x/main/inferno.c.foo d1x/main/inferno.c
--- d1x/main/inferno.c.foo	2008-07-23 15:33:30.000000000 +0200
+++ d1x/main/inferno.c	2008-07-23 15:34:07.000000000 +0200
@@ -1329,13 +1329,9 @@ int main(int argc,char **argv)
 //added on 12/14/98 by Matt Mueller - override res in d1x.ini with command line args
 		int i, argnum=INT_MAX;
 //end addition -MM
-                int vr_mode = VR_NONE;
-		int screen_compatible = 1;
-		int use_double_buffer = 0;
-
 //added/edited on 12/14/98 by Matt Mueller - override res in d1x.ini with command line args
 //added on 9/30/98 by Matt Mueller clean up screen mode code, and add higher resolutions
-#define SCREENMODE(X,Y,C) if ( (i=FindArg( "-" #X "x" #Y ))&&(i<argnum))  {argnum=i; screen_mode = SM( X , Y );if (Inferno_verbose) printf( "Using " #X "x" #Y " ...\n" );screen_width = X;screen_height = Y;use_double_buffer = 1;screen_compatible = C;}
+#define SCREENMODE(X,Y,C) if ( (i=FindArg( "-" #X "x" #Y ))&&(i<argnum))  {argnum=i; screen_mode = SM( X , Y );if (Inferno_verbose) printf( "Using " #X "x" #Y " ...\n" );screen_width = X;screen_height = Y;}
 //aren't #defines great? :)
 
 		SCREENMODE(320,100,0);
@@ -1353,21 +1349,10 @@ int main(int argc,char **argv)
 		SCREENMODE(1600,1200,0);
 //end addition -MM
 		
-//added ifdefs on 9/30/98 by Matt Mueller to fix high res in linux
-#ifdef __MSDOS__
-		if ( FindArg( "-nodoublebuffer" ) )	{
-			if (Inferno_verbose) printf( "Double-buffering disabled...\n" );
-#endif
-			use_double_buffer = 0;
-#ifdef __MSDOS__
-                }
-#endif
-//end addition -MM
-
                 //added 3/24/99 by Owen Evans for screen res changing
                 Game_screen_mode = screen_mode;
                 //end added -OE
-                game_init_render_buffers(screen_mode, screen_width, screen_height, use_double_buffer, vr_mode, screen_compatible);
+                game_init_render_buffers(screen_mode, screen_width, screen_height, VR_NONE);
                 
 	}
 	{
diff -up d1x/main/menu.c.foo d1x/main/menu.c
--- d1x/main/menu.c.foo	2008-07-23 15:33:30.000000000 +0200
+++ d1x/main/menu.c	2008-07-23 15:34:07.000000000 +0200
@@ -226,12 +226,6 @@ void create_main_menu(newmenu_item *m, i
 
 	set_screen_mode (SCREEN_MENU);
 	
-	VR_screen_mode = Game_screen_mode = SM(VR_render_width,VR_render_height);
-
-	if (FindArg("-menu_gameres")) { // ZICO - set players resolution ofter player is selected
-		gr_set_mode(SM(VR_render_width,VR_render_height));
-		set_screen_mode(SCREEN_GAME);
-	}
 
 	ADD_ITEM(TXT_NEW_GAME,MENU_NEW_GAME,KEY_N);
 
@@ -909,8 +903,6 @@ void change_res()
 	u_int32_t modes[12];
 	int i = 0, mc = 0, num_presets = 0;
 	char customres[16];
-	int screen_compatible = 0;
-	int use_double_buffer = 0;
 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
  int fullscreenc;
 #endif
@@ -918,8 +910,6 @@ void change_res()
  u_int32_t screen_mode = 0;
  int screen_width = 0;
  int screen_height = 0;
- int vr_mode = VR_NONE;
-	int screen_flags = 0;
  
 	m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x200"; m[mc].value = (Game_screen_mode == SM(320,200)); m[mc].group = 0; modes[mc] = SM(320,200); mc++;
 	m[mc].type = NM_TYPE_RADIO; m[mc].text = "640x480"; m[mc].value = (Game_screen_mode == SM(640,480)); m[mc].group = 0; modes[mc] = SM(640,480); mc++;
@@ -980,18 +970,15 @@ void change_res()
 	if (screen_height <= 0 || screen_width <= 0)
 		return;
 
-#ifdef __MSDOS__
-	if (FindArg("-nodoublebuffer"))
-#endif
-	{
-   use_double_buffer = 0;
-	}
+	if (Game_screen_mode == screen_mode)
+		return;
 
-        VR_offscreen_buffer = 0;        //Disable VR (so that VR_Screen_mode doesnt mess us up
+	/* Free VR_offscreen_buffer so that game_init_render_buffers
+	   recreates it. */
+	gr_free_canvas(VR_offscreen_buffer);
+	VR_offscreen_buffer = NULL;
         Game_screen_mode = screen_mode;
-        Game_window_w=screen_width;
-        Game_window_h=screen_height;
-        game_init_render_buffers(screen_mode, screen_width, screen_height, use_double_buffer, vr_mode, screen_compatible);
+        game_init_render_buffers(screen_mode, screen_width, screen_height, VR_NONE);
         
 
         mprintf( (0, "\nInitializing palette system..." ));
@@ -1005,7 +992,6 @@ void change_res()
   last_drawn_cockpit[0]=-1;
   last_drawn_cockpit[1]=-1;
    vr_reset_display();
-	set_screen_mode(SCREEN_GAME);
 }
 
 
diff -up d1x/main/playsave.c.foo d1x/main/playsave.c
--- d1x/main/playsave.c.foo	2008-07-23 15:33:30.000000000 +0200
+++ d1x/main/playsave.c	2008-07-23 15:34:07.000000000 +0200
@@ -1394,10 +1394,19 @@ int read_player_file()
 		kc_set_controls();
 	}
 
-	Game_window_w = info.Game_window_w; // ZICO - read out saved pilot data
-	Game_window_h = info.Game_window_h;
-	VR_render_width =  info.Game_window_w;
-	VR_render_height =  info.Game_window_h;
+
+	if (Game_screen_mode != SM(info.Game_window_w,info.Game_window_h))
+	{
+		/* Free VR_offscreen_buffer so that game_init_render_buffers
+		   recreates it. */
+		gr_free_canvas(VR_offscreen_buffer);
+		VR_offscreen_buffer = NULL;
+		Game_screen_mode = SM(info.Game_window_w,info.Game_window_h);
+		game_init_render_buffers(
+			SM(info.Game_window_w,info.Game_window_h),
+			info.Game_window_w,
+			info.Game_window_h, VR_NONE);
+	}
 
 	return errno_ret;
 

d1x-rebirth-fixes.patch:

--- NEW FILE d1x-rebirth-fixes.patch ---
diff -urbB d1x/arch/sdl/digi.c ../d1x-rebirth_v0.42-src-20060416/arch/sdl/digi.c
--- d1x/arch/sdl/digi.c	2006-08-19 11:33:19.000000000 +0200
+++ ../d1x-rebirth_v0.42-src-20060416/arch/sdl/digi.c	2006-03-26 12:52:05.000000000 +0200
@@ -684,7 +684,7 @@
 			}
 			 
 			if (oldvolume != SoundObjects[i].volume) 	{
-				if ( SoundObjects[i].volume < MIN_VOLUME )	 {
+				if ( SoundObjects[i].volume < MIN_VOLUME || Function_mode == FMODE_MENU)	 {
 					// Sound is too far away, so stop it from playing.
 					if ((SoundObjects[i].flags & SOF_PLAYING)&&(SoundObjects[i].flags & SOF_PLAY_FOREVER))	{
                                         	SoundSlots[SoundObjects[i].handle].playing = 0;
diff -urbB d1x/arch/sdl/gr.c ../d1x-rebirth_v0.42-src-20060416/arch/sdl/gr.c
--- d1x/arch/sdl/gr.c	1999-11-21 14:00:09.000000000 +0100
+++ ../d1x-rebirth_v0.42-src-20060416/arch/sdl/gr.c	2006-04-08 21:44:42.000000000 +0200
@@ -151,7 +156,8 @@
 	memset( grd_curscreen, 0, sizeof(grs_screen));
 
 //added 10/05/98 by Matt Mueller - make fullscreen mode optional
-	if (FindArg("-fullscreen"))
+//	if (FindArg("-fullscreen"))
+	if (!(FindArg("-window"))) // ZICO - from window to fullscreen
 	     sdl_video_flags|=SDL_FULLSCREEN;
 //end addition -MM
 	//added 05/19/99 Matt Mueller - make HW surface optional
diff -urbB d1x/main/game.c ../d1x-rebirth_v0.42-src-20060416/main/game.c
--- d1x/main/game.c	2006-08-19 11:33:19.000000000 +0200
+++ ../d1x-rebirth_v0.42-src-20060416/main/game.c	2006-03-27 20:36:31.000000000 +0200
@@ -488,6 +488,10 @@
 int I_am_observer = 0;
 //end this section addition - VR
 
+#ifdef __LINUX__
+#include "SDL/SDL.h"
+#endif
+
 //added 8/23/99 by Matt Mueller for hot key res/fullscreen changing, and menu access
 extern void change_res();
 extern void d1x_options_menu();
@@ -1203,6 +809,7 @@
 //mode if cannot init requested mode)
 int set_screen_mode(int sm)
 {
+stop_time();
 #ifndef OGL //ogl needs Screen_mode set correctly, or menus do not work.
 	if ( (sm==SCREEN_MENU) && (Screen_mode==SCREEN_GAME) && VR_compatible_menus )	{
 		sm = SCREEN_GAME;
@@ -1239,6 +845,10 @@
 		}
                 gr_init_sub_canvas( &VR_screen_pages[0], &grd_curscreen->sc_canvas, 0, 0, grd_curscreen->sc_w, grd_curscreen->sc_h );
 		gr_init_sub_canvas( &VR_screen_pages[1], &grd_curscreen->sc_canvas, 0, 0, grd_curscreen->sc_w, grd_curscreen->sc_h );
+#ifdef __LINUX__
+	if (FindArg("-grabmouse"))
+		SDL_WM_GrabInput(SDL_GRAB_OFF);
+#endif
 		break;
 	case SCREEN_GAME:
 		if (grd_curscreen->sc_mode != VR_screen_mode)
@@ -1290,6 +909,10 @@
 		else
 			gr_init_sub_canvas( &VR_screen_pages[1], game_canvas, 0, 0, grd_curscreen->sc_w, grd_curscreen->sc_h );
 }
+#ifdef __LINUX__
+	if (FindArg("-grabmouse"))
+		SDL_WM_GrabInput(SDL_GRAB_ON);
+#endif
 		break;
 	#ifdef EDITOR
 	case SCREEN_EDITOR:
@@ -1529,7 +1144,7 @@
 int maxfps=80;
 //end this section
 //added on 9/2/98 by Victor Rachels to add option to free cpu time
-int use_nice_fps=0;
+int use_nice_fps=1; // ZICO - changed to be default
 //end this section
 
 void calc_frame_time()
diff -urbB d1x/main/key.c ../d1x-rebirth_v0.42-src-20060416/main/key.c
--- d1x/main/key.c	2000-01-18 05:01:23.000000000 +0100
+++ ../d1x-rebirth_v0.42-src-20060416/main/key.c	2006-03-26 12:51:56.000000000 +0200
@@ -92,7 +92,7 @@
 	{ "[",      '[',    '{',    ARCH_KEY_LBRACKET      },
 	{ "]",      ']',    '}',    ARCH_KEY_RBRACKET      },
 	//edited 06/08/99 Matt Mueller - set to correct key_text
-	{ "ƒ",      255,    255,    ARCH_KEY_ENTER         },
+	{ "ENTER",  255,    255,    ARCH_KEY_ENTER         },
 	//end edit -MM
 	{ "LCTRL",  255,    255,    ARCH_KEY_LCTRL         },
 	{ "A",      'a',    'A',    ARCH_KEY_A             },
@@ -230,7 +230,7 @@
 	{ "",       255,    255,    -1                     },
 	{ "",       255,    255,    -1                     },
 	//edited 06/08/99 Matt Mueller - set to correct key_text
-	{ "PADƒ",   255,    255,    ARCH_KEY_PADENTER      },
+	{ "PADENT", 255,    255,    ARCH_KEY_PADENTER      },
 	//end edit -MM
 	//edited 06/08/99 Matt Mueller - set to correct sym
 	{ "RCTRL",  255,    255,    ARCH_KEY_RCTRL         },
diff -urbB d1x/main/kconfig.c ../d1x-rebirth_v0.42-src-20060416/main/kconfig.c
--- d1x/main/kconfig.c	2000-10-27 06:08:33.000000000 +0200
+++ ../d1x-rebirth_v0.42-src-20060416/main/kconfig.c	2006-03-26 12:51:56.000000000 +0200
@@ -2527,10 +2537,12 @@
 	if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
 
 //----------- Read fire_primary_down_count
+	if (!Global_laser_firing_count) { // ZICO - prevets primary counts if energy is 0 ansd lasers go wild while recharge - VERY DIRTY HACK
         if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
         if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
         if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_joystick[0].value);
         if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
+	}
 
        #ifdef NETWORK
         if(use_alt_vulcanfire)
@@ -2563,10 +2575,12 @@
        #endif
 
 //----------- Read fire_primary_state
+	if (!Global_laser_firing_count) { // ZICO - prevets primary counts if energy is 0 ansd lasers go wild while recharge - VERY DIRTY HACK
 	if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
 	if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
 	if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_joystick[0].value);
 	if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
+	}
 
 //----------- Read fire_secondary_down_count
 	if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
diff -urbB d1x/main/menu.c ../d1x-rebirth_v0.42-src-20060416/main/menu.c
--- d1x/main/menu.c	2000-03-06 02:42:10.000000000 +0100
+++ ../d1x-rebirth_v0.42-src-20060416/main/menu.c	2006-04-14 23:18:24.000000000 +0200
@@ -1279,7 +1247,7 @@
 #ifdef __LINUX__
 		ADD_ITEM("Kalinix", MENU_KALI_MULTIPLAYER, -1 );
 #endif
-		ADD_ITEM(TXT_MODEM_GAME, MENU_START_SERIAL, -1);
+//		ADD_ITEM(TXT_MODEM_GAME, MENU_START_SERIAL, -1); // ZICO - outdated
 
 		choice = newmenu_do1( NULL, TXT_MULTIPLAYER, num_options, m, NULL, choice );
 		
@@ -1365,7 +1333,7 @@
 
 		m[num_options].type = NM_TYPE_INPUT; m[num_options].text=buf; m[num_options].text_len=128;menu_choice[num_options]=-1; num_options++;
 
-		choice = newmenu_do1( NULL, TXT_MULTIPLAYER, num_options, m, NULL, choice );
+		choice = newmenu_do1( NULL, "ENTER IP OR HOSTNAME", num_options, m, NULL, choice );
 
 		if ( choice > -1 ){
 			ip_connect_manual(buf);
@@ -1418,7 +1386,7 @@
 		old_game_mode = Game_mode;
 		num_options = 0;
 
-		ADD_ITEM("Connect to game list server",MENU_IP_SERV_CONNECT, -1 );
+//		ADD_ITEM("Connect to game list server",MENU_IP_SERV_CONNECT, -1 );
 		ADD_ITEM(TXT_START_NET_GAME, MENU_START_NETGAME, -1 );
 		ADD_ITEM(TXT_JOIN_NET_GAME, MENU_MANUAL_IP_JOIN, -1 );
 
diff -urbB d1x/main/mission.h ../d1x-rebirth_v0.42-src-20060416/main/mission.h
--- d1x/main/mission.h	1999-06-15 00:12:36.000000000 +0200
+++ ../d1x-rebirth_v0.42-src-20060416/main/mission.h	2006-03-26 12:51:56.000000000 +0200
@@ -53,7 +56,7 @@
 
 #include <types.h>
 
-#define MAX_MISSIONS                  100
+#define MAX_MISSIONS                 5000 // ZICO - changed from 100 to get more levels in list
 #define MAX_LEVELS_PER_MISSION         30
 #define MAX_SECRET_LEVELS_PER_MISSION   5
 #define MISSION_NAME_LEN               21
diff -urbB d1x/main/newmenu.h ../d1x-rebirth_v0.42-src-20060416/main/newmenu.h
--- d1x/main/newmenu.h	1999-06-15 00:12:48.000000000 +0200
+++ ../d1x-rebirth_v0.42-src-20060416/main/newmenu.h	2006-04-05 21:27:45.000000000 +0200
@@ -125,7 +128,7 @@
 #define NM_TYPE_INPUT_MENU	6		// A inputbox that you hit Enter to edit, when done, hit enter and menu leaves.
 #define NM_TYPE_SLIDER	7		// A slider from min_value to max_value. Draws with text_len chars.
 
-#define NM_MAX_TEXT_LEN	50
+#define NM_MAX_TEXT_LEN	255
 
 typedef struct newmenu_item {
 	int 	type;				// What kind of item this is, see NM_TYPE_????? defines
diff -urbB d1x/main/physics.c ../d1x-rebirth_v0.42-src-20060416/main/physics.c
--- d1x/main/physics.c	2006-08-19 11:33:19.000000000 +0200
+++ ../d1x-rebirth_v0.42-src-20060416/main/physics.c	2006-03-26 12:51:56.000000000 +0200
@@ -603,7 +343,9 @@
 	physics_info *pi;
 	int orig_segnum = obj->segnum;
 
+	if (!Player_is_dead)			// ZICO - object can be none if player is dead
 	Assert(obj->type != OBJ_NONE);
+
 	Assert(obj->movement_type == MT_PHYSICS);
 
 #ifndef NDEBUG
diff -urbB d1x/main/automap.c ../d1x-rebirth_v0.42-src-20060416/main/automap.c
--- d1x/main/automap.c	1999-11-21 14:00:08.000000000 +0100
+++ ../d1x-rebirth_v0.42-src-20060416/main/automap.c	2006-03-26 12:51:56.000000000 +0200
@@ -390,8 +390,12 @@
 u_int32_t automap_mode = SM(640,480);
 int automap_width = 640;
 int automap_height = 480;
-int automap_use_game_res=0;
-int nice_automap=0;
+#ifdef OGL
+int automap_use_game_res=1; // ZICO - should be better
+#else
+int automap_use_game_res=0;
+#endif
+int nice_automap=1; // ZICO - should be better (command-line switches deactivated)
 
 void do_automap( int key_code )	{
 	int done=0;

d1x-rebirth-highresbrief.patch:

--- NEW FILE d1x-rebirth-highresbrief.patch ---
diff -urbB d1x/main/titles.c ../d1x-rebirth_v0.42-src-20060416/main/titles.c
--- d1x/main/titles.c	2006-08-19 11:33:19.000000000 +0200
+++ ../d1x-rebirth_v0.42-src-20060416/main/titles.c	2006-03-27 18:20:10.000000000 +0200
@@ -319,7 +144,7 @@
 }
 
 typedef struct {
-	char	bs_name[14];						//	filename, eg merc01.  Assumes .lbm suffix.
+	char	bs_name[255]; // filename, eg merc01.  Assumes .lbm suffix.
 	byte	level_num;
 	byte	message_num;
 	short	text_ulx, text_uly;		 	//	upper left x,y of text window
@@ -403,8 +219,70 @@
 
 };
 
-#define	MAX_BRIEFING_SCREEN	(sizeof(Briefing_screens) / sizeof(Briefing_screens[0]))
+briefing_screen Briefing_screens_h[] = { // ZICO - added for hires screens
+	{ "brief01h.pcx",   0,  1,  13, 140, 290,  59 },
+	{ "brief02h.pcx",   0,  2,  27,  34, 257, 177 },
+	{ "brief03h.pcx",   0,  3,  20,  22, 257, 177 },
+	{ "brief02h.pcx",   0,  4,  27,  34, 257, 177 },
+
+	{ "moon01h.pcx",    1,  5,  10,  10, 300, 170 },	// level 1
+	{ "moon01h.pcx",    2,  6,  10,  10, 300, 170 },	// level 2
+	{ "moon01h.pcx",    3,  7,  10,  10, 300, 170 },	// level 3
+
+	{ "venus01h.pcx",   4,  8,  15,  15, 300, 200 },	// level 4
+	{ "venus01h.pcx",   5,  9,  15,  15, 300, 200 },	// level 5
+
+	{ "brief03h.pcx",   6, 10,  20,  22, 257, 177 },
+	{ "merc01h.pcx",    6, 11,  10,  15, 300, 200 },	// level 6
+	{ "merc01h.pcx",    7, 12,  10,  15, 300, 200 },	// level 7
 
+#ifndef SHAREWARE
+	{ "brief03h.pcx",   8, 13,  20,  22, 257, 177 },
+	{ "mars01h.pcx",    8, 14,  10, 100, 300, 200 },	// level 8
+	{ "mars01h.pcx",    9, 15,  10, 100, 300, 200 },	// level 9
+	{ "brief03h.pcx",  10, 16,  20,  22, 257, 177 },
+	{ "mars01h.pcx",   10, 17,  10, 100, 300, 200 },	// level 10
+
+	{ "jup01h.pcx",    11, 18,  10,  40, 300, 200 },	// level 11
+	{ "jup01h.pcx",    12, 19,  10,  40, 300, 200 },	// level 12
+	{ "brief03h.pcx",  13, 20,  20,  22, 257, 177 },
+	{ "jup01h.pcx",    13, 21,  10,  40, 300, 200 },	// level 13
+	{ "jup01h.pcx",    14, 22,  10,  40, 300, 200 },	// level 14
+
+	{ "saturn01h.pcx", 15, 23,  10,  40, 300, 200 },	// level 15
+	{ "brief03h.pcx",  16, 24,  20,  22, 257, 177 },
+	{ "saturn01h.pcx", 16, 25,  10,  40, 300, 200 },	// level 16
+	{ "brief03h.pcx",  17, 26,  20,  22, 257, 177 },
+	{ "saturn01h.pcx", 17, 27,  10,  40, 300, 200 },	// level 17
+
+	{ "uranus01h.pcx", 18, 28, 100, 100, 300, 200 },	// level 18
+	{ "uranus01h.pcx", 19, 29, 100, 100, 300, 200 },	// level 19
+	{ "uranus01h.pcx", 20, 30, 100, 100, 300, 200 },	// level 20
+	{ "uranus01h.pcx", 21, 31, 100, 100, 300, 200 },	// level 21
+
+	{ "neptun01h.pcx", 22, 32,  10,  20, 300, 200 },	// level 22
+	{ "neptun01h.pcx", 23, 33,  10,  20, 300, 200 },	// level 23
+	{ "neptun01h.pcx", 24, 34,  10,  20, 300, 200 },	// level 24
+
+	{ "pluto01h.pcx",  25, 35,  10,  20, 300, 200 },	// level 25
+	{ "pluto01h.pcx",  26, 36,  10,  20, 300, 200 },	// level 26
+	{ "pluto01h.pcx",  27, 37,  10,  20, 300, 200 },	// level 27
+
+	{ "aster01h.pcx",  -1, 38,  10, 90, 300,  200 },	// secret level -1
+	{ "aster01h.pcx",  -2, 39,  10, 90, 300,  200 },	// secret level -2
+	{ "aster01h.pcx",  -3, 40,  10, 90, 300,  200 }, 	// secret level -3
+#endif
+
+	{ "end01h.pcx",   SHAREWARE_ENDING_LEVEL_NUM,   1,  23, 40, 320, 200 }, 	// shareware end
+#ifndef SHAREWARE
+	{ "end02h.pcx",   REGISTERED_ENDING_LEVEL_NUM,  1,   5,  5, 300, 200 }, 	// registered end
+	{ "end01h.pcx",   REGISTERED_ENDING_LEVEL_NUM,  2,  23, 40, 320, 200 }, 	// registered end
+	{ "end03h.pcx",   REGISTERED_ENDING_LEVEL_NUM,  3,   5,  5, 300, 200 }, 	// registered end
+#endif
+
+};
+
+#define	MAX_BRIEFING_SCREEN (sizeof(Briefing_screens) / sizeof(Briefing_screens[0]))
 
 char * get_briefing_screen( int level_num )
 {
@@ -409,10 +287,14 @@
 char * get_briefing_screen( int level_num )
 {
 	int i, found_level=0, last_level=0;
-
 	for (i = 0; i < MAX_BRIEFING_SCREEN; i++)	{
+		if (SWIDTH >= 640 && cfexist(D1XDATAPATH "brief01h.pcx")) {
+			if ( found_level && Briefing_screens_h[i].level_num != level_num )
+				return Briefing_screens_h[last_level].bs_name;
+		} else {
 		if ( found_level && Briefing_screens[i].level_num != level_num )
 			return Briefing_screens[last_level].bs_name;
+		}
 		if (Briefing_screens[i].level_num == level_num )	{
 			found_level=1;
 			last_level = i;
@@ -446,6 +329,7 @@
 {
         grs_canvas      *curcanv_save, *bitmap_canv=0;
 	grs_bitmap	*bitmap_ptr;
+	int c0, c1;
 
 	//	Only plot every nth frame.
 	if (Door_div_count) {
@@ -465,13 +349,17 @@
 			New_pal[254*3] = 0;
 			New_pal[254*3+1] = 0;
 			New_pal[254*3+2] = 0;
-			gr_palette_load( New_pal );
-//                        vfx_set_palette_sub( New_pal );
+		}
+
+	if (SWIDTH >= 640 && cfexist(D1XDATAPATH "brief01h.pcx")) {
+		c0=0;c1=0;
+	} else {
+		c0=64;c1=94;
 		}
 
 		switch (Animating_bitmap_type) {
-			case 0:	bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_y(45), 64, 64);	break;
-			case 1:	bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_y(45), 94, 94);	break;	//	Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
+		case 0:		bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_y(45), c0, c0);	break;
+		case 1:		bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_y(45), c1, c1);	break; // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
 			default:	Int3();	//	Impossible, illegal value for Animating_bitmap_type
 		}
 
@@ -549,7 +435,13 @@
 {
 	grs_canvas	*curcanv_save, *bitmap_canv;
 
-	bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 166, 138);
+	if (SWIDTH >= 640 && cfexist(D1XDATAPATH "brief01h.pcx")) // ZICO - use hires if available
+	{
+		bitmap_canv = gr_create_sub_canvas(grd_curcanv, 0, 0, 0, 0);
+	} else {
+		bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220*((double)SWIDTH/320), 45*((double)SHEIGHT/200), 166, 138);
+	}
+
 	curcanv_save = grd_curcanv;
 	grd_curcanv = bitmap_canv;
 	gr_bitmapm(0, 0, bmp);
@@ -662,14 +546,20 @@
 int load_briefing_screen( int screen_num )
 {
 	int	pcx_error;
-
+	if (SWIDTH >= 640 && cfexist(D1XDATAPATH "brief01h.pcx")) // ZICO - use hires if available
+	{
+		if ((pcx_error=pcx_read_fullscr( Briefing_screens_h[screen_num].bs_name, New_pal ))!=PCX_ERROR_NONE) {
+			printf( "File '%s', PCX load error: %s\n  (It's a briefing screen.  Does this cause you pain?)\n",Briefing_screens_h[screen_num].bs_name, pcx_errormsg(pcx_error));
+			Int3();
+			return 0;
+		}
+	} else {
 	if ((pcx_error=pcx_read_fullscr( Briefing_screens[screen_num].bs_name, New_pal ))!=PCX_ERROR_NONE) {
 		printf( "File '%s', PCX load error: %s\n  (It's a briefing screen.  Does this cause you pain?)\n",Briefing_screens[screen_num].bs_name, pcx_errormsg(pcx_error));
-		//printf(0, "File '%s', PCX load error: %s (%i)\n  (It's a briefing screen.  Does this cause you pain?)\n",Briefing_screens[screen_num].bs_name, pcx_errormsg(pcx_error), pcx_error); // adb: huh?
 		Int3();
 		return 0;
 	}
-
+	}
 	return 0;
 }
 
@@ -1133,6 +1010,16 @@
 	}
 
 	gr_init_bitmap_data (&briefing_bm);
+
+	if (SWIDTH >= 640 && cfexist(D1XDATAPATH "brief01h.pcx")) // ZICO - use hires if available
+	{
+		if ((pcx_error=pcx_read_bitmap( Briefing_screens_h[screen_num].bs_name, &briefing_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
+			printf( "PCX load error: %s.  File '%s'\n\n", pcx_errormsg(pcx_error), Briefing_screens_h[screen_num].bs_name);
+			mprintf((0, "File '%s', PCX load error: %s (%i)\n  (It's a briefing screen.  Does this cause you pain?)\n",Briefing_screens_h[screen_num].bs_name, pcx_errormsg(pcx_error), pcx_error));
+		Int3();
+		return 0;
+		}
+	} else {
 	if ((pcx_error=pcx_read_bitmap( Briefing_screens[screen_num].bs_name, &briefing_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
 		printf( "PCX load error: %s.  File '%s'\n\n", pcx_errormsg(pcx_error), Briefing_screens[screen_num].bs_name);
 		mprintf((0, "File '%s', PCX load error: %s (%i)\n  (It's a briefing screen.  Does this cause you pain?)\n",Briefing_screens[screen_num].bs_name, pcx_errormsg(pcx_error), pcx_error));
@@ -1140,17 +1027,19 @@
 		return 0;
 	}
 
-//        vfx_set_palette_sub( New_pal );
+	}
+
 #ifdef OGL
 	gr_palette_load(New_pal);
 #else
 	gr_palette_clear();
 #endif
+	gr_clear_canvas(BM_RGB(0,255,255));
         show_fullscr(&briefing_bm );
 
-        //added on 9/13/98 by adb to make arch's requiring updates work
+//added on 9/13/98 by adb to make arch's requiring updates work
         gr_update();
-        //end changes by adb
+//end changes by adb
         
 	gr_free_bitmap_data (&briefing_bm);
 

d1x-rebirth-mode-handling.patch:

--- NEW FILE d1x-rebirth-mode-handling.patch ---
diff -urbB d1x/main/menu.c ../d1x-rebirth_v0.42-src-20060416/main/menu.c
--- d1x/main/menu.c	2000-03-06 02:42:10.000000000 +0100
+++ ../d1x-rebirth_v0.42-src-20060416/main/menu.c	2006-04-14 23:18:24.000000000 +0200
@@ -226,6 +226,12 @@
 
 	set_screen_mode (SCREEN_MENU);
 	
+	VR_screen_mode = Game_screen_mode = SM(VR_render_width,VR_render_height);
+
+	if (FindArg("-menu_gameres")) { // ZICO - set players resolution ofter player is selected
+		gr_set_mode(SM(VR_render_width,VR_render_height));
+		set_screen_mode(SCREEN_GAME);
+	}
 
 	ADD_ITEM(TXT_NEW_GAME,MENU_NEW_GAME,KEY_N);
 
@@ -898,10 +905,13 @@
 
 void change_res()
 {
- //edited 05/27/99 Matt Mueller - ingame fullscreen changing
- newmenu_item m[8];
- u_int32_t modes[8];
- int i=0, mc=0;
+	// edited 05/27/99 Matt Mueller - ingame fullscreen changing
+	newmenu_item m[12]; // ZICO - from 11 to 12 to be sure...
+	u_int32_t modes[12];
+	int i = 0, mc = 0, num_presets = 0;
+	char customres[16];
+	int screen_compatible = 0;
+	int use_double_buffer = 0;
 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
  int fullscreenc;
 #endif
@@ -910,107 +920,73 @@
  int screen_width = 0;
  int screen_height = 0;
  int vr_mode = VR_NONE;
- int screen_compatible = 0;
- int use_double_buffer = 0;
+	int screen_flags = 0;
  
-//changed 6/15/1999 by Owen Evans to fix some platform-related problems
-#ifdef __MSDOS__
- m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x100"; m[mc].value=(Game_screen_mode==SM(320,100)); m[mc].group=0; modes[mc] = SM(320,100); mc++;
-#endif
- m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x200"; m[mc].value=(Game_screen_mode==SM(320,200)); m[mc].group=0; modes[mc] = SM(320,200); mc++;
- m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x240"; m[mc].value=(Game_screen_mode==SM(320,240)); m[mc].group=0; modes[mc] = SM(320,240); mc++;
- m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x400"; m[mc].value=(Game_screen_mode==SM(320,400)); m[mc].group=0; modes[mc] = SM(320,400); mc++;
-//#ifndef __LINUX__ - heh?  640x400 is perfectly fine on linux
- m[mc].type = NM_TYPE_RADIO; m[mc].text = "640x400"; m[mc].value=(Game_screen_mode==SM(640,400)); m[mc].group=0; modes[mc] = SM(640,400); mc++;
-//#endif
- m[mc].type = NM_TYPE_RADIO; m[mc].text = "640x480"; m[mc].value=(Game_screen_mode==SM(640,480)); m[mc].group=0; modes[mc] = SM(640,480); mc++;
- m[mc].type = NM_TYPE_RADIO; m[mc].text = "800x600"; m[mc].value=(Game_screen_mode==SM(800,600)); m[mc].group=0; modes[mc] = SM(800,600); mc++;
- m[mc].type = NM_TYPE_RADIO; m[mc].text = "1024x768"; m[mc].value=(Game_screen_mode==SM(1024,768)); m[mc].group=0; modes[mc] = SM(1024,768); mc++;
-//end section - OE
+	m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x200"; m[mc].value = (Game_screen_mode == SM(320,200)); m[mc].group = 0; modes[mc] = SM(320,200); mc++;
+	m[mc].type = NM_TYPE_RADIO; m[mc].text = "640x480"; m[mc].value = (Game_screen_mode == SM(640,480)); m[mc].group = 0; modes[mc] = SM(640,480); mc++;
+	m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x400"; m[mc].value = (Game_screen_mode == SM(320,400)); m[mc].group = 0; modes[mc] = SM(320,400); mc++;
+	m[mc].type = NM_TYPE_RADIO; m[mc].text = "640x400"; m[mc].value = (Game_screen_mode == SM(640,400)); m[mc].group = 0; modes[mc] = SM(640,400); mc++;
+	m[mc].type = NM_TYPE_RADIO; m[mc].text = "800x600"; m[mc].value = (Game_screen_mode == SM(800,600)); m[mc].group = 0; modes[mc] = SM(800,600); mc++;
+	m[mc].type = NM_TYPE_RADIO; m[mc].text = "1024x768"; m[mc].value = (Game_screen_mode == SM(1024,768)); m[mc].group = 0; modes[mc] = SM(1024,768); mc++;
+	m[mc].type = NM_TYPE_RADIO; m[mc].text = "1280x1024"; m[mc].value = (Game_screen_mode == SM(1280,1024)); m[mc].group = 0; modes[mc] = SM(1280,1024); mc++;
+	m[mc].type = NM_TYPE_RADIO; m[mc].text = "1600x1200"; m[mc].value = (Game_screen_mode == SM(1600,1200)); m[mc].group = 0; modes[mc] = SM(1600,1200); mc++; // ZICO - added res
 
-// m[mc].type = NM_TYPE_CHECK; m[mc].text = "No Doublebuffer"; m[mc].value = use_double_buffer;
+	num_presets = mc;
+	for (i = 0; i < mc; i++)
+		if (m[mc].value)
+			break;
 
- //added 05/27/99 Matt Mueller - ingame fullscreen changing
+	m[mc].type = NM_TYPE_RADIO; m[mc].text = "custom:"; m[mc].value = (i == mc); m[mc].group = 0; modes[mc] = 0; mc++;
+	sprintf(customres, "%ix%i", SM_W(Game_screen_mode), SM_H(Game_screen_mode));
+	m[mc].type = NM_TYPE_INPUT; m[mc].text = customres; m[mc].text_len = 11; modes[mc] = 0; mc++;
+
+	//m[mc].type = NM_TYPE_CHECK; m[mc].text = "No Doublebuffer"; m[mc].value = use_double_buffer;
+
+	// added 05/27/99 Matt Mueller - ingame fullscreen changing
 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
- fullscreenc=mc;m[mc].type = NM_TYPE_CHECK; m[mc].text = "Fullscreen"; m[mc].value = gr_check_fullscreen();mc++;
+	fullscreenc = mc; m[mc].type = NM_TYPE_CHECK; m[mc].text = "Fullscreen"; m[mc].value = gr_check_fullscreen(); mc++;
 #endif
- //end addition -MM
+	// end addition -MM
 
 
-   i=newmenu_do1( NULL, "Screen Resolution", mc, m, &change_res_poll, i);
+	i = newmenu_do1(NULL, "Screen Resolution", mc, m, &change_res_poll, 0);
 
-  //added 05/27/99 Matt Mueller - ingame fullscreen changing
+	// added 05/27/99 Matt Mueller - ingame fullscreen changing
 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
-   if (m[fullscreenc].value != gr_check_fullscreen()){
+	if (m[fullscreenc].value != gr_check_fullscreen())
+	{
 	   gr_toggle_fullscreen();
         Game_screen_mode = -1;
    }
 #endif
-  //end addition -MM
    
-  for(i=0;(m[i].value==0)&&(i<6);i++);
+	for (i = 0; (m[i].value == 0) && (i < num_presets); i++);
 
-  switch(screen_mode = modes[i])
+	for(i = 0; (m[i].value == 0) && (i < num_presets); i++);
+
+	if (modes[i]==0)
    {
-    case SM(320,100)://19:
-           screen_width = 320;
-           screen_height = 100;
-           screen_compatible = 0;
-           use_double_buffer = 0;
-           break;
-	case SM(320,200)://SM_320x200C:
-           screen_width = 320;
-           screen_height = 200;
-           screen_compatible = 1;
-           use_double_buffer = 0;
-           break;
-	case SM(320,240)://SM_320x240U:
-           screen_width = 320;
-           screen_height = 240;
-           screen_compatible = 0;
-           use_double_buffer = 1;
-           break;
-	case SM(320,400)://SM_320x400U:
-           screen_width = 320;
-           screen_height = 400;
-           screen_compatible = 0;
-           use_double_buffer = 1;
-           break;
-	case SM(640,400)://SM_640x400V:
-           screen_width = 640;
-           screen_height = 400;
-           screen_compatible = 0;
-           use_double_buffer = 1;
-           break;
-	case SM(640,480)://SM_640x480V:
-           screen_width = 640;
-           screen_height = 480;
-           screen_compatible = 0;
-           use_double_buffer = 1;
-           break;
-	case SM(800,600)://SM_800x600V:
-           screen_width = 800;
-           screen_height = 600;
-           screen_compatible = 0;
-           use_double_buffer = 1;
-           break;
-	case SM(1024,768)://SM_1024x768V:
-           screen_width = 1024;
-           screen_height = 768;
-           screen_compatible = 0;
-           use_double_buffer = 1;
-           break;
+		char *h = strchr(customres, 'x');
+		if (!h)
+			return;
+		screen_mode = SM(atoi(customres), atoi(h+1));
    }
+	else
+	{
+		screen_mode = modes[i];
+	}
+
+	screen_width = SM_W(screen_mode);
+	screen_height = SM_H(screen_mode);
+	if (screen_height <= 0 || screen_width <= 0)
+		return;
+
 #ifdef __MSDOS__
-  if ( FindArg( "-nodoublebuffer" ) )
+	if (FindArg("-nodoublebuffer"))
 #endif
+	{
    use_double_buffer = 0;
-
-//added 6/15/1999 by Owen Evans to eliminate unneccesary mode modification
-	if (Game_screen_mode == screen_mode)
-		return;
-//      gr_set_mode(Game_screen_mode);
-//end section - OE
+	}
 
         VR_offscreen_buffer = 0;        //Disable VR (so that VR_Screen_mode doesnt mess us up
         Game_screen_mode = screen_mode;
@@ -1029,11 +1003,9 @@
   init_cockpit();
   last_drawn_cockpit[0]=-1;
   last_drawn_cockpit[1]=-1;
-//  init_gauges();
-
    vr_reset_display();
+	set_screen_mode(SCREEN_GAME);
 }
-//End changed section (OE)
 
 
 //added on 8/18/98 by Victor Rachels to add d1x options menu, maxfps setting
diff -urbB d1x/main/playsave.c ../d1x-rebirth_v0.42-src-20060416/main/playsave.c
--- d1x/main/playsave.c	2006-08-19 11:33:19.000000000 +0200
+++ ../d1x-rebirth_v0.42-src-20060416/main/playsave.c	2006-03-26 12:51:56.000000000 +0200
@@ -294,6 +297,8 @@
 	int	n_highest_levels;				//how many highest levels are saved
 	int	default_difficulty_level;
 	int	default_leveling_on;
+	int	Game_window_w;
+	int	Game_window_h;
 } __pack__ save_info;
 
 typedef struct hli {
@@ -1220,6 +1225,9 @@
 
 }
 
+	extern int screen_width;
+	extern int screen_height;
+
 //read in the player's saved games.  returns errno (0 == no error)
 int read_player_file()
 {
@@ -1388,6 +1396,12 @@
 	if (errno_ret==EZERO)	{
 		kc_set_controls();
 	}
+
+	Game_window_w = info.Game_window_w; // ZICO - read out saved pilot data
+	Game_window_h = info.Game_window_h;
+	VR_render_width =  info.Game_window_w;
+	VR_render_height =  info.Game_window_h;
+
 	return errno_ret;
 
 }
@@ -1474,6 +1488,8 @@
 	info.player_struct_version = PLAYER_STRUCT_VERSION;
 	info.default_difficulty_level = Player_default_difficulty;
 	info.default_leveling_on = Auto_leveling_on;
+	info.Game_window_w = Game_window_w;
+	info.Game_window_h = Game_window_h;
 
 	info.n_highest_levels = n_highest_levels;
 

d1x-rebirth-mouselook.patch:

--- NEW FILE d1x-rebirth-mouselook.patch ---
diff -urbB d1x/main/kconfig.c ../d1x-rebirth_v0.42-src-20060416/main/kconfig.c
--- d1x/main/kconfig.c	2000-10-27 06:08:33.000000000 +0200
+++ ../d1x-rebirth_v0.42-src-20060416/main/kconfig.c	2006-03-26 12:51:56.000000000 +0200
@@ -1878,6 +1881,13 @@
 	ubyte channel_masks;
 	int use_mouse, use_joystick;
 	int speed_factor=1;
+	int ph_div;
+
+	if ((i=FindArg("-mouselook")) && (Config_control_type == 5) ) {
+		ph_div = 2;
+	} else {
+		ph_div = 8;
+	}
 
 	if (Game_turbo_mode)
 		speed_factor = 2;
@@ -2208,9 +2218,9 @@
 		//mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
 		if ( (use_mouse)&&(kc_mouse[13].value < 255) )	{
 			if ( !kc_mouse[14].value )		// If not inverted...
-				Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
+				Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/ph_div; // ZICO we call pitch_div here for better pitching if mouselook
 			else
-				Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
+				Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/ph_div;
 		}
 	} else {
 		Controls.pitch_time = 0;
@@ -2337,9 +2347,9 @@
 		// From mouse...
 		if ( (use_mouse)&&(kc_mouse[15].value < 255 ))	{
 			if ( !kc_mouse[16].value )		// If not inverted...
-				Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
+				Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/ph_div;	// ZICO we call head_div here for better pitching if mouselook
 			else
-				Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
+				Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/ph_div;
 		}
 	} else {
 		Controls.heading_time = 0;
@@ -2640,17 +2654,20 @@
 	if (FrameTime > F1_0 )
 		mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
 
+// ZICO - remove clamp for pitch and heading if mouselook on and no multiplayer game
+if ((Config_control_type != 5) || !(i=FindArg("-mouselook")) || (Game_mode & GM_MULTI) ) {
 	if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
-	if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
 	if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
+	if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
+	if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
+}
+	if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
 	if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
 	if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
 	if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
 //	if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
 
-	if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
 	if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
-	if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
 	if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
 	if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
 	if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;

d1x-rebirth-ogl.patch:

--- NEW FILE d1x-rebirth-ogl.patch ---
diff -urbB d1x/arch/ogl/gr.c ../d1x-rebirth_v0.42-src-20060416/arch/ogl/gr.c
--- d1x/arch/ogl/gr.c	2000-10-28 11:31:08.000000000 +0200
+++ ../d1x-rebirth_v0.42-src-20060416/arch/ogl/gr.c	2006-08-19 11:31:29.000000000 +0200
@@ -64,8 +67,11 @@
 int gr_toggle_fullscreen(void){
 	gr_do_fullscreen(!ogl_fullscreen);
 	//	grd_curscreen->sc_mode=0;//hack to get it to reset screen mode
+	glFlush(); // ZICO - prevents black screen, screen glitches etc.
+ 
 	return ogl_fullscreen;
 }
+
 int arch_toggle_fullscreen_menu(void){
 	unsigned char *buf=NULL;
 
@@ -226,6 +234,11 @@
 	grd_curscreen->sc_mode = mode;
 	grd_curscreen->sc_w = w;
 	grd_curscreen->sc_h = h;
+	if (FindArg("-16to9"))
+		grd_curscreen->sc_aspect = fixdiv(grd_curscreen->sc_w*9,grd_curscreen->sc_h*16);
+	else if (FindArg("-16to10"))
+		grd_curscreen->sc_aspect = fixdiv(grd_curscreen->sc_w*10,grd_curscreen->sc_h*16);
+	else
 	grd_curscreen->sc_aspect = fixdiv(grd_curscreen->sc_w*3,grd_curscreen->sc_h*4);
 	grd_curscreen->sc_canvas.cv_bitmap.bm_x = 0;
 	grd_curscreen->sc_canvas.cv_bitmap.bm_y = 0;
@@ -332,7 +346,8 @@
 		ogl_voodoohack=1;
 		gr_toggle_fullscreen();
 	}
-	if (FindArg("-fullscreen"))
+//	if (FindArg("-fullscreen"))
+	if (!(FindArg("-window"))) // ZICO - from window to fullscreen
 		gr_toggle_fullscreen();
 #endif
 	if ((glt=FindArg("-gl_alttexmerge")))
@@ -348,6 +363,11 @@
 		GL_texmagfilt=GL_LINEAR;
 		GL_texminfilt=GL_LINEAR_MIPMAP_NEAREST;
 	}
+		if ((glt=FindArg("-gl_trilinear")))
+	{
+		GL_texmagfilt = GL_LINEAR;
+		GL_texminfilt = GL_LINEAR_MIPMAP_LINEAR;
+	}
 	if ((t=FindArg("-gl_simple"))){
 		if (t>=glt){//allow overriding of earlier args
 			glt=t;
@@ -576,57 +596,55 @@
 	}
 }
 
+#define GL_BGR_EXT 0x80E0
+
+typedef struct {
+      unsigned char TGAheader[12];
+      unsigned char header[6];
+} TGA_header;
+
 //writes out an uncompressed RGB .tga file
 //if we got really spiffy, we could optionally link in libpng or something, and use that.
-void write_bmp(char *savename,int w,int h,unsigned char *buf){
-	int f;
-#ifdef __WINDOWS__
-	f=open(savename,O_CREAT|O_EXCL|O_WRONLY,S_IRUSR|S_IWUSR);
-#else
-	f=open(savename,O_CREAT|O_EXCL|O_WRONLY,S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
-#endif
-	if (f>=0){
-		GLubyte    targaMagic[12] = { 0, //no identification field
-			 0,//no colormap
-			 2,//RGB image (well, BGR, actually)
-			 0, 0, 0, 0, 0, 0, 0, 0, 0 };//no colormap or image origin stuff.
-		GLubyte blah;
-		int r;
-		GLubyte *s;
-		int x,y;
-		
-		//write .TGA header.
-		write (f,targaMagic,sizeof(targaMagic));
-		blah=w%256;write (f,&blah,1);//w, low
-		blah=w/256;write (f,&blah,1);//w, high
-		blah=h%256;write (f,&blah,1);//h, low
-		blah=h/256;write (f,&blah,1);//h, high
-		blah=24;write (f,&blah,1);//24 bpp
-		blah=0;write (f,&blah,1);//no attribute bits, origin is lowerleft, no interleave
-		
-		s=buf;
-		for (y=0;y<h;y++){//TGAs use BGR ordering of data.
-			for (x=0;x<w;x++){
-				blah=s[0];
-				s[0]=s[2];
-				s[2]=blah;
-				s+=3;				
-			}
-		}
-		x=0;y=w*h*3;
-		while (x<y){
-			r=write(f,buf+x,y);
-			if (r<=0){
-				mprintf((0,"screenshot error, couldn't write to %s (err %i)\n",savename,errno));
-				break;
-			}
-			x+=r;y-=r;
-		}
-		close(f);
-	}else{
-		mprintf((0,"screenshot error, couldn't open %s (err %i)\n",savename,errno));
-	}
+void write_bmp(char *savename,int w,int h,unsigned char *buf){ // ZICO - modified for win32
+	FILE* TGAFile;
+	TGA_header TGA;
+	GLbyte HeightH,HeightL,WidthH,WidthL;
+
+	buf = (unsigned char*)calloc(w*h*3,sizeof(unsigned char));
+
+	glReadPixels(0,0,w,h,GL_BGR_EXT,GL_UNSIGNED_BYTE,buf);
+
+	TGAFile = fopen(savename, "wb");
+
+	HeightH = (GLbyte)(h / 256);
+	HeightL = (GLbyte)(h % 256);
+	WidthH  = (GLbyte)(w / 256);
+	WidthL  = (GLbyte)(w % 256);
+	// Write TGA Header
+	TGA.TGAheader[0] = 0;
+	TGA.TGAheader[1] = 0;
+	TGA.TGAheader[2] = 2;
+	TGA.TGAheader[3] = 0;
+	TGA.TGAheader[4] = 0;
+	TGA.TGAheader[5] = 0;
+	TGA.TGAheader[6] = 0;
+	TGA.TGAheader[7] = 0;
+	TGA.TGAheader[8] = 0;
+	TGA.TGAheader[9] = 0;
+	TGA.TGAheader[10] = 0;
+	TGA.TGAheader[11] = 0;
+	TGA.header[0] = (GLbyte) WidthL;
+	TGA.header[1] = (GLbyte) WidthH;
+	TGA.header[2] = (GLbyte) HeightL;
+	TGA.header[3] = (GLbyte) HeightH;
+	TGA.header[4] = (GLbyte) 24;
+	TGA.header[5] = 0;
+	fwrite(&TGA,sizeof(TGA_header),1,TGAFile);
+	fwrite(buf,w*h*3*sizeof(unsigned char),1,TGAFile);
+	fclose(TGAFile);
+	free(buf);
 }
+
 void save_screen_shot(int automap_flag)
 {
 //	fix t1;
@@ -656,18 +674,13 @@
 //end this section addition/change - Victor Rachels
 
 	if (automap_flag) {
-//	save_font = grd_curcanv->cv_font;
-//	gr_set_curfont(GAME_FONT);
-//	gr_set_fontcolor(gr_find_closest_color_current(0,31,0),-1);
-//	gr_get_string_size(message,&w,&h,&aw);
-//		modex_print_message(32, 2, message);
 	} else {
 		hud_message(MSGC_GAME_FEEDBACK,message);
 	}
 	
 	buf = malloc(grd_curscreen->sc_w*grd_curscreen->sc_h*3);
 	glReadBuffer(GL_FRONT);
-	glReadPixels(0,0,grd_curscreen->sc_w,grd_curscreen->sc_h,GL_RGB,GL_UNSIGNED_BYTE,buf);
+	//glReadPixels(0,0,grd_curscreen->sc_w,grd_curscreen->sc_h,GL_RGB,GL_UNSIGNED_BYTE,buf);
 	write_bmp(savename,grd_curscreen->sc_w,grd_curscreen->sc_h,buf);
 	free(buf);
 
diff -urbB d1x/arch/ogl/include/ogl_init.h ../d1x-rebirth_v0.42-src-20060416/arch/ogl/include/ogl_init.h
--- d1x/arch/ogl/include/ogl_init.h	2006-08-19 11:33:19.000000000 +0200
+++ ../d1x-rebirth_v0.42-src-20060416/arch/ogl/include/ogl_init.h	2006-04-03 20:48:26.000000000 +0200
@@ -34,7 +34,7 @@
 #include "types.h"
 
 
-#define OGL_TEXTURE_LIST_SIZE 2000
+#define OGL_TEXTURE_LIST_SIZE 20000 // ZICO - works better than 2000
 
 typedef struct _ogl_texture {
 	int handle;
@@ -143,6 +143,7 @@
 
 void ogl_urect(int left,int top,int right,int bot);
 bool ogl_ubitmapm_c(int x, int y,grs_bitmap *bm,int c);
+bool ogl_ubitmapm_cs(int x, int y,int dw, int dh, grs_bitmap *bm,int c, int scale, int orient);
 bool ogl_ubitmapm(int x, int y,grs_bitmap *bm);
 bool ogl_ubitblt_i(int dw,int dh,int dx,int dy, int sw, int sh, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
 bool ogl_ubitblt(int w,int h,int dx,int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
diff -urbB d1x/arch/ogl/ogl.c ../d1x-rebirth_v0.42-src-20060416/arch/ogl/ogl.c
--- d1x/arch/ogl/ogl.c	2006-08-19 11:33:19.000000000 +0200
+++ ../d1x-rebirth_v0.42-src-20060416/arch/ogl/ogl.c	2006-03-26 12:52:05.000000000 +0200
@@ -1438,7 +1438,7 @@
 	glmprintf((0,"ogl_loadtexture(%p,%i,%i,%ix%i,%p):%i u=%f v=%f b=%i bu=%i (%i)\n",data,tex->tw,tex->th,dxo,dyo,tex,tex->handle,tex->u,tex->v,tex->bytes,tex->bytesu,r_texcount));
 
 }
-unsigned char decodebuf[512*512];
+unsigned char decodebuf[1024*1024];
 void ogl_loadbmtexture_m(grs_bitmap *bm,int domipmap){
 	unsigned char *buf;
 	while (bm->bm_parent)
@@ -1498,3 +1498,85 @@
 //		bm->gltexture=-1;
 	}
 }
+
+bool ogl_ubitmapm_cs(int x, int y,int dw, int dh, grs_bitmap *bm,int c, int scale, int orient) // ZICO - only used to scale cockpit and statusbar
+{
+	GLfloat xo,yo,xf,yf;
+	GLfloat u1,u2,v1,v2;
+	GLdouble h,a;
+	r_ubitmapc++;
+	x+=grd_curcanv->cv_bitmap.bm_x;
+	y+=grd_curcanv->cv_bitmap.bm_y;
+	xo=x/(float)last_width;
+	xf=(bm->bm_w+x)/(float)last_width;
+	yo=1.0-y/(float)last_height;
+	yf=1.0-(bm->bm_h+y)/(float)last_height;
+
+	if (dw < 0)
+		dw = grd_curcanv->cv_bitmap.bm_w;
+	else if (dw == 0)
+		dw = bm->bm_w;
+	if (dh < 0)
+		dh = grd_curcanv->cv_bitmap.bm_h;
+	else if (dh == 0)
+		dh = bm->bm_h;
+	r_ubitmapc++;
+	if (orient & 1) {
+		int h = dw;
+		dw = dh;
+		dh = h;
+		x += grd_curcanv->cv_bitmap.bm_y;
+		y += grd_curcanv->cv_bitmap.bm_x;
+	}
+	else {
+		x += grd_curcanv->cv_bitmap.bm_x;
+		y += grd_curcanv->cv_bitmap.bm_y;
+	}
+
+	a = (double) grd_curscreen->sc_w / (double) grd_curscreen->sc_h;
+	h = (double) scale / (double) F1_0;
+
+	xo = x / ((double) last_width * h);
+	xf = (dw + x) / ((double) last_width * h);
+	yo = 1.0 - y / ((double) last_height * h);
+	yf = 1.0 - (dh + y) / ((double) last_height * h);
+
+	OGL_ENABLE(TEXTURE_2D);
+	ogl_bindbmtex(bm);
+	ogl_texwrap(bm->gltexture,GL_CLAMP);
+	
+	if (bm->bm_x==0){
+		u1=0;
+		if (bm->bm_w==bm->gltexture->w)
+			u2=bm->gltexture->u;
+		else
+			u2=(bm->bm_w+bm->bm_x)/(float)bm->gltexture->tw;
+	}else {
+		u1=bm->bm_x/(float)bm->gltexture->tw;
+		u2=(bm->bm_w+bm->bm_x)/(float)bm->gltexture->tw;
+	}
+	if (bm->bm_y==0){
+		v1=0;
+		if (bm->bm_h==bm->gltexture->h)
+			v2=bm->gltexture->v;
+		else
+			v2=(bm->bm_h+bm->bm_y)/(float)bm->gltexture->th;
+	}else{
+		v1=bm->bm_y/(float)bm->gltexture->th;
+		v2=(bm->bm_h+bm->bm_y)/(float)bm->gltexture->th;
+	}
+
+	glBegin(GL_QUADS);
+	if (c<0)
+		glColor3f(1.0,1.0,1.0);
+	else
+	glColor3f(CPAL2Tr(c),CPAL2Tg(c),CPAL2Tb(c));
+	glTexCoord2f(u1, v1); glVertex2f(xo, yo);
+	glTexCoord2f(u2, v1); glVertex2f(xf, yo);
+	glTexCoord2f(u2, v2); glVertex2f(xf, yf);
+	glTexCoord2f(u1, v2); glVertex2f(xo, yf);
+	glActiveTextureARB(GL_TEXTURE0_ARB);
+	glEnd();
+	
+	return 0;
+}
diff -urbB d1x/arch/sdl/gr.c ../d1x-rebirth_v0.42-src-20060416/arch/sdl/gr.c
--- d1x/arch/sdl/gr.c	1999-11-21 14:00:09.000000000 +0100
+++ ../d1x-rebirth_v0.42-src-20060416/arch/sdl/gr.c	2006-04-08 21:44:42.000000000 +0200
@@ -108,6 +108,11 @@
 	grd_curscreen->sc_mode = mode;
 	grd_curscreen->sc_w = w;
 	grd_curscreen->sc_h = h;
+	if (FindArg("-16to9"))
+		grd_curscreen->sc_aspect = fixdiv(grd_curscreen->sc_w*9,grd_curscreen->sc_h*16);
+	else if (FindArg("-16to10"))
+		grd_curscreen->sc_aspect = fixdiv(grd_curscreen->sc_w*10,grd_curscreen->sc_h*16);
+	else
 	grd_curscreen->sc_aspect = fixdiv(grd_curscreen->sc_w*3,grd_curscreen->sc_h*4);
 	grd_curscreen->sc_canvas.cv_bitmap.bm_x = 0;
 	grd_curscreen->sc_canvas.cv_bitmap.bm_y = 0;
diff -urbB d1x/main/credits.c ../d1x-rebirth_v0.42-src-20060416/main/credits.c
--- d1x/main/credits.c	2006-08-19 11:33:19.000000000 +0200
+++ ../d1x-rebirth_v0.42-src-20060416/main/credits.c	2006-04-14 22:03:26.000000000 +0200
@@ -186,19 +50,53 @@
 #include "cfile.h"
 #include "compbit.h"
 #include "songs.h"
+#ifdef OGL
+#include "ogl_init.h" // ZICO - for gl_scissors
+#endif
 
-//#define ROW_SPACING 11
-//#define NUM_LINES 20			//19
-
-ubyte fade_values[200] = { 1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,8,9,9,10,10,
-11,11,12,12,12,13,13,14,14,15,15,15,16,16,17,17,17,18,18,19,19,19,20,20,
-20,21,21,22,22,22,23,23,23,24,24,24,24,25,25,25,26,26,26,26,27,27,27,27,
-28,28,28,28,28,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,31,31,31,31,
-31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,30,30,30,30,30,
-30,30,30,30,29,29,29,29,29,29,28,28,28,28,28,27,27,27,27,26,26,26,26,25,
-25,25,24,24,24,24,23,23,23,22,22,22,21,21,20,20,20,19,19,19,18,18,17,17,
-17,16,16,15,15,15,14,14,13,13,12,12,12,11,11,10,10,9,9,8,8,8,7,7,6,6,5,
-5,4,4,3,3,2,2,1 };
+#define ROW_SPACING			(GHEIGHT/17)
+#define NUM_LINES			14
+#define CREDITS_BACKGROUND_FILENAME	"stars.pcx"
+#define CREDITS_FILE 			"credits.tex"
+
+#ifdef OGL
+ubyte fade_values_hires[480] = {
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,8,9,9,10,10,11,11,12,12,
+12,13,13,14,14,15,15,15,16,16,17,17,17,18,18,19,19,19,20,20,20,21,21,22,
+22,22,23,23,23,24,24,24,24,25,25,25,26,26,26,26,27,27,27,27,28,28,28,28,
+28,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,31,31,31,31,31,31,31,31,
+31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,
+31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,
+31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,
+31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,
+31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,
+31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,30,30,30,30,30,30,30,30,30,
+29,29,29,29,29,29,28,28,28,28,28,27,27,27,27,26,26,26,26,25,25,25,24,24,
+24,24,23,23,23,22,22,22,21,21,20,20,20,19,19,19,18,18,17,17,17,16,16,15,
+15,15,14,14,13,13,12,12,12,11,11,10,10,9,9,8,8,8,7,7,6,6,5,5,4,4,3,3,2,
+2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0 };
+#else
+ubyte fade_values_hires[480] = { 1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,
+5,5,5,6,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9,9,9,9,10,10,10,10,10,10,11,11,11,11,11,12,12,12,12,12,12,
+13,13,13,13,13,14,14,14,14,14,14,15,15,15,15,15,15,16,16,16,16,16,17,17,17,17,17,17,18,18,
+18,18,18,18,18,19,19,19,19,19,19,20,20,20,20,20,20,20,21,21,21,21,21,21,22,22,22,22,22,22,
+22,22,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,26,26,26,26,
+26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,29,29,29,
+29,29,29,29,29,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,
+30,30,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,
+31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,30,30,30,
+30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,29,29,29,29,29,29,29,29,29,29,29,29,
+29,29,28,28,28,28,28,28,28,28,28,28,28,28,27,27,27,27,27,27,27,27,27,27,26,26,26,26,26,26,
+26,26,26,25,25,25,25,25,25,25,25,25,24,24,24,24,24,24,24,24,23,23,23,23,23,23,23,22,22,22,
+22,22,22,22,22,21,21,21,21,21,21,20,20,20,20,20,20,20,19,19,19,19,19,19,18,18,18,18,18,18,
+18,17,17,17,17,17,17,16,16,16,16,16,15,15,15,15,15,15,14,14,14,14,14,14,13,13,13,13,13,12,
+12,12,12,12,12,11,11,11,11,11,10,10,10,10,10,10,9,9,9,9,9,8,8,8,8,8,7,7,7,7,7,6,6,6,6,6,5,5,5,5,
+5,5,4,4,4,4,4,3,3,3,3,3,2,2,2,2,2,1,1};
+#endif
 
 extern ubyte *gr_bitblt_fade_table;
 
@@ -206,36 +104,42 @@
 grs_font * title_font;
 grs_font * names_font;
 
-void credits_show()
+typedef struct box {
+	int left, top, width, height;
+} box;
+
+//if filename passed is NULL, show normal credits
+void credits_show(char *credits_filename)
 {
-	int i, j, l, done;
 	CFILE * file;
-	char (*buffer)[80];
-	grs_bitmap backdrop;
-	grs_canvas menucanv;
-	ubyte backdrop_palette[768];
+	int i, j, l, done;
 	int pcx_error;
 	int buffer_line = 0;
-	fix last_time;
-	fix time_delay = 4180*200/SHEIGHT;			// ~ F1_0 / 12.9
-	int first_line_offset,extra_inc=0;
+	int first_line_offset;
+	int extra_inc=0;
 	int have_bin_file = 0;
-	ubyte *fade_values_scalled;
-	int num_lines;
 	char * tempp;
-	int ROW_SPACING;
+	char filename[32];
+	char buffer[NUM_LINES][80];
+	ubyte backdrop_palette[768];
+	ubyte *fade_values_scalled;
+	fix last_time;
+	fix time_delay = 2800;
+	grs_canvas *CreditsOffscreenBuf=NULL;
+	grs_bitmap backdrop;
+	box dirty_box[NUM_LINES];
 
-	gr_use_palette_table( "credits.256" );
-	//we need to reload the fonts, because we are using a different palette.  But we also want to load the correct sized font.  Thus, the gamefont_curfontname() calls.  -MPM
-	header_font = gr_init_font( gamefont_curfontname(0));// "font1-1.fnt" );
-	title_font = gr_init_font( gamefont_curfontname(3));//"font2-3.fnt" );
-	names_font = gr_init_font( gamefont_curfontname(2));//"font2-2.fnt" );
-	ROW_SPACING=names_font->ft_h+1;
+	// Clear out all tex buffer lines.
+	for (i=0; i<NUM_LINES; i++ )
+	{
+		buffer[i][0] = 0;
+		dirty_box[i].left = dirty_box[i].top = dirty_box[i].width = dirty_box[i].height = 0;
+	}
 	
-	l = SHEIGHT;
-	set_screen_mode(SCREEN_MENU);
-	num_lines = l/ROW_SPACING + 1;
+	fade_values_scalled = malloc(SHEIGHT);
+	scale_line(fade_values_hires, fade_values_scalled, 480, GHEIGHT);
 
+	sprintf(filename, "%s", CREDITS_FILE);
 	have_bin_file = 0;
 	file = cfopen( "credits.tex", "rb" );
 	if (file == NULL) {
@@ -245,52 +149,54 @@
 		have_bin_file = 1;
 	}
 
-	gr_init_bitmap_data (&backdrop);
-	pcx_error = pcx_read_bitmap("stars.pcx",&backdrop,BM_LINEAR,//grd_curcanv->cv_bitmap.bm_type,
-			backdrop_palette);
+	set_screen_mode(SCREEN_MENU);
+
+	gr_use_palette_table( "credits.256" );
+#ifdef OGL
+	gr_palette_load(gr_palette);
+#endif
+	header_font = gr_init_font( gamefont_curfontname(0));
+	title_font = gr_init_font( gamefont_curfontname(3));
+	names_font = gr_init_font( gamefont_curfontname(2));
+	backdrop.bm_data=NULL;
+
+//MWA  Made backdrop bitmap linear since it should always be.  the current canvas may not
+//MWA  be linear, so we can't rely on grd_curcanv->cv_bitmap->bm_type.
+
+	pcx_error = pcx_read_bitmap(CREDITS_BACKGROUND_FILENAME,&backdrop, BM_LINEAR,backdrop_palette);
 	if (pcx_error != PCX_ERROR_NONE) {
 		cfclose(file);
 		return;
 	}
 
-	fade_values_scalled = malloc(l);
-	scale_line(fade_values, fade_values_scalled, 200, l);//hey, why not?  Its just a one dimensional bitmap :) -MPM
-//	memset(fade_values_scalled, 31, l);
-//	memcpy(fade_values_scalled, fade_values, 100);
-//	memcpy(fade_values_scalled+l-100, fade_values+100, 100);
-	
-	buffer = malloc(num_lines*80);
-	// Clear out all tex buffer lines.
-	for (i=0; i<num_lines; i++ ) buffer[i][0] = 0;
-
-	songs_play_song( SONG_CREDITS, 0 );
+	songs_play_song( SONG_CREDITS, 1 );
 
 	gr_remap_bitmap_good( &backdrop,backdrop_palette, -1, -1 );
 
-	gr_init_sub_canvas(&menucanv, VR_offscreen_menu, 0, 0, SWIDTH, SHEIGHT);//if the game res higher than the menu res, VR_offscreen_menu is too big. -MPM
-	
 	gr_set_current_canvas(NULL);
 	show_fullscr(&backdrop);
-
         gr_update();
-
         gr_palette_fade_in( gr_palette, 32, 0 );
 
-//        vfx_set_palette_sub( gr_palette );
+	CreditsOffscreenBuf = gr_create_canvas(GWIDTH,GHEIGHT);
+
+	if (!CreditsOffscreenBuf)
+		Error("Not enough memory to allocate Credits Buffer.");
 
-	//gr_clear_canvas(BM_XRGB(0,0,0));
 	key_flush();
+
 	last_time = timer_get_fixed_seconds();
 	done = 0;
+#ifdef OGL
+	first_line_offset = GHEIGHT/8; // ZICO - keep the lines in canvas
+#else
 	first_line_offset = 0;
+#endif
 	while( 1 )	{
 		int k;
 
 		do {
-
-
-
-			buffer_line = (buffer_line+1) % num_lines;
+			buffer_line = (buffer_line+1) % NUM_LINES;
 			if (cfgets( buffer[buffer_line], 80, file ))	{
 				char *p;
 				if (have_bin_file) {				// is this a binary tbl file
@@ -303,25 +209,24 @@
 				p = strchr(&buffer[buffer_line][0],'\n');
 				if (p) *p = '\0';
 			} else	{
-				//fseek( file, 0, SEEK_SET);
 				buffer[buffer_line][0] = 0;
 				done++;
 			}
 		} while (extra_inc--);
 		extra_inc = 0;
 
-		for (i=0; i<ROW_SPACING; i++ )	{
+		for (i=0; i<ROW_SPACING; i += (SWIDTH>=640?2:1) )	{
 			int y;
 
 			y = first_line_offset - i;
 
-			//gr_set_current_canvas(VR_offscreen_menu);
-			gr_set_current_canvas(&menucanv);
+			gr_set_current_canvas(CreditsOffscreenBuf);
 			show_fullscr(&backdrop);
-			for (j=0; j<num_lines; j++ )	{
+
+			for (j=0; j<NUM_LINES; j++ )	{
 				char *s;
 
-				l = (buffer_line + j + 1 ) % num_lines;
+				l = (buffer_line + j + 1 ) %  NUM_LINES;
 				s = buffer[l];
 
 				if ( s[0] == '!' ) {
@@ -338,30 +243,64 @@
 				gr_bitblt_fade_table = fade_values_scalled;
 
 				tempp = strchr( s, '\t' );
-				if ( tempp )	{
+				if ( !tempp )	{
+				// Wacky Fast Credits thing
 					int w, h, aw;
-					*tempp = 0;
-					gr_get_string_size( s, &w, &h, &aw );
-					gr_printf( (160-w)/2, y, s );
-					gr_get_string_size( &tempp[1], &w, &h, &aw );
-                                        gr_printf( 160+((160-w)/2), y, &tempp[1] );
-					*tempp = '\t';
-				} else {
+
+					gr_get_string_size( s, &w, &h, &aw);
+					dirty_box[j].width = w;
+        				dirty_box[j].height = h;
+        				dirty_box[j].top = y;
+        				dirty_box[j].left = (GWIDTH - w) / 2;
+
 					gr_printf( 0x8000, y, s );
 				}
 				gr_bitblt_fade_table = NULL;
-				if (buffer[l][0] == '!')
-					y += ROW_SPACING/2;
-				else
 					y += ROW_SPACING;
 			}
-			gr_bm_ubitblt(
-				GWIDTH, GHEIGHT,
-				0, 0, 0, 0,
-				&VR_offscreen_menu->cv_bitmap,
-				&grd_curscreen->sc_canvas.cv_bitmap
-			);
 
+				// Wacky Fast Credits Thing
+				box	*new_box;
+				grs_bitmap *tempbmp;
+
+				for (j=0; j<NUM_LINES; j++ )
+				{
+#ifdef OGL
+					glScissor (0,GHEIGHT/6,GWIDTH,GHEIGHT-(GHEIGHT/3)); // ZICO - create borders for new line endings
+					glEnable (0x0C11);
+#endif
+					new_box = &dirty_box[j];
+
+					tempbmp = &(CreditsOffscreenBuf->cv_bitmap);
+
+					gr_bm_bitblt(	new_box->width+1,
+							new_box->height+4,
+							new_box->left,
+							new_box->top,
+							new_box->left,
+							new_box->top,
+							tempbmp,
+							&(grd_curscreen->sc_canvas.cv_bitmap) );
+				}
+
+#ifndef OGL
+				for (j=0; j<NUM_LINES; j++ )
+				{
+					new_box = &dirty_box[j];
+
+					tempbmp = &(CreditsOffscreenBuf->cv_bitmap);
+
+					gr_bm_bitblt(   new_box->width,
+							new_box->height+2,
+							new_box->left,
+							new_box->top,
+							new_box->left,
+							new_box->top,
+							&backdrop,
+							tempbmp );
+				}
+				
+#endif
                         gr_update();
 
 			while( timer_get_fixed_seconds() < last_time+time_delay );
@@ -367,53 +306,37 @@
 			while( timer_get_fixed_seconds() < last_time+time_delay );
 			last_time = timer_get_fixed_seconds();
 		
-
 			k = key_inkey();
 
-			#ifndef NDEBUG
+#ifndef NDEBUG
 			if (k == KEY_BACKSP) {
 				Int3();
 				k=0;
 			}
-			#endif
-
-//			{
-//				fix ot = time_delay;
-//				time_delay += (keyd_pressed[KEY_X] - keyd_pressed[KEY_Z])*100;
-//				if (ot!=time_delay)	{
-//					mprintf( (0, "[%x] ", time_delay ));
-//				}
-//			}
+#endif
 
 			if (k == KEY_PRINT_SCREEN) {
 				save_screen_shot(0);
 				k = 0;
 			}
 
-			if ((k>0)||(done>num_lines))	{
+			if ((k>0)||(done>NUM_LINES))	{
 					gr_close_font(header_font);
 					gr_close_font(title_font);
 					gr_close_font(names_font);
 					gr_palette_fade_out( gr_palette, 32, 0 );
 					gr_use_palette_table( "palette.256" );
-					gr_free_bitmap_data (&backdrop);
+					free(backdrop.bm_data);
 					cfclose(file);
 					songs_play_song( SONG_TITLE, 1 );
-					free(fade_values_scalled);
-					free(buffer);
+					if (CreditsOffscreenBuf != VR_offscreen_buffer)
+						gr_free_canvas(CreditsOffscreenBuf);
+					gr_palette_load( gr_palette );
+#ifdef OGL
+					glDisable(0x0C11);
+#endif
 					return;
 			}
 		}
-
-		if (buffer[(buffer_line + 1 ) % num_lines][0] == '!') {
-			first_line_offset -= ROW_SPACING-ROW_SPACING/2;
-			if (first_line_offset <= -ROW_SPACING) {
-				first_line_offset += ROW_SPACING;
-				extra_inc++;
-			}
-		}
 	}
-
 }
-
-
diff -urbB d1x/main/game.c ../d1x-rebirth_v0.42-src-20060416/main/game.c
--- d1x/main/game.c	2006-08-19 11:33:19.000000000 +0200
+++ ../d1x-rebirth_v0.42-src-20060416/main/game.c	2006-03-27 20:36:31.000000000 +0200
@@ -535,9 +171,7 @@
 int time_stopped,time_started;
 #endif
 
-ubyte * Game_cockpit_copy_code = NULL;
-
-ubyte new_cheats[]= {KEY_B^0xaa, KEY_B^0xaa, KEY_B^0xaa, KEY_F^0xaa, KEY_A^0xaa,
+ubyte new_cheats[]= {	KEY_B^0xaa, KEY_B^0xaa, KEY_B^0xaa, KEY_F^0xaa, KEY_A^0xaa,
 							KEY_U^0xaa, KEY_I^0xaa, KEY_R^0xaa, KEY_L^0xaa, KEY_H^0xaa,
 							KEY_G^0xaa, KEY_G^0xaa, KEY_U^0xaa, KEY_A^0xaa, KEY_I^0xaa,
 							KEY_G^0xaa, KEY_R^0xaa, KEY_I^0xaa, KEY_S^0xaa, KEY_M^0xaa,
@@ -618,6 +251,7 @@
 grs_bitmap background_bitmap;
 
 int Game_aborted;
+void	update_cockpits(int force_redraw);
 
 extern void newdemo_strip_frames(char *, int);
 
@@ -728,18 +360,18 @@
 #define cv_w  cv_bitmap.bm_w
 #define cv_h  cv_bitmap.bm_h
 
-//killed 7/5/99 - Owen Evans for letterbox in high rez
-//#define LETTERBOX_HEIGHT 140
-//end killed - OE
-
 //added 3/24/99 by Owen Evans for screen res changing
 u_int32_t Game_screen_mode = 0;
 //end added - OE
+int Game_window_x = 0;
+int Game_window_y = 0;
 int Game_window_w = 0;
 int Game_window_h = 0;
+int max_window_w = 0;
 int max_window_h = 0;
 
 int last_drawn_cockpit[2] = { -1, -1 };
+extern void ogl_loadbmtexture(grs_bitmap *bm);
 
 extern int Rear_view;
 
@@ -761,14 +393,23 @@
 	case CM_REAR_VIEW:
 		gr_set_current_canvas(&VR_screen_pages[VR_current_page]);
 		PIGGY_PAGE_IN(cockpit_bitmap[Cockpit_mode]);
+#ifdef OGL // ZICO - scalable
+		ogl_ubitmapm_cs (0, 0, -1, grd_curcanv->cv_bitmap.bm_h, &GameBitmaps[cockpit_bitmap[Cockpit_mode].index],255, F1_0, 0);
+#else
 		gr_ubitmapm(0,0, &GameBitmaps[cockpit_bitmap[Cockpit_mode].index]);
+#endif
 		break;
 	case CM_FULL_SCREEN:
 		break;
 	case CM_STATUS_BAR:
 		gr_set_current_canvas(&VR_screen_pages[VR_current_page]);
 		PIGGY_PAGE_IN(cockpit_bitmap[Cockpit_mode]);
+#ifdef OGL // ZICO - scalable
+		ogl_ubitmapm_cs (0, grd_curscreen->sc_h-grd_curcanv->cv_bitmap.bm_h/4-(grd_curscreen->sc_h/65), -1, grd_curcanv->cv_bitmap.bm_h/4+(grd_curscreen->sc_h/65), &GameBitmaps[cockpit_bitmap[Cockpit_mode].index],255, F1_0, 0);
+		// ZICO - cleanup ... find an easier way
+#else
 		gr_ubitmapm(0,max_window_h,&GameBitmaps[cockpit_bitmap[Cockpit_mode].index]);
+#endif
 		w = Game_window_w;
 		h = Game_window_h;
 		x = (VR_render_width - w)/2;
@@ -777,7 +418,6 @@
 		break;
 	case CM_LETTERBOX:
 		gr_set_current_canvas(&VR_screen_pages[VR_current_page]);
-		gr_clear_canvas( BM_XRGB(0,0,0) );
 		break;
 	}
 
@@ -792,7 +432,7 @@
 //called every time the screen mode or cockpit changes
 void init_cockpit()
 {
-	int minx, maxx, miny, maxy, x, y;
+	int x, y;
 
 	//Initialize the on-screen canvases
 
@@ -802,20 +442,13 @@
 	if ( VR_render_mode != VR_NONE )
 		Cockpit_mode = CM_FULL_SCREEN;
 
+#ifndef OGL
 //changed 7/5/99 - Owen Evans for letterbox in hi res
         if ( VR_screen_mode != SM(320,200) && Cockpit_mode != CM_LETTERBOX)    {               // This really should be 'if VR_screen_mode isn't linear'
 //end changed - OE
-                // We can only use cockpit or rearview mode in mode 13h
-                //if ( (Cockpit_mode==CM_FULL_COCKPIT) || (Cockpit_mode==CM_REAR_VIEW) )        {
-                //      if (Game_window_h > max_window_h)                       //too big for scalable
-                //              Cockpit_mode = CM_FULL_SCREEN;
-                //      else
-                //              Cockpit_mode = CM_STATUS_BAR;
-                //}
-                //if ( (grd_curscreen->sc_w > 320) || (VR_use_paging) )
-                //              Cockpit_mode = CM_FULL_SCREEN;
                 Cockpit_mode = CM_FULL_SCREEN;
         }
+#endif
 
 	if ( Screen_mode == SCREEN_EDITOR )
 		Cockpit_mode = CM_FULL_SCREEN;
@@ -826,37 +459,16 @@
 
 	gr_set_curfont( GAME_FONT );
 
-#ifdef PCCODE
-	if (Game_cockpit_copy_code)
-		free(Game_cockpit_copy_code);
-#endif
-	Game_cockpit_copy_code  = NULL;
-
 	switch( Cockpit_mode )	{
 	case CM_FULL_COCKPIT:
 	case CM_REAR_VIEW:		{
-		grs_bitmap *bm = &GameBitmaps[cockpit_bitmap[Cockpit_mode].index];
-
-		PIGGY_PAGE_IN(cockpit_bitmap[Cockpit_mode]);
-		gr_set_current_canvas(VR_offscreen_buffer);
-		gr_bitmap( 0, 0, bm );
-		bm = &VR_offscreen_buffer->cv_bitmap;
-		gr_set_transparent (bm, 1);
-#ifdef PCCODE
-		gr_ibitblt_find_hole_size ( bm, &minx, &miny, &maxx, &maxy );
-		Game_cockpit_copy_code	= gr_ibitblt_create_mask( bm, minx, miny, maxx-minx+1, maxy-miny+1, VR_offscreen_buffer->cv_bitmap.bm_rowsize );
-#else
-		gr_ibitblt_find_hole_size ( bm, &minx, &miny, &maxx, &maxy );
-		gr_ibitblt_create_mask( bm, minx, miny, maxx-minx+1, maxy-miny+1, VR_offscreen_buffer->cv_bitmap.bm_rowsize );
-		Game_cockpit_copy_code = (ubyte *)-1;
-#endif
-		gr_set_bitmap_flags (bm, 0);
-		game_init_render_sub_buffers( 0, 0, maxx-minx+1, maxy-miny+1 );
+		if (Cockpit_mode == CM_FULL_COCKPIT)
+			game_init_render_sub_buffers(0, 0, grd_curscreen->sc_w, (grd_curscreen->sc_h*2)/3);
+		else if (Cockpit_mode == CM_REAR_VIEW)
+			game_init_render_sub_buffers((16*grd_curscreen->sc_w)/640, (89*grd_curscreen->sc_h)/480, (604*grd_curscreen->sc_w)/640, (209*grd_curscreen->sc_h)/480);
 		break;
 		}
 	case CM_FULL_SCREEN:
-//		game_init_render_sub_buffers( 0, 0, VR_render_width, VR_render_height );
-	  
         	x = (VR_render_width - Game_window_w) / 2;
                 y = (VR_render_height - Game_window_h) / 2;
 
@@ -866,6 +478,9 @@
 		break;
 
 	case CM_STATUS_BAR:	{
+#ifdef OGL // ZICO - scalable
+		game_init_render_sub_buffers(0, 0, grd_curscreen->sc_w, (grd_curscreen->sc_h*2)/2.7);
+#else
 		int x,y;
 
 		if (Game_window_h > max_window_h) {
@@ -877,6 +492,7 @@
 		y = (max_window_h - Game_window_h)/2;
 
 		game_init_render_sub_buffers( x, y, Game_window_w, Game_window_h );
+#endif
 		break;
 		}
 	case CM_LETTERBOX:	{
@@ -884,7 +500,6 @@
 
 		x = 0; w = VR_render_width;
 //changed 7/5/99 for letterbox in hi res - Owen Evans
-//KILLED	h = LETTERBOX_HEIGHT;
 		h = (VR_render_height * 3) / 4; // true letterbox size (16:9)
 //end changed - OE
 		y = (VR_render_height-h)/2;
@@ -947,29 +562,27 @@
 	HUD_clear_messages();
 }
 
-#define WINDOW_W_DELTA 24	//20
-#define WINDOW_H_DELTA 12	//10
-
-#define WINDOW_MIN_W		160
+#define WINDOW_W_DELTA	((max_window_w / 16)&~1)
+#define WINDOW_H_DELTA	((max_window_h / 16)&~1)
+#define WINDOW_MIN_W	((max_window_w * 10) / 22)
 
 void grow_window()
 {
-	if ((Cockpit_mode == CM_FULL_COCKPIT) && (grd_curscreen->sc_mode == SM(320,200))) {
+	if ((Cockpit_mode == CM_FULL_COCKPIT)) {
 		Game_window_h = max_window_h;
 		Game_window_w = VR_render_width;
 		toggle_cockpit();
-		grow_window();
 		hud_message(MSGC_GAME_FEEDBACK, "Press F3 to return to Cockpit mode");
 		return;
 	}
 
-	if ((Cockpit_mode != CM_STATUS_BAR) && (grd_curscreen->sc_mode == SM(320,200)))
+	if ((Cockpit_mode != CM_STATUS_BAR))
 		return;
 
 	if (Cockpit_mode == CM_FULL_SCREEN)
 		max_window_h = VR_render_height; 
 
-	if ((Game_window_h >= max_window_h) && (grd_curscreen->sc_mode == SM(320,200))) {
+	if ((Game_window_h >= max_window_h)) {
 		Game_window_w = VR_render_width;
 		Game_window_h = VR_render_height;
 		select_cockpit(CM_FULL_SCREEN);
@@ -1028,12 +641,10 @@
 		ofs_x = left % bm->bm_w;
 		dest_x = left;
 
-		//h = (bot < dest_y+bm->bm_h)?(bot-dest_y+1):(bm->bm_h-ofs_y);
 		h = min(bot-dest_y+1,bm->bm_h-ofs_y);
 
 		for (x=tile_left;x<=tile_right;x++) {
 
-			//w = (right < dest_x+bm->bm_w)?(right-dest_x+1):(bm->bm_w-ofs_x);
 			w = min(right-dest_x+1,bm->bm_w-ofs_x);
 
 			gr_bm_ubitblt(w,h,dest_x,dest_y,ofs_x,ofs_y,
@@ -1065,24 +676,19 @@
 		Game_window_h = max_window_h;
 		Game_window_w = VR_render_width;
 		toggle_cockpit();
-//		shrink_window();
-//		shrink_window();
-		hud_message(MSGC_GAME_FEEDBACK, "Press F3 to return to Cockpit mode");
+		HUD_init_message("Press F3 to return to Cockpit mode");
 		return;
 	}
 
-	if ((Cockpit_mode == CM_FULL_SCREEN) && (grd_curscreen->sc_mode == SM(320,200)))	{
+	if (Cockpit_mode == CM_FULL_SCREEN )	{
 		Game_window_h = max_window_h;
 		select_cockpit(CM_STATUS_BAR);
 		return;
 	}
 
-	if ((Cockpit_mode != CM_STATUS_BAR) && (grd_curscreen->sc_mode == SM(320,200)))
+	if (Cockpit_mode != CM_STATUS_BAR)
 		return;
 	
-	if (Cockpit_mode == CM_FULL_SCREEN)
-		max_window_h = VR_render_height;
-
 	if (Game_window_w > WINDOW_MIN_W) {
 		int window_w_delta, window_h_delta;
 		int window_min_w, window_min_h;	
@@ -1094,7 +700,7 @@
 
 		old_window_w = Game_window_w;
 		old_window_h = Game_window_h;
-		if ((Cockpit_mode == CM_FULL_SCREEN) && (old_window_h==max_window_h)){
+		if ((Cockpit_mode == CM_FULL_SCREEN)){
 			//320x200 mode gets the status bar, giving them a wider viewing angle, thus a (slight) advantage.
 			//this merely adds the same ability (viewing angle, not status bar) to other resolutions.  -MM
 			window_w_delta = 0; //must be even
@@ -1115,7 +721,7 @@
 		x = (VR_render_width - Game_window_w)/2;
 		y = (max_window_h - Game_window_h)/2;
 
-		fill_background(x,y,Game_window_w,Game_window_h,window_w_delta/2,window_h_delta/2);
+		fill_background(x,y,Game_window_w,Game_window_h,WINDOW_W_DELTA/2,WINDOW_H_DELTA/2);
 
 		game_init_render_sub_buffers( x, y, Game_window_w, Game_window_h );
 	}
@@ -1218,7 +825,6 @@
 
         if ( (Screen_mode == sm) && !((sm==SCREEN_GAME) && (grd_curscreen->sc_mode != Game_screen_mode) && (Screen_mode == SCREEN_GAME))) {
 		gr_set_current_canvas( &VR_screen_pages[VR_current_page] );
-//		if ( VR_use_paging )	gr_show_canvas( &VR_screen_pages[VR_current_page] );
 #ifdef OGL
 		ogl_set_screen_mode();
 #endif
@@ -1256,16 +866,25 @@
 //End section
 
 		if ( VR_render_mode == VR_NONE ) {
-			if ( max_window_h == 0 && grd_curscreen->sc_mode == SM(320,200))	{
+#ifdef OGL // ZICO - scale the screen correctly for scalable statusbar
+			if ( max_window_h == 0 && grd_curscreen->sc_mode == SM(grd_curscreen->sc_w, grd_curscreen->sc_h))	{
+				max_window_h = (grd_curscreen->sc_h*2)/2.7;
+				Game_window_h = grd_curscreen->sc_h;
+			} else if (grd_curscreen->sc_mode == SM(grd_curscreen->sc_w, grd_curscreen->sc_h)) {
+				max_window_h = (grd_curscreen->sc_h*2)/2.7;
+			} else {
+				max_window_h = grd_curscreen->sc_h;
+			}
+#else
+			if ( max_window_h == 0 && grd_curscreen->sc_mode == SM(320, 200))	{
 				max_window_h = grd_curscreen->sc_h - GameBitmaps[cockpit_bitmap[CM_STATUS_BAR].index].bm_h;
 				Game_window_h = max_window_h;
 			} else if (grd_curscreen->sc_mode == SM(320,200)) {
 				max_window_h = grd_curscreen->sc_h - GameBitmaps[cockpit_bitmap[CM_STATUS_BAR].index].bm_h;
 			} else {
 				max_window_h = grd_curscreen->sc_h;
-//				Game_window_h = max_window_h;
 			}
-				
+#endif	
 		} else {
 			Cockpit_mode = CM_FULL_SCREEN;
 		}
@@ -1814,7 +1420,7 @@
 			h += 7;
 
 		if (Cockpit_mode != CM_REAR_VIEW)
-                        gr_printf((grd_curcanv->cv_bitmap.bm_w-w)/2, grd_curcanv->cv_bitmap.bm_h - h - 2, message );
+                        gr_printf((grd_curcanv->cv_bitmap.bm_w-w)/2, grd_curcanv->cv_bitmap.bm_h - ((double)grd_curscreen->sc_h/200)*h - 2, message ); // ZICO - added multiplicator for h for scalable cockpits
 	}
 
 //added 9/15/98 by Victor Rachels for weapon autoselect toggle notification
@@ -1926,7 +1510,7 @@
 	game_draw_hud_stuff();
 
 	if ( Game_double_buffer ) {		//copy to visible screen
-		if ( Game_cockpit_copy_code==NULL )	{
+		//if ( Game_cockpit_copy_code==NULL )	{
 #ifdef D1XD3D
 			Win32_flip_screens ();
 			VR_current_page = !VR_current_page;
@@ -1947,14 +1531,12 @@
 			}
 #endif
 		} else	{
-#ifdef PCCODE
-			gr_ibitblt( &VR_render_buffer[0].cv_bitmap, &VR_screen_pages[0].cv_bitmap, Game_cockpit_copy_code );
-#else
-			gr_ibitblt( &VR_render_buffer[0].cv_bitmap, &VR_screen_pages[0].cv_bitmap, 0 );
-#endif
-		}
+
+		
 	}
 
+	update_cockpits(1); // ZICO - should normally be 0
+
 	if (Cockpit_mode==CM_FULL_COCKPIT || Cockpit_mode==CM_STATUS_BAR) {
 
 #ifndef SHAREWARE
@@ -1984,7 +1566,7 @@
 {
 	set_screen_mode( SCREEN_GAME );
 
-	update_cockpits(0);
+//	update_cockpits(0);
 
 	play_homing_warning();
 
@@ -2744,7 +2251,9 @@
 {
 	//@@int demo_playing=0;
 	//@@int multi_game=0;
-
+#ifdef __LINUX__
+	fix t1;
+#endif
 	do_lunacy_on();		//	Copy values for insane into copy buffer in ai.c
 	do_lunacy_off();		//	Restore true insane mode.
 
@@ -2997,12 +2505,6 @@
 
 	restore_effect_bitmap_icons();
 
-	if (Game_cockpit_copy_code)	{
-#ifdef PCCODE
-		free(Game_cockpit_copy_code);
-#endif
-		Game_cockpit_copy_code = NULL;
-	}
 
 	gr_free_bitmap_data (&background_bitmap);
 
diff -urbB d1x/main/gauges.c ../d1x-rebirth_v0.42-src-20060416/main/gauges.c
--- d1x/main/gauges.c	2000-01-21 01:43:35.000000000 +0100
+++ ../d1x-rebirth_v0.42-src-20060416/main/gauges.c	2006-03-26 12:51:56.000000000 +0200
@@ -397,7 +404,7 @@
 
 #define SB_ENERGY_GAUGE_X 		98
 #define SB_ENERGY_GAUGE_Y 		155
-#define SB_ENERGY_GAUGE_W 		16
+#define SB_ENERGY_GAUGE_W 		17 // ZICO - 17 fits better in energy window - old: 16
 #define SB_ENERGY_GAUGE_H 		41
 
 #define SB_ENERGY_NUM_X 		(SB_ENERGY_GAUGE_X+2)
@@ -427,22 +434,22 @@
 
 #define PRIMARY_W_PIC_X			64
 #define PRIMARY_W_PIC_Y			154
-#define PRIMARY_W_TEXT_X		87
-#define PRIMARY_W_TEXT_Y		157
-#define PRIMARY_AMMO_X			(96-3)
-#define PRIMARY_AMMO_Y			171
+#define PRIMARY_W_TEXT_X		FPOS_SCALEX*87
+#define PRIMARY_W_TEXT_Y		FPOS_SCALEY*157
+#define PRIMARY_AMMO_X			FPOS_SCALEX*(96-3)
+#define PRIMARY_AMMO_Y			FPOS_SCALEY*171
 
 #define SECONDARY_W_PIC_X		234
 #define SECONDARY_W_PIC_Y		154
-#define SECONDARY_W_TEXT_X		207
-#define SECONDARY_W_TEXT_Y		157
-#define SECONDARY_AMMO_X		213
-#define SECONDARY_AMMO_Y		171
+#define SECONDARY_W_TEXT_X		FPOS_SCALEX*207
+#define SECONDARY_W_TEXT_Y		FPOS_SCALEY*157
+#define SECONDARY_AMMO_X		FPOS_SCALEX*213
+#define SECONDARY_AMMO_Y		FPOS_SCALEY*171
 
 #define SB_LIVES_X                      266
 #define SB_LIVES_Y                      185
 #define SB_LIVES_LABEL_X		237
-#define SB_LIVES_LABEL_Y		(SB_LIVES_Y+1)
+#define SB_LIVES_LABEL_Y		(SB_LIVES_Y) // ZICO - removed +1
 
 #define SB_SCORE_RIGHT			301
 #define SB_SCORE_Y                      158
@@ -477,6 +484,37 @@
 
 #define FADE_SCALE	(2*i2f(GR_FADE_LEVELS)/REARM_TIME)		// fade out and back in REARM_TIME, in fade levels per seconds (int)
 
+// ZICO - needed for scaling gauges
+#ifdef OGL
+#define FPOS_SCALEX ((double)grd_curscreen->sc_w/320)
+#define FPOS_SCALEY ((double)grd_curscreen->sc_h/200)
+#define HUD_SCALE(v,s)	((int) ((double) (v) * (s) + 0.5))
+#define HUD_SCALE_X(v)	HUD_SCALE(v,FPOS_SCALEX)
+#define HUD_SCALE_Y(v)	HUD_SCALE(v,FPOS_SCALEY)
+#else
+#define FPOS_SCALEX 1
+#define FPOS_SCALEY 1
+#endif
+
+inline void hud_bitblt (int x, int y, grs_bitmap *bm, int scale, int orient)
+{
+#ifdef OGL
+ogl_ubitmapm_cs (
+	(x < 0) ? -x : HUD_SCALE_X (x), 
+	(y < 0) ? -y : HUD_SCALE_Y (y), 
+	HUD_SCALE_X (bm->bm_w), 
+	HUD_SCALE_Y (bm->bm_h), 
+	bm, 
+	-1,
+	scale,
+	orient
+	);
+#else
+gr_ubitmapm(x, y, bm);
+#endif
+}
+// ZICO - end of addition
+
 typedef struct span {
 	byte l,r;
 } span;
@@ -576,6 +614,18 @@
 #define N_LEFT_WINDOW_SPANS  (sizeof(weapon_window_left)/sizeof(*weapon_window_left))
 #define N_RIGHT_WINDOW_SPANS (sizeof(weapon_window_right)/sizeof(*weapon_window_right))
 
+#ifdef OGL
+// ZICO - as long as we don't use fading we don't need these boxes - makes a better view in cockpit, however :)
+#define PRIMARY_W_BOX_LEFT	0	//63
+#define PRIMARY_W_BOX_TOP	0	//154
+#define PRIMARY_W_BOX_RIGHT	0	//(PRIMARY_W_BOX_LEFT+58)
+#define PRIMARY_W_BOX_BOT	0	//(PRIMARY_W_BOX_TOP+N_LEFT_WINDOW_SPANS-1)
+											
+#define SECONDARY_W_BOX_LEFT	0	//202	//207
+#define SECONDARY_W_BOX_TOP	0	//151
+#define SECONDARY_W_BOX_RIGHT	0	//263	//(SECONDARY_W_BOX_LEFT+54)
+#define SECONDARY_W_BOX_BOT	0	//(SECONDARY_W_BOX_TOP+N_RIGHT_WINDOW_SPANS-1)
+#else
 #define PRIMARY_W_BOX_LEFT		63
 #define PRIMARY_W_BOX_TOP		154
 #define PRIMARY_W_BOX_RIGHT	(PRIMARY_W_BOX_LEFT+58)
@@ -585,6 +635,7 @@
 #define SECONDARY_W_BOX_TOP	151
 #define SECONDARY_W_BOX_RIGHT	263	//(SECONDARY_W_BOX_LEFT+54)
 #define SECONDARY_W_BOX_BOT	(SECONDARY_W_BOX_TOP+N_RIGHT_WINDOW_SPANS-1)
+#endif
 
 #define SB_PRIMARY_W_BOX_LEFT		34		//50
 #define SB_PRIMARY_W_BOX_TOP		153
@@ -598,17 +649,17 @@
 
 #define SB_PRIMARY_W_PIC_X			(SB_PRIMARY_W_BOX_LEFT+1)	//51
 #define SB_PRIMARY_W_PIC_Y			154
-#define SB_PRIMARY_W_TEXT_X		(SB_PRIMARY_W_BOX_LEFT+24)	//(51+23)
-#define SB_PRIMARY_W_TEXT_Y		157
-#define SB_PRIMARY_AMMO_X			((SB_PRIMARY_W_BOX_LEFT+33)-3)	//(51+32)
-#define SB_PRIMARY_AMMO_Y			171
+#define SB_PRIMARY_W_TEXT_X		FPOS_SCALEX*(SB_PRIMARY_W_BOX_LEFT+24)	//(51+23)
+#define SB_PRIMARY_W_TEXT_Y		FPOS_SCALEY*157
+#define SB_PRIMARY_AMMO_X		FPOS_SCALEX*((SB_PRIMARY_W_BOX_LEFT+33)-3)	//(51+32)
+#define SB_PRIMARY_AMMO_Y		FPOS_SCALEY*171
 
 #define SB_SECONDARY_W_PIC_X		(SB_SECONDARY_W_BOX_LEFT+29)	//(212+27)
 #define SB_SECONDARY_W_PIC_Y		154
-#define SB_SECONDARY_W_TEXT_X		(SB_SECONDARY_W_BOX_LEFT+2)	//212
-#define SB_SECONDARY_W_TEXT_Y		157
-#define SB_SECONDARY_AMMO_X		(SB_SECONDARY_W_BOX_LEFT+11)	//(212+9)
-#define SB_SECONDARY_AMMO_Y		171
+#define SB_SECONDARY_W_TEXT_X		FPOS_SCALEX*(SB_SECONDARY_W_BOX_LEFT+2)	//212
+#define SB_SECONDARY_W_TEXT_Y		FPOS_SCALEY*157
+#define SB_SECONDARY_AMMO_X		FPOS_SCALEX*(SB_SECONDARY_W_BOX_LEFT+11)	//(212+9)
+#define SB_SECONDARY_AMMO_Y		FPOS_SCALEY*171
 
 typedef struct gauge_box {
 	int left,top;
@@ -683,7 +734,7 @@
 	char	score_str[20];
 	int	w, h, aw;
 
-	if ((HUD_nmessages > 0) && (strlen(HUD_messages[hud_first]) > 38))
+	if ((HUD_nmessages > 0) && (strlen(HUD_messages[hud_first]) > 50)) // ZICO - hud msg can be longer than 38
 		return;
 
 	gr_set_curfont( GAME_FONT );
@@ -756,9 +807,9 @@
 		gr_set_fontcolor(gr_getcolor(0,20,0),-1 );
 
 		if ( (Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) ) 
-			gr_printf(SB_SCORE_LABEL_X,SB_SCORE_Y,"%s:", TXT_KILLS);
+			gr_printf(FPOS_SCALEX*SB_SCORE_LABEL_X,FPOS_SCALEY*SB_SCORE_Y,"%s:", TXT_KILLS);
 		else
-			gr_printf(SB_SCORE_LABEL_X,SB_SCORE_Y,"%s:", TXT_SCORE);
+			gr_printf(FPOS_SCALEX*SB_SCORE_LABEL_X,FPOS_SCALEY*SB_SCORE_Y,"%s:", TXT_SCORE);
 	}
 
 	gr_set_curfont( GAME_FONT );
@@ -768,12 +819,12 @@
 		sprintf(score_str, "%5d", Players[Player_num].score);
 	gr_get_string_size(score_str, &w, &h, &aw );
 
-	x = SB_SCORE_RIGHT-w-2;
-	y = SB_SCORE_Y;
+	x = FPOS_SCALEX*SB_SCORE_RIGHT-w-2;
+	y = FPOS_SCALEY*SB_SCORE_Y;
 
 	//erase old score
 	gr_setcolor(BM_XRGB(0,0,0));
-	gr_rect(last_x[VR_current_page],y,SB_SCORE_RIGHT,y+GAME_FONT->ft_h);
+	gr_rect(last_x[VR_current_page],y,FPOS_SCALEX*SB_SCORE_RIGHT,y+GAME_FONT->ft_h);
 
 	if ( (Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) ) 
 		gr_set_fontcolor(gr_getcolor(0,20,0),-1 );
@@ -806,7 +857,9 @@
 	if (score_time > 0) {
 		if (score_display != last_score_display[VR_current_page]) {
 			gr_setcolor(BM_XRGB(0,0,0));
+#ifndef OGL
 			gr_rect(last_x[VR_current_page],SB_SCORE_ADDED_Y,SB_SCORE_ADDED_RIGHT,SB_SCORE_ADDED_Y+GAME_FONT->ft_h);
+#endif
 			last_score_display[VR_current_page] = score_display;
 		}
 
@@ -822,17 +875,19 @@
 
 		gr_get_string_size(score_str, &w, &h, &aw );
 
-		x = SB_SCORE_ADDED_RIGHT-w-2;
+		x = FPOS_SCALEX*SB_SCORE_ADDED_RIGHT-w-2;
 
 		gr_set_fontcolor(gr_getcolor(0, color, 0),-1 );
-		gr_printf(x, SB_SCORE_ADDED_Y, score_str);
+		gr_printf(x, FPOS_SCALEY*SB_SCORE_ADDED_Y, score_str);
 
 		last_x[VR_current_page] = x;
 
 	} else {
 		//erase old score
 		gr_setcolor(BM_XRGB(0,0,0));
+#ifndef OGL
 		gr_rect(last_x[VR_current_page],SB_SCORE_ADDED_Y,SB_SCORE_ADDED_RIGHT,SB_SCORE_ADDED_Y+GAME_FONT->ft_h);
+#endif
 
 		score_time = 0;
 		score_display = 0;
@@ -873,7 +928,7 @@
 	if ((Cockpit_mode == CM_STATUS_BAR) || (Endlevel_sequence)) {
 		if (Last_homing_warning_shown[VR_current_page] == 1) {
 			PIGGY_PAGE_IN( Gauges[GAUGE_HOMING_WARNING_OFF] );
-			gr_ubitmapm( 7, 171, &GameBitmaps[Gauges[GAUGE_HOMING_WARNING_OFF].index] );
+			hud_bitblt( 7, 171, &GameBitmaps[Gauges[GAUGE_HOMING_WARNING_OFF].index], F1_0, 0);
 			Last_homing_warning_shown[VR_current_page] = 0;
 		}
 		return;
@@ -886,19 +941,19 @@
 		if (GameTime & 0x4000) {
 			if (Last_homing_warning_shown[VR_current_page] != 1) {
 				PIGGY_PAGE_IN(Gauges[GAUGE_HOMING_WARNING_ON]);
-				gr_ubitmapm( 7, 171, &GameBitmaps[Gauges[GAUGE_HOMING_WARNING_ON].index]);
+				hud_bitblt( 7, 171, &GameBitmaps[Gauges[GAUGE_HOMING_WARNING_ON].index], F1_0, 0);
 				Last_homing_warning_shown[VR_current_page] = 1;
 			}
 		} else {
 			if (Last_homing_warning_shown[VR_current_page] != 0) {
 				PIGGY_PAGE_IN(Gauges[GAUGE_HOMING_WARNING_OFF]);
-				gr_ubitmapm( 7, 171, &GameBitmaps[Gauges[GAUGE_HOMING_WARNING_OFF].index] );
+				hud_bitblt( 7, 171, &GameBitmaps[Gauges[GAUGE_HOMING_WARNING_OFF].index], F1_0, 0);
 				Last_homing_warning_shown[VR_current_page] = 0;
 			}
 		}
 	} else if (Last_homing_warning_shown[VR_current_page] != 0) {
 		PIGGY_PAGE_IN(Gauges[GAUGE_HOMING_WARNING_OFF]);
-		gr_ubitmapm( 7, 171, &GameBitmaps[Gauges[GAUGE_HOMING_WARNING_OFF].index] );
+		hud_bitblt( 7, 171, &GameBitmaps[Gauges[GAUGE_HOMING_WARNING_OFF].index], F1_0, 0);
 		Last_homing_warning_shown[VR_current_page] = 0;
 	}
 
@@ -920,22 +975,22 @@
 }
 
 void hud_show_keys(void)
-{      //y was 24.  changed to 17 to fix (hopefully) conflict with pauseinfo
+{
 #ifndef SHAREWARE
 	if (Players[Player_num].flags & PLAYER_FLAGS_BLUE_KEY) {
 		PIGGY_PAGE_IN(Gauges[KEY_ICON_BLUE]);
-                gr_ubitmapm(2,17,&GameBitmaps[Gauges[KEY_ICON_BLUE].index]);
-
+		hud_bitblt(2,17,&GameBitmaps[Gauges[KEY_ICON_BLUE].index], F1_0, 0);
 	}
 
 	if (Players[Player_num].flags & PLAYER_FLAGS_GOLD_KEY) {
 		PIGGY_PAGE_IN(Gauges[KEY_ICON_YELLOW]);
-                gr_ubitmapm(10,17,&GameBitmaps[Gauges[KEY_ICON_YELLOW].index]);
+		hud_bitblt(10,17,&GameBitmaps[Gauges[KEY_ICON_YELLOW].index], F1_0, 0);
 	}
 
 	if (Players[Player_num].flags & PLAYER_FLAGS_RED_KEY) {
 		PIGGY_PAGE_IN(Gauges[KEY_ICON_RED]);
-                gr_ubitmapm(18,17,&GameBitmaps[Gauges[KEY_ICON_RED].index]);
+		hud_bitblt(18,17,&GameBitmaps[Gauges[KEY_ICON_RED].index], F1_0, 0);
+
 	}
 #endif
 }
@@ -1080,18 +1135,15 @@
 			x1=grd_curcanv->cv_w/2-(w);//originally /2-20
 			x2=grd_curcanv->cv_w/2+x2;//originally /2+10
 		}else{
-			y=grd_curcanv->cv_h/2+8;
-			x1=grd_curcanv->cv_w/2-(40+w);//originally /2-60
-			x2=grd_curcanv->cv_w/2+(42+x2);//originally /2+50
+			y=grd_curcanv->cv_h/1.8+8; // ZICO - originally /2+8;
+			x1=grd_curcanv->cv_w/2.1-(40+w); //ZICO - originally 2-(40+w);
+			x2=grd_curcanv->cv_w/1.9+(42+x2); //ZICO - originally 2-(42+x2);
 		}
 		hud_show_weapons_mode1(0,1,0,x1,y);
 		hud_show_weapons_mode1(1,1,0,x2,y);
 		gr_set_fontcolor(gr_getcolor(14,14,23),-1 );
-//		gr_printf(grd_curcanv->cv_w/2-8, y-27,"S%i", f2ir(Players[Player_num].shields));
-//		gr_printf(grd_curcanv->cv_w/2-20, y-27,"S%i", f2ir(Players[Player_num].shields));
 		gr_printf(x2, y-(GAME_FONT->ft_h*4+4),"%i", f2ir(Players[Player_num].shields));//originally y-24
 		gr_set_fontcolor(gr_getcolor(25,18,6),-1 );
-//		gr_printf(grd_curcanv->cv_w/2-20, y-19,"E%i", f2ir(Players[Player_num].energy));
 		gr_printf(x1, y-(GAME_FONT->ft_h*4+4),"%i", f2ir(Players[Player_num].energy));//originally y-24
 	}
 //end edit -MM
@@ -1184,6 +1233,8 @@
 
 void hud_show_cloak_invuln(void)
 {
+	gr_set_fontcolor(gr_getcolor(0,31,0),-1 );
+
 	if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) {
 		int	y = grd_curcanv->cv_h;
 
@@ -1247,7 +1298,7 @@
 //draw the icons for number of lives
 void hud_show_lives()
 {
-	if ((HUD_nmessages > 0) && (strlen(HUD_messages[hud_first]) > 38))
+	if ((HUD_nmessages > 0) && (strlen(HUD_messages[hud_first]) > 50)) // ZICO - hud msg can be longer than 38
 		return;
 
 	if (Game_mode & GM_MULTI) {
@@ -1259,10 +1310,24 @@
 		gr_set_curfont( GAME_FONT );
 		gr_set_fontcolor(gr_getcolor(0,20,0),-1 );
 		PIGGY_PAGE_IN(Gauges[GAUGE_LIVES]);
+#ifdef OGL
+		if (grd_curscreen->sc_w >= 640 && cfexist(D1XDATAPATH "font3-1h.fnt")) {
+
+			gr_printf(11,3, "^");
+			gr_printf( 7,6, "'");
+			gr_printf(19,6, "'");
+			gr_printf( 7,4, "-");
+			gr_printf(13,4, "-");
+			gr_printf(10,7, "-");
+			gr_printf(24, 3, "x %d", Players[Player_num].lives-1);
+		} else 
+#endif
+		{
+
 		gr_ubitmapm(10,3,&GameBitmaps[Gauges[GAUGE_LIVES].index]);
 		gr_printf(22, 3, "x %d", Players[Player_num].lives-1);
 	}
-
+	}
 }
 
 void sb_show_lives()
@@ -1276,9 +1341,9 @@
 		gr_set_curfont( GAME_FONT );
 		gr_set_fontcolor(gr_getcolor(0,20,0),-1 );
 		if (Game_mode & GM_MULTI)
-			gr_printf(SB_LIVES_LABEL_X,SB_LIVES_LABEL_Y,"%s:", TXT_DEATHS);
+			gr_printf(FPOS_SCALEX*SB_LIVES_LABEL_X,FPOS_SCALEY*SB_LIVES_LABEL_Y,"%s:", TXT_DEATHS);
 		else
-			gr_printf(SB_LIVES_LABEL_X,SB_LIVES_LABEL_Y,"%s:", TXT_LIVES);
+			gr_printf(FPOS_SCALEX*SB_LIVES_LABEL_X,FPOS_SCALEY*SB_LIVES_LABEL_Y,"%s:", TXT_LIVES);
 	}
 
 	if (Game_mode & GM_MULTI)
@@ -1291,10 +1356,12 @@
 		sprintf(killed_str, "%5d", Players[Player_num].net_killed_total);
 		gr_get_string_size(killed_str, &w, &h, &aw);
 		gr_setcolor(BM_XRGB(0,0,0));
+#ifndef OGL
 		gr_rect(last_x[VR_current_page], y+1, SB_SCORE_RIGHT, y+GAME_FONT->ft_h);
+#endif
 		gr_set_fontcolor(gr_getcolor(0,20,0),-1);
-		x = SB_SCORE_RIGHT-w-2;		
-		gr_printf(x, y+1, killed_str);
+		x = FPOS_SCALEX*SB_SCORE_RIGHT-w-2;		
+		gr_printf(x, FPOS_SCALEY*y+1, killed_str);
 		last_x[VR_current_page] = x;
 		return;
 	}
@@ -1304,20 +1371,17 @@
 		//erase old icons
 
 		gr_setcolor(BM_XRGB(0,0,0));
-		gr_rect(x, y, x+32, y+bm->bm_h);
+		gr_rect(FPOS_SCALEX*x, FPOS_SCALEY*y, FPOS_SCALEX*x+32, (FPOS_SCALEY*y)+bm->bm_h);
 
 		if (Players[Player_num].lives-1 > 0) {
 			gr_set_curfont( GAME_FONT );
 			gr_set_fontcolor(gr_getcolor(0,20,0),-1 );
 			PIGGY_PAGE_IN(Gauges[GAUGE_LIVES]);
-			gr_ubitmapm(x, y,bm);
-			gr_printf(x+12, y, "x %d", Players[Player_num].lives-1);
+			hud_bitblt(x, y,bm, F1_0, 0);
+			gr_printf(FPOS_SCALEX*x+FPOS_SCALEX*12, FPOS_SCALEY*y, "x %d", Players[Player_num].lives-1);
 		}
 	}
 
-//	for (i=0;i<draw_count;i++,x+=bm->bm_w+2)
-//		gr_ubitmapm(x,y,bm);
-
 }
 
 #ifndef RELEASE
@@ -1426,18 +1490,18 @@
 
 void init_gauge_canvases()
 {
-	Canv_LeftEnergyGauge = gr_create_canvas( LEFT_ENERGY_GAUGE_W, LEFT_ENERGY_GAUGE_H );
-	Canv_SBEnergyGauge = gr_create_canvas( SB_ENERGY_GAUGE_W, SB_ENERGY_GAUGE_H );
-	Canv_RightEnergyGauge = gr_create_canvas( RIGHT_ENERGY_GAUGE_W, RIGHT_ENERGY_GAUGE_H );
-	Canv_NumericalGauge = gr_create_canvas( NUMERICAL_GAUGE_W, NUMERICAL_GAUGE_H );
+	Canv_LeftEnergyGauge = gr_create_sub_canvas( grd_curcanv, LEFT_ENERGY_GAUGE_X, LEFT_ENERGY_GAUGE_Y, LEFT_ENERGY_GAUGE_W, LEFT_ENERGY_GAUGE_H );
+	Canv_SBEnergyGauge = gr_create_sub_canvas( grd_curcanv, SB_ENERGY_GAUGE_X, SB_ENERGY_GAUGE_Y, SB_ENERGY_GAUGE_W, SB_ENERGY_GAUGE_H );
+	Canv_RightEnergyGauge = gr_create_sub_canvas( grd_curcanv, RIGHT_ENERGY_GAUGE_X, RIGHT_ENERGY_GAUGE_Y, RIGHT_ENERGY_GAUGE_W, RIGHT_ENERGY_GAUGE_H );
+	Canv_NumericalGauge = gr_create_sub_canvas( grd_curcanv, NUMERICAL_GAUGE_X, NUMERICAL_GAUGE_Y, NUMERICAL_GAUGE_W, NUMERICAL_GAUGE_H );
 }
 
 void close_gauge_canvases()
 {
-	gr_free_canvas( Canv_LeftEnergyGauge );
-	gr_free_canvas( Canv_SBEnergyGauge );
-	gr_free_canvas( Canv_RightEnergyGauge );
-	gr_free_canvas( Canv_NumericalGauge );
+	gr_free_sub_canvas( Canv_LeftEnergyGauge );
+	gr_free_sub_canvas( Canv_SBEnergyGauge );
+	gr_free_sub_canvas( Canv_RightEnergyGauge );
+	gr_free_sub_canvas( Canv_NumericalGauge );
 }
 
 void init_gauges()
@@ -1464,15 +1528,102 @@
 	cloak_fade_state = 0;
 }
 
+#ifdef OGL // ZICO - scalable
+void draw_energy_bar(int energy)
+{
+	grs_bitmap *bm;
+	int energy0;
+	int x1, x2, y, yMax, i;
+	int h0 = HUD_SCALE_X (LEFT_ENERGY_GAUGE_H - 1);
+	int h1 = HUD_SCALE_Y (LEFT_ENERGY_GAUGE_H / 4);
+	int h2 = HUD_SCALE_Y ((LEFT_ENERGY_GAUGE_H * 3) / 4);
+	int w1 = HUD_SCALE_X (LEFT_ENERGY_GAUGE_W - 1);
+	int w2 = HUD_SCALE_X (LEFT_ENERGY_GAUGE_W - 2);
+	int w3 = HUD_SCALE_X (LEFT_ENERGY_GAUGE_W - 3);
+	double eBarScale = (100.0 - (double) energy) * FPOS_SCALEX * 0.075 / (double) HUD_SCALE_Y (LEFT_ENERGY_GAUGE_H);
+
+	// Draw left energy bar
+	PIGGY_PAGE_IN(Gauges[GAUGE_ENERGY_LEFT]);
+	bm = &GameBitmaps[Gauges[GAUGE_ENERGY_LEFT].index];
+	hud_bitblt (LEFT_ENERGY_GAUGE_X, LEFT_ENERGY_GAUGE_Y, bm, F1_0, 0);
+
+	gr_setcolor(BM_XRGB(0,0,0));
+
+	energy0 = HUD_SCALE_X (56);
+	energy0 = energy0 - (energy * energy0) / 100;
+	if (energy < 100) {
+		for (i = 0; i < LEFT_ENERGY_GAUGE_H; i++) {
+			yMax = HUD_SCALE_Y (i + 1);
+			for (y = i; y <= yMax; y++) {
+				x1 = h0 - y;
+				x2 = x1 + energy0 + (int) ((double) y * eBarScale);
+				if (y < h1) {
+					if (x2 > w1) 
+						x2 = w1;
+					}
+				else if (y < h2) {
+					if (x2 > w2)
+						x2 = w2;
+					}
+				else {
+					if (x2 > w3) 
+						x2 = w3;
+					}
+				if (x2 > x1)
+					gr_rect(HUD_SCALE_X (LEFT_ENERGY_GAUGE_X) + x1, HUD_SCALE_Y (LEFT_ENERGY_GAUGE_Y) +y , HUD_SCALE_X (LEFT_ENERGY_GAUGE_X) + x2, HUD_SCALE_Y (LEFT_ENERGY_GAUGE_Y) +y +1);
+				}
+			}
+		}
+	gr_set_current_canvas( get_current_game_screen() );
+
+	// Draw right energy bar
+	PIGGY_PAGE_IN(Gauges[GAUGE_ENERGY_RIGHT]);
+	bm = &GameBitmaps[Gauges[GAUGE_ENERGY_RIGHT].index];
+	hud_bitblt (RIGHT_ENERGY_GAUGE_X-1, RIGHT_ENERGY_GAUGE_Y, bm, F1_0, 0);
+
+	gr_setcolor(BM_XRGB(0,0,0));
+
+	h0 = HUD_SCALE_X (RIGHT_ENERGY_GAUGE_W - RIGHT_ENERGY_GAUGE_H);
+	w1 = HUD_SCALE_X (1);
+	w2 = HUD_SCALE_X (2);
+	if (energy < 100) {
+		yMax = HUD_SCALE_Y (RIGHT_ENERGY_GAUGE_H);
+		for (i = 0; i < RIGHT_ENERGY_GAUGE_H; i++) {
+			yMax = HUD_SCALE_Y (i + 1);
+			for (y = i; y <= yMax; y++) {
+				x2 = h0 + y;
+				x1 = x2 - energy0 - (int) ((double) y * eBarScale);
+				if (y < h1) {
+					if (x1 < 0) 
+						x1 = 0;
+					}
+				else if (y < h2) {
+					if (x1 < w1) 
+						x1 = w1;
+					}
+				else {
+					if (x1 < w2) 
+						x1 = w2;
+					}
+				if (x2 > x1) 
+					gr_rect(HUD_SCALE_X (RIGHT_ENERGY_GAUGE_X) + x1, HUD_SCALE_Y (RIGHT_ENERGY_GAUGE_Y) +y , HUD_SCALE_X (RIGHT_ENERGY_GAUGE_X) + x2, HUD_SCALE_Y (RIGHT_ENERGY_GAUGE_Y) +y +1);
+				}
+			}
+		}
+	gr_set_current_canvas( get_current_game_screen() );
+}
+
+#else // ZICO - SDL mode with non-scalable cockpit
+
 void draw_energy_bar(int energy)
 {
 	int not_energy;
 	int x1, x2, y;
 
 	// Draw left energy bar
-	gr_set_current_canvas( Canv_LeftEnergyGauge );
+	//gr_set_current_canvas( Canv_LeftEnergyGauge );
 	PIGGY_PAGE_IN(Gauges[GAUGE_ENERGY_LEFT]);
-	gr_ubitmapm( 0, 0, &GameBitmaps[Gauges[GAUGE_ENERGY_LEFT].index] );
+	gr_ubitmapm( LEFT_ENERGY_GAUGE_X, LEFT_ENERGY_GAUGE_Y, &GameBitmaps[Gauges[GAUGE_ENERGY_LEFT].index] );
 	gr_setcolor( 0 );
 
 	not_energy = 61 - (energy*61)/100;
@@ -1486,16 +1637,15 @@
 			if ( y>=2 && y<6 ) if (x2 > LEFT_ENERGY_GAUGE_W - 2) x2 = LEFT_ENERGY_GAUGE_W - 2;
 			if ( y>=6 ) if (x2 > LEFT_ENERGY_GAUGE_W - 3) x2 = LEFT_ENERGY_GAUGE_W - 3;
 			
-			if (x2 > x1) gr_uscanline( x1, x2, y ); 
+			if (x2 > x1) gr_uscanline( LEFT_ENERGY_GAUGE_X+x1, LEFT_ENERGY_GAUGE_X+x2, LEFT_ENERGY_GAUGE_Y+y ); 
 		}
 
 	gr_set_current_canvas( get_current_game_screen() );
-	gr_ubitmapm( LEFT_ENERGY_GAUGE_X, LEFT_ENERGY_GAUGE_Y, &Canv_LeftEnergyGauge->cv_bitmap );
 
 	// Draw right energy bar
-	gr_set_current_canvas( Canv_RightEnergyGauge );
+	//gr_set_current_canvas( Canv_RightEnergyGauge );
 	PIGGY_PAGE_IN(Gauges[GAUGE_ENERGY_RIGHT]);
-	gr_ubitmapm( 0, 0, &GameBitmaps[Gauges[GAUGE_ENERGY_RIGHT].index] );
+	gr_ubitmapm( RIGHT_ENERGY_GAUGE_X, RIGHT_ENERGY_GAUGE_Y, &GameBitmaps[Gauges[GAUGE_ENERGY_RIGHT].index] );
 
 	if (energy < 100)
 		for (y=0; y<8; y++) {
@@ -1506,21 +1656,20 @@
 			if ( y>=2 && y<6 ) if (x1 < 1) x1 = 1;
 			if ( y>=6 ) if (x1 < 2) x1 = 2;
 			
-			if (x2 > x1) gr_uscanline( x1, x2, y ); 
+			if (x2 > x1) gr_uscanline( RIGHT_ENERGY_GAUGE_X+x1, RIGHT_ENERGY_GAUGE_X+x2, RIGHT_ENERGY_GAUGE_Y+y ); 
 		}
 
 	gr_set_current_canvas( get_current_game_screen() );
-	gr_ubitmapm( RIGHT_ENERGY_GAUGE_X, RIGHT_ENERGY_GAUGE_Y, &Canv_RightEnergyGauge->cv_bitmap );
 
 }
+#endif
 
 void draw_shield_bar(int shield)
 {
 	int bm_num = shield>=100?9:(shield / 10);
 
-	PIGGY_PAGE_IN(Gauges[GAUGE_SHIELDS+9-bm_num]	);
-	gr_ubitmapm( SHIELD_GAUGE_X, SHIELD_GAUGE_Y, &GameBitmaps[Gauges[GAUGE_SHIELDS+9-bm_num].index] );
-
+	PIGGY_PAGE_IN(Gauges[GAUGE_SHIELDS+9-bm_num]);
+	hud_bitblt (SHIELD_GAUGE_X, SHIELD_GAUGE_Y, &GameBitmaps[Gauges[GAUGE_SHIELDS+9-bm_num].index], F1_0, 0);
 }
 
 #define CLOAK_FADE_WAIT_TIME  0x400
@@ -1587,11 +1736,15 @@
 	}
 
 	gr_set_current_canvas(&VR_render_buffer[0]);
-	gr_ubitmap( x, y, bm);
+	if (!cloak_state) { // ZICO - quick hack to get cloak state without the fade-levels
+		hud_bitblt (x, y, bm, F1_0, 0); // ZICO - scalable
+	}
 
 #ifndef D1XD3D
 	Gr_scanline_darkening_level = cloak_fade_value;
+#ifndef OGL
 	gr_rect(x, y, x+bm->bm_w-1, y+bm->bm_h-1);
+#endif
 	Gr_scanline_darkening_level = GR_FADE_LEVELS;
 #endif
 
@@ -1604,20 +1756,17 @@
 
 void draw_numerical_display(int shield, int energy)
 {
-	gr_set_current_canvas( Canv_NumericalGauge );
+	int dx = NUMERICAL_GAUGE_X, dy = NUMERICAL_GAUGE_Y+1;
+
 	gr_set_curfont( GAME_FONT );
 	PIGGY_PAGE_IN(Gauges[GAUGE_NUMERICAL]);
-	gr_ubitmap( 0, 0, &GameBitmaps[Gauges[GAUGE_NUMERICAL].index] );
+	hud_bitblt (dx, dy, &GameBitmaps[Gauges[GAUGE_NUMERICAL].index], F1_0, 0);
 
 	gr_set_fontcolor(gr_getcolor(14,14,23),-1 );
-
-	gr_printf((shield>99)?3:((shield>9)?5:7),15,"%d",shield);
-
+	gr_printf((shield>99)?(grd_curscreen->sc_w/2)-3:((shield>9)?(grd_curscreen->sc_w/2)-1:(grd_curscreen->sc_w/2)+3),(grd_curscreen->sc_h/1.365),"%d",shield);
 	gr_set_fontcolor(gr_getcolor(25,18,6),-1 );
-	gr_printf((energy>99)?3:((energy>9)?5:7),2,"%d",energy);
-					  
+	gr_printf((energy>99)?(grd_curscreen->sc_w/2)-3:((energy>9)?(grd_curscreen->sc_w/2)-1:(grd_curscreen->sc_w/2)+3),(grd_curscreen->sc_h/1.49),"%d",energy);
 	gr_set_current_canvas( get_current_game_screen() );
-	gr_ubitmapm( NUMERICAL_GAUGE_X, NUMERICAL_GAUGE_Y, &Canv_NumericalGauge->cv_bitmap );
 }
 
 
@@ -1627,26 +1776,26 @@
 
 	if (Players[Player_num].flags & PLAYER_FLAGS_BLUE_KEY )	{
 		PIGGY_PAGE_IN(Gauges[GAUGE_BLUE_KEY]);
-                gr_ubitmapm( GAUGE_BLUE_KEY_X, GAUGE_BLUE_KEY_Y, &GameBitmaps[Gauges[GAUGE_BLUE_KEY].index] );
+                hud_bitblt( GAUGE_BLUE_KEY_X, GAUGE_BLUE_KEY_Y, &GameBitmaps[Gauges[GAUGE_BLUE_KEY].index], F1_0, 0 );
 	} else {
 		PIGGY_PAGE_IN(Gauges[GAUGE_BLUE_KEY_OFF]);
-		gr_ubitmapm( GAUGE_BLUE_KEY_X, GAUGE_BLUE_KEY_Y, &GameBitmaps[Gauges[GAUGE_BLUE_KEY_OFF].index] );
+		hud_bitblt( GAUGE_BLUE_KEY_X, GAUGE_BLUE_KEY_Y, &GameBitmaps[Gauges[GAUGE_BLUE_KEY_OFF].index], F1_0, 0 );
 	}
 
 	if (Players[Player_num].flags & PLAYER_FLAGS_GOLD_KEY)	{
 		PIGGY_PAGE_IN(Gauges[GAUGE_GOLD_KEY]);
-		gr_ubitmapm( GAUGE_GOLD_KEY_X, GAUGE_GOLD_KEY_Y, &GameBitmaps[Gauges[GAUGE_GOLD_KEY].index] );
+		hud_bitblt( GAUGE_GOLD_KEY_X, GAUGE_GOLD_KEY_Y, &GameBitmaps[Gauges[GAUGE_GOLD_KEY].index], F1_0, 0 );
 	} else {
 		PIGGY_PAGE_IN(Gauges[GAUGE_GOLD_KEY_OFF]);
-		gr_ubitmapm( GAUGE_GOLD_KEY_X, GAUGE_GOLD_KEY_Y, &GameBitmaps[Gauges[GAUGE_GOLD_KEY_OFF].index] );
+		hud_bitblt( GAUGE_GOLD_KEY_X, GAUGE_GOLD_KEY_Y, &GameBitmaps[Gauges[GAUGE_GOLD_KEY_OFF].index], F1_0, 0 );
 	}
 
 	if (Players[Player_num].flags & PLAYER_FLAGS_RED_KEY)	{
 		PIGGY_PAGE_IN( Gauges[GAUGE_RED_KEY] );
-		gr_ubitmapm( GAUGE_RED_KEY_X,  GAUGE_RED_KEY_Y,  &GameBitmaps[Gauges[GAUGE_RED_KEY].index] );
+		hud_bitblt( GAUGE_RED_KEY_X,  GAUGE_RED_KEY_Y,  &GameBitmaps[Gauges[GAUGE_RED_KEY].index], F1_0, 0 );
 	} else {
 		PIGGY_PAGE_IN(Gauges[GAUGE_RED_KEY_OFF]);
-		gr_ubitmapm( GAUGE_RED_KEY_X,  GAUGE_RED_KEY_Y,  &GameBitmaps[Gauges[GAUGE_RED_KEY_OFF].index] );
+		hud_bitblt( GAUGE_RED_KEY_X,  GAUGE_RED_KEY_Y,  &GameBitmaps[Gauges[GAUGE_RED_KEY_OFF].index], F1_0, 0 );
 	}
 }
 
@@ -1658,13 +1807,13 @@
 
 	//clear the window
 	gr_setcolor(BM_XRGB(0,0,0));
-	gr_rect(box->left,box->top,box->right,box->bot);
+	gr_rect(FPOS_SCALEX*box->left,FPOS_SCALEY*box->top,FPOS_SCALEX*box->right,FPOS_SCALEY*box->bot);
 
 	bm=&GameBitmaps[Weapon_info[info_index].picture.index];
 	Assert(bm != NULL);
 
 	PIGGY_PAGE_IN( Weapon_info[info_index].picture );
-	gr_ubitmapm(pic_x,pic_y,bm);
+	hud_bitblt (pic_x, pic_y, bm, (Cockpit_mode == CM_FULL_SCREEN) ? 2 * F1_0 : F1_0, 0);
 
 //edited 02/07/99 Matt Mueller
         if (Gauge_hud_mode==0)
@@ -1687,11 +1836,11 @@
 			
 			temp_str[5] = Players[Player_num].laser_level+1 + '0';
 			
-			gr_printf(text_x,text_y+8, temp_str);
+			gr_printf(text_x,text_y+FPOS_SCALEY*8, temp_str);
 			
 			if (Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS) {
 				strcpy(temp_str, TXT_QUAD);
-				gr_printf(text_x,text_y+16, temp_str);
+				gr_printf(text_x,text_y+FPOS_SCALEY*16, temp_str);
 			}
 			
 		}
@@ -1699,6 +1848,13 @@
 //end edit -MM
 }
 
+char    *PRIMARY_WEAPON_NAMES_VERYSHORT[5] = { // ZICO - new weapon names for cockpit and sb
+    "Laser", 
+    "Vulcan", 
+    "Spread", 
+    "Plasma", 
+    "Fusion" 
+};
 
 void draw_weapon_info(int weapon_type,int weapon_num)
 {
@@ -1716,7 +1873,8 @@
           draw_weapon_info_sub(Primary_weapon_to_weapon_info[weapon_num],
               &gauge_boxes[2],
               SB_PRIMARY_W_PIC_X,SB_PRIMARY_W_PIC_Y,
-              PRIMARY_WEAPON_NAMES_SHORT(weapon_num),
+              //PRIMARY_WEAPON_NAMES_SHORT(weapon_num),
+              PRIMARY_WEAPON_NAMES_VERYSHORT[weapon_num], // ZICO - call for new very short names
               SB_PRIMARY_W_TEXT_X,SB_PRIMARY_W_TEXT_Y);
           x=SB_PRIMARY_AMMO_X;
           y=SB_PRIMARY_AMMO_Y;
@@ -1726,7 +1884,8 @@
           draw_weapon_info_sub(Primary_weapon_to_weapon_info[weapon_num],
               &gauge_boxes[0],
               PRIMARY_W_PIC_X,PRIMARY_W_PIC_Y,
-              PRIMARY_WEAPON_NAMES_SHORT(weapon_num),
+              //PRIMARY_WEAPON_NAMES_SHORT(weapon_num),
+              PRIMARY_WEAPON_NAMES_VERYSHORT[weapon_num], // ZICO - call for new very short names
               PRIMARY_W_TEXT_X,PRIMARY_W_TEXT_Y);
           x=PRIMARY_AMMO_X;
           y=PRIMARY_AMMO_Y;
@@ -1834,7 +1993,9 @@
 {
  int drew_flag=0;
 
+#ifndef OGL
   gr_set_current_canvas(&VR_render_buffer[0]);
+#endif
   gr_set_curfont( GAME_FONT );
 
    if (weapon_num != old_weapon[weapon_type][VR_current_page] &&
@@ -1972,23 +2133,21 @@
 {
 	int erase_height;
 
-	gr_set_current_canvas( Canv_SBEnergyGauge );
 	PIGGY_PAGE_IN(Gauges[SB_GAUGE_ENERGY]);
-	gr_ubitmapm( 0, 0, &GameBitmaps[Gauges[SB_GAUGE_ENERGY].index] );
-
+	hud_bitblt( SB_ENERGY_GAUGE_X, SB_ENERGY_GAUGE_Y, &GameBitmaps[Gauges[SB_GAUGE_ENERGY].index], F1_0, 0 );
 	erase_height = (100 - energy) * SB_ENERGY_GAUGE_H / 100;
 
 	if (erase_height > 0) {
 		gr_setcolor( 0 );
-		gr_rect(0,0,SB_ENERGY_GAUGE_W-1,erase_height-1);
+		gr_rect(FPOS_SCALEX*SB_ENERGY_GAUGE_X,FPOS_SCALEY*SB_ENERGY_GAUGE_Y,FPOS_SCALEX*(SB_ENERGY_GAUGE_X+SB_ENERGY_GAUGE_W)-1,FPOS_SCALEY*(SB_ENERGY_GAUGE_Y+(erase_height-1))); // ZICO - maths are great, right? :)
 	}
 
 	gr_set_current_canvas( get_current_game_screen() );
-	gr_ubitmapm( SB_ENERGY_GAUGE_X, SB_ENERGY_GAUGE_Y, &Canv_SBEnergyGauge->cv_bitmap );
+	//gr_ubitmapm( SB_ENERGY_GAUGE_X, SB_ENERGY_GAUGE_Y, &Canv_SBEnergyGauge->cv_bitmap );
 
 	//draw numbers
 	gr_set_fontcolor(gr_getcolor(25,18,6),-1 );
-	gr_printf((energy>99)?SB_ENERGY_NUM_X:((energy>9)?SB_ENERGY_NUM_X+2:SB_ENERGY_NUM_X+4),SB_ENERGY_NUM_Y,"%d",energy);
+	gr_printf((energy>99)?FPOS_SCALEX*SB_ENERGY_NUM_X:((energy>9)?FPOS_SCALEX*(SB_ENERGY_NUM_X+2):FPOS_SCALEX*(SB_ENERGY_NUM_X+4)),FPOS_SCALEY*SB_ENERGY_NUM_Y,"%d",energy);
 					  
 }
 
@@ -2004,9 +2163,11 @@
 	//erase old one
 	PIGGY_PAGE_IN( cockpit_bitmap[Cockpit_mode] );
 	gr_setcolor(gr_gpixel(bm,SB_SHIELD_NUM_X,SB_SHIELD_NUM_Y-(VR_render_height-bm->bm_h)));
+#ifndef OGL
 	gr_rect(SB_SHIELD_NUM_X,SB_SHIELD_NUM_Y,SB_SHIELD_NUM_X+13,SB_SHIELD_NUM_Y+GAME_FONT->ft_h);
+#endif
 
-	gr_printf((shield>99)?SB_SHIELD_NUM_X:((shield>9)?SB_SHIELD_NUM_X+2:SB_SHIELD_NUM_X+4),SB_SHIELD_NUM_Y,"%d",shield);
+	gr_printf((shield>99)?FPOS_SCALEX*SB_SHIELD_NUM_X:((shield>9)?FPOS_SCALEX*(SB_SHIELD_NUM_X+2):FPOS_SCALEX*(SB_SHIELD_NUM_X+4)),FPOS_SCALEY*SB_SHIELD_NUM_Y,"%d",shield);
 }
 
 void sb_draw_shield_bar(int shield)
@@ -2016,8 +2177,7 @@
 	gr_set_current_canvas( get_current_game_screen() );
 
 	PIGGY_PAGE_IN( Gauges[GAUGE_SHIELDS+9-bm_num] );
-	gr_ubitmapm( SB_SHIELD_GAUGE_X, SB_SHIELD_GAUGE_Y, &GameBitmaps[Gauges[GAUGE_SHIELDS+9-bm_num].index] );
-
+	hud_bitblt( SB_SHIELD_GAUGE_X, SB_SHIELD_GAUGE_Y, &GameBitmaps[Gauges[GAUGE_SHIELDS+9-bm_num].index], F1_0, 0 );
 }
 
 void sb_draw_keys()
@@ -2029,14 +2189,13 @@
 
 	bm = &GameBitmaps[Gauges[(flags&PLAYER_FLAGS_BLUE_KEY)?SB_GAUGE_BLUE_KEY:SB_GAUGE_BLUE_KEY_OFF].index];
 	PIGGY_PAGE_IN(Gauges[(flags&PLAYER_FLAGS_BLUE_KEY)?SB_GAUGE_BLUE_KEY:SB_GAUGE_BLUE_KEY_OFF]);
-	gr_ubitmapm( SB_GAUGE_KEYS_X, SB_GAUGE_BLUE_KEY_Y, bm );
+	hud_bitblt( SB_GAUGE_KEYS_X, SB_GAUGE_BLUE_KEY_Y, bm, F1_0, 0 );
 	bm = &GameBitmaps[Gauges[(flags&PLAYER_FLAGS_GOLD_KEY)?SB_GAUGE_GOLD_KEY:SB_GAUGE_GOLD_KEY_OFF].index];
 	PIGGY_PAGE_IN(Gauges[(flags&PLAYER_FLAGS_GOLD_KEY)?SB_GAUGE_GOLD_KEY:SB_GAUGE_GOLD_KEY_OFF]);
-	gr_ubitmapm( SB_GAUGE_KEYS_X, SB_GAUGE_GOLD_KEY_Y, bm );
+	hud_bitblt( SB_GAUGE_KEYS_X, SB_GAUGE_GOLD_KEY_Y, bm, F1_0, 0 );
 	bm = &GameBitmaps[Gauges[(flags&PLAYER_FLAGS_RED_KEY)?SB_GAUGE_RED_KEY:SB_GAUGE_RED_KEY_OFF].index];
 	PIGGY_PAGE_IN(Gauges[(flags&PLAYER_FLAGS_RED_KEY)?SB_GAUGE_RED_KEY:SB_GAUGE_RED_KEY_OFF]);
-	gr_ubitmapm( SB_GAUGE_KEYS_X, SB_GAUGE_RED_KEY_Y, bm  );
-
+	hud_bitblt( SB_GAUGE_KEYS_X, SB_GAUGE_RED_KEY_Y, bm, F1_0, 0  );
 }
 
 //	Draws invulnerable ship, or maybe the flashing ship, depending on invulnerability time left.
@@ -2050,10 +2209,10 @@
 
 		if (Cockpit_mode == CM_STATUS_BAR)	{
 			PIGGY_PAGE_IN(Gauges[GAUGE_INVULNERABLE+invulnerable_frame]);
-			gr_ubitmapm( SB_SHIELD_GAUGE_X, SB_SHIELD_GAUGE_Y, &GameBitmaps[Gauges[GAUGE_INVULNERABLE+invulnerable_frame].index] );
+			hud_bitblt( SB_SHIELD_GAUGE_X, SB_SHIELD_GAUGE_Y, &GameBitmaps[Gauges[GAUGE_INVULNERABLE+invulnerable_frame].index], F1_0, 0 );
 		} else {
 			PIGGY_PAGE_IN(Gauges[GAUGE_INVULNERABLE+invulnerable_frame]);
-			gr_ubitmapm( SHIELD_GAUGE_X, SHIELD_GAUGE_Y, &GameBitmaps[Gauges[GAUGE_INVULNERABLE+invulnerable_frame].index] );
+			hud_bitblt( SHIELD_GAUGE_X, SHIELD_GAUGE_Y, &GameBitmaps[Gauges[GAUGE_INVULNERABLE+invulnerable_frame].index], F1_0, 0 );
 		}
 
 		time += FrameTime;
@@ -2283,7 +2442,7 @@
 		x1 = GAME_FONT->ft_aw*7;//was 31;
 #endif
 
-	save_y = y = grd_curcanv->cv_h - n_left*(fth+1);
+	save_y = y = grd_curcanv->cv_h - n_left*(fth+(FPOS_SCALEY*1));
 
 	if (Cockpit_mode == CM_FULL_COCKPIT) {
 		save_y = y -= 6;
@@ -2411,8 +2570,8 @@
 	if (Cockpit_mode==CM_STATUS_BAR){
 		//ogl needs to redraw every frame, at least currently.
 //		init_cockpit();
-//		last_drawn_cockpit[0]=-1;
-//		last_drawn_cockpit[1]=-1;
+		last_drawn_cockpit[0]=-1;
+		last_drawn_cockpit[1]=-1;
 		  init_gauges();
 
 //		vr_reset_display();
@@ -2466,9 +2626,9 @@
 		gr_set_curfont( GAME_FONT );
 		gr_set_fontcolor(gr_getcolor(0,31,0),-1 );
 		if (Newdemo_state == ND_STATE_PLAYBACK)
-			gr_printf(0x8000,grd_curcanv->cv_h-14,TXT_REAR_VIEW);
+			gr_printf(0x8000,grd_curcanv->cv_h-FPOS_SCALEY*14,TXT_REAR_VIEW);
 		else
-			gr_printf(0x8000,grd_curcanv->cv_h-10,TXT_REAR_VIEW);
+			gr_printf(0x8000,grd_curcanv->cv_h-FPOS_SCALEY*10,TXT_REAR_VIEW);
 	}
 
 }
diff -urbB d1x/main/state.c ../d1x-rebirth_v0.42-src-20060416/main/state.c
--- d1x/main/state.c	2000-10-27 01:58:45.000000000 +0200
+++ ../d1x-rebirth_v0.42-src-20060416/main/state.c	2006-03-26 12:51:56.000000000 +0200
@@ -272,6 +290,9 @@
 #include "strutil.h"
 //end added
 #include "gamefont.h"
+#ifdef OGL
+#include "ogl_init.h"
+#endif
 
 
 #ifndef SHAREWARE
@@ -702,6 +709,9 @@
 			}
 		} else {
 			render_frame(0);
+#ifdef OGL
+			ogl_ubitblt_tolinear(grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h, 0, 0, 0, 0, &grd_curscreen->sc_canvas.cv_bitmap, &grd_curcanv->cv_bitmap);
+#endif
 		}
 		fwrite( cnv->cv_bitmap.bm_data, THUMBNAIL_W*THUMBNAIL_H, 1, fp );
 //added ifdef on 9/30/98 by Matt Mueller to fix savegames in linux
@@ -958,9 +968,9 @@
 		do_briefing_screens(next_level);
 		fp = fopen( filename, "rb" );
 		fseek( fp, saved_offset, SEEK_SET );
- 		StartNewLevelSub( next_level, 0 );		
+ 		StartNewLevelSub( next_level, 1);//use page_in_textures here to fix OGL texture precashing crash -MPM
 	} else {
-		StartNewLevelSub(current_level, 0);		
+		StartNewLevelSub(current_level, 1);//use page_in_textures here to fix OGL texture precashing crash -MPM
 		fread( &Players[Player_num], sizeof(player), 1, fp );
 	}
 	strcpy( Players[Player_num].callsign, org_callsign );
@@ -1123,7 +1133,7 @@
 	fclose(fp);
 
 // Load in bitmaps, etc..
-	piggy_load_level_data();
+//	piggy_load_level_data();//already used page_in_textures in StartNewLevelSub, so no need for this here. -MPM
 
 	return 1;
 }
diff -urbB d1x/main/titles.c ../d1x-rebirth_v0.42-src-20060416/main/titles.c
--- d1x/main/titles.c	2006-08-19 11:33:19.000000000 +0200
+++ ../d1x-rebirth_v0.42-src-20060416/main/titles.c	2006-03-27 18:20:10.000000000 +0200
@@ -436,7 +315,11 @@
 vms_angvec	Robot_angles;
 
 char	Bitmap_name[32] = "";
+#ifndef OGL
 #define	EXIT_DOOR_MAX	14
+#else
+#define	EXIT_DOOR_MAX	0	// ZICO - removed door animation because broken in OGL
+#endif
 #define	OTHER_THING_MAX	10		//	Adam: This is the number of frames in your new animating thing.
 #define	DOOR_DIV_INIT	6
 byte	Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;

d1x-shareware-fixes.patch:

--- NEW FILE d1x-shareware-fixes.patch ---
diff -ur d1x.orig/main/newmenu.c d1x/main/newmenu.c
--- d1x.orig/main/newmenu.c	2000-10-28 12:02:48.000000000 +0200
+++ d1x/main/newmenu.c	2005-01-03 10:48:09.817211864 +0100
@@ -691,10 +691,14 @@
 }
 
 // Draw a left justfied string
-void nm_string( bkg * b, int w1,int x, int y, char * s )
+void nm_string( bkg * b, int w1,int x, int y, char * _s )
 {
 	int w,h,aw;
-        char *p,*s1=0;
+        char *s, *p,*s1=0;
+        
+        s = strdup(_s);
+        if (!s)
+          return;
 
 	p = strchr( s, '\t' );
 	if (p && (w1>0) )	{
@@ -713,14 +717,14 @@
 	
 	gr_string( x, y, s );
 
-	if (p && (w1>0) )	{
+	if (s1)	{
 		gr_get_string_size(s1, &w, &h, &aw  );
 
 		gr_string( x+w1-w, y, s1 );
 
 		*p = '\t';
 	}
-
+	free(s);
 }
 
 
diff -ur d1x.orig/main/playsave.c d1x/main/playsave.c
--- d1x.orig/main/playsave.c	1999-06-15 01:44:12.000000000 +0200
+++ d1x/main/playsave.c	2005-01-03 14:40:50.944797864 +0100
@@ -302,10 +302,12 @@
 
 hli highest_levels[MAX_MISSIONS];
 
-#define SAVED_GAME_VERSION		7		//increment this every time saved_game struct changes
+#define SAVED_GAME_VERSION		8		//increment this every time saved_game struct changes
 
 //version 5 -> 6: added new highest level information
 //version 6 -> 7: stripped out the old saved_game array.
+//version 7 -> 8: readded the old saved_game array since this is needed
+//                for shareware saved games
 
 //the shareware is level 4
 
@@ -1295,7 +1297,7 @@
 	Player_default_difficulty = info.default_difficulty_level;
 	Default_leveling_on = info.default_leveling_on;
 
-	if ( info.saved_game_version < 7 )	{			// Read old saved games.
+	if ( info.saved_game_version != 7 ) {	// Read old & SW saved games.
 		if (fread(saved_games,sizeof(saved_games),1,file) != 1) {
 			errno_ret = errno;
 			fclose(file);
@@ -1468,8 +1470,6 @@
 	info.id = SAVE_FILE_ID;
 	info.saved_game_version = SAVED_GAME_VERSION;
 	info.player_struct_version = PLAYER_STRUCT_VERSION;
-	info.saved_game_version = SAVED_GAME_VERSION;
-	info.player_struct_version = PLAYER_STRUCT_VERSION;
 	info.default_difficulty_level = Player_default_difficulty;
 	info.default_leveling_on = Auto_leveling_on;
 
@@ -1512,11 +1512,11 @@
 		return errno_ret;
 	}
 
-//	if (fwrite(saved_games,sizeof(saved_games),1,file) != 1) {
-//		errno_ret = errno;
-//		fclose(file);
-//		return errno_ret;
-//	}
+	if (fwrite(saved_games,sizeof(saved_games),1,file) != 1) {
+		errno_ret = errno;
+		fclose(file);
+		return errno_ret;
+	}
 
 	#ifdef NETWORK
 	if ((fwrite(Network_message_macro, MAX_MESSAGE_LEN, 4, file) != 4)) {

d1x-store-res-in-plx.patch:

--- NEW FILE d1x-store-res-in-plx.patch ---
--- d1x/main/playsave.c.aap	2006-09-23 14:48:18.000000000 +0200
+++ d1x/main/playsave.c	2006-09-23 14:54:05.000000000 +0200
@@ -294,8 +294,6 @@
 	int	n_highest_levels;				//how many highest levels are saved
 	int	default_difficulty_level;
 	int	default_leveling_on;
-	int	Game_window_w;
-	int	Game_window_h;
 } __pack__ save_info;
 
 typedef struct hli {
@@ -335,6 +333,9 @@
 
 int Default_leveling_on=1;
 
+static int Player_game_window_w = 0;
+static int Player_game_window_h = 0;
+
 void init_game_list()
 {
 	int i;
@@ -668,6 +669,26 @@
                  }
                free(line);
              }
+            else if (strstr(word,"RESOLUTION"))
+             {
+               free(line); free(word);
+               line=fsplitword(f,'\n');
+               word=splitword(line,'=');
+               strupr(word);
+
+                while(!strstr(word,"END") && !feof(f))
+                 {
+                    if(!strcmp(word,"WIDTH"))
+                     sscanf(line,"%i",&Player_game_window_w);
+                    if(!strcmp(word,"HEIGHT"))
+                     sscanf(line,"%i",&Player_game_window_h);
+                   free(line); free(word);
+                   line=fsplitword(f,'\n');
+                   word=splitword(line,'=');
+                   strupr(word);
+                 }
+               free(line);
+             }
             else if (strstr(word,"END") || feof(f))
              {
               Stop=1;
@@ -966,6 +987,10 @@
           fprintf(fout,"0=0x%x,0x%x\n",kconfig_d1x_settings[18],kconfig_d1x_settings[19]);
           fprintf(fout,"[end]\n");
 //end this section change - VR
+          fprintf(fout,"[resolution]\n");
+          fprintf(fout,"width=%d\n", Game_window_w);
+          fprintf(fout,"height=%d\n", Game_window_h);
+          fprintf(fout,"[end]\n");
 
           fprintf(fout,"[plx version]\n");
           fprintf(fout,"plx version=%s\n",D1X_VERSION);
@@ -983,6 +1008,7 @@
 #define JOYSTICK 8
 #define NEWER_KEYS 16
 #define WEAPON_ORDER 32
+#define RESOLUTION 64
 
            while(!Stop && !feof(fin))
             {
@@ -1112,6 +1138,21 @@
                   free(line);
                   printed |= JOYSTICK;
                 }
+               else if (strstr(line,"RESOLUTION"))
+                {
+		  fprintf(fout,"[resolution]\n");
+		  fprintf(fout,"width=%d\n", Game_window_w);
+		  fprintf(fout,"height=%d\n", Game_window_h);
+		  fprintf(fout,"[end]\n");
+                   while(!strstr(line,"END")&&!feof(fin))
+                    {
+                      free(line);
+                      line=fsplitword(fin,'\n');
+                      strupr(line);
+                    }
+                  free(line);
+                  printed |= RESOLUTION;
+                }
                else if (strstr(line,"END"))
                 {
                   Stop=1;
@@ -1197,6 +1238,13 @@
               fprintf(fout,"[end]\n");
             }
 //end this section addition - VR
+           if(!(printed&RESOLUTION))
+            {
+	      fprintf(fout,"[resolution]\n");
+	      fprintf(fout,"width=%d\n", Game_window_w);
+	      fprintf(fout,"height=%d\n", Game_window_h);
+	      fprintf(fout,"[end]\n");
+	    }
 
           fprintf(fout,"[plx version]\n");
           fprintf(fout,"plx version=%s\n",D1X_VERSION);
@@ -1395,17 +1443,16 @@
 	}
 
 
-	if (Game_screen_mode != SM(info.Game_window_w,info.Game_window_h))
+	if (Player_game_window_w && Player_game_window_h &&
+		Game_screen_mode != SM(Player_game_window_w, Player_game_window_h))
 	{
 		/* Free VR_offscreen_buffer so that game_init_render_buffers
 		   recreates it. */
 		gr_free_canvas(VR_offscreen_buffer);
 		VR_offscreen_buffer = NULL;
-		Game_screen_mode = SM(info.Game_window_w,info.Game_window_h);
-		game_init_render_buffers(
-			SM(info.Game_window_w,info.Game_window_h),
-			info.Game_window_w,
-			info.Game_window_h, VR_NONE);
+		Game_screen_mode = SM(Player_game_window_w, Player_game_window_h);
+		game_init_render_buffers(Game_screen_mode,
+			Player_game_window_w, Player_game_window_h, VR_NONE);
 	}
 
 	return errno_ret;
@@ -1494,8 +1541,6 @@
 	info.player_struct_version = PLAYER_STRUCT_VERSION;
 	info.default_difficulty_level = Player_default_difficulty;
 	info.default_leveling_on = Auto_leveling_on;
-	info.Game_window_w = Game_window_w;
-	info.Game_window_h = Game_window_h;
 
 	info.n_highest_levels = n_highest_levels;
 

d1x-types.patch:

--- NEW FILE d1x-types.patch ---
--- d1x/main/game.c.orig	Sat Oct 28 11:31:08 2000
+++ d1x/main/game.c	Thu Aug 29 13:44:00 2002
@@ -4677,7 +4677,7 @@
 {
 	char	*i;
 
-	mprintf((0, "Filling from %8x to %8x\n", start, end));
+	mprintf((0, "Filling from %p to %p\n", start, end));
 
 	for (i=start; i<end; i++)
 		*i = value;
@@ -4691,7 +4691,7 @@
 	for (i=start; i<end; i++)
 		if (*i != value) {
 			Int3();		//	The nast triple aught six bug...we can smell it...contact Mike!
-			Error("Oops, the nasty triple aught six bug.  Address == %8x\n", (int)i);
+			Error("Oops, the nasty triple aught six bug.  Address == %p\n", i);
 		}
 
 }

d1x-unixify.patch:

--- NEW FILE d1x-unixify.patch ---
--- d1x/main/config.c.unix	1999-06-15 01:44:11.000000000 +0200
+++ d1x/main/config.c	2006-08-26 10:37:55.000000000 +0200
@@ -187,6 +187,57 @@
 }
 #endif
 
+#ifdef __unix__
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+int check_and_create_dir(const char *name)
+{
+	struct stat stat_buffer;
+
+	if (stat(name, &stat_buffer))
+	{
+		/* error check if it doesn't exist or something else is wrong */
+		if (errno == ENOENT)
+		{
+			/* doesn't exist letts create it ;) */
+#ifdef BSD43
+			if (mkdir(name, 0775))
+#else
+				if (mkdir(name, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH))
+#endif
+				{
+					fprintf(stderr, "Error creating dir %s", name);
+					perror(" ");
+					return -1;
+				}
+		}
+		else
+		{
+			/* something else went wrong yell about it */
+			fprintf(stderr, "Error opening %s", name);
+			perror(" ");
+			return -1;
+		}
+	}
+	else
+	{
+		/* file exists check it's a dir otherwise yell about it */
+#ifdef BSD43
+		if (!(S_IFDIR & stat_buffer.st_mode))
+#else
+			if (!S_ISDIR(stat_buffer.st_mode))
+#endif
+			{
+				fprintf(stderr,"Error %s exists but isn't a dir\n", name);
+				return -1;
+			}
+	}
+	return 0;
+}
+#endif
+
 int ReadConfigFile()
 {
 	FILE *infile;
@@ -217,6 +268,16 @@
 	Config_midi_volume = 4;
 	Config_control_type = 0;
 	Config_channels_reversed = 0;
+#ifdef __unix__
+	/* we abuse the line buf here todo some unix specific stuff */
+	ptr = getenv("HOME");
+	snprintf(line, sizeof(line), "%s/.d1x", ptr? ptr:".");
+	/* If we succeed we do a chdir, because patching the file load/save
+	   code to use this path is easy, but then we also need to hack the
+	   file-selector, so just doing a chdir is easier. */
+	if (!check_and_create_dir(line))
+		chdir(line);
+#endif
 //added on 5/20/99 by Victor Rachels to make less hassle when switching
 #ifdef __WINDOWS__
         infile = fopen("descentw.cfg", "rt");

d1x-use-reg-save-in-sw.patch:

--- NEW FILE d1x-use-reg-save-in-sw.patch ---
diff -up d1x/main/game.c.foo d1x/main/game.c
--- d1x/main/game.c.foo	2008-07-23 15:37:03.000000000 +0200
+++ d1x/main/game.c	2008-07-23 15:37:17.000000000 +0200
@@ -4026,16 +4026,8 @@ void ReadControls()
 					Function_mode=FMODE_EXIT;
 					break;
 
-#ifdef SHAREWARE
-				case KEY_ALTED+KEY_F2:
-				case KEY_ALTED+KEY_F3:
-					hud_message( MSGC_GAME_FEEDBACK, TXT_ONLY_REGISTERED );
-					digi_play_sample( SOUND_BAD_SELECTION, F1_0 );
-					break;
-#else
 				case KEY_ALTED+KEY_F2:	state_save_all( 0 );		break;	// 0 means not between levels.
 				case KEY_ALTED+KEY_F3:	state_restore_all(1);		break;
-#endif
 
                                 //use function keys for window sizing
 
diff -up d1x/main/menu.c.foo d1x/main/menu.c
--- d1x/main/menu.c.foo	2008-07-23 15:37:03.000000000 +0200
+++ d1x/main/menu.c	2008-07-23 15:37:17.000000000 +0200
@@ -228,11 +228,6 @@ void create_main_menu(newmenu_item *m, i
 	
 
 	ADD_ITEM(TXT_NEW_GAME,MENU_NEW_GAME,KEY_N);
-
-#ifdef SHAREWARE
-	if (get_game_list(NULL)>0)
-#endif
-
   	ADD_ITEM(TXT_LOAD_GAME,MENU_LOAD_GAME,KEY_L);
 
 #ifdef NETWORK
@@ -342,11 +337,7 @@ void do_option ( int select) 
 			}
 			break;
 		case MENU_LOAD_GAME:
-#ifdef SHAREWARE
-			do_load_game_menu();
-#else
 			state_restore_all(0);	
-#endif
 			break;
 		#ifdef EDITOR
 		case MENU_EDITOR:
diff -up d1x/main/playsave.c.foo d1x/main/playsave.c
--- d1x/main/playsave.c.foo	2008-07-23 15:37:04.000000000 +0200
+++ d1x/main/playsave.c	2008-07-23 15:37:17.000000000 +0200
@@ -1474,9 +1474,8 @@ int read_player_file()
 	if (fclose(file) && errno_ret==EZERO)
 		errno_ret = errno;
 
-#ifndef SHAREWARE
-	if ( info.saved_game_version == COMPATIBLE_SAVED_GAME_VERSION ) 	{
-		int i;
+	if ( info.saved_game_version != 7 ) 	{
+		int i, found = 0;
 		
 		Assert( N_SAVE_SLOTS == 10 );
 
@@ -1485,11 +1484,15 @@ int read_player_file()
 				state_save_old_game(i, saved_games[i].name, &saved_games[i].player, 
              		saved_games[i].difficulty_level, saved_games[i].primary_weapon, 
           			saved_games[i].secondary_weapon, saved_games[i].next_level_num );
+          			// make sure we do not do this again, which would possibly overwrite
+          			// a new newstyle savegame
+          			saved_games[i].name[0] = 0;
+          			found++;
 			}
 		}
-		write_player_file();
+		if (found)
+			write_player_file();
 	}
-#endif
 
 	filename[strlen(filename) - 4] = 0;
 	strcat(filename, ".plx");
diff -up d1x/main/state.c.foo d1x/main/state.c
--- d1x/main/state.c.foo	2000-10-27 01:58:45.000000000 +0200
+++ d1x/main/state.c	2008-07-23 15:37:17.000000000 +0200
@@ -274,8 +274,6 @@ static char rcsid[] = "$Id: state.c,v 1.
 #include "gamefont.h"
 
 
-#ifndef SHAREWARE
-
 #define STATE_VERSION 7
 #define STATE_COMPATIBLE_VERSION 6
 // 0 - Put DGSS (Descent Game State Save) id at tof.
@@ -348,6 +346,7 @@ void state_callback(int nitems,newmenu_i
 //	}	
 }
 
+#if 0
 void rpad_string( char * string, int max_chars )
 {
 	int i, end_found;
@@ -362,6 +361,7 @@ void rpad_string( char * string, int max
 	}
 	*string = 0;		// NULL terminate
 }
+#endif
 
 int state_get_save_file(char * fname, char * dsc, int multi )
 {
@@ -577,8 +577,11 @@ int state_save_old_game(int slotnum, cha
 	fwrite( &temp_int, sizeof(int), 1, fp );
 
 // Save the mission info...
+#ifndef SHAREWARE
 	fwrite( &Mission_list[0], sizeof(char)*9, 1, fp );
-
+#else
+	fwrite( "\0\0\0\0\0\0\0\0", sizeof(char)*9, 1, fp );
+#endif
 //Save level info
 	temp_int = sg_player->level;
 	fwrite( &temp_int, sizeof(int), 1, fp );
@@ -625,6 +628,7 @@ int state_save_all(int between_levels)
 {
 	char filename[128], desc[DESC_LENGTH+1];
 
+#ifndef SHAREWARE
 	if ( Game_mode & GM_MULTI )	{
 #ifdef MULTI_SAVE
 		if ( FindArg( "-multisave" ) )
@@ -634,6 +638,7 @@ int state_save_all(int between_levels)
 			hud_message( MSGC_GAME_FEEDBACK, "Can't save in a multiplayer game!" );
 		return 0;
 	}
+#endif
 
 	mprintf(( 0, "CL=%d, NL=%d\n", Current_level_num, Next_level_num ));
 	
@@ -653,12 +658,14 @@ int state_save_all_sub(char *filename, c
 	FILE * fp;
 	grs_canvas * cnv;
 
+#ifndef SHAREWARE
 	if ( Game_mode & GM_MULTI )	{
 #ifdef MULTI_SAVE
 		if ( !FindArg( "-multisave" ) ) 
 #endif  
 			return 0;
 	}
+#endif
 
 	fp = fopen( filename, "wb" );
 	if ( !fp ) {
@@ -721,7 +728,11 @@ int state_save_all_sub(char *filename, c
 	fwrite( &between_levels, sizeof(int), 1, fp );
 
 // Save the mission info...
+#ifndef SHAREWARE
 	fwrite( &Mission_list[Current_mission_num], sizeof(char)*9, 1, fp );
+#else
+	fwrite( "\0\0\0\0\0\0\0\0", sizeof(char)*9, 1, fp );
+#endif
 
 //Save level info
 	fwrite( &Current_level_num, sizeof(int), 1, fp );
@@ -921,15 +932,32 @@ int state_restore_all_sub(char *filename
 // Read the mission info...
 	fread( mission, sizeof(char)*9, 1, fp );
 
+#ifndef SHAREWARE
 	if (!load_mission_by_name( mission ))	{
 		nm_messagebox( NULL, 1, "Ok", "Error!\nUnable to load mission\n'%s'\n", mission );
 		fclose(fp);
 		return 0;
 	}
+#else
+	if (mission[0]) {
+		nm_messagebox( NULL, 1, "Ok", "Error!\nCannot load mission '%s'\nThe shareware version only supports savegames of the shareware mission!", mission );
+		fclose(fp);
+		return 0;
+	}
+#endif
 
 //Read level info
 	fread( &current_level, sizeof(int), 1, fp );
 	fread( &next_level, sizeof(int), 1, fp );
+#ifdef SHAREWARE
+	if (current_level < 1 || current_level > Last_level ||
+		next_level < 0 || next_level > Last_level) {
+		nm_messagebox( NULL, 1, "Ok", "Error!\nCannot load level %d\nThe shareware version only supports savegames of shareware levels!",
+			between_levels? next_level:current_level);
+		fclose(fp);
+		return 0;
+	}
+#endif
 
 //Restore GameTime
 	fread( &GameTime, sizeof(fix), 1, fp );
@@ -1127,6 +1155,3 @@ RetryObjectLoading:
 
 	return 1;
 }
-
-
-#endif


--- NEW FILE d1x.spec ---
Summary:	Modified version of Descent 1
Name:		d1x
Version:	1.43
Release:	6%{?dist}
License:	non-commercial
Group:		Amusements/Games
Source0:	http://home.zonnet.nl/jwrdegoede/d1x143sc.tar.bz2
Source1:	http://home.zonnet.nl/jwrdegoede/d1swdf.tar.gz
Source2:	http://d1x.warpcore.org/files/d1bigfnt.zip
# first batch of patches, many many patches because upstream is dead.
Patch0:		%{name}-config.patch
Patch1:		%{name}-opt.patch
Patch2:		%{name}-fix.patch
Patch3:		%{name}-paths.patch
Patch4:		%{name}-maths.patch
Patch5:		%{name}-types.patch
Patch6:		%{name}-gcc3.patch
Patch7:		%{name}-joystick.patch
Patch8:		%{name}-assert.patch
Patch9:		%{name}-fixc.patch
Patch10:	%{name}-gcc34.patch
Patch11:	%{name}-shareware-fixes.patch
Patch12:	%{name}-cvs-fixes.patch
Patch13:	%{name}-miscfixes.patch
Patch14:	%{name}-cvs-fixes2.patch
Patch15:	%{name}-gnuasm.patch
Patch16:	%{name}-new-sdl.patch
# d1x has been revived as the dxx-rebirth project, I'm honored to say that they
# have used the livna SRPM's as a starting position and that their tarballs
# thus include all of the above patches. However there releases aren't all
# that stable so I've done a diff between 1.43 + all our above patches and
# their latest release (0.42), and cherry picked the good stuff (I hope):
Patch21:        d1x-rebirth-fixes.patch
Patch22:        d1x-rebirth-highresbrief.patch
Patch23:        d1x-rebirth-mode-handling.patch
Patch24:        d1x-rebirth-mouselook.patch
Patch25:        d1x-rebirth-ogl.patch
# these patches are fixes/improvements on top of the d1x-rebirth patches
Patch31:        d1x-post-rebirth-fixes.patch
Patch32:        d1x-fix-rebirth-ogl.patch
Patch33:        d1x-music.patch
Patch34:        d1x-help.patch
Patch35:        d1x-unixify.patch
Patch36:        d1x-store-res-in-plx.patch
Patch37:        d1x-playerfile-compat.patch
Patch38:        d1x-use-reg-save-in-sw.patch
Patch39:        d1x-playerfile-compat-fix.patch
# and patches added much later to keep things compiling with the latest gcc
Patch40:        d1x-gcc43.patch
URL:		http://d1x.warpcore.org/
BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires:	SDL-devel >= 1.1
BuildRequires:	mesa-libGL-devel mesa-libGLU-devel
%ifarch %{ix86}
BuildRequires:	nasm
%endif

%description
D1X is a modification of the Descent 1 source that was released by
Parallax. It's mostly compatible with the Descent 1 v1.5, both in
multiplayer and on the local machine.


%package full
Summary:	D1X - binaries for full version of game
Group:		Amusements/Games

%description full
D1X is a modification of the Descent 1 source that was released by
Parallax. It's mostly compatible with the Descent 1 v1.5, both in
multiplayer and on the local machine.

This package contains D1X binaries for the full (registered/commercial) version
of the game. You will need to place the full version data-files in
/usr/share/%{name}/full .


%package shareware
Summary:	D1X - binaries for shareware version of game
Group:		Amusements/Games

%description shareware
D1X is a modification of the Descent 1 source that was released by
Parallax. It's mostly compatible with the Descent 1 v1.5, both in
multiplayer and on the local machine.

This package contains D1X binaries and data-files for the shareware version of
the game.


%prep
%setup -q -n %{name}
# lots of patches, so no backups as those are useless, since some files
# get patched many times.
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1

%patch21 -p1 
%patch22 -p1
%patch23 -p1
%patch24 -p1
# patch25 is opengl only and gets applied after building the non ogl version.

%patch31 -p1
# patch32 is opengl only and gets applied after building the non ogl version.
%patch33 -p1 -E
%patch34 -p1
%patch35 -p1
%patch36 -p1
%patch37 -p1
%patch38 -p1
%patch39 -p1

%patch40 -p1


%build
mkdir -p lib
echo "DEBUGABLE = 1" >> defines.in
%ifnarch %{ix86}
echo "NO_ASM = 1" >> defines.in
%endif
%ifarch sparc sparc64
echo "BIGENDIAN = 1" >> defines.in
%endif

cp defines.in defines.mak
echo "SDL_IO = 1" >> defines.mak
make	CC="%{__cc}" \
	CXX="%{__cxx}" \
	OPTFLAGS="$RPM_OPT_FLAGS \
	-DD1XDATAPATH=\\\"%{_datadir}/%{name}/full/\\\""
mv d1x143 d1x-sdl-full

make clean
echo "SHAREWARE = 1" >> defines.mak
make	CC="%{__cc}" \
	CXX="%{__cxx}" \
	OPTFLAGS="$RPM_OPT_FLAGS \
	-DD1XDATAPATH=\\\"%{_datadir}/%{name}/d1shar/\\\""
mv d1x143sh d1x-sdl-share

# this patch isn't applied until now as this makes some huge video changes
# (d1x-rebirth scalable cockpit code) which seem to break (cause crashes in) 
# the software renderer
patch -p1 < %{PATCH25}
patch -p1 < %{PATCH32}
make clean
cp -f defines.in defines.mak
echo "SDLGL_IO = 1" >> defines.mak
make	CC="%{__cc}" \
	CXX="%{__cxx}" \
	LFLAGS="-L/usr/X11R6/%{_lib}" \
	OPTFLAGS="$RPM_OPT_FLAGS \
	-DD1XDATAPATH=\\\"%{_datadir}/%{name}/full/\\\""
mv d1x143_ogl d1x-gl-full

make clean
echo "SHAREWARE = 1" >> defines.mak
make	CC="%{__cc}" \
	CXX="%{__cxx}" \
	LFLAGS="-L/usr/X11R6/%{_lib}" \
	OPTFLAGS="$RPM_OPT_FLAGS \
	-DD1XDATAPATH=\\\"%{_datadir}/%{name}/d1shar/\\\""
mv d1x143sh_ogl d1x-gl-share


%install
rm -rf $RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT%{_bindir}
install -d $RPM_BUILD_ROOT%{_datadir}/d1x
install -d $RPM_BUILD_ROOT%{_datadir}/d1x/full
install -d $RPM_BUILD_ROOT%{_datadir}/d1x/d1shar
install d1x-*-* $RPM_BUILD_ROOT%{_bindir}
tar x -z -C $RPM_BUILD_ROOT%{_datadir}/d1x -f %{SOURCE1}
unzip -d $RPM_BUILD_ROOT%{_datadir}/d1x/d1shar %{SOURCE2}
unzip -d $RPM_BUILD_ROOT%{_datadir}/d1x/full   %{SOURCE2}


%clean
rm -rf $RPM_BUILD_ROOT


%files full
%defattr(644,root,root,755)
%attr(755,root,root) %{_bindir}/d1x-sdl-full
%attr(755,root,root) %{_bindir}/d1x-gl-full
%{_datadir}/d1x/full/*
%doc bugs.txt d1x.faq d1x.ini d1x.txt d1x140.txt license.txt readme.d1x readme.org todo.txt
%dir %{_datadir}/d1x
%dir %{_datadir}/d1x/full

%files shareware
%defattr(644,root,root,755)
%attr(755,root,root) %{_bindir}/d1x-sdl-share
%attr(755,root,root) %{_bindir}/d1x-gl-share
%{_datadir}/d1x/d1shar/*
%doc bugs.txt d1x.faq d1x.ini d1x.txt d1x140.txt license.txt readme.d1x readme.org todo.txt
%dir %{_datadir}/d1x
%dir %{_datadir}/d1x/d1shar


%changelog
* Wed Jul 23 2008 Hans de Goede <j.w.r.degoede at hhs.nl> 1.43-6
- Release bump for rpmfusion build

* Sat Oct 14 2006 Hans de Goede <j.w.r.degoede at hhs.nl> 1.43-5
- Fix reading of player file (playerfile compat code) when using addon missions

* Tue Sep 26 2006 Hans de Goede <j.w.r.degoede at hhs.nl> 1.43-4
- Fix building with newer SDL lib which is not directly linked against libX11

* Sun Sep 24 2006 Hans de Goede <j.w.r.degoede at hhs.nl> 1.43-3
- Rebuild for FC-6
- Tried switching to d1x-rebirth sources but didn't because they are unstable
  instead the following d1x-rebirth features were lifted:
  -scaleable cockpits in opengl mode
  -support for highres briefingscreens (download them from the dxx-rebirth web)
  -mouselook support
  -16:9 monitor support
  -store the resolution you're playing at in playername.dlx
- Add/restore music playback, now you can enjoy the original descent music!
- The player and other descent config files are now stored in ~/.d1x, so
  if you've got a player you want to keep move its files to ~/.d1x
- The shareware version now uses the same game load/save code as the registered
  version allowing in game saving (ALT-F2 saves, ALT-F3 restores)
- The shareware version can now properly read player files written by the
  registered version and vica versa

* Sat Mar 18 2006 Thorsten Leemhuis <fedora[AT]leemhuis.info> 1.43-2
- Increase release after fixing BRs once more

* Fri Mar 17 2006 Hans de Goede <j.w.r.degoede at hhs.nl> 1.43-1
- Fix BuidRequires for FC-5  

* Thu Mar 09 2006 Andreas Bierfert <andreas.bierfert[AT]lowlatency.de>
- switch to new release field

* Tue Feb 28 2006 Andreas Bierfert <andreas.bierfert[AT]lowlatency.de>
- add dist

* Wed Aug 10 2005 Hans de Goede <j.w.r.degoede at hhs.nl> 1.43-0.lvn.4
- Remove -Wno-pointer-sign from CFLAGS, this option is not valid for gcc 3.4 .

* Sun Aug  7 2005 Hans de Goede <j.w.r.degoede at hhs.nl> 1.43-0.lvn.3
- Drop Patch 13, intergrate into Patch 0.
- Add new Patch 13 which introduces some fixes from CVS.
- Added Patch 14 which fixes:
  -a few buffer overflows caught by gcc 4 and an uninitialised var warning.
  -the sliders in the menus with newer gcc / glibc
   (or x86_64, but doesn't seem 64 bit related)
  -the 2 initial screens with opengl
  -made /usr/share/d1x/d1shar or /full the default mission dir
  -don't use descent2 fonts, these aren't in the hog file instead use fonts
   from d1bigfnt.zip .
- Add d1bigfnt.zip and install the fonts in /usr/share/d1x/d1shar or /full.
- Build without -fomit-framepointer to allow debugging (DEBUGABLE = 1).
- Add Patch 15 to fix i386 (asm) compile.

* Mon Apr 29 2005 Hans de Goede <j.w.r.degoede at hhs.nl> 1.43-0.lvn.2
- Added Patch 13 which fixes compilation with gcc4

* Mon Jan  3 2005 Hans de Goede <j.w.r.degoede at hhs.nl> 1.43-0.lvn.1
- First Livna release, based on PLD SRPM.
- Patches 0-10 are from PLD, have been reviewed and are all compilation fixes.
- Patch 11 fixes 2 issues with the shareware version:
  -Pressing F1 no longer causes a segfault.
  -Saving now works.
- Patch 12 brings in various fixes from the d1x cvs version.
- Plans:
  -Save settings/games in ~/.d1x instead of in wd.
  -Search for custom levels in %{_datadir}/d1x/full,~/.d1x and a
   user configurable dir.
  -Fix/add music playback.
  -DesktopEntries


Index: .cvsignore
===================================================================
RCS file: /cvs/nonfree/rpms/d1x/F-8/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .cvsignore	22 Jul 2008 16:39:59 -0000	1.1
+++ .cvsignore	23 Jul 2008 14:28:10 -0000	1.2
@@ -0,0 +1,3 @@
+d1bigfnt.zip
+d1swdf.tar.gz
+d1x143sc.tar.bz2


Index: sources
===================================================================
RCS file: /cvs/nonfree/rpms/d1x/F-8/sources,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sources	22 Jul 2008 16:39:59 -0000	1.1
+++ sources	23 Jul 2008 14:28:10 -0000	1.2
@@ -0,0 +1,3 @@
+3f8a1337c32f43eb23dde07112ec92c0  d1bigfnt.zip
+8112d6127a7a81a36735f5a9c3175ec2  d1swdf.tar.gz
+fb52fd2990b2fadcea804238be648e53  d1x143sc.tar.bz2



More information about the rpmfusion-commits mailing list