yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
spc_serializer.h
Go to the documentation of this file.
1#ifndef YAZE_ZELDA3_MUSIC_SPC_SERIALIZER_H
2#define YAZE_ZELDA3_MUSIC_SPC_SERIALIZER_H
3
4#include <cstdint>
5#include <string>
6#include <vector>
7
8#include "absl/status/statusor.h"
10
11namespace yaze {
12namespace zelda3 {
13namespace music {
14
25class SpcSerializer {
26 public:
31 uint16_t base_aram_address = 0xD000; // Target ARAM address for song table
32 bool include_header = true; // Include song header structure
33 };
34
38 struct SerializeResult {
39 std::vector<uint8_t> data;
40 uint16_t base_address;
41 std::vector<uint16_t> relocations;
42 };
43
44 SpcSerializer() = default;
45 ~SpcSerializer() = default;
46
47 static absl::StatusOr<SerializeResult> SerializeSong(const MusicSong& song,
48 uint16_t base_address);
49
56 static absl::StatusOr<SerializeResult> SerializeSongFromSegment(
57 const MusicSong& song, int start_segment, uint16_t base_address);
58
59 static void ApplyBaseAddress(SerializeResult* result,
60 uint16_t new_base_address);
61
62 static int CalculateRequiredSpace(const MusicSong& song);
63
64 private:
65 static std::vector<uint8_t> SerializeTrack(const MusicTrack& track);
66 static std::vector<uint8_t> SerializeNote(const Note& note,
67 uint8_t* current_duration);
68 static std::vector<uint8_t> SerializeCommand(const MusicCommand& command);
69
70 private:
71
72};
73
74} // namespace music
75} // namespace zelda3
76} // namespace yaze
77
78#endif // YAZE_ZELDA3_MUSIC_SPC_SERIALIZER_H
static std::vector< uint8_t > SerializeTrack(const MusicTrack &track)
static std::vector< uint8_t > SerializeCommand(const MusicCommand &command)
static absl::StatusOr< SerializeResult > SerializeSong(const MusicSong &song, uint16_t base_address)
static int CalculateRequiredSpace(const MusicSong &song)
static absl::StatusOr< SerializeResult > SerializeSongFromSegment(const MusicSong &song, int start_segment, uint16_t base_address)
Serialize a song starting from a specific segment (for seeking).
static std::vector< uint8_t > SerializeNote(const Note &note, uint8_t *current_duration)
static void ApplyBaseAddress(SerializeResult *result, uint16_t new_base_address)
Represents an N-SPC command (opcodes 0xE0-0xFF).
Definition song_data.h:222
A complete song composed of segments.
Definition song_data.h:334
One of 8 channels in a music segment.
Definition song_data.h:291
Represents a single musical note.
Definition song_data.h:192
Result of serialization with relocation info.
Definition spc_parser.h:180