Permalink
Browse files

front: automatically set correct settings when loading HTC texture packs

  • Loading branch information...
fzurita committed Mar 11, 2016
1 parent 4b95f29 commit 6ecf5e2f2988e3de8b55a8c2fdb27bd1021d4d7d
@@ -31,6 +31,7 @@
#include <zlib.h>
#include <memory.h>
#include <stdlib.h>
+#include "../Log.h"
TxCache::~TxCache()
{
@@ -307,6 +308,8 @@ TxCache::save(const wchar_t *path, const wchar_t *filename, int config)
boolean
TxCache::load(const wchar_t *path, const wchar_t *filename, int config)
{
+ LOG(LOG_ERROR, "Loading!!! Path: %ls/%ls, config=0x%x", path, filename, config);
+
/* find it on disk */
char cbuf[MAX_PATH];
@@ -324,7 +327,7 @@ TxCache::load(const wchar_t *path, const wchar_t *filename, int config)
wcstombs(cbuf, filename, MAX_PATH);
gzFile gzfp = gzopen(cbuf, "rb");
- DBG_INFO(80, wst("gzfp:%x file:%ls\n"), gzfp, filename);
+ LOG(LOG_ERROR, "gzfp:%x file:%ls\n", gzfp, filename);
if (gzfp) {
/* yep, we have it. load it into memory cache. */
int dataSize;
@@ -333,7 +336,11 @@ TxCache::load(const wchar_t *path, const wchar_t *filename, int config)
/* read header to determine config match */
gzread(gzfp, &tmpconfig, 4);
+ LOG(LOG_ERROR, "Loading high res textures file_config=0x%x, current_config=0x%x",tmpconfig, config);
+
if (tmpconfig == config) {
+
+
do {
GHQTexInfo tmpInfo;
@@ -363,7 +370,6 @@ TxCache::load(const wchar_t *path, const wchar_t *filename, int config)
/* skip in between to prevent the loop from being tied down to vsync */
if (_callback && (!(_cache.size() % 100) || gzeof(gzfp)))
(*_callback)(wst("[%d] total mem:%.02fmb - %ls\n"), _cache.size(), (float)_totalSize/1000000, filename);
-
} while (!gzeof(gzfp));
gzclose(gzfp);
}
@@ -52,6 +52,7 @@
#include <math.h>
#include <stdlib.h>
#include <string.h>
+#include "../Log.h"
TxHiResCache::~TxHiResCache()
{
@@ -97,6 +98,7 @@ TxHiResCache::TxHiResCache(int maxwidth, int maxheight, int maxbpp, int options,
}
#if DUMP_CACHE
+
/* read in hires texture cache */
if (_options & DUMP_HIRESTEXCACHE) {
/* find it on disk */
@@ -106,6 +108,8 @@ TxHiResCache::TxHiResCache(int maxwidth, int maxheight, int maxbpp, int options,
cachepath += wst("cache");
int config = _options & (HIRESTEXTURES_MASK|TILE_HIRESTEX|FORCE16BPP_HIRESTEX|GZ_HIRESTEXCACHE|LET_TEXARTISTS_FLY);
+ LOG(LOG_ERROR, "config=0x%x, options=0x%x", config, _options);
+
_haveCache = TxCache::load(cachepath.c_str(), filename.c_str(), config);
}
#endif
@@ -20,6 +20,15 @@
*/
package paulscode.android.mupen64plusae.jni;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.zip.GZIPInputStream;
+
import paulscode.android.mupen64plusae.persistent.AppData;
import paulscode.android.mupen64plusae.persistent.ConfigFile;
import paulscode.android.mupen64plusae.persistent.GamePrefs;
@@ -29,6 +38,15 @@
{
private final static String EMPTY = "\"\"";
+ private static final int GZ_HIRESTEXCACHE = 0x00800000;
+ private static final int FORCE16BPP_HIRESTEX = 0x10000000;
+ private static final int LET_TEXARTISTS_FLY = 0x40000000;
+
+ private static boolean hiresTexHTCPresent = false;
+ private static boolean zipTextureCache = false;
+ private static boolean force16bpp = false;
+ private static boolean fullAlphaChannel = false;
+
/**
* Populates the core configuration files with the user preferences.
*/
@@ -133,6 +151,8 @@ public static void syncConfigFiles( GamePrefs game, GlobalPrefs global, AppData
if( game.emulationProfile.get( "WidescreenHack", "False" ).equals("True") )
aspectRatio = "3";
+ readHiResSettings(game, global, appData);
+
mupen64plus_cfg.put( "Video-GLideN64", "configVersion", "7" );
mupen64plus_cfg.put( "Video-GLideN64", "AspectRatio", aspectRatio);
mupen64plus_cfg.put( "Video-GLideN64", "ForcePolygonOffset", boolToTF( global.isPolygonOffsetHackEnabled ) );
@@ -163,12 +183,23 @@ public static void syncConfigFiles( GamePrefs game, GlobalPrefs global, AppData
mupen64plus_cfg.put( "Video-GLideN64", "txFilterIgnoreBG", boolToNum( game.gliden64TxFilterIgnoreBG ) );
mupen64plus_cfg.put( "Video-GLideN64", "txCacheSize", String.valueOf( game.gliden64TxCacheSize ) );
mupen64plus_cfg.put( "Video-GLideN64", "txHiresEnable", boolToNum( game.gliden64TxHiresEnable ) );
- mupen64plus_cfg.put( "Video-GLideN64", "txHiresFullAlphaChannel", boolToNum( game.gliden64TxHiresFullAlphaChannel ) );
- mupen64plus_cfg.put( "Video-GLideN64", "txHresAltCRC", boolToNum( game.gliden64TxHresAltCRC ) );
+
+ if(hiresTexHTCPresent && game.gliden64TxHiresEnable)
+ {
+ mupen64plus_cfg.put( "Video-GLideN64", "txHiresFullAlphaChannel", boolToNum( fullAlphaChannel ) );
+ mupen64plus_cfg.put( "Video-GLideN64", "txCacheCompression", boolToNum( zipTextureCache ) );
+ mupen64plus_cfg.put( "Video-GLideN64", "txForce16bpp", boolToNum( force16bpp ) );
+ mupen64plus_cfg.put( "Video-GLideN64", "txSaveCache", boolToNum( true ) );
+ }
+ else
+ {
+ mupen64plus_cfg.put( "Video-GLideN64", "txHiresFullAlphaChannel", boolToNum( game.gliden64TxHiresFullAlphaChannel ) );
+ mupen64plus_cfg.put( "Video-GLideN64", "txCacheCompression", boolToNum( game.gliden64TxCacheCompression ) );
+ mupen64plus_cfg.put( "Video-GLideN64", "txForce16bpp", boolToNum( game.gliden64TxForce16bpp ) );
+ mupen64plus_cfg.put( "Video-GLideN64", "txSaveCache", boolToNum( game.gliden64TxSaveCache ) );
+ }
mupen64plus_cfg.put( "Video-GLideN64", "txDump", "0" );
- mupen64plus_cfg.put( "Video-GLideN64", "txCacheCompression", boolToNum( game.gliden64TxCacheCompression ) );
- mupen64plus_cfg.put( "Video-GLideN64", "txForce16bpp", boolToNum( game.gliden64TxForce16bpp ) );
- mupen64plus_cfg.put( "Video-GLideN64", "txSaveCache", boolToNum( game.gliden64TxSaveCache ) );
+ mupen64plus_cfg.put( "Video-GLideN64", "txHresAltCRC", boolToNum( game.gliden64TxHresAltCRC ) );
mupen64plus_cfg.put( "Video-GLideN64", "fontName", "DroidSans.ttf" );
mupen64plus_cfg.put( "Video-GLideN64", "fontSize", "18" );
mupen64plus_cfg.put( "Video-GLideN64", "fontColor", "B5E61D" );
@@ -212,4 +243,53 @@ private static String boolToNum( boolean b )
{
return b ? "1" : "0";
}
+
+ private static void readHiResSettings( GamePrefs game, GlobalPrefs global, AppData appData)
+ {
+ final String hiResHtc = global.textureCacheDir + "/" + game.gameHeaderName + "_HIRESTEXTURES.htc";
+ final File htcFile = new File(hiResHtc);
+
+ hiresTexHTCPresent = htcFile.exists();
+
+ if(hiresTexHTCPresent)
+ {
+ InputStream stream = null;
+ InputStream gzipStream = null;
+
+ try
+ {
+ stream = new FileInputStream(htcFile);
+ gzipStream = new GZIPInputStream(stream);
+
+ final byte[] buffer = new byte[4];
+
+ gzipStream.read(buffer);
+ final ByteBuffer wrapped = ByteBuffer.wrap(buffer);
+ wrapped.order(ByteOrder.LITTLE_ENDIAN);
+ final int config = wrapped.getInt();
+
+ zipTextureCache = (config & GZ_HIRESTEXCACHE) == GZ_HIRESTEXCACHE;
+ force16bpp = (config & FORCE16BPP_HIRESTEX) == FORCE16BPP_HIRESTEX;
+ fullAlphaChannel = (config & LET_TEXARTISTS_FLY) == LET_TEXARTISTS_FLY;
+ }
+ catch (final FileNotFoundException e)
+ {
+ hiresTexHTCPresent = false;
+ }
+ catch (final IOException e)
+ {
+ hiresTexHTCPresent = false;
+ }
+ finally
+ {
+ try
+ {
+ gzipStream.close();
+ }
+ catch (final IOException e)
+ {
+ }
+ }
+ }
+ }
}
@@ -42,6 +42,9 @@
/** The subdirectory containing manual save files. */
public final String userSaveDir;
+ /** Game header name */
+ public final String gameHeaderName;
+
/** The subdirectory containing user screenshots. */
public final String screenshotDir;
@@ -406,6 +409,7 @@
public GamePrefs( Context context, String romMd5, String crc, String headerName, String countrySymbol,
AppData appData, GlobalPrefs globalPrefs)
{
+ gameHeaderName = headerName;
sharedPrefsName = romMd5.replace(' ', '_' ) + "_preferences";
mPreferences = context.getSharedPreferences( sharedPrefsName, Context.MODE_PRIVATE );
Oops, something went wrong.

0 comments on commit 6ecf5e2

Please sign in to comment.