Fixed MIDI output to file and some minor changes
This commit is contained in:
parent
d75a04b48d
commit
c64dceadb4
@ -3075,6 +3075,7 @@ void bx_sb16_c::writemidicommand(int command, int length, Bit8u data[])
|
||||
return;
|
||||
} else if ((BX_SB16_THIS midimode == 2) ||
|
||||
(BX_SB16_THIS midimode == 3)) {
|
||||
if (MIDIDATA == NULL) {
|
||||
MIDIDATA = fopen(SIM->get_param_string("midi", base)->getptr(),"wb");
|
||||
if (MIDIDATA == NULL) {
|
||||
writelog (MIDILOG(2), "Error opening file %s. Midimode disabled.",
|
||||
@ -3084,6 +3085,7 @@ void bx_sb16_c::writemidicommand(int command, int length, Bit8u data[])
|
||||
initmidifile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (BX_SB16_THIS midimode < 2)
|
||||
return;
|
||||
@ -3273,7 +3275,7 @@ void bx_sb16_c::finishmidifile()
|
||||
} metatrackend = { 0, 0xff, 0x2f, 0 };
|
||||
|
||||
// Meta event track end (0xff 0x2f 0x00) plus leading delta time
|
||||
fwrite(&metatrackend, 1, sizeof metatrackend, MIDIDATA);
|
||||
fwrite(&metatrackend, 1, sizeof(metatrackend), MIDIDATA);
|
||||
|
||||
Bit32u tracklen = ftell(MIDIDATA);
|
||||
if (tracklen < 0)
|
||||
@ -3284,9 +3286,7 @@ void bx_sb16_c::finishmidifile()
|
||||
fseek(MIDIDATA, 22 - 4, SEEK_SET);
|
||||
// value has to be in big endian
|
||||
#ifdef BX_LITTLE_ENDIAN
|
||||
tracklen = (tracklen << 24) | (tracklen >> 24) |
|
||||
((tracklen & 0x00ff0000) >> 8) |
|
||||
((tracklen & 0x0000ff00) << 8);
|
||||
tracklen = bx_bswap32(tracklen);
|
||||
#endif
|
||||
fwrite(&tracklen, 4, 1, MIDIDATA);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user