From d6a5598978cd6a49d0de2f28214fa498c9aa8d48 Mon Sep 17 00:00:00 2001 From: loveemu Date: Sat, 12 Jun 2021 20:46:11 +0900 Subject: [PATCH] Adjust the rules of the song scanner for GAX 2.2 (#22) --- src/gaxtapper/gax_song_header_v2.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gaxtapper/gax_song_header_v2.cpp b/src/gaxtapper/gax_song_header_v2.cpp index dec84f9..151d004 100644 --- a/src/gaxtapper/gax_song_header_v2.cpp +++ b/src/gaxtapper/gax_song_header_v2.cpp @@ -34,10 +34,12 @@ std::optional GaxSongHeaderV2::TryParse(std::string_view rom, s const agbsize_t sample_offset = to_offset(sample_address); if (sample_offset + 8 >= rom.size()) return std::nullopt; - if (const agbptr_t sample_ptr = ReadInt32L(&rom[sample_offset]); !is_romptr(sample_ptr)) - return std::nullopt; - if (const agbsize_t sample_size = ReadInt32L(&rom[sample_offset + 4]); sample_size != 0) - return std::nullopt; + if (const agbptr_t sample_ptr = ReadInt32L(&rom[sample_offset]); sample_ptr != 0) { + if (!is_romptr(sample_ptr)) return std::nullopt; + if (const agbsize_t sample_size = ReadInt32L(&rom[sample_offset + 4]); + sample_size != 0) + return std::nullopt; + } const std::uint16_t num_rows_per_pattern = ReadInt16L(&rom[offset + 2]); const std::uint16_t num_patterns_per_channel = ReadInt16L(&rom[offset + 4]);