// scroll the current selection void select_scroll(s8 dir) { const s32 max = net_num_ops() - 1; s16 newSel; s16 newIdx; if(dir < 0) { /// SCROLL DOWN // if selection is already zero, do nothing if(*pageSelect == 0) { // print_dbg("\r\n reached min selection in inputs scroll. "); return; } // remove highlight from old center render_scroll_apply_hl(SCROLL_CENTER_LINE, 0); // decrement selection newSel = *pageSelect - 1; ///// these bounds checks shouldn't really be needed here... // if(newSel < 0) { newSel = 0; } // if(newSel > max ) { newSel = max; } *pageSelect = newSel; // add new content at top newIdx = newSel - SCROLL_LINES_BELOW; if(newIdx < 0) { // empty row region_fill(lineRegion, 0); } else { render_line(newIdx); } // render tmp region to bottom of scroll // (this also updates scroll byte offset) render_to_scroll_top(); // add highlight to new center render_scroll_apply_hl(SCROLL_CENTER_LINE, 1); } else { // SCROLL UP // if selection is already max, do nothing if(*pageSelect == max) { // print_dbg("\r\n reached max selection in inputs scroll. "); return; } // remove highlight from old center render_scroll_apply_hl(SCROLL_CENTER_LINE, 0); // increment selection newSel = *pageSelect + 1; *pageSelect = newSel; // add new content at bottom of screen newIdx = newSel + SCROLL_LINES_ABOVE; if(newIdx > max) { // empty row region_fill(lineRegion, 0); } else { render_line(newIdx); } // render tmp region to bottom of scroll // (this also updates scroll byte offset) render_to_scroll_bottom(); // add highlight to new center render_scroll_apply_hl(SCROLL_CENTER_LINE, 1); } }
// scroll the current selection static void select_scroll(s32 dir) { // index for new content s16 newIdx; s16 newSel; if(dir < 0) { /// SCROLL DOWN if(*pageSelect == 0) { return; } // remove highlight from old center // render_scroll_apply_hl(SCROLL_CENTER_LINE, 0); // redraw center row without editing cursor, etc render_line(*pageSelect, 0xa); // copy to scroll render_to_scroll_center(); newSel = *pageSelect - 1; *pageSelect = newSel; // add new content at top newIdx = newSel - SCROLL_LINES_BELOW; if(newIdx < 0) { // empty row region_fill(lineRegion, 0); } else { render_line(newIdx, 0xa); } // render tmp region to bottom of scroll // (this also updates scroll byte offset) render_to_scroll_top(); // add highlight to new center render_scroll_apply_hl(SCROLL_CENTER_LINE, 1); } else { // SCROLL UP // if selection is already max, do nothing if(*pageSelect == (maxPresetIdx) ) { return; } // remove highlight from old center render_scroll_apply_hl(SCROLL_CENTER_LINE, 0); // increment selection newSel = *pageSelect + 1; *pageSelect = newSel; // add new content at bottom of screen newIdx = newSel + SCROLL_LINES_ABOVE; if(newIdx > maxPresetIdx) { // empty row region_fill(lineRegion, 0); } else { render_line(newIdx, 0xa); } // render tmp region to bottom of scroll // (this also updates scroll byte offset) render_to_scroll_bottom(); // add highlight to new center render_scroll_apply_hl(SCROLL_CENTER_LINE, 1); } }
// function key handlers void handle_key_0(s32 val) { if(val == 0) { return; } if(altMode) { ///// follow // select target on ins page tmpTarget = net_get_target(*pageSelect); if(tmpTarget >= 0) { pages[ePageIns].select = tmpTarget; set_page(ePageIns); redraw_ins(); } } else { // store // show selected preset name draw_preset_name(); if(check_key(0)) { // store in preset net_set_out_preset(*pageSelect, 1); preset_store_out(preset_get_select(), *pageSelect); // redraw selected line render_line(*pageSelect, 0xa); render_scroll_apply_hl(SCROLL_CENTER_LINE, 1); // TODO: store directly in scene? } } show_foot(); }
// scroll the current selection static void select_scroll(s32 dir) { const s32 max = net_num_outs() - 1; // index for new content s16 newIdx; s16 newSel; s16 oldSel; int i; // cancel actions pages_reset_keypressed(); // wrap with blank line newSel = *pageSelect + dir; if (newSel < -1) { newSel += (max + 2); } if(newSel > max) { newSel -= (max + 2); } oldSel = *pageSelect; *pageSelect = newSel; // remove highlight from old center render_scroll_apply_hl(SCROLL_CENTER_LINE, 0); if(dir > 0) { // add content at bottom for(i=0; i<dir; ++i) { newIdx = oldSel + SCROLL_LINES_BELOW + i + 2; if(newIdx == (max + 1)) { region_fill(lineRegion, 0); } else { if(newIdx > max) { newIdx = newIdx - (max+2); } /* print_dbg(" , rendering new line for idx: "); */ /* print_dbg_ulong(newIdx); */ render_line(newIdx, 0xa); } // render tmp region to bottom of scroll // (this also updates scroll byte offset) render_to_scroll_bottom(); // add highlight to new center } render_scroll_apply_hl(SCROLL_CENTER_LINE, 1); } else { // add content at top for(i=0; i>dir; --i) { newIdx = oldSel - SCROLL_LINES_ABOVE + i; if(newIdx == -1) { region_fill(lineRegion, 0); } else { if(newIdx < -1) { newIdx = newIdx + max + 2; } /* print_dbg(" , rendering new line for idx: "); */ /* print_dbg_ulong(newIdx); */ render_line(newIdx, 0xa); } // render tmp region to top of scroll // (this also updates scroll byte offset) render_to_scroll_top(); } // add highlight to new center render_scroll_apply_hl(SCROLL_CENTER_LINE, 1); } }
// scroll the current selection static void select_scroll(s32 dir) { const s32 max = net_num_ins() - 1; // index for new content s16 newIdx; s16 newSel; s16 oldSel; int i; // wrap with blank line newSel = *pageSelect + dir; if (newSel < -1) { newSel += (max + 2); } if(newSel > max) { newSel -= (max + 2); } // print_dbg("\r\n scrolled selection on inputs page, old sel: "); // print_dbg_ulong(*pageSelect); // print_dbg(" , dir: "); // print_dbg_hex(dir); // print_dbg(" , new idx: "); // print_dbg_ulong(newSel); oldSel = *pageSelect; *pageSelect = newSel; // remove highlight from old center render_scroll_apply_hl(SCROLL_CENTER_LINE, 0); // update 'zeroed' flag zeroed = (net_get_in_value(*pageSelect) == 0); if(dir > 0) { // add content at bottom for(i=0; i<dir; ++i) { newIdx = oldSel + SCROLL_LINES_BELOW + i + 2; if(newIdx == (max + 1)) { region_fill(lineRegion, 0); } else { if(newIdx > max) { newIdx = newIdx - (max+2); } // print_dbg(" , rendering new line for idx: "); // print_dbg_ulong(newIdx); render_line(newIdx, 0xa); } // render tmp region to bottom of scroll // (this also updates scroll byte offset) render_to_scroll_bottom(); // add highlight to new center } render_scroll_apply_hl(SCROLL_CENTER_LINE, 1); } else { // add content at top for(i=0; i>dir; --i) { newIdx = oldSel - SCROLL_LINES_ABOVE + i; if(newIdx == -1) { region_fill(lineRegion, 0); } else { if(newIdx < -1) { newIdx = newIdx + max + 2; } // print_dbg(" , rendering new line for idx: "); // print_dbg_ulong(newIdx); render_line(newIdx, 0xa); } // render tmp region to top of scroll // (this also updates scroll byte offset) render_to_scroll_top(); } // add highlight to new center render_scroll_apply_hl(SCROLL_CENTER_LINE, 1); } }
// scroll the current selection static void select_scroll(s32 dir) { const s32 max = net_num_ins() - 1; // index for new content s16 newIdx; s16 newSel; if(dir < 0) { /// SCROLL DOWN // wrap with blank line if(*pageSelect == -1) { newSel = max; } else { // decrement selection newSel = *pageSelect - 1; // print_dbg("\r\n scroll down to new selection on ins page: "); // print_dbg_ulong(newSel); } *pageSelect = newSel; // remove highlight from old center render_scroll_apply_hl(SCROLL_CENTER_LINE, 0); // update 'zeroed' flag zeroed = (net_get_in_value(*pageSelect) == 0); // add new content at top newIdx = newSel - SCROLL_LINES_BELOW; if(newIdx == -1) { region_fill(lineRegion, 0); } else { if(newIdx < -1) { newIdx = newIdx + max + 2; } render_line(newIdx, 0xa); } // render tmp region to bottom of scroll // (this also updates scroll byte offset) render_to_scroll_top(); // add highlight to new center render_scroll_apply_hl(SCROLL_CENTER_LINE, 1); } else { // SCROLL UP // wrap with a blank line if(*pageSelect == max) { newSel = -1; } else { // increment selection newSel = *pageSelect + 1; } // print_dbg("\r\n scroll up to new selection on ins page: "); // print_dbg_ulong(newSel); *pageSelect = newSel; // remove highlight from old center render_scroll_apply_hl(SCROLL_CENTER_LINE, 0); // add new content at bottom of screen newIdx = newSel + SCROLL_LINES_ABOVE; if(newIdx == (max + 1)) { region_fill(lineRegion, 0); } else { if(newIdx > max) { newIdx = newIdx - (max+2); } render_line(newIdx, 0xa); } // render tmp region to bottom of scroll // (this also updates scroll byte offset) render_to_scroll_bottom(); // add highlight to new center render_scroll_apply_hl(SCROLL_CENTER_LINE, 1); } }
// scroll the current selection static void select_scroll(s32 dir) { // index for new content s16 newIdx; s16 newSel; // cancel actions pages_reset_keypressed(); cursor = 4; if(dir < 0) { /// SCROLL DOWN if(*pageSelect == 0) { return; } /* // remove highlight from old center */ /* render_scroll_apply_hl(SCROLL_CENTER_LINE, 0); */ // redraw and re-render old center selection /// hm, why is this wrong.. render_line(*pageSelect, 0xa); render_to_scroll_line(SCROLL_CENTER_LINE, 0); // decrement selection newSel = *pageSelect - 1; *pageSelect = newSel; // add new content at top newIdx = newSel - SCROLL_LINES_BELOW; if(newIdx < 0) { // empty row region_fill(lineRegion, 0); } else { render_line(newIdx, 0xa); } // render tmp region to bottom of scroll // (this also updates scroll byte offset) render_to_scroll_top(); // add highlight to new center render_scroll_apply_hl(SCROLL_CENTER_LINE, 1); } else { // SCROLL UP // if selection is already max, do nothing if(*pageSelect == (maxPresetIdx) ) { return; } // remove highlight from old center // render_scroll_apply_hl(SCROLL_CENTER_LINE, 0); // re-render last center without cursor render_line(*pageSelect, 0xa); render_to_scroll_line(SCROLL_CENTER_LINE, 0); // increment selection newSel = *pageSelect + 1; *pageSelect = newSel; // add new content at bottom of screen newIdx = newSel + SCROLL_LINES_ABOVE; if(newIdx > maxPresetIdx) { // empty row region_fill(lineRegion, 0); } else { render_line(newIdx, 0xa); } // render tmp region to bottom of scroll // (this also updates scroll byte offset) render_to_scroll_bottom(); // add highlight to new center render_scroll_apply_hl(SCROLL_CENTER_LINE, 1); } }