diff --git a/src/app/core/common.cc b/src/app/core/common.cc index 36de7a01..ec79a9bf 100644 --- a/src/app/core/common.cc +++ b/src/app/core/common.cc @@ -2,7 +2,6 @@ #include -#include #include #include #include @@ -44,19 +43,16 @@ uint32_t SnesToPc(uint32_t addr) { } uint32_t PcToSnes(uint32_t addr) { - std::bitset<24> addr_bits(addr); - std::bitset<24> result_bits; + uint8_t *b = reinterpret_cast(&addr); + b[2] = static_cast(b[2] * 2); - // Shift the address left by 1 bit - addr_bits <<= 1; + if (b[1] >= 0x80) { + b[2] += 1; + } else { + b[1] += 0x80; + } - // Set the most significant bit of the second byte - addr_bits.set(15, true); - - // Convert the modified bitset back to an integer - uint32_t result = static_cast(addr_bits.to_ulong()); - - return result; + return addr; } uint32_t MapBankToWordAddress(uint8_t bank, uint16_t addr) {