BuildTileset upgrades
This commit is contained in:
@@ -7,7 +7,7 @@ namespace yaze {
|
|||||||
namespace app {
|
namespace app {
|
||||||
namespace zelda3 {
|
namespace zelda3 {
|
||||||
|
|
||||||
void Overworld::Load(ROM &rom, uchar *ow_blockset, uchar *current_gfx) {
|
void Overworld::Load(ROM &rom, uchar *ow_blockset) {
|
||||||
rom_ = rom;
|
rom_ = rom;
|
||||||
|
|
||||||
AssembleMap32Tiles();
|
AssembleMap32Tiles();
|
||||||
@@ -20,8 +20,9 @@ void Overworld::Load(ROM &rom, uchar *ow_blockset, uchar *current_gfx) {
|
|||||||
FetchLargeMaps();
|
FetchLargeMaps();
|
||||||
|
|
||||||
for (int i = 0; i < core::NumberOfOWMaps; i++) {
|
for (int i = 0; i < core::NumberOfOWMaps; i++) {
|
||||||
overworld_maps_[i].BuildMap(tiles16.size(), game_state_, map_parent_,
|
// overworld_maps_[i].BuildMap(tiles16.size(), game_state_, map_parent_,
|
||||||
ow_blockset, current_gfx, map_tiles_);
|
// ow_blockset, map_tiles_);
|
||||||
|
overworld_maps_[i].BuildMapV2(tiles16.size(), game_state_, map_parent_);
|
||||||
}
|
}
|
||||||
|
|
||||||
is_loaded_ = true;
|
is_loaded_ = true;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace zelda3 {
|
|||||||
|
|
||||||
class Overworld {
|
class Overworld {
|
||||||
public:
|
public:
|
||||||
void Load(ROM &rom, uchar *ow_blockset, uchar *current_gfx);
|
void Load(ROM &rom, uchar *ow_blockset);
|
||||||
auto GetTiles16() const { return tiles16; }
|
auto GetTiles16() const { return tiles16; }
|
||||||
auto GetOverworldMap(uint index) { return overworld_maps_[index]; }
|
auto GetOverworldMap(uint index) { return overworld_maps_[index]; }
|
||||||
auto isLoaded() const { return is_loaded_; }
|
auto isLoaded() const { return is_loaded_; }
|
||||||
|
|||||||
@@ -104,8 +104,7 @@ void OverworldMap::LoadAreaInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OverworldMap::BuildMap(int count, int game_state, uchar* map_parent,
|
void OverworldMap::BuildMap(int count, int game_state, uchar* map_parent,
|
||||||
uchar* ow_blockset, uchar* current_gfx,
|
uchar* ow_blockset, OWMapTiles& map_tiles) {
|
||||||
OWMapTiles& map_tiles) {
|
|
||||||
if (large_map_) {
|
if (large_map_) {
|
||||||
parent_ = map_parent[index_];
|
parent_ = map_parent[index_];
|
||||||
if (parent_ != index_ && !initialized_) {
|
if (parent_ != index_ && !initialized_) {
|
||||||
@@ -125,7 +124,7 @@ void OverworldMap::BuildMap(int count, int game_state, uchar* map_parent,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildTileset(game_state, current_gfx);
|
BuildTileset(game_state);
|
||||||
BuildTiles16Gfx(count, ow_blockset); // build on GFX.mapgfx16Ptr
|
BuildTiles16Gfx(count, ow_blockset); // build on GFX.mapgfx16Ptr
|
||||||
|
|
||||||
int world = 0;
|
int world = 0;
|
||||||
@@ -150,7 +149,30 @@ void OverworldMap::BuildMap(int count, int game_state, uchar* map_parent,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverworldMap::BuildTileset(int game_state, uchar* current_gfx) {
|
void OverworldMap::BuildMapV2(int count, int game_state, uchar* map_parent) {
|
||||||
|
if (large_map_) {
|
||||||
|
parent_ = map_parent[index_];
|
||||||
|
if (parent_ != index_ && !initialized_) {
|
||||||
|
if (index_ >= 0x80 && index_ <= 0x8A && index_ != 0x88) {
|
||||||
|
area_graphics_ =
|
||||||
|
rom_.data()[core::overworldSpecialGFXGroup + (parent_ - 128)];
|
||||||
|
area_palette_ = rom_.data()[core::overworldSpecialPALGroup + 1];
|
||||||
|
} else if (index_ == 0x88) {
|
||||||
|
area_graphics_ = 81;
|
||||||
|
area_palette_ = 0;
|
||||||
|
} else {
|
||||||
|
area_graphics_ = rom_.data()[core::mapGfx + parent_];
|
||||||
|
area_palette_ = rom_.data()[core::overworldMapPalette + parent_];
|
||||||
|
}
|
||||||
|
|
||||||
|
initialized_ = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildTileset(game_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
absl::Status OverworldMap::BuildTileset(int game_state) {
|
||||||
int index_world = 0x20;
|
int index_world = 0x20;
|
||||||
if (parent_ < 0x40) {
|
if (parent_ < 0x40) {
|
||||||
index_world = 0x20;
|
index_world = 0x20;
|
||||||
@@ -206,23 +228,11 @@ void OverworldMap::BuildTileset(int game_state, uchar* current_gfx) {
|
|||||||
static_graphics_[7] = 91;
|
static_graphics_[7] = 91;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto all_gfx_data = rom_.GetMasterGraphicsBin();
|
auto all_gfx_data = rom_.GetGraphicsBinV2();
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
for (int j = 0; j < 2048; j++) {
|
current_graphics_sheet_set[i] = all_gfx_data[static_graphics_[i]];
|
||||||
uchar mapByte = all_gfx_data[j + (static_graphics_[i] * 2048)];
|
|
||||||
switch (i) {
|
|
||||||
case 0:
|
|
||||||
case 3:
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
mapByte += 0x88;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Upload used gfx data
|
|
||||||
current_gfx[(i * 2048) + j] = mapByte;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverworldMap::BuildTiles16Gfx(int count, uchar* ow_blockset) {
|
void OverworldMap::BuildTiles16Gfx(int count, uchar* ow_blockset) {
|
||||||
@@ -258,6 +268,40 @@ void OverworldMap::BuildTiles16Gfx(int count, uchar* ow_blockset) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
absl::Status OverworldMap::BuildTiles16GfxV2(int count) {
|
||||||
|
auto gfx_tile8_data = 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return absl::OkStatus();
|
||||||
|
}
|
||||||
|
|
||||||
// map,current
|
// map,current
|
||||||
void OverworldMap::CopyTile(int x, int y, int xx, int yy, int offset,
|
void OverworldMap::CopyTile(int x, int y, int xx, int yy, int offset,
|
||||||
gfx::TileInfo tile, uchar* gfx16Pointer,
|
gfx::TileInfo tile, uchar* gfx16Pointer,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/status/status.h"
|
||||||
#include "app/core/common.h"
|
#include "app/core/common.h"
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
@@ -22,18 +23,24 @@ static constexpr int kTileOffsets[] = {0, 8, 4096, 4104};
|
|||||||
class OverworldMap {
|
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,
|
void BuildMap(int count, int game_state, uchar* map_parent,
|
||||||
uchar* ow_blockset, uchar* current_gfx, OWMapTiles& map_tiles);
|
uchar* ow_blockset, OWMapTiles& map_tiles);
|
||||||
|
|
||||||
|
void 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 SetLargeMap(bool is_set) { large_map_ = is_set; }
|
auto SetLargeMap(bool is_set) { large_map_ = is_set; }
|
||||||
auto IsLargeMap() { return large_map_; }
|
auto IsLargeMap() { return large_map_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void LoadAreaInfo();
|
void LoadAreaInfo();
|
||||||
void BuildTileset(int game_state, uchar* current_gfx);
|
|
||||||
void BuildTiles16Gfx(int count, uchar* ow_blockset);
|
void BuildTiles16Gfx(int count, uchar* ow_blockset);
|
||||||
|
|
||||||
|
absl::Status BuildTileset(int game_state);
|
||||||
|
absl::Status BuildTiles16GfxV2(int count);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
@@ -63,6 +70,8 @@ class OverworldMap {
|
|||||||
std::vector<gfx::Tile16> tiles16_;
|
std::vector<gfx::Tile16> tiles16_;
|
||||||
std::vector<std::vector<ushort>> tiles_used_;
|
std::vector<std::vector<ushort>> tiles_used_;
|
||||||
|
|
||||||
|
absl::flat_hash_map<int, gfx::Bitmap> current_graphics_sheet_set;
|
||||||
|
|
||||||
ROM rom_;
|
ROM rom_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user