mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
mid2agb compression algorithm less buggy than originally thought
This commit is contained in:
parent
af4ff89e55
commit
7f38a03093
@ -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 CalculateCompressionScore(std::vector<Event>& events, int index)
|
||||||
{
|
{
|
||||||
int score = 0;
|
int score = 0;
|
||||||
@ -782,7 +781,12 @@ int CalculateCompressionScore(std::vector<Event>& events, int index)
|
|||||||
EventType lastType = events[index].type;
|
EventType lastType = events[index].type;
|
||||||
std::int32_t lastDuration = 0x80000000;
|
std::int32_t lastDuration = 0x80000000;
|
||||||
std::uint8_t lastNote = 0x80u;
|
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)
|
if (events[index].time > 0)
|
||||||
score++;
|
score++;
|
||||||
@ -793,11 +797,10 @@ int CalculateCompressionScore(std::vector<Event>& events, int index)
|
|||||||
{
|
{
|
||||||
int val = 0;
|
int val = 0;
|
||||||
|
|
||||||
// BUG: uses type instead of note
|
if (events[i].note != lastNote)
|
||||||
if ((std::uint8_t)events[i].type != lastNote)
|
|
||||||
{
|
{
|
||||||
val++;
|
val++;
|
||||||
lastNote = (std::uint8_t)events[i].type;
|
lastNote = events[i].note;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (events[i].param1 != lastVelocity)
|
if (events[i].param1 != lastVelocity)
|
||||||
@ -845,8 +848,12 @@ int CalculateCompressionScore(std::vector<Event>& events, int index)
|
|||||||
|
|
||||||
// BUG: uses type instead of param1
|
// BUG: uses type instead of param1
|
||||||
lastParam1 = (std::uint8_t)events[i].type;
|
lastParam1 = (std::uint8_t)events[i].type;
|
||||||
// unused
|
if (events[i].type == EventType::Note)
|
||||||
//lastParam2 = events[i].param2;
|
{
|
||||||
|
// Bug reintroduction
|
||||||
|
lastParam1 |= events[i].note + 0x40;
|
||||||
|
}
|
||||||
|
|
||||||
lastType = events[i].type;
|
lastType = events[i].type;
|
||||||
|
|
||||||
if (events[i].time)
|
if (events[i].time)
|
||||||
|
Loading…
Reference in New Issue
Block a user