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