Skip to content

Commit

Permalink
fixes for function params and grid serialization (monome#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
scanner-darkly authored Sep 14, 2023
1 parent d1de34e commit cd7de54
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/ops/delay.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ static bool delay_common_add(scene_state_t *ss, exec_state_t *es,
ss->delay.time[i] = delay_time;
ss->delay.origin_script[i] = es_variables(es)->script_number;
ss->delay.origin_i[i] = es_variables(es)->i;
ss->delay.origin_fparam1[i] = es_variables(es)->fparam1;
ss->delay.origin_fparam2[i] = es_variables(es)->fparam2;
copy_command(&ss->delay.commands[i], post_command);

return true;
Expand Down
14 changes: 11 additions & 3 deletions src/scene_serialization.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,15 @@ void deserialize_scene(tt_deserializer_t* stream, scene_state_t* scene,
}
else if (c == 'P') { s2 = STATE_PATTERNS; }
else if (c == 'G') {
grid_state = grid_num = grid_count = 0;
grid_state = grid_count = 0;
s2 = STATE_GRID;
}
else {
script = c - 49;
if (script < 0 || script >= EDITABLE_SCRIPT_COUNT) {
script = NO_SCRIPT;
}
else { s2 = STATE_SCRIPT; }
s2 = STATE_SCRIPT;
}

l = 0;
Expand All @@ -225,7 +225,9 @@ void deserialize_scene(tt_deserializer_t* stream, scene_state_t* scene,
}

if (s == STATE_SCRIPT) {
if (script < 0 || script >= EDITABLE_SCRIPT_COUNT) continue;
if (script == NO_SCRIPT || script < 0 ||
script >= EDITABLE_SCRIPT_COUNT)
continue;

if (c != '\n') {
if (p < 32) {
Expand Down Expand Up @@ -328,6 +330,12 @@ void deserialize_scene(tt_deserializer_t* stream, scene_state_t* scene,
}
}
else if (grid_state == 1) {
if (c >= '0' && c <= '9') {
grid_num = c - '0';
grid_state = 2;
}
}
else if (grid_state == 2) {
if (c >= '0' && c <= '9') {
grid_num = grid_num * 10 + c - '0';
}
Expand Down
2 changes: 2 additions & 0 deletions src/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ typedef struct {
int16_t time[DELAY_SIZE];
uint8_t origin_script[DELAY_SIZE];
int16_t origin_i[DELAY_SIZE];
int16_t origin_fparam1[DELAY_SIZE];
int16_t origin_fparam2[DELAY_SIZE];
uint8_t count;
} scene_delay_t;

Expand Down
2 changes: 2 additions & 0 deletions src/teletype.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ void tele_tick(scene_state_t *ss, uint8_t time) {
es_variables(&es)->delayed = true;
es_variables(&es)->script_number = ss->delay.origin_script[i];
es_variables(&es)->i = ss->delay.origin_i[i];
es_variables(&es)->fparam1 = ss->delay.origin_fparam1[i];
es_variables(&es)->fparam2 = ss->delay.origin_fparam2[i];

run_script_with_exec_state(ss, &es, DELAY_SCRIPT);

Expand Down

0 comments on commit cd7de54

Please sign in to comment.