Mercurial > otakunoraifu
changeset 59:36d92d21300f
Implemented sin opcode
author | Thibaut GIRKA <thib@sitedethib.com> |
---|---|
date | Fri, 18 Dec 2009 18:51:44 +0100 |
parents | 0aaa5bb3dde5 |
children | e16e13d8cd68 |
files | scn2k/scn2k_text.cc scn2k/scn2k_text.h scn2k/scn2k_textimpl.cc |
diffstat | 3 files changed, 12 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/scn2k/scn2k_text.cc +++ b/scn2k/scn2k_text.cc @@ -152,7 +152,7 @@ Text::Text(Event::Container& _event, Pic RegisterCommand(1, 4, 500, "InitFrame", (CmdImpl) &Text::impl_InitFrame); RegisterCommand(1, 4, 510, "ReadFrame", (CmdImpl) &Text::impl_ReadFrame); RegisterCommand(1, 4, 620, "InitExFrames", (CmdImpl) &Text::impl_InitFrames); - RegisterCommand(1, 4, 624, "InitExFramesDecel", NULL); + RegisterCommand(1, 4, 624, "InitExFramesDecel", (CmdImpl) &Text::impl_InitFrames); RegisterCommand(1, 4, 630, "ReadExFrames", (CmdImpl) &Text::impl_ReadFrames); RegisterCommand(1, 4, 110, "ResetTimer", (CmdImpl) &Text::impl_ResetTimer); @@ -164,8 +164,8 @@ Text::Text(Event::Container& _event, Pic RegisterCommand(1, 4, 1000, "rnd", (CmdImpl) &Text::impl_rnd); RegisterCommand(1, 4, 1001, "pcnt", (CmdImpl) &Text::impl_pcnt); RegisterCommand(1, 4, 1002, "abs", (CmdImpl) &Text::impl_abs); - RegisterCommand(1, 4, 1003, "power", NULL); - RegisterCommand(1, 4, 1004, "sin", NULL); + RegisterCommand(1, 4, 1003, "power", (CmdImpl) &Text::impl_power); + RegisterCommand(1, 4, 1004, "sin", (CmdImpl) &Text::impl_sin); RegisterCommand(1, 4, 1007, "min", (CmdImpl) &Text::impl_min); RegisterCommand(1, 4, 1008, "max", (CmdImpl) &Text::impl_max); RegisterCommand(1, 4, 1009, "constrain", (CmdImpl) &Text::impl_constrain);
--- a/scn2k/scn2k_text.h +++ b/scn2k/scn2k_text.h @@ -277,6 +277,7 @@ class Text : public CommandHandler { void impl_pcnt(Cmd& cmd); void impl_abs(Cmd& cmd); void impl_power(Cmd& cmd); + void impl_sin(Cmd& cmd); void impl_min(Cmd& cmd); void impl_max(Cmd& cmd); void impl_constrain(Cmd& cmd);
--- a/scn2k/scn2k_textimpl.cc +++ b/scn2k/scn2k_textimpl.cc @@ -332,6 +332,8 @@ void Text::impl_ReadFrames(Cmd& cmd) { cmd.SetSysvar(timers_active); } +#include "math.h" + void Text::impl_rnd(Cmd& cmd) { /* rand() */ @@ -372,8 +374,12 @@ void Text::impl_abs(Cmd& cmd) void Text::impl_power(Cmd& cmd) { - //TODO - //cmd.SetSysvar(pow(cmd.args[0].value, cmd.args[1].value)); + cmd.SetSysvar(pow(cmd.args[0].value, cmd.args[1].value)); +} + +void Text::impl_sin(Cmd& cmd) +{ + cmd.SetSysvar(sin(cmd.args[0].value * M_PI / 180) * 32640 / cmd.args[1].value); } void Text::impl_min(Cmd& cmd)