diff --git a/artifacts/example_mods/GlobalShaders/global.fx b/artifacts/example_mods/GlobalShaders/global.fx index 4991b3ed..47c73e09 100644 --- a/artifacts/example_mods/GlobalShaders/global.fx +++ b/artifacts/example_mods/GlobalShaders/global.fx @@ -36,7 +36,7 @@ int w; int h; // the pixel size is computed as: 1.0f / resolution -float2 rcpRes; +float2 rcpres; // system ticks (received from sfall) //int tickcount; @@ -65,7 +65,7 @@ float4 BlurDeltaPassPS(float2 uv : TEXCOORD0, uniform float2 delta) : COLOR0 float3 sumColor = (tex2D(s0, uv).rgb); float brightness = Brightness(sumColor); - delta *= rcpRes; + delta *= rcpres; float totalWeight = 1; float2 pointUV = uv + delta; @@ -77,8 +77,8 @@ float4 BlurDeltaPassPS(float2 uv : TEXCOORD0, uniform float2 delta) : COLOR0 return float4((sumColor / totalWeight), 1); } -static const float2 wDelta = float2(1, 0) * rcpRes; -static const float2 hDelta = float2(0, 1) * rcpRes; +static const float2 wDelta = float2(1, 0) * rcpres; +static const float2 hDelta = float2(0, 1) * rcpres; float4 BlurPS(float4 color : COLOR0, float2 uv : TEXCOORD0) : COLOR0 { @@ -171,8 +171,8 @@ static const float sharpenVal0 = (Sharpen * (1.5 + EdgeSharpen)); static const float sharpenVal1 = ((sharpenVal0 - 1) / 8.0); // pixel "width" -static const float px = rcpRes.x; -static const float py = rcpRes.y; +static const float px = rcpres.x; +static const float py = rcpres.y; // for the blur filter #define mean 1.0 diff --git a/artifacts/scripting/sfall function notes.txt b/artifacts/scripting/sfall function notes.txt index 420214c1..bc57408c 100644 --- a/artifacts/scripting/sfall function notes.txt +++ b/artifacts/scripting/sfall function notes.txt @@ -685,7 +685,7 @@ optional arguments: - width (optional): the maximum width of the text. The text will be wrapped to fit within the specified width > mixed sfall_func0("combat_data") -- returns a pointer to the C_ATTACK_* data for the current combat attack turn (see defined constants in define_extra.h) +- returns a pointer to the C_ATTACK_* data for the current combat attack process (see defined constants in define_extra.h) - can be used in conjunction with the get_object_data and set_object_data functions example: sfall_func3("set_object_data", sfall_func0("combat_data"), C_ATTACK_UNUSED, 255); diff --git a/sfall/Graphics.cpp b/sfall/Graphics.cpp index 92535437..b50dfe5c 100644 --- a/sfall/Graphics.cpp +++ b/sfall/Graphics.cpp @@ -20,7 +20,6 @@ #include "FalloutEngine.h" #include "InputFuncs.h" #include "LoadGameHook.h" -#include "Version.h" #include "Graphics.h" @@ -176,7 +175,7 @@ static VertexFormat ShaderVertices[] = { {639.5, 479.5, 0, 1, 1, 1} // 3 - bottom right }; -HWND GetFalloutWindowInfo(RECT* rect) { +HWND Gfx_GetFalloutWindowInfo(RECT* rect) { if (rect) { rect->left = windowLeft; rect->top = windowTop; @@ -212,8 +211,7 @@ void __stdcall SetShaderMode(DWORD d, DWORD mode) { int __stdcall LoadShader(const char* file) { if (!GraphicsMode || strstr(file, "..") || strstr(file, ":")) return -1; char buf[MAX_PATH]; - PathNode* masterPtr = *ptr_master_db_handle; - sprintf_s(buf, "%s\\shaders\\%s", masterPtr->path, file); // *ptr_patches + sprintf_s(buf, "%s\\shaders\\%s", (*ptr_master_db_handle)->path, file); // *ptr_patches for (DWORD d = 0; d < shadersSize; d++) { if (!shaders[d].Effect) { if (FAILED(D3DXCreateEffectFromFile(d3d9Device, buf, 0, 0, 0, 0, &shaders[d].Effect, 0))) { @@ -234,8 +232,9 @@ int __stdcall LoadShader(const char* file) { sprintf(buf, "texname%d", i); if (FAILED(shader.Effect->GetString(buf, &name))) break; - sprintf_s(buf, "%s\\art\\stex\\%s", masterPtr->path, name); // *ptr_patches + sprintf_s(buf, "%s\\art\\stex\\%s", (*ptr_master_db_handle)->path, name); // *ptr_patches if (FAILED(D3DXCreateTextureFromFileA(d3d9Device, buf, &tex))) continue; + sprintf(buf, "tex%d", i); shader.Effect->SetTexture(buf, tex); shaderTextures.push_back(tex); @@ -1268,15 +1267,17 @@ static __declspec(naked) void palette_fade_to_hook() { //////////////////////////////////////////////////////////////////////////////// -static void __forceinline UpdateDDSurface(BYTE* surface, int width, int height, int widthFrom, RECT* rect) { - DDSURFACEDESC desc; - RECT lockRect = { rect->left, rect->top, rect->right + 1, rect->bottom + 1 }; +static __forceinline void UpdateDDSurface(BYTE* surface, int width, int height, int widthFrom, RECT* rect) { + if (!DeviceLost) { + DDSURFACEDESC desc; + RECT lockRect = { rect->left, rect->top, rect->right + 1, rect->bottom + 1 }; - primaryDDSurface->Lock(&lockRect, &desc, 0, 0); + primaryDDSurface->Lock(&lockRect, &desc, 0, 0); - BufToBuf(surface, width, height, widthFrom, (BYTE*)desc.lpSurface, desc.lPitch); //+ (desc.lPitch * rect->top) + rect->left + BufToBuf(surface, width, height, widthFrom, (BYTE*)desc.lpSurface, desc.lPitch); //+ (desc.lPitch * rect->top) + rect->left - primaryDDSurface->Unlock(desc.lpSurface); + primaryDDSurface->Unlock(desc.lpSurface); + } } static BYTE* GetBuffer() { @@ -1301,10 +1302,8 @@ static void __fastcall sf_GNW_win_refresh(WINinfo* win, RECT* updateRect, BYTE* mov edx, updateRect; call GNW_button_refresh_; }*/ - if (!DeviceLost) { - int h = (updateRect->bottom - updateRect->top) + 1; - UpdateDDSurface(GetBuffer(), w, h, w, updateRect); // update the entire rectangle area - } + int h = (updateRect->bottom - updateRect->top) + 1; + UpdateDDSurface(GetBuffer(), w, h, w, updateRect); // update the entire rectangle area } else { MouseShow(); // for updating background cursor area RECT mouseRect; @@ -1322,11 +1321,10 @@ static void __fastcall sf_GNW_win_refresh(WINinfo* win, RECT* updateRect, BYTE* mov edx, rects; call GNW_button_refresh_; }*/ - if (!DeviceLost) { - int wRect = (rects->wRect.right - rects->wRect.left) + 1; - int hRect = (rects->wRect.bottom - rects->wRect.top) + 1; - UpdateDDSurface(&GetBuffer()[rects->wRect.left - updateRect->left] + (rects->wRect.top - updateRect->top) * w, wRect, hRect, w, &rects->wRect); - } + int wRect = (rects->wRect.right - rects->wRect.left) + 1; + int hRect = (rects->wRect.bottom - rects->wRect.top) + 1; + UpdateDDSurface(&GetBuffer()[rects->wRect.left - updateRect->left] + (rects->wRect.top - updateRect->top) * w, wRect, hRect, w, &rects->wRect); + RectList* next = rects->nextRect; sf_rect_free(rects); rects = next; @@ -1336,10 +1334,8 @@ static void __fastcall sf_GNW_win_refresh(WINinfo* win, RECT* updateRect, BYTE* } /* Allocates memory for 10 RectList (if no memory was allocated), returns the first Rect and removes it from the list */ - __asm { - call rect_malloc_; - mov rects, eax; - } + __asm call rect_malloc_; + __asm mov rects, eax; if (!rects) return; rects->rect.x = updateRect->left; @@ -1393,7 +1389,7 @@ static void __fastcall sf_GNW_win_refresh(WINinfo* win, RECT* updateRect, BYTE* } else { // copy to buffer instead of DD surface (buffering) drawFunc(surface, width, height, widthFrom, &GetBuffer()[crect.left] + (crect.top * toWidth), toWidth); - //if (!DeviceLost) UpdateDDSurface(surface, width, height, widthFrom, crect); + //UpdateDDSurface(surface, width, height, widthFrom, crect); } if (win->wID == 0) delete[] surface; @@ -1402,7 +1398,7 @@ static void __fastcall sf_GNW_win_refresh(WINinfo* win, RECT* updateRect, BYTE* while (rects) { // copy all rectangles from the buffer to the DD surface (buffering) - if (!toBuffer && !DeviceLost) { + if (!toBuffer) { int width = (rects->rect.offx - rects->rect.x) + 1; int height = (rects->rect.offy - rects->rect.y) + 1; int widthFrom = toWidth; diff --git a/sfall/Graphics.h b/sfall/Graphics.h index 06f56f01..669369b5 100644 --- a/sfall/Graphics.h +++ b/sfall/Graphics.h @@ -35,6 +35,7 @@ void GraphicsInit(); void GraphicsExit(); void Graphics_OnGameLoad(); +HWND Gfx_GetFalloutWindowInfo(RECT* rect); long Gfx_GetGameWidthRes(); long Gfx_GetGameHeightRes(); @@ -63,5 +64,3 @@ void __stdcall SetShaderVector(DWORD d, const char* param, float f1, float f2, f int __stdcall GetShaderTexture(DWORD d, DWORD id); void __stdcall SetShaderTexture(DWORD d, const char* param, DWORD value); - -HWND GetFalloutWindowInfo(RECT* rect); diff --git a/sfall/MetaruleExtender.cpp b/sfall/MetaruleExtender.cpp index 125baf7a..e262d19e 100644 --- a/sfall/MetaruleExtender.cpp +++ b/sfall/MetaruleExtender.cpp @@ -48,7 +48,7 @@ static long __fastcall op_metarule3_ext(long metafunc, long* args) { } else { if (argValue > 127) argValue = 127; SafeWrite8(HorriganEncounterDays, static_cast(argValue)); - HorriganEncounterSetDays = static_cast(argValue); + HorriganEncounterSetDays = static_cast(argValue); } break; }