blob: eed781833c29bb6aebee4fb89976db7bb371be3f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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 " << (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;
}
|