Refactor tracker: standardize function name casing and remove unnecessary comment separators

This commit is contained in:
scawful
2025-01-02 10:06:29 -05:00
parent 2909809f21
commit 1e8a6cff90
2 changed files with 6 additions and 48 deletions

View File

@@ -20,15 +20,13 @@ namespace yaze {
namespace zelda3 {
namespace {
void AddSPCReloc(music::SongSpcBlock *sbl, short addr) {
void AddSpcReloc(music::SongSpcBlock *sbl, short addr) {
sbl->relocs[sbl->relnum++] = addr;
if (sbl->relnum == sbl->relsz) {
sbl->relsz += 16;
sbl->relocs = (unsigned short *)realloc(sbl->relocs, sbl->relsz << 1);
}
}
} // namespace
namespace music {
@@ -55,8 +53,6 @@ SongSpcBlock *Tracker::AllocSpcBlock(int len, int bank) {
return sbl;
}
// =============================================================================
unsigned char *Tracker::GetSpcAddr(Rom &rom, unsigned short addr, short bank) {
unsigned char *rom_ptr;
unsigned short a;
@@ -91,8 +87,6 @@ again:
}
}
// =============================================================================
short Tracker::AllocSpcCommand() {
int i = m_free;
int j;
@@ -117,8 +111,6 @@ short Tracker::AllocSpcCommand() {
return i;
}
// =============================================================================
short Tracker::GetBlockTime(Rom &rom, short num, short prevtime) {
SpcCommand *spc_command = current_spc_command_;
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;
}
// =============================================================================
short Tracker::LoadSpcCommand(Rom &rom, unsigned short addr, short bank,
int t) {
int b = 0;
@@ -387,8 +377,6 @@ short Tracker::LoadSpcCommand(Rom &rom, unsigned short addr, short bank,
return h;
}
// =============================================================================
void Tracker::LoadSongs(Rom &rom) {
unsigned char *b;
unsigned char *c;
@@ -737,7 +725,7 @@ short Tracker::SaveSpcCommand(Rom &rom, short num, short songtime,
if (spc_command2->cmd == 0xef) {
*(short *)b =
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 += 3;
} else {
@@ -780,8 +768,6 @@ short Tracker::SaveSpcCommand(Rom &rom, short num, short songtime,
return 0;
}
// =============================================================================
int Tracker::WriteSpcData(Rom &rom, void *buf, int len, int addr, int spc,
int limit) {
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;
}
// =============================================================================
void Tracker::SaveSongs(Rom &rom) {
int i;
int j;
@@ -941,7 +925,7 @@ void Tracker::SaveSongs(Rom &rom) {
for (n = 0; n < 8; n++) {
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;
@@ -949,14 +933,14 @@ void Tracker::SaveSongs(Rom &rom) {
spsaved:
((short *)(sptbl->buf))[m] = sp->addr;
AddSPCReloc(sptbl, m << 1);
AddSpcReloc(sptbl, m << 1);
}
if (song.flag & 2) {
((short *)(sptbl->buf))[m++] = 255;
((short *)(sptbl->buf))[m] = sptbl->start + (song.lopst << 1);
AddSPCReloc(sptbl, m << 1);
AddSpcReloc(sptbl, m << 1);
} else
((short *)(sptbl->buf))[m++] = 0;
@@ -965,7 +949,7 @@ void Tracker::SaveSongs(Rom &rom) {
alreadysaved:
((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);
}
// =============================================================================
void Tracker::EditTrack(Rom &rom, short i) {
int j, k, l;
SongRange *sr = song_range_;
@@ -1336,5 +1318,4 @@ void Tracker::NewSR(Rom &rom, int bank) {
} // namespace music
} // namespace zelda3
} // namespace yaze

View File

@@ -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,
1, 3, 3, 0, 1, 3, 0, 3, 3, 3, 1, 2, 0, 0, 0, 0};
// =============================================================================
static int sbank_ofs[] = {0xc8000, 0, 0xd8000, 0};
constexpr char fil1[4] = {0, 15, 61, 115};
@@ -35,7 +33,6 @@ constexpr int kOverworldMusicBank = 0x0D0000;
constexpr int kDungeonMusicBank = 0x0D8000;
using text_buf_ty = char[512];
// ============================================================================
struct SongSpcBlock {
unsigned short start;
@@ -49,8 +46,6 @@ struct SongSpcBlock {
int flag;
};
// =============================================================================
struct SongRange {
unsigned short start;
unsigned short end;
@@ -65,8 +60,6 @@ struct SongRange {
int editor;
};
// =============================================================================
struct SongPart {
uchar flag;
uchar inst;
@@ -74,8 +67,6 @@ struct SongPart {
unsigned short addr;
};
// =============================================================================
struct Song {
unsigned char flag;
unsigned char inst;
@@ -85,7 +76,6 @@ struct Song {
unsigned short addr;
bool in_use; // true
};
// =============================================================================
struct ZeldaWave {
int lopst;
@@ -95,8 +85,6 @@ struct ZeldaWave {
short *buf;
};
// ============================================================================
struct SampleEdit {
unsigned short flag;
unsigned short init;
@@ -120,8 +108,6 @@ struct SampleEdit {
ZeldaWave *zw;
};
// =============================================================================
struct ZeldaInstrument {
unsigned char samp;
unsigned char ad;
@@ -131,8 +117,6 @@ struct ZeldaInstrument {
unsigned char multlo;
};
// =============================================================================
struct ZeldaSfxInstrument {
unsigned char voll;
unsigned char volr;
@@ -144,8 +128,6 @@ struct ZeldaSfxInstrument {
unsigned char multhi;
};
// =============================================================================
struct SpcCommand {
unsigned short addr;
short next;
@@ -161,8 +143,6 @@ struct SpcCommand {
unsigned short tim;
};
// =============================================================================
class Tracker {
public:
SongSpcBlock *AllocSpcBlock(int len, int bank);
@@ -249,11 +229,8 @@ class Tracker {
ZeldaSfxInstrument *sndinsts;
};
// =============================================================================
} // namespace music
} // namespace zelda3
} // namespace yaze
#endif