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

Tempo::Tempo()
{
	divider = 0;
	modifier = 0;
}

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

Tempo::Tempo(unsigned char divider, unsigned char modifier, bool) // Set value
{
	SetDivider(divider);
	SetModifier(modifier);
}

unsigned char Tempo::GetDivider()
{
	return divider;
}

void Tempo::SetDivider(unsigned char value)
{
	divider = value;
}

unsigned char Tempo::Getmodifier()
{
	return modifier;
}

void Tempo::SetModifier(unsigned char value)
{
	modifier = value;
}

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

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

	stringstream tmpAsmOut;
	tmpAsmOut << "mus_tempo" << " " << (short)divider << ", " << (short)modifier;
	return tmpAsmOut.str();
}

bool Tempo::Parse(unsigned char* byte)
{
	if(!AbstractData::Parse(byte)) return false;

	divider = byte[1];
	modifier = byte[2];

	return true;
}

unsigned int Tempo::Arguments()
{
	// 2 1-byte arguments = 2
	return 2;
}