summaryrefslogtreecommitdiff
path: root/music/pokeredmusicdisasm/Velocity.cpp
blob: 0000d4bab3744049ba28a004d3df4fd6ce31f7f6 (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
#include <sstream>
#include "Velocity.h"
using namespace std;

Velocity::Velocity()
{
	velocity = 0;
	length = 0;
}

Velocity::Velocity(unsigned char* byte) // Parse Immidiately
{
	Parse(byte);
}

Velocity::Velocity(unsigned char velocity, unsigned char length, bool) // Set value
{
	SetVelocity(velocity);
	SetLength(length);
}

// Direct Getters/Setters
unsigned char Velocity::GetVelocity()
{
	return velocity;
}

void Velocity::SetVelocity(unsigned char value)
{
	velocity = value;
}

unsigned char Velocity::GetLength()
{
	return length;
}

void Velocity::SetLength(unsigned char value)
{
	length = value;
}

bool Velocity::IsValid(unsigned char* byte)
{
	if(byte[0] == 0xDC)
	{
		error = false;
		return true;
	}
	else
	{
		error = true;
		return false;
	}
}

string Velocity::GenAsm()
{
	string tmpRet = AbstractData::GenAsm();
	if(tmpRet != "") return tmpRet;

	stringstream tmpAsmOut;
	tmpAsmOut << "mus_vel" << " " << (short)velocity << ", " << (short)length;
	return tmpAsmOut.str();
}

bool Velocity::Parse(unsigned char* byte)
{
	if(!AbstractData::Parse(byte)) return false;
	
	velocity = byte[1] & 0xF0;
	velocity >>= 4;

	length = byte[1] & 0x0F;
	return true;
}

unsigned int Velocity::Arguments()
{
	// 1 1-byte argument
	return 1;
}