diff --git a/app/jni/prboom/config.h b/app/jni/prboom/config.h index e051b29..eb89c08 100644 --- a/app/jni/prboom/config.h +++ b/app/jni/prboom/config.h @@ -12,7 +12,7 @@ #define USE_ANDROID 1 /* Define to be the path where Doom WADs are stored */ -#define DOOMWADDIR "/sdcard/doom" +//#define DOOMWADDIR "/sdcard/doom" /* Define if you are building with OpenGL support */ /* #undef GL_DOOM */ diff --git a/app/jni/prboom/d_client.c b/app/jni/prboom/d_client.c index fe5eaa7..763e718 100644 --- a/app/jni/prboom/d_client.c +++ b/app/jni/prboom/d_client.c @@ -87,6 +87,8 @@ static boolean isExtraDDisplay = false; static void D_QuitNetGame (void); +extern char *doomWADDir; + #ifndef HAVE_NET doomcom_t* doomcom; #endif @@ -152,7 +154,7 @@ void D_InitNetGame (void) while (i--) { #ifdef USE_ANDROID char tmp[80]; - strcpy(tmp, DOOMWADDIR); + strcpy(tmp, doomWADDir); strcat(tmp, "/"); strcat(tmp, p); D_AddFile(tmp, source_net); diff --git a/app/jni/prboom/d_main.c b/app/jni/prboom/d_main.c index 16c18db..1178029 100644 --- a/app/jni/prboom/d_main.c +++ b/app/jni/prboom/d_main.c @@ -107,6 +107,8 @@ float hmdYaw; float hmdRoll; float hmdPitch; +char *doomWADDir; + //jff 1/22/98 parms for disabling music and sound boolean nosfxparm; @@ -1170,10 +1172,12 @@ static void L_SetupConsoleMasks(void) { // CPhipps - the old contents of D_DoomMain, but moved out of the main // line of execution so its stack space can be freed -void D_DoomMainSetup(void) +void D_DoomMainSetup(char *wadDir) { int p,slot; + doomWADDir = wadDir; + L_SetupConsoleMasks(); // Vladimir setbuf(stdout,NULL); diff --git a/app/jni/prboom/d_main.h b/app/jni/prboom/d_main.h index f76d3f6..90ed6b3 100644 --- a/app/jni/prboom/d_main.h +++ b/app/jni/prboom/d_main.h @@ -70,7 +70,7 @@ void D_DoAdvanceDemo (void); void D_Display(int eye); void D_PageTicker(void); void D_StartTitle(void); -void D_DoomMainSetup(); +void D_DoomMainSetup(char *wadDir); void D_DoomStartFrame(float, float, float); void D_DoomEndFrame(void); void D_AddFile (const char *file, wad_source_t source); diff --git a/app/jni/prboom/i_main.c b/app/jni/prboom/i_main.c index e11072c..497bb1d 100644 --- a/app/jni/prboom/i_main.c +++ b/app/jni/prboom/i_main.c @@ -351,7 +351,7 @@ uid_t stored_euid = -1; #endif //int main(int argc, const char * const * argv) -int doom_main(int argc, char **argv) +int doom_main(int argc, char **argv, char *wadDir) { #ifdef SECURE_UID /* First thing, revoke setuid status (if any) */ @@ -414,7 +414,7 @@ int doom_main(int argc, char **argv) /* cphipps - call to video specific startup code */ I_PreInitGraphics(); - D_DoomMainSetup(); + D_DoomMainSetup(wadDir); return 0; } diff --git a/app/jni/prboom/i_system.c b/app/jni/prboom/i_system.c index c20ef8e..76ebc8a 100644 --- a/app/jni/prboom/i_system.c +++ b/app/jni/prboom/i_system.c @@ -1,218 +1,218 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// $Id:$ -// -// Copyright (C) 1993-1996 by id Software, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// $Log:$ -// -// DESCRIPTION: -// -//----------------------------------------------------------------------------- - -static const char -rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $"; - - +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// $Id:$ +// +// Copyright (C) 1993-1996 by id Software, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// $Log:$ +// +// DESCRIPTION: +// +//----------------------------------------------------------------------------- + +static const char +rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $"; + + #include - -#include -#include - -#include -#include -#include - -#include "doomdef.h" -#include "m_misc.h" -#include "i_video.h" -#include "i_sound.h" - -#include "d_net.h" + +#include +#include + +#include +#include +#include + +#include "doomdef.h" +#include "m_misc.h" +#include "i_video.h" +#include "i_sound.h" + +#include "d_net.h" #include "g_game.h" -/* -#ifdef __GNUG__ -#pragma implementation "i_system.h" +/* +#ifdef __GNUG__ +#pragma implementation "i_system.h" #endif */ - -#include "i_system.h" - -#include "lprintf.h" -#include "r_fps.h" + +#include "i_system.h" + +#include "lprintf.h" +#include "r_fps.h" - -int mb_used = 6; - - -void -I_Tactile -( int on, - int off, - int total ) -{ - // UNUSED. - on = off = total = 0; -} - -ticcmd_t emptycmd; -ticcmd_t* I_BaseTiccmd(void) -{ - return &emptycmd; -} - - -int I_GetHeapSize (void) -{ - return mb_used*1024*1024; -} - -byte* I_ZoneBase (int* size) -{ - *size = mb_used*1024*1024; - return (byte *) malloc (*size); -} - - - -// -// I_GetTime -// returns time in 1/70th second tics -// - -int I_GetTime (void) + +int mb_used = 6; + + +void +I_Tactile +( int on, + int off, + int total ) +{ + // UNUSED. + on = off = total = 0; +} + +ticcmd_t emptycmd; +ticcmd_t* I_BaseTiccmd(void) +{ + return &emptycmd; +} + + +int I_GetHeapSize (void) +{ + return mb_used*1024*1024; +} + +byte* I_ZoneBase (int* size) +{ + *size = mb_used*1024*1024; + return (byte *) malloc (*size); +} + + + +// +// I_GetTime +// returns time in 1/70th second tics +// + +int I_GetTime (void) { struct timeval tp; struct timezone tzp; - - int newtics; - static int basetime=0; - - gettimeofday(&tp, &tzp); - - if (!basetime) - basetime = tp.tv_sec; - - newtics = (tp.tv_sec-basetime)*TICRATE + tp.tv_usec*TICRATE/1000000; - return newtics; -} - - - -// -// I_Init -// -/* -void I_Init (void) -{ - I_InitSound(); - // I_InitGraphics(); -} -*/ - -// -// I_Quit -// -void I_Quit (void) -{ - // Vladimir D_QuitNetGame (); - I_ShutdownSound(); - I_ShutdownMusic(); - M_SaveDefaults (); - I_ShutdownGraphics(); - exit(0); -} - -void I_WaitVBL(int count) -{ -#ifdef SGI - sginap(1); -#else -#ifdef SUN - sleep(0); -#else - usleep (count * (1000000/70) ); -#endif -#endif -} - -void I_BeginRead(void) -{ -} - -void I_EndRead(void) -{ -} - -byte* I_AllocLow(int length) -{ - byte* mem; - - mem = (byte *)malloc (length); - memset (mem,0,length); - return mem; -} - - -// -// I_Error -// -extern boolean demorecording; - -// Send a string back to Java -extern void jni_fatal_error(const char * text); - -void I_Error (char *error, ...) -{ - //printf("I_Error: %s\n", error); - va_list argptr; - static char string[1024]; - - - // Message first. - va_start (argptr,error); - vsprintf (string, error ,argptr); -/* Vladimir - fprintf (stderr, "Error: "); - vfprintf ( stderr,error,argptr); - fprintf (stderr, "\n"); - - printf ( "Error: "); - vprintf (error,argptr); - printf ("\n"); -*/ - va_end (argptr); - - - // Vladimir fflush( stderr ); - - // Shutdown. Here might be other errors. - if (demorecording) - G_CheckDemoStatus(); - - // Vladimir D_QuitNetGame (); - I_ShutdownGraphics(); - // Send the error back to JNI layer - jni_fatal_error(string); + int newtics; + static int basetime=0; + + gettimeofday(&tp, &tzp); + + if (!basetime) + basetime = tp.tv_sec; + + newtics = (tp.tv_sec-basetime)*TICRATE + tp.tv_usec*TICRATE/1000000; + return newtics; +} + + + +// +// I_Init +// +/* +void I_Init (void) +{ + I_InitSound(); + // I_InitGraphics(); +} +*/ + +// +// I_Quit +// +void I_Quit (void) +{ + // Vladimir D_QuitNetGame (); + I_ShutdownSound(); + I_ShutdownMusic(); + M_SaveDefaults (); + I_ShutdownGraphics(); + exit(0); +} + +void I_WaitVBL(int count) +{ +#ifdef SGI + sginap(1); +#else +#ifdef SUN + sleep(0); +#else + usleep (count * (1000000/70) ); +#endif +#endif +} + +void I_BeginRead(void) +{ +} + +void I_EndRead(void) +{ +} + +byte* I_AllocLow(int length) +{ + byte* mem; + + mem = (byte *)malloc (length); + memset (mem,0,length); + return mem; +} + + +// +// I_Error +// +extern boolean demorecording; + +// Send a string back to Java +extern void jni_fatal_error(const char * text); + +void I_Error (char *error, ...) +{ + //printf("I_Error: %s\n", error); + va_list argptr; + static char string[1024]; + + + // Message first. + va_start (argptr,error); + vsprintf (string, error ,argptr); +/* Vladimir + fprintf (stderr, "Error: "); + vfprintf ( stderr,error,argptr); + fprintf (stderr, "\n"); + + printf ( "Error: "); + vprintf (error,argptr); + printf ("\n"); +*/ + va_end (argptr); + + + // Vladimir fflush( stderr ); + + // Shutdown. Here might be other errors. + if (demorecording) + G_CheckDemoStatus(); + + // Vladimir D_QuitNetGame (); + I_ShutdownGraphics(); + + // Send the error back to JNI layer + jni_fatal_error(string); // Vladimir JNI Change: The Lib will not terminate to let Java know - // Something wrong has happened - //exit(-1); + // Something wrong has happened + //exit(-1); } /* cphipps - I_GetVersionString @@ -223,7 +223,8 @@ const char* I_GetVersionString(char* buf, size_t sz) snprintf(buf,sz,"LxDoom v%s (http://lxdoom.linuxgames.com/)",VERSION); return buf; } - /* + +/* * I_Filelength * * Return length of an open file. @@ -243,27 +244,10 @@ int I_Filelength(int handle) return length; } -// cph - V.Aguilar (5/30/99) suggested return ~/.lxdoom/, creating -// if non-existant -static const char prboom_dir[] = {"/doom"}; // Mead rem extra slash 8/21/03 - +extern char* doomWADDir; const char *I_DoomExeDir(void) { - static char *base; - if (!base) // cache multiple requests - { - char *home = "/sdcard"; //getenv("HOME"); - size_t len = strlen(home); - - base = malloc(len + strlen(prboom_dir) + 1); - strcpy(base, home); - // I've had trouble with trailing slashes before... - if (base[len-1] == '/') base[len-1] = 0; - strcat(base, prboom_dir); - //mkdir(base, S_IRUSR | S_IWUSR | S_IXUSR); // Make sure it exists - printf("I_DoomExeDir: Create dir %s\n", base); - } - return base; + return doomWADDir; } /* @@ -278,7 +262,7 @@ const char *I_DoomExeDir(void) */ char* I_FindFile(const char* wfname, const char* ext) -{ +{ // Vladimir if ( ! wfname ) { printf("I_FindFile BUG: File name cannot be NULL!\n"); @@ -291,48 +275,12 @@ char* I_FindFile(const char* wfname, const char* ext) //exit (1); } - // lookup table of directories to search - static const struct { - const char *dir; // directory - const char *sub; // subdirectory - const char *env; // environment variable - const char *(*func)(void); // for I_DoomExeDir - } search[] = { - {NULL}, // current working directory - {NULL, NULL, "DOOMWADDIR"}, // run-time $DOOMWADDIR - {DOOMWADDIR}, // build-time configured DOOMWADDIR - {NULL, "doom", "HOME"}, // ~/doom - {NULL, NULL, "HOME"}, // ~ - {NULL, NULL, NULL, I_DoomExeDir}, // config directory - {"/data"}, - {"/data/data"}, - {"/sdcard/doom"}, - {"/sdcard"}, - }; - - int i; /* Precalculate a length we will need in the loop */ size_t pl = strlen(wfname) + strlen(ext) + 4; - for (i = 0; i < sizeof(search)/sizeof(*search); i++) { - char * p; - const char * d = NULL; - const char * s = NULL; - /* Each entry in the switch sets d to the directory to look in, - * and optionally s to a subdirectory of d */ - // switch replaced with lookup table - if (search[i].env) { - if (!(d = getenv(search[i].env))) - continue; - } else if (search[i].func) - d = search[i].func(); - else - d = search[i].dir; - s = search[i].sub; - - p = malloc((d ? strlen(d) : 0) + (s ? strlen(s) : 0) + pl); - sprintf(p, "%s%s%s%s%s", d ? d : "", (d && !HasTrailingSlash(d)) ? "/" : "", - s ? s : "", (s && !HasTrailingSlash(s)) ? "/" : "", + const char * d = I_DoomExeDir(); + char * p = malloc((d ? strlen(d) : 0) + pl); + sprintf(p, "%s%s%s", d ? d : "", (d && !HasTrailingSlash(d)) ? "/" : "", wfname); if (access(p,F_OK)) @@ -344,7 +292,7 @@ char* I_FindFile(const char* wfname, const char* ext) } free(p); - } + return NULL; } diff --git a/app/jni/prboom/include/doom_jni_Natives.h b/app/jni/prboom/include/doom_jni_Natives.h index 1a4739d..fe2bd0d 100644 --- a/app/jni/prboom/include/doom_jni_Natives.h +++ b/app/jni/prboom/include/doom_jni_Natives.h @@ -19,7 +19,7 @@ extern "C" { * Signature: ([Ljava/lang/String;)I */ JNIEXPORT jint JNICALL Java_doom_util_Natives_DoomInit - (JNIEnv *, jclass, jobjectArray); + (JNIEnv *, jclass, jobjectArray, jstring); /* * Class: doom_util_Natives diff --git a/app/jni/prboom/jni_doom.c b/app/jni/prboom/jni_doom.c index c290769..ab991b2 100644 --- a/app/jni/prboom/jni_doom.c +++ b/app/jni/prboom/jni_doom.c @@ -117,7 +117,7 @@ int loadJNIMethods(JNIEnv * env) return 0; } -extern int doom_main(int argc, char **argv); +extern int doom_main(int argc, char **argv, char *wadDir); /* * Class: doom_util_Natives @@ -125,7 +125,7 @@ extern int doom_main(int argc, char **argv); * Signature: ([Ljava/lang/String;)V */ JNIEXPORT jint JNICALL Java_doom_util_Natives_DoomInit - (JNIEnv * env, jclass class, jobjectArray jargv) + (JNIEnv * env, jclass class, jobjectArray jargv, jstring jDoomWADDir) { (*env)->GetJavaVM(env, &g_VM); @@ -153,7 +153,17 @@ JNIEXPORT jint JNICALL Java_doom_util_Natives_DoomInit (*env)->ReleaseStringUTFChars(env, jrow, row); } - doom_main (clen, args); + const char *row = (*env)->GetStringUTFChars(env, jDoomWADDir, 0); + + char *doomWADDir = malloc( strlen(row) + 1); + strcpy (doomWADDir, row); + + jni_printf("Main argv[%d]=%s", i, args[i]); + + // free java string jrow + (*env)->ReleaseStringUTFChars(env, jrow, row); + + doom_main (clen, args, doomWADDir); return 0; } diff --git a/app/jni/prboom/m_misc.c b/app/jni/prboom/m_misc.c index 8f44af8..3bcc7cc 100644 --- a/app/jni/prboom/m_misc.c +++ b/app/jni/prboom/m_misc.c @@ -945,11 +945,11 @@ void M_LoadDefaults (void) #else sprintf ((char *)defaultfile, #endif - "%s%s%sboom.cfg", exedir, HasTrailingSlash(exedir) ? "" : "/", + "%s%s%s.cfg", exedir, HasTrailingSlash(exedir) ? "" : "/", #if ((defined GL_DOOM) && (defined _MSC_VER)) "gl"); #else - "pr"); + "DVR"); #endif } diff --git a/app/src/main/assets/DVR.cfg b/app/src/main/assets/DVR.cfg index 1d10dd7..c9e9d00 100644 --- a/app/src/main/assets/DVR.cfg +++ b/app/src/main/assets/DVR.cfg @@ -76,9 +76,9 @@ mus_pause_opt 2 snd_channels 8 # Video settings -videomode "8" -screen_width 320 -screen_height 200 +videomode "8" +screen_width 640 +screen_height 400 use_fullscreen 1 use_doublebuffer 1 translucency 1 diff --git a/app/src/main/assets/prboom.wad b/app/src/main/assets/prboom.wad new file mode 100644 index 0000000..85dc155 Binary files /dev/null and b/app/src/main/assets/prboom.wad differ diff --git a/app/src/main/java/com/drbeef/dvr/DVRConfig.java b/app/src/main/java/com/drbeef/dvr/DVRConfig.java deleted file mode 100644 index de086d5..0000000 --- a/app/src/main/java/com/drbeef/dvr/DVRConfig.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.drbeef.dvr; - - -import android.os.Environment; - -import java.io.File; - -public class DVRConfig { - - static public String GetSDCARD() - { - return Environment.getExternalStorageDirectory().getPath(); - } - - static public String GetWorkingFolder() - { - //Do we use old folder name? - if (new File(GetSDCARD() + "/Q4C").exists()) - { - return "Q4C/"; - } - else - { - return "DVR/"; - } - } - - static public String GetFullWorkingFolder() - { - return GetSDCARD() + "/" + GetWorkingFolder(); - } -} diff --git a/app/src/main/java/com/drbeef/dvr/MainActivity.java b/app/src/main/java/com/drbeef/dvr/MainActivity.java index 1670ae9..918344c 100644 --- a/app/src/main/java/com/drbeef/dvr/MainActivity.java +++ b/app/src/main/java/com/drbeef/dvr/MainActivity.java @@ -13,7 +13,6 @@ import android.opengl.GLES20; import android.opengl.GLUtils; import android.opengl.Matrix; import android.os.Bundle; -import android.os.Message; import android.os.Vibrator; import android.util.Log; import android.view.KeyEvent; @@ -291,6 +290,10 @@ public class MainActivity vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + //At the very least ensure we have a directory containing a config file + copy_asset("DVR.cfg", DoomTools.GetDVRFolder() + "/"); + copy_asset("prboom.wad", DoomTools.GetDVRFolder() + "/"); + if (!DoomTools.wadsExist()) { MessageBox("Read this carefully", "You must install a game file. Tap \"Install WADs\" for auto-install. " @@ -425,9 +428,10 @@ public class MainActivity if (!mShowingSpashScreen) { final String[] argv; String args = new String(); - args = "doom -width 640 -height 400 -iwad doom.wad"; + args = "doom -iwad " + WADChooser.GetChosenWAD(); argv = args.split(" "); - Natives.DoomInit(argv); + String dvr= DoomTools.GetDVRFolder(); + Natives.DoomInit(argv, dvr); mDVRInitialised = true; } } diff --git a/app/src/main/java/com/drbeef/dvr/WADChooser.java b/app/src/main/java/com/drbeef/dvr/WADChooser.java new file mode 100644 index 0000000..ab4338e --- /dev/null +++ b/app/src/main/java/com/drbeef/dvr/WADChooser.java @@ -0,0 +1,14 @@ +package com.drbeef.dvr; + +/** + * Created by Simon on 04/03/2016. + */ +public class WADChooser { + + static String wad = "doom.wad"; + + public static String GetChosenWAD() + { + return wad; + } +} diff --git a/app/src/main/java/doom/util/DoomTools.java b/app/src/main/java/doom/util/DoomTools.java index 41d1db8..914b672 100644 --- a/app/src/main/java/doom/util/DoomTools.java +++ b/app/src/main/java/doom/util/DoomTools.java @@ -11,36 +11,31 @@ import java.util.zip.ZipInputStream; import android.app.ProgressDialog; import android.content.Context; +import android.os.Environment; import android.util.Log; import android.view.KeyEvent; public class DoomTools { - public static final String DOOM_FOLDER = "/sdcard/doom" + File.separator ; - // Soundtrack - public static final String DOOM_SOUND_FOLDER = "/sdcard/doom" + File.separator + "sound"; - - // Base server URL - public static final String URL_BASE = "http://prboom4android.googlecode.com/files/"; - - // HowTo URL - public static final String URL_HOWTO = "http://code.google.com/p/prboom4android/wiki/HowTo"; - - // Url prefix that has all Doom files: WADs, Sound + JNI lib - public static final String DOWNLOAD_BASE = URL_BASE + "" ; - - // Url prefix that has all Sounds - public static final String SOUND_BASE = DOWNLOAD_BASE + "" ; - + static public String GetSDCARD() + { + return Environment.getExternalStorageDirectory().getPath(); + } + + static public String GetWorkingFolder() + { + return "DVR"; + } + + static public String GetDVRFolder() + { + return GetSDCARD() + File.separator + GetWorkingFolder(); + } + // Game files we can handle - public static final String[] DOOM_WADS = {"freedoom.wad", "freedm.wad"}; - - /** - * Doom lib. To be downloaded into /data/data/APP_PKG/files - */ - //public static final String DOOM_LIB = "libdoom_jni.so"; - public static final String DOOM_LIB = "prboom_jni"; + public static final String[] DOOM_WADS = + {"freedoom.wad", "freedm.wad", "doom.wad", "doom2.wad"}; // These are required for the game to run public static final String REQUIRED_DOOM_WAD = "prboom.wad"; @@ -214,88 +209,20 @@ public class DoomTools { } } - - static public boolean installConfig(Context ctx) { - File f = new File(DoomTools.DOOM_FOLDER + File.separator); - if(!f.exists()) - f.mkdir(); - InputStream cfgIn; - try { - cfgIn = ctx.getAssets().open("prboom.cfg.zip"); - unzip(cfgIn, new File(DOOM_FOLDER)); - return true; - } catch (IOException e) { - e.printStackTrace(); - } - return false; - } - - static public boolean installPrBoom(Context ctx) { - // check of /sdcard/doom exists, if not create it - File f = new File(DoomTools.DOOM_FOLDER + File.separator); - if(!f.exists()) - f.mkdir(); - InputStream prboomIn; - try { - prboomIn = ctx.getAssets().open("prboom.zip"); - unzip(prboomIn, new File(DOOM_FOLDER)); - return true; - } catch (IOException e) { - e.printStackTrace(); - } - return false; - } - - /** - * SDCARD? - * @return - */ - static public boolean hasSDCard() { - try { - File f = new File(DOOM_FOLDER); - - // Does /sdcard/doom exist? - if ( f.exists()) return true; - - // Can we write into it? - return f.mkdir(); - } catch (Exception e) { - System.err.println(e.toString()); - return false; - } - } - - /** - * Ping the download server - * @return - */ - static public boolean pingServer() { - try { - WebDownload wd = new WebDownload(URL_BASE); - wd.doGet(); - int rc = wd.getResponseCode(); - Log.d(TAG, "PingServer Response:" + rc); - return rc == 200; - } catch (Exception e) { - Log.e(TAG, "PingServer: " + e.toString()); - return false; - } - } - static public boolean wadExists (int idx) { - final String path = DOOM_FOLDER + File.separator + DOOM_WADS[idx]; + final String path = GetDVRFolder() + File.separator + DOOM_WADS[idx]; return new File(path).exists(); } static public boolean wadExists (String name) { - final String path = DOOM_FOLDER + File.separator + name; + final String path = GetDVRFolder() + File.separator + name; return new File(path).exists(); } static public boolean wadsExist() { for(int i = 0; i < DOOM_WADS.length; i++) { - File f = new File(DOOM_FOLDER + File.separator + DOOM_WADS[i]); + File f = new File(GetDVRFolder() + File.separator + DOOM_WADS[i]); if(f.exists()) return true; } @@ -305,21 +232,20 @@ public class DoomTools { static public void hardExit ( int code) { System.exit(code); } - /** * Sound present for a WAD? */ public static boolean hasSound() { - Log.d(TAG, "Sound folder: " + DOOM_SOUND_FOLDER); - return new File(DOOM_SOUND_FOLDER).exists(); + Log.d(TAG, "Sound folder: " + GetDVRFolder() + File.separator + "sound"); + return new File(GetDVRFolder() + File.separator + "sound").exists(); } /** * Get the sound folder name for a game file */ public static File getSoundFolder() { - return new File(DOOM_SOUND_FOLDER); + return new File(GetDVRFolder() + File.separator + "sound"); } @@ -358,36 +284,6 @@ public class DoomTools { static final String TAG = "DoomTools"; - - /** - * Ckech 4 sdcard - * @return - */ - public static boolean checkSDCard(Context ctx) { - boolean sdcard = DoomTools.hasSDCard(); - - if ( ! sdcard) { - //DialogTool.MessageBox(ctx, "No SDCARD", "An SDCARD is required to store game files."); - return false; - } - return true; - } - - /** - * Make sure you have a web cn - * @param ctx - * @return - */ - public static boolean checkServer(Context ctx) { - boolean alive = DoomTools.pingServer(); - - if ( ! alive) { - //DialogTool.MessageBox(ctx, "Sever Ping Failed", "Make sure you have a web connection."); - return false; - } - return true; - } - /** * Clean sounds */ @@ -409,61 +305,5 @@ public class DoomTools { } if ( folder.exists() ) folder.delete(); } - - /** - * Cleanup game files - */ - private static void deleteWads() { - File folder = new File(DoomTools.DOOM_FOLDER); - - if ( !folder.exists()) { - Log.e(TAG, "Error: Doom folder " + folder + " not found."); - return; - } - - File[] files = folder.listFiles(); - - for (int i = 0; i < files.length; i++) { - - if (files[i].exists() ) - files[i].delete(); - } - if ( folder.exists() ) folder.delete(); - } - /** - * Add a default config to DOOM_FOLDER with default key bindings - * @param ctx - */ -// static final String DEFAULT_CFG = "prboom.cfg"; -// -// public static void createDefaultDoomConfig(Handler handler, Context ctx) { -// File dest = new File(DOOM_FOLDER + DEFAULT_CFG); -// -// // Skip if config exists -// if ( dest.exists()) { -// Log.w(TAG, "A default Doom config already exists in " + dest); -// return; -// } -// -// try { -// BufferedInputStream is = new BufferedInputStream( ctx.getAssets().open(DEFAULT_CFG)); -// FileOutputStream fos = new FileOutputStream(dest); -// -// byte[] buf = new byte [1024]; -// -// // let the user know -// Toast(handler, ctx, "Default movement keys: 1AQW"); -// -// Log.d(TAG, "Writing a default DOOM config to " + dest); -// -// for (int read = is.read(buf); read != -1; read = is.read(buf)) { -// fos.write(buf,0, read); -// } -// -// } catch (Exception e) { -// Log.e(TAG, "Error saving default DOOm config: " + e.toString()); -// } -// } - } diff --git a/app/src/main/java/doom/util/Natives.java b/app/src/main/java/doom/util/Natives.java index b4524f9..c05525d 100644 --- a/app/src/main/java/doom/util/Natives.java +++ b/app/src/main/java/doom/util/Natives.java @@ -37,7 +37,7 @@ public class Natives * @param argv * @return */ - public static native int DoomInit(String[] argv); + public static native int DoomInit(String[] argv, String wadDir); /** * Start frame rendering