Mercurial > otakunoraifu
comparison scn2k/scn2k_textimpl.cc @ 68:043d5db57474
Fix index_series implementation (still incomplete)
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Wed, 23 Feb 2011 16:19:11 +0100 |
parents | 36d92d21300f |
children | c3d4f9ee2cf1 |
comparison
equal
deleted
inserted
replaced
67:419761c8d9b9 | 68:043d5db57474 |
---|---|
405 /* range conversion : 比率に丸める */ | 405 /* range conversion : 比率に丸める */ |
406 // アルゴリズムは間違えてるような気がする | 406 // アルゴリズムは間違えてるような気がする |
407 // | 407 // |
408 if (cmd.args.size() >= 7) | 408 if (cmd.args.size() >= 7) |
409 { | 409 { |
410 int val = cmd.args[0].value; | 410 int i, val; |
411 int offset = cmd.args[1].value; | 411 int x, startval; |
412 int r_min = cmd.args[2].value; | 412 int start, end, endval, mode; |
413 int v_min = cmd.args[3].value; | 413 |
414 int v_max = cmd.args[4].value; | 414 //TODO: why index and offset, and not x? |
415 int r_max = cmd.args[5].value; | 415 x = cmd.args[0].value + cmd.args[1].value; |
416 int mode = cmd.args[6].value; | 416 startval = cmd.args[2].value; |
417 // rldev : mode == 1,3 : 'acceralating curve', 2,3: 'decelerating curve' | 417 start = end = 0; |
418 // 複数の引数リスト(r_minからmodeまでのリスト)もつこともあり、その場合は | 418 val = endval = startval; |
419 // "cancel out in some way" らしい | 419 for (i=3; i < cmd.args.size(); i += 4) |
420 if (mode == 1 || mode == 3) | 420 { |
421 val += offset; | 421 startval = endval; |
422 else if (mode == 2 || mode == 4) | 422 start = cmd.args[i].value; |
423 val -= offset; | 423 end = cmd.args[i + 1].value; |
424 if (cmd.args.size() != 7) | 424 endval = cmd.args[i + 2].value; |
425 fprintf(stderr,"\n%d/%d: cmd 01-04:0320 : XXXX NOT SUPPORTED LIST : DOUBLE RANGE CONVERSION! XXXXXXXXXXX\n",cmd.scn,cmd.pos); | 425 int mode = cmd.args[i + 3].value; |
426 if (val < v_min) | 426 if (start <= x && x <= end) |
427 val = v_min; | 427 { |
428 if (val > v_max) | 428 // rldev : mode == 1,3 : 'acceralating curve', 2,3: 'decelerating curve' |
429 val = v_max; | 429 // 複数の引数リスト(r_minからmodeまでのリスト)もつこともあり、その場合は |
430 val = (r_max-r_min)*(val-v_min)/(v_max-v_min) + r_min; | 430 // "cancel out in some way" らしい |
431 // Assume mode 0, as we only know of it | |
432 // TODO: find out how other mode works (exp/log?) | |
433 // TODO: "When two ranges overlap, they appear to cancel out in some way" | |
434 val = startval + (endval - startval) * (x - start) / (end - start); | |
435 } | |
436 } | |
437 if (i != cmd.args.size()) | |
438 fprintf(stderr, "\n%d/%d: cmd 01-04:0320 : WARNING: %d unconsumed arguments\n", cmd.scn, cmd.pos, cmd.args.size() - i); | |
439 if (x > end) | |
440 x = endval; | |
431 cmd.SetSysvar(val); | 441 cmd.SetSysvar(val); |
432 } | 442 } |
443 else | |
444 fprintf(stderr, "\n%d/%d: cmd 01-04:0320 : Not enough arguments?!\n", cmd.scn, cmd.pos); | |
433 } | 445 } |
434 | 446 |
435 void Text::impl_constrain(Cmd& cmd) | 447 void Text::impl_constrain(Cmd& cmd) |
436 { | 448 { |
437 /* range 内に丸める */ | 449 /* range 内に丸める */ |