Moved 24-bit BMP code refs to HRP\Image.cpp

Minor edits to code/documents.
Updated version number.
This commit is contained in:
NovaRain
2022-02-17 10:20:56 +08:00
parent e84376351b
commit 29cd430b17
8 changed files with 72 additions and 74 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
;sfall configuration settings
;v4.3.3
;v4.3.3.1
[Main]
;Set to 1 to enable the built-in High Resolution Patch mode that is similar to the hi-res patch by Mash
+1 -1
View File
@@ -83,7 +83,7 @@
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
@@ -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
+59
View File
@@ -156,4 +156,63 @@ void Image::ScaleText(BYTE* dstSurf, const char* text, long txtWidth, long dstWi
}
}
#pragma pack(push, 1)
struct BMPHEADER {
BITMAPFILEHEADER bFile;
BITMAPINFOHEADER bInfo;
};
#pragma pack(pop)
/* BMP 24-bit
bool MakeBMP(const char* file, BYTE* dataRGB32, long width, long height, long pitch) {
long bmpExtraSize = width * 3 % 4;
if (bmpExtraSize != 0) bmpExtraSize = 4 - bmpExtraSize;
DWORD sizeImage = width * height * 3;
sizeImage += height * 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 = width;
bmpHeader.bInfo.biHeight = 0 - height;
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;
// 32-bit to 24-bit
for (size_t h = 0; h < height; h++) {
BYTE* sData = dataRGB32;
for (size_t w = 0; w < width; w++) {
*dData++ = *sData++;
*dData++ = *sData++;
*dData++ = *sData++;
sData++;
}
dataRGB32 += pitch;
dData += bmpExtraSize;
}
HANDLE hFile = CreateFileA(file, GENERIC_WRITE, 0, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
bool result = (hFile != INVALID_HANDLE_VALUE);
if (result) {
DWORD dwWritten;
WriteFile(hFile, &bmpHeader, sizeof(BMPHEADER), &dwWritten, 0);
WriteFile(hFile, bmpImageData, sizeImage, &dwWritten, 0);
CloseHandle(hFile);
}
delete[] bmpImageData;
return result;
}*/
}
+6 -67
View File
@@ -188,11 +188,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;
@@ -206,7 +207,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;
@@ -1013,7 +1014,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;
}
@@ -1193,13 +1194,6 @@ void Graphics::BackgroundClearColor(long indxColor) {
}
}
//#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);
@@ -1222,61 +1216,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
@@ -98,7 +98,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);
}
}
+2 -2
View File
@@ -25,6 +25,6 @@
#define VERSION_MAJOR 4
#define VERSION_MINOR 3
#define VERSION_BUILD 3
#define VERSION_REV 0
#define VERSION_REV 1
#define VERSION_STRING "4.3.3"
#define VERSION_STRING "4.3.3.1"