housekeeping
This commit is contained in:
@@ -19,7 +19,7 @@ int AddressFromBytes(uint8_t addr1, uint8_t addr2, uint8_t addr3) {
|
||||
}
|
||||
|
||||
// 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 value;
|
||||
int ceiling = length - 1;
|
||||
|
||||
@@ -119,7 +119,8 @@ void OverworldEditor::DrawToolset() {
|
||||
if (ImGui::Button(ICON_MD_UPDATE)) {
|
||||
overworld_.Load(rom_, tile16_blockset_bmp_.GetData(),
|
||||
current_gfx_bmp_.GetData());
|
||||
tile16_blockset_bmp_.CreateTexture(rom_.Renderer());
|
||||
|
||||
current_gfx_bmp_.CreateTexture(rom_.Renderer());
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
@@ -197,6 +198,18 @@ void OverworldEditor::DrawOverworldCanvas() {
|
||||
overworld_map_canvas_.DrawBackground();
|
||||
overworld_map_canvas_.UpdateContext();
|
||||
overworld_map_canvas_.DrawGrid(64.f);
|
||||
if (overworld_.isLoaded()) {
|
||||
// overworld_map_canvas_.GetDrawList()->AddImage(
|
||||
// (void *)overworld_.GetOverworldMap(0).GetBitmap().GetTexture(),
|
||||
// ImVec2(overworld_map_canvas_.GetZeroPoint().x + 2,
|
||||
// overworld_map_canvas_.GetZeroPoint().y + 2),
|
||||
// ImVec2(
|
||||
// overworld_map_canvas_.GetZeroPoint().x +
|
||||
// (overworld_.GetOverworldMap(0).GetBitmap().GetWidth() * 2),
|
||||
// overworld_map_canvas_.GetZeroPoint().y +
|
||||
// (overworld_.GetOverworldMap(0).GetBitmap().GetHeight() *
|
||||
// 2)));
|
||||
}
|
||||
overworld_map_canvas_.DrawOverlay();
|
||||
}
|
||||
|
||||
@@ -286,9 +299,8 @@ void OverworldEditor::DrawAreaGraphics() {
|
||||
void OverworldEditor::LoadGraphics() {
|
||||
rom_.LoadAllGraphicsData();
|
||||
graphics_bin_ = rom_.GetGraphicsBin();
|
||||
|
||||
tile16_blockset_bmp_.Create(128, 8192, 8, 1048576);
|
||||
current_gfx_bmp_.Create(128, 512, 8, 32768);
|
||||
tile16_blockset_bmp_.Create(128 * 2, 8192 * 2, 8, 1048576);
|
||||
current_gfx_bmp_.Create(128 * 2, 512 * 2, 8, 32768);
|
||||
}
|
||||
|
||||
} // namespace editor
|
||||
|
||||
@@ -19,7 +19,6 @@ void Overworld::Load(ROM &rom, uchar *ow_blockset, uchar *current_gfx) {
|
||||
overworld_maps_.emplace_back(i, rom_, tiles16);
|
||||
}
|
||||
FetchLargeMaps();
|
||||
LoadOverworldMap();
|
||||
|
||||
auto size = tiles16.size();
|
||||
for (int i = 0; i < core::NumberOfOWMaps; i++) {
|
||||
@@ -217,27 +216,6 @@ void Overworld::FetchLargeMaps() {
|
||||
}
|
||||
}
|
||||
|
||||
void Overworld::LoadOverworldMap() {
|
||||
overworld_map_bmp_.Create(128, 128, 8, 0x40000);
|
||||
auto ptr = overworld_map_bmp_.GetData();
|
||||
|
||||
int pos = 0;
|
||||
for (int sy = 0; sy < 16; sy++) {
|
||||
for (int sx = 0; sx < 16; sx++) {
|
||||
for (int y = 0; y < 8; y++) {
|
||||
for (int x = 0; x < 8; x++) {
|
||||
auto position = x + (sx * 8) + (y * 128) + (sy * 1024);
|
||||
ptr[position] = rom_.data()[0x0C4000 + pos];
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto renderer = rom_.Renderer();
|
||||
overworld_map_bmp_.CreateTexture(renderer);
|
||||
}
|
||||
|
||||
} // namespace zelda3
|
||||
} // namespace app
|
||||
} // namespace yaze
|
||||
@@ -22,6 +22,8 @@ class Overworld {
|
||||
public:
|
||||
void Load(ROM &rom, uchar *ow_blockset, uchar *current_gfx);
|
||||
auto GetTiles16() const { return tiles16; }
|
||||
auto GetOverworldMap(uint index) { return overworld_maps_[index]; }
|
||||
auto isLoaded() const { return is_loaded_; }
|
||||
|
||||
private:
|
||||
const int map32address[4] = {core::map32TilesTL, core::map32TilesTR,
|
||||
@@ -40,7 +42,6 @@ class Overworld {
|
||||
int sx, int sy, int tpos);
|
||||
void DecompressAllMapTiles();
|
||||
void FetchLargeMaps();
|
||||
void LoadOverworldMap();
|
||||
|
||||
int game_state_ = 1;
|
||||
uchar map_parent_[160];
|
||||
@@ -49,9 +50,6 @@ class Overworld {
|
||||
ROM rom_;
|
||||
OWMapTiles map_tiles_;
|
||||
|
||||
gfx::Bitmap current_gfx_bmp_;
|
||||
gfx::Bitmap overworld_map_bmp_;
|
||||
|
||||
std::vector<gfx::Tile16> tiles16;
|
||||
std::vector<gfx::Tile32> tiles32;
|
||||
std::vector<gfx::Tile32> map16tiles;
|
||||
|
||||
@@ -101,8 +101,6 @@ void OverworldMap::LoadAreaInfo() {
|
||||
sprite_palette_[1] = z3data[core::overworldSpritePalette + parent_ + 128];
|
||||
sprite_palette_[2] = z3data[core::overworldSpritePalette + parent_ + 128];
|
||||
}
|
||||
|
||||
std::cout << "Loading header for overworld area #" << index_ << std::endl;
|
||||
}
|
||||
|
||||
void OverworldMap::BuildMap(int count, int game_state, uchar* map_parent,
|
||||
@@ -150,8 +148,6 @@ void OverworldMap::BuildMap(int count, int game_state, uchar* map_parent,
|
||||
CopyTile8bpp16((x * 16), (y * 16), tiles_used_[xt][yt], ow_blockset);
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Finished building overworld map #" << index_ << std::endl;
|
||||
}
|
||||
|
||||
void OverworldMap::BuildTileset(int game_state, uchar* current_gfx) {
|
||||
@@ -210,8 +206,7 @@ void OverworldMap::BuildTileset(int game_state, uchar* current_gfx) {
|
||||
static_graphics_[7] = 91;
|
||||
}
|
||||
|
||||
uchar* current_map_gfx_tile8_data = current_gfx;
|
||||
uchar const* all_gfx_data = rom_.GetMasterGraphicsBin();
|
||||
auto all_gfx_data = rom_.GetMasterGraphicsBin();
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
for (int j = 0; j < 2048; j++) {
|
||||
@@ -224,8 +219,9 @@ void OverworldMap::BuildTileset(int game_state, uchar* current_gfx) {
|
||||
mapByte += 0x88;
|
||||
break;
|
||||
}
|
||||
|
||||
// Upload used gfx data
|
||||
current_map_gfx_tile8_data[(i * 2048) + j] = mapByte;
|
||||
current_gfx[(i * 2048) + j] = mapByte;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,15 +22,15 @@ class OverworldMap {
|
||||
void BuildMap(int count, int game_state, uchar* map_parent,
|
||||
uchar* ow_blockset, uchar* current_gfx, OWMapTiles& map_tiles);
|
||||
|
||||
auto GetBitmap() { return bitmap_; }
|
||||
auto SetLargeMap(bool is_set) { large_map_ = is_set; }
|
||||
auto IsLargeMap() { return large_map_; }
|
||||
auto GetBitmap() { return bitmap_; }
|
||||
|
||||
private:
|
||||
void LoadAreaInfo();
|
||||
void BuildTileset(int game_state, uchar* current_gfx);
|
||||
void BuildTiles16Gfx(int count, uchar* ow_blockset);
|
||||
|
||||
|
||||
void CopyTile(int x, int y, int xx, int yy, int offset, gfx::TileInfo tile,
|
||||
uchar* gfx16Pointer, uchar* gfx8Pointer);
|
||||
|
||||
@@ -51,12 +51,12 @@ class OverworldMap {
|
||||
uchar sprite_palette_[3];
|
||||
uchar area_music_[4];
|
||||
uchar static_graphics_[16];
|
||||
gfx::Bitmap bitmap_;
|
||||
uchar* gfxPtr = new uchar[512 * 512];
|
||||
|
||||
bool initialized_ = false;
|
||||
bool large_map_ = false;
|
||||
|
||||
gfx::Bitmap bitmap_;
|
||||
|
||||
std::vector<gfx::Tile16> tiles16_;
|
||||
std::vector<std::vector<ushort>> tiles_used_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user