Merge branch 'master' into mosaic-transition
This commit is contained in:
@@ -22,6 +22,21 @@ set(ABSL_PROPAGATE_CXX_STD ON)
|
|||||||
set(ABSL_CXX_STANDARD 17)
|
set(ABSL_CXX_STANDARD 17)
|
||||||
set(ABSL_USE_GOOGLETEST_HEAD ON)
|
set(ABSL_USE_GOOGLETEST_HEAD ON)
|
||||||
set(ABSL_ENABLE_INSTALL ON)
|
set(ABSL_ENABLE_INSTALL ON)
|
||||||
|
set(
|
||||||
|
ABSL_TARGETS
|
||||||
|
absl::strings
|
||||||
|
absl::flags
|
||||||
|
absl::status
|
||||||
|
absl::statusor
|
||||||
|
absl::examine_stack
|
||||||
|
absl::stacktrace
|
||||||
|
absl::base
|
||||||
|
absl::config
|
||||||
|
absl::core_headers
|
||||||
|
absl::raw_logging_internal
|
||||||
|
absl::failure_signal_handler
|
||||||
|
absl::flat_hash_map
|
||||||
|
)
|
||||||
|
|
||||||
# Video Libraries -------------------------------------------------------------
|
# Video Libraries -------------------------------------------------------------
|
||||||
find_package(PNG REQUIRED)
|
find_package(PNG REQUIRED)
|
||||||
|
|||||||
17
docs/dev-setup-windows.md
Normal file
17
docs/dev-setup-windows.md
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
For VSCode users, use the following CMake extensions with MinGW-w64
|
||||||
|
|
||||||
|
https://marketplace.visualstudio.com/items?itemName=twxs.cmake
|
||||||
|
https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools
|
||||||
|
|
||||||
|
https://www.msys2.org/
|
||||||
|
|
||||||
|
Add to environment variables `C:\msys64\mingw64\bin`
|
||||||
|
|
||||||
|
Install the following packages using `pacman -S <package-name>`
|
||||||
|
|
||||||
|
`mingw-w64-x86_64-gcc`
|
||||||
|
`mingw-w64-x86_64-gcc-libs`
|
||||||
|
`mingw-w64-x86_64-cmake`
|
||||||
|
`mingw-w64-x86_64-glew`
|
||||||
|
`mingw-w64-x86_64-lib-png`
|
||||||
@@ -36,6 +36,11 @@ set(
|
|||||||
|
|
||||||
# Asar Assembly ---------------------------------------------------------------
|
# Asar Assembly ---------------------------------------------------------------
|
||||||
add_subdirectory(lib/asar/src)
|
add_subdirectory(lib/asar/src)
|
||||||
|
set(ASAR_GEN_EXE OFF)
|
||||||
|
set(ASAR_GEN_DLL ON)
|
||||||
|
set(ASAR_GEN_LIB OFF)
|
||||||
|
set(ASAR_GEN_EXE_TEST OFF)
|
||||||
|
set(ASAR_GEN_DLL_TEST OFF)
|
||||||
|
|
||||||
# yaze source files -----------------------------------------------------------
|
# yaze source files -----------------------------------------------------------
|
||||||
set(
|
set(
|
||||||
@@ -108,22 +113,6 @@ target_include_directories(
|
|||||||
lib/asar/src/asar-dll-bindings/c
|
lib/asar/src/asar-dll-bindings/c
|
||||||
)
|
)
|
||||||
|
|
||||||
set(
|
|
||||||
ABSL_TARGETS
|
|
||||||
absl::strings
|
|
||||||
absl::flags
|
|
||||||
absl::status
|
|
||||||
absl::statusor
|
|
||||||
absl::examine_stack
|
|
||||||
absl::stacktrace
|
|
||||||
absl::base
|
|
||||||
absl::config
|
|
||||||
absl::core_headers
|
|
||||||
absl::raw_logging_internal
|
|
||||||
absl::failure_signal_handler
|
|
||||||
absl::flat_hash_map
|
|
||||||
)
|
|
||||||
|
|
||||||
set(SDL_TARGETS SDL2::SDL2)
|
set(SDL_TARGETS SDL2::SDL2)
|
||||||
|
|
||||||
if(WIN32 OR MINGW)
|
if(WIN32 OR MINGW)
|
||||||
@@ -137,7 +126,8 @@ target_link_libraries(
|
|||||||
${SDL_TARGETS}
|
${SDL_TARGETS}
|
||||||
${PNG_LIBRARIES}
|
${PNG_LIBRARIES}
|
||||||
${GLEW_LIBRARIES}
|
${GLEW_LIBRARIES}
|
||||||
${OPENGL_LIBRARIES}
|
${OPENGL_LIBRARIES}
|
||||||
|
${CMAKE_DL_LIBS}
|
||||||
ImGui
|
ImGui
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#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/common.h"
|
||||||
#include "app/core/constants.h"
|
#include "app/core/constants.h"
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
|
|
||||||
@@ -19,15 +20,6 @@ namespace yaze {
|
|||||||
namespace app {
|
namespace app {
|
||||||
namespace snes_asm {
|
namespace snes_asm {
|
||||||
|
|
||||||
static auto string_replace(std::string &str, const std::string &from,
|
|
||||||
const std::string &to) -> bool {
|
|
||||||
size_t start = str.find(from);
|
|
||||||
if (start == std::string::npos) return false;
|
|
||||||
|
|
||||||
str.replace(start, from.length(), to);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string GenerateBytePool(char mosaic_tiles[core::kNumOverworldMaps]) {
|
std::string GenerateBytePool(char mosaic_tiles[core::kNumOverworldMaps]) {
|
||||||
std::string to_return = "";
|
std::string to_return = "";
|
||||||
int column = 0;
|
int column = 0;
|
||||||
@@ -95,21 +87,12 @@ absl::Status Script::GenerateMosaicChangeAssembly(
|
|||||||
|
|
||||||
auto assembly_string = assembly.str();
|
auto assembly_string = assembly.str();
|
||||||
|
|
||||||
if (!hook_offset) {
|
if (!core::StringReplace(assembly_string, "<HOOK>", kMosaicChangeOffset)) {
|
||||||
// TODO: TESTME
|
return absl::InternalError(
|
||||||
if (!string_replace(assembly_string, "<HOOK>",
|
"Mosaic template did not have proper `<HOOK>` to replace.");
|
||||||
absl::StrFormat("$%06x", hook_offset))) {
|
|
||||||
return absl::InternalError(
|
|
||||||
"Mosaic template did not have proper `<HOOK>` to replace.");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!string_replace(assembly_string, "<HOOK>", kMosaicChangeOffset)) {
|
|
||||||
return absl::InternalError(
|
|
||||||
"Mosaic template did not have proper `<HOOK>` to replace.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string_replace(
|
if (!core::StringReplace(
|
||||||
assembly_string, "<EXPANDED_SPACE>",
|
assembly_string, "<EXPANDED_SPACE>",
|
||||||
absl::StrFormat("$%x", routine_offset + kSNESToPCOffset))) {
|
absl::StrFormat("$%x", routine_offset + kSNESToPCOffset))) {
|
||||||
return absl::InternalError(
|
return absl::InternalError(
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
@@ -19,7 +20,7 @@ int AddressFromBytes(uint8_t addr1, uint8_t addr2, uint8_t addr3) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// hextodec has been imported from SNESDisasm to parse hex numbers
|
// hextodec has been imported from SNESDisasm to parse hex numbers
|
||||||
int HexToDec(char* input, int length) {
|
int HexToDec(char *input, int length) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
int value;
|
int value;
|
||||||
int ceiling = length - 1;
|
int ceiling = length - 1;
|
||||||
@@ -48,6 +49,15 @@ int HexToDec(char* input, int length) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StringReplace(std::string &str, const std::string &from,
|
||||||
|
const std::string &to) {
|
||||||
|
size_t start = str.find(from);
|
||||||
|
if (start == std::string::npos) return false;
|
||||||
|
|
||||||
|
str.replace(start, from.length(), to);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace core
|
} // namespace core
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define YAZE_CORE_COMMON_H
|
#define YAZE_CORE_COMMON_H
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
@@ -10,6 +11,8 @@ namespace core {
|
|||||||
unsigned int SnesToPc(unsigned int addr);
|
unsigned int SnesToPc(unsigned int addr);
|
||||||
int AddressFromBytes(uint8_t addr1, uint8_t addr2, uint8_t addr3);
|
int AddressFromBytes(uint8_t addr1, uint8_t addr2, uint8_t addr3);
|
||||||
int HexToDec(char *input, int length);
|
int HexToDec(char *input, int length);
|
||||||
|
bool StringReplace(std::string &str, const std::string &from,
|
||||||
|
const std::string &to);
|
||||||
|
|
||||||
} // namespace core
|
} // namespace core
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ absl::Status Controller::CreateWindow() {
|
|||||||
SDL_WINDOWPOS_UNDEFINED, // initial y position
|
SDL_WINDOWPOS_UNDEFINED, // initial y position
|
||||||
1200, // width, in pixels
|
1200, // width, in pixels
|
||||||
800, // height, in pixels
|
800, // height, in pixels
|
||||||
SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL),
|
SDL_WINDOW_RESIZABLE),
|
||||||
sdl_deleter());
|
sdl_deleter());
|
||||||
if (window_ == nullptr) {
|
if (window_ == nullptr) {
|
||||||
return absl::InternalError(
|
return absl::InternalError(
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ namespace editor {
|
|||||||
|
|
||||||
void DungeonEditor::Update() {
|
void DungeonEditor::Update() {
|
||||||
DrawToolset();
|
DrawToolset();
|
||||||
canvas_.Update();
|
canvas_.DrawBackground();
|
||||||
|
canvas_.UpdateContext();
|
||||||
|
canvas_.DrawGrid();
|
||||||
|
canvas_.DrawOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DungeonEditor::DrawToolset() {
|
void DungeonEditor::DrawToolset() {
|
||||||
|
|||||||
@@ -188,12 +188,12 @@ void MasterEditor::DrawFileMenu() const {
|
|||||||
|
|
||||||
void MasterEditor::DrawEditMenu() {
|
void MasterEditor::DrawEditMenu() {
|
||||||
if (ImGui::BeginMenu("Edit")) {
|
if (ImGui::BeginMenu("Edit")) {
|
||||||
MENU_ITEM2("Undo", "Ctrl+Z") {}
|
MENU_ITEM2("Undo", "Ctrl+Z") { status_ = overworld_editor_.Undo(); }
|
||||||
MENU_ITEM2("Redo", "Ctrl+Y") {}
|
MENU_ITEM2("Redo", "Ctrl+Y") { status_ = overworld_editor_.Redo(); }
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
MENU_ITEM2("Cut", "Ctrl+X") {}
|
MENU_ITEM2("Cut", "Ctrl+X") { status_ = overworld_editor_.Cut(); }
|
||||||
MENU_ITEM2("Copy", "Ctrl+C") {}
|
MENU_ITEM2("Copy", "Ctrl+C") { status_ = overworld_editor_.Copy(); }
|
||||||
MENU_ITEM2("Paste", "Ctrl+V") {}
|
MENU_ITEM2("Paste", "Ctrl+V") { status_ = overworld_editor_.Paste(); }
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
MENU_ITEM2("Find", "Ctrl+F") {}
|
MENU_ITEM2("Find", "Ctrl+F") {}
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|||||||
@@ -41,8 +41,11 @@ class OverworldEditor {
|
|||||||
public:
|
public:
|
||||||
void SetupROM(ROM &rom);
|
void SetupROM(ROM &rom);
|
||||||
absl::Status Update();
|
absl::Status Update();
|
||||||
|
|
||||||
absl::Status Undo() { return absl::UnimplementedError("Undo"); }
|
absl::Status Undo() { return absl::UnimplementedError("Undo"); }
|
||||||
|
absl::Status Redo() { return absl::UnimplementedError("Redo"); }
|
||||||
|
absl::Status Cut() { return absl::UnimplementedError("Cut"); }
|
||||||
|
absl::Status Copy() { return absl::UnimplementedError("Copy"); }
|
||||||
|
absl::Status Paste() { return absl::UnimplementedError("Paste"); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
absl::Status DrawToolset();
|
absl::Status DrawToolset();
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ namespace editor {
|
|||||||
absl::Status PaletteEditor::Update() {
|
absl::Status PaletteEditor::Update() {
|
||||||
for (const auto &name : kPaletteCategoryNames) {
|
for (const auto &name : kPaletteCategoryNames) {
|
||||||
if (ImGui::TreeNode(name.data())) {
|
if (ImGui::TreeNode(name.data())) {
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::SmallButton("button")) {
|
if (ImGui::SmallButton("button")) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ static int overworldCustomMosaicArray = 0x1301F0;
|
|||||||
|
|
||||||
class ScreenEditor {
|
class ScreenEditor {
|
||||||
public:
|
public:
|
||||||
void SetupROM(ROM &rom) { rom_ = rom; }
|
|
||||||
ScreenEditor();
|
ScreenEditor();
|
||||||
|
void SetupROM(ROM &rom) { rom_ = rom; }
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -114,9 +114,9 @@ class ROM {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
long size_ = 0;
|
long size_ = 0;
|
||||||
std::string filename_;
|
|
||||||
uchar title[21] = "ROM Not Loaded";
|
uchar title[21] = "ROM Not Loaded";
|
||||||
bool is_loaded_ = false;
|
bool is_loaded_ = false;
|
||||||
|
std::string filename_;
|
||||||
|
|
||||||
Bytes rom_data_;
|
Bytes rom_data_;
|
||||||
std::shared_ptr<SDL_Renderer> renderer_;
|
std::shared_ptr<SDL_Renderer> renderer_;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ absl::Status Overworld::Load(ROM &rom, uchar *ow_blockset) {
|
|||||||
auto size = tiles16.size();
|
auto size = tiles16.size();
|
||||||
for (int i = 0; i < core::kNumOverworldMaps; ++i) {
|
for (int i = 0; i < core::kNumOverworldMaps; ++i) {
|
||||||
auto map_status =
|
auto map_status =
|
||||||
overworld_maps_[i].BuildMapV2(size, game_state_, map_parent_);
|
overworld_maps_[i].BuildMap(size, game_state_, map_parent_);
|
||||||
if (!map_status.ok()) {
|
if (!map_status.ok()) {
|
||||||
return map_status;
|
return map_status;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,55 +102,8 @@ void OverworldMap::LoadAreaInfo() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverworldMap::BuildMap(int count, int game_state, uchar* map_parent,
|
absl::Status OverworldMap::BuildMap(int count, int game_state,
|
||||||
uchar* ow_blockset, OWMapTiles& map_tiles) {
|
uchar* map_parent) {
|
||||||
if (large_map_) {
|
|
||||||
parent_ = map_parent[index_];
|
|
||||||
if (parent_ != index_ && !initialized_) {
|
|
||||||
if (index_ >= 0x80 && index_ <= 0x8A && index_ != 0x88) {
|
|
||||||
area_graphics_ = rom_[core::overworldSpecialGFXGroup + (parent_ - 128)];
|
|
||||||
area_palette_ = rom_[core::overworldSpecialPALGroup + 1];
|
|
||||||
} else if (index_ == 0x88) {
|
|
||||||
area_graphics_ = 81;
|
|
||||||
area_palette_ = 0;
|
|
||||||
} else {
|
|
||||||
area_graphics_ = rom_[core::mapGfx + parent_];
|
|
||||||
area_palette_ = rom_[core::overworldMapPalette + parent_];
|
|
||||||
}
|
|
||||||
|
|
||||||
initialized_ = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!BuildTileset(game_state).ok()) {
|
|
||||||
std::cout << "BuildTileset failed" << std::endl;
|
|
||||||
}
|
|
||||||
BuildTiles16Gfx(count, ow_blockset); // build on GFX.mapgfx16Ptr
|
|
||||||
|
|
||||||
// int world = 0;
|
|
||||||
// if (index_ < 64) {
|
|
||||||
// map_tiles_ = map_tiles.light_world;
|
|
||||||
// } else if (index_ < 128 && index_ >= 64) {
|
|
||||||
// map_tiles_ = map_tiles.dark_world;
|
|
||||||
// world = 1;
|
|
||||||
// } else {
|
|
||||||
// map_tiles_ = map_tiles.special_world;
|
|
||||||
// world = 2;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// int superY = ((index_ - (world * 64)) / 8);
|
|
||||||
// int superX = index_ - (world * 64) - (superY * 8);
|
|
||||||
// for (int y = 0; y < 32; y++) {
|
|
||||||
// for (int x = 0; x < 32; x++) {
|
|
||||||
// auto xt = x + (superX * 32);
|
|
||||||
// auto yt = y + (superY * 32);
|
|
||||||
// CopyTile8bpp16((x * 16), (y * 16), map_tiles_[xt][yt], ow_blockset);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
absl::Status OverworldMap::BuildMapV2(int count, int game_state,
|
|
||||||
uchar* map_parent) {
|
|
||||||
if (large_map_) {
|
if (large_map_) {
|
||||||
parent_ = map_parent[index_];
|
parent_ = map_parent[index_];
|
||||||
if (parent_ != index_ && !initialized_) {
|
if (parent_ != index_ && !initialized_) {
|
||||||
@@ -174,12 +127,25 @@ absl::Status OverworldMap::BuildMapV2(int count, int game_state,
|
|||||||
return tileset_status;
|
return tileset_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// int world = 0;
|
||||||
// if (index_ < 64) {
|
// if (index_ < 64) {
|
||||||
// world_ = 0;
|
// map_tiles_ = map_tiles.light_world;
|
||||||
// } else if (index_ < 128 && index_ >= 64) {
|
// } else if (index_ < 128 && index_ >= 64) {
|
||||||
// world_ = 1;
|
// map_tiles_ = map_tiles.dark_world;
|
||||||
|
// world = 1;
|
||||||
// } else {
|
// } else {
|
||||||
// world_ = 2;
|
// map_tiles_ = map_tiles.special_world;
|
||||||
|
// world = 2;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// int superY = ((index_ - (world * 64)) / 8);
|
||||||
|
// int superX = index_ - (world * 64) - (superY * 8);
|
||||||
|
// for (int y = 0; y < 32; y++) {
|
||||||
|
// for (int x = 0; x < 32; x++) {
|
||||||
|
// auto xt = x + (superX * 32);
|
||||||
|
// auto yt = y + (superY * 32);
|
||||||
|
// CopyTile8bpp16((x * 16), (y * 16), map_tiles_[xt][yt], ow_blockset);
|
||||||
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
@@ -246,40 +212,7 @@ absl::Status OverworldMap::BuildTileset(int game_state) {
|
|||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverworldMap::BuildTiles16Gfx(int count, uchar* ow_blockset) {
|
absl::Status OverworldMap::BuildTiles16Gfx(int count) {
|
||||||
auto gfx_tile16_data = ow_blockset;
|
|
||||||
auto gfx_tile8_data = nullptr; // rom_.GetMasterGraphicsBin();
|
|
||||||
|
|
||||||
int offsets[] = {0, 8, 1024, 1032};
|
|
||||||
auto yy = 0;
|
|
||||||
auto xx = 0;
|
|
||||||
|
|
||||||
// number of tiles16 3748?
|
|
||||||
for (auto i = 0; i < count; i++) {
|
|
||||||
// 8x8 tile draw
|
|
||||||
// gfx8 = 4bpp so everyting is /2F
|
|
||||||
auto tiles = tiles16_[i];
|
|
||||||
|
|
||||||
for (auto tile = 0; tile < 4; tile++) {
|
|
||||||
gfx::TileInfo info = tiles16_[i].tiles_info[tile];
|
|
||||||
int offset = offsets[tile];
|
|
||||||
|
|
||||||
for (auto y = 0; y < 8; y++) {
|
|
||||||
for (auto x = 0; x < 4; x++) {
|
|
||||||
CopyTile(x, y, xx, yy, offset, info, gfx_tile16_data, gfx_tile8_data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
xx += 16;
|
|
||||||
if (xx >= 128) {
|
|
||||||
yy += 2048;
|
|
||||||
xx = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
absl::Status OverworldMap::BuildTiles16GfxV2(int count) {
|
|
||||||
auto gfx_tile8_data = nullptr; // rom_.GetMasterGraphicsBin();
|
auto gfx_tile8_data = nullptr; // rom_.GetMasterGraphicsBin();
|
||||||
|
|
||||||
int offsets[] = {0, 8, 1024, 1032};
|
int offsets[] = {0, 8, 1024, 1032};
|
||||||
@@ -354,33 +287,6 @@ void OverworldMap::CopyTile8bpp16(int x, int y, int tile, uchar* ow_blockset) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// EXPERIMENTAL ----------------------------------------------------------------
|
|
||||||
|
|
||||||
// map,current
|
|
||||||
void OverworldMap::CopyTileToMap(int x, int y, int xx, int yy, int offset,
|
|
||||||
gfx::TileInfo tile, uchar* gfx16Pointer,
|
|
||||||
uchar* gfx8Pointer) {
|
|
||||||
int mx = x;
|
|
||||||
int my = y;
|
|
||||||
uchar r = 0;
|
|
||||||
|
|
||||||
if (tile.horizontal_mirror_ != 0) {
|
|
||||||
mx = 3 - x;
|
|
||||||
r = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tile.vertical_mirror_ != 0) {
|
|
||||||
my = 7 - y;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tx = ((tile.id_ / 16) * 512) + ((tile.id_ - ((tile.id_ / 16) * 16)) * 4);
|
|
||||||
auto index = xx + (yy * 512) + offset + (mx * 2) + (my * 512);
|
|
||||||
auto pixel = gfx8Pointer[tx + (y * 64) + x];
|
|
||||||
|
|
||||||
gfx16Pointer[index + r ^ 1] = (uchar)((pixel & 0x0F) + tile.palette_ * 16);
|
|
||||||
gfx16Pointer[index + r] = (uchar)(((pixel >> 4) & 0x0F) + tile.palette_ * 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace zelda3
|
} // namespace zelda3
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
@@ -24,10 +24,7 @@ class OverworldMap {
|
|||||||
public:
|
public:
|
||||||
OverworldMap(int index, ROM& rom, const std::vector<gfx::Tile16>& tiles16);
|
OverworldMap(int index, ROM& rom, const std::vector<gfx::Tile16>& tiles16);
|
||||||
|
|
||||||
void BuildMap(int count, int game_state, uchar* map_parent,
|
absl::Status BuildMap(int count, int game_state, uchar* map_parent);
|
||||||
uchar* ow_blockset, OWMapTiles& map_tiles);
|
|
||||||
|
|
||||||
absl::Status BuildMapV2(int count, int game_state, uchar* map_parent);
|
|
||||||
|
|
||||||
auto GetBitmap() { return bitmap_; }
|
auto GetBitmap() { return bitmap_; }
|
||||||
auto GetCurrentGraphicsSet() { return current_graphics_sheet_set; }
|
auto GetCurrentGraphicsSet() { return current_graphics_sheet_set; }
|
||||||
@@ -36,21 +33,15 @@ class OverworldMap {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void LoadAreaInfo();
|
void LoadAreaInfo();
|
||||||
void BuildTiles16Gfx(int count, uchar* ow_blockset);
|
|
||||||
|
|
||||||
absl::Status BuildTileset(int game_state);
|
absl::Status BuildTileset(int game_state);
|
||||||
absl::Status BuildTiles16GfxV2(int count);
|
absl::Status BuildTiles16Gfx(int count);
|
||||||
|
|
||||||
|
// TODO: Find the SDL_Surface way to do this.
|
||||||
void CopyTile(int x, int y, int xx, int yy, int offset, gfx::TileInfo tile,
|
void CopyTile(int x, int y, int xx, int yy, int offset, gfx::TileInfo tile,
|
||||||
uchar* gfx16Pointer, uchar* gfx8Pointer);
|
uchar* gfx16Pointer, uchar* gfx8Pointer);
|
||||||
|
|
||||||
void CopyTile8bpp16(int x, int y, int tile, uchar* ow_blockset);
|
void CopyTile8bpp16(int x, int y, int tile, uchar* ow_blockset);
|
||||||
|
|
||||||
void CopyTileToMap(int x, int y, int xx, int yy, int offset,
|
|
||||||
gfx::TileInfo tile, uchar* gfx16Pointer,
|
|
||||||
uchar* gfx8Pointer);
|
|
||||||
void CopyTile8bpp16From8(int xP, int yP, int tileID, uchar* destbmpPtr);
|
|
||||||
|
|
||||||
int parent_ = 0;
|
int parent_ = 0;
|
||||||
int index_ = 0;
|
int index_ = 0;
|
||||||
int world_ = 0;
|
int world_ = 0;
|
||||||
|
|||||||
@@ -8,89 +8,6 @@
|
|||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace gui {
|
namespace gui {
|
||||||
|
|
||||||
void Canvas::Update() {
|
|
||||||
ImVec2 canvas_p0 = ImGui::GetCursorScreenPos();
|
|
||||||
if (!custom_canvas_size_) canvas_sz_ = ImGui::GetContentRegionAvail();
|
|
||||||
|
|
||||||
auto canvas_p1 =
|
|
||||||
ImVec2(canvas_p0.x + canvas_sz_.x, canvas_p0.y + canvas_sz_.y);
|
|
||||||
|
|
||||||
// Draw border and background color
|
|
||||||
const ImGuiIO &io = ImGui::GetIO();
|
|
||||||
ImDrawList *draw_list = ImGui::GetWindowDrawList();
|
|
||||||
draw_list->AddRectFilled(canvas_p0, canvas_p1, IM_COL32(32, 32, 32, 255));
|
|
||||||
draw_list->AddRect(canvas_p0, canvas_p1, IM_COL32(255, 255, 255, 255));
|
|
||||||
|
|
||||||
// This will catch our interactions
|
|
||||||
ImGui::InvisibleButton(
|
|
||||||
"canvas", canvas_sz_,
|
|
||||||
ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight);
|
|
||||||
const bool is_hovered = ImGui::IsItemHovered(); // Hovered
|
|
||||||
const bool is_active = ImGui::IsItemActive(); // Held
|
|
||||||
const ImVec2 origin(canvas_p0.x + scrolling_.x,
|
|
||||||
canvas_p0.y + scrolling_.y); // Lock scrolled origin
|
|
||||||
const ImVec2 mouse_pos_in_canvas(io.MousePos.x - origin.x,
|
|
||||||
io.MousePos.y - origin.y);
|
|
||||||
|
|
||||||
// Add first and second point
|
|
||||||
if (is_hovered && !dragging_select_ &&
|
|
||||||
ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
|
|
||||||
points_.push_back(mouse_pos_in_canvas);
|
|
||||||
points_.push_back(mouse_pos_in_canvas);
|
|
||||||
dragging_select_ = true;
|
|
||||||
}
|
|
||||||
if (dragging_select_) {
|
|
||||||
points_.back() = mouse_pos_in_canvas;
|
|
||||||
if (!ImGui::IsMouseDown(ImGuiMouseButton_Left)) dragging_select_ = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pan (we use a zero mouse threshold when there's no context menu)
|
|
||||||
const float mouse_threshold_for_pan = enable_context_menu_ ? -1.0f : 0.0f;
|
|
||||||
if (is_active &&
|
|
||||||
ImGui::IsMouseDragging(ImGuiMouseButton_Right, mouse_threshold_for_pan)) {
|
|
||||||
scrolling_.x += io.MouseDelta.x;
|
|
||||||
scrolling_.y += io.MouseDelta.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Context menu (under default mouse threshold)
|
|
||||||
ImVec2 drag_delta = ImGui::GetMouseDragDelta(ImGuiMouseButton_Right);
|
|
||||||
if (enable_context_menu_ && drag_delta.x == 0.0f && drag_delta.y == 0.0f)
|
|
||||||
ImGui::OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonRight);
|
|
||||||
if (ImGui::BeginPopup("context")) {
|
|
||||||
if (dragging_select_) points_.resize(points_.size() - 2);
|
|
||||||
dragging_select_ = false;
|
|
||||||
if (ImGui::MenuItem("Remove all", nullptr, false, points_.Size > 0)) {
|
|
||||||
points_.clear();
|
|
||||||
}
|
|
||||||
ImGui::EndPopup();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw grid + all lines in the canvas
|
|
||||||
draw_list->PushClipRect(canvas_p0, canvas_p1, true);
|
|
||||||
if (enable_grid_) {
|
|
||||||
const float GRID_STEP = 64.0f;
|
|
||||||
for (float x = fmodf(scrolling_.x, GRID_STEP); x < canvas_sz_.x;
|
|
||||||
x += GRID_STEP)
|
|
||||||
draw_list->AddLine(ImVec2(canvas_p0.x + x, canvas_p0.y),
|
|
||||||
ImVec2(canvas_p0.x + x, canvas_p1.y),
|
|
||||||
IM_COL32(200, 200, 200, 40));
|
|
||||||
for (float y = fmodf(scrolling_.y, GRID_STEP); y < canvas_sz_.y;
|
|
||||||
y += GRID_STEP)
|
|
||||||
draw_list->AddLine(ImVec2(canvas_p0.x, canvas_p0.y + y),
|
|
||||||
ImVec2(canvas_p1.x, canvas_p0.y + y),
|
|
||||||
IM_COL32(200, 200, 200, 40));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int n = 0; n < points_.Size; n += 2) {
|
|
||||||
draw_list->AddRect(
|
|
||||||
ImVec2(origin.x + points_[n].x, origin.y + points_[n].y),
|
|
||||||
ImVec2(origin.x + points_[n + 1].x, origin.y + points_[n + 1].y),
|
|
||||||
IM_COL32(255, 255, 255, 255), 1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
draw_list->PopClipRect();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Canvas::DrawBackground(ImVec2 canvas_size) {
|
void Canvas::DrawBackground(ImVec2 canvas_size) {
|
||||||
canvas_p0_ = ImGui::GetCursorScreenPos();
|
canvas_p0_ = ImGui::GetCursorScreenPos();
|
||||||
if (!custom_canvas_size_) canvas_sz_ = ImGui::GetContentRegionAvail();
|
if (!custom_canvas_size_) canvas_sz_ = ImGui::GetContentRegionAvail();
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ class Canvas {
|
|||||||
Canvas(ImVec2 canvas_size)
|
Canvas(ImVec2 canvas_size)
|
||||||
: custom_canvas_size_(true), canvas_sz_(canvas_size) {}
|
: custom_canvas_size_(true), canvas_sz_(canvas_size) {}
|
||||||
|
|
||||||
void Update();
|
|
||||||
|
|
||||||
void DrawBackground(ImVec2 canvas_size = ImVec2(0, 0));
|
void DrawBackground(ImVec2 canvas_size = ImVec2(0, 0));
|
||||||
void UpdateContext();
|
void UpdateContext();
|
||||||
void DrawGrid(float grid_step = 64.0f);
|
void DrawGrid(float grid_step = 64.0f);
|
||||||
|
|||||||
@@ -21,5 +21,5 @@ bool InputHexShort(const char* label, int* data) {
|
|||||||
ImGuiInputTextFlags_CharsHexadecimal);
|
ImGuiInputTextFlags_CharsHexadecimal);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Gui
|
} // namespace gui
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace gui {
|
|||||||
IMGUI_API bool InputHex(const char* label, int* data);
|
IMGUI_API bool InputHex(const char* label, int* data);
|
||||||
IMGUI_API bool InputHexShort(const char* label, int* data);
|
IMGUI_API bool InputHexShort(const char* label, int* data);
|
||||||
|
|
||||||
} // namespace Gui
|
} // namespace gui
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Submodule src/lib/SDL updated: dd2e318211...198d62d813
@@ -34,20 +34,10 @@ target_include_directories(
|
|||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
yaze_test
|
yaze_test
|
||||||
absl::strings
|
|
||||||
absl::flags
|
|
||||||
absl::status
|
|
||||||
absl::statusor
|
|
||||||
absl::failure_signal_handler
|
|
||||||
absl::examine_stack
|
|
||||||
absl::stacktrace
|
|
||||||
absl::base
|
|
||||||
absl::config
|
|
||||||
absl::core_headers
|
|
||||||
absl::raw_logging_internal
|
|
||||||
SDL2::SDL2
|
SDL2::SDL2
|
||||||
|
${ABSL_TARGETS}
|
||||||
${OPENGL_LIBRARIES}
|
${OPENGL_LIBRARIES}
|
||||||
asar-static
|
${CMAKE_DL_LIBS}
|
||||||
gmock_main
|
gmock_main
|
||||||
gmock
|
gmock
|
||||||
gtest_main
|
gtest_main
|
||||||
|
|||||||
Reference in New Issue
Block a user