|
|
@@ -35,6 +35,7 @@ static bool show_welcome_message; |
|
|
static const uint8_t D_INPUT = 1 << 0; |
|
|
static const uint8_t D_LIST = 1 << 1; |
|
|
static const uint8_t D_MESSAGE = 1 << 2; |
|
|
static const uint8_t D_VARS = 1 << 3; |
|
|
static const uint8_t D_ALL = 0xFF; |
|
|
static uint8_t dirty; |
|
|
|
|
|
@@ -45,6 +46,10 @@ static const uint8_t A_STACK = 1 << 3; |
|
|
static const uint8_t A_MUTES = 1 << 4; |
|
|
static uint8_t activity_prev; |
|
|
static uint8_t activity; |
|
|
static bool show_vars = false; |
|
|
static int16_t vars_prev[8]; |
|
|
char var_names[] = { 'A', 0, 'B', 0, 'C', 0, 'D', 0, |
|
|
'X', 0, 'Y', 0, 'Z', 0, 'T', 0 }; |
|
|
|
|
|
// teletype_io.h |
|
|
void tele_has_delays(bool has_delays) { |
|
|
@@ -80,6 +85,10 @@ void set_metro_icon(bool display) { |
|
|
activity &= ~A_METRO; |
|
|
} |
|
|
|
|
|
void set_vars_updated() { |
|
|
dirty |= D_VARS; |
|
|
} |
|
|
|
|
|
// main mode functions |
|
|
void init_live_mode() { |
|
|
status = E_OK; |
|
|
@@ -88,6 +97,9 @@ void init_live_mode() { |
|
|
activity_prev = 0xFF; |
|
|
history_top = -1; |
|
|
history_line = -1; |
|
|
for (int i = 0; i < 7; i++) |
|
|
var_names[i * 2 + 1] = 0; |
|
|
show_vars = false; |
|
|
} |
|
|
|
|
|
void set_live_mode() { |
|
|
@@ -164,6 +176,13 @@ void process_live_keys(uint8_t k, uint8_t m, bool is_held_key) { |
|
|
match_no_mod(m, k, HID_CLOSE_BRACKET)) { |
|
|
set_mode(M_EDIT); |
|
|
} |
|
|
// tilde: show the variables |
|
|
else if (match_no_mod(m, k, HID_TILDE)) { |
|
|
show_vars = !show_vars; |
|
|
if (show_vars) |
|
|
dirty |= D_VARS; // combined with this... |
|
|
dirty |= D_LIST; // cheap flag to indicate mode just switched |
|
|
} |
|
|
else { // pass the key though to the line editor |
|
|
bool processed = line_editor_process_keys(&le, k, m, is_held_key); |
|
|
if (processed) dirty |= D_INPUT; |
|
|
@@ -173,6 +192,7 @@ void process_live_keys(uint8_t k, uint8_t m, bool is_held_key) { |
|
|
|
|
|
bool screen_refresh_live() { |
|
|
bool screen_dirty = false; |
|
|
|
|
|
if (dirty & D_INPUT) { |
|
|
line_editor_draw(&le, '>', &line[7]); |
|
|
screen_dirty = true; |
|
|
@@ -211,8 +231,39 @@ bool screen_refresh_live() { |
|
|
dirty &= ~D_MESSAGE; |
|
|
} |
|
|
|
|
|
if (show_vars && ((dirty & D_VARS) || (dirty & D_LIST))) { |
|
|
int16_t* vp = &scene_state.variables.a; |
|
|
char s[8]; |
|
|
|
|
|
for (int i = 1; i < 6; i++) region_fill(&line[i], 0); |
|
|
|
|
|
bool changed = dirty & D_LIST; |
|
|
if (!changed) |
|
|
for (int i = 0; i < 8; i++) |
|
|
if (vp[i] != vars_prev[i]) { |
|
|
vars_prev[i] = vp[i]; |
|
|
changed = true; |
|
|
break; |
|
|
} |
|
|
|
|
|
if (changed) { |
|
|
for (int i = 0; i < 8; i++) { |
|
|
uint8_t x = (8 * (i % 4 + 1)) - 2; |
|
|
uint8_t y = 2 * (i / 4) + 1; |
|
|
// print header |
|
|
font_string_region_clip_right(&line[y], var_names + (i * 2), x * 4, 0, 0x1, 0); |
|
|
// print value |
|
|
itoa(vp[i], s, 10); |
|
|
font_string_region_clip_right(&line[y + 1], s, x * 4, 0, 0xf, 0); |
|
|
} |
|
|
screen_dirty = true; |
|
|
} |
|
|
dirty &= ~D_VARS; |
|
|
dirty &= ~D_LIST; |
|
|
} |
|
|
|
|
|
if (dirty & D_LIST) { |
|
|
for (int i = 0; i < 6; i++) region_fill(&line[i], 0); |
|
|
for (int i = 1; i < 6; i++) region_fill(&line[i], 0); |
|
|
|
|
|
screen_dirty = true; |
|
|
dirty &= ~D_LIST; |
|
|
|