2022-05-19 01:51:26 -07:00
|
|
|
#include "mmx.h"
|
|
|
|
|
|
|
|
#include "core.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
// Return `true` if CPU supports MMX.
|
|
|
|
//
|
|
|
|
// 0x4E08A0
|
|
|
|
bool mmxIsSupported()
|
|
|
|
{
|
2022-06-11 12:56:21 -07:00
|
|
|
return SDL_HasMMX() == SDL_TRUE;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|