mirror of
https://github.com/FireEmblemUniverse/fireemblem8u.git
synced 2024-11-23 13:19:53 +00:00
Add some workarounds to mid2agb from https://github.com/freshollie/sa2.
This commit is contained in:
parent
0ec9639987
commit
1105344759
@ -431,22 +431,33 @@ void PrintAgbTrack(std::vector<Event>& events)
|
||||
if (event.type == EventType::Note)
|
||||
break;
|
||||
|
||||
if (event.type == EventType::Controller && event.param1 == 0x07)
|
||||
if (IsVolumeEvent(event))
|
||||
{
|
||||
foundVolBeforeNote = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If we find this signature we need to print
|
||||
// the keyshift after the volume event
|
||||
bool needsKeyshiftWorkaround =
|
||||
events[0].type == EventType::WholeNoteMark &&
|
||||
IsVolumeEvent(events[1]);
|
||||
|
||||
if (!foundVolBeforeNote)
|
||||
PrintByte("\tVOL , 127*%s_mvl/mxv", g_asmLabel.c_str());
|
||||
|
||||
if (!needsKeyshiftWorkaround) {
|
||||
PrintByte("KEYSH , %s_key%+d", g_asmLabel.c_str(), 0);
|
||||
}
|
||||
PrintWait(g_initialWait);
|
||||
PrintByte("KEYSH , %s_key%+d", g_asmLabel.c_str(), 0);
|
||||
|
||||
for (unsigned i = 0; events[i].type != EventType::EndOfTrack; i++)
|
||||
{
|
||||
const Event& event = events[i];
|
||||
// We are going to be hacky
|
||||
// and modify the time value, so can't be const
|
||||
Event& event = events[i];
|
||||
std::int32_t eventTime = event.time;
|
||||
|
||||
if (IsPatternBoundary(event.type))
|
||||
{
|
||||
@ -513,7 +524,19 @@ void PrintAgbTrack(std::vector<Event>& events)
|
||||
PrintOp(event.time, "BEND ", "c_v%+d", event.param2 - 64);
|
||||
break;
|
||||
case EventType::Controller:
|
||||
// Ensure that a wait value is not printed after the volume
|
||||
// command
|
||||
if (needsKeyshiftWorkaround && i == 1) {
|
||||
event.time = 0;
|
||||
}
|
||||
|
||||
PrintControllerOp(event);
|
||||
// print the keyshift and any wait after we have written the volume value
|
||||
if (needsKeyshiftWorkaround && i == 1) {
|
||||
PrintByte("\tKEYSH , %s_key%+d", g_asmLabel.c_str(), 0);
|
||||
PrintWait(eventTime);
|
||||
event.time = eventTime;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
PrintWait(event.time);
|
||||
|
@ -573,6 +573,14 @@ bool EventCompare(const Event& event1, const Event& event2)
|
||||
unsigned event1Type = (unsigned)event1.type;
|
||||
unsigned event2Type = (unsigned)event2.type;
|
||||
|
||||
// For some reason if there is a volume
|
||||
// event and an instrument change event
|
||||
// at the start, we need to ensure the volume event
|
||||
// happens first
|
||||
if (event1.type == EventType::InstrumentChange && IsVolumeEvent(event2) &&
|
||||
event1.time == 0 && event2.time == 0)
|
||||
return false;
|
||||
|
||||
if (event1.type == EventType::Note)
|
||||
event1Type += event1.note;
|
||||
|
||||
|
@ -84,4 +84,8 @@ inline bool IsPatternBoundary(EventType type)
|
||||
return type == EventType::EndOfTrack || (int)type <= 0x17;
|
||||
}
|
||||
|
||||
inline bool IsVolumeEvent(const Event& event) {
|
||||
return event.type == EventType::Controller && event.param1 == 0x07;
|
||||
}
|
||||
|
||||
#endif // MIDI_H
|
||||
|
Loading…
Reference in New Issue
Block a user