From 18bb743540968be3330b6afbd1ffee406b566b10 Mon Sep 17 00:00:00 2001 From: BeWorld <36823759+BeWorld2018@users.noreply.github.com> Date: Tue, 26 Jan 2021 20:53:52 +0100 Subject: [PATCH] Fix bigendian MIDI (#113) * Fix bigendian MIDI Add define READ_INT16(b) and fix MUSh header * Update mmus2mid.c * Revert "Update mmus2mid.c" This reverts commit fc8c2119d3d288b91be5570e1772358307f3b269. * Update mmus2mid.c --- Source/mmus2mid.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Source/mmus2mid.c b/Source/mmus2mid.c index 8feccf62..b4b64b4a 100644 --- a/Source/mmus2mid.c +++ b/Source/mmus2mid.c @@ -286,6 +286,7 @@ static UBYTE MidiEvent(MIDI *mididata,UBYTE midicode,UBYTE MIDIchannel, // // Returns 0 if successful, otherwise an error code (see mmus2mid.h). // +#define READ_INT16(b) ((b)[0] | ((b)[1] << 8)) int mmus2mid(UBYTE *mus, MIDI *mididata, UWORD division, int nocomp) { UWORD TrackCnt = 0; @@ -302,8 +303,12 @@ int mmus2mid(UBYTE *mus, MIDI *mididata, UWORD division, int nocomp) signed char MUS2MIDchannel[MIDI_TRACKS]; // copy the MUS header from the MUS buffer to the MUSh header structure - - memcpy(&MUSh,mus,sizeof(MUSheader)); + memcpy(MUSh.ID, mus, 4); + MUSh.ScoreLength = READ_INT16(&mus[4]); + MUSh.ScoreStart = READ_INT16(&mus[6]); + MUSh.channels = READ_INT16(&mus[8]); + MUSh.SecChannels = READ_INT16(&mus[10]); + MUSh.InstrCnt = READ_INT16(&mus[12]); // check some things and set length of MUS buffer from internal data