add save gfx groups

This commit is contained in:
scawful
2024-05-28 17:09:09 -04:00
parent 387ef551b6
commit 2d383d0243
5 changed files with 45 additions and 38 deletions

View File

@@ -257,6 +257,10 @@ absl::Status Rom::SaveToFile(bool backup, bool save_new, std::string filename) {
RETURN_IF_ERROR(SaveAllPalettes());
}
if (flags()->kSaveGfxGroups) {
SaveGroupsToRom();
}
if (save_new) {
// Create a file of the same name and append the date between the filename
// and file extension
@@ -335,6 +339,39 @@ absl::Status Rom::SaveAllPalettes() {
return absl::OkStatus();
}
void Rom::SaveGroupsToRom() {
int gfxPointer =
(rom_data_[kGfxGroupsPointer + 1] << 8) + rom_data_[kGfxGroupsPointer];
gfxPointer = core::SnesToPc(gfxPointer);
for (int i = 0; i < 37; i++) {
for (int j = 0; j < 8; j++) {
rom_data_[gfxPointer + (i * 8) + j] = main_blockset_ids[i][j];
}
}
for (int i = 0; i < 82; i++) {
for (int j = 0; j < 4; j++) {
rom_data_[core::entrance_gfx_group + (i * 4) + j] =
room_blockset_ids[i][j];
}
}
for (int i = 0; i < 144; i++) {
for (int j = 0; j < 4; j++) {
rom_data_[version_constants().kSpriteBlocksetPointer + (i * 4) + j] =
spriteset_ids[i][j];
}
}
for (int i = 0; i < 72; i++) {
for (int j = 0; j < 4; j++) {
rom_data_[version_constants().kDungeonPalettesGroups + (i * 4) + j] =
paletteset_ids[i][j];
}
}
}
std::shared_ptr<Rom> SharedRom::shared_rom_ = nullptr;
} // namespace app