add OverworldDebug menu
This commit is contained in:
@@ -30,6 +30,9 @@ class Overworld {
|
||||
auto GetCurrentGraphics() const {
|
||||
return overworld_maps_[current_map_].GetCurrentGraphics();
|
||||
}
|
||||
auto GetCurrentBitmapData() const {
|
||||
return overworld_maps_[current_map_].GetBitmapData();
|
||||
}
|
||||
auto isLoaded() const { return is_loaded_; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace zelda3 {
|
||||
namespace {
|
||||
|
||||
void CopyTile(int x, int y, int xx, int yy, int offset, gfx::TileInfo tile,
|
||||
uchar* ow_blockset, uchar* current_gfx) {
|
||||
Bytes& ow_blockset, Bytes& current_gfx) {
|
||||
int mx = x;
|
||||
int my = y;
|
||||
uchar r = 0;
|
||||
@@ -44,7 +44,7 @@ void CopyTile(int x, int y, int xx, int yy, int offset, gfx::TileInfo tile,
|
||||
ow_blockset[p2] = (uchar)(((pixel >> 4) & 0x0F) + tile.palette_ * 16);
|
||||
}
|
||||
|
||||
void CopyTile8bpp16(int x, int y, int tile, uchar* dest, uchar* src) {
|
||||
void CopyTile8bpp16(int x, int y, int tile, Bytes& dest, Bytes& src) {
|
||||
int src_pos = ((tile - ((tile / 8) * 8)) * 16) + ((tile / 8) * 2048);
|
||||
int dest_pos = (x + (y * 512));
|
||||
for (int yy = 0; yy < 16; yy++) {
|
||||
@@ -233,11 +233,15 @@ absl::Status OverworldMap::BuildTileset() {
|
||||
current_graphics_sheet_set[i] = sheet;
|
||||
}
|
||||
|
||||
auto allgfxData = rom_.GetGraphicsBuffer().data();
|
||||
all_gfx_ = rom_.GetGraphicsBuffer();
|
||||
current_gfx_.reserve(32768);
|
||||
for (int i = 0; i < 32768; i++) {
|
||||
current_gfx_.push_back(0x00);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
for (int j = 0; j < 2048; j++) {
|
||||
auto mapByte = allgfxData[j + (static_graphics_[i] * 2048)];
|
||||
auto mapByte = all_gfx_[j + (static_graphics_[i] * 2048)];
|
||||
switch (i) {
|
||||
case 0:
|
||||
case 3:
|
||||
@@ -256,6 +260,9 @@ absl::Status OverworldMap::BuildTileset() {
|
||||
|
||||
absl::Status OverworldMap::BuildTiles16Gfx(int count) {
|
||||
current_blockset_.reserve(1048576);
|
||||
for (int i = 0; i < 1048576; i++) {
|
||||
current_blockset_.push_back(0x00);
|
||||
}
|
||||
int offsets[] = {0, 8, 1024, 1032};
|
||||
auto yy = 0;
|
||||
auto xx = 0;
|
||||
@@ -278,13 +285,14 @@ absl::Status OverworldMap::BuildTiles16Gfx(int count) {
|
||||
case 3:
|
||||
info = tiles16_[i].tile3_;
|
||||
break;
|
||||
default:
|
||||
return absl::InternalError("Invalid 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, current_blockset_.data(),
|
||||
current_gfx_.data());
|
||||
CopyTile(x, y, xx, yy, offset, info, current_blockset_, current_gfx_);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -300,8 +308,11 @@ absl::Status OverworldMap::BuildTiles16Gfx(int count) {
|
||||
}
|
||||
|
||||
absl::Status OverworldMap::BuildBitmap(OWBlockset& world_blockset) {
|
||||
bitmap_.Create(512, 512, 8, 1048576);
|
||||
auto bitmap_ptr_ = bitmap_.GetData();
|
||||
bitmap_data_.reserve(262144);
|
||||
for (int i = 0; i < 262144; i++) {
|
||||
bitmap_data_.push_back(0x00);
|
||||
}
|
||||
|
||||
int superY = ((index_ - (world_ * 64)) / 8);
|
||||
int superX = index_ - (world_ * 64) - (superY * 8);
|
||||
|
||||
@@ -309,11 +320,10 @@ absl::Status OverworldMap::BuildBitmap(OWBlockset& world_blockset) {
|
||||
for (int x = 0; x < 32; x++) {
|
||||
auto xt = x + (superX * 32);
|
||||
auto yt = y + (superY * 32);
|
||||
CopyTile8bpp16((x * 16), (y * 16), world_blockset[xt][yt], bitmap_ptr_,
|
||||
current_blockset_.data());
|
||||
CopyTile8bpp16((x * 16), (y * 16), world_blockset[xt][yt], bitmap_data_,
|
||||
current_blockset_);
|
||||
}
|
||||
}
|
||||
rom_.RenderBitmap(bitmap_);
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,10 +28,11 @@ class OverworldMap {
|
||||
absl::Status BuildMap(int count, int game_state, int world, uchar* map_parent,
|
||||
OWBlockset& world_blockset);
|
||||
|
||||
auto GetBitmap() const { return bitmap_; }
|
||||
gfx::Bitmap& GetBitmap() { return bitmap_; }
|
||||
auto GetCurrentGraphicsSet() const { return current_graphics_sheet_set; }
|
||||
auto GetCurrentBlockset() const { return current_blockset_; }
|
||||
auto GetCurrentGraphics() const { return current_gfx_; }
|
||||
auto GetBitmapData() const { return bitmap_data_; }
|
||||
auto SetLargeMap(bool is_set) { large_map_ = is_set; }
|
||||
auto IsLargeMap() const { return large_map_; }
|
||||
auto IsInitialized() const { return initialized_; }
|
||||
@@ -62,8 +63,10 @@ class OverworldMap {
|
||||
bool large_map_ = false;
|
||||
|
||||
ROM rom_;
|
||||
Bytes all_gfx_;
|
||||
Bytes current_blockset_;
|
||||
Bytes current_gfx_;
|
||||
Bytes bitmap_data_;
|
||||
gfx::Bitmap bitmap_;
|
||||
OWMapTiles map_tiles_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user