diff --git a/pcsx2/Patch.cpp b/pcsx2/Patch.cpp index 29e5bc51e7..a3dd7af487 100644 --- a/pcsx2/Patch.cpp +++ b/pcsx2/Patch.cpp @@ -60,9 +60,9 @@ static const PatchTextTable dataType[] = {3, "word", nullptr}, {4, "double", nullptr}, {5, "extended", nullptr}, - {6, "leshort", nullptr}, - {7, "leword", nullptr}, - {8, "ledouble", nullptr}, + {6, "beshort", nullptr}, + {7, "beword", nullptr}, + {8, "bedouble", nullptr}, {0, nullptr, nullptr} // Array Terminator }; diff --git a/pcsx2/Patch.h b/pcsx2/Patch.h index 340e030f07..f195845e7b 100644 --- a/pcsx2/Patch.h +++ b/pcsx2/Patch.h @@ -54,9 +54,9 @@ enum patch_data_type { WORD_T, DOUBLE_T, EXTENDED_T, - SHORT_LE_T, - WORD_LE_T, - DOUBLE_LE_T + SHORT_BE_T, + WORD_BE_T, + DOUBLE_BE_T }; // "place" is the first number at a pnach line (patch=,...), e.g.: @@ -146,8 +146,3 @@ extern const IConsoleWriter *PatchesCon; // regardless, they don't seem to have an implementation anywhere. // extern int AddPatch(int Mode, int Place, int Address, int Size, u64 data); // extern void ResetPatch(void); - -// Swaps endianess of InputNum -// ex. 01020304 -> 04030201 -// BitLength is length of InputNum in bits, ex. double,64 word,32 short,16 -extern u64 SwapEndian(u64 InputNum, u8 BitLength); diff --git a/pcsx2/Patch_Memory.cpp b/pcsx2/Patch_Memory.cpp index c92575531b..ae32c4fec8 100644 --- a/pcsx2/Patch_Memory.cpp +++ b/pcsx2/Patch_Memory.cpp @@ -15,6 +15,8 @@ #include "PrecompiledHeader.h" +#include "common/ByteSwap.h" + #define _PC_ // disables MIPS opcode macros. #include "Common.h" @@ -542,20 +544,20 @@ void _ApplyPatch(IniPatch *p) handle_extended_t(p); break; - case SHORT_LE_T: - ledata = SwapEndian(p->data, 16); + case SHORT_BE_T: + ledata = ByteSwap(static_cast(p->data)); if (memRead16(p->addr) != (u16)ledata) memWrite16(p->addr, (u16)ledata); break; - case WORD_LE_T: - ledata = SwapEndian(p->data, 32); + case WORD_BE_T: + ledata = ByteSwap(static_cast(p->data)); if (memRead32(p->addr) != (u32)ledata) memWrite32(p->addr, (u32)ledata); break; - case DOUBLE_LE_T: - ledata = SwapEndian(p->data, 64); + case DOUBLE_BE_T: + ledata = ByteSwap(p->data); if (memRead64(p->addr) != (u64)ledata) memWrite64(p->addr, (u64)ledata); break; @@ -605,18 +607,3 @@ void _ApplyDynaPatch(const DynamicPatch& patch, u32 address) memWrite32(address + replacement.offset, replacement.value); } } - -u64 SwapEndian(u64 InputNum, u8 BitLength) -{ - if (BitLength == 64) // DOUBLE_LE_T - { - InputNum = (InputNum & 0x00000000FFFFFFFF) << 32 | (InputNum & 0xFFFFFFFF00000000) >> 32; //Swaps 4 bytes - } - if ((BitLength == 32)||(BitLength==64)) // WORD_LE_T - { - InputNum = (InputNum & 0x0000FFFF0000FFFF) << 16 | (InputNum & 0xFFFF0000FFFF0000) >> 16; // Swaps 2 bytes - } - InputNum = (InputNum & 0x00FF00FF00FF00FF) << 8 | (InputNum & 0xFF00FF00FF00FF00) >> 8; // Swaps 1 byte - return InputNum; -} -