Repository navigation
Follow-ups to #198 and #199: BGI fonts and embedded-fonts, dotted music pauses, RIS and CSI = Ps M - #200
Merged
Conversation
The .CHR fonts under palette_screen_buffer/bgi/fonts were compiled in with include_bytes!, so a build without embedded-fonts still carried about 125 KB of them. They now go through font_bytes! like the fonts under data/fonts. A font that does not load is Font::empty(), which draws nothing, instead of a panic on Font::load(&[]).unwrap().
A dotted pause was stored as Pause(tempo * length * 2 / 3) and played for 240000 / that, so the two integer divisions rounded it differently from a dotted note: T97 P1. lasted 3750 ms instead of 3711, and T121 P4. 745 ms instead of 743. Pause now carries the dotted flag like PlayNote, and both last 240000 / (tempo * length) ms, or 360000 / (tempo * length) dotted.
ESC c reset the music state that carries over between strings, but not the introducers CSI = Ps M picked, so after CSI = 0 M an RIS left CSI M and CSI N off for the rest of the session. AnsiParser now keeps the option set_music_option configured and returns to it on RIS. The icy_engine call sites that assigned the music_option field directly use set_music_option instead.
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.
These are three small fixes to #198 (embedder API) and #199 (CTerm conformance) that I found while moving enig-term onto master. Each is its own commit with its own test, and each test fails without its change.
cargo test -p icy_engine -p icy_parser_corepasses, and so do the icy_engine lib tests with--no-default-features. With the feature off, 49 icy_engine integration tests that need the bundled fonts fail, the same 49 as on master.cargo fmt --checkis clean, clippy has no new warnings in icy_engine, icy_parser_core or icy_engine_gui (with and without default features), andcargo check --workspacepasses.Let the BGI stroke fonts follow embedded-fonts
The BGI
.CHRstroke fonts underpalette_screen_buffer/bgi/fontsare not underdata/fonts, so #198'sembedded-fontsfeature missed them: they were still compiled in withinclude_bytes!, about 125 KB, in a--no-default-featuresbuild.They now go through
font_bytes!like the other font data. With the feature off,Font::load(&[])fails, so instead of unwrapping it the font list falls back to a newFont::empty(), which has no characters and draws nothing.bgi_fonts_absent_do_not_panic(feature off only) resolves everyFontTypeand checks it is an empty font. I also checked the build: a 48-byte sample from GOTH.CHR, SANS.CHR and BOLD.CHR is inlibicy_engine.rlibbefore the change and gone after it.Make a dotted ANSI music pause 1.5 times as long as a plain one
A dotted pause was stored as
Pause(tempo * length * 2 / 3)and played for240000 / thatms. The two integer divisions round differently from a dotted note's360000 / (tempo * length), so at some tempos the pause and the note didn't match:T97 P1.lasted 3750 ms instead of 3711, andT121 P4.745 ms instead of 743.MusicAction::Pausenow carries a dotted flag likePlayNote, andget_durationhandles both the same way. This changes the shape of a public enum, so an embedder matchingPause(len)needsPause(len, dotted)orPause(..); the one match in icy_engine_gui is updated. If you'd rather keepPause(i32)as it is, the other option I saw was storing the duration in ms, which I liked less.test_dotted_pause_lasts_one_and_a_half_times_as_longchecks the T97 and T121 values above, and then for every tempo (32 to 255) and length (1 to 64) that a pause and a note last 240000 / (tempo * length) ms, or 360000 / (tempo * length) dotted. Note durations are unchanged.Restore the configured music option on RIS
RIS resets the music state that carries over between strings, but not the introducers
CSI = Ps Mpicked. AfterCSI = 0 M, anESC cleftCSI MandCSI Noff for the rest of the session.AnsiParser now remembers the option
set_music_optionconfigured and returns to it on RIS. The three icy_engine call sites that assigned themusic_optionfield directly now callset_music_option, so RIS returns to what they set. The field is still public; its doc points to the setter.test_ris_restores_the_configured_music_optionchecks that RIS undoesCSI = 0 M, and that afterset_music_option(Banana)andCSI = 2 M, RIS returns to Banana andCSI Mis Delete Line again.