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

Call::Call()
{
    error = false;
    address = 0;
}

Call::Call(unsigned char* byte)
{
    Parse(byte);
}

Call::Call(unsigned short value, bool)
{
    SetAddress(value);
}

unsigned short Call::GetAddress()
{
    return address;
}

void Call::SetAddress(unsigned short value)
{
    address = value;
}

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

    stringstream tmpAsmOut;
    tmpAsmOut << "mus_call" << " $" << hex << uppercase << address;
    return tmpAsmOut.str();
}

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

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

    // Get Address
    address = byte[2];
    address <<= 8;
    address |= byte[1];

    return true;
}

unsigned int Call::Arguments()
{
    // 1 2-byte argument = 2 bytes
	return 2;
}