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

Imports music_macros.asm format files into MusicSong. More...

#include <asm_importer.h>

Classes

struct  ParseState
 

Public Member Functions

 AsmImporter ()=default
 
 ~AsmImporter ()=default
 
absl::StatusOr< AsmParseResultImportSong (const std::string &asm_source, const AsmImportOptions &options)
 Import a song from ASM string.
 
absl::StatusOr< AsmParseResultImportFromFile (const std::string &path, const AsmImportOptions &options)
 Import a song from a file.
 

Private Member Functions

absl::Status ParseLine (const std::string &line, MusicSong &song, ParseState &state, const AsmImportOptions &options)
 
bool ParseLabel (const std::string &line, ParseState &state)
 
bool ParseDirective (const std::string &line, ParseState &state)
 
absl::Status ParseDataBytes (const std::string &line, MusicSong &song, ParseState &state, const AsmImportOptions &options)
 
absl::StatusOr< std::vector< TrackEvent > > ParseMacro (const std::string &macro_call, ParseState &state, const AsmImportOptions &options)
 
absl::StatusOr< uint8_t > ParseNoteName (const std::string &note_name)
 
absl::StatusOr< uint8_t > ParseDurationConstant (const std::string &duration)
 
absl::StatusOr< MusicCommandResolveInstrumentMacro (const std::string &macro_name)
 
absl::StatusOr< MusicCommandResolveCommandMacro (const std::string &macro_name, const std::vector< uint8_t > &params)
 
bool ParseMacroCall (const std::string &call, std::string &macro_name, std::vector< std::string > &params)
 
absl::StatusOr< uint8_t > ParseHexValue (const std::string &value)
 

Static Private Member Functions

static std::string Trim (const std::string &s)
 

Detailed Description

Imports music_macros.asm format files into MusicSong.

Supports the Oracle of Secrets 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)
  • Channel labels (.Channel0, .Channel1, etc.)

Definition at line 47 of file asm_importer.h.

Constructor & Destructor Documentation

◆ AsmImporter()

yaze::zelda3::music::AsmImporter::AsmImporter ( )
default

◆ ~AsmImporter()

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

Member Function Documentation

◆ ImportSong()

◆ ImportFromFile()

absl::StatusOr< AsmParseResult > yaze::zelda3::music::AsmImporter::ImportFromFile ( const std::string & path,
const AsmImportOptions & options )

Import a song from a file.

Parameters
pathInput file path.
optionsImport options.
Returns
Parse result with song and diagnostics.

Definition at line 57 of file asm_importer.cc.

References ImportSong().

Here is the call graph for this function:

◆ ParseLine()

◆ ParseLabel()

bool yaze::zelda3::music::AsmImporter::ParseLabel ( const std::string & line,
ParseState & state )
private

◆ ParseDirective()

bool yaze::zelda3::music::AsmImporter::ParseDirective ( const std::string & line,
ParseState & state )
private

Definition at line 196 of file asm_importer.cc.

References yaze::zelda3::music::AsmImporter::ParseState::aram_address, yaze::zelda3::name, ParseHexValue(), and Trim().

Referenced by ParseLine().

Here is the call graph for this function:

◆ ParseDataBytes()

◆ ParseMacro()

◆ ParseNoteName()

absl::StatusOr< uint8_t > yaze::zelda3::music::AsmImporter::ParseNoteName ( const std::string & note_name)
private

Definition at line 401 of file asm_importer.cc.

References yaze::zelda3::music::kAsmNoteNames.

Referenced by ParseDataBytes().

◆ ParseDurationConstant()

absl::StatusOr< uint8_t > yaze::zelda3::music::AsmImporter::ParseDurationConstant ( const std::string & duration)
private

Definition at line 410 of file asm_importer.cc.

References yaze::zelda3::music::kDurationConstants, and yaze::zelda3::name.

Referenced by ParseDataBytes(), and ParseMacro().

◆ ResolveInstrumentMacro()

absl::StatusOr< MusicCommand > yaze::zelda3::music::AsmImporter::ResolveInstrumentMacro ( const std::string & macro_name)
private

◆ ResolveCommandMacro()

absl::StatusOr< MusicCommand > yaze::zelda3::music::AsmImporter::ResolveCommandMacro ( const std::string & macro_name,
const std::vector< uint8_t > & params )
private

◆ ParseMacroCall()

bool yaze::zelda3::music::AsmImporter::ParseMacroCall ( const std::string & call,
std::string & macro_name,
std::vector< std::string > & params )
private

Definition at line 458 of file asm_importer.cc.

References Trim().

Referenced by ParseMacro().

Here is the call graph for this function:

◆ ParseHexValue()

absl::StatusOr< uint8_t > yaze::zelda3::music::AsmImporter::ParseHexValue ( const std::string & value)
private

Definition at line 491 of file asm_importer.cc.

Referenced by ParseDataBytes(), ParseDirective(), and ParseMacro().

◆ Trim()

std::string yaze::zelda3::music::AsmImporter::Trim ( const std::string & s)
staticprivate

Definition at line 513 of file asm_importer.cc.

Referenced by ParseDataBytes(), ParseDirective(), ParseLine(), and ParseMacroCall().


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