Repository navigation
Two profiles: 50 fps, or 25 fps with 22 kHz and 25 kHz sound - #12
Merged
Merged
Conversation
The app chooses at compile time how the ST's time is shared between the frame copy and the sound (APP_PROFILE, rp/src/include/profile.h): PROFILE_50FPS, the default, keeps a frame every VBL with the YM at 5,585 Hz and the DMA chip at 12,517 Hz; PROFILE_25FPS takes a frame every second VBL, on every machine, and plays the YM at 21,943 Hz (Timer-B count 28) and the DMA chip at 25,033 Hz. On a plain ST the full-screen copy and 22 kHz sound then take about 35 ms of each 40 ms frame. The ST image is the same for both: fb_init() writes the profile into shared slot 8, and userfw reads it once at boot for Timer-B's count, the DMA chip's mode and lead, and the VBLs a frame (it takes a new frame no sooner than that many VBLs after the last, counted by its VBL handler). The constants of both profiles are named on both sides and checked by test_layout.py; APP_PROFILE comes from the environment through CMake, and a 25 fps build's ID ends in +25fps (flash.sh builds it in its own folder). The audio buffer grows to 4 KB (YM slices of 1 KB: 878 bytes a VBL at 21,943 Hz), the DMA ring to 4 KB at $6F000 with its position reported by 16 bytes; APP_FREE starts at $FA5180. YM sources (.YMS files, the jingle) stay at 5,585 Hz and are resampled to the output's rate. The two outputs' FIFOs share their memory, which keeps the 25 fps debug build within the RP's RAM. test_audio_dma.c runs under both profiles. The ST's stopwatch replaces the slack report, which used the same Timer-A: TIME_STUDY = 1 in userfw.s (off by default) runs Timer-A free at 4.07 us a tick, counts its wraps with an interrupt, and reports the VBL and four points of the loop on one timeline ($FB8B/8C/8F). Debug builds keep the points and the slack before the VBL that may start the next frame; tools/dev/swd.py stopwatch reads them. Measured: Mega ST at 25 fps, the copy with 22 kHz sound takes 29.9 ms and leaves 9.75 ms before the next frame (8.9 with the mouse moved flat out, no IKBD error); Mega STE at 25 fps plays the DMA chip at 25 kHz. At 50 fps both machines behave as before.
What each profile trades, how to choose it (APP_PROFILE) and what was measured, in CLAUDE.md, the README (with the audio section's rates and the FIFO), the skill and the changelog; the moved audio buffer, DMA ring and APP_FREE; the stopwatch in place of the slack report, and swd.py stopwatch in the dev tools' README.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A compile-time choice for the app between two ways of sharing the ST's time between the frame copy and the sound (
APP_PROFILE,rp/src/include/profile.h):PROFILE_50FPS(default)PROFILE_25FPSfb_init()writes the profile into shared slot 8 ($FA4030), anduserfwreads it once at boot. From it, the ST sets Timer-B's count, the DMA chip's mode and lead, and the VBLs per frame. A new frame is taken no sooner than that many VBLs after the last one. The constants of both profiles are named on both sides, andtest_layout.pychecks that they agree.$6F000, with its position reported by 16 bytes.APP_FREEnow starts at$FA5180(about 12.4 KB)..YMSfiles, the built-in jingle) stay at 5,585 Hz and are resampled to the output rate.+25fps, andtools/dev/flash.shbuilds it in its own folder. Both examples' CMake files passAPP_PROFILEon.TIME_STUDY = 1inuserfw.s, off by default: Timer-A runs free at 4.07 µs per tick.$FB8B/$FB8C/$FB8F).tools/dev/swd.py stopwatchprints them.Tests
make -C tests/host testpasses.test_audio_dma.cis built and run under both profiles, andtest_layout.pychecks the constants of both.