big cleanup
This commit is contained in:
@@ -55,50 +55,12 @@ uint32_t crc32(const std::vector<uint8_t> &data) {
|
||||
return ::crc32(crc, data.data(), data.size());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::shared_ptr<ExperimentFlags::Flags> ExperimentFlags::flags_;
|
||||
|
||||
// Initialize the static member
|
||||
std::stack<ImGuiID> ImGuiIdIssuer::idStack;
|
||||
|
||||
uint32_t Get24LocalFromPC(uint8_t *data, int addr, bool pc) {
|
||||
uint32_t ret =
|
||||
(PcToSnes(addr) & 0xFF0000) | (data[addr + 1] << 8) | data[addr];
|
||||
if (pc) {
|
||||
return SnesToPc(ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// hextodec has been imported from SNESDisasm to parse hex numbers
|
||||
int HexToDec(char *input, int length) {
|
||||
int result = 0;
|
||||
int value;
|
||||
int ceiling = length - 1;
|
||||
int power16 = 16;
|
||||
|
||||
int j = ceiling;
|
||||
|
||||
for (; j >= 0; j--) {
|
||||
if (input[j] >= 'A' && input[j] <= 'F') {
|
||||
value = input[j] - 'F';
|
||||
value += 15;
|
||||
} else {
|
||||
value = input[j] - '9';
|
||||
value += 9;
|
||||
}
|
||||
|
||||
if (j == ceiling) {
|
||||
result += value;
|
||||
continue;
|
||||
}
|
||||
|
||||
result += (value * power16);
|
||||
power16 *= 16;
|
||||
}
|
||||
|
||||
return result;
|
||||
// "load little endian value at the given byte offset and shift to get its
|
||||
// value relative to the base offset (powers of 256, essentially)"
|
||||
unsigned ldle(uint8_t const *const p_arr, unsigned const p_index) {
|
||||
uint32_t v = p_arr[p_index];
|
||||
v <<= (8 * p_index);
|
||||
return v;
|
||||
}
|
||||
|
||||
void stle(uint8_t *const p_arr, size_t const p_index, unsigned const p_val) {
|
||||
@@ -122,24 +84,6 @@ void stle2(uint8_t *const p_arr, unsigned const p_val) {
|
||||
void stle3(uint8_t *const p_arr, unsigned const p_val) {
|
||||
stle(p_arr, 3, p_val);
|
||||
}
|
||||
void stle16b(uint8_t *const p_arr, uint16_t const p_val) {
|
||||
stle0(p_arr, p_val);
|
||||
stle1(p_arr, p_val);
|
||||
}
|
||||
|
||||
void stle16b_i(uint8_t *const p_arr, size_t const p_index,
|
||||
uint16_t const p_val) {
|
||||
stle16b(p_arr + (p_index * 2), p_val);
|
||||
}
|
||||
// "load little endian value at the given byte offset and shift to get its
|
||||
// value relative to the base offset (powers of 256, essentially)"
|
||||
unsigned ldle(uint8_t const *const p_arr, unsigned const p_index) {
|
||||
uint32_t v = p_arr[p_index];
|
||||
|
||||
v <<= (8 * p_index);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
// Helper function to get the first byte in a little endian number
|
||||
uint32_t ldle0(uint8_t const *const p_arr) { return ldle(p_arr, 0); }
|
||||
@@ -153,11 +97,32 @@ uint32_t ldle2(uint8_t const *const p_arr) { return ldle(p_arr, 2); }
|
||||
// Helper function to get the third byte in a little endian number
|
||||
uint32_t ldle3(uint8_t const *const p_arr) { return ldle(p_arr, 3); }
|
||||
|
||||
} // namespace
|
||||
|
||||
std::shared_ptr<ExperimentFlags::Flags> ExperimentFlags::flags_;
|
||||
|
||||
uint32_t Get24LocalFromPC(uint8_t *data, int addr, bool pc) {
|
||||
uint32_t ret =
|
||||
(PcToSnes(addr) & 0xFF0000) | (data[addr + 1] << 8) | data[addr];
|
||||
if (pc) {
|
||||
return SnesToPc(ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void stle16b_i(uint8_t *const p_arr, size_t const p_index,
|
||||
uint16_t const p_val) {
|
||||
stle16b(p_arr + (p_index * 2), p_val);
|
||||
}
|
||||
|
||||
void stle16b(uint8_t *const p_arr, uint16_t const p_val) {
|
||||
stle0(p_arr, p_val);
|
||||
stle1(p_arr, p_val);
|
||||
}
|
||||
|
||||
uint16_t ldle16b(uint8_t const *const p_arr) {
|
||||
uint16_t v = 0;
|
||||
|
||||
v |= (ldle0(p_arr) | ldle1(p_arr));
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -175,82 +140,83 @@ void CreateBpsPatch(const std::vector<uint8_t> &source,
|
||||
encode(target.size(), patch);
|
||||
encode(0, patch); // No metadata
|
||||
|
||||
size_t sourceOffset = 0;
|
||||
size_t targetOffset = 0;
|
||||
int64_t sourceRelOffset = 0;
|
||||
int64_t targetRelOffset = 0;
|
||||
size_t source_offset = 0;
|
||||
size_t target_offset = 0;
|
||||
int64_t source_rel_offset = 0;
|
||||
int64_t target_rel_offset = 0;
|
||||
|
||||
while (targetOffset < target.size()) {
|
||||
if (sourceOffset < source.size() &&
|
||||
source[sourceOffset] == target[targetOffset]) {
|
||||
while (target_offset < target.size()) {
|
||||
if (source_offset < source.size() &&
|
||||
source[source_offset] == target[target_offset]) {
|
||||
size_t length = 0;
|
||||
while (sourceOffset + length < source.size() &&
|
||||
targetOffset + length < target.size() &&
|
||||
source[sourceOffset + length] == target[targetOffset + length]) {
|
||||
while (source_offset + length < source.size() &&
|
||||
target_offset + length < target.size() &&
|
||||
source[source_offset + length] == target[target_offset + length]) {
|
||||
length++;
|
||||
}
|
||||
encode((length - 1) << 2 | 0, patch); // SourceRead
|
||||
sourceOffset += length;
|
||||
targetOffset += length;
|
||||
source_offset += length;
|
||||
target_offset += length;
|
||||
} else {
|
||||
size_t length = 0;
|
||||
while (targetOffset + length < target.size() &&
|
||||
(sourceOffset + length >= source.size() ||
|
||||
source[sourceOffset + length] != target[targetOffset + length])) {
|
||||
while (
|
||||
target_offset + length < target.size() &&
|
||||
(source_offset + length >= source.size() ||
|
||||
source[source_offset + length] != target[target_offset + length])) {
|
||||
length++;
|
||||
}
|
||||
if (length > 0) {
|
||||
encode((length - 1) << 2 | 1, patch); // TargetRead
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
patch.push_back(target[targetOffset + i]);
|
||||
patch.push_back(target[target_offset + i]);
|
||||
}
|
||||
targetOffset += length;
|
||||
target_offset += length;
|
||||
}
|
||||
}
|
||||
|
||||
// SourceCopy
|
||||
if (sourceOffset < source.size()) {
|
||||
if (source_offset < source.size()) {
|
||||
size_t length = 0;
|
||||
int64_t offset = sourceOffset - sourceRelOffset;
|
||||
while (sourceOffset + length < source.size() &&
|
||||
targetOffset + length < target.size() &&
|
||||
source[sourceOffset + length] == target[targetOffset + length]) {
|
||||
int64_t offset = source_offset - source_rel_offset;
|
||||
while (source_offset + length < source.size() &&
|
||||
target_offset + length < target.size() &&
|
||||
source[source_offset + length] == target[target_offset + length]) {
|
||||
length++;
|
||||
}
|
||||
if (length > 0) {
|
||||
encode((length - 1) << 2 | 2, patch);
|
||||
encode((offset < 0 ? 1 : 0) | (abs(offset) << 1), patch);
|
||||
sourceOffset += length;
|
||||
targetOffset += length;
|
||||
sourceRelOffset = sourceOffset;
|
||||
source_offset += length;
|
||||
target_offset += length;
|
||||
source_rel_offset = source_offset;
|
||||
}
|
||||
}
|
||||
|
||||
// TargetCopy
|
||||
if (targetOffset > 0) {
|
||||
if (target_offset > 0) {
|
||||
size_t length = 0;
|
||||
int64_t offset = targetOffset - targetRelOffset;
|
||||
while (targetOffset + length < target.size() &&
|
||||
target[targetOffset - 1] == target[targetOffset + length]) {
|
||||
int64_t offset = target_offset - target_rel_offset;
|
||||
while (target_offset + length < target.size() &&
|
||||
target[target_offset - 1] == target[target_offset + length]) {
|
||||
length++;
|
||||
}
|
||||
if (length > 0) {
|
||||
encode((length - 1) << 2 | 3, patch);
|
||||
encode((offset < 0 ? 1 : 0) | (abs(offset) << 1), patch);
|
||||
targetOffset += length;
|
||||
targetRelOffset = targetOffset;
|
||||
target_offset += length;
|
||||
target_rel_offset = target_offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
patch.resize(patch.size() + 12); // Make space for the checksums
|
||||
uint32_t sourceChecksum = crc32(source);
|
||||
uint32_t targetChecksum = crc32(target);
|
||||
uint32_t patchChecksum = crc32(patch);
|
||||
uint32_t source_checksum = crc32(source);
|
||||
uint32_t target_checksum = crc32(target);
|
||||
uint32_t patch_checksum = crc32(patch);
|
||||
|
||||
memcpy(patch.data() + patch.size() - 12, &sourceChecksum, sizeof(uint32_t));
|
||||
memcpy(patch.data() + patch.size() - 8, &targetChecksum, sizeof(uint32_t));
|
||||
memcpy(patch.data() + patch.size() - 4, &patchChecksum, sizeof(uint32_t));
|
||||
memcpy(patch.data() + patch.size() - 12, &source_checksum, sizeof(uint32_t));
|
||||
memcpy(patch.data() + patch.size() - 8, &target_checksum, sizeof(uint32_t));
|
||||
memcpy(patch.data() + patch.size() - 4, &patch_checksum, sizeof(uint32_t));
|
||||
}
|
||||
|
||||
void ApplyBpsPatch(const std::vector<uint8_t> &source,
|
||||
@@ -261,48 +227,48 @@ void ApplyBpsPatch(const std::vector<uint8_t> &source,
|
||||
throw std::runtime_error("Invalid patch format");
|
||||
}
|
||||
|
||||
size_t patchOffset = 4;
|
||||
uint64_t sourceSize = decode(patch, patchOffset);
|
||||
uint64_t targetSize = decode(patch, patchOffset);
|
||||
uint64_t metadataSize = decode(patch, patchOffset);
|
||||
patchOffset += metadataSize;
|
||||
size_t patch_offset = 4;
|
||||
uint64_t source_size = decode(patch, patch_offset);
|
||||
uint64_t target_size = decode(patch, patch_offset);
|
||||
uint64_t metadata_size = decode(patch, patch_offset);
|
||||
patch_offset += metadata_size;
|
||||
|
||||
target.resize(targetSize);
|
||||
size_t sourceOffset = 0;
|
||||
size_t targetOffset = 0;
|
||||
int64_t sourceRelOffset = 0;
|
||||
int64_t targetRelOffset = 0;
|
||||
target.resize(target_size);
|
||||
size_t source_offset = 0;
|
||||
size_t target_offset = 0;
|
||||
int64_t source_rel_offset = 0;
|
||||
int64_t target_rel_offset = 0;
|
||||
|
||||
while (patchOffset < patch.size() - 12) {
|
||||
uint64_t data = decode(patch, patchOffset);
|
||||
while (patch_offset < patch.size() - 12) {
|
||||
uint64_t data = decode(patch, patch_offset);
|
||||
uint64_t command = data & 3;
|
||||
uint64_t length = (data >> 2) + 1;
|
||||
|
||||
switch (command) {
|
||||
case 0: // SourceRead
|
||||
while (length--) {
|
||||
target[targetOffset++] = source[sourceOffset++];
|
||||
target[target_offset++] = source[source_offset++];
|
||||
}
|
||||
break;
|
||||
case 1: // TargetRead
|
||||
while (length--) {
|
||||
target[targetOffset++] = patch[patchOffset++];
|
||||
target[target_offset++] = patch[patch_offset++];
|
||||
}
|
||||
break;
|
||||
case 2: // SourceCopy
|
||||
{
|
||||
int64_t offsetData = decode(patch, patchOffset);
|
||||
sourceRelOffset += (offsetData & 1 ? -1 : +1) * (offsetData >> 1);
|
||||
int64_t offsetData = decode(patch, patch_offset);
|
||||
source_rel_offset += (offsetData & 1 ? -1 : +1) * (offsetData >> 1);
|
||||
while (length--) {
|
||||
target[targetOffset++] = source[sourceRelOffset++];
|
||||
target[target_offset++] = source[source_rel_offset++];
|
||||
}
|
||||
} break;
|
||||
case 3: // TargetCopy
|
||||
{
|
||||
uint64_t offsetData = decode(patch, patchOffset);
|
||||
targetRelOffset += (offsetData & 1 ? -1 : +1) * (offsetData >> 1);
|
||||
uint64_t offsetData = decode(patch, patch_offset);
|
||||
target_rel_offset += (offsetData & 1 ? -1 : +1) * (offsetData >> 1);
|
||||
while (length--) {
|
||||
target[targetOffset++] = target[targetRelOffset++];
|
||||
target[target_offset++] = target[target_rel_offset++];
|
||||
}
|
||||
}
|
||||
default:
|
||||
@@ -310,15 +276,15 @@ void ApplyBpsPatch(const std::vector<uint8_t> &source,
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t sourceChecksum;
|
||||
uint32_t targetChecksum;
|
||||
uint32_t patchChecksum;
|
||||
memcpy(&sourceChecksum, patch.data() + patch.size() - 12, sizeof(uint32_t));
|
||||
memcpy(&targetChecksum, patch.data() + patch.size() - 8, sizeof(uint32_t));
|
||||
memcpy(&patchChecksum, patch.data() + patch.size() - 4, sizeof(uint32_t));
|
||||
uint32_t source_checksum;
|
||||
uint32_t target_checksum;
|
||||
uint32_t patch_checksum;
|
||||
memcpy(&source_checksum, patch.data() + patch.size() - 12, sizeof(uint32_t));
|
||||
memcpy(&target_checksum, patch.data() + patch.size() - 8, sizeof(uint32_t));
|
||||
memcpy(&patch_checksum, patch.data() + patch.size() - 4, sizeof(uint32_t));
|
||||
|
||||
if (sourceChecksum != crc32(source) || targetChecksum != crc32(target) ||
|
||||
patchChecksum !=
|
||||
if (source_checksum != crc32(source) || target_checksum != crc32(target) ||
|
||||
patch_checksum !=
|
||||
crc32(std::vector<uint8_t>(patch.begin(), patch.end() - 4))) {
|
||||
throw std::runtime_error("Checksum mismatch");
|
||||
}
|
||||
|
||||
@@ -159,27 +159,6 @@ class NotifyValue {
|
||||
T temp_value_;
|
||||
};
|
||||
|
||||
class ImGuiIdIssuer {
|
||||
private:
|
||||
static std::stack<ImGuiID> idStack;
|
||||
|
||||
public:
|
||||
// Generate and push a new ID onto the stack
|
||||
static ImGuiID GetNewID() {
|
||||
static int counter = 1; // Start from 1 to ensure uniqueness
|
||||
ImGuiID child_id = ImGui::GetID((void *)(intptr_t)counter++);
|
||||
idStack.push(child_id);
|
||||
return child_id;
|
||||
}
|
||||
|
||||
// Pop all IDs from the stack (can be called explicitly or upon program exit)
|
||||
static void Cleanup() {
|
||||
while (!idStack.empty()) {
|
||||
idStack.pop();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static bool log_to_console = false;
|
||||
static std::string log_file_out = "log.txt";
|
||||
|
||||
@@ -236,23 +215,25 @@ inline uint32_t MapBankToWordAddress(uint8_t bank, uint16_t addr) noexcept {
|
||||
|
||||
uint32_t Get24LocalFromPC(uint8_t *data, int addr, bool pc = true);
|
||||
|
||||
int HexToDec(char *input, int length);
|
||||
|
||||
// "Store little endian 16-bit value using a byte pointer, offset by an
|
||||
// index before dereferencing"
|
||||
/**
|
||||
* @brief Store little endian 16-bit value using a byte pointer, offset by an
|
||||
* index before dereferencing
|
||||
*/
|
||||
void stle16b_i(uint8_t *const p_arr, size_t const p_index,
|
||||
uint16_t const p_val);
|
||||
|
||||
// Load little endian halfword (16-bit) dereferenced from an arrays of bytes.
|
||||
// This version provides an index that will be multiplied by 2 and added to the
|
||||
// base address.
|
||||
void stle16b(uint8_t *const p_arr, uint16_t const p_val);
|
||||
|
||||
/**
|
||||
* @brief Load little endian halfword (16-bit) dereferenced from an arrays of
|
||||
* bytes. This version provides an index that will be multiplied by 2 and added
|
||||
* to the base address.
|
||||
*/
|
||||
uint16_t ldle16b_i(uint8_t const *const p_arr, size_t const p_index);
|
||||
|
||||
// Load little endian halfword (16-bit) dereferenced from
|
||||
uint16_t ldle16b(uint8_t const *const p_arr);
|
||||
|
||||
void stle16b(uint8_t *const p_arr, uint16_t const p_val);
|
||||
|
||||
struct FolderItem {
|
||||
std::string name;
|
||||
std::vector<FolderItem> subfolders;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "imgui/imgui.h"
|
||||
#include "imgui/imgui_internal.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "app/core/common.h"
|
||||
|
||||
#include "app/core/platform/renderer.h"
|
||||
#include "app/editor/editor_manager.h"
|
||||
#include "app/editor/utils/editor.h"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "app/core/common.h"
|
||||
|
||||
#include "app/core/constants.h"
|
||||
#include "app/gui/icons.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "app/core/common.h"
|
||||
|
||||
#include "app/core/constants.h"
|
||||
|
||||
namespace yaze {
|
||||
|
||||
@@ -21,6 +21,7 @@ struct Message {
|
||||
void* sender;
|
||||
std::any payload;
|
||||
|
||||
Message() = default;
|
||||
Message(const std::string& type, void* sender, const std::any& payload)
|
||||
: type(type), sender(sender), payload(payload) {}
|
||||
};
|
||||
|
||||
@@ -69,7 +69,8 @@ class Renderer : public ExperimentFlags {
|
||||
}
|
||||
|
||||
absl::Status CreateAndRenderBitmap(int width, int height, int depth,
|
||||
const std::vector<uint8_t>& data, gfx::Bitmap& bitmap,
|
||||
const std::vector<uint8_t>& data,
|
||||
gfx::Bitmap& bitmap,
|
||||
gfx::SnesPalette& palette) {
|
||||
bitmap.Create(width, height, depth, data);
|
||||
RETURN_IF_ERROR(bitmap.ApplyPalette(palette));
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
#ifndef YAZE_APP_EDITOR_ASSEMBLY_EDITOR_H
|
||||
#define YAZE_APP_EDITOR_ASSEMBLY_EDITOR_H
|
||||
|
||||
#include "ImGuiColorTextEdit/TextEditor.h"
|
||||
#include "ImGuiFileDialog/ImGuiFileDialog.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <istream>
|
||||
#include <string>
|
||||
|
||||
#include "ImGuiColorTextEdit/TextEditor.h"
|
||||
#include "ImGuiFileDialog/ImGuiFileDialog.h"
|
||||
#include "app/core/common.h"
|
||||
#include "app/editor/utils/editor.h"
|
||||
#include "app/gui/style.h"
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
#ifndef YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_H
|
||||
#define YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_H
|
||||
|
||||
#include "imgui/imgui.h"
|
||||
#include "imgui/misc/cpp/imgui_stdlib.h"
|
||||
#include "imgui_memory_editor.h"
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "app/core/common.h"
|
||||
#include "app/core/constants.h"
|
||||
#include "app/core/platform/file_dialog.h"
|
||||
#include "app/core/project.h"
|
||||
@@ -30,6 +25,9 @@
|
||||
#include "app/gui/input.h"
|
||||
#include "app/gui/style.h"
|
||||
#include "app/rom.h"
|
||||
#include "imgui/imgui.h"
|
||||
#include "imgui/misc/cpp/imgui_stdlib.h"
|
||||
#include "imgui_memory_editor.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "dungeon_editor.h"
|
||||
|
||||
#include "app/core/common.h"
|
||||
#include "app/core/labeling.h"
|
||||
#include "app/core/platform/renderer.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "ImGuiFileDialog/ImGuiFileDialog.h"
|
||||
#include "abseil-cpp/absl/strings/match.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "app/core/common.h"
|
||||
|
||||
#include "app/core/constants.h"
|
||||
#include "app/core/platform/file_dialog.h"
|
||||
#include "app/core/platform/renderer.h"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "ImGuiColorTextEdit/TextEditor.h"
|
||||
#include "ImGuiFileDialog/ImGuiFileDialog.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "app/core/common.h"
|
||||
|
||||
#include "app/core/constants.h"
|
||||
#include "app/core/message.h"
|
||||
#include "app/core/project.h"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "app/core/common.h"
|
||||
|
||||
#include "app/core/constants.h"
|
||||
#include "app/core/platform/renderer.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "app/core/common.h"
|
||||
#include "app/editor/graphics/palette_editor.h"
|
||||
#include "app/editor/utils/editor.h"
|
||||
#include "app/editor/utils/gfx_context.h"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "absl/strings/str_replace.h"
|
||||
#include "absl/strings/str_split.h"
|
||||
#include "app/core/common.h"
|
||||
|
||||
#include "app/core/platform/renderer.h"
|
||||
#include "app/editor/utils/editor.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "app/core/common.h"
|
||||
|
||||
#include "app/core/constants.h"
|
||||
#include "app/core/platform/clipboard.h"
|
||||
#include "app/core/platform/renderer.h"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "app/core/common.h"
|
||||
|
||||
#include "app/editor/graphics/gfx_group_editor.h"
|
||||
#include "app/editor/graphics/palette_editor.h"
|
||||
#include "app/editor/graphics/tile16_editor.h"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "ImGuiFileDialog/ImGuiFileDialog.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "app/core/common.h"
|
||||
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/gui/canvas.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "app/core/common.h"
|
||||
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/gui/canvas.h"
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "app/core/common.h"
|
||||
#include "app/core/constants.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
@@ -72,9 +71,8 @@ void Room::LoadHeader() {
|
||||
// Existing room size address calculation...
|
||||
auto room_size_address = 0xF8000 + (room_id_ * 3);
|
||||
|
||||
if (flags()->kLogToConsole)
|
||||
std::cout << "Room #" << room_id_ << " Address: " << std::hex
|
||||
<< room_size_address << std::endl;
|
||||
std::cout << "Room #" << room_id_ << " Address: " << std::hex
|
||||
<< room_size_address << std::endl;
|
||||
|
||||
// Reading bytes for long address construction
|
||||
uint8_t low = rom()->data()[room_size_address];
|
||||
@@ -83,15 +81,13 @@ void Room::LoadHeader() {
|
||||
|
||||
// Constructing the long address
|
||||
int long_address = (bank << 16) | (high << 8) | low;
|
||||
if (flags()->kLogToConsole)
|
||||
std::cout << std::hex << std::setfill('0') << std::setw(6) << long_address
|
||||
<< std::endl;
|
||||
std::cout << std::hex << std::setfill('0') << std::setw(6) << long_address
|
||||
<< std::endl;
|
||||
room_size_pointer_ = long_address;
|
||||
|
||||
if (long_address == 0x0A8000) {
|
||||
// Blank room disregard in size calculation
|
||||
if (flags()->kLogToConsole)
|
||||
std::cout << "Size of Room #" << room_id_ << ": 0 bytes" << std::endl;
|
||||
std::cout << "Size of Room #" << room_id_ << ": 0 bytes" << std::endl;
|
||||
room_size_ = 0;
|
||||
} else {
|
||||
// use the long address to calculate the size of the room
|
||||
@@ -100,9 +96,8 @@ void Room::LoadHeader() {
|
||||
|
||||
int next_room_address = 0xF8000 + ((room_id_ + 1) * 3);
|
||||
|
||||
if (flags()->kLogToConsole)
|
||||
std::cout << "Next Room Address: " << std::hex << next_room_address
|
||||
<< std::endl;
|
||||
std::cout << "Next Room Address: " << std::hex << next_room_address
|
||||
<< std::endl;
|
||||
|
||||
// Reading bytes for long address construction
|
||||
uint8_t next_low = rom()->data()[next_room_address];
|
||||
@@ -112,19 +107,17 @@ void Room::LoadHeader() {
|
||||
// Constructing the long address
|
||||
int next_long_address = (next_bank << 16) | (next_high << 8) | next_low;
|
||||
|
||||
if (flags()->kLogToConsole)
|
||||
std::cout << std::hex << std::setfill('0') << std::setw(6)
|
||||
<< next_long_address << std::endl;
|
||||
std::cout << std::hex << std::setfill('0') << std::setw(6)
|
||||
<< next_long_address << std::endl;
|
||||
|
||||
// Calculate the size of the room
|
||||
int room_size = next_long_address - long_address;
|
||||
room_size_ = room_size;
|
||||
if (flags()->kLogToConsole)
|
||||
std::cout << "Size of Room #" << room_id_ << ": " << std::dec
|
||||
<< room_size << " bytes" << std::endl;
|
||||
std::cout << "Size of Room #" << room_id_ << ": " << std::dec << room_size
|
||||
<< " bytes" << std::endl;
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
if (flags()->kLogToConsole) std::cout << "Error: " << e.what() << std::endl;
|
||||
std::cout << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "app/core/common.h"
|
||||
#include "app/core/constants.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
@@ -118,7 +117,7 @@ struct ChestData {
|
||||
|
||||
struct StaircaseRooms {};
|
||||
|
||||
class Room : public SharedRom, public core::ExperimentFlags {
|
||||
class Room : public SharedRom {
|
||||
public:
|
||||
Room() = default;
|
||||
Room(int room_id) : room_id_(room_id) {}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "app/core/common.h"
|
||||
|
||||
#include "app/core/constants.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "app/core/common.h"
|
||||
|
||||
#include "app/core/constants.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/compression.h"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "app/core/common.h"
|
||||
|
||||
#include "app/editor/utils/gfx_context.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "app/core/common.h"
|
||||
|
||||
#include "app/editor/utils/gfx_context.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "app/core/common.h"
|
||||
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/rom.h"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "app/core/common.h"
|
||||
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/rom.h"
|
||||
|
||||
Reference in New Issue
Block a user