housekeeping and inventory
This commit is contained in:
@@ -13,9 +13,18 @@ void Inventory::Create(Bytes& all_gfx) {
|
||||
for (int i = 0; i < 256 * 256; i++) {
|
||||
data_.push_back(0xFF);
|
||||
}
|
||||
BuildTileset(all_gfx);
|
||||
PRINT_IF_ERROR(BuildTileset(all_gfx))
|
||||
//tiles_.push_back(gfx::GetTilesInfo(rom_.toint16(kInventoryStart)));
|
||||
|
||||
tiles_.push_back(gfx::GetTilesInfo(rom_.toint16(kBowItemPos)));
|
||||
const int offsets[] = {0x00, 0x08, 0x200, 0x208};
|
||||
tiles_.push_back(gfx::GetTilesInfo(rom_.toint16(kBowItemPos + 0x02)));
|
||||
tiles_.push_back(gfx::GetTilesInfo(rom_.toint16(kBowItemPos + 0x04)));
|
||||
tiles_.push_back(gfx::GetTilesInfo(rom_.toint16(kBowItemPos + 0x08)));
|
||||
// tiles_.push_back(gfx::GetTilesInfo(rom_.toint16(kLampItemPos)));
|
||||
// tiles_.push_back(gfx::GetTilesInfo(rom_.toint16(kLampItemPos + 0x02)));
|
||||
// tiles_.push_back(gfx::GetTilesInfo(rom_.toint16(kLampItemPos + 0x04)));
|
||||
// tiles_.push_back(gfx::GetTilesInfo(rom_.toint16(kLampItemPos + 0x08)));
|
||||
const int offsets[] = {0x00, 0x08, 0x800, 0x808};
|
||||
auto xx = 0;
|
||||
auto yy = 0;
|
||||
|
||||
@@ -36,7 +45,7 @@ void Inventory::Create(Bytes& all_gfx) {
|
||||
}
|
||||
|
||||
int xpos = ((tile.id_ % 0x10) * 0x08);
|
||||
int ypos = (((tile.id_ / 0x10)) * 0x200);
|
||||
int ypos = (((tile.id_ / 0x10)) * 0x400);
|
||||
int source = ypos + xpos + (x + (y * 0x80));
|
||||
|
||||
auto destination = xx + yy + offset + (mx + (my * 0x100));
|
||||
@@ -44,39 +53,29 @@ void Inventory::Create(Bytes& all_gfx) {
|
||||
}
|
||||
}
|
||||
|
||||
xx += 0x10;
|
||||
if (xx >= 0x80) {
|
||||
yy += 0x800;
|
||||
xx = 0;
|
||||
}
|
||||
|
||||
if (i == 4) {
|
||||
i = 0;
|
||||
xx += 0x10;
|
||||
if (xx >= 0x80) {
|
||||
yy += 0x800;
|
||||
xx = 0;
|
||||
}
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
bitmap_.Create(256, 256, 128, data_);
|
||||
// bitmap_.ApplyPalette(rom_.GetPaletteGroup("hud")[0]);
|
||||
rom_.RenderBitmap(&bitmap_);
|
||||
}
|
||||
|
||||
void Inventory::BuildTileset(Bytes& all_gfx) {
|
||||
//const int offsets[] = {0xDC000, 0x6D900, 0x6EF00, 0x6F000, 0xD8000, 0xD9000};
|
||||
const int offsets[] = {0xDC000, 0x6D900, 0x6EF00, 0x6F000, 0xD8000, 0xD9000};
|
||||
tilesheets_.reserve(6 * 0x1000);
|
||||
for (int i = 0; i < 6 * 0x1000; i++) {
|
||||
tilesheets_.push_back(0xFF);
|
||||
}
|
||||
|
||||
for (int y = 0; y < 6; y++) {
|
||||
int offset = offsets[y];
|
||||
for (int x = 0; x < 0x1000; x++) {
|
||||
tilesheets_[x + (y * 0x1000)] = all_gfx[offset + x + (y * 0x1000)];
|
||||
}
|
||||
}
|
||||
|
||||
tilesheets_bmp_.Create(128, 192, 64, tilesheets_);
|
||||
absl::Status Inventory::BuildTileset(Bytes& all_gfx) {
|
||||
tilesheets_.reserve(6 * 0x2000);
|
||||
for (int i = 0; i < 6 * 0x2000; i++) tilesheets_.push_back(0xFF);
|
||||
ASSIGN_OR_RETURN(tilesheets_, rom_.Load2bppGraphics())
|
||||
tilesheets_bmp_.Create(128, 192 + 96 + 48 - 16, 64, tilesheets_);
|
||||
rom_.RenderBitmap(&tilesheets_bmp_);
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
} // namespace zelda3
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace yaze {
|
||||
namespace app {
|
||||
namespace zelda3 {
|
||||
|
||||
constexpr int kMenuGfxStart = 0xE000;
|
||||
constexpr int kLampItemPos = 0x6F6F0;
|
||||
constexpr int kInventoryStart = 0x6564A;
|
||||
constexpr int kLampItemPos = 0x6F6F9;
|
||||
constexpr int kBowItemPos = 0x6F631;
|
||||
|
||||
class Inventory {
|
||||
@@ -23,8 +23,7 @@ class Inventory {
|
||||
void Create(Bytes& all_gfx);
|
||||
|
||||
private:
|
||||
void BuildTileset(Bytes& all_gfx);
|
||||
|
||||
absl::Status BuildTileset(Bytes& all_gfx);
|
||||
|
||||
ROM rom_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user