1#ifndef YAZE_CORE_COMMON_H
2#define YAZE_CORE_COMMON_H
13#include "absl/status/statusor.h"
14#include "absl/strings/str_format.h"
15#include "imgui/imgui.h"
100 flags_ = std::make_shared<Flags>();
107 flags_ = std::make_shared<Flags>();
114 "kLogInstructions: " + std::to_string(
flags_->kLogInstructions) +
"\n";
116 "kUseNewImGuiInput: " + std::to_string(
flags_->kUseNewImGuiInput) +
119 "kSaveAllPalettes: " + std::to_string(
flags_->kSaveAllPalettes) +
"\n";
121 "kSaveGfxGroups: " + std::to_string(
flags_->kSaveGfxGroups) +
"\n";
122 result +=
"kSaveWithChangeQueue: " +
123 std::to_string(
flags_->kSaveWithChangeQueue) +
"\n";
124 result +=
"kDrawDungeonRoomGraphics: " +
125 std::to_string(
flags_->kDrawDungeonRoomGraphics) +
"\n";
126 result +=
"kNewFileDialogWrapper: " +
127 std::to_string(
flags_->kNewFileDialogWrapper) +
"\n";
129 "kLoadSystemFonts: " + std::to_string(
flags_->kLoadSystemFonts) +
"\n";
130 result +=
"kLoadTexturesAsStreaming: " +
131 std::to_string(
flags_->kLoadTexturesAsStreaming) +
"\n";
133 "kSaveDungeonMaps: " + std::to_string(
flags_->kSaveDungeonMaps) +
"\n";
134 result +=
"kLogToConsole: " + std::to_string(
flags_->kLogToConsole) +
"\n";
135 result +=
"kDrawOverworldSprites: " +
136 std::to_string(
flags_->overworld.kDrawOverworldSprites) +
"\n";
137 result +=
"kSaveOverworldMaps: " +
138 std::to_string(
flags_->overworld.kSaveOverworldMaps) +
"\n";
139 result +=
"kSaveOverworldEntrances: " +
140 std::to_string(
flags_->overworld.kSaveOverworldEntrances) +
"\n";
141 result +=
"kSaveOverworldExits: " +
142 std::to_string(
flags_->overworld.kSaveOverworldExits) +
"\n";
143 result +=
"kSaveOverworldItems: " +
144 std::to_string(
flags_->overworld.kSaveOverworldItems) +
"\n";
145 result +=
"kSaveOverworldProperties: " +
146 std::to_string(
flags_->overworld.kSaveOverworldProperties) +
"\n";
166 void set(
const T &value) {
190 operator T() {
return get(); }
200static bool log_to_console =
false;
201static std::string log_file_out =
"log.txt";
203template <
typename... Args>
204static void logf(
const absl::FormatSpec<Args...> &format,
const Args &...args) {
205 std::string message = absl::StrFormat(format, args...);
206 if (log_to_console) {
207 std::cout << message << std::endl;
209 static std::ofstream fout(log_file_out, std::ios::out | std::ios::app);
210 fout << message << std::endl;
215 static void log(std::string message) {
216 static std::ofstream fout(log_file_out, std::ios::out | std::ios::app);
217 fout << message << std::endl;
227 uint32_t temp = (addr & 0x7FFF) + ((addr / 2) & 0xFF8000);
232 uint8_t *b =
reinterpret_cast<uint8_t *
>(&addr);
233 b[2] =
static_cast<uint8_t
>(b[2] * 2);
245 return (bank << 16) | (high << 8) | low;
250 result = (bank << 16) | addr;
260void stle16b_i(uint8_t *
const p_arr,
size_t const p_index,
261 uint16_t
const p_val);
263void stle16b(uint8_t *
const p_arr, uint16_t
const p_val);
270uint16_t
ldle16b_i(uint8_t
const *
const p_arr,
size_t const p_index);
273uint16_t
ldle16b(uint8_t
const *
const p_arr);
284 const std::vector<uint8_t> &target,
285 std::vector<uint8_t> &patch);
288 const std::vector<uint8_t> &patch,
289 std::vector<uint8_t> &target);
291absl::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)
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)
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.
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