summaryrefslogtreecommitdiff
path: root/tools/mid2agb/midi.cpp
diff options
context:
space:
mode:
authorDiegoisawesome <diego@domoreaweso.me>2018-09-25 11:41:18 -0500
committerDiegoisawesome <diego@domoreaweso.me>2018-09-25 11:41:18 -0500
commit7f38a03093cf20e1db57ec739029fff316e69686 (patch)
tree19c2f530e32c1155c49e8da7a797be0f8835dab2 /tools/mid2agb/midi.cpp
parentaf4ff89e550455bbd503a44ac26ba6b1bc2857f7 (diff)
mid2agb compression algorithm less buggy than originally thought
Diffstat (limited to 'tools/mid2agb/midi.cpp')
-rw-r--r--tools/mid2agb/midi.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/tools/mid2agb/midi.cpp b/tools/mid2agb/midi.cpp
index 8a84a0945..be5454d4e 100644
--- a/tools/mid2agb/midi.cpp
+++ b/tools/mid2agb/midi.cpp
@@ -773,7 +773,6 @@ void CalculateWaits(std::vector<Event>& events)
}
}
-// This code is (purposely) buggy as shit, to mimic how the real mid2agb worked
int CalculateCompressionScore(std::vector<Event>& events, int index)
{
int score = 0;
@@ -782,7 +781,12 @@ int CalculateCompressionScore(std::vector<Event>& events, int index)
EventType lastType = events[index].type;
std::int32_t lastDuration = 0x80000000;
std::uint8_t lastNote = 0x80u;
- //std::int32_t lastParam2;
+
+ if (events[index].type == EventType::Note)
+ {
+ // Bug reintroduction
+ lastParam1 |= events[index].note + 0x40;
+ }
if (events[index].time > 0)
score++;
@@ -793,11 +797,10 @@ int CalculateCompressionScore(std::vector<Event>& events, int index)
{
int val = 0;
- // BUG: uses type instead of note
- if ((std::uint8_t)events[i].type != lastNote)
+ if (events[i].note != lastNote)
{
val++;
- lastNote = (std::uint8_t)events[i].type;
+ lastNote = events[i].note;
}
if (events[i].param1 != lastVelocity)
@@ -845,8 +848,12 @@ int CalculateCompressionScore(std::vector<Event>& events, int index)
// BUG: uses type instead of param1
lastParam1 = (std::uint8_t)events[i].type;
- // unused
- //lastParam2 = events[i].param2;
+ if (events[i].type == EventType::Note)
+ {
+ // Bug reintroduction
+ lastParam1 |= events[i].note + 0x40;
+ }
+
lastType = events[i].type;
if (events[i].time)