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

Jump::Jump()
{
	address = 0x0000;
	loop = 0;
}

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

Jump::Jump(unsigned short value, unsigned char loop, bool) // Set value
{
	SetAddress(value);
	SetLoop(loop);
}

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

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

unsigned char Jump::GetLoop()
{
	return loop;
}

void Jump::SetLoop(unsigned char value)
{
	loop = value;
}

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

	stringstream tmpAsmOut;
	tmpAsmOut << "mus_jump" << " " << (short)loop << ", $" << hex << uppercase << address;
	return tmpAsmOut.str();
}

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

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

	loop = byte[1];

    address = byte[3];
    address <<= 8;
    address |= byte[2];

	return true;
}

unsigned int Jump::Arguments()
{
	// 1 1-byte command, 1 1-byte loop, 1 2-byte pointer = 4 bytes
	return 3;
}