housekeeping and inventory menu

This commit is contained in:
scawful
2022-09-17 10:34:44 -05:00
parent 67a5f6bf68
commit a20b3fd240
17 changed files with 266 additions and 165 deletions

View File

@@ -8,22 +8,18 @@
namespace yaze {
namespace app {
namespace zelda3 {
void Inventory::Create(Bytes& all_gfx) {
void Inventory::Create() {
data_.reserve(256 * 256);
for (int i = 0; i < 256 * 256; i++) {
data_.push_back(0xFF);
}
PRINT_IF_ERROR(BuildTileset(all_gfx))
//tiles_.push_back(gfx::GetTilesInfo(rom_.toint16(kInventoryStart)));
tiles_.push_back(gfx::GetTilesInfo(rom_.toint16(kBowItemPos)));
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)));
PRINT_IF_ERROR(BuildTileset())
for (int i = 0; i < 0x400; 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)));
}
const int offsets[] = {0x00, 0x08, 0x800, 0x808};
auto xx = 0;
auto yy = 0;
@@ -49,15 +45,15 @@ void Inventory::Create(Bytes& all_gfx) {
int source = ypos + xpos + (x + (y * 0x80));
auto destination = xx + yy + offset + (mx + (my * 0x100));
data_[destination] = (tilesheets_[source] & 0x0F);
data_[destination] = (test_[source] & 0x0F) + tile.palette_ * 0x08;
}
}
if (i == 4) {
i = 0;
xx += 0x10;
if (xx >= 0x80) {
yy += 0x800;
if (xx >= 0x100) {
yy += 0x1000;
xx = 0;
}
} else {
@@ -65,15 +61,24 @@ void Inventory::Create(Bytes& all_gfx) {
}
}
bitmap_.Create(256, 256, 128, data_);
// bitmap_.ApplyPalette(rom_.GetPaletteGroup("hud")[0]);
bitmap_.ApplyPalette(palette_);
rom_.RenderBitmap(&bitmap_);
}
absl::Status Inventory::BuildTileset(Bytes& all_gfx) {
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())
tilesheets_bmp_.Create(128, 192 + 96 + 48 - 16, 64, tilesheets_);
Bytes test;
for (int i = 0; i < 0x4000; i++) {
test_.push_back(tilesheets_[i]);
}
for (int i = 0x8000; i < + 0x8000 + 0x2000; i++) {
test_.push_back(tilesheets_[i]);
}
tilesheets_bmp_.Create(128, 0x130, 64, test_);
palette_ = rom_.GetPaletteGroup("hud")[0];
tilesheets_bmp_.ApplyPalette(palette_);
rom_.RenderBitmap(&tilesheets_bmp_);
return absl::OkStatus();
}

View File

@@ -3,6 +3,7 @@
#include "app/gfx/bitmap.h"
#include "app/gfx/snes_tile.h"
#include "app/gfx/snes_palette.h"
#include "app/rom.h"
#include "gui/canvas.h"
@@ -11,7 +12,6 @@ namespace app {
namespace zelda3 {
constexpr int kInventoryStart = 0x6564A;
constexpr int kLampItemPos = 0x6F6F9;
constexpr int kBowItemPos = 0x6F631;
class Inventory {
@@ -19,11 +19,12 @@ class Inventory {
void SetupROM(ROM& rom) { rom_ = rom; }
auto Bitmap() const { return bitmap_; }
auto Tilesheet() const { return tilesheets_bmp_; }
auto Palette() const { return palette_; }
void Create(Bytes& all_gfx);
void Create();
private:
absl::Status BuildTileset(Bytes& all_gfx);
absl::Status BuildTileset();
ROM rom_;
@@ -31,7 +32,9 @@ class Inventory {
gfx::Bitmap bitmap_;
Bytes tilesheets_;
Bytes test_;
gfx::Bitmap tilesheets_bmp_;
gfx::SNESPalette palette_;
gui::Canvas canvas_;
std::vector<gfx::TileInfo> tiles_;