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
7#include "app/rom.h"
8
9namespace yaze {
10namespace app {
11namespace zelda3 {
12
19namespace music {
20
21// bank 19, 1A, 1B
22// iirc 1A is OW, 1B is dungeon
23// 19 is general spc stuff like samples, ects
24constexpr 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
29static int sbank_ofs[] = {0xc8000, 0, 0xd8000, 0};
30
31constexpr char fil1[4] = {0, 15, 61, 115};
32constexpr char fil2[4] = {0, 4, 5, 6};
33constexpr char fil3[4] = {0, 0, 15, 13};
34
35constexpr int kOverworldMusicBank = 0x0D0000;
36constexpr int kDungeonMusicBank = 0x0D8000;
37
38using text_buf_ty = char[512];
39// ============================================================================
40
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
55struct 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
71struct SongPart {
74 short tbl[8];
75 unsigned short addr;
76};
77
78// =============================================================================
79
80struct Song {
81 unsigned char flag;
82 unsigned char inst;
84 short numparts;
85 short lopst;
86 unsigned short addr;
87 bool in_use; // true
88};
89// =============================================================================
90
91struct ZeldaWave {
92 int lopst;
93 int end;
94 short lflag;
95 short copy;
96 short *buf;
97};
98
99// ============================================================================
100
102 unsigned short flag;
103 unsigned short init;
104 unsigned short editsamp;
105 int width;
107 int pageh;
108 int pagev;
109 int zoom;
111 int page;
112
114 int sell;
115
117 int selr;
118
120
122};
123
124// =============================================================================
125
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
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
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
167class 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
195
200
204
205 int sndinit = 0;
206
209 int m_ofs;
211
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;
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;
245
247
251};
252
253// =============================================================================
254
255} // namespace music
256} // namespace zelda3
257} // namespace app
258} // namespace yaze
259
260#endif
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:136
ZeldaSfxInstrument * sndinsts
Definition tracker.h:250
unsigned char * GetSpcAddr(Rom &rom, unsigned short addr, short bank)
Definition tracker.cc:61
void EditTrack(Rom &rom, short i)
Definition tracker.cc:1266
short LoadSpcCommand(Rom &rom, unsigned short addr, short bank, int t)
Definition tracker.cc:217
int WriteSpcData(Rom &rom, void *buf, int len, int addr, int spc, int limit)
Definition tracker.cc:786
std::vector< Song > songs
Definition tracker.h:241
short SaveSpcCommand(Rom &rom, short num, short songtime, short endtr)
Definition tracker.cc:663
void NewSR(Rom &rom, int bank)
Definition tracker.cc:1316
SongSpcBlock * AllocSpcBlock(int len, int bank)
Definition tracker.cc:36
short GetBlockTime(Rom &rom, short num, short prevtime)
Definition tracker.cc:123
unsigned char uchar
Definition constants.h:114
constexpr int kDungeonMusicBank
Definition tracker.h:36
constexpr int kOverworldMusicBank
Definition tracker.h:35
constexpr char fil3[4]
Definition tracker.h:33
constexpr char fil2[4]
Definition tracker.h:32
constexpr char fil1[4]
Definition tracker.h:31
constexpr char op_len[32]
Definition tracker.h:24
Definition common.cc:22
int selr
Right hand sample selection point.
Definition tracker.h:117
int sell
Left hand sample selection point.
Definition tracker.h:114