Mercurial > otakunoraifu
changeset 68:043d5db57474
Fix index_series implementation (still incomplete)
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Wed, 23 Feb 2011 16:19:11 +0100 |
parents | 419761c8d9b9 |
children | c3d4f9ee2cf1 |
files | scn2k/scn2k_textimpl.cc |
diffstat | 1 files changed, 33 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/scn2k/scn2k_textimpl.cc +++ b/scn2k/scn2k_textimpl.cc @@ -407,29 +407,41 @@ void Text::impl_index_series(Cmd& cmd) // if (cmd.args.size() >= 7) { - int val = cmd.args[0].value; - int offset = cmd.args[1].value; - int r_min = cmd.args[2].value; - int v_min = cmd.args[3].value; - int v_max = cmd.args[4].value; - int r_max = cmd.args[5].value; - int mode = cmd.args[6].value; - // rldev : mode == 1,3 : 'acceralating curve', 2,3: 'decelerating curve' - // 複数の引数リスト(r_minからmodeまでのリスト)もつこともあり、その場合は - // "cancel out in some way" らしい - if (mode == 1 || mode == 3) - val += offset; - else if (mode == 2 || mode == 4) - val -= offset; -if (cmd.args.size() != 7) - fprintf(stderr,"\n%d/%d: cmd 01-04:0320 : XXXX NOT SUPPORTED LIST : DOUBLE RANGE CONVERSION! XXXXXXXXXXX\n",cmd.scn,cmd.pos); - if (val < v_min) - val = v_min; - if (val > v_max) - val = v_max; - val = (r_max-r_min)*(val-v_min)/(v_max-v_min) + r_min; + int i, val; + int x, startval; + int start, end, endval, mode; + + //TODO: why index and offset, and not x? + x = cmd.args[0].value + cmd.args[1].value; + startval = cmd.args[2].value; + start = end = 0; + val = endval = startval; + for (i=3; i < cmd.args.size(); i += 4) + { + startval = endval; + start = cmd.args[i].value; + end = cmd.args[i + 1].value; + endval = cmd.args[i + 2].value; + int mode = cmd.args[i + 3].value; + if (start <= x && x <= end) + { + // rldev : mode == 1,3 : 'acceralating curve', 2,3: 'decelerating curve' + // 複数の引数リスト(r_minからmodeまでのリスト)もつこともあり、その場合は + // "cancel out in some way" らしい + // Assume mode 0, as we only know of it + // TODO: find out how other mode works (exp/log?) + // TODO: "When two ranges overlap, they appear to cancel out in some way" + val = startval + (endval - startval) * (x - start) / (end - start); + } + } + if (i != cmd.args.size()) + fprintf(stderr, "\n%d/%d: cmd 01-04:0320 : WARNING: %d unconsumed arguments\n", cmd.scn, cmd.pos, cmd.args.size() - i); + if (x > end) + x = endval; cmd.SetSysvar(val); } + else + fprintf(stderr, "\n%d/%d: cmd 01-04:0320 : Not enough arguments?!\n", cmd.scn, cmd.pos); } void Text::impl_constrain(Cmd& cmd)