# HG changeset patch # User Thibaut GIRKA # Date 1261158704 -3600 # Node ID 36d92d21300f91bb6898e2aac711a7c8d7f364b0 # Parent 0aaa5bb3dde5e7fb4a7d8d54faa9ffa06baa8260 Implemented sin opcode diff --git a/scn2k/scn2k_text.cc b/scn2k/scn2k_text.cc --- 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); diff --git a/scn2k/scn2k_text.h b/scn2k/scn2k_text.h --- 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); diff --git a/scn2k/scn2k_textimpl.cc b/scn2k/scn2k_textimpl.cc --- 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)