inline common fns, replace redudant code
This commit is contained in:
@@ -194,13 +194,38 @@ class Logger {
|
||||
static std::vector<std::string> logs;
|
||||
};
|
||||
|
||||
inline uint32_t SnesToPc(uint32_t addr) noexcept;
|
||||
constexpr uint32_t kFastRomRegion = 0x808000;
|
||||
|
||||
inline uint32_t PcToSnes(uint32_t addr);
|
||||
inline uint32_t SnesToPc(uint32_t addr) noexcept {
|
||||
if (addr >= kFastRomRegion) {
|
||||
addr -= kFastRomRegion;
|
||||
}
|
||||
uint32_t temp = (addr & 0x7FFF) + ((addr / 2) & 0xFF8000);
|
||||
return (temp + 0x0);
|
||||
}
|
||||
|
||||
inline uint32_t MapBankToWordAddress(uint8_t bank, uint16_t addr);
|
||||
inline uint32_t PcToSnes(uint32_t addr) {
|
||||
uint8_t *b = reinterpret_cast<uint8_t *>(&addr);
|
||||
b[2] = static_cast<uint8_t>(b[2] * 2);
|
||||
|
||||
inline int AddressFromBytes(uint8_t bank, uint8_t high, uint8_t low) noexcept;
|
||||
if (b[1] >= 0x80) {
|
||||
b[2] += 1;
|
||||
} else {
|
||||
b[1] += 0x80;
|
||||
}
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
inline int AddressFromBytes(uint8_t bank, uint8_t high, uint8_t low) noexcept {
|
||||
return (bank << 16) | (high << 8) | low;
|
||||
}
|
||||
|
||||
inline uint32_t MapBankToWordAddress(uint8_t bank, uint16_t addr) noexcept {
|
||||
uint32_t result = 0;
|
||||
result = (bank << 16) | addr;
|
||||
return result;
|
||||
}
|
||||
|
||||
int HexToDec(char *input, int length);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user