Repository navigation
Conversation
| f = None | ||
| for s in smp: | ||
| if vrom_pos+len(s.data) > vrom_size: | ||
| if len(s.data) > vrom_size: |
There was a problem hiding this comment.
Instead of leaving all that logic in the for loop you could put this in a method and name it accordingly.
| if isinstance(s, adpcm_a) and len(s.data) > 0x100000: | ||
| error("ADPCM-A sample '%s' is larger than one 1 MiB page" % s.name) | ||
| while True: | ||
| # ADPCM-A start and inclusive end addresses must share a 1 MiB page. |
There was a problem hiding this comment.
This comment comes from the fact that the code is not self contained and named properly
| @@ -0,0 +1,80 @@ | |||
| """Regression tests for ADPCM sample placement and generated V-ROM data.""" | |||
There was a problem hiding this comment.
This looks AI generated. vromtool doesn't have tests but good to have
| vromtool.allocate_samples(samples, 2 * PAGE, "sampleX.rom") | ||
| self.assertEqual([s.start for s in samples], [0, PAGE - 0x100, PAGE]) | ||
|
|
||
| def test_adpcm_b_can_cross_page(self): |
There was a problem hiding this comment.
This is not needed! The pagination issue only concerns ADPCM-A.
|
|
||
|
|
||
| class SampleAllocationTests(unittest.TestCase): | ||
| def test_adpcm_a_crossing_page_moves_to_next_page(self): |
There was a problem hiding this comment.
That should be the only test in this test class if the owner of the library wants it. The rest is testing random vromtool features and out of scope for this ticket. They should land in a separate ticket.
| sample(vromtool.adpcm_a, "next", 0x100)] | ||
| vromtool.allocate_samples(samples, 2 * PAGE, "sampleX.rom") | ||
| self.assertEqual([s.start for s in samples], [0, PAGE, PAGE + 0x2300]) | ||
| for s in samples: |
There was a problem hiding this comment.
This for loop is not needed it is redundant with the line above
| if vrom_pos+len(s.data) > vrom_size: | ||
| if len(s.data) > vrom_size: | ||
| error("Sample '%s' is larger than one VROM" % s.name) | ||
| while True: |
There was a problem hiding this comment.
Besides event driven work I never had to write a while true.
|
I am dubious of your solution! It should be built on top of the work that will go in the main branch here |
|
Closed via #180 |
Closes #174.
Depends on #176, which is still open. This branch includes its existing commit
52e14de5so page placement builds on identical-sample sharing; that commit retains its original authorship.Move each new ADPCM-A sample to the next 1 MiB page when its inclusive end would cross the page containing its start. Duplicate samples reuse the already aligned location. An explicit capacity condition advances to the next V-ROM when page padding no longer fits. Reject samples larger than a V-ROM or ADPCM-A samples larger than a page.
Six focused ADPCM-A regressions pass with Python 3.14 and PyYAML (
python -m unittest discover -s tests -v). They cover the reported earthquake offsets together with duplicate sharing, exact page endings, ROM rollover, impossible allocations, generated padding/sample bytes, and ASM addresses. The boundary and ROM-padding cases verify that the placement change neither discards nor misplaces sample data.The platform cross-compiler/example build and hardware or emulator playback were not run locally.