#include <tracker.h>
Public Member Functions | |
SongSpcBlock * | AllocSpcBlock (int len, int bank) |
Allocates a new SongSpcBlock for holding generated SPC data. These blocks are the building blocks for the final binary output that will be written to the ROM and eventually loaded into the APU. | |
unsigned char * | GetSpcAddr (Rom &rom, unsigned short addr, short bank) |
Gets a direct pointer to music data within the ROM. This function is critical for parsing. It correctly resolves a virtual SPC address and bank into a physical offset within the loaded ROM file, handling the game's specific sound bank mapping. | |
short | AllocSpcCommand () |
Allocates a new SpcCommand from a pre-allocated pool. This uses a classic free-list implementation for efficient memory management without repeated malloc/free calls. | |
short | GetBlockTime (Rom &rom, short num, short prevtime) |
Calculates the total time (duration) of a block of SpcCommands. This is essential for synchronization and editor display. It works backwards from the end of a command list, calculating and caching the duration. | |
short | SaveSpcCommand (Rom &rom, short num, short songtime, short endtr) |
Saves a block of edited SpcCommands back into a binary format. This is the serializer, the inverse of LoadSpcCommand. It walks the linked list of commands and writes the corresponding bytes into a new SongSpcBlock. | |
short | LoadSpcCommand (Rom &rom, unsigned short addr, short bank, int t) |
Loads a block of music data from a given ROM address. This is the main parser. It reads the raw byte stream from the ROM and converts it into a doubly-linked list of SpcCommand structs. | |
void | SaveSongs (Rom &rom) |
High-level function to save all modified song data back to the ROM. (Currently commented out, but this would orchestrate the entire save process.) This function would be responsible for taking all the edited, in-memory SongSpcBlocks, arranging them into a final binary layout, patching all the relocated pointers, and writing the result back into the ROM file using WriteSpcData. | |
void | LoadSongs (Rom &rom) |
High-level function to load all song data from the ROM. (Currently commented out, but this would be the main entry point for parsing.) It would iterate through the main song table in the ROM, and for each song, recursively load all its parts and commands using LoadSpcCommand. It would also load instrument and sample data. | |
int | WriteSpcData (Rom &rom, void *buf, int len, int addr, int spc, int limit) |
Writes a prepared data block into the ROM file. This is a utility for SaveSongs, formatting the data with a header containing the length and target SPC address. | |
void | EditTrack (Rom &rom, short i) |
Opens an editor window for a specific track. (Legacy UI-related function) | |
void | NewSR (Rom &rom, int bank) |
Creates a new, empty song range (SongRange) and opens it for editing. (Legacy UI-related function) | |
Private Member Functions | |
const SpcCommand & | GetSpcCommand (short index) const |
Private Attributes | |
int | modf |
int | mark_sr |
int | mark_start |
int | mark_end |
int | mark_first |
int | mark_last |
int | numwave |
int | numinst |
int | numsndinst |
int | sndinit = 0 |
int | sndlen1 |
int | sndlen2 |
int | m_ofs |
int | w_modf |
int | ss_num |
int | ss_size |
char | op_len [32] |
char * | snddat1 |
char * | snddat2 |
unsigned short | ss_next = 0 |
unsigned short | spclen |
unsigned short | numseg |
short | spcbank |
short | lastsr |
short | ss_lasttime |
short | srnum |
short | srsize |
short | numsong [3] |
short | m_size |
short | m_free |
short | m_modf |
short | m_loaded |
short | t_loaded |
short | t_modf |
short | withhead |
size_t | t_number |
std::vector< Song > | songs |
SongPart * | sp_mark |
SongRange * | song_range_ |
SpcCommand * | current_spc_command_ |
SongSpcBlock ** | ssblt |
ZeldaWave * | waves |
ZeldaInstrument * | insts |
ZeldaSfxInstrument * | sndinsts |
SongSpcBlock * yaze::zelda3::music::Tracker::AllocSpcBlock | ( | int | len, |
int | bank | ||
) |
Allocates a new SongSpcBlock for holding generated SPC data. These blocks are the building blocks for the final binary output that will be written to the ROM and eventually loaded into the APU.
len | The size of the data buffer to allocate for this block. |
bank | The target sound bank for this block. |
Definition at line 42 of file tracker.cc.
References yaze::zelda3::music::SongSpcBlock::bank, yaze::zelda3::music::SongSpcBlock::buf, yaze::zelda3::music::SongSpcBlock::flag, yaze::zelda3::music::SongSpcBlock::len, yaze::zelda3::music::SongSpcBlock::relnum, yaze::zelda3::music::SongSpcBlock::relocs, yaze::zelda3::music::SongSpcBlock::relsz, ss_next, ss_num, ss_size, ssblt, and yaze::zelda3::music::SongSpcBlock::start.
Referenced by SaveSpcCommand().
unsigned char * yaze::zelda3::music::Tracker::GetSpcAddr | ( | Rom & | rom, |
unsigned short | addr, | ||
short | bank | ||
) |
Gets a direct pointer to music data within the ROM. This function is critical for parsing. It correctly resolves a virtual SPC address and bank into a physical offset within the loaded ROM file, handling the game's specific sound bank mapping.
rom | The ROM object. |
addr | The 16-bit virtual address of the data. |
bank | The sound bank where the data resides. |
Definition at line 75 of file tracker.cc.
References yaze::Rom::mutable_data(), spcbank, and spclen.
Referenced by LoadSpcCommand().
short yaze::zelda3::music::Tracker::AllocSpcCommand | ( | ) |
Allocates a new SpcCommand from a pre-allocated pool. This uses a classic free-list implementation for efficient memory management without repeated malloc/free calls.
Definition at line 115 of file tracker.cc.
References current_spc_command_, m_free, m_size, yaze::zelda3::music::SpcCommand::next, and yaze::zelda3::music::SpcCommand::prev.
Referenced by NewSR().
short yaze::zelda3::music::Tracker::GetBlockTime | ( | Rom & | rom, |
short | num, | ||
short | prevtime | ||
) |
Calculates the total time (duration) of a block of SpcCommands. This is essential for synchronization and editor display. It works backwards from the end of a command list, calculating and caching the duration.
rom | The ROM object. |
num | The starting command index. |
prevtime | The duration of the subsequent block. |
Definition at line 148 of file tracker.cc.
References yaze::zelda3::music::SpcCommand::b1, yaze::zelda3::music::SpcCommand::cmd, current_spc_command_, yaze::zelda3::music::SpcCommand::flag, GetBlockTime(), m_modf, m_size, yaze::zelda3::music::SpcCommand::next, yaze::zelda3::music::SpcCommand::p1, yaze::zelda3::music::SpcCommand::p3, yaze::zelda3::music::SpcCommand::prev, ss_lasttime, yaze::zelda3::music::SpcCommand::tim, and yaze::zelda3::music::SpcCommand::tim2.
Referenced by GetBlockTime(), LoadSpcCommand(), and SaveSpcCommand().
short yaze::zelda3::music::Tracker::SaveSpcCommand | ( | Rom & | rom, |
short | num, | ||
short | songtime, | ||
short | endtr | ||
) |
Saves a block of edited SpcCommands back into a binary format. This is the serializer, the inverse of LoadSpcCommand. It walks the linked list of commands and writes the corresponding bytes into a new SongSpcBlock.
rom | The ROM object. |
num | The index of the first command to save. |
songtime | The total duration of the song, used for padding. |
endtr | Flag indicating if this is the end of a track. |
Definition at line 711 of file tracker.cc.
References yaze::zelda3::music::SpcCommand::addr, AllocSpcBlock(), yaze::zelda3::music::SpcCommand::b1, yaze::zelda3::music::SpcCommand::b2, yaze::zelda3::music::SongSpcBlock::buf, yaze::zelda3::music::SpcCommand::cmd, current_spc_command_, yaze::zelda3::music::SpcCommand::flag, GetBlockTime(), m_modf, m_size, yaze::zelda3::music::SpcCommand::next, op_len, yaze::zelda3::music::SpcCommand::p1, yaze::zelda3::music::SpcCommand::p2, yaze::zelda3::music::SpcCommand::p3, yaze::zelda3::music::SpcCommand::prev, SaveSpcCommand(), song_range_, srnum, and yaze::zelda3::music::SongSpcBlock::start.
Referenced by SaveSpcCommand().
short yaze::zelda3::music::Tracker::LoadSpcCommand | ( | Rom & | rom, |
unsigned short | addr, | ||
short | bank, | ||
int | t | ||
) |
Loads a block of music data from a given ROM address. This is the main parser. It reads the raw byte stream from the ROM and converts it into a doubly-linked list of SpcCommand structs.
rom | The ROM object. |
addr | The starting address in the ROM. |
bank | The sound bank. |
t | A time limit for parsing, to handle potentially infinite loops. |
Definition at line 250 of file tracker.cc.
References yaze::zelda3::music::SpcCommand::addr, yaze::zelda3::music::SpcCommand::b1, yaze::zelda3::music::SpcCommand::b2, yaze::zelda3::music::SongRange::bank, yaze::zelda3::music::SpcCommand::cmd, current_spc_command_, yaze::zelda3::music::SongRange::editor, yaze::zelda3::music::SongRange::end, yaze::zelda3::music::SongRange::endtime, yaze::zelda3::music::SongRange::first, yaze::zelda3::music::SpcCommand::flag, GetBlockTime(), GetSpcAddr(), yaze::zelda3::music::SongRange::inst, lastsr, LoadSpcCommand(), m_free, m_size, yaze::zelda3::music::SpcCommand::next, op_len, yaze::zelda3::music::SpcCommand::p1, yaze::zelda3::music::SpcCommand::p2, yaze::zelda3::music::SpcCommand::p3, yaze::zelda3::music::SpcCommand::prev, song_range_, spcbank, srnum, srsize, yaze::zelda3::music::SongRange::start, yaze::zelda3::music::SpcCommand::tim, and yaze::zelda3::music::SpcCommand::tim2.
Referenced by LoadSpcCommand().
void yaze::zelda3::music::Tracker::SaveSongs | ( | Rom & | rom | ) |
High-level function to save all modified song data back to the ROM. (Currently commented out, but this would orchestrate the entire save process.) This function would be responsible for taking all the edited, in-memory SongSpcBlocks, arranging them into a final binary layout, patching all the relocated pointers, and writing the result back into the ROM file using WriteSpcData.
Definition at line 880 of file tracker.cc.
void yaze::zelda3::music::Tracker::LoadSongs | ( | Rom & | rom | ) |
High-level function to load all song data from the ROM. (Currently commented out, but this would be the main entry point for parsing.) It would iterate through the main song table in the ROM, and for each song, recursively load all its parts and commands using LoadSpcCommand. It would also load instrument and sample data.
Definition at line 431 of file tracker.cc.
Referenced by yaze::editor::MusicEditor::DrawToolset().
int yaze::zelda3::music::Tracker::WriteSpcData | ( | Rom & | rom, |
void * | buf, | ||
int | len, | ||
int | addr, | ||
int | spc, | ||
int | limit | ||
) |
Writes a prepared data block into the ROM file. This is a utility for SaveSongs, formatting the data with a header containing the length and target SPC address.
rom | The ROM object. |
buf | The data to write. |
len | The length of the data. |
addr | The ROM address to write to. |
spc | The target SPC address for this data. |
limit | The upper bound for writing in the ROM. |
Definition at line 844 of file tracker.cc.
References m_modf, and yaze::Rom::mutable_data().
void yaze::zelda3::music::Tracker::EditTrack | ( | Rom & | rom, |
short | i | ||
) |
Opens an editor window for a specific track. (Legacy UI-related function)
rom | The ROM object. |
i | The index of the first command of the track to edit. |
Definition at line 1334 of file tracker.cc.
References current_spc_command_, yaze::zelda3::music::SongRange::first, m_size, song_range_, and srnum.
Referenced by NewSR().
void yaze::zelda3::music::Tracker::NewSR | ( | Rom & | rom, |
int | bank | ||
) |
Creates a new, empty song range (SongRange) and opens it for editing. (Legacy UI-related function)
rom | The ROM object. |
bank | The target bank for the new song. |
Definition at line 1390 of file tracker.cc.
References AllocSpcCommand(), yaze::zelda3::music::SongRange::bank, yaze::zelda3::music::SpcCommand::cmd, current_spc_command_, yaze::zelda3::music::SongRange::editor, EditTrack(), yaze::zelda3::music::SongRange::first, yaze::zelda3::music::SpcCommand::flag, yaze::zelda3::music::SpcCommand::next, yaze::zelda3::music::SpcCommand::prev, song_range_, srnum, and srsize.
|
inlineprivate |
Definition at line 268 of file tracker.h.
References current_spc_command_.
|
private |
Definition at line 234 of file tracker.h.
Referenced by AllocSpcBlock().
|
private |
Definition at line 235 of file tracker.h.
Referenced by AllocSpcBlock().
|
private |
Definition at line 237 of file tracker.h.
Referenced by LoadSpcCommand(), and SaveSpcCommand().
|
private |
Definition at line 242 of file tracker.h.
Referenced by AllocSpcBlock().
|
private |
Definition at line 243 of file tracker.h.
Referenced by GetSpcAddr().
|
private |
|
private |
Definition at line 246 of file tracker.h.
Referenced by GetSpcAddr(), and LoadSpcCommand().
|
private |
Definition at line 247 of file tracker.h.
Referenced by LoadSpcCommand().
|
private |
Definition at line 248 of file tracker.h.
Referenced by GetBlockTime().
|
private |
Definition at line 249 of file tracker.h.
Referenced by EditTrack(), LoadSpcCommand(), NewSR(), and SaveSpcCommand().
|
private |
Definition at line 250 of file tracker.h.
Referenced by LoadSpcCommand(), and NewSR().
|
private |
Definition at line 252 of file tracker.h.
Referenced by AllocSpcCommand(), EditTrack(), GetBlockTime(), LoadSpcCommand(), and SaveSpcCommand().
|
private |
Definition at line 253 of file tracker.h.
Referenced by AllocSpcCommand(), and LoadSpcCommand().
|
private |
Definition at line 254 of file tracker.h.
Referenced by GetBlockTime(), SaveSpcCommand(), and WriteSpcData().
|
private |
|
private |
Definition at line 265 of file tracker.h.
Referenced by EditTrack(), LoadSpcCommand(), NewSR(), and SaveSpcCommand().
|
private |
Definition at line 266 of file tracker.h.
Referenced by AllocSpcCommand(), EditTrack(), GetBlockTime(), GetSpcCommand(), LoadSpcCommand(), NewSR(), and SaveSpcCommand().
|
private |
Definition at line 272 of file tracker.h.
Referenced by AllocSpcBlock().
|
private |
|
private |