Refactor tracker: standardize function name casing and remove unnecessary comment separators
This commit is contained in:
@@ -20,15 +20,13 @@ namespace yaze {
|
|||||||
namespace zelda3 {
|
namespace zelda3 {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
void AddSpcReloc(music::SongSpcBlock *sbl, short addr) {
|
||||||
void AddSPCReloc(music::SongSpcBlock *sbl, short addr) {
|
|
||||||
sbl->relocs[sbl->relnum++] = addr;
|
sbl->relocs[sbl->relnum++] = addr;
|
||||||
if (sbl->relnum == sbl->relsz) {
|
if (sbl->relnum == sbl->relsz) {
|
||||||
sbl->relsz += 16;
|
sbl->relsz += 16;
|
||||||
sbl->relocs = (unsigned short *)realloc(sbl->relocs, sbl->relsz << 1);
|
sbl->relocs = (unsigned short *)realloc(sbl->relocs, sbl->relsz << 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace music {
|
namespace music {
|
||||||
@@ -55,8 +53,6 @@ SongSpcBlock *Tracker::AllocSpcBlock(int len, int bank) {
|
|||||||
return sbl;
|
return sbl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
unsigned char *Tracker::GetSpcAddr(Rom &rom, unsigned short addr, short bank) {
|
unsigned char *Tracker::GetSpcAddr(Rom &rom, unsigned short addr, short bank) {
|
||||||
unsigned char *rom_ptr;
|
unsigned char *rom_ptr;
|
||||||
unsigned short a;
|
unsigned short a;
|
||||||
@@ -91,8 +87,6 @@ again:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
short Tracker::AllocSpcCommand() {
|
short Tracker::AllocSpcCommand() {
|
||||||
int i = m_free;
|
int i = m_free;
|
||||||
int j;
|
int j;
|
||||||
@@ -117,8 +111,6 @@ short Tracker::AllocSpcCommand() {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
short Tracker::GetBlockTime(Rom &rom, short num, short prevtime) {
|
short Tracker::GetBlockTime(Rom &rom, short num, short prevtime) {
|
||||||
SpcCommand *spc_command = current_spc_command_;
|
SpcCommand *spc_command = current_spc_command_;
|
||||||
SpcCommand *spc_command2;
|
SpcCommand *spc_command2;
|
||||||
@@ -211,8 +203,6 @@ short Tracker::GetBlockTime(Rom &rom, short num, short prevtime) {
|
|||||||
return spc_command[num].tim + prevtime * spc_command[num].tim2;
|
return spc_command[num].tim + prevtime * spc_command[num].tim2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
short Tracker::LoadSpcCommand(Rom &rom, unsigned short addr, short bank,
|
short Tracker::LoadSpcCommand(Rom &rom, unsigned short addr, short bank,
|
||||||
int t) {
|
int t) {
|
||||||
int b = 0;
|
int b = 0;
|
||||||
@@ -387,8 +377,6 @@ short Tracker::LoadSpcCommand(Rom &rom, unsigned short addr, short bank,
|
|||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
void Tracker::LoadSongs(Rom &rom) {
|
void Tracker::LoadSongs(Rom &rom) {
|
||||||
unsigned char *b;
|
unsigned char *b;
|
||||||
unsigned char *c;
|
unsigned char *c;
|
||||||
@@ -737,7 +725,7 @@ short Tracker::SaveSpcCommand(Rom &rom, short num, short songtime,
|
|||||||
if (spc_command2->cmd == 0xef) {
|
if (spc_command2->cmd == 0xef) {
|
||||||
*(short *)b =
|
*(short *)b =
|
||||||
SaveSpcCommand(rom, *(short *)&(spc_command2->p1), 0, 1);
|
SaveSpcCommand(rom, *(short *)&(spc_command2->p1), 0, 1);
|
||||||
if (b) AddSPCReloc(sbl, b - sbl->buf);
|
if (b) AddSpcReloc(sbl, b - sbl->buf);
|
||||||
b[2] = spc_command2->p3;
|
b[2] = spc_command2->p3;
|
||||||
b += 3;
|
b += 3;
|
||||||
} else {
|
} else {
|
||||||
@@ -780,8 +768,6 @@ short Tracker::SaveSpcCommand(Rom &rom, short num, short songtime,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
int Tracker::WriteSpcData(Rom &rom, void *buf, int len, int addr, int spc,
|
int Tracker::WriteSpcData(Rom &rom, void *buf, int len, int addr, int spc,
|
||||||
int limit) {
|
int limit) {
|
||||||
unsigned char *rom_data = rom.mutable_data();
|
unsigned char *rom_data = rom.mutable_data();
|
||||||
@@ -810,8 +796,6 @@ int Tracker::WriteSpcData(Rom &rom, void *buf, int len, int addr, int spc,
|
|||||||
return addr + len + 4;
|
return addr + len + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
void Tracker::SaveSongs(Rom &rom) {
|
void Tracker::SaveSongs(Rom &rom) {
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
@@ -941,7 +925,7 @@ void Tracker::SaveSongs(Rom &rom) {
|
|||||||
for (n = 0; n < 8; n++) {
|
for (n = 0; n < 8; n++) {
|
||||||
core::stle16b_i(trtbl->buf, n, SaveSpcCommand(rom, sp->tbl[n], p, q));
|
core::stle16b_i(trtbl->buf, n, SaveSpcCommand(rom, sp->tbl[n], p, q));
|
||||||
|
|
||||||
if (core::ldle16b_i(trtbl->buf, n)) AddSPCReloc(trtbl, n << 1), q = 0;
|
if (core::ldle16b_i(trtbl->buf, n)) AddSpcReloc(trtbl, n << 1), q = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sp->addr = trtbl->start;
|
sp->addr = trtbl->start;
|
||||||
@@ -949,14 +933,14 @@ void Tracker::SaveSongs(Rom &rom) {
|
|||||||
spsaved:
|
spsaved:
|
||||||
((short *)(sptbl->buf))[m] = sp->addr;
|
((short *)(sptbl->buf))[m] = sp->addr;
|
||||||
|
|
||||||
AddSPCReloc(sptbl, m << 1);
|
AddSpcReloc(sptbl, m << 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (song.flag & 2) {
|
if (song.flag & 2) {
|
||||||
((short *)(sptbl->buf))[m++] = 255;
|
((short *)(sptbl->buf))[m++] = 255;
|
||||||
((short *)(sptbl->buf))[m] = sptbl->start + (song.lopst << 1);
|
((short *)(sptbl->buf))[m] = sptbl->start + (song.lopst << 1);
|
||||||
|
|
||||||
AddSPCReloc(sptbl, m << 1);
|
AddSpcReloc(sptbl, m << 1);
|
||||||
} else
|
} else
|
||||||
((short *)(sptbl->buf))[m++] = 0;
|
((short *)(sptbl->buf))[m++] = 0;
|
||||||
|
|
||||||
@@ -965,7 +949,7 @@ void Tracker::SaveSongs(Rom &rom) {
|
|||||||
alreadysaved:
|
alreadysaved:
|
||||||
((short *)(stbl->buf))[j] = song.addr;
|
((short *)(stbl->buf))[j] = song.addr;
|
||||||
|
|
||||||
AddSPCReloc(stbl, j << 1);
|
AddSpcReloc(stbl, j << 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1260,8 +1244,6 @@ void Tracker::SaveSongs(Rom &rom) {
|
|||||||
free(ssblt);
|
free(ssblt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
void Tracker::EditTrack(Rom &rom, short i) {
|
void Tracker::EditTrack(Rom &rom, short i) {
|
||||||
int j, k, l;
|
int j, k, l;
|
||||||
SongRange *sr = song_range_;
|
SongRange *sr = song_range_;
|
||||||
@@ -1336,5 +1318,4 @@ void Tracker::NewSR(Rom &rom, int bank) {
|
|||||||
|
|
||||||
} // namespace music
|
} // namespace music
|
||||||
} // namespace zelda3
|
} // namespace zelda3
|
||||||
|
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ namespace music {
|
|||||||
constexpr char op_len[32] = {1, 1, 2, 3, 0, 1, 2, 1, 2, 1, 1, 3, 0, 1, 2, 3,
|
constexpr char op_len[32] = {1, 1, 2, 3, 0, 1, 2, 1, 2, 1, 1, 3, 0, 1, 2, 3,
|
||||||
1, 3, 3, 0, 1, 3, 0, 3, 3, 3, 1, 2, 0, 0, 0, 0};
|
1, 3, 3, 0, 1, 3, 0, 3, 3, 3, 1, 2, 0, 0, 0, 0};
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
static int sbank_ofs[] = {0xc8000, 0, 0xd8000, 0};
|
static int sbank_ofs[] = {0xc8000, 0, 0xd8000, 0};
|
||||||
|
|
||||||
constexpr char fil1[4] = {0, 15, 61, 115};
|
constexpr char fil1[4] = {0, 15, 61, 115};
|
||||||
@@ -35,7 +33,6 @@ constexpr int kOverworldMusicBank = 0x0D0000;
|
|||||||
constexpr int kDungeonMusicBank = 0x0D8000;
|
constexpr int kDungeonMusicBank = 0x0D8000;
|
||||||
|
|
||||||
using text_buf_ty = char[512];
|
using text_buf_ty = char[512];
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
struct SongSpcBlock {
|
struct SongSpcBlock {
|
||||||
unsigned short start;
|
unsigned short start;
|
||||||
@@ -49,8 +46,6 @@ struct SongSpcBlock {
|
|||||||
int flag;
|
int flag;
|
||||||
};
|
};
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
struct SongRange {
|
struct SongRange {
|
||||||
unsigned short start;
|
unsigned short start;
|
||||||
unsigned short end;
|
unsigned short end;
|
||||||
@@ -65,8 +60,6 @@ struct SongRange {
|
|||||||
int editor;
|
int editor;
|
||||||
};
|
};
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
struct SongPart {
|
struct SongPart {
|
||||||
uchar flag;
|
uchar flag;
|
||||||
uchar inst;
|
uchar inst;
|
||||||
@@ -74,8 +67,6 @@ struct SongPart {
|
|||||||
unsigned short addr;
|
unsigned short addr;
|
||||||
};
|
};
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
struct Song {
|
struct Song {
|
||||||
unsigned char flag;
|
unsigned char flag;
|
||||||
unsigned char inst;
|
unsigned char inst;
|
||||||
@@ -85,7 +76,6 @@ struct Song {
|
|||||||
unsigned short addr;
|
unsigned short addr;
|
||||||
bool in_use; // true
|
bool in_use; // true
|
||||||
};
|
};
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
struct ZeldaWave {
|
struct ZeldaWave {
|
||||||
int lopst;
|
int lopst;
|
||||||
@@ -95,8 +85,6 @@ struct ZeldaWave {
|
|||||||
short *buf;
|
short *buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
struct SampleEdit {
|
struct SampleEdit {
|
||||||
unsigned short flag;
|
unsigned short flag;
|
||||||
unsigned short init;
|
unsigned short init;
|
||||||
@@ -120,8 +108,6 @@ struct SampleEdit {
|
|||||||
ZeldaWave *zw;
|
ZeldaWave *zw;
|
||||||
};
|
};
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
struct ZeldaInstrument {
|
struct ZeldaInstrument {
|
||||||
unsigned char samp;
|
unsigned char samp;
|
||||||
unsigned char ad;
|
unsigned char ad;
|
||||||
@@ -131,8 +117,6 @@ struct ZeldaInstrument {
|
|||||||
unsigned char multlo;
|
unsigned char multlo;
|
||||||
};
|
};
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
struct ZeldaSfxInstrument {
|
struct ZeldaSfxInstrument {
|
||||||
unsigned char voll;
|
unsigned char voll;
|
||||||
unsigned char volr;
|
unsigned char volr;
|
||||||
@@ -144,8 +128,6 @@ struct ZeldaSfxInstrument {
|
|||||||
unsigned char multhi;
|
unsigned char multhi;
|
||||||
};
|
};
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
struct SpcCommand {
|
struct SpcCommand {
|
||||||
unsigned short addr;
|
unsigned short addr;
|
||||||
short next;
|
short next;
|
||||||
@@ -161,8 +143,6 @@ struct SpcCommand {
|
|||||||
unsigned short tim;
|
unsigned short tim;
|
||||||
};
|
};
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
class Tracker {
|
class Tracker {
|
||||||
public:
|
public:
|
||||||
SongSpcBlock *AllocSpcBlock(int len, int bank);
|
SongSpcBlock *AllocSpcBlock(int len, int bank);
|
||||||
@@ -249,11 +229,8 @@ class Tracker {
|
|||||||
ZeldaSfxInstrument *sndinsts;
|
ZeldaSfxInstrument *sndinsts;
|
||||||
};
|
};
|
||||||
|
|
||||||
// =============================================================================
|
|
||||||
|
|
||||||
} // namespace music
|
} // namespace music
|
||||||
} // namespace zelda3
|
} // namespace zelda3
|
||||||
|
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user