Code edits to Graphics.cpp & Logging.cpp

Minor edits to other code/documents.
Updated version number.
This commit is contained in:
NovaRain
2022-02-17 10:26:42 +08:00
parent 5fcf4aae50
commit b1323fc07a
10 changed files with 29 additions and 75 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
;sfall configuration settings
;v3.8.33
;v3.8.33.1
[Main]
;Set to 1 if you want to use command line arguments to tell sfall to use another ini file
+1 -1
View File
@@ -167,7 +167,7 @@ When using `critter_dmg` function, this script will also run. In that case weapo
Does not run for critters in the knockdown/out state.
```
Item arg0 - The pid of the weapon performing the attack. (May be -1 if the attack is unarmed)
int arg0 - The pid of the weapon performing the attack. (May be -1 if the attack is unarmed)
Critter arg1 - The attacker
Critter arg2 - The target
int arg3 - The amount of damage
+1 -1
View File
@@ -31,7 +31,7 @@ namespace sfall
static const DWORD ExpectedSize = 1189888;
static const DWORD ExpectedCRC[] = {
0xE1680293, // US 1.02d
0xEF34F989 // US 1.02d + HRP
0xEF34F989 // US 1.02d + HRP by Mash
};
static void inline ExitMessageFail(const char* a) {
+12
View File
@@ -47,12 +47,24 @@ void dlog(const char* a, int type) {
}
}
void dlog(const std::string& a, int type) {
if (type == DL_MAIN || (isDebug && (type & DebugTypes))) {
OutLog(a);
}
}
void dlogr(const char* a, int type) {
if (type == DL_MAIN || (isDebug && (type & DebugTypes))) {
OutLogN(a);
}
}
void dlogr(const std::string& a, int type) {
if (type == DL_MAIN || (isDebug && (type & DebugTypes))) {
OutLogN(a);
}
}
void dlog_f(const char* fmt, int type, ...) {
if (type == DL_MAIN || (isDebug && (type & DebugTypes))) {
va_list args;
+3
View File
@@ -25,12 +25,15 @@
#ifndef NO_SFALL_DEBUG
#include <stdio.h>
#include <string>
namespace sfall
{
void dlog(const char* msg, int type);
void dlog(const std::string& msg, int type);
void dlogr(const char* msg, int type);
void dlogr(const std::string& msg, int type);
void dlog_f(const char* fmt, int type, ...);
#ifndef NDEBUG
+6 -67
View File
@@ -205,11 +205,12 @@ static void ResetDevice(bool create) {
static D3DFORMAT textureFormat = D3DFMT_X8R8G8B8;
if (create) {
DWORD mThreadFlags = (dShowMovies) ? D3DCREATE_MULTITHREADED : 0;
DWORD deviceFlags = D3DCREATE_FPU_PRESERVE;
if (dShowMovies) deviceFlags |= D3DCREATE_MULTITHREADED;
dlog("Creating D3D9 Device...", DL_MAIN);
if (FAILED(d3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window, D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE | mThreadFlags, &params, &d3d9Device))) { // D3DCREATE_PUREDEVICE
if (FAILED(d3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window, D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE | mThreadFlags, &params, &d3d9Device))) {
if (FAILED(d3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window, D3DCREATE_HARDWARE_VERTEXPROCESSING | deviceFlags, &params, &d3d9Device))) { // D3DCREATE_PUREDEVICE
if (FAILED(d3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window, D3DCREATE_SOFTWARE_VERTEXPROCESSING | deviceFlags, &params, &d3d9Device))) {
d3d9Device = nullptr;
dlogr(" Failed!", DL_MAIN);
return;
@@ -223,7 +224,7 @@ static void ResetDevice(bool create) {
ShaderVersion = ((caps.PixelShaderVersion & 0x0000FF00) >> 8) * 10 + (caps.PixelShaderVersion & 0xFF);
bool npow2 = ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) != 0); //(caps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL)
if (npow2) dlogr("Warning: The graphics card does not support non-power-of-two textures.", DL_MAIN);
if (npow2) dlog("Warning: The graphics card does not support non-power-of-two textures.", DL_MAIN);
// Use: 0 - only CPU, 1 - force GPU, 2 - Auto Mode (GPU or switch to CPU)
if (Graphics::GPUBlt == 2 && ShaderVersion < 20) Graphics::GPUBlt = 0;
@@ -1028,7 +1029,7 @@ public:
HRESULT __stdcall RestoreDisplayMode() { // called from GNW95_reset_mode_
#ifdef NDEBUG
ShowWindow(window, SW_HIDE);
if (!Graphics::IsWindowedMode) ShowWindow(window, SW_HIDE);
#endif
return DD_OK;
}
@@ -1342,13 +1343,6 @@ static __declspec(naked) void palette_fade_to_hook() {
}
}
//#pragma pack(push, 1)
//struct BMPHEADER {
// BITMAPFILEHEADER bFile;
// BITMAPINFOHEADER bInfo;
//};
//#pragma pack(pop)
long __stdcall SaveScreen(const char* file) {
IDirect3DSurface9* surface;
d3d9Device->CreateOffscreenPlainSurface(gWidth, gHeight, D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &surface, 0);
@@ -1371,61 +1365,6 @@ long __stdcall SaveScreen(const char* file) {
surface->Release();
buffer->Release();
/* BMP 24-bit
long bmpExtraSize = gWidth * 3 % 4;
if (bmpExtraSize != 0) bmpExtraSize = 4 - bmpExtraSize;
DWORD sizeImage = gWidth * gHeight * 3;
sizeImage += gHeight * bmpExtraSize;
BMPHEADER bmpHeader;
std::memset(&bmpHeader, 0, sizeof(BMPHEADER));
bmpHeader.bFile.bfType = 'BM';
bmpHeader.bFile.bfSize = sizeImage + sizeof(BMPHEADER);
bmpHeader.bFile.bfOffBits = sizeof(BMPHEADER);
bmpHeader.bInfo.biSize = sizeof(BITMAPINFOHEADER);
bmpHeader.bInfo.biWidth = gWidth;
bmpHeader.bInfo.biHeight = 0 - gHeight;
bmpHeader.bInfo.biPlanes = 1;
bmpHeader.bInfo.biBitCount = 24;
bmpHeader.bInfo.biCompression = BI_RGB;
bmpHeader.bInfo.biSizeImage = sizeImage;
BYTE* bmpImageData = new BYTE[sizeImage];
BYTE* dData = bmpImageData;
D3DLOCKED_RECT lockRect;
surface->LockRect(&lockRect, 0, 0);
BYTE* lockData = (BYTE*)lockRect.pBits;
// 32-bit to 24-bit
for (size_t h = 0; h < gHeight; h++) {
BYTE* sData = lockData;
for (size_t x = 0; x < gWidth; x++) {
*dData++ = *sData++;
*dData++ = *sData++;
*dData++ = *sData++;
sData++;
}
lockData += lockRect.Pitch;
dData += bmpExtraSize;
}
surface->UnlockRect();
surface->Release();
HANDLE hFile = CreateFileA(file, GENERIC_WRITE, 0, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
bool resultOK = (hFile != INVALID_HANDLE_VALUE);
if (resultOK) {
DWORD dwWritten;
WriteFile(hFile, &bmpHeader, sizeof(BMPHEADER), &dwWritten, 0);
WriteFile(hFile, bmpImageData, sizeImage, &dwWritten, 0);
CloseHandle(hFile);
}
delete[] bmpImageData;*/
return (resultOK) ? 0 : 1;
}
+1 -1
View File
@@ -572,7 +572,7 @@ bool Movies::DirectShowMovies() {
Graphics::AviMovieWidthFit = (allowDShowMovies >= 2);
MakeJump(0x44E690, gmovie_play_hack);
HookCall(0x44E993, gmovie_play_hook_stop);
/* NOTE: At this address 0x487781 (movieStart_), HRP changes the callback procedure to display mve frames. */
/* NOTE: At this address 0x487781 (movieStart_), HRP by Mash changes the callback procedure to display mve frames. */
return true;
}
return false;
+1 -1
View File
@@ -96,7 +96,7 @@ void op_get_year(OpcodeContext& ctx) {
void __declspec(naked) op_eax_available() {
__asm {
xor edx, edx
xor edx, edx; // EAX support has been removed since 2.1a
_J_RET_VAL_TYPE(VAR_TYPE_INT);
}
}
+1 -1
View File
@@ -66,7 +66,7 @@ void op_set_palette(OpcodeContext&);
//numbers subgame functions
void __declspec() op_nb_create_char();
void __declspec() op_hero_select_win() ;
void __declspec() op_hero_select_win();
void __declspec() op_set_hero_style();
+2 -2
View File
@@ -25,6 +25,6 @@
#define VERSION_MAJOR 3
#define VERSION_MINOR 8
#define VERSION_BUILD 33
#define VERSION_REV 0
#define VERSION_REV 1
#define VERSION_STRING "3.8.33"
#define VERSION_STRING "3.8.33.1"