-
Notifications
You must be signed in to change notification settings - Fork 14
/
Wolfteam_MF_Format.txt
134 lines (121 loc) · 5.3 KB
/
Wolfteam_MF_Format.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
Wolf Team MF Format
===================
This format was first seen in use by Wolf Team games, which used it for MT-32 MIDI music.
Wolf Team had PC-9801 and X68000 drivers that play back MF files.
However the format and driver has also been used by a few other developers as well:
- Melody / PANDA HOUSE used it in their games as "MFD.COM" (with an additional command FC and an improper fix to E0/E1)
- Studio Twinkle used it in the game "Twilight" (with commands F8..FB, but not FC and a proper E0/E1 fix)
Main Header
-----------
2 bytes - "MF"
1 bytes - number of songs (usually 01)
1 byte - unused (always 00)
4 bytes - total file size
This is followed by all songs concatenated.
Song Header
-----------
2 bytes - song size (includes this value)
2 bytes - unknown (always 0000)
1 byte - unknown (always 00)
1 bytes - flags (always 28h or 29h)
Bit 0 (01): Endianess (0 - Little Endian, 1 - Big Endian)
Note: The PC-98 driver requires the flags to be 28h and refuses to play the song else. The X68000 requires them to be 29h.
1 bytes - song tempo in BPM (Beats Per Minute, with 48 ticks per beat)
1 byte - track count tc
Note: The "Endianess" flag affects all 2-byte values in the file.
[repeat tc times]
2 bytes - track measure offset list (relative to Song Header)
1 byte - MIDI channel (00..0F - MIDI channel 1..16, 80..8F - MIDI channel 1..16 in drum mode, FF - disabled)
1 byte - unused (always 00)
[repeat end]
Track Measure List
------------------
series of 2-byte offsets (relative to Song Header) that point to the measure's sequence data to play
Offsets < 0010h are special:
0000 - track end
0001 - loop start
0002 - loop end
0003..000F - invalid, same effect as track end
Commands
--------
00..7F ll - note, length ll (modified by Dx commands)
00..7F 00 ll - note, absolute length ll, followed by another note at the same tick
80..87 mm - Modulation (MIDI CC 1)
88..8F vv - Main Volume (MIDI CC 7)
90..97 pp - Panpot (MIDI CC 10)
98..9F ee - Expression (MIDI CC 11)
A0..A7 ii - instrument
A8..AF cc dd - Control Change cc, data dd
B0..BF xx - Pitch Bend (8-bit)
E0 ll mm is calculated as follows:
pb = 0x2000 + xx
ll = pb & 0x7F
mm = (pb >> 7) & 0x7F
C0..CF xx xx - Pitch Bend (16-bit)
E0 ll mm is calculated as follows:
pb = 0x2000 + xxxx
ll = pb & 0x7F
mm = (pb >> 7) & 0x7F
Note: The byte order of xxxx depends on the Endianess flag in the file header.
D0..DF - affects note length (D8 - stop after aobut 50%, D2 - stop shortly before actual end)
-> might be "stop note XX ticks earlier than actual end)
default: no early stop
D6 with a note of length 6 means "duration: 1 tick"
-> according to disasm: D0 = off, D1 = 0 ticks, D2 = 1 tick, etc.
E0..E1 aa bb - Tempo Modifier (E1 = command with delay)
aa = tempo scale (2.6 fixed point, 40h = 100%, 20h = 50%, 10h = 25%)
bb = ignored (intended to be RCP-style tempo fade?)
Notes:
- The command is buggy in the PC-9801 and X68000 versions of Wolf Team's driver and doesn't have any effect there.
- MFD.COM (by PANDA HOUSE) uses an incorrect formula: finalTempo = songTempo + (aa - 0x40)
- The sound driver in "Twilight" (by Studio Twinkle) implements the proper RCP formula: finalTempo = songTempo * aa / 0x40
E2..E3 - set MIDI channel (E3 = command with delay)
E4..E5 aa - Channel Aftertouch (E5 = command with delay)
E6..E7 aa bb - Note Aftertouch (E7 = command with delay)
E8..EB - ignored
EC..EF - Pan (EC = 64/centre, ED = 0/right, EE = 127/left, EF = 64/centre)
Bug: The X68000 Wolf Team driver sends MIDI CC 0x10 instead of 10, causing it to not work properly.
The bug doesn't exist in its PC-9801 version.
F0 dd - delay dd
F1 vv - set note velocity
F2..F7 - ignored
F8..FB - ignored [Wolf Team and MFD drivers]
F8 dd ii bb - set GS instrument [Twilight driver only]
dd - delay
ii - instrument
bb - bank
The driver will send "Bank MSB = dd", "Bank LSB = 0", "Instrument = ii" in that order.
F9 dd p1 p2 - set Roland Base Address [Twilight driver only]
same as RCP command DD (see "raw RCP command")
FA dd p1 p2 - set Roland Parameter + send SysEx [Twilight driver only]
same as RCP command DE (see "raw RCP command")
FB dd p1 p2 - set Roland Device [Twilight driver only]
same as RCP command DF (see "raw RCP command")
FC cc dd p1 p2 - raw RCP command
cc - RCP command
dd - delay
p1/p2 - parameter 1/2
MFD driver: Implements RCP commands DD/DE/DF as described below. The files also seem to use RCP command F6/F7 for song comments.
DD - set Roland Base Address
p1 = address high "raH"
p2 = mid "raM"
DE - set Roland Parameter + send SysEx
p1 = address low "raL"
p2 = parameter "rPar"
-> the driver sends: F0 41 rDev rMod 12 raH raM raL rPar [checksum] F7
DF - set Roland Device
p1 = Device ID "rDev"
p2 = Model ID "rMod"
Wolf Team driver: Only bb is used as delay. All other parameters are ignored.
Twilight driver: The command is ignored and treated as it would have no parameters.
FD - increment Measure Counter
FE - Measure End (reads next measure pointer)
FF - Next Measure (combines FD and FE)
Note: The actual value of the Measure Counter is ignored. FE and FF always just read the next measure pointer.
How the command ranges work:
cc+00 - command, no delay
cc+01 - command, delay of 1 tick
cc+02 - command, delay of 2 ticks
...
cc+(n-2) - command, delay of (n-2) ticks
cc+(n-1) xx - command, delay xx ticks (additional delay parameter right after command byte)