yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::zelda3::music::AsmExporter Class Reference

Exports MusicSong to Oracle of Secrets music_macros.asm format. More...

#include <asm_exporter.h>

Public Member Functions

 AsmExporter ()=default
 
 ~AsmExporter ()=default
 
absl::StatusOr< std::string > ExportSong (const MusicSong &song, const AsmExportOptions &options)
 Export a song to ASM string.
 
absl::Status ExportToFile (const MusicSong &song, const std::string &path, const AsmExportOptions &options)
 Export a song to a file.
 

Private Member Functions

std::string GenerateHeader (const MusicSong &song, const AsmExportOptions &options)
 
std::string GenerateChannelPointers (const MusicSong &song, const AsmExportOptions &options)
 
std::string GenerateChannelData (const MusicTrack &track, int channel_index, const AsmExportOptions &options)
 
std::string ConvertEventToAsm (const TrackEvent &event, const AsmExportOptions &options, uint8_t &current_duration)
 
std::string ConvertNoteToAsm (const Note &note, const AsmExportOptions &options, uint8_t &current_duration)
 
std::string ConvertCommandToAsm (const MusicCommand &cmd, const AsmExportOptions &options)
 

Static Private Member Functions

static const char * GetDurationConstant (uint8_t duration)
 
static std::string GetNoteName (uint8_t pitch)
 
static const char * GetInstrumentMacro (uint8_t instrument_id)
 
static const char * GetCommandMacro (uint8_t opcode)
 
static int GetCommandParamCount (uint8_t opcode)
 

Detailed Description

Exports MusicSong to Oracle of Secrets music_macros.asm format.

The exported ASM file can be assembled with asar and integrated into Oracle of Secrets or similar ROM hack music systems.

Output format follows the music_macros.asm conventions:

  • Duration constants (!4th, !8th, etc.)
  • Instrument helper macros (Piano(), Strings(), etc.)
  • N-SPC command macros (SetTempo, SetPan, etc.)
  • ARAM address calculations (!ARAMAddr, !ARAMC)

Definition at line 41 of file asm_exporter.h.

Constructor & Destructor Documentation

◆ AsmExporter()

yaze::zelda3::music::AsmExporter::AsmExporter ( )
default

◆ ~AsmExporter()

yaze::zelda3::music::AsmExporter::~AsmExporter ( )
default

Member Function Documentation

◆ ExportSong()

absl::StatusOr< std::string > yaze::zelda3::music::AsmExporter::ExportSong ( const MusicSong & song,
const AsmExportOptions & options )

Export a song to ASM string.

Parameters
songThe song to export.
optionsExport options.
Returns
ASM source code string or error.

Definition at line 12 of file asm_exporter.cc.

References GenerateChannelData(), GenerateChannelPointers(), GenerateHeader(), yaze::zelda3::music::AsmExportOptions::include_comments, yaze::zelda3::music::MusicSong::name, and yaze::zelda3::music::MusicSong::segments.

Referenced by yaze::editor::MusicEditor::ExportSongToAsm(), and ExportToFile().

Here is the call graph for this function:

◆ ExportToFile()

absl::Status yaze::zelda3::music::AsmExporter::ExportToFile ( const MusicSong & song,
const std::string & path,
const AsmExportOptions & options )

Export a song to a file.

Parameters
songThe song to export.
pathOutput file path.
optionsExport options.
Returns
Status indicating success or failure.

Definition at line 53 of file asm_exporter.cc.

References ExportSong().

Here is the call graph for this function:

◆ GenerateHeader()

std::string yaze::zelda3::music::AsmExporter::GenerateHeader ( const MusicSong & song,
const AsmExportOptions & options )
private

◆ GenerateChannelPointers()

std::string yaze::zelda3::music::AsmExporter::GenerateChannelPointers ( const MusicSong & song,
const AsmExportOptions & options )
private

◆ GenerateChannelData()

std::string yaze::zelda3::music::AsmExporter::GenerateChannelData ( const MusicTrack & track,
int channel_index,
const AsmExportOptions & options )
private

Definition at line 129 of file asm_exporter.cc.

References ConvertEventToAsm(), and yaze::zelda3::music::MusicTrack::events.

Referenced by ExportSong().

Here is the call graph for this function:

◆ ConvertEventToAsm()

std::string yaze::zelda3::music::AsmExporter::ConvertEventToAsm ( const TrackEvent & event,
const AsmExportOptions & options,
uint8_t & current_duration )
private

◆ ConvertNoteToAsm()

std::string yaze::zelda3::music::AsmExporter::ConvertNoteToAsm ( const Note & note,
const AsmExportOptions & options,
uint8_t & current_duration )
private

◆ ConvertCommandToAsm()

std::string yaze::zelda3::music::AsmExporter::ConvertCommandToAsm ( const MusicCommand & cmd,
const AsmExportOptions & options )
private

◆ GetDurationConstant()

const char * yaze::zelda3::music::AsmExporter::GetDurationConstant ( uint8_t duration)
staticprivate

Definition at line 233 of file asm_exporter.cc.

References yaze::zelda3::music::kDurationConstants.

Referenced by ConvertNoteToAsm().

◆ GetNoteName()

std::string yaze::zelda3::music::AsmExporter::GetNoteName ( uint8_t pitch)
staticprivate

◆ GetInstrumentMacro()

const char * yaze::zelda3::music::AsmExporter::GetInstrumentMacro ( uint8_t instrument_id)
staticprivate

Definition at line 263 of file asm_exporter.cc.

References yaze::zelda3::music::kInstrumentMacros.

Referenced by ConvertCommandToAsm().

◆ GetCommandMacro()

const char * yaze::zelda3::music::AsmExporter::GetCommandMacro ( uint8_t opcode)
staticprivate

Definition at line 272 of file asm_exporter.cc.

Referenced by ConvertCommandToAsm().

◆ GetCommandParamCount()

int yaze::zelda3::music::AsmExporter::GetCommandParamCount ( uint8_t opcode)
staticprivate

Definition at line 305 of file asm_exporter.cc.

References yaze::zelda3::music::kCommandParamCount.

Referenced by ConvertCommandToAsm().


The documentation for this class was generated from the following files: