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
@@ -72,7 +72,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
|
||||
|
||||
|
||||
@@ -751,7 +751,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
|
||||
|
||||
|
||||
@@ -289,13 +289,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ DWORD GetMaxCharWidth();
|
||||
void RedrawObject(GameObject* obj);
|
||||
|
||||
// Redraws all interface windows
|
||||
void RefreshGNW(size_t from);
|
||||
void RefreshGNW(size_t from = 0);
|
||||
|
||||
UnlistedFrm *LoadUnlistedFrm(char *frmName, unsigned int folderRef);
|
||||
|
||||
|
||||
@@ -280,6 +280,17 @@ struct ElevatorFrms {
|
||||
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
|
||||
@@ -289,24 +300,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
|
||||
|
||||
@@ -925,7 +925,7 @@ static void __declspec(naked) make_path_func_hook() {
|
||||
cmp ebx, [esp + 0x5C - 0x1C + 4]; // target tile
|
||||
je fix;
|
||||
jmp fo::funcoffs::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;
|
||||
@@ -3193,7 +3193,7 @@ void BugFixes::init()
|
||||
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
|
||||
|
||||
@@ -50,7 +50,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;
|
||||
@@ -771,7 +771,7 @@ public:
|
||||
if (d3d9Device->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) {
|
||||
ResetDevice(false);
|
||||
DeviceLost = false;
|
||||
fo::RefreshGNW(0);
|
||||
fo::RefreshGNW();
|
||||
}
|
||||
return !DeviceLost;
|
||||
}
|
||||
@@ -1100,8 +1100,18 @@ HRESULT __stdcall InitFakeDirectDrawCreate(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();
|
||||
|
||||
@@ -1154,7 +1164,7 @@ void Graphics::init() {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -510,7 +510,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;
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ static void StopMovie() {
|
||||
aviPlayState = AviState::Stop;
|
||||
Graphics::SetMovieTexture(false);
|
||||
movieInterface.pControl->Stop();
|
||||
if (*(DWORD*)FO_VAR_subtitles == 0) fo::RefreshGNW(0); // Note: it is only necessary when in the game
|
||||
if (*(DWORD*)FO_VAR_subtitles == 0) fo::RefreshGNW(); // Note: it is only necessary when in the game
|
||||
}
|
||||
|
||||
DWORD FreeMovie(sDSTexture* movie) {
|
||||
|
||||
@@ -470,26 +470,13 @@ static long GetArtFIDFile(long fid, const char* &file) {
|
||||
return direction;
|
||||
}
|
||||
|
||||
static fo::FrmFile* LoadArtFile(const char* file, long frameno, long direction, fo::FrmFrameData* &framePtr) {
|
||||
static fo::FrmFile* LoadArtFile(const char* file, long frame, long direction, fo::FrmFrameData* &framePtr) {
|
||||
fo::FrmFile* frmPtr = nullptr;
|
||||
if (fo::func::load_frame(file, &frmPtr)) {
|
||||
return nullptr;
|
||||
}
|
||||
framePtr = (fo::FrmFrameData*)&frmPtr->width;
|
||||
if (direction > 0 && direction < 6) {
|
||||
BYTE* offsOriFrame = (BYTE*)framePtr;
|
||||
offsOriFrame += frmPtr->oriFrameOffset[direction];
|
||||
framePtr = (fo::FrmFrameData*)offsOriFrame;
|
||||
}
|
||||
if (frameno > 0) {
|
||||
int maxFrames = frmPtr->frames - 1;
|
||||
if (frameno > maxFrames) frameno = maxFrames;
|
||||
while (frameno-- > 0) {
|
||||
BYTE* offsFrame = (BYTE*)framePtr;
|
||||
offsFrame += framePtr->size + (sizeof(fo::FrmFrameData) - 1);
|
||||
framePtr = (fo::FrmFrameData*)offsFrame;
|
||||
}
|
||||
}
|
||||
framePtr = frmPtr->GetFrameData(direction, frame);
|
||||
|
||||
return frmPtr;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,11 @@
|
||||
#pragma warning(disable: 4414) // 'function': short jump to function converted to near
|
||||
#endif
|
||||
|
||||
#pragma intrinsic(memcpy, memset)
|
||||
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <initializer_list>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
Reference in New Issue
Block a user