diff --git a/src/app/core/constants.h b/src/app/core/constants.h index a5e37676..ce96be82 100644 --- a/src/app/core/constants.h +++ b/src/app/core/constants.h @@ -142,23 +142,9 @@ constexpr float kYazeVersion = 0.2; // Magic numbers // ============================================================================ -/// Bit set for object priority -constexpr ushort TilePriorityBit = 0x2000; - -/// Bit set for object hflip -constexpr ushort TileHFlipBit = 0x4000; - -/// Bit set for object vflip -constexpr ushort TileVFlipBit = 0x8000; - -/// Bits used for tile name -constexpr ushort TileNameMask = 0x03FF; - -constexpr int Uncompressed3BPPSize = 0x0600; constexpr int UncompressedSheetSize = 0x0800; constexpr int NumberOfRooms = 296; - constexpr int NumberOfColors = 3143; // ============================================================================ @@ -179,15 +165,6 @@ constexpr int kTilesheetWidth = 128; constexpr int kTilesheetHeight = 32; constexpr int kTilesheetDepth = 8; -// TEXT EDITOR RELATED CONSTANTS -constexpr int gfx_font = 0x70000; // 2bpp format -constexpr int text_data = 0xE0000; -constexpr int text_data2 = 0x75F40; -constexpr int pointers_dictionaries = 0x74703; -constexpr int characters_width = 0x74ADF; - -constexpr int entrance_gfx_group = 0x5D97; - // ============================================================================ // Gravestones related variables // ============================================================================ @@ -218,7 +195,6 @@ static const std::string RoomEffect[] = {"Nothing", "Ganon's Darkness"}; static const std::string RoomTag[] = {"Nothing", - "NW Kill Enemy to Open", "NE Kill Enemy to Open", "SW Kill Enemy to Open", @@ -287,18 +263,6 @@ static const std::string RoomTag[] = {"Nothing", "Light Torches for Chest", "Kill Boss Again"}; -static const std::string SecretItemNames[] = { - "Nothing", "Green Rupee", "Rock hoarder", "Bee", "Health pack", - "Bomb", "Heart ", "Blue Rupee", - - "Key", "Arrow", "Bomb", "Heart", "Magic", - "Full Magic", "Cucco", "Green Soldier", "Bush Stal", "Blue Soldier", - - "Landmine", "Heart", "Fairy", "Heart", - "Nothing ", // 22 - - "Hole", "Warp", "Staircase", "Bombable", "Switch"}; - static const std::string TileTypeNames[] = { "$00 Nothing (standard floor)", "$01 Collision", diff --git a/src/app/gfx/snes_tile.cc b/src/app/gfx/snes_tile.cc index 6974134a..f123bce3 100644 --- a/src/app/gfx/snes_tile.cc +++ b/src/app/gfx/snes_tile.cc @@ -9,6 +9,18 @@ namespace yaze { namespace app { namespace gfx { +// Bit set for object priority +constexpr ushort TilePriorityBit = 0x2000; + +// Bit set for object hflip +constexpr ushort TileHFlipBit = 0x4000; + +// Bit set for object vflip +constexpr ushort TileVFlipBit = 0x8000; + +// Bits used for tile name +constexpr ushort TileNameMask = 0x03FF; + tile8 UnpackBppTile(const Bytes& data, const uint32_t offset, const uint32_t bpp) { tile8 tile; @@ -337,28 +349,28 @@ uint16_t TileInfoToShort(TileInfo tile_info) { uint16_t value = 0; // vhopppcc cccccccc if (tile_info.over_) { - value |= core::TilePriorityBit; + value |= TilePriorityBit; } if (tile_info.horizontal_mirror_) { - value |= core::TileHFlipBit; + value |= TileHFlipBit; } if (tile_info.vertical_mirror_) { - value |= core::TileVFlipBit; + value |= TileVFlipBit; } value |= (uint16_t)((tile_info.palette_ << 10) & 0x1C00); - value |= (uint16_t)(tile_info.id_ & core::TileNameMask); + value |= (uint16_t)(tile_info.id_ & TileNameMask); return value; } TileInfo GetTilesInfo(uint16_t tile) { // vhopppcc cccccccc - uint16_t tid = (uint16_t)(tile & core::TileNameMask); + uint16_t tid = (uint16_t)(tile & TileNameMask); uint8_t p = (uint8_t)((tile >> 10) & 0x07); - bool o = ((tile & core::TilePriorityBit) == core::TilePriorityBit); - bool h = ((tile & core::TileHFlipBit) == core::TileHFlipBit); - bool v = ((tile & core::TileVFlipBit) == core::TileVFlipBit); + bool o = ((tile & TilePriorityBit) == TilePriorityBit); + bool h = ((tile & TileHFlipBit) == TileHFlipBit); + bool v = ((tile & TileVFlipBit) == TileVFlipBit); return TileInfo(tid, p, v, h, o); } diff --git a/src/app/rom.cc b/src/app/rom.cc index d64fa41c..6fbc30ae 100644 --- a/src/app/rom.cc +++ b/src/app/rom.cc @@ -29,6 +29,17 @@ namespace yaze { namespace app { +constexpr int Uncompressed3BPPSize = 0x0600; +constexpr int kEntranceGfxGroup = 0x5D97; + +int Rom::GetGraphicsAddress(const uchar* data, uint8_t addr) { + auto part_one = data[version_constants().kOverworldGfxPtr1 + addr] << 16; + auto part_two = data[version_constants().kOverworldGfxPtr2 + addr] << 8; + auto part_three = data[version_constants().kOverworldGfxPtr3 + addr]; + auto snes_addr = (part_one | part_two | part_three); + return core::SnesToPc(snes_addr); +} + absl::StatusOr Rom::Load2BppGraphics() { Bytes sheet; const uint8_t sheets[] = {113, 114, 218, 219, 220, 221}; @@ -77,9 +88,9 @@ absl::Status Rom::LoadAllGraphicsData() { for (int i = 0; i < kNumGfxSheets; i++) { if (i >= 115 && i <= 126) { // uncompressed sheets - sheet.resize(core::Uncompressed3BPPSize); + sheet.resize(Uncompressed3BPPSize); auto offset = GetGraphicsAddress(data(), i); - for (int j = 0; j < core::Uncompressed3BPPSize; j++) { + for (int j = 0; j < Uncompressed3BPPSize; j++) { sheet[j] = rom_data_[j + offset]; } bpp3 = true; @@ -207,9 +218,9 @@ absl::Status Rom::LoadFromPointer(uchar* data, size_t length) { "Could not load ROM: parameter `data` is empty."); for (int i = 0; i < length; ++i) rom_data_.push_back(data[i]); - + size_ = length; - + // Copy ROM title constexpr uint32_t kTitleStringOffset = 0x7FC0; constexpr uint32_t kTitleStringLength = 20; @@ -221,7 +232,7 @@ absl::Status Rom::LoadFromPointer(uchar* data, size_t length) { } RETURN_IF_ERROR(gfx::LoadAllPalettes(rom_data_, palette_groups_)); LoadGfxGroups(); - + // Set is_loaded_ flag and return success is_loaded_ = true; @@ -384,8 +395,7 @@ void Rom::LoadGfxGroups() { for (int i = 0; i < 82; i++) { for (int j = 0; j < 4; j++) { - room_blockset_ids[i][j] = - rom_data_[core::entrance_gfx_group + (i * 4) + j]; + room_blockset_ids[i][j] = rom_data_[kEntranceGfxGroup + (i * 4) + j]; } } @@ -417,8 +427,7 @@ void Rom::SaveGroupsToRom() { 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]; + rom_data_[kEntranceGfxGroup + (i * 4) + j] = room_blockset_ids[i][j]; } } diff --git a/src/app/rom.h b/src/app/rom.h index 4f96eb14..37cfc58d 100644 --- a/src/app/rom.h +++ b/src/app/rom.h @@ -203,27 +203,6 @@ class Rom : public core::ExperimentFlags { */ absl::Status SaveAllPalettes(); - /** - * @brief Updates a color in a specified palette group. - * - * This function updates the color at the specified `colorIndex` in the - * palette at `palette_index` within the palette group with the given - * `group_name`. If the group, palette, or color indices are invalid, an error - * is returned. - * - * @param group_name The name of the palette group to update. - * @param palette_index The index of the palette within the group to update. - * @param colorIndex The index of the color within the palette to update. - * @param newColor The new color value to set. - * - * @return An `absl::Status` indicating whether the update was successful. - * Returns `absl::OkStatus()` if successful, or an error status if the - * group, palette, or color indices are invalid. - */ - absl::Status UpdatePaletteColor(const std::string& group_name, - size_t palette_index, size_t colorIndex, - const gfx::SnesColor& newColor); - // Read functions absl::StatusOr ReadByte(int offset) { if (offset >= rom_data_.size()) { @@ -433,13 +412,7 @@ class Rom : public core::ExperimentFlags { return kVersionConstantsMap.at(version_); } - int GetGraphicsAddress(const uchar* data, uint8_t addr) const { - auto part_one = data[version_constants().kOverworldGfxPtr1 + addr] << 16; - auto part_two = data[version_constants().kOverworldGfxPtr2 + addr] << 8; - auto part_three = data[version_constants().kOverworldGfxPtr3 + addr]; - auto snes_addr = (part_one | part_two | part_three); - return core::SnesToPc(snes_addr); - } + int GetGraphicsAddress(const uchar* data, uint8_t addr); auto palette_group() { return palette_groups_; } auto mutable_palette_group() { return &palette_groups_; }