yaze
0.2.0
Link to the Past ROM Editor
Loading...
Searching...
No Matches
tracker.h
Go to the documentation of this file.
1
#ifndef YAZE_APP_ZELDA3_TRACKER_H
2
#define YAZE_APP_ZELDA3_TRACKER_H
3
4
#include <vector>
5
6
#include "
app/core/constants.h
"
7
#include "
app/rom.h
"
8
9
namespace
yaze
{
10
namespace
app {
11
namespace
zelda3 {
12
19
namespace
music {
20
21
// bank 19, 1A, 1B
22
// iirc 1A is OW, 1B is dungeon
23
// 19 is general spc stuff like samples, ects
24
constexpr
char
op_len
[32] = {1, 1, 2, 3, 0, 1, 2, 1, 2, 1, 1, 3, 0, 1, 2, 3,
25
1, 3, 3, 0, 1, 3, 0, 3, 3, 3, 1, 2, 0, 0, 0, 0};
26
27
// =============================================================================
28
29
static
int
sbank_ofs[] = {0xc8000, 0, 0xd8000, 0};
30
31
constexpr
char
fil1
[4] = {0, 15, 61, 115};
32
constexpr
char
fil2
[4] = {0, 4, 5, 6};
33
constexpr
char
fil3
[4] = {0, 0, 15, 13};
34
35
constexpr
int
kOverworldMusicBank
= 0x0D0000;
36
constexpr
int
kDungeonMusicBank
= 0x0D8000;
37
38
using
text_buf_ty
=
char
[512];
39
// ============================================================================
40
41
struct
SongSpcBlock
{
42
unsigned
short
start
;
43
unsigned
short
len
;
44
unsigned
short
relnum
;
45
unsigned
short
relsz
;
46
unsigned
short
*
relocs
;
47
unsigned
short
bank
;
48
unsigned
short
addr
;
49
unsigned
char
*
buf
;
50
int
flag
;
51
};
52
53
// =============================================================================
54
55
struct
SongRange
{
56
unsigned
short
start
;
57
unsigned
short
end
;
58
59
short
first
;
60
short
inst
;
61
short
bank
;
62
63
unsigned
char
endtime
;
64
unsigned
char
filler
;
65
66
int
editor
;
67
};
68
69
// =============================================================================
70
71
struct
SongPart
{
72
uchar
flag
;
73
uchar
inst
;
74
short
tbl
[8];
75
unsigned
short
addr
;
76
};
77
78
// =============================================================================
79
80
struct
Song
{
81
unsigned
char
flag
;
82
unsigned
char
inst
;
83
SongPart
**
tbl
;
84
short
numparts
;
85
short
lopst
;
86
unsigned
short
addr
;
87
bool
in_use
;
// true
88
};
89
// =============================================================================
90
91
struct
ZeldaWave
{
92
int
lopst
;
93
int
end
;
94
short
lflag
;
95
short
copy
;
96
short
*
buf
;
97
};
98
99
// ============================================================================
100
101
struct
SampleEdit
{
102
unsigned
short
flag
;
103
unsigned
short
init
;
104
unsigned
short
editsamp
;
105
int
width
;
106
int
height
;
107
int
pageh
;
108
int
pagev
;
109
int
zoom
;
110
int
scroll
;
111
int
page
;
112
114
int
sell
;
115
117
int
selr
;
118
119
int
editinst
;
120
121
ZeldaWave
*
zw
;
122
};
123
124
// =============================================================================
125
126
struct
ZeldaInstrument
{
127
unsigned
char
samp
;
128
unsigned
char
ad
;
129
unsigned
char
sr
;
130
unsigned
char
gain
;
131
unsigned
char
multhi
;
132
unsigned
char
multlo
;
133
};
134
135
// =============================================================================
136
137
struct
ZeldaSfxInstrument
{
138
unsigned
char
voll
;
139
unsigned
char
volr
;
140
short
freq
;
141
unsigned
char
samp
;
142
unsigned
char
ad
;
143
unsigned
char
sr
;
144
unsigned
char
gain
;
145
unsigned
char
multhi
;
146
};
147
148
// =============================================================================
149
150
struct
SpcCommand
{
151
unsigned
short
addr
;
152
short
next
;
153
short
prev
;
154
unsigned
char
flag
;
155
unsigned
char
cmd
;
156
unsigned
char
p1
;
157
unsigned
char
p2
;
158
unsigned
char
p3
;
159
unsigned
char
b1
;
160
unsigned
char
b2
;
161
unsigned
char
tim2
;
162
unsigned
short
tim
;
163
};
164
165
// =============================================================================
166
167
class
Tracker
{
168
public
:
169
SongSpcBlock
*
AllocSpcBlock
(
int
len,
int
bank);
170
171
unsigned
char
*
GetSpcAddr
(
Rom
&rom,
unsigned
short
addr,
short
bank);
172
173
short
AllocSpcCommand
();
174
175
short
GetBlockTime
(
Rom
&rom,
short
num,
short
prevtime);
176
177
short
SaveSpcCommand
(
Rom
&rom,
short
num,
short
songtime,
short
endtr);
178
short
LoadSpcCommand
(
Rom
&rom,
unsigned
short
addr,
short
bank,
int
t);
179
180
void
SaveSongs
(
Rom
&rom);
181
182
void
LoadSongs
(
Rom
&rom);
183
184
int
WriteSpcData
(
Rom
&rom,
void
*buf,
int
len,
int
addr,
int
spc,
int
limit);
185
186
void
EditTrack
(
Rom
&rom,
short
i);
187
188
void
NewSR
(
Rom
&rom,
int
bank);
189
190
private
:
191
// A "modified" flag
192
int
modf
;
193
194
int
mark_sr
;
195
196
int
mark_start
;
197
int
mark_end
;
198
int
mark_first
;
199
int
mark_last
;
200
201
int
numwave
;
202
int
numinst
;
203
int
numsndinst
;
204
205
int
sndinit
= 0;
206
207
int
sndlen1
;
208
int
sndlen2
;
209
int
m_ofs
;
210
int
w_modf
;
211
212
int
ss_num
;
213
int
ss_size
;
214
215
char
op_len
[32];
216
217
char
*
snddat1
;
218
char
*
snddat2
;
// more music stuff.
219
220
unsigned
short
ss_next
= 0;
221
unsigned
short
spclen
;
222
unsigned
short
numseg
;
223
224
short
spcbank
;
225
short
lastsr
;
226
short
ss_lasttime
;
227
short
srnum
;
228
short
srsize
;
229
short
numsong
[3];
// ditto
230
short
m_size
;
231
short
m_free
;
232
short
m_modf
;
// ???
233
short
m_loaded
;
234
235
short
t_loaded
;
236
short
t_modf
;
237
short
withhead
;
238
239
size_t
t_number
;
240
241
std::vector<Song>
songs
;
242
SongPart
*
sp_mark
;
243
SongRange
*
song_range_
;
244
SpcCommand
*
current_spc_command_
;
245
246
SongSpcBlock
**
ssblt
;
247
248
ZeldaWave
*
waves
;
249
ZeldaInstrument
*
insts
;
250
ZeldaSfxInstrument
*
sndinsts
;
251
};
252
253
// =============================================================================
254
255
}
// namespace music
256
}
// namespace zelda3
257
}
// namespace app
258
}
// namespace yaze
259
260
#endif
yaze::app::Rom
The Rom class is used to load, save, and modify Rom data.
Definition
rom.h:136
yaze::app::zelda3::music::Tracker
Definition
tracker.h:167
yaze::app::zelda3::music::Tracker::mark_first
int mark_first
Definition
tracker.h:198
yaze::app::zelda3::music::Tracker::sndinsts
ZeldaSfxInstrument * sndinsts
Definition
tracker.h:250
yaze::app::zelda3::music::Tracker::spcbank
short spcbank
Definition
tracker.h:224
yaze::app::zelda3::music::Tracker::t_loaded
short t_loaded
Definition
tracker.h:235
yaze::app::zelda3::music::Tracker::m_free
short m_free
Definition
tracker.h:231
yaze::app::zelda3::music::Tracker::ssblt
SongSpcBlock ** ssblt
Definition
tracker.h:246
yaze::app::zelda3::music::Tracker::t_modf
short t_modf
Definition
tracker.h:236
yaze::app::zelda3::music::Tracker::numsong
short numsong[3]
Definition
tracker.h:229
yaze::app::zelda3::music::Tracker::GetSpcAddr
unsigned char * GetSpcAddr(Rom &rom, unsigned short addr, short bank)
Definition
tracker.cc:61
yaze::app::zelda3::music::Tracker::EditTrack
void EditTrack(Rom &rom, short i)
Definition
tracker.cc:1266
yaze::app::zelda3::music::Tracker::numseg
unsigned short numseg
Definition
tracker.h:222
yaze::app::zelda3::music::Tracker::op_len
char op_len[32]
Definition
tracker.h:215
yaze::app::zelda3::music::Tracker::snddat1
char * snddat1
Definition
tracker.h:217
yaze::app::zelda3::music::Tracker::m_modf
short m_modf
Definition
tracker.h:232
yaze::app::zelda3::music::Tracker::LoadSpcCommand
short LoadSpcCommand(Rom &rom, unsigned short addr, short bank, int t)
Definition
tracker.cc:217
yaze::app::zelda3::music::Tracker::numsndinst
int numsndinst
Definition
tracker.h:203
yaze::app::zelda3::music::Tracker::SaveSongs
void SaveSongs(Rom &rom)
Definition
tracker.cc:816
yaze::app::zelda3::music::Tracker::WriteSpcData
int WriteSpcData(Rom &rom, void *buf, int len, int addr, int spc, int limit)
Definition
tracker.cc:786
yaze::app::zelda3::music::Tracker::mark_last
int mark_last
Definition
tracker.h:199
yaze::app::zelda3::music::Tracker::songs
std::vector< Song > songs
Definition
tracker.h:241
yaze::app::zelda3::music::Tracker::ss_size
int ss_size
Definition
tracker.h:213
yaze::app::zelda3::music::Tracker::ss_num
int ss_num
Definition
tracker.h:212
yaze::app::zelda3::music::Tracker::song_range_
SongRange * song_range_
Definition
tracker.h:243
yaze::app::zelda3::music::Tracker::numinst
int numinst
Definition
tracker.h:202
yaze::app::zelda3::music::Tracker::m_size
short m_size
Definition
tracker.h:230
yaze::app::zelda3::music::Tracker::lastsr
short lastsr
Definition
tracker.h:225
yaze::app::zelda3::music::Tracker::sndlen2
int sndlen2
Definition
tracker.h:208
yaze::app::zelda3::music::Tracker::insts
ZeldaInstrument * insts
Definition
tracker.h:249
yaze::app::zelda3::music::Tracker::t_number
size_t t_number
Definition
tracker.h:239
yaze::app::zelda3::music::Tracker::sndinit
int sndinit
Definition
tracker.h:205
yaze::app::zelda3::music::Tracker::numwave
int numwave
Definition
tracker.h:201
yaze::app::zelda3::music::Tracker::waves
ZeldaWave * waves
Definition
tracker.h:248
yaze::app::zelda3::music::Tracker::AllocSpcCommand
short AllocSpcCommand()
Definition
tracker.cc:97
yaze::app::zelda3::music::Tracker::mark_end
int mark_end
Definition
tracker.h:197
yaze::app::zelda3::music::Tracker::SaveSpcCommand
short SaveSpcCommand(Rom &rom, short num, short songtime, short endtr)
Definition
tracker.cc:663
yaze::app::zelda3::music::Tracker::snddat2
char * snddat2
Definition
tracker.h:218
yaze::app::zelda3::music::Tracker::NewSR
void NewSR(Rom &rom, int bank)
Definition
tracker.cc:1316
yaze::app::zelda3::music::Tracker::ss_next
unsigned short ss_next
Definition
tracker.h:220
yaze::app::zelda3::music::Tracker::withhead
short withhead
Definition
tracker.h:237
yaze::app::zelda3::music::Tracker::AllocSpcBlock
SongSpcBlock * AllocSpcBlock(int len, int bank)
Definition
tracker.cc:36
yaze::app::zelda3::music::Tracker::modf
int modf
Definition
tracker.h:192
yaze::app::zelda3::music::Tracker::mark_start
int mark_start
Definition
tracker.h:196
yaze::app::zelda3::music::Tracker::sndlen1
int sndlen1
Definition
tracker.h:207
yaze::app::zelda3::music::Tracker::current_spc_command_
SpcCommand * current_spc_command_
Definition
tracker.h:244
yaze::app::zelda3::music::Tracker::w_modf
int w_modf
Definition
tracker.h:210
yaze::app::zelda3::music::Tracker::spclen
unsigned short spclen
Definition
tracker.h:221
yaze::app::zelda3::music::Tracker::LoadSongs
void LoadSongs(Rom &rom)
Definition
tracker.cc:393
yaze::app::zelda3::music::Tracker::ss_lasttime
short ss_lasttime
Definition
tracker.h:226
yaze::app::zelda3::music::Tracker::mark_sr
int mark_sr
Definition
tracker.h:194
yaze::app::zelda3::music::Tracker::GetBlockTime
short GetBlockTime(Rom &rom, short num, short prevtime)
Definition
tracker.cc:123
yaze::app::zelda3::music::Tracker::srsize
short srsize
Definition
tracker.h:228
yaze::app::zelda3::music::Tracker::sp_mark
SongPart * sp_mark
Definition
tracker.h:242
yaze::app::zelda3::music::Tracker::srnum
short srnum
Definition
tracker.h:227
yaze::app::zelda3::music::Tracker::m_ofs
int m_ofs
Definition
tracker.h:209
yaze::app::zelda3::music::Tracker::m_loaded
short m_loaded
Definition
tracker.h:233
constants.h
uchar
unsigned char uchar
Definition
constants.h:114
yaze::app::zelda3::music::kDungeonMusicBank
constexpr int kDungeonMusicBank
Definition
tracker.h:36
yaze::app::zelda3::music::kOverworldMusicBank
constexpr int kOverworldMusicBank
Definition
tracker.h:35
yaze::app::zelda3::music::fil3
constexpr char fil3[4]
Definition
tracker.h:33
yaze::app::zelda3::music::fil2
constexpr char fil2[4]
Definition
tracker.h:32
yaze::app::zelda3::music::text_buf_ty
char[512] text_buf_ty
Definition
tracker.h:38
yaze::app::zelda3::music::fil1
constexpr char fil1[4]
Definition
tracker.h:31
yaze::app::zelda3::music::op_len
constexpr char op_len[32]
Definition
tracker.h:24
yaze
Definition
common.cc:22
rom.h
yaze::app::zelda3::music::SampleEdit
Definition
tracker.h:101
yaze::app::zelda3::music::SampleEdit::editinst
int editinst
Definition
tracker.h:119
yaze::app::zelda3::music::SampleEdit::selr
int selr
Right hand sample selection point.
Definition
tracker.h:117
yaze::app::zelda3::music::SampleEdit::pagev
int pagev
Definition
tracker.h:108
yaze::app::zelda3::music::SampleEdit::flag
unsigned short flag
Definition
tracker.h:102
yaze::app::zelda3::music::SampleEdit::editsamp
unsigned short editsamp
Definition
tracker.h:104
yaze::app::zelda3::music::SampleEdit::width
int width
Definition
tracker.h:105
yaze::app::zelda3::music::SampleEdit::zw
ZeldaWave * zw
Definition
tracker.h:121
yaze::app::zelda3::music::SampleEdit::init
unsigned short init
Definition
tracker.h:103
yaze::app::zelda3::music::SampleEdit::sell
int sell
Left hand sample selection point.
Definition
tracker.h:114
yaze::app::zelda3::music::SampleEdit::page
int page
Definition
tracker.h:111
yaze::app::zelda3::music::SampleEdit::pageh
int pageh
Definition
tracker.h:107
yaze::app::zelda3::music::SampleEdit::height
int height
Definition
tracker.h:106
yaze::app::zelda3::music::SampleEdit::scroll
int scroll
Definition
tracker.h:110
yaze::app::zelda3::music::SampleEdit::zoom
int zoom
Definition
tracker.h:109
yaze::app::zelda3::music::SongPart
Definition
tracker.h:71
yaze::app::zelda3::music::SongPart::addr
unsigned short addr
Definition
tracker.h:75
yaze::app::zelda3::music::SongPart::tbl
short tbl[8]
Definition
tracker.h:74
yaze::app::zelda3::music::SongPart::flag
uchar flag
Definition
tracker.h:72
yaze::app::zelda3::music::SongPart::inst
uchar inst
Definition
tracker.h:73
yaze::app::zelda3::music::SongRange
Definition
tracker.h:55
yaze::app::zelda3::music::SongRange::end
unsigned short end
Definition
tracker.h:57
yaze::app::zelda3::music::SongRange::filler
unsigned char filler
Definition
tracker.h:64
yaze::app::zelda3::music::SongRange::start
unsigned short start
Definition
tracker.h:56
yaze::app::zelda3::music::SongRange::bank
short bank
Definition
tracker.h:61
yaze::app::zelda3::music::SongRange::editor
int editor
Definition
tracker.h:66
yaze::app::zelda3::music::SongRange::inst
short inst
Definition
tracker.h:60
yaze::app::zelda3::music::SongRange::first
short first
Definition
tracker.h:59
yaze::app::zelda3::music::SongRange::endtime
unsigned char endtime
Definition
tracker.h:63
yaze::app::zelda3::music::SongSpcBlock
Definition
tracker.h:41
yaze::app::zelda3::music::SongSpcBlock::relocs
unsigned short * relocs
Definition
tracker.h:46
yaze::app::zelda3::music::SongSpcBlock::bank
unsigned short bank
Definition
tracker.h:47
yaze::app::zelda3::music::SongSpcBlock::relnum
unsigned short relnum
Definition
tracker.h:44
yaze::app::zelda3::music::SongSpcBlock::relsz
unsigned short relsz
Definition
tracker.h:45
yaze::app::zelda3::music::SongSpcBlock::start
unsigned short start
Definition
tracker.h:42
yaze::app::zelda3::music::SongSpcBlock::buf
unsigned char * buf
Definition
tracker.h:49
yaze::app::zelda3::music::SongSpcBlock::flag
int flag
Definition
tracker.h:50
yaze::app::zelda3::music::SongSpcBlock::addr
unsigned short addr
Definition
tracker.h:48
yaze::app::zelda3::music::SongSpcBlock::len
unsigned short len
Definition
tracker.h:43
yaze::app::zelda3::music::Song
Definition
tracker.h:80
yaze::app::zelda3::music::Song::inst
unsigned char inst
Definition
tracker.h:82
yaze::app::zelda3::music::Song::lopst
short lopst
Definition
tracker.h:85
yaze::app::zelda3::music::Song::addr
unsigned short addr
Definition
tracker.h:86
yaze::app::zelda3::music::Song::numparts
short numparts
Definition
tracker.h:84
yaze::app::zelda3::music::Song::in_use
bool in_use
Definition
tracker.h:87
yaze::app::zelda3::music::Song::flag
unsigned char flag
Definition
tracker.h:81
yaze::app::zelda3::music::Song::tbl
SongPart ** tbl
Definition
tracker.h:83
yaze::app::zelda3::music::SpcCommand
Definition
tracker.h:150
yaze::app::zelda3::music::SpcCommand::cmd
unsigned char cmd
Definition
tracker.h:155
yaze::app::zelda3::music::SpcCommand::flag
unsigned char flag
Definition
tracker.h:154
yaze::app::zelda3::music::SpcCommand::b2
unsigned char b2
Definition
tracker.h:160
yaze::app::zelda3::music::SpcCommand::prev
short prev
Definition
tracker.h:153
yaze::app::zelda3::music::SpcCommand::p3
unsigned char p3
Definition
tracker.h:158
yaze::app::zelda3::music::SpcCommand::tim
unsigned short tim
Definition
tracker.h:162
yaze::app::zelda3::music::SpcCommand::p2
unsigned char p2
Definition
tracker.h:157
yaze::app::zelda3::music::SpcCommand::b1
unsigned char b1
Definition
tracker.h:159
yaze::app::zelda3::music::SpcCommand::tim2
unsigned char tim2
Definition
tracker.h:161
yaze::app::zelda3::music::SpcCommand::addr
unsigned short addr
Definition
tracker.h:151
yaze::app::zelda3::music::SpcCommand::p1
unsigned char p1
Definition
tracker.h:156
yaze::app::zelda3::music::SpcCommand::next
short next
Definition
tracker.h:152
yaze::app::zelda3::music::ZeldaInstrument
Definition
tracker.h:126
yaze::app::zelda3::music::ZeldaInstrument::samp
unsigned char samp
Definition
tracker.h:127
yaze::app::zelda3::music::ZeldaInstrument::ad
unsigned char ad
Definition
tracker.h:128
yaze::app::zelda3::music::ZeldaInstrument::gain
unsigned char gain
Definition
tracker.h:130
yaze::app::zelda3::music::ZeldaInstrument::sr
unsigned char sr
Definition
tracker.h:129
yaze::app::zelda3::music::ZeldaInstrument::multhi
unsigned char multhi
Definition
tracker.h:131
yaze::app::zelda3::music::ZeldaInstrument::multlo
unsigned char multlo
Definition
tracker.h:132
yaze::app::zelda3::music::ZeldaSfxInstrument
Definition
tracker.h:137
yaze::app::zelda3::music::ZeldaSfxInstrument::ad
unsigned char ad
Definition
tracker.h:142
yaze::app::zelda3::music::ZeldaSfxInstrument::volr
unsigned char volr
Definition
tracker.h:139
yaze::app::zelda3::music::ZeldaSfxInstrument::multhi
unsigned char multhi
Definition
tracker.h:145
yaze::app::zelda3::music::ZeldaSfxInstrument::gain
unsigned char gain
Definition
tracker.h:144
yaze::app::zelda3::music::ZeldaSfxInstrument::voll
unsigned char voll
Definition
tracker.h:138
yaze::app::zelda3::music::ZeldaSfxInstrument::freq
short freq
Definition
tracker.h:140
yaze::app::zelda3::music::ZeldaSfxInstrument::sr
unsigned char sr
Definition
tracker.h:143
yaze::app::zelda3::music::ZeldaSfxInstrument::samp
unsigned char samp
Definition
tracker.h:141
yaze::app::zelda3::music::ZeldaWave
Definition
tracker.h:91
yaze::app::zelda3::music::ZeldaWave::buf
short * buf
Definition
tracker.h:96
yaze::app::zelda3::music::ZeldaWave::lopst
int lopst
Definition
tracker.h:92
yaze::app::zelda3::music::ZeldaWave::end
int end
Definition
tracker.h:93
yaze::app::zelda3::music::ZeldaWave::copy
short copy
Definition
tracker.h:95
yaze::app::zelda3::music::ZeldaWave::lflag
short lflag
Definition
tracker.h:94
src
app
zelda3
music
tracker.h
Generated by
1.12.0