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

Octave::Octave()
{
	octave = 0;
}

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

Octave::Octave(unsigned char octave, bool) // Set value
{
	SetOctave(octave);
}

unsigned char Octave::GetOctave()
{
	return octave;
}

void Octave::SetOctave(unsigned char value)
{
	octave = value;
}

bool Octave::IsValid(unsigned char* byte)
{
	if((byte[0] >= 0xE0) &&
		(byte[0] <= 0xE7))
	{
		error = false;	// Unblock assembling
		return true;
	}
	else
	{
		error = true;	// Block assembling
		return false;
	}
}

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

	stringstream tmpAsmOut;
	tmpAsmOut << "mus_octave" << " " << LookupOctString();
	return tmpAsmOut.str();
}

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

	octave = byte[0];
	return true;
}

string Octave::LookupOctString()
{
	// In case some error happens and the values doesn't match the list below
	stringstream defTmp;

	switch(octave)
	{
	case oct0:
		return "oct0";
	case oct1:
		return "oct1";
	case oct2:
		return "oct2";
	case oct3:
		return "oct3";
	case oct4:
		return "oct4";
	case oct5:
		return "oct5";
	case oct6:
		return "oct6";
	case oct7:
		return "oct7";
	default:
		defTmp.setf(ios_base::uppercase | ios_base::hex);
		defTmp << "$" << (short)octave;
		return defTmp.str();
	}
}

unsigned int Octave::Arguments()
{
	// No Arguments
	return 0;
}