Add ROM::LoadLinkGraphics

This commit is contained in:
scawful
2023-10-26 10:26:54 -04:00
parent ce2ff06d60
commit 62e9b5f9f0
2 changed files with 24 additions and 0 deletions

View File

@@ -202,6 +202,26 @@ absl::StatusOr<Bytes> 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;

View File

@@ -167,6 +167,8 @@ class ROM {
*/
absl::StatusOr<Bytes> 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<std::function<void()>> changes_;