backend-infra-engineer: Pre-0.2.2 2024 Q1 snapshot
This commit is contained in:
@@ -9,12 +9,31 @@
|
||||
#include <stack>
|
||||
#include <string>
|
||||
|
||||
#include "absl/strings/str_format.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
namespace core {
|
||||
|
||||
std::shared_ptr<ExperimentFlags::Flags> ExperimentFlags::flags_;
|
||||
|
||||
std::string UppercaseHexByte(uint8_t byte, bool leading) {
|
||||
if (leading) {
|
||||
std::string result = absl::StrFormat("0x%02X", byte);
|
||||
return result;
|
||||
}
|
||||
std::string result = absl::StrFormat("%02X", byte);
|
||||
return result;
|
||||
}
|
||||
std::string UppercaseHexWord(uint16_t word) {
|
||||
std::string result = absl::StrFormat("0x%04x", word);
|
||||
return result;
|
||||
}
|
||||
std::string UppercaseHexLong(uint32_t dword) {
|
||||
std::string result = absl::StrFormat("0x%08x", dword);
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t SnesToPc(uint32_t addr) {
|
||||
if (addr >= 0x808000) {
|
||||
addr -= 0x808000;
|
||||
@@ -24,8 +43,15 @@ uint32_t SnesToPc(uint32_t addr) {
|
||||
}
|
||||
|
||||
uint32_t PcToSnes(uint32_t addr) {
|
||||
if (addr >= 0x400000) return -1;
|
||||
addr = ((addr << 1) & 0x7F0000) | (addr & 0x7FFF) | 0x8000;
|
||||
uint8_t *b = reinterpret_cast<uint8_t *>(&addr);
|
||||
b[2] = static_cast<uint8_t>(b[2] * 2);
|
||||
|
||||
if (b[1] >= 0x80) {
|
||||
b[2] += 1;
|
||||
} else {
|
||||
b[1] += 0x80;
|
||||
}
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user