summaryrefslogtreecommitdiff
path: root/music/pokeredmusicdisasm/Modulation.cpp
diff options
context:
space:
mode:
authorKuroiIeWa5Da <tyuki@adu.me>2012-01-23 01:51:24 -0600
committerKuroiIeWa5Da <tyuki@adu.me>2012-01-23 01:51:24 -0600
commit7b23ef09829ac2c8afc842d96b3b15fdc2c91719 (patch)
treebd0962fee3d11412db573f9f087444c126b2943d /music/pokeredmusicdisasm/Modulation.cpp
parent6b49a9f14161e6398b5cf4e1ce633197009b82f3 (diff)
parent4e9fe0f8acd2301937c38b0b085f39aa4fd51bff (diff)
Merge
hg-commit-id: eecb568bd9b6
Diffstat (limited to 'music/pokeredmusicdisasm/Modulation.cpp')
-rw-r--r--music/pokeredmusicdisasm/Modulation.cpp96
1 files changed, 96 insertions, 0 deletions
diff --git a/music/pokeredmusicdisasm/Modulation.cpp b/music/pokeredmusicdisasm/Modulation.cpp
new file mode 100644
index 00000000..61ccbf82
--- /dev/null
+++ b/music/pokeredmusicdisasm/Modulation.cpp
@@ -0,0 +1,96 @@
+#include <sstream>
+#include "Modulation.h"
+using namespace std;
+
+Modulation::Modulation()
+{
+ delay = 0;
+ depth = 0;
+ rate = 0;
+}
+
+Modulation::Modulation(unsigned char* byte) // Parse Immidiately
+{
+ Parse(byte);
+}
+
+Modulation::Modulation(unsigned char delay, unsigned char depth, unsigned char rate, bool) // Set value
+{
+ SetDelay(delay);
+ SetDepth(depth);
+ SetRate(rate);
+}
+
+// Direct Getter/Setter Functions
+unsigned char Modulation::GetDelay()
+{
+ return delay;
+}
+
+void Modulation::SetDelay(unsigned char value)
+{
+ delay = value;
+}
+
+unsigned char Modulation::GetDepth()
+{
+ return depth;
+}
+
+void Modulation::SetDepth(unsigned char value)
+{
+ depth = value;
+}
+
+unsigned char Modulation::GetRate()
+{
+ return rate;
+}
+
+void Modulation::SetRate(unsigned char value)
+{
+ rate = value;
+}
+
+bool Modulation::IsValid(unsigned char* byte)
+{
+ if(byte[0] == 0xEA)
+ {
+ error = false; // Unblock assembling
+ return true;
+ }
+ else
+ {
+ error = true; // Block assembling
+ return false;
+ }
+}
+
+string Modulation::GenAsm()
+{
+ string tmpRet = AbstractData::GenAsm();
+ if(tmpRet != "") return tmpRet;
+
+ stringstream tmpAsmOut;
+ tmpAsmOut << "mus_mod " << hex << (short)delay << ", " << (short)depth << ", " << (short)rate;
+ return tmpAsmOut.str();
+}
+
+bool Modulation::Parse(unsigned char* byte)
+{
+ if(!AbstractData::Parse(byte)) return false;
+
+ delay = byte[1];
+
+ depth = byte[2] & 0xF0;
+ depth >>= 4;
+
+ rate = byte[2] & 0x0F;
+ return true;
+}
+
+unsigned int Modulation::Arguments()
+{
+ // 2 1-byte arguments = 2
+ return 2;
+} \ No newline at end of file