From 8fa65805cf4a9784def3a8ce9520f3986c8f5f95 Mon Sep 17 00:00:00 2001 From: Ethan Date: Tue, 9 Jan 2024 01:46:25 +0900 Subject: [PATCH] Improve 'next' segment rom pos finding behavior --- src/splat/scripts/split.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/splat/scripts/split.py b/src/splat/scripts/split.py index 84179a76..6cd28e5a 100644 --- a/src/splat/scripts/split.py +++ b/src/splat/scripts/split.py @@ -56,10 +56,15 @@ def initialize_segments(config_segments: Union[dict, list]) -> List[Segment]: this_start = Segment.parse_segment_start(seg_yaml) - if i == len(config_segments) - 1 and Segment.parse_segment_file_path(seg_yaml): - next_start: Optional[int] = 0 - else: - next_start = Segment.parse_segment_start(config_segments[i + 1]) + j = i + 1 + while j < len(config_segments): + next_start = Segment.parse_segment_start(config_segments[j]) + if next_start is not None: + break + j += 1 + assert ( + next_start is not None + ), "Next segment address could not be found. Segments list must end with a rom end pos marker ([0x10000000])" if segment_class.is_noload(): # Pretend bss's rom address is after the last actual rom segment