Proposal: Commander ($
) operator and utils.
#77
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.
Preface:
The other day I was watching this tutorial featured in the OrcaJS repo, and I found out that adjusting the BPM programmatically (as seen here) wasn't an option, so I decided to try and implement that, along with some of the other features from the commander interface.
I haven't programmed anything in C beyond some
"hello world"
stuff (I come from a JS background) and this PR is the result of reverse engineering the really comprehensible code written in this repo + some web search 😄 .Changes:
Menu
Crtl + G
command to show operators.Implemented Orca
commander
interface:State (
state.h
):State
*, it savesbpm
,tick_num
,is_playing
and*oosc_dev
(that one is still a TODO).* This abstraction was necessary to change
is_playing
via reference pointer (without abstracting the wholeGed
struct). It could still be implemented without struct nesting, changing the type ofis_playing
toint
and leaving everything inside of theGed
struct intact (this could maybe favor performance, but I don't know how much the performance is affected currently by passing a struct vs passing each value individually by reference).Commander (
commander.h
,commander.c
,sim.h
,sim.c
,cli_main.c
,symisc.c
):parse_command(Glyph command, State state)
method. This implementation adds the following commands:play
,run
,stop
,bpm:num
,frame:num
,rewind:num
andskip:num
. It usesstrtok
to obtain tokens,strcmp
to compare strings andstrtoul
to parse number values.parse_command
method.orca_run
now takesstate
as the only param related tobpm
,tick_num
,is_playing
andoosc_dev
.tool:
commander.c
to avoid linking errors.Caveats and considerations:
State
abstraction). This can be mitigated easily removing said abstraction and passing every single value by reference,skip
command).