1#ifndef YAZE_CORE_COMMON_H
2#define YAZE_CORE_COMMON_H
10#include "absl/status/statusor.h"
11#include "absl/strings/str_format.h"
30 const std::string &to);
105 flags_ = std::make_shared<Flags>();
112 flags_ = std::make_shared<Flags>();
119 "kLogInstructions: " + std::to_string(
flags_->kLogInstructions) +
"\n";
121 "kUseNewImGuiInput: " + std::to_string(
flags_->kUseNewImGuiInput) +
124 "kSaveAllPalettes: " + std::to_string(
flags_->kSaveAllPalettes) +
"\n";
126 "kSaveGfxGroups: " + std::to_string(
flags_->kSaveGfxGroups) +
"\n";
127 result +=
"kSaveWithChangeQueue: " +
128 std::to_string(
flags_->kSaveWithChangeQueue) +
"\n";
129 result +=
"kDrawDungeonRoomGraphics: " +
130 std::to_string(
flags_->kDrawDungeonRoomGraphics) +
"\n";
131 result +=
"kNewFileDialogWrapper: " +
132 std::to_string(
flags_->kNewFileDialogWrapper) +
"\n";
133 result +=
"kLoadTexturesAsStreaming: " +
134 std::to_string(
flags_->kLoadTexturesAsStreaming) +
"\n";
136 "kSaveDungeonMaps: " + std::to_string(
flags_->kSaveDungeonMaps) +
"\n";
137 result +=
"kLogToConsole: " + std::to_string(
flags_->kLogToConsole) +
"\n";
138 result +=
"kDrawOverworldSprites: " +
139 std::to_string(
flags_->overworld.kDrawOverworldSprites) +
"\n";
140 result +=
"kSaveOverworldMaps: " +
141 std::to_string(
flags_->overworld.kSaveOverworldMaps) +
"\n";
142 result +=
"kSaveOverworldEntrances: " +
143 std::to_string(
flags_->overworld.kSaveOverworldEntrances) +
"\n";
144 result +=
"kSaveOverworldExits: " +
145 std::to_string(
flags_->overworld.kSaveOverworldExits) +
"\n";
146 result +=
"kSaveOverworldItems: " +
147 std::to_string(
flags_->overworld.kSaveOverworldItems) +
"\n";
148 result +=
"kSaveOverworldProperties: " +
149 std::to_string(
flags_->overworld.kSaveOverworldProperties) +
"\n";
169 void set(
const T &value) {
193 operator T() {
return get(); }
203static bool log_to_console =
false;
204static std::string log_file_out =
"log.txt";
206template <
typename... Args>
207static void logf(
const absl::FormatSpec<Args...> &format,
const Args &...args) {
208 std::string message = absl::StrFormat(format, args...);
209 if (log_to_console) {
210 std::cout << message << std::endl;
212 static std::ofstream fout(log_file_out, std::ios::out | std::ios::app);
213 fout << message << std::endl;
218 static void log(std::string message) {
219 static std::ofstream fout(log_file_out, std::ios::out | std::ios::app);
220 fout << message << std::endl;
230 uint32_t temp = (addr & 0x7FFF) + ((addr / 2) & 0xFF8000);
235 uint8_t *b =
reinterpret_cast<uint8_t *
>(&addr);
236 b[2] =
static_cast<uint8_t
>(b[2] * 2);
248 return (bank << 16) | (high << 8) | low;
253 result = (bank << 16) | addr;
263void stle16b_i(uint8_t *
const p_arr,
size_t const p_index,
264 uint16_t
const p_val);
266void stle16b(uint8_t *
const p_arr, uint16_t
const p_val);
273uint16_t
ldle16b_i(uint8_t
const *
const p_arr,
size_t const p_index);
276uint16_t
ldle16b(uint8_t
const *
const p_arr);
287 const std::vector<uint8_t> &target,
288 std::vector<uint8_t> &patch);
291 const std::vector<uint8_t> &patch,
292 std::vector<uint8_t> &target);
294absl::StatusOr<std::string>
CheckVersion(
const char *version);
A class to manage experimental feature flags.
static std::shared_ptr< Flags > flags_
ExperimentFlags()=default
std::string Serialize() const
virtual ~ExperimentFlags()=default
static void log(std::string message)
A class to manage a value that can be modified and notify when it changes.
NotifyValue(const T &value)
void operator=(const T &value)
void ApplyBpsPatch(const std::vector< uint8_t > &source, const std::vector< uint8_t > &patch, std::vector< uint8_t > &target)
std::string UppercaseHexLongLong(uint64_t qword)
bool StringReplace(std::string &str, const std::string &from, const std::string &to)
uint32_t PcToSnes(uint32_t addr)
uint32_t MapBankToWordAddress(uint8_t bank, uint16_t addr) noexcept
void stle16b(uint8_t *const p_arr, uint16_t const p_val)
uint16_t ldle16b(uint8_t const *const p_arr)
absl::StatusOr< std::string > CheckVersion(const char *version)
uint32_t Get24LocalFromPC(uint8_t *data, int addr, bool pc)
int AddressFromBytes(uint8_t bank, uint8_t high, uint8_t low) noexcept
void CreateBpsPatch(const std::vector< uint8_t > &source, const std::vector< uint8_t > &target, std::vector< uint8_t > &patch)
std::string UppercaseHexLong(uint32_t dword)
uint16_t ldle16b_i(uint8_t const *const p_arr, size_t const p_index)
Load little endian halfword (16-bit) dereferenced from an arrays of bytes. This version provides an i...
uint32_t SnesToPc(uint32_t addr) noexcept
constexpr uint32_t kFastRomRegion
void stle16b_i(uint8_t *const p_arr, size_t const p_index, uint16_t const p_val)
Store little endian 16-bit value using a byte pointer, offset by an index before dereferencing.
std::string UppercaseHexByte(uint8_t byte, bool leading)
constexpr std::string_view kYazeVersion
std::string UppercaseHexWord(uint16_t word, bool leading)
bool kLoadCustomOverworld
bool kSaveOverworldProperties
bool kDrawOverworldSprites
bool kSaveOverworldEntrances
bool kLoadTexturesAsStreaming
bool kSaveWithChangeQueue
struct yaze::app::core::ExperimentFlags::Flags::Overworld overworld
bool kDrawDungeonRoomGraphics
bool kNewFileDialogWrapper
std::vector< FolderItem > subfolders
std::vector< std::string > files