mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Tweaked how the graphics mode setting is read
Changed all checks with Graphics::mode in the same way as 4.x. Added a couple of notes to ddraw.ini. Minor code edits.
This commit is contained in:
+2
-1
@@ -38,6 +38,7 @@ SpeedMultiInitial=100
|
||||
;Set to 6 for DX9 fullscreen windowed (the resolution in f2_res.ini should be set to the same aspect ratio as your desktop resolution)
|
||||
;A DX9 mode is required for any graphics related script extender functions to work (i.e. fullscreen shaders)
|
||||
;Modes 1, 2 and 3 are no longer supported
|
||||
;This option will always be read from the main ini file (i.e. ddraw.ini) when using the hi-res patch by Mash
|
||||
Mode=0
|
||||
|
||||
;If using a DX9 mode, this changes the resolution
|
||||
@@ -796,7 +797,7 @@ DisableSpecialAreas=0
|
||||
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
[Debugging]
|
||||
;Extra sfall configuration settings that can be used by modders
|
||||
;This section is not effected by the 'UseCommandLine' option. It will always be read from the main ini
|
||||
;This section is not affected by the 'UseCommandLine' option. It will always be read from the main ini file (i.e. ddraw.ini)
|
||||
|
||||
;Set to 1 to enable sfall debugging mode
|
||||
Enable=0
|
||||
|
||||
@@ -232,7 +232,7 @@ long __fastcall Items::item_w_mp_cost(fo::GameObject* source, fo::AttackType hit
|
||||
);
|
||||
}
|
||||
|
||||
static void __declspec(naked) item_w_mp_cost_hack() {
|
||||
static void __declspec(naked) item_w_mp_cost_replacement() {
|
||||
using namespace fo;
|
||||
__asm {
|
||||
push ebx; // isCalled
|
||||
@@ -248,7 +248,7 @@ void Items::init() {
|
||||
sf::HookCall(0x429A08, ai_search_inven_weap_hook);
|
||||
|
||||
// Replace the item_w_mp_cost_ function with the sfall implementation
|
||||
sf::MakeJump(fo::funcoffs::item_w_mp_cost_ + 1, item_w_mp_cost_hack); // 0x478B25
|
||||
sf::MakeJump(fo::funcoffs::item_w_mp_cost_ + 1, item_w_mp_cost_replacement); // 0x478B25
|
||||
|
||||
fastShotTweak = sf::IniReader::GetConfigInt("Misc", "FastShotFix", 0);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ long __fastcall Tilemap::tile_num_beyond(long sourceTile, long targetTile, long
|
||||
}
|
||||
|
||||
static void __declspec(naked) tile_num_beyond_replacement() {
|
||||
__asm { //push ecx;
|
||||
__asm { // push ecx;
|
||||
push ebx;
|
||||
mov ecx, eax;
|
||||
call Tilemap::tile_num_beyond;
|
||||
|
||||
+11
-3
@@ -50,6 +50,12 @@ static std::vector<std::string> getList(const char* section, const char* setting
|
||||
return list;
|
||||
}
|
||||
|
||||
static int setInt(const char* section, const char* setting, int value, const char* iniFile) {
|
||||
char buf[33];
|
||||
_itoa_s(value, buf, 33, 10);
|
||||
return WritePrivateProfileStringA(section, setting, buf, iniFile);
|
||||
}
|
||||
|
||||
const char* IniReader::GetConfigFile() {
|
||||
return ini;
|
||||
}
|
||||
@@ -107,9 +113,11 @@ std::vector<std::string> IniReader::GetList(const char* section, const char* set
|
||||
}
|
||||
|
||||
int IniReader::SetConfigInt(const char* section, const char* setting, int value) {
|
||||
char buf[33];
|
||||
_itoa_s(value, buf, 33, 10);
|
||||
return WritePrivateProfileStringA(section, setting, buf, ini);
|
||||
return setInt(section, setting, value, ini);
|
||||
}
|
||||
|
||||
int IniReader::SetDefaultConfigInt(const char* section, const char* setting, int value) {
|
||||
return setInt(section, setting, value, ddrawIni);
|
||||
}
|
||||
|
||||
int IniReader::SetDefaultConfigString(const char* section, const char* setting, const char* value) {
|
||||
|
||||
@@ -65,6 +65,8 @@ public:
|
||||
|
||||
static int SetConfigInt(const char* section, const char* setting, int value);
|
||||
|
||||
static int SetDefaultConfigInt(const char* section, const char* setting, int value);
|
||||
|
||||
static int SetDefaultConfigString(const char* section, const char* setting, const char* value);
|
||||
};
|
||||
|
||||
|
||||
@@ -1395,13 +1395,16 @@ static __declspec(naked) void dump_screen_hack_replacement() {
|
||||
}
|
||||
|
||||
void Graphics::init() {
|
||||
Graphics::mode = IniReader::GetConfigInt("Graphics", "Mode", 0);
|
||||
Graphics::mode = (hrpIsEnabled) // avoid mode mismatch between ddraw.ini and another ini file
|
||||
? IniReader::GetIntDefaultConfig("Graphics", "Mode", 0)
|
||||
: IniReader::GetConfigInt("Graphics", "Mode", 0);
|
||||
|
||||
if (Graphics::mode < 4 || Graphics::mode > 6) {
|
||||
Graphics::mode = 0;
|
||||
}
|
||||
IsWindowedMode = (Graphics::mode >= 5);
|
||||
|
||||
if (Graphics::mode != 0) {
|
||||
if (Graphics::mode >= 4) {
|
||||
dlog("Applying DX9 graphics patch.", DL_INIT);
|
||||
#define _DLL_NAME "d3dx9_42.dll"
|
||||
HMODULE h = LoadLibraryExA(_DLL_NAME, 0, LOAD_LIBRARY_AS_DATAFILE);
|
||||
@@ -1417,7 +1420,7 @@ void Graphics::init() {
|
||||
SafeWrite8(0x50FB6B, '2'); // Set call DirectDrawCreate2
|
||||
HookCall(0x44260C, game_init_hook);
|
||||
|
||||
MakeJump(fo::funcoffs::GNW95_SetPaletteEntries_ + 1, GNW95_SetPaletteEntries_replacement); // 0x4CB311
|
||||
MakeJump(fo::funcoffs::GNW95_SetPaletteEntries_ + 1, GNW95_SetPaletteEntries_replacement); // 0x4CB310
|
||||
MakeJump(fo::funcoffs::GNW95_SetPalette_, GNW95_SetPalette_replacement); // 0x4CB568
|
||||
|
||||
// Replace the screenshot saving implementation for sfall DirectX 9
|
||||
@@ -1479,7 +1482,7 @@ void Graphics::init() {
|
||||
}
|
||||
|
||||
void Graphics::exit() {
|
||||
if (Graphics::mode != 0) {
|
||||
if (Graphics::mode >= 4) {
|
||||
RECT rect;
|
||||
if (Graphics::mode == 5 && GetWindowRect(window, &rect)) {
|
||||
int data = rect.top | (rect.left << 16);
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
static __forceinline void UpdateDDSurface(BYTE* surface, int width, int height, int widthFrom, RECT* rect) {
|
||||
long x = rect->left;
|
||||
long y = rect->top;
|
||||
if (Graphics::mode == 0) {
|
||||
if (Graphics::mode < 4) {
|
||||
__asm {
|
||||
xor eax, eax;
|
||||
push y;
|
||||
|
||||
@@ -271,7 +271,7 @@ static bool __stdcall GameReset(DWORD isGameLoad) {
|
||||
if (gameLoaded) { // prevent resetting when a new game has not been started (loading saved game from main menu)
|
||||
// OnGameReset
|
||||
BugFixes::OnGameLoad();
|
||||
if (Graphics::mode) {
|
||||
if (Graphics::mode >= 4) {
|
||||
Graphics::ForceGraphicsRefresh(0); // disable refresh
|
||||
ScriptShaders::OnGameLoad();
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ void __stdcall SetShaderMode(DWORD d, DWORD mode) {
|
||||
}
|
||||
|
||||
int __stdcall LoadShader(const char* file) {
|
||||
if (Graphics::mode == 0 || strstr(file, "..") || strstr(file, ":")) return -1;
|
||||
if (Graphics::mode < 4 || strstr(file, "..") || strstr(file, ":")) return -1;
|
||||
char buf[MAX_PATH];
|
||||
sprintf_s(buf, "%s\\shaders\\%s", (*fo::ptr::master_db_handle)->path, file); // *fo::ptr::patches
|
||||
for (DWORD d = 0; d < shadersSize; d++) {
|
||||
@@ -225,7 +225,7 @@ void ScriptShaders::OnGameLoad() {
|
||||
}
|
||||
|
||||
void ScriptShaders::init() {
|
||||
if (Graphics::mode != 0) {
|
||||
if (Graphics::mode >= 4) {
|
||||
for each (const std::string& shaderFile in IniReader::GetConfigList("Graphics", "GlobalShaderFile", "", 1024)) {
|
||||
if (shaderFile.length() > 3) gShaderFiles.push_back(GlobalShader(shaderFile));
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ LRESULT CALLBACK SoundWndProc(HWND wnd, UINT msg, WPARAM w, LPARAM l) {
|
||||
|
||||
static void CreateSndWnd() {
|
||||
dlog("Creating sfall sound callback window.", DL_INIT);
|
||||
if (Graphics::mode == 0) CoInitialize(0);
|
||||
if (Graphics::mode < 4) CoInitialize(0);
|
||||
|
||||
WNDCLASSEX wcx;
|
||||
std::memset(&wcx, 0, sizeof(wcx));
|
||||
@@ -1072,7 +1072,7 @@ void Sound::init() {
|
||||
}
|
||||
|
||||
void Sound::exit() {
|
||||
if (soundwindow && Graphics::mode == 0) CoUninitialize();
|
||||
if (soundwindow && Graphics::mode < 4) CoUninitialize();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ void TalkingHeads::init() {
|
||||
// Disable centering the screen if NPC has talking head
|
||||
HookCall(0x445224, gdialogInitFromScript_hook);
|
||||
|
||||
if (Graphics::mode && IniReader::GetConfigInt("Graphics", "Use32BitHeadGraphics", 0)) {
|
||||
if (Graphics::mode >= 4 && IniReader::GetConfigInt("Graphics", "Use32BitHeadGraphics", 0)) {
|
||||
TalkingHeads::Use32Bit = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user