mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Updated code
This commit is contained in:
@@ -50,6 +50,12 @@ struct GameObject;
|
||||
struct Program;
|
||||
struct ScriptInstance;
|
||||
|
||||
struct PALETTE { // F2 palette
|
||||
BYTE B;
|
||||
BYTE G;
|
||||
BYTE R;
|
||||
};
|
||||
|
||||
struct Art {
|
||||
long flags;
|
||||
char path[16];
|
||||
@@ -546,9 +552,9 @@ struct UnlistedFrm {
|
||||
frameAreaSize = 0;
|
||||
frames = nullptr;
|
||||
}
|
||||
|
||||
~UnlistedFrm() {
|
||||
if (frames != nullptr)
|
||||
delete[] frames;
|
||||
if (frames != nullptr) delete[] frames;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -57,7 +57,7 @@ bool HRP::CheckExternalPatch() {
|
||||
}
|
||||
return isEnabled;
|
||||
}
|
||||
|
||||
/*
|
||||
static void __declspec(naked) mem_copy() {
|
||||
__asm {
|
||||
cmp edx, eax;
|
||||
@@ -111,7 +111,7 @@ forward:
|
||||
retn;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
void HRP::init() {
|
||||
//HookCall(0x482899, mem_copy);
|
||||
//SafeWrite16(0x4B2EA8, 0x9090); // _show_grid
|
||||
|
||||
@@ -88,6 +88,8 @@ static long __fastcall IntfaceWinCreate(long height, long yPos, long xPos, long
|
||||
xPosition = xPos;
|
||||
yPosition = yPos;
|
||||
|
||||
flags |= fo::WinFlags::DontMoveTop;
|
||||
|
||||
if (IFaceBar::IFACE_BAR_MODE == 0 && IFaceBar::IFACE_BAR_SIDE_ART && HRP::ScreenWidth() > IFaceBar::IFACE_BAR_WIDTH) {
|
||||
long leftID = fo::func::win_add(0, yPos, xPos, height, 0, flags);
|
||||
long rightID = fo::func::win_add(xPos + width, yPos, HRP::ScreenWidth() - (xPos + width), height, 0, flags);
|
||||
|
||||
@@ -93,6 +93,8 @@ static long __fastcall main_menu_create_hook_add_win(long h, long y, long color,
|
||||
long offset = 0;
|
||||
long sw = w, sh = h;
|
||||
|
||||
Graphics::BackgroundClearColor(0);
|
||||
|
||||
if (MainMenuScreen::USE_HIRES_IMAGES) {
|
||||
if (!mainBackgroundFrm) {
|
||||
mainBackgroundFrm = fo::util::LoadUnlistedFrm("HR_MAINMENU.frm", fo::ArtType::OBJ_TYPE_INTRFACE);
|
||||
@@ -237,9 +239,6 @@ static long __fastcall ButtonScale(long &width, long xPos, BYTE* &upImageData, B
|
||||
// down
|
||||
downButtonImageData = &buttonImageData[size];
|
||||
Image::Scale(*(BYTE**)FO_VAR_button_down_data, width, width, downButtonImageData, sWidth, sWidth);
|
||||
|
||||
//fo::var::setInt(FO_VAR_button_up_data) = (long)buttonImageData;
|
||||
//fo::var::setInt(FO_VAR_button_down_data) = (long)downButtonImageData;
|
||||
}
|
||||
upImageData = buttonImageData;
|
||||
downImageData = downButtonImageData;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace sfall
|
||||
// 2 - image will stretch to fill the screen
|
||||
long SplashScreen::SPLASH_SCRN_SIZE;
|
||||
|
||||
static void __cdecl game_splash_screen_hook_scr_blit(BYTE* srcPixels, long srcWidth, long srcHeight, long srcX, long srcY, long width, long height, long x, long y) {
|
||||
static void __cdecl game_splash_screen_hack_scr_blit(BYTE* srcPixels, long srcWidth, long srcHeight, long srcX, long srcY, long width, long height, long x, long y) {
|
||||
RECT rect;
|
||||
long w = Graphics::GetGameWidthRes();
|
||||
long h = Graphics::GetGameHeightRes();
|
||||
@@ -72,9 +72,36 @@ static void __cdecl game_splash_screen_hook_scr_blit(BYTE* srcPixels, long srcWi
|
||||
Graphics::UpdateDDSurface(srcPixels, srcWidth, srcHeight, srcWidth, &rect);
|
||||
}
|
||||
|
||||
// Fixes colored screen border when the index 0 of the palette contains a color with a non-black (zero) value
|
||||
static void __fastcall Clear(fo::PALETTE* palette) {
|
||||
long minValue = (palette->B + palette->G + palette->R);
|
||||
if (minValue == 0) return;
|
||||
|
||||
long index = 0;
|
||||
|
||||
// search index of the darkest color in the palette
|
||||
for (size_t i = 1; i < 256; i++)
|
||||
{
|
||||
long rgbVal = palette[i].B + palette[i].G + palette[i].R;
|
||||
if (rgbVal < minValue) {
|
||||
minValue = rgbVal;
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
if (index != 0) Graphics::BackgroundClearColor(index);
|
||||
}
|
||||
|
||||
static void __declspec(naked) game_splash_screen_hook() {
|
||||
__asm {
|
||||
call fo::funcoffs::db_fclose_;
|
||||
mov ecx, ebp; // .rix palette
|
||||
jmp Clear;
|
||||
}
|
||||
}
|
||||
|
||||
void SplashScreen::init() {
|
||||
|
||||
MakeCall(0x44451E, game_splash_screen_hook_scr_blit, 1);
|
||||
HookCall(0x4444FC, game_splash_screen_hook);
|
||||
MakeCall(0x44451E, game_splash_screen_hack_scr_blit, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -67,7 +67,8 @@ bool BugFixes::DrugsLoadFix(HANDLE file) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ResetBodyState() {
|
||||
__asm mov critterBody, 0;
|
||||
@@ -3110,6 +3111,20 @@ skip:
|
||||
}
|
||||
}
|
||||
|
||||
static void __declspec(naked) win_show_hack() {
|
||||
__asm {
|
||||
xor ebx, ebx;
|
||||
lea edx, [esi + 0x8]; // window.rect
|
||||
mov eax, esi;
|
||||
call fo::funcoffs::GNW_win_refresh_;
|
||||
pop esi;
|
||||
pop edx;
|
||||
pop ecx;
|
||||
pop ebx;
|
||||
retn;
|
||||
}
|
||||
}
|
||||
|
||||
static bool createObjectSidStartFix = false;
|
||||
|
||||
static void __declspec(naked) op_create_object_sid_hack() {
|
||||
@@ -3956,6 +3971,9 @@ void BugFixes::init()
|
||||
MakeJump(0x4B6C3B, checkAllRegions_hack);
|
||||
HookCall(0x4B6C13, checkAllRegions_hook);
|
||||
|
||||
// Fix for the window with the "DontMoveTop" flag not being redrawn after the show function call if it is not the topmost one
|
||||
MakeJump(0x4D6E04, win_show_hack);
|
||||
|
||||
// Fix for the script attached to an object not being initialized properly upon object creation
|
||||
createObjectSidStartFix = (IniReader::GetConfigInt("Misc", "CreateObjectSidFix", 0) != 0);
|
||||
MakeCall(0x4551C0, op_create_object_sid_hack, 1);
|
||||
|
||||
+29
-16
@@ -79,12 +79,6 @@ static struct PALCOLOR {
|
||||
};
|
||||
};
|
||||
} *palette;
|
||||
|
||||
struct PALETTE { // F2 palette
|
||||
BYTE B;
|
||||
BYTE G;
|
||||
BYTE R;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//static bool paletteInit = false;
|
||||
@@ -661,7 +655,7 @@ public:
|
||||
if (primary && Graphics::GPUBlt) {
|
||||
// use the mainTex texture as source buffer
|
||||
} else {
|
||||
lockTarget = new BYTE[ResWidth * ResHeight];
|
||||
lockTarget = new BYTE[ResWidth * ResHeight]();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -748,7 +742,13 @@ public:
|
||||
HRESULT __stdcall GetOverlayPosition(LPLONG, LPLONG) { UNUSEDFUNCTION; }
|
||||
HRESULT __stdcall GetPalette(LPDIRECTDRAWPALETTE *) { UNUSEDFUNCTION; }
|
||||
HRESULT __stdcall GetPixelFormat(LPDDPIXELFORMAT) { UNUSEDFUNCTION; }
|
||||
HRESULT __stdcall GetSurfaceDesc(LPDDSURFACEDESC) { UNUSEDFUNCTION; }
|
||||
|
||||
HRESULT __stdcall GetSurfaceDesc(LPDDSURFACEDESC a) {
|
||||
*a = surfaceDesc;
|
||||
a->lpSurface = lockTarget;
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
HRESULT __stdcall Initialize(LPDIRECTDRAW, LPDDSURFACEDESC) { UNUSEDFUNCTION; }
|
||||
HRESULT __stdcall IsLost() { UNUSEDFUNCTION; }
|
||||
|
||||
@@ -939,7 +939,7 @@ public:
|
||||
if (!windowInit || (long)c <= 0) return DDERR_INVALIDPARAMS;
|
||||
//palCounter++;
|
||||
|
||||
PALETTE* destPal = (PALETTE*)d;
|
||||
fo::PALETTE* destPal = (fo::PALETTE*)d;
|
||||
|
||||
if (Graphics::GPUBlt) {
|
||||
D3DLOCKED_RECT pal;
|
||||
@@ -1067,14 +1067,14 @@ public:
|
||||
}
|
||||
dlog("Creating D3D9 Device window...", DL_MAIN);
|
||||
|
||||
if (Graphics::mode >= 5) {
|
||||
if (ResWidth != gWidth || ResHeight != gHeight) {
|
||||
std::sprintf(windowTitle, "%s @sfall " VERSION_STRING " %ix%i >> %ix%i", (const char*)0x50AF08, ResWidth, ResHeight, gWidth, gHeight);
|
||||
} else {
|
||||
std::sprintf(windowTitle, "%s @sfall " VERSION_STRING, (const char*)0x50AF08);
|
||||
}
|
||||
SetWindowTextA(a, windowTitle);
|
||||
if (ResWidth != gWidth || ResHeight != gHeight) {
|
||||
std::sprintf(windowTitle, "%s @sfall " VERSION_STRING " %ix%i >> %ix%i", (const char*)0x50AF08, ResWidth, ResHeight, gWidth, gHeight);
|
||||
} else {
|
||||
std::sprintf(windowTitle, "%s @sfall " VERSION_STRING, (const char*)0x50AF08);
|
||||
}
|
||||
SetWindowTextA(a, windowTitle);
|
||||
|
||||
if (Graphics::mode >= 5) {
|
||||
SetWindowLongA(a, GWL_STYLE, windowStyle);
|
||||
RECT r;
|
||||
r.left = 0;
|
||||
@@ -1258,6 +1258,19 @@ void __stdcall Graphics::ForceGraphicsRefresh(DWORD d) {
|
||||
forcingGraphicsRefresh = (d == 0) ? 0 : 1;
|
||||
}
|
||||
|
||||
void Graphics::BackgroundClearColor(long indxColor) {
|
||||
if (GPUBlt) {
|
||||
D3DLOCKED_RECT buf;
|
||||
mainTex->LockRect(0, &buf, 0, D3DLOCK_DISCARD);
|
||||
std::memset(buf.pBits, indxColor, ResWidth * ResHeight);
|
||||
mainTex->UnlockRect(0);
|
||||
} else {
|
||||
DDSURFACEDESC desc;
|
||||
primarySurface->GetSurfaceDesc(&desc);
|
||||
std::memset(desc.lpSurface, indxColor, ResWidth * ResHeight);
|
||||
}
|
||||
}
|
||||
|
||||
void Graphics::init() {
|
||||
Graphics::mode = IniReader::GetConfigInt("Graphics", "Mode", 0);
|
||||
if (Graphics::mode == 6) {
|
||||
|
||||
@@ -85,6 +85,8 @@ public:
|
||||
static void RefreshGraphics();
|
||||
static void __stdcall ForceGraphicsRefresh(DWORD d);
|
||||
|
||||
static void BackgroundClearColor(long indxColor);
|
||||
|
||||
static __forceinline void UpdateDDSurface(BYTE* surface, int width, int height, int widthFrom, RECT* rect) {
|
||||
long x = rect->left;
|
||||
long y = rect->top;
|
||||
|
||||
Reference in New Issue
Block a user