Fix DungeonMap ScreenEditor gfx bug, update formatting

This commit is contained in:
scawful
2024-11-10 09:55:07 -05:00
parent 744ad03be3
commit 89a8e47e9c
2 changed files with 28 additions and 27 deletions

View File

@@ -124,13 +124,13 @@ absl::Status ScreenEditor::LoadDungeonMaps() {
int ptr, int ptr,
rom()->ReadWord(zelda3::screen::kDungeonMapRoomsPtr + (d * 2))); rom()->ReadWord(zelda3::screen::kDungeonMapRoomsPtr + (d * 2)));
ASSIGN_OR_RETURN( ASSIGN_OR_RETURN(
int ptrGFX, int ptr_gfx,
rom()->ReadWord(zelda3::screen::kDungeonMapRoomsPtr + (d * 2))); rom()->ReadWord(zelda3::screen::kDungeonMapGfxPtr + (d * 2)));
ptr |= 0x0A0000; // Add bank to the short ptr ptr |= 0x0A0000; // Add bank to the short ptr
ptrGFX |= 0x0A0000; // Add bank to the short ptr ptr_gfx |= 0x0A0000; // Add bank to the short ptr
int pcPtr = core::SnesToPc(ptr); // Contains data for the next 25 rooms int pc_ptr = core::SnesToPc(ptr); // Contains data for the next 25 rooms
int pcPtrGFX = int pc_ptr_gfx =
core::SnesToPc(ptrGFX); // Contains data for the next 25 rooms core::SnesToPc(ptr_gfx); // Contains data for the next 25 rooms
ASSIGN_OR_RETURN( ASSIGN_OR_RETURN(
ushort bossRoomD, ushort bossRoomD,
@@ -162,12 +162,12 @@ absl::Status ScreenEditor::LoadDungeonMaps() {
for (int j = 0; j < 25; j++) { for (int j = 0; j < 25; j++) {
// rdata[j] = 0x0F; // rdata[j] = 0x0F;
gdata[j] = 0xFF; gdata[j] = 0xFF;
rdata[j] = rom()->data()[pcPtr + j + (i * 25)]; // Set the rooms rdata[j] = rom()->data()[pc_ptr + j + (i * 25)]; // Set the rooms
if (rdata[j] == 0x0F) { if (rdata[j] == 0x0F) {
gdata[j] = 0xFF; gdata[j] = 0xFF;
} else { } else {
gdata[j] = rom()->data()[pcPtrGFX++]; gdata[j] = rom()->data()[pc_ptr_gfx++];
} }
std::string label = core::UppercaseHexByte(rdata[j]); std::string label = core::UppercaseHexByte(rdata[j]);
@@ -188,19 +188,19 @@ absl::Status ScreenEditor::LoadDungeonMaps() {
absl::Status ScreenEditor::SaveDungeonMaps() { absl::Status ScreenEditor::SaveDungeonMaps() {
for (int d = 0; d < 14; d++) { for (int d = 0; d < 14; d++) {
int ptr = zelda3::screen::kDungeonMapRoomsPtr + (d * 2); int ptr = zelda3::screen::kDungeonMapRoomsPtr + (d * 2);
int ptrGFX = zelda3::screen::kDungeonMapGfxPtr + (d * 2); int ptr_gfx = zelda3::screen::kDungeonMapGfxPtr + (d * 2);
int pcPtr = core::SnesToPc(ptr); int pc_ptr = core::SnesToPc(ptr);
int pcPtrGFX = core::SnesToPc(ptrGFX); int pc_ptr_gfx = core::SnesToPc(ptr_gfx);
const int nbr_floors = dungeon_maps_[d].nbr_of_floor; const int nbr_floors = dungeon_maps_[d].nbr_of_floor;
const int nbr_basements = dungeon_maps_[d].nbr_of_basement; const int nbr_basements = dungeon_maps_[d].nbr_of_basement;
for (int i = 0; i < nbr_floors + nbr_basements; i++) { for (int i = 0; i < nbr_floors + nbr_basements; i++) {
for (int j = 0; j < 25; j++) { for (int j = 0; j < 25; j++) {
RETURN_IF_ERROR(rom()->WriteByte(pcPtr + j + (i * 25), RETURN_IF_ERROR(rom()->WriteByte(pc_ptr + j + (i * 25),
dungeon_maps_[d].floor_rooms[i][j])); dungeon_maps_[d].floor_rooms[i][j]));
RETURN_IF_ERROR(rom()->WriteByte(pcPtrGFX + j + (i * 25), RETURN_IF_ERROR(rom()->WriteByte(pc_ptr_gfx + j + (i * 25),
dungeon_maps_[d].floor_gfx[i][j])); dungeon_maps_[d].floor_gfx[i][j]));
pcPtrGFX++; pc_ptr_gfx++;
} }
} }
} }
@@ -240,6 +240,8 @@ absl::Status ScreenEditor::LoadDungeonMapTile16() {
if (tile16_individual_.count(i) == 0) { if (tile16_individual_.count(i) == 0) {
auto tile = tile16_sheet_.GetTile16(i); auto tile = tile16_sheet_.GetTile16(i);
tile16_individual_[i] = tile; tile16_individual_[i] = tile;
RETURN_IF_ERROR(tile16_individual_[i].ApplyPalette(
*rom()->mutable_dungeon_palette(3)));
Renderer::GetInstance().RenderBitmap(&tile16_individual_[i]); Renderer::GetInstance().RenderBitmap(&tile16_individual_[i]);
} }
} }
@@ -261,15 +263,13 @@ void ScreenEditor::DrawDungeonMapsTabs() {
if (ImGui::BeginTabItem(tab_name.c_str())) { if (ImGui::BeginTabItem(tab_name.c_str())) {
floor_number = i; floor_number = i;
// screen_canvas_.LoadCustomLabels(dungeon_map_labels_[selected_dungeon]);
// screen_canvas_.set_current_labels(floor_number);
screen_canvas_.DrawBackground(ImVec2(325, 325)); screen_canvas_.DrawBackground(ImVec2(325, 325));
screen_canvas_.DrawTileSelector(64.f); screen_canvas_.DrawTileSelector(64.f);
auto boss_room = current_dungeon.boss_room; auto boss_room = current_dungeon.boss_room;
for (int j = 0; j < 25; j++) { for (int j = 0; j < 25; j++) {
if (current_dungeon.floor_rooms[floor_number][j] != 0x0F) { if (current_dungeon.floor_rooms[floor_number][j] != 0x0F) {
int tile16_id = current_dungeon.floor_rooms[floor_number][j]; int tile16_id = current_dungeon.floor_gfx[floor_number][j];
int posX = ((j % 5) * 32); int posX = ((j % 5) * 32);
int posY = ((j / 5) * 32); int posY = ((j / 5) * 32);
@@ -290,6 +290,8 @@ void ScreenEditor::DrawDungeonMapsTabs() {
std::string label = std::string label =
dungeon_map_labels_[selected_dungeon][floor_number][j]; dungeon_map_labels_[selected_dungeon][floor_number][j];
screen_canvas_.DrawText(label, (posX * 2), (posY * 2)); screen_canvas_.DrawText(label, (posX * 2), (posY * 2));
std::string gfx_id = core::UppercaseHexByte(tile16_id);
screen_canvas_.DrawText(gfx_id, (posX * 2), (posY * 2) + 16);
} }
} }
@@ -327,13 +329,13 @@ void ScreenEditor::DrawDungeonMapsTabs() {
} }
// Add Basement Button // Add Basement Button
if (ImGui::Button("Add Basement", ImVec2(100, 0)) && if (ImGui::Button("Add Basement", ImVec2(110, 0)) &&
current_dungeon.nbr_of_basement < 8) { current_dungeon.nbr_of_basement < 8) {
current_dungeon.nbr_of_basement++; current_dungeon.nbr_of_basement++;
dungeon_map_labels_[selected_dungeon].emplace_back(); dungeon_map_labels_[selected_dungeon].emplace_back();
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("Remove Basement", ImVec2(100, 0)) && if (ImGui::Button("Remove Basement", ImVec2(110, 0)) &&
current_dungeon.nbr_of_basement > 0) { current_dungeon.nbr_of_basement > 0) {
current_dungeon.nbr_of_basement--; current_dungeon.nbr_of_basement--;
dungeon_map_labels_[selected_dungeon].pop_back(); dungeon_map_labels_[selected_dungeon].pop_back();

View File

@@ -25,12 +25,11 @@ constexpr int kDungeonMapTile16Expanded = 0x109010; // $21:9010
// 14 words values 0x000F = no boss // 14 words values 0x000F = no boss
constexpr int kDungeonMapBossRooms = 0x56807; constexpr int kDungeonMapBossRooms = 0x56807;
constexpr int kTriforceVertices = 0x04FFD2; // group of 3, X, Y ,Z constexpr int kTriforceVertices = 0x04FFD2; // group of 3, X, Y ,Z
constexpr int TriforceFaces = 0x04FFE4; // group of 5 constexpr int kTriforceFaces = 0x04FFE4; // group of 5
constexpr int crystalVertices = 0x04FF98; constexpr int kCrystalVertices = 0x04FF98;
class DungeonMap { struct DungeonMap {
public:
unsigned short boss_room = 0xFFFF; unsigned short boss_room = 0xFFFF;
unsigned char nbr_of_floor = 0; unsigned char nbr_of_floor = 0;
unsigned char nbr_of_basement = 0; unsigned char nbr_of_basement = 0;