Skip to content

Commit

Permalink
Add a Rom Memory view and defrag operation.
Browse files Browse the repository at this point in the history
1) Rom Memory viewer show which segments of rom are owned by maps,
sideview areas and free space.
2) Defrag re-packs maps to try to get a more optimal arrangement in the
known static maps regions.
3) Move the fragment of code in bank3's keepout to a specific set of
unused bytes in bank3.  Moving the code to this particular location
allows easier management of freespace.
  • Loading branch information
Chris Frantz committed May 5, 2019
1 parent 3ab4dec commit 5a8489e
Show file tree
Hide file tree
Showing 12 changed files with 600 additions and 7 deletions.
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ cc_library(
"//imwidget:palace_gfx",
"//imwidget:palette",
"//imwidget:project",
"//imwidget:rom_memory",
"//imwidget:simplemap",
"//imwidget:start_values",
"//imwidget:text_table",
Expand Down
6 changes: 6 additions & 0 deletions app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ void Z2Edit::Init() {
misc_hacks_.reset(new z2util::MiscellaneousHacks);
palace_gfx_.reset(new z2util::PalaceGraphics);
palette_editor_.reset(new z2util::PaletteEditor);
rom_memory_.reset(new z2util::RomMemory);
start_values_.reset(new z2util::StartValues);
text_table_.reset(new z2util::TextTableEditor);
tile_transform_.reset(new z2util::TileTransform);
Expand Down Expand Up @@ -126,6 +127,8 @@ void Z2Edit::LoadPostProcess(int movekeepout) {
palace_gfx_->Refresh();
palette_editor_->set_mapper(mapper_.get());
palette_editor_->Refresh();
rom_memory_->set_mapper(mapper_.get());
rom_memory_->Refresh();
start_values_->set_mapper(mapper_.get());
start_values_->Refresh();
text_table_->set_mapper(mapper_.get());
Expand Down Expand Up @@ -1105,6 +1108,8 @@ void Z2Edit::Draw() {
&chrview_->visible());
ImGui::MenuItem("Object Table", nullptr,
&object_table_->visible());
ImGui::MenuItem("Rom Memory", nullptr,
&rom_memory_->visible());
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Help")) {
Expand Down Expand Up @@ -1135,6 +1140,7 @@ void Z2Edit::Draw() {
misc_hacks_->Draw();
palace_gfx_->Draw();
palette_editor_->Draw();
rom_memory_->Draw();
hwpal_->Draw();
chrview_->Draw();
drops_->Draw();
Expand Down
2 changes: 2 additions & 0 deletions app.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "imwidget/palace_gfx.h"
#include "imwidget/palette.h"
#include "imwidget/project.h"
#include "imwidget/rom_memory.h"
#include "imwidget/simplemap.h"
#include "imwidget/start_values.h"
#include "imwidget/text_table.h"
Expand Down Expand Up @@ -92,6 +93,7 @@ class Z2Edit: public ImApp {
std::unique_ptr<z2util::MiscellaneousHacks> misc_hacks_;
std::unique_ptr<z2util::PalaceGraphics> palace_gfx_;
std::unique_ptr<z2util::PaletteEditor> palette_editor_;
std::unique_ptr<z2util::RomMemory> rom_memory_;
std::unique_ptr<z2util::StartValues> start_values_;
std::unique_ptr<z2util::TextTableEditor> text_table_;
std::unique_ptr<z2util::TileTransform> tile_transform_;
Expand Down
19 changes: 19 additions & 0 deletions content/misc.textpb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@ misc {
{ bank: 5 address: 0xbb15 length: 0xe0 },
{ bank: 0 address: 0 length: 0 }
]
# Preferred location for the code in the keepout area.
bank3_code_move: { bank:3 address: 0x84da }
vanilla_overworld: [
{ bank:1 address: 0x905c length: 801},
{ bank:1 address: 0xa64c length: 743},
{ bank:2 address: 0x9046 length: 794},
{ bank:2 address: 0xa64c length: 743}
]

static_regions: [
{ bank: 1 address: 0x8ca0 length: 1757 },
{ bank: 1 address: 0xa31e length: 1557 },
{ bank: 2 address: 0x8ca0 length: 1728 },
{ bank: 2 address: 0xa31e length: 1557 },
{ bank: 3 address: 0x8ca0 length: 1888 },
{ bank: 4 address: 0x8ca0 length: 1888 },
{ bank: 5 address: 0x834e length: 386 },
{ bank: 5 address: 0x861f length: 252 }
]

enemy_pointer: [
{ address: 0x85a1 },
Expand Down
14 changes: 14 additions & 0 deletions imwidget/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,17 @@ cc_library(
"//external:imgui",
],
)

cc_library(
name = "rom_memory",
hdrs = ["rom_memory.h"],
srcs = ["rom_memory.cc"],
deps = [
":base",
":glbitmap",
"//nes:mappers",
"//external:imgui",
"//external:gflags",
],
)

4 changes: 2 additions & 2 deletions imwidget/glbitmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ void GLBitmap::Box(int x, int y, int w, int h, uint32_t color) {

void GLBitmap::FilledBox(int x, int y, int w, int h, uint32_t color) {
if (x >= width_ || y >= height_) return;
if (x+w >= width_) w = width_ - x - 1;
if (y+h >= height_) h = height_ - y - 1;
if (x+w > width_) w = width_ - x;
if (y+h > height_) h = height_ - y;
color |= 0xFF000000;

int ww = width_ - w;
Expand Down
Loading

0 comments on commit 5a8489e

Please sign in to comment.