From d5351c4580ade2780c8355a2d3a8a4d017f4562a Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Fri, 22 Mar 2024 22:24:45 -0700 Subject: [PATCH] set BB player mag color at char creation time --- src/ItemParameterTable.hh | 9 +++++---- src/SaveFileFormats.cc | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/ItemParameterTable.hh b/src/ItemParameterTable.hh index 70b58ca4..50ed23d4 100644 --- a/src/ItemParameterTable.hh +++ b/src/ItemParameterTable.hh @@ -607,12 +607,13 @@ private: class MagEvolutionTable { public: struct TableOffsets { - /* 00 / 0400 */ le_uint32_t unknown_a1; // -> [offset -> (0xC-byte struct)[0x53], offset -> (same as first offset)] - /* 04 / 0408 */ le_uint32_t unknown_a2; // -> (2-byte struct, or single word)[0x53] + // num_mags = 0x53 in BB, 0x43 in V3 + /* 00 / 0400 */ le_uint32_t unknown_a1; // -> [offset -> (0xC-byte struct)[num_mags], offset -> (same as first offset)] + /* 04 / 0408 */ le_uint32_t unknown_a2; // -> (2-byte struct, or single word)[num_mags] /* 08 / 04AE */ le_uint32_t unknown_a3; // -> (0xA8 bytes; possibly (8-byte struct)[0x15]) - /* 0C / 0556 */ le_uint32_t unknown_a4; // -> (uint8_t)[0x53] + /* 0C / 0556 */ le_uint32_t unknown_a4; // -> (uint8_t)[num_mags] /* 10 / 05AC */ le_uint32_t unknown_a5; // -> (float)[0x48] - /* 14 / 06CC */ le_uint32_t evolution_number; // -> (uint8_t)[0x53] + /* 14 / 06CC */ le_uint32_t evolution_number; // -> (uint8_t)[num_mags] } __attribute__((packed)); struct EvolutionNumberTable { diff --git a/src/SaveFileFormats.cc b/src/SaveFileFormats.cc index 18d5ba38..b59ef3a1 100644 --- a/src/SaveFileFormats.cc +++ b/src/SaveFileFormats.cc @@ -356,6 +356,31 @@ shared_ptr PSOBBCharacterFile::create_from_config( for (size_t z = 0; z < initial_items.size(); z++) { ret->inventory.items[z] = initial_items[z]; } + + // Set mag color based on initial costume + static const array, 12> mag_colors = {{ + {0x09, 0x01, 0x02, 0x11, 0x0A, 0x05, 0x06, 0x0B, 0x05, 0x00, 0x07, 0x0B, 0x0C, 0x04, 0x05, 0x06, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x01, 0x02, 0x11, 0x04, 0x05, 0x06, 0x08, 0x11, 0x0D, 0x01, 0x02, 0x0C, 0x04, 0x05, 0x06, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x01, 0x02, 0x11, 0x04, 0x0E, 0x06, 0x01, 0x0E, 0x09, 0x07, 0x02, 0x11, 0x04, 0x05, 0x06, 0x04, 0x11, 0x0D, 0x01, 0x0B, 0x11, 0x0D, 0x05, 0x06}, + {0x00, 0x01, 0x0B, 0x11, 0x04, 0x05, 0x06, 0x0F, 0x05, 0x09, 0x07, 0x02, 0x11, 0x04, 0x05, 0x0F, 0x06, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x01, 0x0B, 0x11, 0x0A, 0x05, 0x06, 0x06, 0x09, 0x09, 0x01, 0x02, 0x11, 0x0A, 0x0E, 0x06, 0x01, 0x04, 0x0D, 0x07, 0x01, 0x0C, 0x0A, 0x05, 0x06}, + {0x10, 0x07, 0x02, 0x11, 0x0A, 0x05, 0x0A, 0x00, 0x07, 0x00, 0x01, 0x08, 0x11, 0x04, 0x09, 0x0F, 0x0D, 0x02, 0x0A, 0x07, 0x02, 0x0C, 0x04, 0x0E, 0x0E}, + {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x10, 0x01, 0x00, 0x07, 0x02, 0x0C, 0x04, 0x05, 0x06, 0x10, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x0D, 0x01, 0x02, 0x11, 0x04, 0x05, 0x06, 0x00, 0x11, 0x08, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x04, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x10, 0x05, 0x09, 0x01, 0x0B, 0x0C, 0x04, 0x05, 0x06, 0x0E, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x01, 0x02, 0x0C, 0x04, 0x05, 0x0F, 0x0A, 0x04, 0x0D, 0x01, 0x08, 0x11, 0x04, 0x05, 0x0F, 0x05, 0x10, 0x10, 0x07, 0x02, 0x0B, 0x0A, 0x0A, 0x0F}, + {0x00, 0x01, 0x0B, 0x0C, 0x04, 0x05, 0x06, 0x08, 0x0A, 0x0D, 0x07, 0x02, 0x11, 0x0A, 0x05, 0x06, 0x01, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x07, 0x02, 0x11, 0x04, 0x05, 0x06, 0x09, 0x0C, 0x00, 0x01, 0x02, 0x11, 0x0D, 0x05, 0x10, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + }}; + uint8_t char_class = (visual.char_class > 0x0B) ? 0 : visual.char_class; + uint8_t mag_color_index; + if (char_class == 2 || char_class == 4 || char_class == 5 || char_class == 9) { + mag_color_index = (visual.skin >= 25) ? 0 : visual.skin.load(); + } else { + mag_color_index = (visual.costume >= 18) ? 0 : visual.costume.load(); + } + ret->inventory.items[2].data.data2[3] = mag_colors.at(char_class).at(mag_color_index); + ret->inventory.items[13].extension_data2 = 1; const auto& config = (ret->disp.visual.class_flags & 0x80) ? config_force : config_hunter_ranger;