diff --git a/src/app/rom.cc b/src/app/rom.cc index 393ac375..b47a0110 100644 --- a/src/app/rom.cc +++ b/src/app/rom.cc @@ -202,6 +202,26 @@ absl::StatusOr ROM::Load2BppGraphics() { return sheet; } +absl::Status ROM::LoadLinkGraphics() { + const auto link_gfx_offset = 0x80000; + const auto link_gfx_length = 0x500; + + // Load Links graphics from the ROM + for (int i = 0; i < 14; i++) { + ASSIGN_OR_RETURN( + auto link_sheet_data, + ReadByteVector(/*offset=*/link_gfx_offset + (i * link_gfx_length), + /*length=*/link_gfx_length)) + auto link_sheet_8bpp = gfx::SnesTo8bppSheet(link_sheet_data, /*bpp=*/4); + link_graphics_[i].Create(core::kTilesheetWidth, core::kTilesheetHeight, + core::kTilesheetDepth, link_sheet_8bpp); + link_graphics_[i].ApplyPalette(link_palette_); + RenderBitmap(&link_graphics_[i]); + } + + return absl::OkStatus(); +} + absl::Status ROM::LoadAllGraphicsData() { Bytes sheet; bool bpp3 = false; diff --git a/src/app/rom.h b/src/app/rom.h index d306d449..e9f46df1 100644 --- a/src/app/rom.h +++ b/src/app/rom.h @@ -167,6 +167,8 @@ class ROM { */ absl::StatusOr Load2BppGraphics(); + absl::Status LoadLinkGraphics(); + /** * This function iterates over all graphics sheets in the ROM and loads them * into memory. Depending on the sheet's index, it may be uncompressed or @@ -474,6 +476,8 @@ class ROM { Z3_Version version_ = Z3_Version::US; gfx::BitmapTable graphics_bin_; + gfx::BitmapTable link_graphics_; + gfx::SNESPalette link_palette_; PaletteGroupMap palette_groups_; std::stack> changes_;