mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Moved 24-bit BMP code refs to HRP\Image.cpp
Minor edits to code/documents. Updated version number.
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
;sfall configuration settings
|
;sfall configuration settings
|
||||||
;v4.3.3
|
;v4.3.3.1
|
||||||
|
|
||||||
[Main]
|
[Main]
|
||||||
;Set to 1 to enable the built-in High Resolution Patch mode that is similar to the hi-res patch by Mash
|
;Set to 1 to enable the built-in High Resolution Patch mode that is similar to the hi-res patch by Mash
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
Does not run for critters in the knockdown/out state.
|
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 arg1 - The attacker
|
||||||
Critter arg2 - The target
|
Critter arg2 - The target
|
||||||
int arg3 - The amount of damage
|
int arg3 - The amount of damage
|
||||||
|
|||||||
@@ -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.
|
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 arg1 - The attacker
|
||||||
Critter arg2 - The target
|
Critter arg2 - The target
|
||||||
int arg3 - The amount of damage
|
int arg3 - The amount of damage
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,11 +188,12 @@ static void ResetDevice(bool create) {
|
|||||||
static D3DFORMAT textureFormat = D3DFMT_X8R8G8B8;
|
static D3DFORMAT textureFormat = D3DFMT_X8R8G8B8;
|
||||||
|
|
||||||
if (create) {
|
if (create) {
|
||||||
DWORD mThreadFlags = (dShowMovies) ? D3DCREATE_MULTITHREADED : 0;
|
DWORD deviceFlags = D3DCREATE_FPU_PRESERVE;
|
||||||
|
if (dShowMovies) deviceFlags |= D3DCREATE_MULTITHREADED;
|
||||||
|
|
||||||
dlog("Creating D3D9 Device...", DL_MAIN);
|
dlog("Creating D3D9 Device...", DL_MAIN);
|
||||||
if (FAILED(d3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window, D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE | mThreadFlags, ¶ms, &d3d9Device))) { // D3DCREATE_PUREDEVICE
|
if (FAILED(d3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window, D3DCREATE_HARDWARE_VERTEXPROCESSING | deviceFlags, ¶ms, &d3d9Device))) { // D3DCREATE_PUREDEVICE
|
||||||
if (FAILED(d3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window, D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE | mThreadFlags, ¶ms, &d3d9Device))) {
|
if (FAILED(d3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window, D3DCREATE_SOFTWARE_VERTEXPROCESSING | deviceFlags, ¶ms, &d3d9Device))) {
|
||||||
d3d9Device = nullptr;
|
d3d9Device = nullptr;
|
||||||
dlogr(" Failed!", DL_MAIN);
|
dlogr(" Failed!", DL_MAIN);
|
||||||
return;
|
return;
|
||||||
@@ -206,7 +207,7 @@ static void ResetDevice(bool create) {
|
|||||||
ShaderVersion = ((caps.PixelShaderVersion & 0x0000FF00) >> 8) * 10 + (caps.PixelShaderVersion & 0xFF);
|
ShaderVersion = ((caps.PixelShaderVersion & 0x0000FF00) >> 8) * 10 + (caps.PixelShaderVersion & 0xFF);
|
||||||
|
|
||||||
bool npow2 = ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) != 0); //(caps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL)
|
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)
|
// Use: 0 - only CPU, 1 - force GPU, 2 - Auto Mode (GPU or switch to CPU)
|
||||||
if (Graphics::GPUBlt == 2 && ShaderVersion < 20) Graphics::GPUBlt = 0;
|
if (Graphics::GPUBlt == 2 && ShaderVersion < 20) Graphics::GPUBlt = 0;
|
||||||
@@ -1013,7 +1014,7 @@ public:
|
|||||||
|
|
||||||
HRESULT __stdcall RestoreDisplayMode() { // called from GNW95_reset_mode_
|
HRESULT __stdcall RestoreDisplayMode() { // called from GNW95_reset_mode_
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
ShowWindow(window, SW_HIDE);
|
if (!Graphics::IsWindowedMode) ShowWindow(window, SW_HIDE);
|
||||||
#endif
|
#endif
|
||||||
return DD_OK;
|
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) {
|
long __stdcall SaveScreen(const char* file) {
|
||||||
IDirect3DSurface9* surface;
|
IDirect3DSurface9* surface;
|
||||||
d3d9Device->CreateOffscreenPlainSurface(gWidth, gHeight, D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &surface, 0);
|
d3d9Device->CreateOffscreenPlainSurface(gWidth, gHeight, D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &surface, 0);
|
||||||
@@ -1222,61 +1216,6 @@ long __stdcall SaveScreen(const char* file) {
|
|||||||
surface->Release();
|
surface->Release();
|
||||||
buffer->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;
|
return (resultOK) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ void op_get_year(OpcodeContext& ctx) {
|
|||||||
|
|
||||||
void __declspec(naked) op_eax_available() {
|
void __declspec(naked) op_eax_available() {
|
||||||
__asm {
|
__asm {
|
||||||
xor edx, edx
|
xor edx, edx; // EAX support has been removed since 2.1a
|
||||||
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
_J_RET_VAL_TYPE(VAR_TYPE_INT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ void op_set_palette(OpcodeContext&);
|
|||||||
//numbers subgame functions
|
//numbers subgame functions
|
||||||
void __declspec() op_nb_create_char();
|
void __declspec() op_nb_create_char();
|
||||||
|
|
||||||
void __declspec() op_hero_select_win() ;
|
void __declspec() op_hero_select_win();
|
||||||
|
|
||||||
void __declspec() op_set_hero_style();
|
void __declspec() op_set_hero_style();
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -25,6 +25,6 @@
|
|||||||
#define VERSION_MAJOR 4
|
#define VERSION_MAJOR 4
|
||||||
#define VERSION_MINOR 3
|
#define VERSION_MINOR 3
|
||||||
#define VERSION_BUILD 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"
|
||||||
|
|||||||
Reference in New Issue
Block a user