From 9b40277052b4e51d06a45b8917b9eef20c0aa80e Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Mon, 13 Feb 2023 14:17:52 +0300 Subject: [PATCH] Get rid of mmx stuff --- CMakeLists.txt | 2 -- src/plib/gnw/grbuf.cc | 31 +++++++++++++++++++++++++++-- src/plib/gnw/grbuf.h | 2 ++ src/plib/gnw/input.cc | 1 - src/plib/gnw/mmx.cc | 46 ------------------------------------------- src/plib/gnw/mmx.h | 12 ----------- src/plib/gnw/svga.cc | 25 ----------------------- src/plib/gnw/svga.h | 3 --- 8 files changed, 31 insertions(+), 91 deletions(-) delete mode 100644 src/plib/gnw/mmx.cc delete mode 100644 src/plib/gnw/mmx.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6264ab4..cf022c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,8 +232,6 @@ target_sources(${EXECUTABLE_NAME} PUBLIC "src/plib/gnw/kb.h" "src/plib/gnw/memory.cc" "src/plib/gnw/memory.h" - "src/plib/gnw/mmx.cc" - "src/plib/gnw/mmx.h" "src/plib/gnw/mouse.cc" "src/plib/gnw/mouse.h" "src/plib/gnw/rect.cc" diff --git a/src/plib/gnw/grbuf.cc b/src/plib/gnw/grbuf.cc index ec34a8e..e00316f 100644 --- a/src/plib/gnw/grbuf.cc +++ b/src/plib/gnw/grbuf.cc @@ -3,8 +3,6 @@ #include #include "plib/color/color.h" -#include "plib/gnw/input.h" -#include "plib/gnw/mmx.h" namespace fallout { @@ -332,4 +330,33 @@ void buf_outline(unsigned char* buf, int width, int height, int pitch, int color } } +// 0x4CDB50 +void srcCopy(unsigned char* dest, int destPitch, unsigned char* src, int srcPitch, int width, int height) +{ + for (int y = 0; y < height; y++) { + memcpy(dest, src, width); + dest += destPitch; + src += srcPitch; + } +} + +// 0x4CDC75 +void transSrcCopy(unsigned char* dest, int destPitch, unsigned char* src, int srcPitch, int width, int height) +{ + int destSkip = destPitch - width; + int srcSkip = srcPitch - width; + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + unsigned char c = *src++; + if (c != 0) { + *dest = c; + } + dest++; + } + src += srcSkip; + dest += destSkip; + } +} + } // namespace fallout diff --git a/src/plib/gnw/grbuf.h b/src/plib/gnw/grbuf.h index c8abb94..a40769c 100644 --- a/src/plib/gnw/grbuf.h +++ b/src/plib/gnw/grbuf.h @@ -16,6 +16,8 @@ void buf_texture(unsigned char* buf, int width, int height, int pitch, void* a5, void lighten_buf(unsigned char* buf, int width, int height, int pitch); void swap_color_buf(unsigned char* buf, int width, int height, int pitch, int color1, int color2); void buf_outline(unsigned char* buf, int width, int height, int pitch, int a5); +void srcCopy(unsigned char* dest, int destPitch, unsigned char* src, int srcPitch, int width, int height); +void transSrcCopy(unsigned char* dest, int destPitch, unsigned char* src, int srcPitch, int width, int height); } // namespace fallout diff --git a/src/plib/gnw/input.cc b/src/plib/gnw/input.cc index 66de6ac..21e8527 100644 --- a/src/plib/gnw/input.cc +++ b/src/plib/gnw/input.cc @@ -11,7 +11,6 @@ #include "plib/gnw/grbuf.h" #include "plib/gnw/intrface.h" #include "plib/gnw/memory.h" -#include "plib/gnw/mmx.h" #include "plib/gnw/svga.h" #include "plib/gnw/text.h" #include "plib/gnw/vcr.h" diff --git a/src/plib/gnw/mmx.cc b/src/plib/gnw/mmx.cc deleted file mode 100644 index 6c97b89..0000000 --- a/src/plib/gnw/mmx.cc +++ /dev/null @@ -1,46 +0,0 @@ -#include "plib/gnw/mmx.h" - -#include - -#include "plib/gnw/svga.h" - -namespace fallout { - -// Return `true` if CPU supports MMX. -// -// 0x4CD640 -bool mmxTest() -{ - return SDL_HasMMX() == SDL_TRUE; -} - -// 0x4CDB50 -void srcCopy(unsigned char* dest, int destPitch, unsigned char* src, int srcPitch, int width, int height) -{ - for (int y = 0; y < height; y++) { - memcpy(dest, src, width); - dest += destPitch; - src += srcPitch; - } -} - -// 0x4CDC75 -void transSrcCopy(unsigned char* dest, int destPitch, unsigned char* src, int srcPitch, int width, int height) -{ - int destSkip = destPitch - width; - int srcSkip = srcPitch - width; - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - unsigned char c = *src++; - if (c != 0) { - *dest = c; - } - dest++; - } - src += srcSkip; - dest += destSkip; - } -} - -} // namespace fallout diff --git a/src/plib/gnw/mmx.h b/src/plib/gnw/mmx.h deleted file mode 100644 index b8650c1..0000000 --- a/src/plib/gnw/mmx.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef FALLOUT_PLIB_GNW_MMX_H_ -#define FALLOUT_PLIB_GNW_MMX_H_ - -namespace fallout { - -bool mmxTest(); -void srcCopy(unsigned char* dest, int destPitch, unsigned char* src, int srcPitch, int width, int height); -void transSrcCopy(unsigned char* dest, int destPitch, unsigned char* src, int srcPitch, int width, int height); - -} // namespace fallout - -#endif /* FALLOUT_PLIB_GNW_MMX_H_ */ diff --git a/src/plib/gnw/svga.cc b/src/plib/gnw/svga.cc index e9bd81a..6e0f929 100644 --- a/src/plib/gnw/svga.cc +++ b/src/plib/gnw/svga.cc @@ -4,7 +4,6 @@ #include "game/intface.h" #include "plib/gnw/gnw.h" #include "plib/gnw/grbuf.h" -#include "plib/gnw/mmx.h" #include "plib/gnw/mouse.h" #include "plib/gnw/winmain.h" @@ -16,9 +15,6 @@ static int GNW95_init_mode(int width, int height); static bool createRenderer(int width, int height); static void destroyRenderer(); -// 0x51E2C8 -bool mmxEnabled = true; - // screen rect Rect scr_size; @@ -34,25 +30,6 @@ SDL_Surface* gSdlTextureSurface = NULL; // TODO: Remove once migration to update-render cycle is completed. FpsLimiter sharedFpsLimiter; -// 0x4CACD0 -void mmxEnable(bool enable) -{ - // 0x51E2CC - static bool inited = false; - - // 0x6ACA20 - static bool mmx; - - if (!inited) { - mmx = mmxTest(); - inited = true; - } - - if (mmx) { - mmxEnabled = enable; - } -} - // 0x4CAD08 int init_mode_320_200() { @@ -161,8 +138,6 @@ static int GNW95_init_mode_ex(int width, int height, int bpp) scr_size.lrx = width - 1; scr_size.lry = height - 1; - mmxEnable(true); - mouse_blit_trans = NULL; scr_blit = GNW95_ShowRect; mouse_blit = GNW95_ShowRect; diff --git a/src/plib/gnw/svga.h b/src/plib/gnw/svga.h index 3704dbf..7646fab 100644 --- a/src/plib/gnw/svga.h +++ b/src/plib/gnw/svga.h @@ -9,8 +9,6 @@ namespace fallout { -extern bool mmxEnabled; - extern Rect scr_size; extern ScreenBlitFunc* scr_blit; @@ -21,7 +19,6 @@ extern SDL_Texture* gSdlTexture; extern SDL_Surface* gSdlTextureSurface; extern FpsLimiter sharedFpsLimiter; -void mmxEnable(bool enable); int init_mode_320_200(); int init_mode_320_400(); int init_mode_640_480_16();