mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Some code refactoring
Added a value of 2 to TextureFilter option.
This commit is contained in:
+2
-1
@@ -56,7 +56,8 @@ WindowData=0
|
||||
;You can specify multiple shader files, separated by commas
|
||||
;GlobalShaderFile=global.fx
|
||||
|
||||
;Set to 1 to enable linear texture filtering
|
||||
;Set to 1 to automatically enable linear texture filtering when the scale factor is not an integer
|
||||
;Set to 2 to force-enable linear texture filtering
|
||||
;This can be used in conjunction with the GlobalShaderFile option
|
||||
TextureFilter=1
|
||||
|
||||
|
||||
@@ -657,7 +657,7 @@ optional arguments:
|
||||
- x/y: offset relative to the top-left corner of the window
|
||||
optional arguments:
|
||||
- frame: frame number, the first frame starts from zero
|
||||
- param: an array which specifies additional parameters:
|
||||
- param: an array which specifies additional parameters, where:
|
||||
index 0 - sprite direction for multi-directional FRM
|
||||
index 1/index 2 - the new width/height to scale the image to. Pass -1 to use the original width/height
|
||||
|
||||
|
||||
+2
-2
@@ -908,7 +908,7 @@ static void __declspec(naked) make_path_func_hook() {
|
||||
cmp ebx, [esp + 0x5C - 0x1C + 4]; // target tile
|
||||
je fix;
|
||||
jmp anim_can_use_door_;
|
||||
fix:
|
||||
fix: // replace the target tile (where the multihex object is located) with the current tile
|
||||
mov ebx, [esp + 0x5C - 0x14 + 4]; // current tile
|
||||
mov [esp + 0x5C - 0x1C + 4], ebx; // target tile
|
||||
retn;
|
||||
@@ -3180,7 +3180,7 @@ void BugFixesInit()
|
||||
HookCall(0x4A22DF, ResetPlayer_hook);
|
||||
|
||||
// Fix for add_mult_objs_to_inven only adding 500 of an object when the value of the "count" argument is over 99999
|
||||
SafeWrite32(0x45A2A0, 0x1869F); // 99999
|
||||
SafeWrite32(0x45A2A0, 99999);
|
||||
|
||||
// Fix for being at incorrect hex after map change when the exit hex in source map is at the same position as
|
||||
// some exit hex in destination map
|
||||
|
||||
@@ -1416,13 +1416,8 @@ long wmGetCurrentTerrainType() {
|
||||
// copy the area from the interface buffer to the data array
|
||||
void SurfaceCopyToMem(long fromX, long fromY, long width, long height, long fromWidth, BYTE* fromSurface, BYTE* toMem) {
|
||||
fromSurface += fromY * fromWidth + fromX;
|
||||
long i = 0;
|
||||
for (long h = 0; h < height; h++) {
|
||||
/*for (long w = 0; w < width; w++) {
|
||||
toMem[i++] = fromSurface[w];
|
||||
}*/
|
||||
for (long i = 0, h = 0; h < height; h++, i += width) {
|
||||
std::memcpy(&toMem[i], fromSurface, width);
|
||||
i += width;
|
||||
fromSurface += fromWidth;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1333,6 +1333,6 @@ DWORD __stdcall GetMaxCharWidth();
|
||||
void RedrawObject(TGameObj* obj);
|
||||
|
||||
// Redraws all interface windows
|
||||
void RefreshGNW(size_t from);
|
||||
void RefreshGNW(size_t from = 0);
|
||||
|
||||
UNLSTDfrm *LoadUnlistedFrm(char *frmName, unsigned int folderRef);
|
||||
|
||||
+35
-13
@@ -250,6 +250,17 @@ struct sElevatorFrms {
|
||||
DWORD buttons;
|
||||
};
|
||||
|
||||
// structures for holding frms loaded with fallout2 functions
|
||||
typedef class FrmFrameData { // sizeof 12 + 1 byte
|
||||
public:
|
||||
WORD width;
|
||||
WORD height;
|
||||
DWORD size; // width * height
|
||||
WORD x;
|
||||
WORD y;
|
||||
BYTE data[1]; // begin frame image data
|
||||
} FrmFrameData;
|
||||
|
||||
struct FrmFile {
|
||||
long id; //0x00
|
||||
short fps; //0x04
|
||||
@@ -259,24 +270,35 @@ struct FrmFile {
|
||||
short yshift[6]; //0x16
|
||||
long oriFrameOffset[6]; //0x22
|
||||
long frameAreaSize; //0x3a
|
||||
short width; //0x3e
|
||||
union { //0x3e
|
||||
FrmFrameData *frameData;
|
||||
short width;
|
||||
};
|
||||
short height; //0x40
|
||||
long frameSize; //0x42
|
||||
short xoffset; //0x46
|
||||
short yoffset; //0x48
|
||||
BYTE pixels[80 * 36]; //0x4a
|
||||
};
|
||||
union { //0x4a
|
||||
BYTE *pixelData;
|
||||
BYTE pixels[80 * 36]; // for tiles FRM
|
||||
};
|
||||
|
||||
//structures for holding frms loaded with fallout2 functions
|
||||
typedef class FrmFrameData { // sizeof 12 + 1 byte
|
||||
public:
|
||||
WORD width;
|
||||
WORD height;
|
||||
DWORD size; // width * height
|
||||
WORD x;
|
||||
WORD y;
|
||||
BYTE data[1]; // begin frame data
|
||||
} FrmFrameData;
|
||||
// Returns a pointer to the data of the frame in the direction
|
||||
FrmFrameData* GetFrameData(long dir, long frame) {
|
||||
BYTE* offsDirectionFrame = (BYTE*)&frameData;
|
||||
if (dir > 0 && dir < 6) {
|
||||
offsDirectionFrame += oriFrameOffset[dir];
|
||||
}
|
||||
if (frame > 0) {
|
||||
int maxFrames = frames - 1;
|
||||
if (frame > maxFrames) frame = maxFrames;
|
||||
while (frame-- > 0) {
|
||||
offsDirectionFrame += ((FrmFrameData*)offsDirectionFrame)->size + (sizeof(FrmFrameData) - 1);
|
||||
}
|
||||
}
|
||||
return (FrmFrameData*)offsDirectionFrame;
|
||||
}
|
||||
};
|
||||
|
||||
#pragma pack(push, 2)
|
||||
typedef class FrmHeaderData { // sizeof 62
|
||||
|
||||
+15
-5
@@ -46,7 +46,7 @@ static DWORD yoffset;
|
||||
|
||||
static bool DeviceLost = false;
|
||||
static bool mainTexLock = false;
|
||||
static bool textureFilter = true;
|
||||
static char textureFilter; // 1 - auto, 2 - force
|
||||
|
||||
static DDSURFACEDESC surfaceDesc;
|
||||
static DDSURFACEDESC mveDesc;
|
||||
@@ -896,7 +896,7 @@ public:
|
||||
if (d3d9Device->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) {
|
||||
ResetDevice(false);
|
||||
DeviceLost = false;
|
||||
RefreshGNW(0);
|
||||
RefreshGNW();
|
||||
}
|
||||
return !DeviceLost;
|
||||
}
|
||||
@@ -1228,8 +1228,18 @@ HRESULT __stdcall FakeDirectDrawCreate2(void*, IDirectDraw** b, void*) {
|
||||
rcpres[0] = 1.0f / (float)gWidth;
|
||||
rcpres[1] = 1.0f / (float)gHeight;
|
||||
|
||||
// Disable texture filtering if the set resolutions are equal
|
||||
textureFilter = (textureFilter && (ResWidth != gWidth || ResHeight != gHeight));
|
||||
if (textureFilter) {
|
||||
float wScale = (float)gWidth / ResWidth;
|
||||
float hScale = (float)gHeight / ResHeight;
|
||||
if (wScale == 1.0f && hScale == 1.0f) textureFilter = 0; // disable texture filtering if the set resolutions are equal
|
||||
if (textureFilter == 1) {
|
||||
int ws = static_cast<int>(wScale);
|
||||
int hs = static_cast<int>(hScale);
|
||||
if (ws == wScale && hs == hScale) {
|
||||
textureFilter = 0; // disable for integer scales
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*b = (IDirectDraw*)new FakeDirectDraw();
|
||||
|
||||
@@ -1293,7 +1303,7 @@ void GraphicsInit() {
|
||||
SafeWrite8(0x50FB6B, '2'); // Set call DirectDrawCreate2
|
||||
HookCall(0x44260C, game_init_hook);
|
||||
|
||||
textureFilter = (GetConfigInt("Graphics", "TextureFilter", 1) != 0);
|
||||
textureFilter = GetConfigInt("Graphics", "TextureFilter", 1);
|
||||
dlogr(" Done", DL_INIT);
|
||||
|
||||
for each (const std::string& shaderFile in GetConfigList("Graphics", "GlobalShaderFile", "", 1024)) {
|
||||
|
||||
@@ -543,7 +543,7 @@ static void surface_draw(long width, long height, long fromWidth, long fromX, lo
|
||||
toBuff += toY * toWidth + toX;
|
||||
|
||||
for (long h = 0; h < height; h++) {
|
||||
for (long w = 0; w < width; w++) toBuff[w] = fromBuff[w];
|
||||
std::memcpy(toBuff, fromBuff, width);
|
||||
fromBuff += fromWidth;
|
||||
toBuff += toWidth;
|
||||
}
|
||||
|
||||
+1
-1
@@ -217,7 +217,7 @@ static void StopMovie() {
|
||||
aviPlayState = AVISTATE_Stop;
|
||||
Gfx_SetMovieTexture(false);
|
||||
movieInterface.pControl->Stop();
|
||||
if (*(DWORD*)_subtitles == 0) RefreshGNW(0); // Note: it is only necessary when in the game
|
||||
if (*(DWORD*)_subtitles == 0) RefreshGNW(); // Note: it is only necessary when in the game
|
||||
}
|
||||
|
||||
DWORD FreeMovie(sDSTexture* movie) {
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#pragma warning(disable: 4414) // 'function': short jump to function converted to near
|
||||
#endif
|
||||
|
||||
#pragma intrinsic(memcpy, memset)
|
||||
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
Reference in New Issue
Block a user