Add player name entry, dedicated menu music, and original Bullfrog menu fonts
This commit is contained in:
1 parent
c017d27b2a
commit
6c24f715a0
13 files changed
+835
-199
No files matched your search
@@ -9,12 +9,13 @@ void XmidiPlayer::set_sample_rate(int sample_rate) {
|
||||
samples_per_tick_ = static_cast<double>(sample_rate_) / 120.0;
|
||||
}
|
||||
|
||||
void XmidiPlayer::set_sequence(const assets::XmiSequence* seq, bool loop) {
|
||||
void XmidiPlayer::set_sequence(const assets::XmiSequence* seq, bool loop, uint32_t start_tick) {
|
||||
seq_ = seq;
|
||||
loop_ = loop;
|
||||
playing_ = (seq != nullptr && !seq->events.empty());
|
||||
event_cursor_ = 0;
|
||||
current_tick_ = 0;
|
||||
pending_start_tick_ = (seq && start_tick <= seq->total_ticks) ? start_tick : 0;
|
||||
sample_accum_ = 0.0;
|
||||
samples_per_tick_ = static_cast<double>(sample_rate_) / 120.0;
|
||||
for (auto& n : note_offs_) n = PendingNoteOff{};
|
||||
@@ -24,6 +25,7 @@ void XmidiPlayer::set_sequence(const assets::XmiSequence* seq, bool loop) {
|
||||
void XmidiPlayer::stop() {
|
||||
playing_ = false;
|
||||
seq_ = nullptr;
|
||||
pending_start_tick_ = 0;
|
||||
for (auto& n : note_offs_) n = PendingNoteOff{};
|
||||
loop_depth_ = 0;
|
||||
}
|
||||
@@ -31,6 +33,29 @@ void XmidiPlayer::stop() {
|
||||
void XmidiPlayer::process_tick(IMidiSynth& synth) {
|
||||
if (!seq_ || !playing_) return;
|
||||
|
||||
const auto& evs = seq_->events;
|
||||
// Fast-forward controller/program/pitch-bend setup before requested start_tick
|
||||
if (pending_start_tick_ > 0) {
|
||||
while (event_cursor_ < evs.size() && evs[event_cursor_].tick < pending_start_tick_) {
|
||||
const auto& ev = evs[event_cursor_++];
|
||||
if (ev.status == 0xFFu) continue;
|
||||
uint8_t hi = ev.status & 0xF0u;
|
||||
uint8_t ch = ev.status & 0x0Fu;
|
||||
if (hi == 0xB0u) {
|
||||
if (ev.data1 != 116u && ev.data1 != 117u && ev.data1 != 120u && ev.data1 != 123u) {
|
||||
synth.control_change(ch, ev.data1, ev.data2);
|
||||
}
|
||||
} else if (hi == 0xC0u) {
|
||||
synth.program_change(ch, ev.data1);
|
||||
} else if (hi == 0xE0u) {
|
||||
int16_t bend14 = static_cast<int16_t>(((ev.data2 & 0x7Fu) << 7) | (ev.data1 & 0x7Fu)) - 8192;
|
||||
synth.pitch_bend(ch, bend14);
|
||||
}
|
||||
}
|
||||
current_tick_ = pending_start_tick_;
|
||||
pending_start_tick_ = 0;
|
||||
}
|
||||
|
||||
// Fire due note-offs
|
||||
for (auto& n : note_offs_) {
|
||||
if (n.active && current_tick_ >= n.off_tick) {
|
||||
@@ -48,7 +73,6 @@ void XmidiPlayer::process_tick(IMidiSynth& synth) {
|
||||
};
|
||||
|
||||
// Fire events at or before current_tick_
|
||||
const auto& evs = seq_->events;
|
||||
while (event_cursor_ < evs.size() && evs[event_cursor_].tick <= current_tick_) {
|
||||
const auto& ev = evs[event_cursor_++];
|
||||
if (ev.status == 0xFFu) {
|
||||
|
||||
Reference in new issue
Block a user