Skip to content

Commit

Permalink
Add support for shadow scaling and button mods
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaldaien committed Jan 13, 2017
1 parent fc42e1d commit ce62e9b
Show file tree
Hide file tree
Showing 18 changed files with 940 additions and 508 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
################################################################################

/.vs/tbf/v14/.suo
/x64/Debug/tbf.tlog
/x64/Debug
/x64/Release
tbf.VC.db
4 changes: 2 additions & 2 deletions include/DLL_VERSION.H
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@


#define TBF_MAJOR 0
#define TBF_MINOR 0
#define TBF_BUILD 1
#define TBF_MINOR 1
#define TBF_BUILD 0
#define TBF_REV 0


Expand Down
36 changes: 21 additions & 15 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,32 @@ struct tbf_config_t
} lua;

struct {
float fovy = 0.785398f;
float aspect_ratio = 1.777778f;
DWORD aspect_addr = 0x00D56494;//0x00D52398;
DWORD fovy_addr = 0x00D56498;//0x00D5239C;
bool blackbar_videos = true; // OBSOLETE
bool aspect_correction = true;
int32_t shadow_rescale = -2;
float postproc_ratio = 1.0f;
bool clear_blackbars = true;
int32_t env_shadow_rescale = 0;
float fovy = 0.785398f;
float aspect_ratio = 1.777778f;
uintptr_t aspect_addr = 0x00D56494ULL;//0x00D52398;
uintptr_t fovy_addr = 0x00D56498ULL;//0x00D5239C;
bool blackbar_videos = false; // OBSOLETE
bool aspect_correction = false;
int32_t shadow_rescale = -2;
float postproc_ratio = 0.0f;
bool clear_blackbars = false;
int32_t env_shadow_rescale = 0;
} render;

struct {
bool dump = false;
bool remaster = false;
bool cache = true;
int32_t max_cache_in_mib = 2048L;
int32_t worker_threads = 6;
bool dump = false;
bool remaster = true;
bool cache = true;
int32_t max_cache_in_mib = 2048L;
int32_t worker_threads = 6;
} textures;

struct {
struct {
std::wstring texture_set = L"XboxOne";
} gamepad;
} input;

struct {
std::wstring swap_keys = L"";
} keyboard;
Expand Down
35 changes: 35 additions & 0 deletions include/input.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* This file is part of Tales of Berseria "Fix".
*
* Tales of Berseria "Fix" 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 3 of
* the License, or (at your option) any later version.
*
* Tales of Berseria "Fix" is distributed in the hope that it will be
* useful,
*
* But WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tales of Berseria "Fix".
*
* If not, see <http://www.gnu.org/licenses/>.
*
**/

#ifndef __TBF__INPUT_H__
#define __TBF__INPUT_H__

namespace tbf
{
namespace InputFix
{
void Init ();
void Shutdown ();
};
};

#endif /* __TBF__INPUT_H__ */
28 changes: 19 additions & 9 deletions include/render.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ namespace tbf
static CommandProcessor* pCommProc;
};

extern bool fullscreen;

extern uint32_t width;
extern uint32_t height;

Expand Down Expand Up @@ -150,18 +152,20 @@ struct game_state_t {
(((data_t *)base_addr)->Loading1 & 0x1); }

bool hasFixedAspect (void) {
if (((data_t *)base_addr)->OpeningMovie ||
((data_t *)base_addr)->Title ||
((data_t *)base_addr)->Menu ||
in_skit)
return true;
return false;
//if (((data_t *)base_addr)->OpeningMovie ||
//((data_t *)base_addr)->Title ||
//((data_t *)base_addr)->Menu ||
//in_skit)
//return true;
//return false;
}
bool needsFixedMouseCoords(void) {
return (((data_t *)base_addr)->GamePause ||
((data_t *)base_addr)->Menu ||
((data_t *)base_addr)->BattlePause ||
((data_t *)base_addr)->Title);
return false;
//return (((data_t *)base_addr)->GamePause ||
//((data_t *)base_addr)->Menu ||
//((data_t *)base_addr)->BattlePause ||
//((data_t *)base_addr)->Title);
}
} static game_state;

Expand All @@ -175,6 +179,12 @@ typedef HRESULT (STDMETHODCALLTYPE *EndScene_pfn)(

#include <d3d9.h>

typedef D3DPRESENT_PARAMETERS* (__stdcall *SK_SetPresentParamsD3D9_pfn)
(
IDirect3DDevice9 *pDevice,
D3DPRESENT_PARAMETERS *pParams
);

typedef HRESULT (STDMETHODCALLTYPE *DrawPrimitive_pfn)
(
IDirect3DDevice9 *This,
Expand Down
18 changes: 4 additions & 14 deletions include/textures.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,12 @@ namespace RenderFix {
ISKTextureD3D9* d3d9_tex;
};

struct frame_texture_t {
const uint32_t crc32_corner = 0x6465f296;
const uint32_t crc32_side = 0xace25896;

IDirect3DBaseTexture9* tex_corner = (IDirect3DBaseTexture9 *)1;
IDirect3DBaseTexture9* tex_side = (IDirect3DBaseTexture9 *)1;

bool in_use = false;
} extern cutscene_frame;

struct pad_buttons_t {
const uint32_t crc32_ps3 = 0x8D7A5256;
const uint32_t crc32_xbox = 0x74F5352D;
const uint32_t crc32_ps4 = 0xBFDF5B6F;
const uint32_t crc32_xboxone = 0x1DE50346;

IDirect3DTexture9* tex_ps3 = nullptr;
IDirect3DTexture9* tex_xbox = nullptr;
IDirect3DTexture9* tex_ps4 = nullptr;
IDirect3DTexture9* tex_xboxone = nullptr;
} extern pad_buttons;

class TextureManager {
Expand Down
Binary file added resource/version.aps
Binary file not shown.
128 changes: 126 additions & 2 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ std::wstring DEFAULT_BK2 = L"RAW\\MOVIE\\AM_TOZ_OP_001.BK2";

static
iSK_INI* dll_ini = nullptr;
static
iSK_INI* gamepad_ini = nullptr;
tbf_config_t config;

tbf::ParameterFactory g_ParameterFactory;
Expand Down Expand Up @@ -97,6 +99,12 @@ struct {
tbf::ParameterBool* fix_priest;
} lua;

struct {
struct {
tbf::ParameterStringW* texture_set;
} gamepad;
} input;

struct {
tbf::ParameterStringW* intro_video;
tbf::ParameterStringW* version;
Expand All @@ -118,12 +126,16 @@ TBF_LoadConfig (std::wstring name)

// Load INI File
wchar_t wszFullName [ MAX_PATH + 2 ] = { L'\0' };
wchar_t wszPadName [ MAX_PATH + 2 ] = { L'\0' };

lstrcatW (wszFullName, SK_GetConfigPath ());
lstrcatW (wszFullName, name.c_str ());
lstrcatW (wszFullName, L".ini");
dll_ini = TBF_CreateINI (wszFullName);

lstrcatW (wszPadName, SK_GetConfigPath ());
lstrcatW (wszPadName, L"TBFix_Gamepad.ini");
gamepad_ini = TBF_CreateINI (wszPadName);

bool empty = dll_ini->get_sections ().empty ();

Expand Down Expand Up @@ -172,6 +184,79 @@ TBF_LoadConfig (std::wstring name)
L"EnableFix" );


textures.cache =
static_cast <tbf::ParameterBool *>
(g_ParameterFactory.create_parameter <bool> (
L"Cache Textures to Speed Up Menus (and Remaster)")
);
textures.cache->register_to_ini (
dll_ini,
L"TBFIX.Textures",
L"Cache" );

textures.dump =
static_cast <tbf::ParameterBool *>
(g_ParameterFactory.create_parameter <bool> (
L"Dump Textures as they are loaded")
);
textures.dump->register_to_ini (
dll_ini,
L"TBFIX.Textures",
L"Dump" );

textures.remaster =
static_cast <tbf::ParameterBool *>
(g_ParameterFactory.create_parameter <bool> (
L"Various Fixes to Eliminate Texture Aliasing")
);
textures.remaster->register_to_ini (
dll_ini,
L"TBFIX.Textures",
L"Remaster" );

textures.cache_size =
static_cast <tbf::ParameterInt *>
(g_ParameterFactory.create_parameter <int> (
L"Size of Texture Cache")
);
textures.cache_size->register_to_ini (
dll_ini,
L"TBFIX.Textures",
L"MaxCacheInMiB" );

textures.worker_threads =
static_cast <tbf::ParameterInt *>
(g_ParameterFactory.create_parameter <int> (
L"Number of Worker Threads")
);
textures.worker_threads->register_to_ini (
dll_ini,
L"TBFIX.Textures",
L"WorkerThreads" );


render.rescale_shadows =
static_cast <tbf::ParameterInt *>
(g_ParameterFactory.create_parameter <int> (
L"Shadow Rescale Factor")
);
render.rescale_shadows->register_to_ini (
dll_ini,
L"TBFIX.Render",
L"RescaleShadows" );


input.gamepad.texture_set =
static_cast <tbf::ParameterStringW *>
(g_ParameterFactory.create_parameter <std::wstring> (
L"Gamepad Type")
);
input.gamepad.texture_set->register_to_ini (
gamepad_ini,
L"Gamepad.Type",
L"TextureSet" );


sys.version =
static_cast <tbf::ParameterStringW *>
(g_ParameterFactory.create_parameter <std::wstring> (
Expand Down Expand Up @@ -210,10 +295,26 @@ TBF_LoadConfig (std::wstring name)
audio.compatibility->load ( config.audio.compatibility );
audio.enable_fix->load ( config.audio.enable_fix );

render.rescale_shadows->load (config.render.shadow_rescale);

//textures.remaster->load (config.textures.remaster);
textures.cache->load (config.textures.cache);
textures.dump->load (config.textures.dump);
textures.cache_size->load (config.textures.max_cache_in_mib);
textures.worker_threads->load (config.textures.worker_threads);

sys.version->load (config.system.version);
sys.intro_video->load (config.system.intro_video);
//sys.intro_video->load (config.system.intro_video);
sys.injector->load (config.system.injector);

if (gamepad_ini->get_sections ().empty ()) {
TBF_SaveConfig (name, false);

gamepad_ini->parse ();
}

input.gamepad.texture_set->load (config.input.gamepad.texture_set);

if (empty)
return false;

Expand All @@ -228,11 +329,22 @@ TBF_SaveConfig (std::wstring name, bool close_config)
audio.compatibility->store (config.audio.compatibility);
audio.enable_fix->store (config.audio.enable_fix);

render.rescale_shadows->store (config.render.shadow_rescale);

//textures.remaster->store (config.textures.remaster);
textures.cache->store (config.textures.cache);
textures.dump->store (config.textures.dump);
textures.cache_size->store (config.textures.max_cache_in_mib);
textures.worker_threads->store (config.textures.worker_threads);

input.gamepad.texture_set->store (config.input.gamepad.texture_set);

sys.version->store (TBF_VER_STR);
sys.intro_video->store (config.system.intro_video);
//sys.intro_video->store (config.system.intro_video);
sys.injector->store (config.system.injector);

wchar_t wszFullName [ MAX_PATH + 2 ] = { L'\0' };
wchar_t wszPadName [ MAX_PATH + 2 ] = { L'\0' };

lstrcatW ( wszFullName,
SK_GetConfigPath () );
Expand All @@ -243,10 +355,22 @@ TBF_SaveConfig (std::wstring name, bool close_config)

dll_ini->write (wszFullName);

lstrcatW ( wszPadName,
SK_GetConfigPath () );
lstrcatW ( wszPadName,
L"TBFix_Gamepad.ini" );

gamepad_ini->write (wszPadName);

if (close_config) {
if (dll_ini != nullptr) {
delete dll_ini;
dll_ini = nullptr;
}

if (gamepad_ini != nullptr) {
delete gamepad_ini;
gamepad_ini = nullptr;
}
}
}
4 changes: 2 additions & 2 deletions src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ DllThread (LPVOID user)
tbf::SoundFix::Init ();
//tbf::FileIO::Init ();
//tbf::SteamFix::Init ();
//tbf::RenderFix::Init ();
tbf::RenderFix::Init ();
//tbf::FrameRateFix::Init ();
//tbf::KeyboardFix::Init ();

Expand Down Expand Up @@ -193,7 +193,7 @@ DllMain (HMODULE hModule,
tbf::SoundFix::Shutdown ();
//tbf::FileIO::Shutdown ();
//tbf::SteamFix::Shutdown ();
//tbf::RenderFix::Shutdown ();
tbf::RenderFix::Shutdown ();
//tbf::FrameRateFix::Shutdown ();
//tbf::KeyboardFix::Shutdown ();

Expand Down
Loading

0 comments on commit ce62e9b

Please sign in to comment.