Fixes for SDL and VisualC.
authorFlorian Schulze <crow@icculus.org>
Wed, 13 Feb 2002 17:45:34 +0000 (17:45 +0000)
committerFlorian Schulze <crow@icculus.org>
Wed, 13 Feb 2002 17:45:34 +0000 (17:45 +0000)
12 files changed:
VisualC6/jumpnbump.dsp [new file with mode: 0644]
VisualC6/jumpnbump.dsw [new file with mode: 0644]
config.h
dj.h
dos/gfx.c
globals.h
indent.txt [new file with mode: 0644]
main.c
menu.c
sdl/gfx.c [new file with mode: 0644]
sdl/interrpt.c [new file with mode: 0644]
sdl/sound.c [new file with mode: 0644]

diff --git a/VisualC6/jumpnbump.dsp b/VisualC6/jumpnbump.dsp
new file mode 100644 (file)
index 0000000..fb398d4
--- /dev/null
@@ -0,0 +1,135 @@
+# Microsoft Developer Studio Project File - Name="jumpnbump" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** NICHT BEARBEITEN **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=jumpnbump - Win32 Debug
+!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE
+!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl
+!MESSAGE 
+!MESSAGE NMAKE /f "jumpnbump.mak".
+!MESSAGE 
+!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben
+!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel:
+!MESSAGE 
+!MESSAGE NMAKE /f "jumpnbump.mak" CFG="jumpnbump - Win32 Debug"
+!MESSAGE 
+!MESSAGE Für die Konfiguration stehen zur Auswahl:
+!MESSAGE 
+!MESSAGE "jumpnbump - Win32 Release" (basierend auf  "Win32 (x86) Application")
+!MESSAGE "jumpnbump - Win32 Debug" (basierend auf  "Win32 (x86) Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "jumpnbump - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "USE_SDL" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x407 /d "NDEBUG"
+# ADD RSC /l 0x407 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib SDLmain.lib SDL.lib SDL_mixer.lib /nologo /subsystem:windows /machine:I386
+
+!ELSEIF  "$(CFG)" == "jumpnbump - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "USE_SDL" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x407 /d "_DEBUG"
+# ADD RSC /l 0x407 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib SDLmain.lib SDL.lib SDL_mixer.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+
+!ENDIF 
+
+# Begin Target
+
+# Name "jumpnbump - Win32 Release"
+# Name "jumpnbump - Win32 Debug"
+# Begin Group "Quellcodedateien"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\sdl\gfx.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\sdl\interrpt.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\main.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\menu.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\sdl\sound.c
+# End Source File
+# End Group
+# Begin Group "Header-Dateien"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\config.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\dj.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\globals.h
+# End Source File
+# End Group
+# Begin Group "Ressourcendateien"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/VisualC6/jumpnbump.dsw b/VisualC6/jumpnbump.dsw
new file mode 100644 (file)
index 0000000..97b55b4
--- /dev/null
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN!
+
+###############################################################################
+
+Project: "jumpnbump"=.\jumpnbump.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
index 3362079..d96bcfa 100644 (file)
--- a/config.h
+++ b/config.h
@@ -1,14 +1,7 @@
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
-#undef DOS
-
-#ifndef DOS
-# define LINUX
-#endif
-
-#ifdef LINUX
-# define NOSOUND
+#ifdef USE_SDL
 # define JNB_WIDTH 400
 # define JNB_HEIGHT 256
 #endif
diff --git a/dj.h b/dj.h
index d071cc8..07b2fc8 100644 (file)
--- a/dj.h
+++ b/dj.h
@@ -1,10 +1,13 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <conio.h>
+
+#ifdef DOS
 #include <pc.h>
 #include <dpmi.h>
 #include <go32.h>
 #include <sys/nearptr.h>
+#endif
 
 #define DJ_SD_TYPE_NOSOUND 0
 #define DJ_SD_TYPE_SBLASTER 1
index 836ee54..63dad5f 100644 (file)
--- a/dos/gfx.c
+++ b/dos/gfx.c
@@ -132,17 +132,17 @@ void put_text(char page, int x, int y, char *text, char align)
                        image = t1 - 49;
                else if (t1 == '~')
                        image = 74;
-               else if (t1 == '\84')
+               else if (t1 == 0x84)
                        image = 75;
-               else if (t1 == '\86')
+               else if (t1 == 0x86)
                        image = 76;
-               else if (t1 == '\8e')
+               else if (t1 == 0x8e)
                        image = 77;
-               else if (t1 == '\8f')
+               else if (t1 == 0x8f)
                        image = 78;
-               else if (t1 == '\94')
+               else if (t1 == 0x94)
                        image = 79;
-               else if (t1 == '\99')
+               else if (t1 == 0x99)
                        image = 80;
                else
                        continue;
index 7a29f0c..b1701e4 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -6,7 +6,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#ifndef _MSC_VER
 #include <strings.h>
+#endif
 #include <time.h>
 #include <math.h>
 #include <dj.h>
 # include <pc.h>
 #endif
 
-#ifdef USE_SDL
+#ifdef _MSC_VER
 # include <sys/stat.h>
-# include <SDL/SDL.h>
-# include <SDL/SDL_mixer.h>
+# include <io.h>
+# include <SDL.h>
+# include <SDL_mixer.h>
+#else
+# ifdef USE_SDL
+#  include <sys/stat.h>
+#  include <SDL/SDL.h>
+#  include <SDL/SDL_mixer.h>
+# endif
 #endif
 
 #ifndef USE_SDL
@@ -164,7 +173,7 @@ void position_player(short player_num);
 void fireworks(void);
 void add_object(char type, short x, short y, long x_add, long y_add, short anim, short frame);
 void update_objects(void);
-char add_pob(char page, short x, short y, short image, char *pob_data);
+char add_pob(int page, short x, short y, short image, char *pob_data);
 void draw_pobs(int page);
 void redraw_pob_backgrounds(int page);
 char add_leftovers(int page, short x, short y, short image, char *pob_data);
@@ -212,13 +221,16 @@ char read_pcx(FILE * handle, char *buffer, long buf_len, char *pal);
 void get_block(char page, long x, long y, long width, long height, char *buffer);
 void put_block(char page, long x, long y, long width, long height, char *buffer);
 
-#ifdef LINUX
+#ifdef USE_SDL
+#ifndef _MSC_VER
 long filelength(int handle);
+#endif
 void setpalette(int index, int count, char *palette);
 void fillpalette(int red, int green, int blue);
 void flippage(long page);
 void fs_toggle();
 char *get_vgaptr(long, long, long);
+char intr_sysupdate();
 #endif
 
 /* interrpt.c */
@@ -229,18 +241,9 @@ char hook_keyb_handler(void);
 void remove_keyb_handler(void);
 char key_pressed(unsigned char key);
 
-#ifdef LINUX
-char intr_sysupdate();
-#endif
-
 /* sound-linux.c */
 #ifdef LINUX
 
-void load_song(FILE *, signed int);
-void play_song();
-void update_song();
-void initsound();
-void songquit();
 
 #endif
 
diff --git a/indent.txt b/indent.txt
new file mode 100644 (file)
index 0000000..fe87cd3
--- /dev/null
@@ -0,0 +1 @@
+indent -kr -i8 -l1000 -lps -nhnl
diff --git a/main.c b/main.c
index dee1bd1..ae36572 100644 (file)
--- a/main.c
+++ b/main.c
@@ -5,6 +5,10 @@
 __dpmi_regs regs;
 #endif
 
+#ifndef M_PI
+#define M_PI           3.14159265358979323846
+#endif
+
 char *object_gobs;
 char *number_gobs;
 
@@ -811,7 +815,7 @@ void steer_players(void)
 
                                if ((c1 == 0 && ((key_pressed(KEY_PL1_LEFT) == 1 && key_pressed(KEY_PL1_RIGHT) == 1))) || (c1 == 1 && ((key_pressed(KEY_PL2_LEFT) == 1 && key_pressed(KEY_PL2_RIGHT) == 1))) || (c1 == 2 && ((key_pressed(KEY_PL3_LEFT) == 1 && key_pressed(KEY_PL3_RIGHT) == 1))) || (c1 == 3 && ((key_pressed(KEY_PL4_LEFT) == 1 && key_pressed(KEY_PL4_RIGHT) == 1)))) {
                                        if (player[c1].direction == 0) {
-                                               if ((c1 == 0 && key_pressed(KEY_PL1_RIGHT) == 1) || (c1 == 1 && key_pressed(KEY_PL2_RIGHT) == 1) || (c1 == 2 && key_pressed(KEY_PL3_RIGHT) == 1) || (c1 == 3 && key_pressed(KEY_PL4_RIGHT) == 1 mouse.but2 == 1)) {
+                                               if ((c1 == 0 && key_pressed(KEY_PL1_RIGHT) == 1) || (c1 == 1 && key_pressed(KEY_PL2_RIGHT) == 1) || (c1 == 2 && key_pressed(KEY_PL3_RIGHT) == 1) || (c1 == 3 && key_pressed(KEY_PL4_RIGHT) == 1)) {
                                                        s1 = (player[c1].x >> 16);
                                                        s2 = (player[c1].y >> 16);
                                                        if (ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 3) {
@@ -2008,6 +2012,7 @@ char init_program(int argc, char *argv[])
        int c1 = 0, c2 = 0;
        char load_flag = 0;
        char force2, force3;
+       sfx_data fly;
        int player_anim_data[] = {
                1, 0, 0, 0x7fff, 0, 0, 0, 0, 0, 0,
                4, 0, 0, 4, 1, 4, 2, 4, 3, 4,
@@ -2404,9 +2409,6 @@ void deinit_program(void)
 #ifdef DOS
        regs.x.ax = 0x3;
        __dpmi_int(0x10, &regs);
-#else
-       songquit();
-       SDL_Quit();
 #endif
 
        if (main_info.error_str[0] != 0) {
diff --git a/menu.c b/menu.c
index 0a36524..689189b 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -450,8 +450,9 @@ char menu(void)
                                outportw(0x3c4, 0x0f02);
                                memset((char *) (0xa0000 + 220 * 100 + __djgpp_conventional_base), 0, 2000);
                                memset((char *) (0xa0000 + 32768 + 220 * 100 + __djgpp_conventional_base), 0, 2000);
-                               /* clear 5 lines at x=0,y=220 in front and backbuffer */
-                               */memset((void *) get_vgaptr(0, 0, 220), 0, 8000);
+                               // clear 20 lines at x=0,y=220 in front and backbuffer
+*/
+                               memset((void *) get_vgaptr(0, 0, 220), 0, 8000);
 
                                cur_message++;
                                if (cur_message >= NUM_MESSAGES)
@@ -486,7 +487,7 @@ char menu(void)
                main_info.draw_page ^= 1;
                main_info.view_page ^= 1;
 
-#ifndef LINUX
+#ifdef DOS
                outportw(0x3d4, (main_info.view_page << 23) + 0x0d);
                outportw(0x3d4, ((main_info.view_page << 15) & 0xff00) + 0x0c);
 #else
diff --git a/sdl/gfx.c b/sdl/gfx.c
new file mode 100644 (file)
index 0000000..0b668b8
--- /dev/null
+++ b/sdl/gfx.c
@@ -0,0 +1,509 @@
+#include "globals.h"
+
+#define JNB_BPP 8
+static SDL_Surface *jnb_surface, *jnb_surface_page1;
+static int fullscreen = 0;
+static int vinited = 0;
+
+void open_screen(void)
+{
+       int lval = 0;
+
+       lval = SDL_Init(SDL_INIT_EVERYTHING | SDL_INIT_AUDIO);
+       if (lval < 0) {
+               fprintf(stderr, "SDL ERROR: %s\n", SDL_GetError());
+               exit(EXIT_FAILURE);
+       }
+
+       jnb_surface = SDL_SetVideoMode(JNB_WIDTH, JNB_HEIGHT, JNB_BPP, SDL_HWSURFACE | SDL_DOUBLEBUF);
+       if (!jnb_surface) {
+               fprintf(stderr, "SDL ERROR: %s\n", SDL_GetError());
+               exit(EXIT_FAILURE);
+       }
+
+       jnb_surface_page1 = SDL_CreateRGBSurface(SDL_HWSURFACE, JNB_WIDTH, JNB_HEIGHT, JNB_BPP, 0, 0, 0, 0);
+       if (!jnb_surface_page1) {
+               fprintf(stderr, "SDL ERROR: %s\n", SDL_GetError());
+               exit(EXIT_FAILURE);
+       }
+
+       SDL_ShowCursor(0);
+
+       if (fullscreen) {
+               lval = SDL_WM_ToggleFullScreen(jnb_surface);
+               if (lval != 1) {
+                       fprintf(stderr, "SDL WARNING: %s\n", SDL_GetError());
+                       fullscreen = 0;
+               }
+       }
+
+       vinited = 1;
+
+       return;
+}
+
+void fs_toggle()
+{
+       if (!vinited) {
+               fullscreen ^= 1;
+               return;
+       }
+       if (SDL_WM_ToggleFullScreen(jnb_surface))
+               fullscreen ^= 1;
+}
+
+void wait_vrt(void)
+{
+       return;
+}
+
+void flippage(long page)
+{
+       SDL_Surface *which;
+
+       which = (page == 1) ? jnb_surface_page1 : jnb_surface;
+
+       SDL_UpdateRect(which, 0, 0, 0, 0);
+}
+
+char *get_vgaptr(long page, long x, long y)
+{
+       SDL_Surface *which;
+
+       which = (page == 1) ? jnb_surface_page1 : jnb_surface;
+
+       return (char *) &(((char *) which->pixels)[(y * JNB_WIDTH) + x]);
+}
+
+void setpalette(int index, int count, char *palette)
+{
+       SDL_Color colors[256];
+       int i;
+
+       for (i = 0; i < count; i++) {
+               colors[i].r = palette[i * 3 + 0] << 2;
+               colors[i].g = palette[i * 3 + 1] << 2;
+               colors[i].b = palette[i * 3 + 2] << 2;
+       }
+       SDL_SetColors(jnb_surface, colors, index, count);
+       SDL_SetColors(jnb_surface_page1, colors, index, count);
+}
+
+void fillpalette(int red, int green, int blue)
+{
+       SDL_Color colors[256];
+       int i;
+
+       for (i = 0; i < 256; i++) {
+               colors[i].r = red << 2;
+               colors[i].g = green << 2;
+               colors[i].b = blue << 2;
+       }
+       SDL_SetColors(jnb_surface, colors, 0, 256);
+       SDL_SetColors(jnb_surface_page1, colors, 0, 256);
+}
+
+void get_block(char page, long x, long y, long width, long height, char *buffer)
+{
+       short w, h;
+       char *buffer_ptr, *vga_ptr;
+
+       if (x < 0)
+               x = 0;
+       if (y < 0)
+               y = 0;
+       if (y + height >= JNB_HEIGHT)
+               height = JNB_HEIGHT - y;
+       if (x + width >= JNB_WIDTH)
+               width = JNB_WIDTH - x;
+
+       for (h = 0; h < height; h++) {
+               buffer_ptr = &buffer[h * width];
+
+               vga_ptr = get_vgaptr(page, x, h + y);
+
+               for (w = 0; w < width; w++) {
+                       unsigned char ch;
+                       ch = *vga_ptr;
+                       *buffer_ptr = ch;
+                       buffer_ptr++;
+                       vga_ptr++;
+               }
+       }
+
+}
+
+void put_block(char page, long x, long y, long width, long height, char *buffer)
+{
+       short w, h;
+       char *vga_ptr, *buffer_ptr;
+
+       if (x < 0)
+               x = 0;
+       if (y < 0)
+               y = 0;
+       if (y + height >= JNB_HEIGHT)
+               height = JNB_HEIGHT - y;
+       if (x + width >= JNB_WIDTH)
+               width = JNB_WIDTH - x;
+
+       for (h = 0; h < height; h++) {
+               vga_ptr = get_vgaptr(page, x, y + h);
+
+               buffer_ptr = &buffer[h * width];
+               for (w = 0; w < width; w++) {
+                       *vga_ptr = *buffer_ptr;
+                       vga_ptr++;
+                       buffer_ptr++;
+               }
+       }
+}
+
+void put_text(char page, int x, int y, char *text, char align)
+{
+       int c1;
+       int t1;
+       int width;
+       int cur_x;
+       int image;
+
+       if (text == NULL || strlen(text) == 0)
+               return;
+       if (font_gobs == NULL)
+               return;
+
+       width = 0;
+       c1 = 0;
+       while (text[c1] != 0) {
+               t1 = text[c1];
+               c1++;
+               if (t1 == ' ') {
+                       width += 5;
+                       continue;
+               }
+               if (t1 >= 33 && t1 <= 34)
+                       image = t1 - 33;
+
+               else if (t1 >= 39 && t1 <= 41)
+                       image = t1 - 37;
+
+               else if (t1 >= 44 && t1 <= 59)
+                       image = t1 - 39;
+
+               else if (t1 >= 64 && t1 <= 90)
+                       image = t1 - 43;
+
+               else if (t1 >= 97 && t1 <= 122)
+                       image = t1 - 49;
+
+               else if (t1 == '~')
+                       image = 74;
+
+               else if (t1 == 0x84)
+                       image = 75;
+
+               else if (t1 == 0x86)
+                       image = 76;
+
+               else if (t1 == 0x8e)
+                       image = 77;
+
+               else if (t1 == 0x8f)
+                       image = 78;
+
+               else if (t1 == 0x94)
+                       image = 79;
+
+               else if (t1 == 0x99)
+                       image = 80;
+               else
+                       continue;
+               width += pob_width(image, font_gobs) + 1;
+       }
+
+       switch (align) {
+       case 0:
+               cur_x = x;
+               break;
+       case 1:
+               cur_x = x - width;
+               break;
+       case 2:
+               cur_x = x - width / 2;
+               break;
+       default:
+               cur_x = 0;      /* this should cause error? -Chuck */
+               break;
+       }
+       c1 = 0;
+
+       while (text[c1] != 0) {
+               t1 = text[c1];
+               c1++;
+               if (t1 == ' ') {
+                       cur_x += 5;
+                       continue;
+               }
+               if (t1 >= 33 && t1 <= 34)
+                       image = t1 - 33;
+
+               else if (t1 >= 39 && t1 <= 41)
+                       image = t1 - 37;
+
+               else if (t1 >= 44 && t1 <= 59)
+                       image = t1 - 39;
+
+               else if (t1 >= 64 && t1 <= 90)
+                       image = t1 - 43;
+
+               else if (t1 >= 97 && t1 <= 122)
+                       image = t1 - 49;
+
+               else if (t1 == '~')
+                       image = 74;
+
+               else if (t1 == '\84')
+                       image = 75;
+
+               else if (t1 == '\86')
+                       image = 76;
+
+               else if (t1 == '\8e')
+                       image = 77;
+
+               else if (t1 == '\8f')
+                       image = 78;
+
+               else if (t1 == '\94')
+                       image = 79;
+
+               else if (t1 == '\99')
+                       image = 80;
+
+               else
+                       continue;
+               put_pob(page, cur_x, y, image, font_gobs, 1, mask_pic);
+               cur_x += pob_width(image, font_gobs) + 1;
+       }
+}
+
+void put_pob(char page, short x, short y, short image, char *pob_data, char mask, char *mask_pic)
+{
+       long c1, c2;
+       long pob_offset;
+       char *pob_ptr, *vga_ptr, *mask_ptr;
+       long width, height;
+       long draw_width, draw_height;
+       char colour;
+
+       if (image < 0 || image >= *(short *) (pob_data))
+               return;
+
+       vga_ptr = get_vgaptr(page, 0, 0);
+       pob_offset = *(unsigned long *) (pob_data + (image * 4) + 2);
+       width = draw_width = *(short *) (pob_data + pob_offset);
+       height = draw_height = *(short *) (pob_data + pob_offset + 2);
+       x -= *(short *) (pob_data + pob_offset + 4);
+       y -= *(short *) (pob_data + pob_offset + 6);
+       pob_offset += 8;
+       if ((x + width) <= 0 || x >= 400)
+               return;
+       if ((y + height) <= 0 || y >= 256)
+               return;
+       if (x < 0) {
+               pob_offset -= x;
+               draw_width += x;
+               x = 0;
+       }
+       if ((x + width) > 400)
+               draw_width -= x + width - 400;
+       if (y < 0) {
+               pob_offset += -y * width;
+               draw_height -= -y;
+               y = 0;
+       }
+       if ((y + height) > 256)
+               draw_height -= y + height - 256;
+
+       pob_ptr = &pob_data[pob_offset];
+
+
+#ifndef USE_SDL
+       vga_ptr = (char *) (0xa0000 + (long) (page << 15) + (long) y * 100L + ((x + c3) >> 2) + __djgpp_conventional_base);
+#else
+       vga_ptr = get_vgaptr(page, x, y);
+#endif
+       mask_ptr = (char *) (mask_pic + (y * 400) + x);
+       for (c1 = 0; c1 < draw_height; c1++) {
+               for (c2 = 0; c2 < draw_width; c2++) {
+                       colour = *mask_ptr;
+                       if (mask == 0 || (mask == 1 && colour == 0)) {
+                               colour = *pob_ptr;
+                               if (colour != 0)
+                                       *vga_ptr = colour;
+                       }
+                       pob_ptr++;
+                       vga_ptr++;
+                       mask_ptr++;
+               }
+               pob_ptr += width - c2;
+               vga_ptr += (400 - c2);
+               mask_ptr += (400 - c2);
+       }
+}
+
+char pob_col(short x1, short y1, short image1, char *pob_data1, short x2, short y2, short image2, char *pob_data2)
+{
+       short c1, c2;
+       long pob_offset1, pob_offset2;
+       short width1, width2;
+       short height1, height2;
+       short check_width, check_height;
+       char *pob_ptr1, *pob_ptr2;
+
+       pob_offset1 = *(long *) (pob_data1 + image1 * 4 + 2);
+       width1 = *(short *) (pob_data1 + pob_offset1);
+       height1 = *(short *) (pob_data1 + pob_offset1 + 2);
+       x1 -= *(short *) (pob_data1 + pob_offset1 + 4);
+       y1 -= *(short *) (pob_data1 + pob_offset1 + 6);
+       pob_offset1 += 8;
+       pob_offset2 = *(long *) (pob_data2 + image2 * 4 + 2);
+       width2 = *(short *) (pob_data2 + pob_offset2);
+       height2 = *(short *) (pob_data2 + pob_offset2 + 2);
+       x2 -= *(short *) (pob_data2 + pob_offset2 + 4);
+       y2 -= *(short *) (pob_data2 + pob_offset2 + 6);
+       pob_offset2 += 8;
+
+       if (x1 < x2) {
+               if ((x1 + width1) <= x2)
+                       return 0;
+
+               else if ((x1 + width1) <= (x2 + width2)) {
+                       pob_offset1 += x2 - x1;
+                       check_width = x1 + width1 - x2;
+               }
+
+               else {
+                       pob_offset1 += x2 - x1;
+                       check_width = width2;
+               }
+       }
+
+       else {
+               if ((x2 + width2) <= x1)
+                       return 0;
+
+               else if ((x2 + width2) <= (x1 + width1)) {
+                       pob_offset2 += x1 - x2;
+                       check_width = x2 + width2 - x1;
+               }
+
+               else {
+                       pob_offset2 += x1 - x2;
+                       check_width = width1;
+               }
+       }
+       if (y1 < y2) {
+               if ((y1 + height1) <= y2)
+                       return 0;
+
+               else if ((y1 + height1) <= (y2 + height2)) {
+                       pob_offset1 += (y2 - y1) * width1;
+                       check_height = y1 + height1 - y2;
+               }
+
+               else {
+                       pob_offset1 += (y2 - y1) * width1;
+                       check_height = height2;
+               }
+       }
+
+       else {
+               if ((y2 + height2) <= y1)
+                       return 0;
+
+               else if ((y2 + height2) <= (y1 + height1)) {
+                       pob_offset2 += (y1 - y2) * width2;
+                       check_height = y2 + height2 - y1;
+               }
+
+               else {
+                       pob_offset2 += (y1 - y2) * width2;
+                       check_height = height1;
+               }
+       }
+       pob_ptr1 = (char *) (pob_data1 + pob_offset1);
+       pob_ptr2 = (char *) (pob_data2 + pob_offset2);
+       for (c1 = 0; c1 < check_height; c1++) {
+               for (c2 = 0; c2 < check_width; c2++) {
+                       if (*pob_ptr1 != 0 && *pob_ptr2 != 0)
+                               return 1;
+                       pob_ptr1++;
+                       pob_ptr2++;
+               }
+               pob_ptr1 += width1 - check_width;
+               pob_ptr2 += width2 - check_width;
+       }
+       return 0;
+}
+
+short pob_width(short image, char *pob_data)
+{
+       return *(short *) (pob_data + *(long *) (pob_data + image * 4 + 2));
+}
+
+short pob_height(short image, char *pob_data)
+{
+       return *(short *) (pob_data + *(long *) (pob_data + image * 4 + 2) + 2);
+}
+
+short pob_hs_x(short image, char *pob_data)
+{
+       return *(short *) (pob_data + *(long *) (pob_data + image * 4 + 2) + 4);
+}
+
+short pob_hs_y(short image, char *pob_data)
+{
+       return *(short *) (pob_data + *(long *) (pob_data + image * 4 + 2) + 6);
+}
+
+char read_pcx(FILE * handle, char *buffer, long buf_len, char *pal)
+{
+       short c1;
+       short a, b;
+       long ofs1;
+       if (buffer != 0) {
+               fseek(handle, 128, SEEK_CUR);
+               ofs1 = 0;
+               while (ofs1 < buf_len) {
+                       a = fgetc(handle);
+                       if ((a & 0xc0) == 0xc0) {
+                               b = fgetc(handle);
+                               a &= 0x3f;
+                               for (c1 = 0; c1 < a && ofs1 < buf_len; c1++)
+                                       buffer[ofs1++] = (char) b;
+                       } else
+                               buffer[ofs1++] = (char) a;
+               }
+               if (pal != 0) {
+                       fseek(handle, 1, SEEK_CUR);
+                       for (c1 = 0; c1 < 768; c1++)
+                               pal[c1] = fgetc(handle) >> 2;
+               }
+       }
+       return 0;
+}
+
+#ifndef _MSC_VER
+long filelength(int handle)
+{
+       struct stat buf;
+
+       if (fstat(handle, &buf) == -1) {
+               perror("filelength");
+               exit(EXIT_FAILURE);
+       }
+
+       return buf.st_size;
+}
+#endif
diff --git a/sdl/interrpt.c b/sdl/interrpt.c
new file mode 100644 (file)
index 0000000..013f7ee
--- /dev/null
@@ -0,0 +1,207 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#ifndef _MSC_VER
+#include <unistd.h>
+#endif
+#include "globals.h"
+
+
+struct {
+       char enabled;
+} keyb_handler_info;
+
+volatile char keyb[256];
+char last_keys[50];
+
+unsigned char scancode2ascii[256] = {
+       0, 0, 49, 50, 51, 52, 53, 54, 55, 56,           /* 0-9 */
+       57, 48, 45, 0, 0, 0, 113, 119, 101, 114,        /* 10-19 */
+       116, 121, 117, 105, 111, 112, 0, 0, 0, 0,       /* 20-29 */
+       97, 115, 100, 102, 103, 104, 106, 107, 108, 0,  /* 30-39 */
+       0, 0, 0, 0, 122, 120, 99, 118, 98, 110,         /* 40-49 */
+       109, 44, 46, 47, 0, 0, 0, 32, 0, 0,             /* 50-59 */
+       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,
+       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,
+       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
+};
+
+#ifndef USE_SDL
+_go32_dpmi_seginfo old_keyb_handler_seginfo, new_keyb_handler_seginfo;
+#endif
+
+void keyb_handler()
+{
+       unsigned char key;
+       static char extended;
+       int c1;
+
+       key = 0;
+#ifndef USE_SDL
+       key = inportb(0x60);
+#endif
+
+       if (key == 0xe0)
+               extended = 1;
+       else {
+               if (extended == 0) {
+                       if ((key & 0x80) == 0) {
+                               keyb[key & 0x7f] = 1;
+                               for (c1 = 48; c1 > 0; c1--)
+                                       last_keys[c1] = last_keys[c1 - 1];
+                               last_keys[0] = scancode2ascii[key & 0x7f];
+                       } else
+                               keyb[key & 0x7f] = 0;
+               } else {
+                       if ((key & 0x80) == 0) {
+                               keyb[(key & 0x7f) + 0x80] = 1;
+                               for (c1 = 48; c1 > 0; c1--)
+                                       last_keys[c1] = last_keys[c1 - 1];
+                               last_keys[0] = scancode2ascii[(key & 0x7f) + 0x80];
+                       } else
+                               keyb[(key & 0x7f) + 0x80] = 0;
+               }
+               if (extended == 1)
+                       extended = 0;
+       }
+#ifndef USE_SDL
+       outportb(0x20, 0x20);
+#endif
+
+}
+
+void keyb_handler_end()
+{
+}
+
+
+char hook_keyb_handler(void)
+{
+#ifndef USE_SDL
+       if (keyb_handler_info.enabled == 0) {
+               _go32_dpmi_lock_data((char *) &keyb, sizeof(keyb));
+               _go32_dpmi_lock_code(keyb_handler, (unsigned long) keyb_handler_end - (unsigned long) keyb_handler);
+               _go32_dpmi_get_protected_mode_interrupt_vector(9, &old_keyb_handler_seginfo);
+               new_keyb_handler_seginfo.pm_offset = (int) keyb_handler;
+               if (_go32_dpmi_allocate_iret_wrapper(&new_keyb_handler_seginfo) != 0)
+                       return 1;
+               if (_go32_dpmi_set_protected_mode_interrupt_vector(9, &new_keyb_handler_seginfo) != 0) {
+                       _go32_dpmi_free_iret_wrapper(&new_keyb_handler_seginfo);
+                       return 1;
+               }
+               keyb_handler_info.enabled = 1;
+               memset(last_keys, 0, sizeof(last_keys));
+       }
+#endif
+       SDL_EnableUNICODE(1);
+       memset((void *) last_keys, 0, sizeof(last_keys));
+       return 0;
+
+}
+
+
+void remove_keyb_handler(void)
+{
+#ifndef USE_SDL
+       if (keyb_handler_info.enabled == 1) {
+               _go32_dpmi_set_protected_mode_interrupt_vector(9, &old_keyb_handler_seginfo);
+               _go32_dpmi_free_iret_wrapper(&new_keyb_handler_seginfo);
+               keyb_handler_info.enabled = 0;
+       }
+#endif
+}
+
+
+char key_pressed(unsigned char key)
+{
+       return keyb[(unsigned char) key];
+}
+
+int addkey(unsigned int key)
+{
+       int c1;
+
+       if (!(key & 0x8000)) {
+               keyb[key & 0x7fff] = 1;
+               for (c1 = 48; c1 > 0; c1--)
+                       last_keys[c1] = last_keys[c1 - 1];
+               last_keys[0] = key & 0x7fff;
+       } else
+               keyb[key & 0x7fff] = 0;
+       return 0;
+}
+
+char intr_sysupdate()
+{
+       SDL_Event e;
+       int i = 0;
+       static Uint32 now, then = 0;
+
+       while (SDL_PollEvent(&e)) {
+               switch (e.type) {
+               case SDL_MOUSEBUTTONDOWN:
+                       break;
+               case SDL_KEYDOWN:
+               case SDL_KEYUP:
+                       switch (e.key.keysym.sym) {
+                       case SDLK_F12:
+                               if (e.type == SDL_KEYDOWN) {
+                                       SDL_Quit();
+                                       exit(1);
+                               }
+                               break;
+                       case SDLK_F10:
+                               if (e.type == SDL_KEYDOWN) {
+                                       fs_toggle();
+                               }
+                               break;
+                       case SDLK_ESCAPE:
+                               if (e.type == SDL_KEYUP)
+                                       addkey(1 | 0x8000);
+                               else
+                                       addkey(1 & 0x7f);
+                               break;
+                       default:
+                               e.key.keysym.sym &= 0x7f;
+                               if (e.type == SDL_KEYUP)
+                                       e.key.keysym.sym |= 0x8000;
+                               addkey(e.key.keysym.sym);
+
+                               break;
+                       }
+                       break;
+               default:
+                       break;
+               }
+               i++;
+       }
+       //SDL_Delay(4);
+       now = SDL_GetTicks();
+       if (!then)
+               SDL_Delay(1);
+       else {
+               then = (1000 / 60) - (now - then);
+               if (then > 0 && then < 1000)
+                       SDL_Delay(then);
+       }
+       then = now;
+
+       return i;
+}
diff --git a/sdl/sound.c b/sdl/sound.c
new file mode 100644 (file)
index 0000000..b7ca194
--- /dev/null
@@ -0,0 +1,353 @@
+#include "globals.h"
+
+static Mix_Music *current_music = (Mix_Music *) NULL;
+static struct {
+       int id;
+       Mix_Chunk *chunk;
+       int used;
+       int loop;
+} soundsamples[128];
+
+/* misc handling */
+
+char dj_init(void)
+{
+       int audio_rate = 22050;
+       Uint16 audio_format = AUDIO_U16;
+       int audio_channels = 2;
+       int audio_buffers = 4096;
+
+       if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) < 0) {
+               fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
+               return 0;
+       }
+
+       Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
+       printf("Opened audio at %dHz %dbit %s, %d bytes audio buffer\n", audio_rate, (audio_format & 0xFF), (audio_channels > 1) ? "stereo" : "mono", audio_buffers);
+
+       Mix_SetMusicCMD(getenv("MUSIC_CMD"));
+
+       memset(soundsamples, 0, sizeof(soundsamples));
+
+       return 0;
+}
+
+void dj_deinit(void)
+{
+//      int i;
+
+       Mix_FadeOutMusic(1500);
+       SDL_Delay(1500);
+       Mix_HaltMusic();
+       if (current_music)
+               Mix_FreeMusic(current_music);
+       current_music = NULL;
+
+/*     for(i = 0; i < 128; i++) {
+               if(soundsamples[i].used && soundsamples[i].chunk)
+                       Mix_FreeChunk(soundsamples[i].chunk);
+       }*/
+
+       Mix_CloseAudio();
+
+       SDL_Quit();
+}
+
+void dj_start(void)
+{
+}
+
+void dj_stop(void)
+{
+}
+
+char dj_autodetect_sd(void)
+{
+       return 0;
+}
+
+char dj_set_stereo(char flag)
+{
+       return 0;
+}
+
+void dj_set_auto_mix(char flag)
+{
+}
+
+unsigned short dj_set_mixing_freq(unsigned short freq)
+{
+       return freq;
+}
+
+void dj_set_dma_time(unsigned short time)
+{
+}
+
+void dj_set_nosound(char flag)
+{
+}
+
+/* mix handling */
+
+void dj_mix(void)
+{
+}
+
+/* sfx handling */
+
+char dj_set_num_sfx_channels(char num_channels)
+{
+       return num_channels;
+}
+
+void dj_set_sfx_volume(char volume)
+{
+}
+
+void dj_play_sfx(unsigned char sfx_num, unsigned short freq, char volume, char panning, unsigned short delay, char channel)
+{
+       int i;
+       int used_channel;
+
+       for (i = 0; i < 128; i++) {
+               if (soundsamples[i].id == sfx_num)
+                       break;
+       }
+       if (i == 128)
+               return;
+       else if (!soundsamples[i].used)
+               return;
+       else if (!soundsamples[i].chunk)
+               return;
+
+       used_channel = Mix_PlayChannel(channel, soundsamples[i].chunk, soundsamples[i].loop);
+       Mix_Volume(used_channel, volume * 2);
+}
+
+char dj_get_sfx_settings(unsigned char sfx_num, sfx_data * data)
+{
+       int i;
+
+       data->priority = 0;
+       data->default_freq = 0;
+       data->default_volume = 0;
+       data->length = 0;
+       data->loop = 0;
+       data->loop_start = 0;
+       data->loop_length = 0;
+       data->buf = 0;
+
+       for (i = 0; i < 128; i++) {
+               if (soundsamples[i].id == sfx_num)
+                       break;
+       }
+       if (i == 128)
+               return 1;
+       else if (!soundsamples[i].used)
+               return 1;
+       else if (!soundsamples[i].chunk)
+               return 1;
+
+       data->loop = soundsamples[i].loop;
+
+       return 0;
+}
+
+char dj_set_sfx_settings(unsigned char sfx_num, sfx_data * data)
+{
+       int i;
+
+       for (i = 0; i < 128; i++) {
+               if (soundsamples[i].id == sfx_num)
+                       break;
+       }
+       if (i == 128)
+               return 1;
+       else if (!soundsamples[i].used)
+               return 1;
+       else if (!soundsamples[i].chunk)
+               return 1;
+
+       soundsamples[i].loop = (data->loop) ? (-1) : (0);
+
+       return 0;
+}
+
+void dj_set_sfx_channel_volume(char channel_num, char volume)
+{
+       Mix_Volume(channel_num, volume * 2);
+}
+
+void dj_stop_sfx_channel(char channel_num)
+{
+       Mix_HaltChannel(channel_num);
+}
+
+char dj_load_sfx(FILE * file_handle, char *filename, int file_length, char sfx_type, unsigned char sfx_num)
+{
+       int i;
+       typedef struct {
+               char RIFF_ID[4];
+               long riff_size;
+               char WAVE_ID[4];
+               char FMT_ID[4];
+               long fmt_size;
+               short FormatTag;
+               unsigned short Channels;
+               unsigned long SamplesPerSec;
+               unsigned long AvgBytesPerSec;
+               unsigned short BlockAlign;
+               unsigned short BitsPerSample;
+               char DATA_ID[4];
+               long data_size;
+               unsigned char data[0];
+       } wave_file_t;
+
+       wave_file_t *wave_buffer;
+       SDL_RWops *rwop;
+
+       for (i = 0; (i < 128) && soundsamples[i].used; i++);
+       if (i == 128)
+               return -1;
+
+       wave_buffer = (wave_file_t *) malloc(sizeof(wave_file_t) + file_length);
+       memset(wave_buffer, 0, sizeof(wave_file_t) + file_length);
+
+       strncpy(wave_buffer->RIFF_ID, "RIFF", 4);
+       wave_buffer->riff_size = sizeof(wave_file_t) + file_length - 8;
+       strncpy(wave_buffer->WAVE_ID, "WAVE", 4);
+       strncpy(wave_buffer->FMT_ID, "fmt ", 4);
+       wave_buffer->fmt_size = 16;
+       wave_buffer->FormatTag = 1;
+       wave_buffer->Channels = 1;
+       switch (sfx_num) {
+       case SFX_JUMP:
+               wave_buffer->SamplesPerSec = SFX_JUMP_FREQ;
+               break;
+       case SFX_LAND:
+               wave_buffer->SamplesPerSec = SFX_LAND_FREQ;
+               break;
+       case SFX_DEATH:
+               wave_buffer->SamplesPerSec = SFX_DEATH_FREQ;
+               break;
+       case SFX_SPRING:
+               wave_buffer->SamplesPerSec = SFX_SPRING_FREQ;
+               break;
+       case SFX_SPLASH:
+               wave_buffer->SamplesPerSec = SFX_SPLASH_FREQ;
+               break;
+       case SFX_FLY:
+               wave_buffer->SamplesPerSec = SFX_FLY_FREQ;
+               break;
+       default:
+               wave_buffer->SamplesPerSec = 22050;
+               break;
+       }
+       wave_buffer->BitsPerSample = 16;
+       wave_buffer->AvgBytesPerSec = wave_buffer->SamplesPerSec * wave_buffer->Channels * (wave_buffer->BitsPerSample / 8);
+       wave_buffer->BlockAlign = 1;
+       strncpy(wave_buffer->DATA_ID, "data", 4);
+       wave_buffer->data_size = file_length;
+       fread(wave_buffer->data, file_length, 1, file_handle);
+
+       rwop = SDL_RWFromMem(wave_buffer, sizeof(wave_file_t) + file_length);
+
+       soundsamples[i].chunk = Mix_LoadWAV_RW(rwop, 1);
+       soundsamples[i].chunk->allocated = 1;
+       soundsamples[i].used = 1;
+       soundsamples[i].id = sfx_num;
+       soundsamples[i].loop = 0;
+
+       return 0;
+}
+
+void dj_free_sfx(unsigned char sfx_num)
+{
+       if (sfx_num >= 128 || !soundsamples[sfx_num].used)
+               return;
+
+       Mix_FreeChunk(soundsamples[sfx_num].chunk);
+       soundsamples[sfx_num].chunk = (Mix_Chunk *) NULL;
+       soundsamples[sfx_num].used = 0;
+}
+
+/* mod handling */
+
+char dj_ready_mod(char mod_num)
+{
+       FILE *tmp;
+#ifdef _MSC_VER
+       char filename[] = "jnb.tmpmusic.mod";
+#else
+       char filename[] = "/tmp/jnb.tmpmusic.mod";
+#endif
+       FILE *fp;
+       int len;
+       switch (mod_num) {
+       case MOD_MENU:
+               fp = dat_open("jump.mod", datfile_name, "rb");
+               len = dat_filelen("jump.mod", datfile_name);
+               break;
+       case MOD_GAME:
+               fp = dat_open("bump.mod", datfile_name, "rb");
+               len = dat_filelen("bump.mod", datfile_name);
+               break;
+       case MOD_SCORES:
+               fp = dat_open("scores.mod", datfile_name, "rb");
+               len = dat_filelen("scores.mod", datfile_name);
+               break;
+       default:
+               break;
+       }
+
+       if (Mix_PlayingMusic())
+               Mix_FadeOutMusic(1500);
+
+       if (current_music) {
+               Mix_FreeMusic(current_music);
+               current_music = NULL;
+       }
+       tmp = fopen(filename, "wb");
+       for (; len > 0; len--)
+               fputc(fgetc(fp), tmp);
+       fflush(tmp);
+       fclose(tmp);
+       fclose(fp);
+
+       current_music = Mix_LoadMUS(filename);
+       if (current_music == NULL) {
+               fprintf(stderr, "Couldn't load music: %s\n", SDL_GetError());
+               return 0;
+       }
+
+       return 0;
+}
+
+char dj_start_mod(void)
+{
+       Mix_VolumeMusic(64);
+
+       Mix_FadeInMusic(current_music, -1, 2000);
+
+       return 0;
+}
+
+void dj_stop_mod(void)
+{
+       Mix_HaltMusic();
+}
+
+void dj_set_mod_volume(char volume)
+{
+       //Mix_VolumeMusic(volume*4);
+}
+
+char dj_load_mod(FILE * file_handle, char *filename, char mod_num)
+{
+       return 0;
+}
+
+void dj_free_mod(char mod_num)
+{
+}