remove nonstandard type aliases
This commit is contained in:
@@ -5,13 +5,13 @@
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "absl/strings/str_cat.h"
|
#include "absl/strings/str_cat.h"
|
||||||
#include "absl/strings/str_format.h"
|
#include "absl/strings/str_format.h"
|
||||||
#include "app/core/platform/file_dialog.h"
|
#include "app/core/platform/file_dialog.h"
|
||||||
#include "app/gui/icons.h"
|
#include "app/gui/icons.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace core {
|
namespace core {
|
||||||
@@ -27,54 +27,54 @@ static const float FONT_SIZE_DEFAULT = 16.0f;
|
|||||||
static const float FONT_SIZE_DROID_SANS = 18.0f;
|
static const float FONT_SIZE_DROID_SANS = 18.0f;
|
||||||
static const float ICON_FONT_SIZE = 18.0f;
|
static const float ICON_FONT_SIZE = 18.0f;
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
std::string SetFontPath(const std::string& font_path) {
|
std::string SetFontPath(const std::string& font_path) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#if TARGET_OS_IOS == 1
|
#if TARGET_OS_IOS == 1
|
||||||
const std::string kBundlePath = GetBundleResourcePath();
|
const std::string kBundlePath = GetBundleResourcePath();
|
||||||
return kBundlePath + font_path;
|
return kBundlePath + font_path;
|
||||||
#else
|
#else
|
||||||
return absl::StrCat(GetBundleResourcePath(), "Contents/Resources/font/",
|
return absl::StrCat(GetBundleResourcePath(), "Contents/Resources/font/",
|
||||||
font_path);
|
font_path);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
return absl::StrCat("assets/font/", font_path);
|
return absl::StrCat("assets/font/", font_path);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::Status LoadFont(const FontConfig& font_config) {
|
absl::Status LoadFont(const FontConfig& font_config) {
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
std::string actual_font_path = SetFontPath(font_config.font_path);
|
std::string actual_font_path = SetFontPath(font_config.font_path);
|
||||||
// Check if the file exists with std library first, since ImGui IO will assert
|
// Check if the file exists with std library first, since ImGui IO will assert
|
||||||
// if the file does not exist
|
// if the file does not exist
|
||||||
if (!std::filesystem::exists(actual_font_path)) {
|
if (!std::filesystem::exists(actual_font_path)) {
|
||||||
return absl::InternalError(
|
return absl::InternalError(
|
||||||
absl::StrFormat("Font file %s does not exist", actual_font_path));
|
absl::StrFormat("Font file %s does not exist", actual_font_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!io.Fonts->AddFontFromFileTTF(actual_font_path.data(), font_config.font_size)) {
|
if (!io.Fonts->AddFontFromFileTTF(actual_font_path.data(),
|
||||||
return absl::InternalError(
|
font_config.font_size)) {
|
||||||
absl::StrFormat("Failed to load font from %s", actual_font_path));
|
return absl::InternalError(
|
||||||
}
|
absl::StrFormat("Failed to load font from %s", actual_font_path));
|
||||||
return absl::OkStatus();
|
}
|
||||||
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::Status AddIconFont() {
|
absl::Status AddIconFont() {
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
static const ImWchar icons_ranges[] = { ICON_MIN_MD, 0xf900, 0 };
|
static const ImWchar icons_ranges[] = {ICON_MIN_MD, 0xf900, 0};
|
||||||
ImFontConfig icons_config;
|
ImFontConfig icons_config;
|
||||||
icons_config.MergeMode = true;
|
icons_config.MergeMode = true;
|
||||||
icons_config.GlyphOffset.y = 5.0f;
|
icons_config.GlyphOffset.y = 5.0f;
|
||||||
icons_config.GlyphMinAdvanceX = 13.0f;
|
icons_config.GlyphMinAdvanceX = 13.0f;
|
||||||
icons_config.PixelSnapH = true;
|
icons_config.PixelSnapH = true;
|
||||||
std::string icon_font_path = SetFontPath(FONT_ICON_FILE_NAME_MD);
|
std::string icon_font_path = SetFontPath(FONT_ICON_FILE_NAME_MD);
|
||||||
if (!io.Fonts->AddFontFromFileTTF(icon_font_path.c_str(), ICON_FONT_SIZE,
|
if (!io.Fonts->AddFontFromFileTTF(icon_font_path.c_str(), ICON_FONT_SIZE,
|
||||||
&icons_config, icons_ranges)) {
|
&icons_config, icons_ranges)) {
|
||||||
return absl::InternalError("Failed to add icon fonts");
|
return absl::InternalError("Failed to add icon fonts");
|
||||||
}
|
}
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::Status AddJapaneseFont() {
|
absl::Status AddJapaneseFont() {
|
||||||
@@ -86,8 +86,8 @@ absl::Status AddJapaneseFont() {
|
|||||||
japanese_font_config.PixelSnapH = true;
|
japanese_font_config.PixelSnapH = true;
|
||||||
std::string japanese_font_path = SetFontPath(NOTO_SANS_JP);
|
std::string japanese_font_path = SetFontPath(NOTO_SANS_JP);
|
||||||
if (!io.Fonts->AddFontFromFileTTF(japanese_font_path.data(), ICON_FONT_SIZE,
|
if (!io.Fonts->AddFontFromFileTTF(japanese_font_path.data(), ICON_FONT_SIZE,
|
||||||
&japanese_font_config,
|
&japanese_font_config,
|
||||||
io.Fonts->GetGlyphRangesJapanese())) {
|
io.Fonts->GetGlyphRangesJapanese())) {
|
||||||
return absl::InternalError("Failed to add Japanese fonts");
|
return absl::InternalError("Failed to add Japanese fonts");
|
||||||
}
|
}
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
@@ -96,7 +96,7 @@ absl::Status AddJapaneseFont() {
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
absl::Status LoadPackageFonts() {
|
absl::Status LoadPackageFonts() {
|
||||||
ImGuiIO &io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
// Icon configuration
|
// Icon configuration
|
||||||
static const ImWchar icons_ranges[] = {ICON_MIN_MD, 0xf900, 0};
|
static const ImWchar icons_ranges[] = {ICON_MIN_MD, 0xf900, 0};
|
||||||
@@ -114,45 +114,46 @@ absl::Status LoadPackageFonts() {
|
|||||||
icons_config.PixelSnapH = true;
|
icons_config.PixelSnapH = true;
|
||||||
|
|
||||||
// List of fonts to be loaded
|
// List of fonts to be loaded
|
||||||
std::vector<const char *> font_paths = {
|
std::vector<const char*> font_paths = {
|
||||||
KARLA_REGULAR, ROBOTO_MEDIUM, COUSINE_REGULAR, IBM_PLEX_JP, DROID_SANS};
|
KARLA_REGULAR, ROBOTO_MEDIUM, COUSINE_REGULAR, IBM_PLEX_JP, DROID_SANS};
|
||||||
|
|
||||||
// Load fonts with associated icon and Japanese merges
|
// Load fonts with associated icon and Japanese merges
|
||||||
for (const auto &font_path : font_paths) {
|
for (const auto& font_path : font_paths) {
|
||||||
float font_size =
|
float font_size =
|
||||||
(font_path == DROID_SANS) ? FONT_SIZE_DROID_SANS : FONT_SIZE_DEFAULT;
|
(font_path == DROID_SANS) ? FONT_SIZE_DROID_SANS : FONT_SIZE_DEFAULT;
|
||||||
|
|
||||||
FontConfig font_config = { font_path, font_size };
|
FontConfig font_config = {font_path, font_size};
|
||||||
RETURN_IF_ERROR(LoadFont(font_config));
|
RETURN_IF_ERROR(LoadFont(font_config));
|
||||||
|
|
||||||
// Merge icon set
|
// Merge icon set
|
||||||
RETURN_IF_ERROR(AddIconFont());
|
RETURN_IF_ERROR(AddIconFont());
|
||||||
|
|
||||||
// Merge Japanese font
|
// Merge Japanese font
|
||||||
RETURN_IF_ERROR(AddJapaneseFont());
|
RETURN_IF_ERROR(AddJapaneseFont());
|
||||||
}
|
}
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::Status ReloadPackageFont(const FontConfig& config) {
|
absl::Status ReloadPackageFont(const FontConfig& config) {
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
std::string actual_font_path = SetFontPath(config.font_path);
|
std::string actual_font_path = SetFontPath(config.font_path);
|
||||||
if (!io.Fonts->AddFontFromFileTTF(actual_font_path.data(), config.font_size)) {
|
if (!io.Fonts->AddFontFromFileTTF(actual_font_path.data(),
|
||||||
return absl::InternalError(
|
config.font_size)) {
|
||||||
absl::StrFormat("Failed to load font from %s", actual_font_path));
|
return absl::InternalError(
|
||||||
}
|
absl::StrFormat("Failed to load font from %s", actual_font_path));
|
||||||
RETURN_IF_ERROR(AddIconFont());
|
}
|
||||||
RETURN_IF_ERROR(AddJapaneseFont());
|
RETURN_IF_ERROR(AddIconFont());
|
||||||
|
RETURN_IF_ERROR(AddJapaneseFont());
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
int CALLBACK EnumFontFamExProc(const LOGFONT *lpelfe, const TEXTMETRIC *lpntme,
|
int CALLBACK EnumFontFamExProc(const LOGFONT* lpelfe, const TEXTMETRIC* lpntme,
|
||||||
DWORD FontType, LPARAM lParam) {
|
DWORD FontType, LPARAM lParam) {
|
||||||
// Step 3: Load the font into ImGui
|
// Step 3: Load the font into ImGui
|
||||||
ImGuiIO &io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.Fonts->AddFontFromFileTTF(lpelfe->lfFaceName, 16.0f);
|
io.Fonts->AddFontFromFileTTF(lpelfe->lfFaceName, 16.0f);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -175,8 +176,8 @@ void LoadSystemFonts() {
|
|||||||
RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, &valueCount,
|
RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, &valueCount,
|
||||||
&maxValueNameSize, &maxValueDataSize, NULL, NULL);
|
&maxValueNameSize, &maxValueDataSize, NULL, NULL);
|
||||||
|
|
||||||
char *valueName = new char[maxValueNameSize + 1]; // +1 for null terminator
|
char* valueName = new char[maxValueNameSize + 1]; // +1 for null terminator
|
||||||
BYTE *valueData = new BYTE[maxValueDataSize + 1]; // +1 for null terminator
|
BYTE* valueData = new BYTE[maxValueDataSize + 1]; // +1 for null terminator
|
||||||
|
|
||||||
// Enumerate all font entries
|
// Enumerate all font entries
|
||||||
for (DWORD i = 0; i < valueCount; i++) {
|
for (DWORD i = 0; i < valueCount; i++) {
|
||||||
@@ -193,7 +194,7 @@ void LoadSystemFonts() {
|
|||||||
valueData, &valueDataSize) == ERROR_SUCCESS) {
|
valueData, &valueDataSize) == ERROR_SUCCESS) {
|
||||||
if (valueType == REG_SZ) {
|
if (valueType == REG_SZ) {
|
||||||
// Add the font file path to the vector
|
// Add the font file path to the vector
|
||||||
std::string fontPath(reinterpret_cast<char *>(valueData),
|
std::string fontPath(reinterpret_cast<char*>(valueData),
|
||||||
valueDataSize);
|
valueDataSize);
|
||||||
|
|
||||||
fontPaths.push_back(fontPath);
|
fontPaths.push_back(fontPath);
|
||||||
@@ -207,7 +208,7 @@ void LoadSystemFonts() {
|
|||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiIO &io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
// List of common font face names
|
// List of common font face names
|
||||||
static const std::unordered_set<std::string> commonFontFaceNames = {
|
static const std::unordered_set<std::string> commonFontFaceNames = {
|
||||||
@@ -226,7 +227,7 @@ void LoadSystemFonts() {
|
|||||||
"Tahoma",
|
"Tahoma",
|
||||||
"Lucida Console"};
|
"Lucida Console"};
|
||||||
|
|
||||||
for (auto &fontPath : fontPaths) {
|
for (auto& fontPath : fontPaths) {
|
||||||
// Check if the font path has a "C:\" prefix
|
// Check if the font path has a "C:\" prefix
|
||||||
if (fontPath.substr(0, 2) != "C:") {
|
if (fontPath.substr(0, 2) != "C:") {
|
||||||
// Add "C:\Windows\Fonts\" prefix to the font path
|
// Add "C:\Windows\Fonts\" prefix to the font path
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/gui/icons.h"
|
#include "app/gui/icons.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
#include "imgui/misc/cpp/imgui_stdlib.h"
|
#include "imgui/misc/cpp/imgui_stdlib.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
|
|
||||||
@@ -184,5 +184,4 @@ std::string ResourceLabelManager::CreateOrGetLabel(
|
|||||||
return labels_[type][key];
|
return labels_[type][key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#ifndef YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_H
|
#ifndef YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_H
|
||||||
#define YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_H
|
#define YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_H
|
||||||
|
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/core/platform/file_dialog.h"
|
#include "app/core/platform/file_dialog.h"
|
||||||
#include "app/editor/code/memory_editor.h"
|
#include "app/editor/code/memory_editor.h"
|
||||||
#include "app/gui/input.h"
|
#include "app/gui/input.h"
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
#include "imgui_memory_editor.h"
|
#include "imgui_memory_editor.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace editor {
|
namespace editor {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "absl/strings/match.h"
|
#include "absl/strings/match.h"
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/core/platform/file_dialog.h"
|
#include "app/core/platform/file_dialog.h"
|
||||||
#include "app/core/project.h"
|
#include "app/core/project.h"
|
||||||
#include "app/editor/code/assembly_editor.h"
|
#include "app/editor/code/assembly_editor.h"
|
||||||
@@ -22,6 +21,7 @@
|
|||||||
#include "editor/editor.h"
|
#include "editor/editor.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
#include "imgui/misc/cpp/imgui_stdlib.h"
|
#include "imgui/misc/cpp/imgui_stdlib.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace editor {
|
namespace editor {
|
||||||
@@ -62,7 +62,7 @@ absl::Status EditorManager::Update() {
|
|||||||
DrawPopups();
|
DrawPopups();
|
||||||
|
|
||||||
if (rom()->is_loaded() && !rom_assets_loaded_) {
|
if (rom()->is_loaded() && !rom_assets_loaded_) {
|
||||||
auto& sheet_manager = GraphicsSheetManager::GetInstance();
|
auto &sheet_manager = GraphicsSheetManager::GetInstance();
|
||||||
ASSIGN_OR_RETURN(*sheet_manager.mutable_gfx_sheets(),
|
ASSIGN_OR_RETURN(*sheet_manager.mutable_gfx_sheets(),
|
||||||
LoadAllGraphicsData(*rom()))
|
LoadAllGraphicsData(*rom()))
|
||||||
RETURN_IF_ERROR(overworld_editor_.LoadGraphics());
|
RETURN_IF_ERROR(overworld_editor_.LoadGraphics());
|
||||||
@@ -357,15 +357,19 @@ void EditorManager::DrawPopups() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditorManager::DrawHomepage() {
|
void EditorManager::DrawHomepage() {
|
||||||
TextWrapped("Welcome to the Yet Another Zelda3 Editor (yaze)!");
|
TextWrapped("Welcome to the Yet Another Zelda3 Editor (yaze)!");
|
||||||
TextWrapped("This editor is designed to be a comprehensive tool for editing the Legend of Zelda: A Link to the Past.");
|
TextWrapped(
|
||||||
TextWrapped("The editor is still in development, so please report any bugs or issues you encounter.");
|
"This editor is designed to be a comprehensive tool for editing the "
|
||||||
|
"Legend of Zelda: A Link to the Past.");
|
||||||
|
TextWrapped(
|
||||||
|
"The editor is still in development, so please report any bugs or issues "
|
||||||
|
"you encounter.");
|
||||||
|
|
||||||
static bool managed_startup = false;
|
static bool managed_startup = false;
|
||||||
|
|
||||||
if (Button("Open ROM", ImVec2(200, 0))) {
|
if (Button("Open ROM", ImVec2(200, 0))) {
|
||||||
LoadRom();
|
LoadRom();
|
||||||
}
|
}
|
||||||
SameLine();
|
SameLine();
|
||||||
ImGui::Checkbox("Manage Startup", &managed_startup);
|
ImGui::Checkbox("Manage Startup", &managed_startup);
|
||||||
Separator();
|
Separator();
|
||||||
@@ -467,18 +471,18 @@ void EditorManager::DrawMenuContent() {
|
|||||||
flags_menu.DrawSystemFlags();
|
flags_menu.DrawSystemFlags();
|
||||||
EndMenu();
|
EndMenu();
|
||||||
}
|
}
|
||||||
if (BeginMenu("Overworld Flags")) {
|
if (BeginMenu("Overworld Flags")) {
|
||||||
flags_menu.DrawOverworldFlags();
|
flags_menu.DrawOverworldFlags();
|
||||||
EndMenu();
|
EndMenu();
|
||||||
}
|
}
|
||||||
if (BeginMenu("Dungeon Flags")) {
|
if (BeginMenu("Dungeon Flags")) {
|
||||||
flags_menu.DrawDungeonFlags();
|
flags_menu.DrawDungeonFlags();
|
||||||
EndMenu();
|
EndMenu();
|
||||||
}
|
}
|
||||||
if (BeginMenu("Resource Flags")) {
|
if (BeginMenu("Resource Flags")) {
|
||||||
flags_menu.DrawResourceFlags();
|
flags_menu.DrawResourceFlags();
|
||||||
EndMenu();
|
EndMenu();
|
||||||
}
|
}
|
||||||
EndMenu();
|
EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -718,7 +722,7 @@ void EditorManager::LoadRom() {
|
|||||||
auto file_name = FileDialogWrapper::ShowOpenFileDialog();
|
auto file_name = FileDialogWrapper::ShowOpenFileDialog();
|
||||||
auto load_rom = rom()->LoadFromFile(file_name);
|
auto load_rom = rom()->LoadFromFile(file_name);
|
||||||
if (load_rom.ok()) {
|
if (load_rom.ok()) {
|
||||||
current_rom_ = rom();
|
current_rom_ = rom();
|
||||||
static RecentFilesManager manager("recent_files.txt");
|
static RecentFilesManager manager("recent_files.txt");
|
||||||
manager.Load();
|
manager.Load();
|
||||||
manager.AddFile(file_name);
|
manager.AddFile(file_name);
|
||||||
@@ -736,8 +740,8 @@ void EditorManager::SaveRom() {
|
|||||||
RETURN_VOID_IF_ERROR(status_);
|
RETURN_VOID_IF_ERROR(status_);
|
||||||
|
|
||||||
if (core::ExperimentFlags::get().kSaveGraphicsSheet)
|
if (core::ExperimentFlags::get().kSaveGraphicsSheet)
|
||||||
PRINT_IF_ERROR(SaveAllGraphicsData(*rom(),
|
PRINT_IF_ERROR(SaveAllGraphicsData(
|
||||||
GraphicsSheetManager::GetInstance().gfx_sheets()));
|
*rom(), GraphicsSheetManager::GetInstance().gfx_sheets()));
|
||||||
|
|
||||||
status_ = rom()->SaveToFile(backup_rom_, save_new_auto_);
|
status_ = rom()->SaveToFile(backup_rom_, save_new_auto_);
|
||||||
}
|
}
|
||||||
@@ -750,13 +754,13 @@ void EditorManager::OpenRomOrProject(const std::string &filename) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status_ = rom()->LoadFromFile(filename);
|
status_ = rom()->LoadFromFile(filename);
|
||||||
current_rom_ = rom();
|
current_rom_ = rom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::Status EditorManager::OpenProject() {
|
absl::Status EditorManager::OpenProject() {
|
||||||
RETURN_IF_ERROR(rom()->LoadFromFile(current_project_.rom_filename_));
|
RETURN_IF_ERROR(rom()->LoadFromFile(current_project_.rom_filename_));
|
||||||
current_rom_ = rom();
|
current_rom_ = rom();
|
||||||
|
|
||||||
if (!rom()->resource_label()->LoadLabels(current_project_.labels_filename_)) {
|
if (!rom()->resource_label()->LoadLabels(current_project_.labels_filename_)) {
|
||||||
return absl::InternalError(
|
return absl::InternalError(
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#include "absl/strings/str_format.h"
|
#include "absl/strings/str_format.h"
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/core/platform/file_dialog.h"
|
#include "app/core/platform/file_dialog.h"
|
||||||
#include "app/core/platform/renderer.h"
|
#include "app/core/platform/renderer.h"
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
@@ -17,6 +16,7 @@
|
|||||||
#include "app/gui/icons.h"
|
#include "app/gui/icons.h"
|
||||||
#include "app/gui/input.h"
|
#include "app/gui/input.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace editor {
|
namespace editor {
|
||||||
@@ -128,7 +128,7 @@ absl::Status ScreenEditor::LoadDungeonMaps() {
|
|||||||
int pc_ptr_gfx =
|
int pc_ptr_gfx =
|
||||||
core::SnesToPc(ptr_gfx); // Contains data for the next 25 rooms
|
core::SnesToPc(ptr_gfx); // Contains data for the next 25 rooms
|
||||||
|
|
||||||
ASSIGN_OR_RETURN(ushort boss_room_d,
|
ASSIGN_OR_RETURN(uint16_t boss_room_d,
|
||||||
rom()->ReadWord(zelda3::kDungeonMapBossRooms + (d * 2)));
|
rom()->ReadWord(zelda3::kDungeonMapBossRooms + (d * 2)));
|
||||||
|
|
||||||
ASSIGN_OR_RETURN(nbr_basement_d,
|
ASSIGN_OR_RETURN(nbr_basement_d,
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "absl/strings/str_format.h"
|
#include "absl/strings/str_format.h"
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/core/platform/clipboard.h"
|
#include "app/core/platform/clipboard.h"
|
||||||
#include "app/core/platform/renderer.h"
|
#include "app/core/platform/renderer.h"
|
||||||
#include "app/editor/graphics/palette_editor.h"
|
#include "app/editor/graphics/palette_editor.h"
|
||||||
@@ -24,6 +23,7 @@
|
|||||||
#include "app/zelda3/overworld/overworld.h"
|
#include "app/zelda3/overworld/overworld.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
#include "imgui_memory_editor.h"
|
#include "imgui_memory_editor.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace editor {
|
namespace editor {
|
||||||
@@ -1041,7 +1041,7 @@ absl::Status OverworldEditor::LoadGraphics() {
|
|||||||
|
|
||||||
core::logf("Loading overworld tile16 graphics.");
|
core::logf("Loading overworld tile16 graphics.");
|
||||||
// Loop through the tiles and copy their pixel data into separate vectors
|
// Loop through the tiles and copy their pixel data into separate vectors
|
||||||
for (uint i = 0; i < zelda3::kNumTile16Individual; i++) {
|
for (unsigned int i = 0; i < zelda3::kNumTile16Individual; i++) {
|
||||||
tile16_individual_[i].Create(kTile16Size, kTile16Size, 0x08,
|
tile16_individual_[i].Create(kTile16Size, kTile16Size, 0x08,
|
||||||
kTile16Size * kTile16Size);
|
kTile16Size * kTile16Size);
|
||||||
|
|
||||||
@@ -1214,7 +1214,7 @@ absl::Status OverworldEditor::RefreshTile16Blockset() {
|
|||||||
|
|
||||||
// Loop through the tiles and copy their pixel data into separate vectors
|
// Loop through the tiles and copy their pixel data into separate vectors
|
||||||
std::vector<std::future<absl::Status>> futures;
|
std::vector<std::future<absl::Status>> futures;
|
||||||
for (uint i = 0; i < zelda3::kNumTile16Individual; i++) {
|
for (unsigned int i = 0; i < zelda3::kNumTile16Individual; i++) {
|
||||||
futures.push_back(std::async(
|
futures.push_back(std::async(
|
||||||
std::launch::async,
|
std::launch::async,
|
||||||
[&](int index) -> absl::Status {
|
[&](int index) -> absl::Status {
|
||||||
@@ -1241,7 +1241,7 @@ absl::Status OverworldEditor::RefreshTile16Blockset() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Render the bitmaps of each tile.
|
// Render the bitmaps of each tile.
|
||||||
for (uint id = 0; id < zelda3::kNumTile16Individual; id++) {
|
for (unsigned int id = 0; id < zelda3::kNumTile16Individual; id++) {
|
||||||
Renderer::GetInstance().UpdateBitmap(&tile16_individual_[id]);
|
Renderer::GetInstance().UpdateBitmap(&tile16_individual_[id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,12 +18,12 @@
|
|||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace editor {
|
namespace editor {
|
||||||
|
|
||||||
constexpr uint k4BPP = 4;
|
constexpr unsigned int k4BPP = 4;
|
||||||
constexpr uint kByteSize = 3;
|
constexpr unsigned int kByteSize = 3;
|
||||||
constexpr uint kMessageIdSize = 5;
|
constexpr unsigned int kMessageIdSize = 5;
|
||||||
constexpr uint kNumSheetsToLoad = 223;
|
constexpr unsigned int kNumSheetsToLoad = 223;
|
||||||
constexpr uint kTile8DisplayHeight = 64;
|
constexpr unsigned int kTile8DisplayHeight = 64;
|
||||||
constexpr uint kOverworldMapSize = 0x200;
|
constexpr unsigned int kOverworldMapSize = 0x200;
|
||||||
constexpr float kInputFieldSize = 30.f;
|
constexpr float kInputFieldSize = 30.f;
|
||||||
constexpr ImVec2 kOverworldCanvasSize(kOverworldMapSize * 8,
|
constexpr ImVec2 kOverworldCanvasSize(kOverworldMapSize * 8,
|
||||||
kOverworldMapSize * 8);
|
kOverworldMapSize * 8);
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace editor {
|
namespace editor {
|
||||||
@@ -106,8 +106,8 @@ struct ZSprite {
|
|||||||
offset += sizeof(int);
|
offset += sizeof(int);
|
||||||
|
|
||||||
for (int j = 0; j < tCount; j++) {
|
for (int j = 0; j < tCount; j++) {
|
||||||
ushort tid = *reinterpret_cast<ushort*>(&buffer[offset]);
|
uint16_t tid = *reinterpret_cast<uint16_t*>(&buffer[offset]);
|
||||||
offset += sizeof(ushort);
|
offset += sizeof(uint16_t);
|
||||||
uint8_t tpal = *reinterpret_cast<uint8_t*>(&buffer[offset]);
|
uint8_t tpal = *reinterpret_cast<uint8_t*>(&buffer[offset]);
|
||||||
offset += sizeof(uint8_t);
|
offset += sizeof(uint8_t);
|
||||||
bool tmx = *reinterpret_cast<bool*>(&buffer[offset]);
|
bool tmx = *reinterpret_cast<bool*>(&buffer[offset]);
|
||||||
@@ -246,7 +246,7 @@ struct ZSprite {
|
|||||||
|
|
||||||
for (int j = 0; j < editor.Frames[i].Tiles.size(); j++) {
|
for (int j = 0; j < editor.Frames[i].Tiles.size(); j++) {
|
||||||
fs.write(reinterpret_cast<const char*>(&editor.Frames[i].Tiles[j].id),
|
fs.write(reinterpret_cast<const char*>(&editor.Frames[i].Tiles[j].id),
|
||||||
sizeof(ushort));
|
sizeof(uint16_t));
|
||||||
fs.write(
|
fs.write(
|
||||||
reinterpret_cast<const char*>(&editor.Frames[i].Tiles[j].palette),
|
reinterpret_cast<const char*>(&editor.Frames[i].Tiles[j].palette),
|
||||||
sizeof(uint8_t));
|
sizeof(uint8_t));
|
||||||
|
|||||||
@@ -9,13 +9,8 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/gfx/snes_palette.h"
|
#include "app/gfx/snes_palette.h"
|
||||||
|
#include "util/macro.h"
|
||||||
#define SDL_RETURN_IF_ERROR() \
|
|
||||||
if (SDL_GetError() != nullptr) { \
|
|
||||||
return absl::InternalError(SDL_GetError()); \
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
@@ -218,7 +213,8 @@ Bitmap::Bitmap(int width, int height, int depth, int data_size) {
|
|||||||
Create(width, height, depth, std::vector<uint8_t>(data_size, 0));
|
Create(width, height, depth, std::vector<uint8_t>(data_size, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bitmap::Initialize(int width, int height, int depth, std::span<uint8_t>& data) {
|
void Bitmap::Initialize(int width, int height, int depth,
|
||||||
|
std::span<uint8_t> &data) {
|
||||||
width_ = width;
|
width_ = width;
|
||||||
height_ = height;
|
height_ = height;
|
||||||
depth_ = depth;
|
depth_ = depth;
|
||||||
@@ -259,7 +255,8 @@ void Bitmap::Create(int width, int height, int depth, int format,
|
|||||||
GetSnesPixelFormat(format)),
|
GetSnesPixelFormat(format)),
|
||||||
SDL_Surface_Deleter{}};
|
SDL_Surface_Deleter{}};
|
||||||
if (surface_ == nullptr) {
|
if (surface_ == nullptr) {
|
||||||
SDL_Log("Bitmap::Create.SDL_CreateRGBSurfaceWithFormat failed: %s\n", SDL_GetError());
|
SDL_Log("Bitmap::Create.SDL_CreateRGBSurfaceWithFormat failed: %s\n",
|
||||||
|
SDL_GetError());
|
||||||
active_ = false;
|
active_ = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -293,7 +290,8 @@ void Bitmap::CreateTexture(SDL_Renderer *renderer) {
|
|||||||
SDL_TEXTUREACCESS_STREAMING, width_, height_),
|
SDL_TEXTUREACCESS_STREAMING, width_, height_),
|
||||||
SDL_Texture_Deleter{}};
|
SDL_Texture_Deleter{}};
|
||||||
if (texture_ == nullptr) {
|
if (texture_ == nullptr) {
|
||||||
SDL_Log("Bitmap::CreateTexture.SDL_CreateTextureFromSurface failed: %s\n", SDL_GetError());
|
SDL_Log("Bitmap::CreateTexture.SDL_CreateTextureFromSurface failed: %s\n",
|
||||||
|
SDL_GetError());
|
||||||
}
|
}
|
||||||
texture_pixels = data_.data();
|
texture_pixels = data_.data();
|
||||||
|
|
||||||
@@ -301,7 +299,8 @@ void Bitmap::CreateTexture(SDL_Renderer *renderer) {
|
|||||||
SDL_ConvertSurfaceFormat(surface_.get(), SDL_PIXELFORMAT_ARGB8888, 0),
|
SDL_ConvertSurfaceFormat(surface_.get(), SDL_PIXELFORMAT_ARGB8888, 0),
|
||||||
SDL_Surface_Deleter{}};
|
SDL_Surface_Deleter{}};
|
||||||
if (converted_surface_ == nullptr) {
|
if (converted_surface_ == nullptr) {
|
||||||
SDL_Log("Bitmap::CreateTexture.SDL_ConvertSurfaceFormat failed: %s\n", SDL_GetError());
|
SDL_Log("Bitmap::CreateTexture.SDL_ConvertSurfaceFormat failed: %s\n",
|
||||||
|
SDL_GetError());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/core/platform/sdl_deleter.h"
|
#include "app/core/platform/sdl_deleter.h"
|
||||||
#include "app/gfx/snes_palette.h"
|
#include "app/gfx/snes_palette.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
|
|
||||||
@@ -91,10 +91,10 @@ class Bitmap {
|
|||||||
|
|
||||||
void SaveSurfaceToFile(std::string_view filename);
|
void SaveSurfaceToFile(std::string_view filename);
|
||||||
|
|
||||||
void Initialize(int width, int height, int depth, std::span<uint8_t>& data);
|
void Initialize(int width, int height, int depth, std::span<uint8_t> &data);
|
||||||
|
|
||||||
void Create(int width, int height, int depth, int data_size) {
|
void Create(int width, int height, int depth, int data_size) {
|
||||||
Create(width, height, depth, std::vector<uint8_t>(data_size, 0));
|
Create(width, height, depth, std::vector<uint8_t>(data_size, 0));
|
||||||
}
|
}
|
||||||
void Create(int width, int height, int depth, std::span<uint8_t> data);
|
void Create(int width, int height, int depth, std::span<uint8_t> data);
|
||||||
void Create(int width, int height, int depth,
|
void Create(int width, int height, int depth,
|
||||||
@@ -133,7 +133,7 @@ class Bitmap {
|
|||||||
void Get16x16Tile(int tile_x, int tile_y, std::vector<uint8_t> &tile_data,
|
void Get16x16Tile(int tile_x, int tile_y, std::vector<uint8_t> &tile_data,
|
||||||
int &tile_data_offset);
|
int &tile_data_offset);
|
||||||
|
|
||||||
void WriteToPixel(int position, uchar value) {
|
void WriteToPixel(int position, uint8_t value) {
|
||||||
if (pixel_data_ == nullptr) {
|
if (pixel_data_ == nullptr) {
|
||||||
pixel_data_ = data_.data();
|
pixel_data_ = data_.data();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
#define DEBUG_LOG(msg) std::cout << msg << std::endl
|
#define DEBUG_LOG(msg) std::cout << msg << std::endl
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ std::vector<uint8_t> HyruleMagicDecompress(uint8_t const* src, int* const size,
|
|||||||
unsigned short c, d;
|
unsigned short c, d;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
// retrieve a uchar from the buffer.
|
// retrieve a uint8_t from the buffer.
|
||||||
a = *(src++);
|
a = *(src++);
|
||||||
|
|
||||||
// end the decompression routine if we encounter 0xff.
|
// end the decompression routine if we encounter 0xff.
|
||||||
@@ -320,10 +320,10 @@ void PrintCompressionChain(const CompressionPiecePointer& chain_head) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckByteRepeat(const uchar* rom_data, DataSizeArray& data_size_taken,
|
void CheckByteRepeat(const uint8_t* rom_data, DataSizeArray& data_size_taken,
|
||||||
CommandArgumentArray& cmd_args, uint& src_data_pos,
|
CommandArgumentArray& cmd_args, uint& src_data_pos,
|
||||||
const uint last_pos) {
|
const unsigned int last_pos) {
|
||||||
uint pos = src_data_pos;
|
unsigned int pos = src_data_pos;
|
||||||
char byte_to_repeat = rom_data[pos];
|
char byte_to_repeat = rom_data[pos];
|
||||||
while (pos <= last_pos && rom_data[pos] == byte_to_repeat) {
|
while (pos <= last_pos && rom_data[pos] == byte_to_repeat) {
|
||||||
data_size_taken[kCommandByteFill]++;
|
data_size_taken[kCommandByteFill]++;
|
||||||
@@ -332,12 +332,12 @@ void CheckByteRepeat(const uchar* rom_data, DataSizeArray& data_size_taken,
|
|||||||
cmd_args[kCommandByteFill][0] = byte_to_repeat;
|
cmd_args[kCommandByteFill][0] = byte_to_repeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckWordRepeat(const uchar* rom_data, DataSizeArray& data_size_taken,
|
void CheckWordRepeat(const uint8_t* rom_data, DataSizeArray& data_size_taken,
|
||||||
CommandArgumentArray& cmd_args, uint& src_data_pos,
|
CommandArgumentArray& cmd_args, uint& src_data_pos,
|
||||||
const uint last_pos) {
|
const unsigned int last_pos) {
|
||||||
if (src_data_pos + 2 <= last_pos &&
|
if (src_data_pos + 2 <= last_pos &&
|
||||||
rom_data[src_data_pos] != rom_data[src_data_pos + 1]) {
|
rom_data[src_data_pos] != rom_data[src_data_pos + 1]) {
|
||||||
uint pos = src_data_pos;
|
unsigned int pos = src_data_pos;
|
||||||
char byte1 = rom_data[pos];
|
char byte1 = rom_data[pos];
|
||||||
char byte2 = rom_data[pos + 1];
|
char byte2 = rom_data[pos + 1];
|
||||||
pos += 2;
|
pos += 2;
|
||||||
@@ -354,10 +354,10 @@ void CheckWordRepeat(const uchar* rom_data, DataSizeArray& data_size_taken,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckIncByte(const uchar* rom_data, DataSizeArray& data_size_taken,
|
void CheckIncByte(const uint8_t* rom_data, DataSizeArray& data_size_taken,
|
||||||
CommandArgumentArray& cmd_args, uint& src_data_pos,
|
CommandArgumentArray& cmd_args, uint& src_data_pos,
|
||||||
const uint last_pos) {
|
const unsigned int last_pos) {
|
||||||
uint pos = src_data_pos;
|
unsigned int pos = src_data_pos;
|
||||||
char byte = rom_data[pos];
|
char byte = rom_data[pos];
|
||||||
pos++;
|
pos++;
|
||||||
data_size_taken[kCommandIncreasingFill] = 1;
|
data_size_taken[kCommandIncreasingFill] = 1;
|
||||||
@@ -370,14 +370,14 @@ void CheckIncByte(const uchar* rom_data, DataSizeArray& data_size_taken,
|
|||||||
cmd_args[kCommandIncreasingFill][0] = rom_data[src_data_pos];
|
cmd_args[kCommandIncreasingFill][0] = rom_data[src_data_pos];
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckIntraCopy(const uchar* rom_data, DataSizeArray& data_size_taken,
|
void CheckIntraCopy(const uint8_t* rom_data, DataSizeArray& data_size_taken,
|
||||||
CommandArgumentArray& cmd_args, uint& src_data_pos,
|
CommandArgumentArray& cmd_args, uint& src_data_pos,
|
||||||
const uint last_pos, uint start) {
|
const unsigned int last_pos, unsigned int start) {
|
||||||
if (src_data_pos != start) {
|
if (src_data_pos != start) {
|
||||||
uint searching_pos = start;
|
unsigned int searching_pos = start;
|
||||||
uint current_pos_u = src_data_pos;
|
unsigned int current_pos_u = src_data_pos;
|
||||||
uint copied_size = 0;
|
unsigned int copied_size = 0;
|
||||||
uint search_start = start;
|
unsigned int search_start = start;
|
||||||
|
|
||||||
while (searching_pos < src_data_pos && current_pos_u <= last_pos) {
|
while (searching_pos < src_data_pos && current_pos_u <= last_pos) {
|
||||||
while (rom_data[current_pos_u] != rom_data[searching_pos] &&
|
while (rom_data[current_pos_u] != rom_data[searching_pos] &&
|
||||||
@@ -409,8 +409,8 @@ void CheckIntraCopy(const uchar* rom_data, DataSizeArray& data_size_taken,
|
|||||||
void ValidateForByteGain(const DataSizeArray& data_size_taken,
|
void ValidateForByteGain(const DataSizeArray& data_size_taken,
|
||||||
const CommandSizeArray& cmd_size, uint& max_win,
|
const CommandSizeArray& cmd_size, uint& max_win,
|
||||||
uint& cmd_with_max) {
|
uint& cmd_with_max) {
|
||||||
for (uint cmd_i = 1; cmd_i < 5; cmd_i++) {
|
for (unsigned int cmd_i = 1; cmd_i < 5; cmd_i++) {
|
||||||
uint cmd_size_taken = data_size_taken[cmd_i];
|
unsigned int cmd_size_taken = data_size_taken[cmd_i];
|
||||||
// TODO(@scawful): Replace conditional with table of command sizes
|
// TODO(@scawful): Replace conditional with table of command sizes
|
||||||
// "Table that is even with copy but all other cmd are 2"
|
// "Table that is even with copy but all other cmd are 2"
|
||||||
auto table_check =
|
auto table_check =
|
||||||
@@ -424,7 +424,7 @@ void ValidateForByteGain(const DataSizeArray& data_size_taken,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompressionCommandAlternative(const uchar* rom_data,
|
void CompressionCommandAlternative(const uint8_t* rom_data,
|
||||||
CompressionPiecePointer& compressed_chain,
|
CompressionPiecePointer& compressed_chain,
|
||||||
const CommandSizeArray& cmd_size,
|
const CommandSizeArray& cmd_size,
|
||||||
const CommandArgumentArray& cmd_args,
|
const CommandArgumentArray& cmd_args,
|
||||||
@@ -459,9 +459,9 @@ void CompressionCommandAlternative(const uchar* rom_data,
|
|||||||
comp_accumulator = 0;
|
comp_accumulator = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckByteRepeatV2(const uchar* data, uint& src_pos, const uint last_pos,
|
void CheckByteRepeatV2(const uint8_t* data, uint& src_pos, const unsigned int last_pos,
|
||||||
CompressionCommand& cmd) {
|
CompressionCommand& cmd) {
|
||||||
uint i = 0;
|
unsigned int i = 0;
|
||||||
while (src_pos + i < last_pos && data[src_pos] == data[src_pos + i]) {
|
while (src_pos + i < last_pos && data[src_pos] == data[src_pos + i]) {
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
@@ -469,10 +469,10 @@ void CheckByteRepeatV2(const uchar* data, uint& src_pos, const uint last_pos,
|
|||||||
cmd.arguments[kCommandByteFill][0] = data[src_pos];
|
cmd.arguments[kCommandByteFill][0] = data[src_pos];
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckWordRepeatV2(const uchar* data, uint& src_pos, const uint last_pos,
|
void CheckWordRepeatV2(const uint8_t* data, uint& src_pos, const unsigned int last_pos,
|
||||||
CompressionCommand& cmd) {
|
CompressionCommand& cmd) {
|
||||||
if (src_pos + 2 <= last_pos && data[src_pos] != data[src_pos + 1]) {
|
if (src_pos + 2 <= last_pos && data[src_pos] != data[src_pos + 1]) {
|
||||||
uint pos = src_pos;
|
unsigned int pos = src_pos;
|
||||||
char byte1 = data[pos];
|
char byte1 = data[pos];
|
||||||
char byte2 = data[pos + 1];
|
char byte2 = data[pos + 1];
|
||||||
pos += 2;
|
pos += 2;
|
||||||
@@ -489,9 +489,9 @@ void CheckWordRepeatV2(const uchar* data, uint& src_pos, const uint last_pos,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckIncByteV2(const uchar* rom_data, uint& src_data_pos,
|
void CheckIncByteV2(const uint8_t* rom_data, uint& src_data_pos,
|
||||||
const uint last_pos, CompressionCommand& cmd) {
|
const unsigned int last_pos, CompressionCommand& cmd) {
|
||||||
uint pos = src_data_pos;
|
unsigned int pos = src_data_pos;
|
||||||
char byte = rom_data[pos];
|
char byte = rom_data[pos];
|
||||||
pos++;
|
pos++;
|
||||||
cmd.data_size[kCommandIncreasingFill] = 1;
|
cmd.data_size[kCommandIncreasingFill] = 1;
|
||||||
@@ -504,14 +504,14 @@ void CheckIncByteV2(const uchar* rom_data, uint& src_data_pos,
|
|||||||
cmd.arguments[kCommandIncreasingFill][0] = rom_data[src_data_pos];
|
cmd.arguments[kCommandIncreasingFill][0] = rom_data[src_data_pos];
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckIntraCopyV2(const uchar* rom_data, uint& src_data_pos,
|
void CheckIntraCopyV2(const uint8_t* rom_data, uint& src_data_pos,
|
||||||
const uint last_pos, uint start,
|
const unsigned int last_pos, unsigned int start,
|
||||||
CompressionCommand& cmd) {
|
CompressionCommand& cmd) {
|
||||||
if (src_data_pos != start) {
|
if (src_data_pos != start) {
|
||||||
uint searching_pos = start;
|
unsigned int searching_pos = start;
|
||||||
uint current_pos_u = src_data_pos;
|
unsigned int current_pos_u = src_data_pos;
|
||||||
uint copied_size = 0;
|
unsigned int copied_size = 0;
|
||||||
uint search_start = start;
|
unsigned int search_start = start;
|
||||||
|
|
||||||
while (searching_pos < src_data_pos && current_pos_u <= last_pos) {
|
while (searching_pos < src_data_pos && current_pos_u <= last_pos) {
|
||||||
while (rom_data[current_pos_u] != rom_data[searching_pos] &&
|
while (rom_data[current_pos_u] != rom_data[searching_pos] &&
|
||||||
@@ -544,8 +544,8 @@ const std::array<int, 5> kCommandSizes = {1, 2, 2, 2, 3};
|
|||||||
// TODO(@scawful): TEST ME
|
// TODO(@scawful): TEST ME
|
||||||
void ValidateForByteGainV2(const CompressionCommand& cmd, uint& max_win,
|
void ValidateForByteGainV2(const CompressionCommand& cmd, uint& max_win,
|
||||||
uint& cmd_with_max) {
|
uint& cmd_with_max) {
|
||||||
for (uint cmd_i = 1; cmd_i < 5; cmd_i++) {
|
for (unsigned int cmd_i = 1; cmd_i < 5; cmd_i++) {
|
||||||
uint cmd_size_taken = cmd.data_size[cmd_i];
|
unsigned int cmd_size_taken = cmd.data_size[cmd_i];
|
||||||
// Check if the command size exceeds the maximum win and the size in the
|
// Check if the command size exceeds the maximum win and the size in the
|
||||||
// command sizes table, except for the repeating bytes command when the size
|
// command sizes table, except for the repeating bytes command when the size
|
||||||
// taken is 3
|
// taken is 3
|
||||||
@@ -558,7 +558,7 @@ void ValidateForByteGainV2(const CompressionCommand& cmd, uint& max_win,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompressionCommandAlternativeV2(const uchar* rom_data,
|
void CompressionCommandAlternativeV2(const uint8_t* rom_data,
|
||||||
const CompressionCommand& cmd,
|
const CompressionCommand& cmd,
|
||||||
CompressionPiecePointer& compressed_chain,
|
CompressionPiecePointer& compressed_chain,
|
||||||
uint& src_data_pos, uint& comp_accumulator,
|
uint& src_data_pos, uint& comp_accumulator,
|
||||||
@@ -593,7 +593,7 @@ void CompressionCommandAlternativeV2(const uchar* rom_data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AddAlternativeCompressionCommand(
|
void AddAlternativeCompressionCommand(
|
||||||
const uchar* rom_data, CompressionPiecePointer& compressed_chain,
|
const uint8_t* rom_data, CompressionPiecePointer& compressed_chain,
|
||||||
const CompressionCommand& command, uint& source_data_position,
|
const CompressionCommand& command, uint& source_data_position,
|
||||||
uint& uncompressed_data_size, uint& best_command, uint& best_command_gain) {
|
uint& uncompressed_data_size, uint& best_command, uint& best_command_gain) {
|
||||||
std::cout << "- Identified a gain from command: " << best_command
|
std::cout << "- Identified a gain from command: " << best_command
|
||||||
@@ -642,7 +642,7 @@ void AddAlternativeCompressionCommand(
|
|||||||
absl::StatusOr<CompressionPiecePointer> SplitCompressionPiece(
|
absl::StatusOr<CompressionPiecePointer> SplitCompressionPiece(
|
||||||
CompressionPiecePointer& piece, int mode) {
|
CompressionPiecePointer& piece, int mode) {
|
||||||
CompressionPiecePointer new_piece;
|
CompressionPiecePointer new_piece;
|
||||||
uint length_left = piece->length - kMaxLengthCompression;
|
unsigned int length_left = piece->length - kMaxLengthCompression;
|
||||||
piece->length = kMaxLengthCompression;
|
piece->length = kMaxLengthCompression;
|
||||||
|
|
||||||
switch (piece->command) {
|
switch (piece->command) {
|
||||||
@@ -670,7 +670,7 @@ absl::StatusOr<CompressionPiecePointer> SplitCompressionPiece(
|
|||||||
}
|
}
|
||||||
case kCommandRepeatingBytes: {
|
case kCommandRepeatingBytes: {
|
||||||
piece->argument_length = kMaxLengthCompression;
|
piece->argument_length = kMaxLengthCompression;
|
||||||
uint offset = piece->argument[0] + (piece->argument[1] << 8);
|
unsigned int offset = piece->argument[0] + (piece->argument[1] << 8);
|
||||||
new_piece = std::make_shared<CompressionPiece>(
|
new_piece = std::make_shared<CompressionPiece>(
|
||||||
piece->command, length_left, piece->argument, piece->argument_length);
|
piece->command, length_left, piece->argument, piece->argument_length);
|
||||||
if (mode == kNintendoMode2) {
|
if (mode == kNintendoMode2) {
|
||||||
@@ -694,7 +694,7 @@ absl::StatusOr<CompressionPiecePointer> SplitCompressionPiece(
|
|||||||
|
|
||||||
std::vector<uint8_t> CreateCompressionString(CompressionPiecePointer& start,
|
std::vector<uint8_t> CreateCompressionString(CompressionPiecePointer& start,
|
||||||
int mode) {
|
int mode) {
|
||||||
uint pos = 0;
|
unsigned int pos = 0;
|
||||||
auto piece = start;
|
auto piece = start;
|
||||||
std::vector<uint8_t> output;
|
std::vector<uint8_t> output;
|
||||||
|
|
||||||
@@ -704,7 +704,8 @@ std::vector<uint8_t> CreateCompressionString(CompressionPiecePointer& start,
|
|||||||
pos++;
|
pos++;
|
||||||
} else {
|
} else {
|
||||||
if (piece->length <= kMaxLengthCompression) {
|
if (piece->length <= kMaxLengthCompression) {
|
||||||
output.push_back(kCompressionStringMod | ((uchar)piece->command << 2) |
|
output.push_back(kCompressionStringMod |
|
||||||
|
((uint8_t)piece->command << 2) |
|
||||||
(((piece->length - 1) & 0xFF00) >> 8));
|
(((piece->length - 1) & 0xFF00) >> 8));
|
||||||
pos++;
|
pos++;
|
||||||
printf("Building extended header : cmd: %d, length: %d - %02X\n",
|
printf("Building extended header : cmd: %d, length: %d - %02X\n",
|
||||||
@@ -777,7 +778,7 @@ CompressionPiecePointer MergeCopy(CompressionPiecePointer& start) {
|
|||||||
if (piece->command == kCommandDirectCopy && piece->next != nullptr &&
|
if (piece->command == kCommandDirectCopy && piece->next != nullptr &&
|
||||||
piece->next->command == kCommandDirectCopy &&
|
piece->next->command == kCommandDirectCopy &&
|
||||||
piece->length + piece->next->length <= kMaxLengthCompression) {
|
piece->length + piece->next->length <= kMaxLengthCompression) {
|
||||||
uint previous_length = piece->length;
|
unsigned int previous_length = piece->length;
|
||||||
piece->length = piece->length + piece->next->length;
|
piece->length = piece->length + piece->next->length;
|
||||||
|
|
||||||
for (int i = 0; i < piece->next->argument_length; ++i) {
|
for (int i = 0; i < piece->next->argument_length; ++i) {
|
||||||
@@ -795,7 +796,7 @@ CompressionPiecePointer MergeCopy(CompressionPiecePointer& start) {
|
|||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::StatusOr<std::vector<uint8_t>> CompressV2(const uchar* data,
|
absl::StatusOr<std::vector<uint8_t>> CompressV2(const uint8_t* data,
|
||||||
const int start,
|
const int start,
|
||||||
const int length, int mode,
|
const int length, int mode,
|
||||||
bool check) {
|
bool check) {
|
||||||
@@ -814,9 +815,9 @@ absl::StatusOr<std::vector<uint8_t>> CompressV2(const uchar* data,
|
|||||||
/*cmd_size*/ {0, 1, 2, 1, 2},
|
/*cmd_size*/ {0, 1, 2, 1, 2},
|
||||||
/*data_size*/ {0, 0, 0, 0, 0}};
|
/*data_size*/ {0, 0, 0, 0, 0}};
|
||||||
|
|
||||||
uint src_pos = start;
|
unsigned int src_pos = start;
|
||||||
uint last_pos = start + length - 1;
|
unsigned int last_pos = start + length - 1;
|
||||||
uint comp_accumulator = 0; // Used when skipping using copy
|
unsigned int comp_accumulator = 0; // Used when skipping using copy
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
current_cmd.data_size.fill({});
|
current_cmd.data_size.fill({});
|
||||||
@@ -827,8 +828,8 @@ absl::StatusOr<std::vector<uint8_t>> CompressV2(const uchar* data,
|
|||||||
CheckIncByteV2(data, src_pos, last_pos, current_cmd);
|
CheckIncByteV2(data, src_pos, last_pos, current_cmd);
|
||||||
CheckIntraCopyV2(data, src_pos, last_pos, start, current_cmd);
|
CheckIntraCopyV2(data, src_pos, last_pos, start, current_cmd);
|
||||||
|
|
||||||
uint max_win = 2;
|
unsigned int max_win = 2;
|
||||||
uint cmd_with_max = kCommandDirectCopy;
|
unsigned int cmd_with_max = kCommandDirectCopy;
|
||||||
ValidateForByteGain(current_cmd.data_size, current_cmd.cmd_size, max_win,
|
ValidateForByteGain(current_cmd.data_size, current_cmd.cmd_size, max_win,
|
||||||
cmd_with_max);
|
cmd_with_max);
|
||||||
// ValidateForByteGainV2(current_cmd, max_win, cmd_with_max);
|
// ValidateForByteGainV2(current_cmd, max_win, cmd_with_max);
|
||||||
@@ -871,13 +872,13 @@ absl::StatusOr<std::vector<uint8_t>> CompressV2(const uchar* data,
|
|||||||
return CreateCompressionString(compressed_chain_start->next, mode);
|
return CreateCompressionString(compressed_chain_start->next, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::StatusOr<std::vector<uint8_t>> CompressGraphics(const uchar* data,
|
absl::StatusOr<std::vector<uint8_t>> CompressGraphics(const uint8_t* data,
|
||||||
const int pos,
|
const int pos,
|
||||||
const int length) {
|
const int length) {
|
||||||
return CompressV2(data, pos, length, kNintendoMode2);
|
return CompressV2(data, pos, length, kNintendoMode2);
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::StatusOr<std::vector<uint8_t>> CompressOverworld(const uchar* data,
|
absl::StatusOr<std::vector<uint8_t>> CompressOverworld(const uint8_t* data,
|
||||||
const int pos,
|
const int pos,
|
||||||
const int length) {
|
const int length) {
|
||||||
return CompressV2(data, pos, length, kNintendoMode1);
|
return CompressV2(data, pos, length, kNintendoMode1);
|
||||||
@@ -889,7 +890,7 @@ absl::StatusOr<std::vector<uint8_t>> CompressOverworld(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CheckByteRepeatV3(CompressionContext& context) {
|
void CheckByteRepeatV3(CompressionContext& context) {
|
||||||
uint pos = context.src_pos;
|
unsigned int pos = context.src_pos;
|
||||||
|
|
||||||
// Ensure the sequence does not start with an uncompressable byte
|
// Ensure the sequence does not start with an uncompressable byte
|
||||||
if (pos == 0 || context.data[pos - 1] != context.data[pos]) {
|
if (pos == 0 || context.data[pos - 1] != context.data[pos]) {
|
||||||
@@ -910,7 +911,7 @@ void CheckByteRepeatV3(CompressionContext& context) {
|
|||||||
|
|
||||||
void CheckWordRepeatV3(CompressionContext& context) {
|
void CheckWordRepeatV3(CompressionContext& context) {
|
||||||
if (context.src_pos + 1 <= context.last_pos) { // Changed the condition here
|
if (context.src_pos + 1 <= context.last_pos) { // Changed the condition here
|
||||||
uint pos = context.src_pos;
|
unsigned int pos = context.src_pos;
|
||||||
char byte1 = context.data[pos];
|
char byte1 = context.data[pos];
|
||||||
char byte2 = context.data[pos + 1];
|
char byte2 = context.data[pos + 1];
|
||||||
pos += 2;
|
pos += 2;
|
||||||
@@ -935,7 +936,7 @@ void CheckWordRepeatV3(CompressionContext& context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CheckIncByteV3(CompressionContext& context) {
|
void CheckIncByteV3(CompressionContext& context) {
|
||||||
uint pos = context.src_pos;
|
unsigned int pos = context.src_pos;
|
||||||
uint8_t byte = context.data[pos];
|
uint8_t byte = context.data[pos];
|
||||||
pos++;
|
pos++;
|
||||||
context.current_cmd.data_size[kCommandIncreasingFill] = 1;
|
context.current_cmd.data_size[kCommandIncreasingFill] = 1;
|
||||||
@@ -974,8 +975,8 @@ void CheckIntraCopyV3(CompressionContext& context) {
|
|||||||
// beginning
|
// beginning
|
||||||
if (context.src_pos > 0 &&
|
if (context.src_pos > 0 &&
|
||||||
context.src_pos + window_size <= context.data.size()) {
|
context.src_pos + window_size <= context.data.size()) {
|
||||||
uint max_copied_size = 0;
|
unsigned int max_copied_size = 0;
|
||||||
uint best_search_start = 0;
|
unsigned int best_search_start = 0;
|
||||||
|
|
||||||
// Slide the window over the source data
|
// Slide the window over the source data
|
||||||
for (int win_pos = 1; win_pos < window_size && win_pos < context.src_pos;
|
for (int win_pos = 1; win_pos < window_size && win_pos < context.src_pos;
|
||||||
@@ -991,7 +992,7 @@ void CheckIntraCopyV3(CompressionContext& context) {
|
|||||||
|
|
||||||
if (found_pos != search_end) {
|
if (found_pos != search_end) {
|
||||||
// Check the entire length of the match
|
// Check the entire length of the match
|
||||||
uint len = 0;
|
unsigned int len = 0;
|
||||||
while (context.src_pos + len < context.data.size() &&
|
while (context.src_pos + len < context.data.size() &&
|
||||||
context.data[context.src_pos + len] == *(found_pos + len)) {
|
context.data[context.src_pos + len] == *(found_pos + len)) {
|
||||||
len++;
|
len++;
|
||||||
@@ -1047,8 +1048,8 @@ void DetermineBestCompression(CompressionContext& context) {
|
|||||||
// Start with the default scenario.
|
// Start with the default scenario.
|
||||||
context.cmd_with_max = kCommandDirectCopy;
|
context.cmd_with_max = kCommandDirectCopy;
|
||||||
|
|
||||||
for (uint cmd_i = 1; cmd_i < 5; cmd_i++) {
|
for (unsigned int cmd_i = 1; cmd_i < 5; cmd_i++) {
|
||||||
uint cmd_size_taken = context.current_cmd.data_size[cmd_i];
|
unsigned int cmd_size_taken = context.current_cmd.data_size[cmd_i];
|
||||||
int net_savings = cmd_size_taken - context.current_cmd.cmd_size[cmd_i];
|
int net_savings = cmd_size_taken - context.current_cmd.cmd_size[cmd_i];
|
||||||
|
|
||||||
// Skip commands that aren't efficient.
|
// Skip commands that aren't efficient.
|
||||||
@@ -1193,7 +1194,7 @@ absl::Status ValidateCompressionResultV3(const CompressionContext& context) {
|
|||||||
absl::StatusOr<CompressionPiece> SplitCompressionPieceV3(
|
absl::StatusOr<CompressionPiece> SplitCompressionPieceV3(
|
||||||
CompressionPiece& piece, int mode) {
|
CompressionPiece& piece, int mode) {
|
||||||
CompressionPiece new_piece;
|
CompressionPiece new_piece;
|
||||||
uint length_left = piece.length - kMaxLengthCompression;
|
unsigned int length_left = piece.length - kMaxLengthCompression;
|
||||||
piece.length = kMaxLengthCompression;
|
piece.length = kMaxLengthCompression;
|
||||||
|
|
||||||
switch (piece.command) {
|
switch (piece.command) {
|
||||||
@@ -1220,7 +1221,7 @@ absl::StatusOr<CompressionPiece> SplitCompressionPieceV3(
|
|||||||
}
|
}
|
||||||
case kCommandRepeatingBytes: {
|
case kCommandRepeatingBytes: {
|
||||||
piece.argument_length = kMaxLengthCompression;
|
piece.argument_length = kMaxLengthCompression;
|
||||||
uint offset = piece.argument[0] + (piece.argument[1] << 8);
|
unsigned int offset = piece.argument[0] + (piece.argument[1] << 8);
|
||||||
new_piece = CompressionPiece(piece.command, length_left, piece.argument,
|
new_piece = CompressionPiece(piece.command, length_left, piece.argument,
|
||||||
piece.argument_length);
|
piece.argument_length);
|
||||||
if (mode == kNintendoMode2) {
|
if (mode == kNintendoMode2) {
|
||||||
@@ -1242,7 +1243,7 @@ absl::StatusOr<CompressionPiece> SplitCompressionPieceV3(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FinalizeCompression(CompressionContext& context) {
|
void FinalizeCompression(CompressionContext& context) {
|
||||||
uint pos = 0;
|
unsigned int pos = 0;
|
||||||
|
|
||||||
for (CompressionPiece& piece : context.compression_pieces) {
|
for (CompressionPiece& piece : context.compression_pieces) {
|
||||||
if (piece.length <= kMaxLengthNormalHeader) { // Normal Header
|
if (piece.length <= kMaxLengthNormalHeader) { // Normal Header
|
||||||
@@ -1252,7 +1253,7 @@ void FinalizeCompression(CompressionContext& context) {
|
|||||||
} else {
|
} else {
|
||||||
if (piece.length <= kMaxLengthCompression) {
|
if (piece.length <= kMaxLengthCompression) {
|
||||||
context.compression_string.push_back(
|
context.compression_string.push_back(
|
||||||
kCompressionStringMod | ((uchar)piece.command << 2) |
|
kCompressionStringMod | ((uint8_t)piece.command << 2) |
|
||||||
(((piece.length - 1) & 0xFF00) >> 8));
|
(((piece.length - 1) & 0xFF00) >> 8));
|
||||||
pos++;
|
pos++;
|
||||||
std::cout << "Building extended header : cmd: " << piece.command
|
std::cout << "Building extended header : cmd: " << piece.command
|
||||||
@@ -1340,7 +1341,7 @@ absl::StatusOr<std::vector<uint8_t>> CompressV3(
|
|||||||
context.compressed_data.end());
|
context.compressed_data.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SetBuffer(const uchar* data, int src_pos, int comp_accumulator) {
|
std::string SetBuffer(const uint8_t* data, int src_pos, int comp_accumulator) {
|
||||||
std::string buffer;
|
std::string buffer;
|
||||||
for (int i = 0; i < comp_accumulator; ++i) {
|
for (int i = 0; i < comp_accumulator; ++i) {
|
||||||
buffer.push_back(data[i + src_pos - comp_accumulator]);
|
buffer.push_back(data[i + src_pos - comp_accumulator]);
|
||||||
@@ -1357,7 +1358,7 @@ std::string SetBuffer(const std::vector<uint8_t>& data, int src_pos,
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void memfill(const uchar* data, std::vector<uint8_t>& buffer, int buffer_pos,
|
void memfill(const uint8_t* data, std::vector<uint8_t>& buffer, int buffer_pos,
|
||||||
int offset, int length) {
|
int offset, int length) {
|
||||||
auto a = data[offset];
|
auto a = data[offset];
|
||||||
auto b = data[offset + 1];
|
auto b = data[offset + 1];
|
||||||
@@ -1367,17 +1368,18 @@ void memfill(const uchar* data, std::vector<uint8_t>& buffer, int buffer_pos,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::StatusOr<std::vector<uint8_t>> DecompressV2(const uchar* data, int offset,
|
absl::StatusOr<std::vector<uint8_t>> DecompressV2(const uint8_t* data,
|
||||||
int size, int mode) {
|
int offset, int size,
|
||||||
|
int mode) {
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
return std::vector<uint8_t>();
|
return std::vector<uint8_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> buffer(size, 0);
|
std::vector<uint8_t> buffer(size, 0);
|
||||||
uint length = 0;
|
unsigned int length = 0;
|
||||||
uint buffer_pos = 0;
|
unsigned int buffer_pos = 0;
|
||||||
uchar command = 0;
|
uint8_t command = 0;
|
||||||
uchar header = data[offset];
|
uint8_t header = data[offset];
|
||||||
|
|
||||||
while (header != kSnesByteMax) {
|
while (header != kSnesByteMax) {
|
||||||
if ((header & kExpandedMod) == kExpandedMod) {
|
if ((header & kExpandedMod) == kExpandedMod) {
|
||||||
@@ -1418,8 +1420,8 @@ absl::StatusOr<std::vector<uint8_t>> DecompressV2(const uchar* data, int offset,
|
|||||||
offset += 1; // Advance 1 byte in the ROM
|
offset += 1; // Advance 1 byte in the ROM
|
||||||
} break;
|
} break;
|
||||||
case kCommandRepeatingBytes: {
|
case kCommandRepeatingBytes: {
|
||||||
ushort s1 = ((data[offset + 1] & kSnesByteMax) << 8);
|
uint16_t s1 = ((data[offset + 1] & kSnesByteMax) << 8);
|
||||||
ushort s2 = (data[offset] & kSnesByteMax);
|
uint16_t s2 = (data[offset] & kSnesByteMax);
|
||||||
int addr = (s1 | s2);
|
int addr = (s1 | s2);
|
||||||
if (mode == kNintendoMode1) { // Reversed byte order for
|
if (mode == kNintendoMode1) { // Reversed byte order for
|
||||||
// overworld maps
|
// overworld maps
|
||||||
@@ -1454,12 +1456,12 @@ absl::StatusOr<std::vector<uint8_t>> DecompressV2(const uchar* data, int offset,
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::StatusOr<std::vector<uint8_t>> DecompressGraphics(const uchar* data,
|
absl::StatusOr<std::vector<uint8_t>> DecompressGraphics(const uint8_t* data,
|
||||||
int pos, int size) {
|
int pos, int size) {
|
||||||
return DecompressV2(data, pos, size, kNintendoMode2);
|
return DecompressV2(data, pos, size, kNintendoMode2);
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::StatusOr<std::vector<uint8_t>> DecompressOverworld(const uchar* data,
|
absl::StatusOr<std::vector<uint8_t>> DecompressOverworld(const uint8_t* data,
|
||||||
int pos, int size) {
|
int pos, int size) {
|
||||||
return DecompressV2(data, pos, size, kNintendoMode1);
|
return DecompressV2(data, pos, size, kNintendoMode1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
#ifndef YAZE_APP_GFX_COMPRESSION_H
|
#ifndef YAZE_APP_GFX_COMPRESSION_H
|
||||||
#define YAZE_APP_GFX_COMPRESSION_H
|
#define YAZE_APP_GFX_COMPRESSION_H
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
#include "app/core/constants.h"
|
#include "util/macro.h"
|
||||||
|
|
||||||
#define BUILD_HEADER(command, length) (command << 5) + (length - 1)
|
#define BUILD_HEADER(command, length) (command << 5) + (length - 1)
|
||||||
|
|
||||||
@@ -94,27 +95,27 @@ void PrintCompressionChain(const CompressionPiecePointer& chain_head);
|
|||||||
|
|
||||||
// Compression V1
|
// Compression V1
|
||||||
|
|
||||||
void CheckByteRepeat(const uchar* rom_data, DataSizeArray& data_size_taken,
|
void CheckByteRepeat(const uint8_t* rom_data, DataSizeArray& data_size_taken,
|
||||||
CommandArgumentArray& cmd_args, uint& src_data_pos,
|
CommandArgumentArray& cmd_args, uint& src_data_pos,
|
||||||
const uint last_pos);
|
const unsigned int last_pos);
|
||||||
|
|
||||||
void CheckWordRepeat(const uchar* rom_data, DataSizeArray& data_size_taken,
|
void CheckWordRepeat(const uint8_t* rom_data, DataSizeArray& data_size_taken,
|
||||||
CommandArgumentArray& cmd_args, uint& src_data_pos,
|
CommandArgumentArray& cmd_args, uint& src_data_pos,
|
||||||
const uint last_pos);
|
const unsigned int last_pos);
|
||||||
|
|
||||||
void CheckIncByte(const uchar* rom_data, DataSizeArray& data_size_taken,
|
void CheckIncByte(const uint8_t* rom_data, DataSizeArray& data_size_taken,
|
||||||
CommandArgumentArray& cmd_args, uint& src_data_pos,
|
CommandArgumentArray& cmd_args, uint& src_data_pos,
|
||||||
const uint last_pos);
|
const unsigned int last_pos);
|
||||||
|
|
||||||
void CheckIntraCopy(const uchar* rom_data, DataSizeArray& data_size_taken,
|
void CheckIntraCopy(const uint8_t* rom_data, DataSizeArray& data_size_taken,
|
||||||
CommandArgumentArray& cmd_args, uint& src_data_pos,
|
CommandArgumentArray& cmd_args, uint& src_data_pos,
|
||||||
const uint last_pos, uint start);
|
const unsigned int last_pos, unsigned int start);
|
||||||
|
|
||||||
void ValidateForByteGain(const DataSizeArray& data_size_taken,
|
void ValidateForByteGain(const DataSizeArray& data_size_taken,
|
||||||
const CommandSizeArray& cmd_size, uint& max_win,
|
const CommandSizeArray& cmd_size, uint& max_win,
|
||||||
uint& cmd_with_max);
|
uint& cmd_with_max);
|
||||||
|
|
||||||
void CompressionCommandAlternative(const uchar* rom_data,
|
void CompressionCommandAlternative(const uint8_t* rom_data,
|
||||||
CompressionPiecePointer& compressed_chain,
|
CompressionPiecePointer& compressed_chain,
|
||||||
const CommandSizeArray& cmd_size,
|
const CommandSizeArray& cmd_size,
|
||||||
const CommandArgumentArray& cmd_args,
|
const CommandArgumentArray& cmd_args,
|
||||||
@@ -123,22 +124,22 @@ void CompressionCommandAlternative(const uchar* rom_data,
|
|||||||
|
|
||||||
// Compression V2
|
// Compression V2
|
||||||
|
|
||||||
void CheckByteRepeatV2(const uchar* data, uint& src_pos, const uint last_pos,
|
void CheckByteRepeatV2(const uint8_t* data, uint& src_pos, const unsigned int last_pos,
|
||||||
CompressionCommand& cmd);
|
CompressionCommand& cmd);
|
||||||
|
|
||||||
void CheckWordRepeatV2(const uchar* data, uint& src_pos, const uint last_pos,
|
void CheckWordRepeatV2(const uint8_t* data, uint& src_pos, const unsigned int last_pos,
|
||||||
CompressionCommand& cmd);
|
CompressionCommand& cmd);
|
||||||
|
|
||||||
void CheckIncByteV2(const uchar* data, uint& src_pos, const uint last_pos,
|
void CheckIncByteV2(const uint8_t* data, uint& src_pos, const unsigned int last_pos,
|
||||||
CompressionCommand& cmd);
|
CompressionCommand& cmd);
|
||||||
|
|
||||||
void CheckIntraCopyV2(const uchar* data, uint& src_pos, const uint last_pos,
|
void CheckIntraCopyV2(const uint8_t* data, uint& src_pos, const unsigned int last_pos,
|
||||||
uint start, CompressionCommand& cmd);
|
unsigned int start, CompressionCommand& cmd);
|
||||||
|
|
||||||
void ValidateForByteGainV2(const CompressionCommand& cmd, uint& max_win,
|
void ValidateForByteGainV2(const CompressionCommand& cmd, uint& max_win,
|
||||||
uint& cmd_with_max);
|
uint& cmd_with_max);
|
||||||
|
|
||||||
void CompressionCommandAlternativeV2(const uchar* data,
|
void CompressionCommandAlternativeV2(const uint8_t* data,
|
||||||
const CompressionCommand& cmd,
|
const CompressionCommand& cmd,
|
||||||
CompressionPiecePointer& compressed_chain,
|
CompressionPiecePointer& compressed_chain,
|
||||||
uint& src_pos, uint& comp_accumulator,
|
uint& src_pos, uint& comp_accumulator,
|
||||||
@@ -148,15 +149,15 @@ void CompressionCommandAlternativeV2(const uchar* data,
|
|||||||
* @brief Compresses a buffer of data using the LC_LZ2 algorithm.
|
* @brief Compresses a buffer of data using the LC_LZ2 algorithm.
|
||||||
* \deprecated Use HyruleMagicDecompress instead.
|
* \deprecated Use HyruleMagicDecompress instead.
|
||||||
*/
|
*/
|
||||||
absl::StatusOr<std::vector<uint8_t>> CompressV2(const uchar* data,
|
absl::StatusOr<std::vector<uint8_t>> CompressV2(const uint8_t* data,
|
||||||
const int start,
|
const int start,
|
||||||
const int length, int mode = 1,
|
const int length, int mode = 1,
|
||||||
bool check = false);
|
bool check = false);
|
||||||
|
|
||||||
absl::StatusOr<std::vector<uint8_t>> CompressGraphics(const uchar* data,
|
absl::StatusOr<std::vector<uint8_t>> CompressGraphics(const uint8_t* data,
|
||||||
const int pos,
|
const int pos,
|
||||||
const int length);
|
const int length);
|
||||||
absl::StatusOr<std::vector<uint8_t>> CompressOverworld(const uchar* data,
|
absl::StatusOr<std::vector<uint8_t>> CompressOverworld(const uint8_t* data,
|
||||||
const int pos,
|
const int pos,
|
||||||
const int length);
|
const int length);
|
||||||
absl::StatusOr<std::vector<uint8_t>> CompressOverworld(
|
absl::StatusOr<std::vector<uint8_t>> CompressOverworld(
|
||||||
@@ -178,12 +179,12 @@ struct CompressionContext {
|
|||||||
std::vector<uint8_t> compressed_data;
|
std::vector<uint8_t> compressed_data;
|
||||||
std::vector<CompressionPiece> compression_pieces;
|
std::vector<CompressionPiece> compression_pieces;
|
||||||
std::vector<uint8_t> compression_string;
|
std::vector<uint8_t> compression_string;
|
||||||
uint src_pos;
|
unsigned int src_pos;
|
||||||
uint last_pos;
|
unsigned int last_pos;
|
||||||
uint start;
|
unsigned int start;
|
||||||
uint comp_accumulator = 0;
|
unsigned int comp_accumulator = 0;
|
||||||
uint cmd_with_max = kCommandDirectCopy;
|
unsigned int cmd_with_max = kCommandDirectCopy;
|
||||||
uint max_win = 0;
|
unsigned int max_win = 0;
|
||||||
CompressionCommand current_cmd = {};
|
CompressionCommand current_cmd = {};
|
||||||
int mode;
|
int mode;
|
||||||
|
|
||||||
@@ -227,8 +228,8 @@ absl::StatusOr<std::vector<uint8_t>> CompressV3(
|
|||||||
|
|
||||||
std::string SetBuffer(const std::vector<uint8_t>& data, int src_pos,
|
std::string SetBuffer(const std::vector<uint8_t>& data, int src_pos,
|
||||||
int comp_accumulator);
|
int comp_accumulator);
|
||||||
std::string SetBuffer(const uchar* data, int src_pos, int comp_accumulator);
|
std::string SetBuffer(const uint8_t* data, int src_pos, int comp_accumulator);
|
||||||
void memfill(const uchar* data, std::vector<uint8_t>& buffer, int buffer_pos,
|
void memfill(const uint8_t* data, std::vector<uint8_t>& buffer, int buffer_pos,
|
||||||
int offset, int length);
|
int offset, int length);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -236,12 +237,12 @@ void memfill(const uchar* data, std::vector<uint8_t>& buffer, int buffer_pos,
|
|||||||
* @note Works well for graphics but not overworld data. Prefer Hyrule Magic
|
* @note Works well for graphics but not overworld data. Prefer Hyrule Magic
|
||||||
* routines for overworld data.
|
* routines for overworld data.
|
||||||
*/
|
*/
|
||||||
absl::StatusOr<std::vector<uint8_t>> DecompressV2(const uchar* data, int offset,
|
absl::StatusOr<std::vector<uint8_t>> DecompressV2(const uint8_t* data,
|
||||||
int size = 0x800,
|
int offset, int size = 0x800,
|
||||||
int mode = 1);
|
int mode = 1);
|
||||||
absl::StatusOr<std::vector<uint8_t>> DecompressGraphics(const uchar* data,
|
absl::StatusOr<std::vector<uint8_t>> DecompressGraphics(const uint8_t* data,
|
||||||
int pos, int size);
|
int pos, int size);
|
||||||
absl::StatusOr<std::vector<uint8_t>> DecompressOverworld(const uchar* data,
|
absl::StatusOr<std::vector<uint8_t>> DecompressOverworld(const uint8_t* data,
|
||||||
int pos, int size);
|
int pos, int size);
|
||||||
absl::StatusOr<std::vector<uint8_t>> DecompressOverworld(
|
absl::StatusOr<std::vector<uint8_t>> DecompressOverworld(
|
||||||
const std::vector<uint8_t> data, int pos, int size);
|
const std::vector<uint8_t> data, int pos, int size);
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
@@ -90,11 +90,11 @@ absl::Status LoadScr(std::string_view filename, uint8_t input_value,
|
|||||||
i += 2) {
|
i += 2) {
|
||||||
auto b1_pos = (i - (input_value * 0x400));
|
auto b1_pos = (i - (input_value * 0x400));
|
||||||
map_data[b1_pos] = gfx::TileInfoToShort(
|
map_data[b1_pos] = gfx::TileInfoToShort(
|
||||||
gfx::GetTilesInfo((ushort)scr_data[md + (i * 2)]));
|
gfx::GetTilesInfo((uint16_t)scr_data[md + (i * 2)]));
|
||||||
|
|
||||||
auto b2_pos = (i - (input_value * 0x400) + 1);
|
auto b2_pos = (i - (input_value * 0x400) + 1);
|
||||||
map_data[b2_pos] = gfx::TileInfoToShort(
|
map_data[b2_pos] = gfx::TileInfoToShort(
|
||||||
gfx::GetTilesInfo((ushort)scr_data[md + (i * 2) + 2]));
|
gfx::GetTilesInfo((uint16_t)scr_data[md + (i * 2) + 2]));
|
||||||
}
|
}
|
||||||
// 0x900
|
// 0x900
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ absl::Status LoadScr(std::string_view filename, uint8_t input_value,
|
|||||||
|
|
||||||
for (int i = 0; i < 0x1000 - offset; i++) {
|
for (int i = 0; i < 0x1000 - offset; i++) {
|
||||||
map_data[i] = gfx::TileInfoToShort(
|
map_data[i] = gfx::TileInfoToShort(
|
||||||
gfx::GetTilesInfo((ushort)scr_data[((i + offset) * 2)]));
|
gfx::GetTilesInfo((uint16_t)scr_data[((i + offset) * 2)]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
@@ -144,9 +144,9 @@ absl::Status DrawScrWithCgx(uint8_t bpp, std::vector<uint8_t>& map_data,
|
|||||||
|
|
||||||
if (bpp != 8) {
|
if (bpp != 8) {
|
||||||
map_bitmap_data[index] =
|
map_bitmap_data[index] =
|
||||||
(uchar)((pixel & 0xFF) + t.palette_ * 16);
|
(uint8_t)((pixel & 0xFF) + t.palette_ * 16);
|
||||||
} else {
|
} else {
|
||||||
map_bitmap_data[index] = (uchar)(pixel & 0xFF);
|
map_bitmap_data[index] = (uint8_t)(pixel & 0xFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,9 @@
|
|||||||
#include "absl/container/flat_hash_map.h"
|
#include "absl/container/flat_hash_map.h"
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/gfx/snes_color.h"
|
#include "app/gfx/snes_color.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
@@ -224,8 +224,8 @@ SnesPalette::SnesPalette(char *data) {
|
|||||||
assert((sizeof(data) % 4 == 0) && (sizeof(data) <= 32));
|
assert((sizeof(data) % 4 == 0) && (sizeof(data) <= 32));
|
||||||
for (unsigned i = 0; i < sizeof(data); i += 2) {
|
for (unsigned i = 0; i < sizeof(data); i += 2) {
|
||||||
SnesColor col;
|
SnesColor col;
|
||||||
col.set_snes(static_cast<uchar>(data[i + 1]) << 8);
|
col.set_snes(static_cast<uint8_t>(data[i + 1]) << 8);
|
||||||
col.set_snes(col.snes() | static_cast<uchar>(data[i]));
|
col.set_snes(col.snes() | static_cast<uint8_t>(data[i]));
|
||||||
snes_color mColor = ConvertSnesToRgb(col.snes());
|
snes_color mColor = ConvertSnesToRgb(col.snes());
|
||||||
col.set_rgb(ImVec4(mColor.red, mColor.green, mColor.blue, 1.f));
|
col.set_rgb(ImVec4(mColor.red, mColor.green, mColor.blue, 1.f));
|
||||||
colors.push_back(col);
|
colors.push_back(col);
|
||||||
@@ -271,7 +271,7 @@ SnesPalette ReadPaletteFromRom(int offset, int num_colors, const uint8_t *rom) {
|
|||||||
std::vector<gfx::SnesColor> colors(num_colors);
|
std::vector<gfx::SnesColor> colors(num_colors);
|
||||||
|
|
||||||
while (color_offset < num_colors) {
|
while (color_offset < num_colors) {
|
||||||
short color = (ushort)((rom[offset + 1]) << 8) | rom[offset];
|
short color = (uint16_t)((rom[offset + 1]) << 8) | rom[offset];
|
||||||
snes_color new_color;
|
snes_color new_color;
|
||||||
new_color.red = (color & 0x1F) * 8;
|
new_color.red = (color & 0x1F) * 8;
|
||||||
new_color.green = ((color >> 5) & 0x1F) * 8;
|
new_color.green = ((color >> 5) & 0x1F) * 8;
|
||||||
|
|||||||
@@ -9,10 +9,10 @@
|
|||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/gfx/snes_color.h"
|
#include "app/gfx/snes_color.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
#include "snes_color.h"
|
#include "snes_color.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
|
|||||||
@@ -5,22 +5,22 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "app/core/constants.h"
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
|
|
||||||
// Bit set for object priority
|
// Bit set for object priority
|
||||||
constexpr ushort TilePriorityBit = 0x2000;
|
constexpr uint16_t TilePriorityBit = 0x2000;
|
||||||
|
|
||||||
// Bit set for object hflip
|
// Bit set for object hflip
|
||||||
constexpr ushort TileHFlipBit = 0x4000;
|
constexpr uint16_t TileHFlipBit = 0x4000;
|
||||||
|
|
||||||
// Bit set for object vflip
|
// Bit set for object vflip
|
||||||
constexpr ushort TileVFlipBit = 0x8000;
|
constexpr uint16_t TileVFlipBit = 0x8000;
|
||||||
|
|
||||||
// Bits used for tile name
|
// Bits used for tile name
|
||||||
constexpr ushort TileNameMask = 0x03FF;
|
constexpr uint16_t TileNameMask = 0x03FF;
|
||||||
|
|
||||||
snes_tile8 UnpackBppTile(const std::vector<uint8_t>& data,
|
snes_tile8 UnpackBppTile(const std::vector<uint8_t>& data,
|
||||||
const uint32_t offset, const uint32_t bpp) {
|
const uint32_t offset, const uint32_t bpp) {
|
||||||
|
|||||||
@@ -16,19 +16,19 @@
|
|||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
#include "absl/strings/str_cat.h"
|
#include "absl/strings/str_cat.h"
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/core/platform/renderer.h"
|
#include "app/core/platform/renderer.h"
|
||||||
#include "app/gfx/compression.h"
|
#include "app/gfx/compression.h"
|
||||||
#include "app/gfx/snes_color.h"
|
#include "app/gfx/snes_color.h"
|
||||||
#include "app/gfx/snes_palette.h"
|
#include "app/gfx/snes_palette.h"
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
using core::Renderer;
|
using core::Renderer;
|
||||||
constexpr int Uncompressed3BPPSize = 0x0600;
|
constexpr int Uncompressed3BPPSize = 0x0600;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
int GetGraphicsAddress(const uchar *data, uint8_t addr, uint32_t ptr1,
|
int GetGraphicsAddress(const uint8_t *data, uint8_t addr, uint32_t ptr1,
|
||||||
uint32_t ptr2, uint32_t ptr3) {
|
uint32_t ptr2, uint32_t ptr3) {
|
||||||
return core::SnesToPc(core::AddressFromBytes(
|
return core::SnesToPc(core::AddressFromBytes(
|
||||||
data[ptr1 + addr], data[ptr2 + addr], data[ptr3 + addr]));
|
data[ptr1 + addr], data[ptr2 + addr], data[ptr3 + addr]));
|
||||||
@@ -373,8 +373,8 @@ absl::Status Rom::LoadZelda3() {
|
|||||||
constexpr size_t kBaseRomSize = 1048576; // 1MB
|
constexpr size_t kBaseRomSize = 1048576; // 1MB
|
||||||
constexpr size_t kHeaderSize = 0x200; // 512 bytes
|
constexpr size_t kHeaderSize = 0x200; // 512 bytes
|
||||||
if (size_ % kBaseRomSize == kHeaderSize) {
|
if (size_ % kBaseRomSize == kHeaderSize) {
|
||||||
auto header =
|
auto header = std::vector<uint8_t>(rom_data_.begin(),
|
||||||
std::vector<uchar>(rom_data_.begin(), rom_data_.begin() + kHeaderSize);
|
rom_data_.begin() + kHeaderSize);
|
||||||
rom_data_.erase(rom_data_.begin(), rom_data_.begin() + kHeaderSize);
|
rom_data_.erase(rom_data_.begin(), rom_data_.begin() + kHeaderSize);
|
||||||
size_ -= 0x200;
|
size_ -= 0x200;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,11 +20,11 @@
|
|||||||
#include "absl/strings/str_format.h"
|
#include "absl/strings/str_format.h"
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
#include "app/core/common.h"
|
#include "app/core/common.h"
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/core/project.h"
|
#include "app/core/project.h"
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/gfx/snes_palette.h"
|
#include "app/gfx/snes_palette.h"
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ class Rom {
|
|||||||
*/
|
*/
|
||||||
absl::Status LoadFromFile(const std::string& filename, bool z3_load = true);
|
absl::Status LoadFromFile(const std::string& filename, bool z3_load = true);
|
||||||
absl::Status LoadFromData(const std::vector<uint8_t>& data,
|
absl::Status LoadFromData(const std::vector<uint8_t>& data,
|
||||||
bool z3_load = true);
|
bool z3_load = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Saves the Rom data to a file
|
* @brief Saves the Rom data to a file
|
||||||
|
|||||||
@@ -6,11 +6,11 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/strings/str_cat.h"
|
#include "absl/strings/str_cat.h"
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
#include "app/zelda3/dungeon/room_object.h"
|
#include "app/zelda3/dungeon/room_object.h"
|
||||||
#include "app/zelda3/dungeon/room_tag.h"
|
#include "app/zelda3/dungeon/room_tag.h"
|
||||||
#include "app/zelda3/sprite/sprite.h"
|
#include "app/zelda3/sprite/sprite.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace zelda3 {
|
namespace zelda3 {
|
||||||
@@ -27,8 +27,7 @@ void Room::LoadHeader() {
|
|||||||
|
|
||||||
auto header_location = core::SnesToPc(address);
|
auto header_location = core::SnesToPc(address);
|
||||||
|
|
||||||
bg2_ = (background2)((rom()->data()[header_location] >> 5) &
|
bg2_ = (background2)((rom()->data()[header_location] >> 5) & 0x07);
|
||||||
0x07);
|
|
||||||
collision_ = (CollisionKey)((rom()->data()[header_location] >> 2) & 0x07);
|
collision_ = (CollisionKey)((rom()->data()[header_location] >> 2) & 0x07);
|
||||||
is_light_ = ((rom()->data()[header_location]) & 0x01) == 1;
|
is_light_ = ((rom()->data()[header_location]) & 0x01) == 1;
|
||||||
|
|
||||||
@@ -163,12 +162,12 @@ void Room::LoadRoomFromROM() {
|
|||||||
|
|
||||||
b = rom_data[hpos];
|
b = rom_data[hpos];
|
||||||
|
|
||||||
pits_.target_layer = (uchar)(b & 0x03);
|
pits_.target_layer = (uint8_t)(b & 0x03);
|
||||||
stair1_.target_layer = (uchar)((b >> 2) & 0x03);
|
stair1_.target_layer = (uint8_t)((b >> 2) & 0x03);
|
||||||
stair2_.target_layer = (uchar)((b >> 4) & 0x03);
|
stair2_.target_layer = (uint8_t)((b >> 4) & 0x03);
|
||||||
stair3_.target_layer = (uchar)((b >> 6) & 0x03);
|
stair3_.target_layer = (uint8_t)((b >> 6) & 0x03);
|
||||||
hpos++;
|
hpos++;
|
||||||
stair4_.target_layer = (uchar)(rom_data[hpos] & 0x03);
|
stair4_.target_layer = (uint8_t)(rom_data[hpos] & 0x03);
|
||||||
hpos++;
|
hpos++;
|
||||||
|
|
||||||
pits_.target = rom_data[hpos];
|
pits_.target = rom_data[hpos];
|
||||||
@@ -193,7 +192,7 @@ void Room::LoadRoomFromROM() {
|
|||||||
// core::SnesToPc(dungeon_spr_ptrs | spr_ptr + (room_id_ * 2));
|
// core::SnesToPc(dungeon_spr_ptrs | spr_ptr + (room_id_ * 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::LoadRoomGraphics(uchar entrance_blockset) {
|
void Room::LoadRoomGraphics(uint8_t entrance_blockset) {
|
||||||
const auto &main_gfx = rom()->main_blockset_ids;
|
const auto &main_gfx = rom()->main_blockset_ids;
|
||||||
const auto &room_gfx = rom()->room_blockset_ids;
|
const auto &room_gfx = rom()->room_blockset_ids;
|
||||||
const auto &sprite_gfx = rom()->spriteset_ids;
|
const auto &sprite_gfx = rom()->spriteset_ids;
|
||||||
@@ -216,7 +215,7 @@ void Room::LoadRoomGraphics(uchar entrance_blockset) {
|
|||||||
blocks_[10] = 115 + 6;
|
blocks_[10] = 115 + 6;
|
||||||
blocks_[11] = 115 + 7;
|
blocks_[11] = 115 + 7;
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
blocks_[12 + i] = (uchar)(sprite_gfx[spriteset + 64][i] + 115);
|
blocks_[12 + i] = (uint8_t)(sprite_gfx[spriteset + 64][i] + 115);
|
||||||
} // 12-16 sprites
|
} // 12-16 sprites
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,7 +237,7 @@ void Room::CopyRoomGraphicsToBuffer() {
|
|||||||
int data = 0;
|
int data = 0;
|
||||||
int block_offset = blocks_[i] * kGfxBufferRoomOffset;
|
int block_offset = blocks_[i] * kGfxBufferRoomOffset;
|
||||||
while (data < kGfxBufferRoomOffset) {
|
while (data < kGfxBufferRoomOffset) {
|
||||||
uchar map_byte = gfx_buffer_data[data + block_offset];
|
uint8_t map_byte = gfx_buffer_data[data + block_offset];
|
||||||
if (i < 4) {
|
if (i < 4) {
|
||||||
map_byte += kGfxBufferRoomSpriteLastLineOffset;
|
map_byte += kGfxBufferRoomSpriteLastLineOffset;
|
||||||
}
|
}
|
||||||
@@ -260,7 +259,7 @@ void Room::LoadAnimatedGraphics() {
|
|||||||
auto rom_data = rom()->vector();
|
auto rom_data = rom()->vector();
|
||||||
int data = 0;
|
int data = 0;
|
||||||
while (data < 512) {
|
while (data < 512) {
|
||||||
uchar map_byte =
|
uint8_t map_byte =
|
||||||
gfx_buffer_data[data + (92 * 2048) + (512 * animated_frame_)];
|
gfx_buffer_data[data + (92 * 2048) + (512 * animated_frame_)];
|
||||||
current_gfx16_[data + (7 * 2048)] = map_byte;
|
current_gfx16_[data + (7 * 2048)] = map_byte;
|
||||||
|
|
||||||
@@ -382,8 +381,7 @@ void Room::LoadObjects() {
|
|||||||
} else {
|
} else {
|
||||||
tile_objects_.back().set_options(ObjectOption::Stairs |
|
tile_objects_.back().set_options(ObjectOption::Stairs |
|
||||||
tile_objects_.back().options());
|
tile_objects_.back().options());
|
||||||
z3_staircases_.push_back(
|
z3_staircases_.push_back(staircase(posX, posY, "To ???"));
|
||||||
staircase(posX, posY, "To ???"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -393,7 +391,7 @@ void Room::LoadObjects() {
|
|||||||
tile_objects_.back().set_options(ObjectOption::Chest |
|
tile_objects_.back().set_options(ObjectOption::Chest |
|
||||||
tile_objects_.back().options());
|
tile_objects_.back().options());
|
||||||
// chest_list_.push_back(
|
// chest_list_.push_back(
|
||||||
// z3_chest(posX, posY, chests_in_room_.front().itemIn, false));
|
// z3_chest(posX, posY, chests_in_room_.front().itemIn, false));
|
||||||
chests_in_room_.erase(chests_in_room_.begin());
|
chests_in_room_.erase(chests_in_room_.begin());
|
||||||
}
|
}
|
||||||
} else if (oid == 0xFB1) {
|
} else if (oid == 0xFB1) {
|
||||||
@@ -401,12 +399,14 @@ void Room::LoadObjects() {
|
|||||||
tile_objects_.back().set_options(ObjectOption::Chest |
|
tile_objects_.back().set_options(ObjectOption::Chest |
|
||||||
tile_objects_.back().options());
|
tile_objects_.back().options());
|
||||||
// chest_list_.push_back(
|
// chest_list_.push_back(
|
||||||
// z3_chest(posX + 1, posY, chests_in_room_.front().item_in, true));
|
// z3_chest(posX + 1, posY, chests_in_room_.front().item_in,
|
||||||
|
// true));
|
||||||
chests_in_room_.erase(chests_in_room_.begin());
|
chests_in_room_.erase(chests_in_room_.begin());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// tile_objects_.push_back(z3_object_door(static_cast<short>((b2 << 8) + b1),
|
// tile_objects_.push_back(z3_object_door(static_cast<short>((b2 << 8) +
|
||||||
|
// b1),
|
||||||
// 0, 0, 0,
|
// 0, 0, 0,
|
||||||
// static_cast<uint8_t>(layer)));
|
// static_cast<uint8_t>(layer)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,12 @@
|
|||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
#include "app/zelda3/dungeon/room_object.h"
|
#include "app/zelda3/dungeon/room_object.h"
|
||||||
#include "app/zelda3/dungeon/room_tag.h"
|
#include "app/zelda3/dungeon/room_tag.h"
|
||||||
#include "app/zelda3/sprite/sprite.h"
|
#include "app/zelda3/sprite/sprite.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace zelda3 {
|
namespace zelda3 {
|
||||||
@@ -79,7 +79,7 @@ constexpr int dungeon_spr_ptrs = 0x090000;
|
|||||||
|
|
||||||
constexpr int NumberOfRooms = 296;
|
constexpr int NumberOfRooms = 296;
|
||||||
|
|
||||||
constexpr ushort stairsObjects[] = {0x139, 0x138, 0x13B, 0x12E, 0x12D};
|
constexpr uint16_t stairsObjects[] = {0x139, 0x138, 0x13B, 0x12E, 0x12D};
|
||||||
|
|
||||||
struct LayerMergeType {
|
struct LayerMergeType {
|
||||||
uint8_t ID;
|
uint8_t ID;
|
||||||
@@ -121,7 +121,7 @@ class Room : public SharedRom {
|
|||||||
void CalculateRoomSize();
|
void CalculateRoomSize();
|
||||||
void LoadRoomFromROM();
|
void LoadRoomFromROM();
|
||||||
|
|
||||||
void LoadRoomGraphics(uchar entrance_blockset = 0xFF);
|
void LoadRoomGraphics(uint8_t entrance_blockset = 0xFF);
|
||||||
void CopyRoomGraphicsToBuffer();
|
void CopyRoomGraphicsToBuffer();
|
||||||
void LoadAnimatedGraphics();
|
void LoadAnimatedGraphics();
|
||||||
|
|
||||||
|
|||||||
@@ -104,22 +104,22 @@ class RoomEntrance {
|
|||||||
room_ =
|
room_ =
|
||||||
static_cast<short>((rom[kEntranceRoom + (entrance_id * 2) + 1] << 8) +
|
static_cast<short>((rom[kEntranceRoom + (entrance_id * 2) + 1] << 8) +
|
||||||
rom[kEntranceRoom + (entrance_id * 2)]);
|
rom[kEntranceRoom + (entrance_id * 2)]);
|
||||||
y_position_ = static_cast<ushort>(
|
y_position_ = static_cast<uint16_t>(
|
||||||
(rom[kEntranceYPosition + (entrance_id * 2) + 1] << 8) +
|
(rom[kEntranceYPosition + (entrance_id * 2) + 1] << 8) +
|
||||||
rom[kEntranceYPosition + (entrance_id * 2)]);
|
rom[kEntranceYPosition + (entrance_id * 2)]);
|
||||||
x_position_ = static_cast<ushort>(
|
x_position_ = static_cast<uint16_t>(
|
||||||
(rom[kEntranceXPosition + (entrance_id * 2) + 1] << 8) +
|
(rom[kEntranceXPosition + (entrance_id * 2) + 1] << 8) +
|
||||||
rom[kEntranceXPosition + (entrance_id * 2)]);
|
rom[kEntranceXPosition + (entrance_id * 2)]);
|
||||||
camera_x_ = static_cast<ushort>(
|
camera_x_ = static_cast<uint16_t>(
|
||||||
(rom[kEntranceXScroll + (entrance_id * 2) + 1] << 8) +
|
(rom[kEntranceXScroll + (entrance_id * 2) + 1] << 8) +
|
||||||
rom[kEntranceXScroll + (entrance_id * 2)]);
|
rom[kEntranceXScroll + (entrance_id * 2)]);
|
||||||
camera_y_ = static_cast<ushort>(
|
camera_y_ = static_cast<uint16_t>(
|
||||||
(rom[kEntranceYScroll + (entrance_id * 2) + 1] << 8) +
|
(rom[kEntranceYScroll + (entrance_id * 2) + 1] << 8) +
|
||||||
rom[kEntranceYScroll + (entrance_id * 2)]);
|
rom[kEntranceYScroll + (entrance_id * 2)]);
|
||||||
camera_trigger_y_ = static_cast<ushort>(
|
camera_trigger_y_ = static_cast<uint16_t>(
|
||||||
(rom[(kEntranceCameraYTrigger + (entrance_id * 2)) + 1] << 8) +
|
(rom[(kEntranceCameraYTrigger + (entrance_id * 2)) + 1] << 8) +
|
||||||
rom[kEntranceCameraYTrigger + (entrance_id * 2)]);
|
rom[kEntranceCameraYTrigger + (entrance_id * 2)]);
|
||||||
camera_trigger_x_ = static_cast<ushort>(
|
camera_trigger_x_ = static_cast<uint16_t>(
|
||||||
(rom[(kEntranceCameraXTrigger + (entrance_id * 2)) + 1] << 8) +
|
(rom[(kEntranceCameraXTrigger + (entrance_id * 2)) + 1] << 8) +
|
||||||
rom[kEntranceCameraXTrigger + (entrance_id * 2)]);
|
rom[kEntranceCameraXTrigger + (entrance_id * 2)]);
|
||||||
blockset_ = rom[kEntranceBlockset + entrance_id];
|
blockset_ = rom[kEntranceBlockset + entrance_id];
|
||||||
@@ -148,27 +148,27 @@ class RoomEntrance {
|
|||||||
(rom[kStartingEntranceroom + (entrance_id * 2) + 1] << 8) +
|
(rom[kStartingEntranceroom + (entrance_id * 2) + 1] << 8) +
|
||||||
rom[kStartingEntranceroom + (entrance_id * 2)]);
|
rom[kStartingEntranceroom + (entrance_id * 2)]);
|
||||||
|
|
||||||
y_position_ = static_cast<ushort>(
|
y_position_ = static_cast<uint16_t>(
|
||||||
(rom[kStartingEntranceYPosition + (entrance_id * 2) + 1] << 8) +
|
(rom[kStartingEntranceYPosition + (entrance_id * 2) + 1] << 8) +
|
||||||
rom[kStartingEntranceYPosition + (entrance_id * 2)]);
|
rom[kStartingEntranceYPosition + (entrance_id * 2)]);
|
||||||
|
|
||||||
x_position_ = static_cast<ushort>(
|
x_position_ = static_cast<uint16_t>(
|
||||||
(rom[kStartingEntranceXPosition + (entrance_id * 2) + 1] << 8) +
|
(rom[kStartingEntranceXPosition + (entrance_id * 2) + 1] << 8) +
|
||||||
rom[kStartingEntranceXPosition + (entrance_id * 2)]);
|
rom[kStartingEntranceXPosition + (entrance_id * 2)]);
|
||||||
|
|
||||||
camera_x_ = static_cast<ushort>(
|
camera_x_ = static_cast<uint16_t>(
|
||||||
(rom[kStartingEntranceXScroll + (entrance_id * 2) + 1] << 8) +
|
(rom[kStartingEntranceXScroll + (entrance_id * 2) + 1] << 8) +
|
||||||
rom[kStartingEntranceXScroll + (entrance_id * 2)]);
|
rom[kStartingEntranceXScroll + (entrance_id * 2)]);
|
||||||
|
|
||||||
camera_y_ = static_cast<ushort>(
|
camera_y_ = static_cast<uint16_t>(
|
||||||
(rom[kStartingEntranceYScroll + (entrance_id * 2) + 1] << 8) +
|
(rom[kStartingEntranceYScroll + (entrance_id * 2) + 1] << 8) +
|
||||||
rom[kStartingEntranceYScroll + (entrance_id * 2)]);
|
rom[kStartingEntranceYScroll + (entrance_id * 2)]);
|
||||||
|
|
||||||
camera_trigger_y_ = static_cast<ushort>(
|
camera_trigger_y_ = static_cast<uint16_t>(
|
||||||
(rom[kStartingEntranceCameraYTrigger + (entrance_id * 2) + 1] << 8) +
|
(rom[kStartingEntranceCameraYTrigger + (entrance_id * 2) + 1] << 8) +
|
||||||
rom[kStartingEntranceCameraYTrigger + (entrance_id * 2)]);
|
rom[kStartingEntranceCameraYTrigger + (entrance_id * 2)]);
|
||||||
|
|
||||||
camera_trigger_x_ = static_cast<ushort>(
|
camera_trigger_x_ = static_cast<uint16_t>(
|
||||||
(rom[kStartingEntranceCameraXTrigger + (entrance_id * 2) + 1] << 8) +
|
(rom[kStartingEntranceCameraXTrigger + (entrance_id * 2) + 1] << 8) +
|
||||||
rom[kStartingEntranceCameraXTrigger + (entrance_id * 2)]);
|
rom[kStartingEntranceCameraXTrigger + (entrance_id * 2)]);
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ void RoomObject::DrawTile(gfx::Tile16 t, int xx, int yy,
|
|||||||
std::vector<uint8_t>& current_gfx16,
|
std::vector<uint8_t>& current_gfx16,
|
||||||
std::vector<uint8_t>& tiles_bg1_buffer,
|
std::vector<uint8_t>& tiles_bg1_buffer,
|
||||||
std::vector<uint8_t>& tiles_bg2_buffer,
|
std::vector<uint8_t>& tiles_bg2_buffer,
|
||||||
ushort tileUnder) {
|
uint16_t tileUnder) {
|
||||||
bool preview = false;
|
bool preview = false;
|
||||||
if (width_ < xx + 8) {
|
if (width_ < xx + 8) {
|
||||||
width_ = xx + 8;
|
width_ = xx + 8;
|
||||||
@@ -99,7 +99,7 @@ void RoomObject::DrawTile(gfx::Tile16 t, int xx, int yy,
|
|||||||
0x1000 &&
|
0x1000 &&
|
||||||
((xx / 8) + nx_ + offset_x_) + ((ny_ + offset_y_ + (yy / 8)) * 0x40) >=
|
((xx / 8) + nx_ + offset_x_) + ((ny_ + offset_y_ + (yy / 8)) * 0x40) >=
|
||||||
0) {
|
0) {
|
||||||
ushort td = 0; // gfx::GetTilesInfo();
|
uint16_t td = 0; // gfx::GetTilesInfo();
|
||||||
|
|
||||||
// collisionPoint.Add(
|
// collisionPoint.Add(
|
||||||
// new Point(xx + ((nx + offsetX) * 8), yy + ((ny + +offsetY) * 8)));
|
// new Point(xx + ((nx + offsetX) * 8), yy + ((ny + +offsetY) * 8)));
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class RoomObject : public SharedRom {
|
|||||||
std::vector<uint8_t>& current_gfx16,
|
std::vector<uint8_t>& current_gfx16,
|
||||||
std::vector<uint8_t>& tiles_bg1_buffer,
|
std::vector<uint8_t>& tiles_bg1_buffer,
|
||||||
std::vector<uint8_t>& tiles_bg2_buffer,
|
std::vector<uint8_t>& tiles_bg2_buffer,
|
||||||
ushort tile_under = 0xFFFF);
|
uint16_t tile_under = 0xFFFF);
|
||||||
|
|
||||||
auto options() const { return options_; }
|
auto options() const { return options_; }
|
||||||
void set_options(ObjectOption options) { options_ = options; }
|
void set_options(ObjectOption options) { options_ = options; }
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace zelda3 {
|
namespace zelda3 {
|
||||||
@@ -43,8 +43,8 @@ SongSpcBlock *Tracker::AllocSpcBlock(int len, int bank) {
|
|||||||
ss_num++;
|
ss_num++;
|
||||||
sbl->start = ss_next;
|
sbl->start = ss_next;
|
||||||
sbl->len = len;
|
sbl->len = len;
|
||||||
sbl->buf = (uchar *)malloc(len);
|
sbl->buf = (uint8_t *)malloc(len);
|
||||||
sbl->relocs = (ushort *)malloc(32);
|
sbl->relocs = (uint16_t *)malloc(32);
|
||||||
sbl->relsz = 16;
|
sbl->relsz = 16;
|
||||||
sbl->relnum = 0;
|
sbl->relnum = 0;
|
||||||
sbl->bank = bank & 7;
|
sbl->bank = bank & 7;
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace zelda3 {
|
namespace zelda3 {
|
||||||
@@ -61,8 +61,8 @@ struct SongRange {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct SongPart {
|
struct SongPart {
|
||||||
uchar flag;
|
uint8_t flag;
|
||||||
uchar inst;
|
uint8_t inst;
|
||||||
short tbl[8];
|
short tbl[8];
|
||||||
unsigned short addr;
|
unsigned short addr;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/gfx/compression.h"
|
#include "app/gfx/compression.h"
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace zelda3 {
|
namespace zelda3 {
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
#include "app/zelda3/common.h"
|
#include "app/zelda3/common.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace zelda3 {
|
namespace zelda3 {
|
||||||
@@ -49,14 +49,14 @@ constexpr int kOverworldHoleEntrance = 0xDB84C;
|
|||||||
class OverworldEntrance : public GameEntity {
|
class OverworldEntrance : public GameEntity {
|
||||||
public:
|
public:
|
||||||
uint16_t map_pos_;
|
uint16_t map_pos_;
|
||||||
uchar entrance_id_;
|
uint8_t entrance_id_;
|
||||||
uchar area_x_;
|
uint8_t area_x_;
|
||||||
uchar area_y_;
|
uint8_t area_y_;
|
||||||
bool is_hole_ = false;
|
bool is_hole_ = false;
|
||||||
bool deleted = false;
|
bool deleted = false;
|
||||||
|
|
||||||
OverworldEntrance() = default;
|
OverworldEntrance() = default;
|
||||||
OverworldEntrance(int x, int y, uchar entrance_id, short map_id,
|
OverworldEntrance(int x, int y, uint8_t entrance_id, short map_id,
|
||||||
uint16_t map_pos, bool hole)
|
uint16_t map_pos, bool hole)
|
||||||
: map_pos_(map_pos), entrance_id_(entrance_id), is_hole_(hole) {
|
: map_pos_(map_pos), entrance_id_(entrance_id), is_hole_(hole) {
|
||||||
x_ = x;
|
x_ = x;
|
||||||
@@ -67,8 +67,8 @@ class OverworldEntrance : public GameEntity {
|
|||||||
|
|
||||||
int mapX = (map_id_ - ((map_id_ / 8) * 8));
|
int mapX = (map_id_ - ((map_id_ / 8) * 8));
|
||||||
int mapY = (map_id_ / 8);
|
int mapY = (map_id_ / 8);
|
||||||
area_x_ = (uchar)((std::abs(x - (mapX * 512)) / 16));
|
area_x_ = (uint8_t)((std::abs(x - (mapX * 512)) / 16));
|
||||||
area_y_ = (uchar)((std::abs(y - (mapY * 512)) / 16));
|
area_y_ = (uint8_t)((std::abs(y - (mapY * 512)) / 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateMapProperties(uint16_t map_id) override {
|
void UpdateMapProperties(uint16_t map_id) override {
|
||||||
@@ -81,8 +81,8 @@ class OverworldEntrance : public GameEntity {
|
|||||||
int mapX = (map_id_ - ((map_id_ / 8) * 8));
|
int mapX = (map_id_ - ((map_id_ / 8) * 8));
|
||||||
int mapY = (map_id_ / 8);
|
int mapY = (map_id_ / 8);
|
||||||
|
|
||||||
area_x_ = (uchar)((std::abs(x_ - (mapX * 512)) / 16));
|
area_x_ = (uint8_t)((std::abs(x_ - (mapX * 512)) / 16));
|
||||||
area_y_ = (uchar)((std::abs(y_ - (mapY * 512)) / 16));
|
area_y_ = (uint8_t)((std::abs(y_ - (mapY * 512)) / 16));
|
||||||
|
|
||||||
map_pos_ = (uint16_t)((((area_y_) << 6) | (area_x_ & 0x3F)) << 1);
|
map_pos_ = (uint16_t)((((area_y_) << 6) | (area_x_ & 0x3F)) << 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/zelda3/common.h"
|
#include "app/zelda3/common.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace zelda3 {
|
namespace zelda3 {
|
||||||
@@ -44,30 +44,31 @@ class OverworldExit : public GameEntity {
|
|||||||
public:
|
public:
|
||||||
uint16_t y_scroll_;
|
uint16_t y_scroll_;
|
||||||
uint16_t x_scroll_;
|
uint16_t x_scroll_;
|
||||||
uchar y_player_;
|
uint8_t y_player_;
|
||||||
uchar x_player_;
|
uint8_t x_player_;
|
||||||
uchar y_camera_;
|
uint8_t y_camera_;
|
||||||
uchar x_camera_;
|
uint8_t x_camera_;
|
||||||
uchar scroll_mod_y_;
|
uint8_t scroll_mod_y_;
|
||||||
uchar scroll_mod_x_;
|
uint8_t scroll_mod_x_;
|
||||||
uint16_t door_type_1_;
|
uint16_t door_type_1_;
|
||||||
uint16_t door_type_2_;
|
uint16_t door_type_2_;
|
||||||
uint16_t room_id_;
|
uint16_t room_id_;
|
||||||
uint16_t map_pos_; // Position in the vram
|
uint16_t map_pos_; // Position in the vram
|
||||||
uchar entrance_id_;
|
uint8_t entrance_id_;
|
||||||
uchar area_x_;
|
uint8_t area_x_;
|
||||||
uchar area_y_;
|
uint8_t area_y_;
|
||||||
bool is_hole_ = false;
|
bool is_hole_ = false;
|
||||||
bool deleted_ = false;
|
bool deleted_ = false;
|
||||||
bool is_automatic_ = false;
|
bool is_automatic_ = false;
|
||||||
bool large_map_ = false;
|
bool large_map_ = false;
|
||||||
|
|
||||||
OverworldExit() = default;
|
OverworldExit() = default;
|
||||||
OverworldExit(uint16_t room_id, uchar map_id, uint16_t vram_location,
|
OverworldExit(uint16_t room_id, uint8_t map_id, uint16_t vram_location,
|
||||||
uint16_t y_scroll, uint16_t x_scroll, uint16_t player_y,
|
uint16_t y_scroll, uint16_t x_scroll, uint16_t player_y,
|
||||||
uint16_t player_x, uint16_t camera_y, uint16_t camera_x,
|
uint16_t player_x, uint16_t camera_y, uint16_t camera_x,
|
||||||
uchar scroll_mod_y, uchar scroll_mod_x, uint16_t door_type_1,
|
uint8_t scroll_mod_y, uint8_t scroll_mod_x,
|
||||||
uint16_t door_type_2, bool deleted = false)
|
uint16_t door_type_1, uint16_t door_type_2,
|
||||||
|
bool deleted = false)
|
||||||
: map_pos_(vram_location),
|
: map_pos_(vram_location),
|
||||||
entrance_id_(0),
|
entrance_id_(0),
|
||||||
area_x_(0),
|
area_x_(0),
|
||||||
@@ -94,19 +95,19 @@ class OverworldExit : public GameEntity {
|
|||||||
int mapX = (map_id_ - ((map_id_ / 8) * 8));
|
int mapX = (map_id_ - ((map_id_ / 8) * 8));
|
||||||
int mapY = (map_id_ / 8);
|
int mapY = (map_id_ / 8);
|
||||||
|
|
||||||
area_x_ = (uchar)((std::abs(x_ - (mapX * 512)) / 16));
|
area_x_ = (uint8_t)((std::abs(x_ - (mapX * 512)) / 16));
|
||||||
area_y_ = (uchar)((std::abs(y_ - (mapY * 512)) / 16));
|
area_y_ = (uint8_t)((std::abs(y_ - (mapY * 512)) / 16));
|
||||||
|
|
||||||
if (door_type_1 != 0) {
|
if (door_type_1 != 0) {
|
||||||
int p = (door_type_1 & 0x7FFF) >> 1;
|
int p = (door_type_1 & 0x7FFF) >> 1;
|
||||||
entrance_id_ = (uchar)(p % 64);
|
entrance_id_ = (uint8_t)(p % 64);
|
||||||
area_y_ = (uchar)(p >> 6);
|
area_y_ = (uint8_t)(p >> 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (door_type_2 != 0) {
|
if (door_type_2 != 0) {
|
||||||
int p = (door_type_2 & 0x7FFF) >> 1;
|
int p = (door_type_2 & 0x7FFF) >> 1;
|
||||||
entrance_id_ = (uchar)(p % 64);
|
entrance_id_ = (uint8_t)(p % 64);
|
||||||
area_y_ = (uchar)(p >> 6);
|
area_y_ = (uint8_t)(p >> 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map_id_ >= 64) {
|
if (map_id_ >= 64) {
|
||||||
@@ -116,8 +117,8 @@ class OverworldExit : public GameEntity {
|
|||||||
mapX = (map_id_ - ((map_id_ / 8) * 8));
|
mapX = (map_id_ - ((map_id_ / 8) * 8));
|
||||||
mapY = (map_id_ / 8);
|
mapY = (map_id_ / 8);
|
||||||
|
|
||||||
area_x_ = (uchar)((std::abs(x_ - (mapX * 512)) / 16));
|
area_x_ = (uint8_t)((std::abs(x_ - (mapX * 512)) / 16));
|
||||||
area_y_ = (uchar)((std::abs(y_ - (mapY * 512)) / 16));
|
area_y_ = (uint8_t)((std::abs(y_ - (mapY * 512)) / 16));
|
||||||
|
|
||||||
map_pos_ = (uint16_t)((((area_y_) << 6) | (area_x_ & 0x3F)) << 1);
|
map_pos_ = (uint16_t)((((area_y_) << 6) | (area_x_ & 0x3F)) << 1);
|
||||||
}
|
}
|
||||||
@@ -139,8 +140,8 @@ class OverworldExit : public GameEntity {
|
|||||||
int mapX = map_id - ((map_id / 8) * 8);
|
int mapX = map_id - ((map_id / 8) * 8);
|
||||||
int mapY = map_id / 8;
|
int mapY = map_id / 8;
|
||||||
|
|
||||||
area_x_ = (uchar)((std::abs(x_ - (mapX * 512)) / 16));
|
area_x_ = (uint8_t)((std::abs(x_ - (mapX * 512)) / 16));
|
||||||
area_y_ = (uchar)((std::abs(y_ - (mapY * 512)) / 16));
|
area_y_ = (uint8_t)((std::abs(y_ - (mapY * 512)) / 16));
|
||||||
|
|
||||||
if (map_id >= 64) {
|
if (map_id >= 64) {
|
||||||
map_id -= 64;
|
map_id -= 64;
|
||||||
|
|||||||
@@ -423,7 +423,7 @@ void OverworldMap::DrawAnimatedTiles() {
|
|||||||
|
|
||||||
void OverworldMap::LoadAreaGraphicsBlocksets() {
|
void OverworldMap::LoadAreaGraphicsBlocksets() {
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
uchar value = rom_[rom_.version_constants().kOverworldGfxGroups1 +
|
uint8_t value = rom_[rom_.version_constants().kOverworldGfxGroups1 +
|
||||||
(area_graphics_ * 4) + i];
|
(area_graphics_ * 4) + i];
|
||||||
if (value != 0) {
|
if (value != 0) {
|
||||||
static_graphics_[3 + i] = value;
|
static_graphics_[3 + i] = value;
|
||||||
@@ -595,16 +595,16 @@ absl::Status OverworldMap::LoadPalette() {
|
|||||||
|
|
||||||
area_palette_ = std::min((int)area_palette_, 0xA3);
|
area_palette_ = std::min((int)area_palette_, 0xA3);
|
||||||
|
|
||||||
uchar pal0 = 0;
|
uint8_t pal0 = 0;
|
||||||
uchar pal1 = rom_[rom_.version_constants().kOverworldMapPaletteGroup +
|
uint8_t pal1 = rom_[rom_.version_constants().kOverworldMapPaletteGroup +
|
||||||
(area_palette_ * 4)];
|
(area_palette_ * 4)];
|
||||||
uchar pal2 = rom_[rom_.version_constants().kOverworldMapPaletteGroup +
|
uint8_t pal2 = rom_[rom_.version_constants().kOverworldMapPaletteGroup +
|
||||||
(area_palette_ * 4) + 1];
|
(area_palette_ * 4) + 1];
|
||||||
uchar pal3 = rom_[rom_.version_constants().kOverworldMapPaletteGroup +
|
uint8_t pal3 = rom_[rom_.version_constants().kOverworldMapPaletteGroup +
|
||||||
(area_palette_ * 4) + 2];
|
(area_palette_ * 4) + 2];
|
||||||
uchar pal4 =
|
uint8_t pal4 =
|
||||||
rom_[kOverworldSpritePaletteGroup + (sprite_palette_[game_state_] * 2)];
|
rom_[kOverworldSpritePaletteGroup + (sprite_palette_[game_state_] * 2)];
|
||||||
uchar pal5 = rom_[kOverworldSpritePaletteGroup +
|
uint8_t pal5 = rom_[kOverworldSpritePaletteGroup +
|
||||||
(sprite_palette_[game_state_] * 2) + 1];
|
(sprite_palette_[game_state_] * 2) + 1];
|
||||||
|
|
||||||
auto grass_pal_group = rom_.palette_group().grass;
|
auto grass_pal_group = rom_.palette_group().grass;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ void TitleScreen::Create() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TitleScreen::BuildTileset() {
|
void TitleScreen::BuildTileset() {
|
||||||
uchar staticgfx[16] = {0};
|
uint8_t staticgfx[16] = {0};
|
||||||
|
|
||||||
// Main Blocksets
|
// Main Blocksets
|
||||||
|
|
||||||
@@ -37,13 +37,13 @@ void TitleScreen::BuildTileset() {
|
|||||||
staticgfx[15] = 112;
|
staticgfx[15] = 112;
|
||||||
|
|
||||||
// Loaded gfx for the current screen (empty at this point)
|
// Loaded gfx for the current screen (empty at this point)
|
||||||
uchar* currentmapgfx8Data = tiles8Bitmap.mutable_data().data();
|
uint8_t* currentmapgfx8Data = tiles8Bitmap.mutable_data().data();
|
||||||
|
|
||||||
// All gfx of the game pack of 2048 bytes (4bpp)
|
// All gfx of the game pack of 2048 bytes (4bpp)
|
||||||
uchar* allgfxData = nullptr;
|
uint8_t* allgfxData = nullptr;
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
for (int j = 0; j < 2048; j++) {
|
for (int j = 0; j < 2048; j++) {
|
||||||
uchar mapByte = allgfxData[j + (staticgfx[i] * 2048)];
|
uint8_t mapByte = allgfxData[j + (staticgfx[i] * 2048)];
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
case 3:
|
case 3:
|
||||||
@@ -83,7 +83,7 @@ void TitleScreen::LoadTitleScreen() {
|
|||||||
int jj = 0;
|
int jj = 0;
|
||||||
int posB = pos;
|
int posB = pos;
|
||||||
while (j < (length / 2) + 1) {
|
while (j < (length / 2) + 1) {
|
||||||
ushort tiledata = (ushort)pos;
|
uint16_t tiledata = (uint16_t)pos;
|
||||||
if (dest_addr >= 0x1000) {
|
if (dest_addr >= 0x1000) {
|
||||||
// destAddr -= 0x1000;
|
// destAddr -= 0x1000;
|
||||||
if (dest_addr < 0x2000) {
|
if (dest_addr < 0x2000) {
|
||||||
|
|||||||
@@ -43,12 +43,12 @@ class TitleScreen {
|
|||||||
int addressesgfx[7] = {0x53ee0, 0x53f04, 0x53ef2, 0x53f16,
|
int addressesgfx[7] = {0x53ee0, 0x53f04, 0x53ef2, 0x53f16,
|
||||||
0x53f28, 0x53f3a, 0x53f4c};
|
0x53f28, 0x53f3a, 0x53f4c};
|
||||||
|
|
||||||
ushort bossRoom = 0x000F;
|
uint16_t bossRoom = 0x000F;
|
||||||
ushort selected_tile = 0;
|
uint16_t selected_tile = 0;
|
||||||
ushort tilesBG1Buffer[0x1000]; // 0x1000
|
uint16_t tilesBG1Buffer[0x1000]; // 0x1000
|
||||||
ushort tilesBG2Buffer[0x1000]; // 0x1000
|
uint16_t tilesBG2Buffer[0x1000]; // 0x1000
|
||||||
uchar mapdata; // 64 * 64
|
uint8_t mapdata; // 64 * 64
|
||||||
uchar dwmapdata; // 64 * 64
|
uint8_t dwmapdata; // 64 * 64
|
||||||
|
|
||||||
bool mDown = false;
|
bool mDown = false;
|
||||||
bool swordSelected = false;
|
bool swordSelected = false;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#include "cli/z3ed.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -5,9 +7,8 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "cli/z3ed.h"
|
|
||||||
#include "cli/tui.h"
|
#include "cli/tui.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "app/core/common.h"
|
#include "app/core/common.h"
|
||||||
#include "app/core/constants.h"
|
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
|
#include "util/macro.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace cli {
|
namespace cli {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef YAZE_APP_CORE_CONSTANTS_H
|
#ifndef YAZE_UTIL_MACRO_H
|
||||||
#define YAZE_APP_CORE_CONSTANTS_H
|
#define YAZE_UTIL_MACRO_H
|
||||||
|
|
||||||
#define TAB_ITEM(w) if (ImGui::BeginTabItem(w)) {
|
#define TAB_ITEM(w) if (ImGui::BeginTabItem(w)) {
|
||||||
#define END_TAB_ITEM() \
|
#define END_TAB_ITEM() \
|
||||||
@@ -109,8 +109,9 @@
|
|||||||
return temp; \
|
return temp; \
|
||||||
}
|
}
|
||||||
|
|
||||||
using ushort = unsigned short;
|
#define SDL_RETURN_IF_ERROR() \
|
||||||
using uint = unsigned int;
|
if (SDL_GetError() != nullptr) { \
|
||||||
using uchar = unsigned char;
|
return absl::InternalError(SDL_GetError()); \
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif // YAZE_UTIL_MACRO_H
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
@@ -32,7 +33,7 @@ using ::testing::TypedEq;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
std::vector<uint8_t> ExpectCompressOk(Rom& rom, uchar* in, int in_size) {
|
std::vector<uint8_t> ExpectCompressOk(Rom& rom, uint8_t* in, int in_size) {
|
||||||
std::vector<uint8_t> data(in, in + in_size);
|
std::vector<uint8_t> data(in, in + in_size);
|
||||||
auto load_status = rom.LoadFromData(data, false);
|
auto load_status = rom.LoadFromData(data, false);
|
||||||
EXPECT_TRUE(load_status.ok());
|
EXPECT_TRUE(load_status.ok());
|
||||||
@@ -52,7 +53,7 @@ std::vector<uint8_t> ExpectDecompressBytesOk(Rom& rom,
|
|||||||
return decompressed_bytes;
|
return decompressed_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> ExpectDecompressOk(Rom& rom, uchar* in, int in_size) {
|
std::vector<uint8_t> ExpectDecompressOk(Rom& rom, uint8_t* in, int in_size) {
|
||||||
std::vector<uint8_t> data(in, in + in_size);
|
std::vector<uint8_t> data(in, in + in_size);
|
||||||
auto load_status = rom.LoadFromData(data, false);
|
auto load_status = rom.LoadFromData(data, false);
|
||||||
EXPECT_TRUE(load_status.ok());
|
EXPECT_TRUE(load_status.ok());
|
||||||
@@ -161,8 +162,8 @@ TEST(LC_LZ2_CompressionTest, NewDecompressionPieceOk) {
|
|||||||
// 0x25 instead of 0x24
|
// 0x25 instead of 0x24
|
||||||
TEST(LC_LZ2_CompressionTest, CompressionSingleSet) {
|
TEST(LC_LZ2_CompressionTest, CompressionSingleSet) {
|
||||||
Rom rom;
|
Rom rom;
|
||||||
uchar single_set[5] = {0x2A, 0x2A, 0x2A, 0x2A, 0x2A};
|
uint8_t single_set[5] = {0x2A, 0x2A, 0x2A, 0x2A, 0x2A};
|
||||||
uchar single_set_expected[3] = {BUILD_HEADER(1, 5), 0x2A, 0xFF};
|
uint8_t single_set_expected[3] = {BUILD_HEADER(1, 5), 0x2A, 0xFF};
|
||||||
|
|
||||||
auto comp_result = ExpectCompressOk(rom, single_set, 5);
|
auto comp_result = ExpectCompressOk(rom, single_set, 5);
|
||||||
EXPECT_THAT(single_set_expected, ElementsAreArray(comp_result.data(), 3));
|
EXPECT_THAT(single_set_expected, ElementsAreArray(comp_result.data(), 3));
|
||||||
@@ -170,8 +171,8 @@ TEST(LC_LZ2_CompressionTest, CompressionSingleSet) {
|
|||||||
|
|
||||||
TEST(LC_LZ2_CompressionTest, CompressionSingleWord) {
|
TEST(LC_LZ2_CompressionTest, CompressionSingleWord) {
|
||||||
Rom rom;
|
Rom rom;
|
||||||
uchar single_word[6] = {0x2A, 0x01, 0x2A, 0x01, 0x2A, 0x01};
|
uint8_t single_word[6] = {0x2A, 0x01, 0x2A, 0x01, 0x2A, 0x01};
|
||||||
uchar single_word_expected[4] = {BUILD_HEADER(0x02, 0x06), 0x2A, 0x01, 0xFF};
|
uint8_t single_word_expected[4] = {BUILD_HEADER(0x02, 0x06), 0x2A, 0x01, 0xFF};
|
||||||
|
|
||||||
auto comp_result = ExpectCompressOk(rom, single_word, 6);
|
auto comp_result = ExpectCompressOk(rom, single_word, 6);
|
||||||
EXPECT_THAT(single_word_expected, ElementsAreArray(comp_result.data(), 4));
|
EXPECT_THAT(single_word_expected, ElementsAreArray(comp_result.data(), 4));
|
||||||
@@ -179,16 +180,16 @@ TEST(LC_LZ2_CompressionTest, CompressionSingleWord) {
|
|||||||
|
|
||||||
TEST(LC_LZ2_CompressionTest, CompressionSingleIncrement) {
|
TEST(LC_LZ2_CompressionTest, CompressionSingleIncrement) {
|
||||||
Rom rom;
|
Rom rom;
|
||||||
uchar single_inc[3] = {0x01, 0x02, 0x03};
|
uint8_t single_inc[3] = {0x01, 0x02, 0x03};
|
||||||
uchar single_inc_expected[3] = {BUILD_HEADER(0x03, 0x03), 0x01, 0xFF};
|
uint8_t single_inc_expected[3] = {BUILD_HEADER(0x03, 0x03), 0x01, 0xFF};
|
||||||
auto comp_result = ExpectCompressOk(rom, single_inc, 3);
|
auto comp_result = ExpectCompressOk(rom, single_inc, 3);
|
||||||
EXPECT_THAT(single_inc_expected, ElementsAreArray(comp_result.data(), 3));
|
EXPECT_THAT(single_inc_expected, ElementsAreArray(comp_result.data(), 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(LC_LZ2_CompressionTest, CompressionSingleCopy) {
|
TEST(LC_LZ2_CompressionTest, CompressionSingleCopy) {
|
||||||
Rom rom;
|
Rom rom;
|
||||||
uchar single_copy[4] = {0x03, 0x0A, 0x07, 0x14};
|
uint8_t single_copy[4] = {0x03, 0x0A, 0x07, 0x14};
|
||||||
uchar single_copy_expected[6] = {
|
uint8_t single_copy_expected[6] = {
|
||||||
BUILD_HEADER(0x00, 0x04), 0x03, 0x0A, 0x07, 0x14, 0xFF};
|
BUILD_HEADER(0x00, 0x04), 0x03, 0x0A, 0x07, 0x14, 0xFF};
|
||||||
auto comp_result = ExpectCompressOk(rom, single_copy, 4);
|
auto comp_result = ExpectCompressOk(rom, single_copy, 4);
|
||||||
EXPECT_THAT(single_copy_expected, ElementsAreArray(comp_result.data(), 6));
|
EXPECT_THAT(single_copy_expected, ElementsAreArray(comp_result.data(), 6));
|
||||||
@@ -303,12 +304,12 @@ TEST(LC_LZ2_CompressionTest, LengthBorderCompression) {
|
|||||||
|
|
||||||
TEST(LC_LZ2_CompressionTest, CompressionExtendedWordCopy) {
|
TEST(LC_LZ2_CompressionTest, CompressionExtendedWordCopy) {
|
||||||
// ROM rom;
|
// ROM rom;
|
||||||
// uchar buffer[3000];
|
// uint8_t buffer[3000];
|
||||||
// for (unsigned int i = 0; i < 3000; i += 2) {
|
// for (unsigned int i = 0; i < 3000; i += 2) {
|
||||||
// buffer[i] = 0x05;
|
// buffer[i] = 0x05;
|
||||||
// buffer[i + 1] = 0x06;
|
// buffer[i + 1] = 0x06;
|
||||||
// }
|
// }
|
||||||
// uchar hightlength_word_1050[] = {
|
// uint8_t hightlength_word_1050[] = {
|
||||||
// 0b11101011, 0xFF, 0x05, 0x06, BUILD_HEADER(0x02, 0x1A), 0x05, 0x06,
|
// 0b11101011, 0xFF, 0x05, 0x06, BUILD_HEADER(0x02, 0x1A), 0x05, 0x06,
|
||||||
// 0xFF};
|
// 0xFF};
|
||||||
|
|
||||||
@@ -340,9 +341,9 @@ TEST(LC_LZ2_CompressionTest, CompressionMixedPatterns) {
|
|||||||
|
|
||||||
TEST(LC_LZ2_CompressionTest, CompressionLongIntraCopy) {
|
TEST(LC_LZ2_CompressionTest, CompressionLongIntraCopy) {
|
||||||
ROM rom;
|
ROM rom;
|
||||||
uchar long_data[15] = {0x05, 0x06, 0x07, 0x08, 0x05, 0x06, 0x07, 0x08,
|
uint8_t long_data[15] = {0x05, 0x06, 0x07, 0x08, 0x05, 0x06, 0x07, 0x08,
|
||||||
0x05, 0x06, 0x07, 0x08, 0x05, 0x06, 0x07};
|
0x05, 0x06, 0x07, 0x08, 0x05, 0x06, 0x07};
|
||||||
uchar long_expected[] = {BUILD_HEADER(0x00, 0x04), 0x05, 0x06, 0x07, 0x08,
|
uint8_t long_expected[] = {BUILD_HEADER(0x00, 0x04), 0x05, 0x06, 0x07, 0x08,
|
||||||
BUILD_HEADER(0x04, 0x0C), 0x00, 0x00, 0xFF};
|
BUILD_HEADER(0x04, 0x0C), 0x00, 0x00, 0xFF};
|
||||||
|
|
||||||
auto comp_result = ExpectCompressOk(rom, long_data, 15);
|
auto comp_result = ExpectCompressOk(rom, long_data, 15);
|
||||||
@@ -403,14 +404,14 @@ TEST(LC_LZ2_CompressionTest, DecompressionValidCommand) {
|
|||||||
Rom rom;
|
Rom rom;
|
||||||
std::vector<uint8_t> simple_copy_input = {BUILD_HEADER(0x00, 0x02), 0x2A,
|
std::vector<uint8_t> simple_copy_input = {BUILD_HEADER(0x00, 0x02), 0x2A,
|
||||||
0x45, 0xFF};
|
0x45, 0xFF};
|
||||||
uchar simple_copy_output[2] = {0x2A, 0x45};
|
uint8_t simple_copy_output[2] = {0x2A, 0x45};
|
||||||
auto decomp_result = ExpectDecompressBytesOk(rom, simple_copy_input);
|
auto decomp_result = ExpectDecompressBytesOk(rom, simple_copy_input);
|
||||||
EXPECT_THAT(simple_copy_output, ElementsAreArray(decomp_result.data(), 2));
|
EXPECT_THAT(simple_copy_output, ElementsAreArray(decomp_result.data(), 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(LC_LZ2_CompressionTest, DecompressionMixingCommand) {
|
TEST(LC_LZ2_CompressionTest, DecompressionMixingCommand) {
|
||||||
Rom rom;
|
Rom rom;
|
||||||
uchar random1_i[11] = {BUILD_HEADER(0x01, 0x03),
|
uint8_t random1_i[11] = {BUILD_HEADER(0x01, 0x03),
|
||||||
0x2A,
|
0x2A,
|
||||||
BUILD_HEADER(0x00, 0x04),
|
BUILD_HEADER(0x00, 0x04),
|
||||||
0x01,
|
0x01,
|
||||||
@@ -421,7 +422,7 @@ TEST(LC_LZ2_CompressionTest, DecompressionMixingCommand) {
|
|||||||
0x0B,
|
0x0B,
|
||||||
0x16,
|
0x16,
|
||||||
0xFF};
|
0xFF};
|
||||||
uchar random1_o[9] = {42, 42, 42, 1, 2, 3, 4, 11, 22};
|
uint8_t random1_o[9] = {42, 42, 42, 1, 2, 3, 4, 11, 22};
|
||||||
auto decomp_result = ExpectDecompressOk(rom, random1_i, 11);
|
auto decomp_result = ExpectDecompressOk(rom, random1_i, 11);
|
||||||
EXPECT_THAT(random1_o, ElementsAreArray(decomp_result.data(), 9));
|
EXPECT_THAT(random1_o, ElementsAreArray(decomp_result.data(), 9));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user