Add FindMetastamp, etc housekeeping
This commit is contained in:
@@ -36,6 +36,7 @@ set(
|
||||
app/zelda3/sprite/sprite.cc
|
||||
app/zelda3/music/tracker.cc
|
||||
app/zelda3/dungeon/room.cc
|
||||
app/zelda3/dungeon/room_object.cc
|
||||
)
|
||||
|
||||
set(
|
||||
|
||||
@@ -15,6 +15,31 @@ namespace yaze {
|
||||
namespace app {
|
||||
namespace gfx {
|
||||
|
||||
void FindMetastamp() {
|
||||
int matching_position = -1;
|
||||
bool matched = false;
|
||||
Bytes cgx_rom;
|
||||
Bytes raw_data_;
|
||||
for (int i = 0;
|
||||
i < cgx_rom.size() - sizeof(kMatchedBytes) - kOffsetFromMatchedBytesEnd;
|
||||
i++) {
|
||||
raw_data_.push_back(cgx_rom[i]);
|
||||
bool is_match = std::equal(std::begin(kMatchedBytes),
|
||||
std::end(kMatchedBytes), &cgx_rom[i]);
|
||||
if (is_match) {
|
||||
matching_position = i;
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (matched) {
|
||||
int bpp_marker_position =
|
||||
matching_position + sizeof(kMatchedBytes) + kOffsetFromMatchedBytesEnd;
|
||||
int bpp_marker = cgx_rom[bpp_marker_position];
|
||||
std::string bpp_type = (bpp_marker == 0x31) ? "8bpp" : "4bpp";
|
||||
}
|
||||
}
|
||||
|
||||
absl::Status LoadCgx(uint8_t bpp, std::string_view filename,
|
||||
std::vector<uint8_t>& cgx_data,
|
||||
std::vector<uint8_t>& cgx_loaded,
|
||||
|
||||
@@ -46,6 +46,11 @@ struct CgxHeader {
|
||||
uint8_t color_path[0x100];
|
||||
};
|
||||
|
||||
constexpr uint16_t kMatchedBytes[] = {0x4E, 0x41, 0x4B, 0x31, 0x39, 0x38, 0x39};
|
||||
constexpr uint16_t kOffsetFromMatchedBytesEnd = 0x1D;
|
||||
|
||||
void FindMetastamp();
|
||||
|
||||
absl::Status LoadScr(std::string_view filename, uint8_t input_value,
|
||||
std::vector<uint8_t>& map_data);
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/rom.h"
|
||||
#include "app/gui/canvas.h"
|
||||
#include "app/rom.h"
|
||||
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
@@ -16,10 +17,10 @@ void Inventory::Create() {
|
||||
}
|
||||
PRINT_IF_ERROR(BuildTileset())
|
||||
for (int i = 0; i < 0x500; i += 0x08) {
|
||||
tiles_.push_back(gfx::GetTilesInfo(rom_.toint16(i + kBowItemPos)));
|
||||
tiles_.push_back(gfx::GetTilesInfo(rom_.toint16(i + kBowItemPos + 0x02)));
|
||||
tiles_.push_back(gfx::GetTilesInfo(rom_.toint16(i + kBowItemPos + 0x04)));
|
||||
tiles_.push_back(gfx::GetTilesInfo(rom_.toint16(i + kBowItemPos + 0x08)));
|
||||
tiles_.push_back(gfx::GetTilesInfo(rom()->toint16(i + kBowItemPos)));
|
||||
tiles_.push_back(gfx::GetTilesInfo(rom()->toint16(i + kBowItemPos + 0x02)));
|
||||
tiles_.push_back(gfx::GetTilesInfo(rom()->toint16(i + kBowItemPos + 0x04)));
|
||||
tiles_.push_back(gfx::GetTilesInfo(rom()->toint16(i + kBowItemPos + 0x08)));
|
||||
}
|
||||
const int offsets[] = {0x00, 0x08, 0x800, 0x808};
|
||||
auto xx = 0;
|
||||
@@ -63,13 +64,13 @@ void Inventory::Create() {
|
||||
}
|
||||
bitmap_.Create(256, 256, 128, data_);
|
||||
bitmap_.ApplyPalette(palette_);
|
||||
rom_.RenderBitmap(&bitmap_);
|
||||
rom()->RenderBitmap(&bitmap_);
|
||||
}
|
||||
|
||||
absl::Status Inventory::BuildTileset() {
|
||||
tilesheets_.reserve(6 * 0x2000);
|
||||
for (int i = 0; i < 6 * 0x2000; i++) tilesheets_.push_back(0xFF);
|
||||
ASSIGN_OR_RETURN(tilesheets_, rom_.Load2bppGraphics())
|
||||
ASSIGN_OR_RETURN(tilesheets_, rom()->Load2bppGraphics())
|
||||
Bytes test;
|
||||
for (int i = 0; i < 0x4000; i++) {
|
||||
test_.push_back(tilesheets_[i]);
|
||||
@@ -78,9 +79,9 @@ absl::Status Inventory::BuildTileset() {
|
||||
test_.push_back(tilesheets_[i]);
|
||||
}
|
||||
tilesheets_bmp_.Create(128, 0x130, 64, test_);
|
||||
palette_ = rom_.GetPaletteGroup("hud")[0];
|
||||
palette_ = rom()->GetPaletteGroup("hud")[0];
|
||||
tilesheets_bmp_.ApplyPalette(palette_);
|
||||
rom_.RenderBitmap(&tilesheets_bmp_);
|
||||
rom()->RenderBitmap(&tilesheets_bmp_);
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,8 @@ namespace zelda3 {
|
||||
constexpr int kInventoryStart = 0x6564A;
|
||||
constexpr int kBowItemPos = 0x6F631;
|
||||
|
||||
class Inventory {
|
||||
class Inventory : public SharedROM {
|
||||
public:
|
||||
void SetupROM(ROM& rom) { rom_ = rom; }
|
||||
auto Bitmap() const { return bitmap_; }
|
||||
auto Tilesheet() const { return tilesheets_bmp_; }
|
||||
auto Palette() const { return palette_; }
|
||||
@@ -26,8 +25,6 @@ class Inventory {
|
||||
private:
|
||||
absl::Status BuildTileset();
|
||||
|
||||
ROM rom_;
|
||||
|
||||
Bytes data_;
|
||||
gfx::Bitmap bitmap_;
|
||||
|
||||
|
||||
@@ -39,6 +39,13 @@ class Sprite {
|
||||
auto GetRealX() const { return bounding_box_.x; }
|
||||
auto GetRealY() const { return bounding_box_.y; }
|
||||
auto id() const { return id_; }
|
||||
auto x() const { return x_; }
|
||||
auto y() const { return y_; }
|
||||
auto nx() const { return nx_; }
|
||||
auto ny() const { return ny_; }
|
||||
auto layer() const { return layer_; }
|
||||
auto subtype() const { return subtype_; }
|
||||
auto& keyDrop() const { return key_drop_; }
|
||||
|
||||
auto Width() const { return bounding_box_.w; }
|
||||
auto Height() const { return bounding_box_.h; }
|
||||
@@ -47,6 +54,7 @@ class Sprite {
|
||||
private:
|
||||
Bytes current_gfx_;
|
||||
bool overworld_;
|
||||
|
||||
uchar map_id_;
|
||||
uchar id_;
|
||||
uchar x_;
|
||||
@@ -55,6 +63,10 @@ class Sprite {
|
||||
uchar ny_;
|
||||
uchar overlord_ = 0;
|
||||
std::string name_;
|
||||
|
||||
int subtype_;
|
||||
int layer_;
|
||||
|
||||
int map_x_;
|
||||
int map_y_;
|
||||
Bytes preview_gfx_;
|
||||
@@ -67,6 +79,7 @@ class Sprite {
|
||||
int width_ = 16;
|
||||
int height_ = 16;
|
||||
|
||||
int key_drop_;
|
||||
};
|
||||
|
||||
} // namespace zelda3
|
||||
|
||||
Reference in New Issue
Block a user