diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f55093..e671d8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,8 +152,6 @@ target_sources(${EXECUTABLE_NAME} PUBLIC "src/memory.h" "src/message.cc" "src/message.h" - "src/mmx.cc" - "src/mmx.h" "src/mouse_manager.cc" "src/mouse_manager.h" "src/mouse.cc" diff --git a/src/draw.cc b/src/draw.cc index 592273f..674b0ac 100644 --- a/src/draw.cc +++ b/src/draw.cc @@ -3,7 +3,6 @@ #include #include "color.h" -#include "mmx.h" #include "svga.h" namespace fallout { @@ -208,13 +207,13 @@ void blitBufferToBufferStretchTrans(unsigned char* src, int srcWidth, int srcHei // 0x4D36D4 void blitBufferToBuffer(unsigned char* src, int width, int height, int srcPitch, unsigned char* dest, int destPitch) { - mmxBlit(dest, destPitch, src, srcPitch, width, height); + srcCopy(dest, destPitch, src, srcPitch, width, height); } // 0x4D3704 void blitBufferToBufferTrans(unsigned char* src, int width, int height, int srcPitch, unsigned char* dest, int destPitch) { - mmxBlitTrans(dest, destPitch, src, srcPitch, width, height); + transSrcCopy(dest, destPitch, src, srcPitch, width, height); } // 0x4D387C @@ -311,4 +310,33 @@ void bufferOutline(unsigned char* buf, int width, int height, int pitch, int col } } +// 0x4E0DB0 +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; + } +} + +// 0x4E0ED5 +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/draw.h b/src/draw.h index 49d068b..47601c0 100644 --- a/src/draw.h +++ b/src/draw.h @@ -15,6 +15,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 bufferOutline(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/mmx.cc b/src/mmx.cc deleted file mode 100644 index 8a5b4d1..0000000 --- a/src/mmx.cc +++ /dev/null @@ -1,60 +0,0 @@ -#include "mmx.h" - -#include - -#include "svga.h" - -namespace fallout { - -// Return `true` if CPU supports MMX. -// -// 0x4E08A0 -bool mmxIsSupported() -{ - return SDL_HasMMX() == SDL_TRUE; -} - -// 0x4E0DB0 -void mmxBlit(unsigned char* dest, int destPitch, unsigned char* src, int srcPitch, int width, int height) -{ - if (gMmxEnabled) { - // TODO: Blit with MMX. - gMmxEnabled = false; - mmxBlit(dest, destPitch, src, srcPitch, width, height); - gMmxEnabled = true; - } else { - for (int y = 0; y < height; y++) { - memcpy(dest, src, width); - dest += destPitch; - src += srcPitch; - } - } -} - -// 0x4E0ED5 -void mmxBlitTrans(unsigned char* dest, int destPitch, unsigned char* src, int srcPitch, int width, int height) -{ - if (gMmxEnabled) { - // TODO: Blit with MMX. - gMmxEnabled = false; - mmxBlitTrans(dest, destPitch, src, srcPitch, width, height); - gMmxEnabled = true; - } else { - 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/mmx.h b/src/mmx.h deleted file mode 100644 index 051397b..0000000 --- a/src/mmx.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef MMX_H -#define MMX_H - -namespace fallout { - -bool mmxIsSupported(); -void mmxBlit(unsigned char* dest, int destPitch, unsigned char* src, int srcPitch, int width, int height); -void mmxBlitTrans(unsigned char* dest, int destPitch, unsigned char* src, int srcPitch, int width, int height); - -} // namespace fallout - -#endif /* MMX_H */ diff --git a/src/svga.cc b/src/svga.cc index bdcc9b1..e361fea 100644 --- a/src/svga.cc +++ b/src/svga.cc @@ -9,7 +9,6 @@ #include "draw.h" #include "interface.h" #include "memory.h" -#include "mmx.h" #include "mouse.h" #include "win32.h" #include "window_manager.h" @@ -20,9 +19,6 @@ namespace fallout { static bool createRenderer(int width, int height); static void destroyRenderer(); -// 0x51E2C8 -bool gMmxEnabled = true; - // screen rect Rect _scr_size; @@ -41,25 +37,6 @@ SDL_Surface* gSdlTextureSurface = NULL; // TODO: Remove once migration to update-render cycle is completed. FpsLimiter sharedFpsLimiter; -// 0x4CACD0 -void mmxSetEnabled(bool a1) -{ - // 0x51E2CC - static bool probed = false; - - // 0x6ACA20 - static bool supported; - - if (!probed) { - supported = mmxIsSupported(); - probed = true; - } - - if (supported) { - gMmxEnabled = a1; - } -} - // 0x4CAD08 int _init_mode_320_200() { @@ -165,8 +142,6 @@ int _GNW95_init_mode_ex(int width, int height, int bpp) _scr_size.right = width - 1; _scr_size.bottom = height - 1; - mmxSetEnabled(true); - _mouse_blit_trans = NULL; _scr_blit = _GNW95_ShowRect; _zero_mem = _GNW95_zero_vid_mem; diff --git a/src/svga.h b/src/svga.h index 1de0d0a..510d724 100644 --- a/src/svga.h +++ b/src/svga.h @@ -8,8 +8,6 @@ namespace fallout { -extern bool gMmxEnabled; - extern Rect _scr_size; extern void (*_scr_blit)(unsigned char* src, int src_pitch, int a3, int src_x, int src_y, int src_width, int src_height, int dest_x, int dest_y); extern void (*_zero_mem)(); @@ -21,7 +19,6 @@ extern SDL_Texture* gSdlTexture; extern SDL_Surface* gSdlTextureSurface; extern FpsLimiter sharedFpsLimiter; -void mmxSetEnabled(bool a1); int _init_mode_320_200(); int _init_mode_320_400(); int _init_mode_640_480_16();