mirror of
https://github.com/pret/pokeemerald.git
synced 2026-08-24 03:00:31 -05:00
[mid2agb] Add support for the rest of the missing commands
Added the rest of the missing commands, including the loop and goto ops.
This commit is contained in:
@@ -69,8 +69,16 @@
|
||||
.equ TUNE, 0xc8 @ micro tuning (c_v+??)
|
||||
|
||||
.equ XCMD, 0xcd @ extend command ***lib
|
||||
.equ xWAVE, 0x01
|
||||
.equ xTYPE, 0x02
|
||||
.equ xATTA, 0x04
|
||||
.equ xDECA, 0x05
|
||||
.equ xSUST, 0x06
|
||||
.equ xRELE, 0x07
|
||||
.equ xIECV, 0x08 @ imi.echo vol ***lib
|
||||
.equ xIECL, 0x09 @ imi.echo len ***lib
|
||||
.equ xLENG, 0x0A
|
||||
.equ xSWEE, 0x0B
|
||||
|
||||
.equ EOT, 0xce @ End of Tie
|
||||
.equ TIE, 0xcf @
|
||||
|
||||
@@ -330,16 +330,38 @@ void PrintMemAcc(const Event& event)
|
||||
|
||||
void PrintExtendedOp(const Event& event)
|
||||
{
|
||||
// TODO: support for other extended commands
|
||||
|
||||
switch (s_extendedCommand)
|
||||
{
|
||||
case 0x01:
|
||||
PrintOp(event.time, "XCMD ", "xWAVE , %u", event.param2);
|
||||
break;
|
||||
case 0x02:
|
||||
PrintOp(event.time, "XCMD ", "xTYPE , %u", event.param2);
|
||||
break;
|
||||
case 0x04:
|
||||
PrintOp(event.time, "XCMD ", "xATTA , %u", event.param2);
|
||||
break;
|
||||
case 0x05:
|
||||
PrintOp(event.time, "XCMD ", "xDECA , %u", event.param2);
|
||||
break;
|
||||
case 0x06:
|
||||
PrintOp(event.time, "XCMD ", "xSUST , %u", event.param2);
|
||||
break;
|
||||
case 0x07:
|
||||
PrintOp(event.time, "XCMD ", "xRELE , %u", event.param2);
|
||||
break;
|
||||
case 0x08:
|
||||
PrintOp(event.time, "XCMD ", "xIECV , %u", event.param2);
|
||||
break;
|
||||
case 0x09:
|
||||
PrintOp(event.time, "XCMD ", "xIECL , %u", event.param2);
|
||||
break;
|
||||
case 0x0A:
|
||||
PrintOp(event.time, "XCMD ", "xLENG , %u", event.param2);
|
||||
break;
|
||||
case 0x0B:
|
||||
PrintOp(event.time, "XCMD ", "xSWEE , %u", event.param2);
|
||||
break;
|
||||
default:
|
||||
PrintWait(event.time);
|
||||
break;
|
||||
@@ -348,7 +370,14 @@ void PrintExtendedOp(const Event& event)
|
||||
|
||||
void PrintControllerOp(const Event& event)
|
||||
{
|
||||
switch (event.param1)
|
||||
int param1 = event.param1;
|
||||
|
||||
// Map alternate controller ranges (42-63) down by 30
|
||||
// e.g. CC 63 -> 33 (PRIO)
|
||||
if (param1 >= 42 && param1 < 64)
|
||||
param1 -= 30;
|
||||
|
||||
switch (param1)
|
||||
{
|
||||
case 0x01:
|
||||
PrintOp(event.time, "MOD ", "%u", event.param2);
|
||||
@@ -401,7 +430,22 @@ void PrintControllerOp(const Event& event)
|
||||
break;
|
||||
case 0x1E:
|
||||
s_extendedCommand = event.param2;
|
||||
// TODO: loop op
|
||||
if (event.param2 == 100)
|
||||
{
|
||||
std::fprintf(g_outputFile, "%s_%u_LOOP:\n", g_asmLabel.c_str(), g_agbTrack);
|
||||
PrintWait(event.time);
|
||||
ResetTrackVars();
|
||||
}
|
||||
else if (event.param2 == 101)
|
||||
{
|
||||
PrintByte("GOTO");
|
||||
PrintWord("%s_%u_LOOP", g_asmLabel.c_str(), g_agbTrack);
|
||||
PrintWait(event.time);
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintWait(event.time);
|
||||
}
|
||||
break;
|
||||
case 0x21:
|
||||
case 0x27:
|
||||
|
||||
@@ -149,7 +149,7 @@ void ReadMidiFileHeader()
|
||||
g_midiTrackCount = ReadInt16();
|
||||
g_midiTimeDiv = ReadInt16();
|
||||
|
||||
if (g_midiTimeDiv < 0)
|
||||
if (g_midiTimeDiv <= 0)
|
||||
RaiseError("unsupported MIDI time division (%d)", g_midiTimeDiv);
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ std::string ReadEventText()
|
||||
|
||||
if (length <= 2)
|
||||
{
|
||||
if (fread(buffer, length, 1, g_inputFile) != 1)
|
||||
if (length > 0 && fread(buffer, length, 1, g_inputFile) != 1)
|
||||
RaiseError("failed to read event text");
|
||||
}
|
||||
else
|
||||
@@ -636,7 +636,7 @@ void ConvertTimes(std::vector<Event>& events)
|
||||
|
||||
if (event.type == EventType::Note)
|
||||
{
|
||||
event.param1 = g_noteVelocityLUT[event.param1];
|
||||
event.param1 = g_noteVelocityLUT[event.param1 & 0x7F];
|
||||
|
||||
std::uint32_t duration = (24 * g_clocksPerBeat * event.param2) / g_midiTimeDiv;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user