summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/mid2agb/main.cpp14
-rw-r--r--tools/mid2agb/midi.cpp13
2 files changed, 26 insertions, 1 deletions
diff --git a/tools/mid2agb/main.cpp b/tools/mid2agb/main.cpp
index 9b883fba5..5659e49b1 100644
--- a/tools/mid2agb/main.cpp
+++ b/tools/mid2agb/main.cpp
@@ -73,6 +73,18 @@ static std::string StripExtension(std::string s)
return s;
}
+static std::string StripPathAndExtension(std::string s)
+{
+ std::size_t pos = s.find_last_of("/\\");
+
+ if (pos > 0 && pos != std::string::npos)
+ {
+ s = s.substr(pos + 1, pos);
+ }
+
+ return StripExtension(s);
+}
+
static std::string GetExtension(std::string s)
{
std::size_t pos = s.find_last_of('.');
@@ -206,7 +218,7 @@ int main(int argc, char** argv)
RaiseError("output filename extension is not \"s\"");
if (g_asmLabel.empty())
- g_asmLabel = StripExtension(outputFilename);
+ g_asmLabel = StripPathAndExtension(outputFilename);
g_inputFile = std::fopen(inputFilename.c_str(), "rb");
diff --git a/tools/mid2agb/midi.cpp b/tools/mid2agb/midi.cpp
index ba5dd654a..7c05c5237 100644
--- a/tools/mid2agb/midi.cpp
+++ b/tools/mid2agb/midi.cpp
@@ -52,6 +52,7 @@ static std::int32_t s_absoluteTime;
static int s_blockCount = 0;
static int s_minNote;
static int s_maxNote;
+static int s_runningStatus = 0;
void Seek(long offset)
{
@@ -181,19 +182,31 @@ void DetermineEventCategory(MidiEventCategory& category, int& typeChan, int& siz
{
typeChan = ReadInt8();
+ if (typeChan < 0x80 && s_runningStatus != 0)
+ {
+ typeChan = s_runningStatus;
+ Skip(-1);
+ }
+
if (typeChan == 0xFF)
{
category = MidiEventCategory::Meta;
size = 0;
}
+ else if (typeChan >= 0xF8)
+ {
+ category = MidiEventCategory::Invalid;
+ }
else if (typeChan >= 0xF0)
{
category = MidiEventCategory::SysEx;
size = 0;
+ s_runningStatus = 0;
}
else if (typeChan >= 0x80)
{
category = MidiEventCategory::Control;
+ s_runningStatus = typeChan;
switch (typeChan >> 4)
{