Get rid of mmx stuff

This commit is contained in:
Alexander Batalov 2023-02-18 18:14:30 +03:00
parent 3e8227a62b
commit 249892716e
7 changed files with 33 additions and 105 deletions

View File

@ -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"

View File

@ -3,7 +3,6 @@
#include <string.h>
#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

View File

@ -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

View File

@ -1,60 +0,0 @@
#include "mmx.h"
#include <string.h>
#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

View File

@ -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 */

View File

@ -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;

View File

@ -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();