Commit 1c99e77

Nick committed on
WIP deflemask import more
commit 1c99e77e39dfbcb74bbc25e2a323bde32bc92e8e parent cec038b
3 changed files +39−14
Modifieddmfimport.pas +34−12
@@ -5,7 +5,7 @@ unit DMFImport;
5 interface 5 interface
6 6
7 uses 7 uses
8 Classes, SysUtils, ZStream, Song, hUGEDataTypes; 8 Classes, SysUtils, ZStream, Song, hUGEDataTypes, Constants;
9 9
10 type 10 type
11 EDMFException = class(Exception); 11 EDMFException = class(Exception);
@@ -30,6 +30,7 @@ var
30 Temp: QWord; 30 Temp: QWord;
31 TempS: String; 31 TempS: String;
32 Pat: PPattern; 32 Pat: PPattern;
33 DmfNote, DmfOctave: Integer;
33 begin 34 begin
34 InitializeSong(Result); 35 InitializeSong(Result);
35 36
@@ -79,12 +80,13 @@ begin
79 //1 Byte: Custom HZ value 3 80 //1 Byte: Custom HZ value 3
80 DS.Seek(5, soCurrent); 81 DS.Seek(5, soCurrent);
81 //4 Bytes: TOTAL_ROWS_PER_PATTERN 82 //4 Bytes: TOTAL_ROWS_PER_PATTERN
82 Temp := DS.ReadQWord; 83 Temp := DS.ReadDWord;
83 Writeln(temp); 84 Writeln(temp);
84 if Temp <> 64 then 85 if Temp <> 64 then
85 raise EDMFException.Create('DMF file needs 64 rows per pattern!'); 86 raise EDMFException.Create('DMF file needs 64 rows per pattern!');
86 //1 Byte: TOTAL_ROWS_IN_PATTERN_MATRIX 87 //1 Byte: TOTAL_ROWS_IN_PATTERN_MATRIX
87 Temp := DS.ReadByte; 88 Temp := DS.ReadByte;
89 writeln('rows in pattern matrix ', temp);
88 for I := Low(Result.OrderMatrix) to High(Result.OrderMatrix) do 90 for I := Low(Result.OrderMatrix) to High(Result.OrderMatrix) do
89 SetLength(Result.OrderMatrix[I], Temp); 91 SetLength(Result.OrderMatrix[I], Temp);
90 92
@@ -99,16 +101,17 @@ begin
99 raise EDMFException.Create('DMF file must have 15 instruments or less!'); 101 raise EDMFException.Create('DMF file must have 15 instruments or less!');
100 102
101 // Read all instruments 103 // Read all instruments
104 writeln('total instruments ', totalinstruments);
102 for I := 0 to TotalInstruments-1 do begin 105 for I := 0 to TotalInstruments-1 do begin
103 // 1 Byte: Instrument Name Chars Count (0-255) 106 // 1 Byte: Instrument Name Chars Count (0-255)
104 // N Bytes: Instrument Name Chars 107 // N Bytes: Instrument Name Chars
105 TempS := DS.ReadDMFString; 108 TempS := DS.ReadDMFString;
106 Result.Instruments.Duty[I].Name := TempS; 109 Result.Instruments.Duty[I+1].Name := TempS;
107 Result.Instruments.Wave[I].Name := TempS; 110 Result.Instruments.Wave[I+1].Name := TempS;
108 Result.Instruments.Noise[I].Name := TempS; 111 Result.Instruments.Noise[I+1].Name := TempS;
109 112
110 // 1 Byte: Instrument Mode (0 = STANDARD INS, 1 = FM INS) 113 // 1 Byte: Instrument Mode (0 = STANDARD INS, 1 = FM INS)
111 if DS.ReadByte <> 1 then 114 if DS.ReadByte <> 0 then
112 raise EDMFException.Create('DMF file contains a non-standard instrument!'); 115 raise EDMFException.Create('DMF file contains a non-standard instrument!');
113 116
114 //ARPEGGIO MACRO 117 //ARPEGGIO MACRO
@@ -161,20 +164,39 @@ begin
161 // 4 Bytes: Wavetable Data 164 // 4 Bytes: Wavetable Data
162 TotalWavetables := DS.ReadByte; 165 TotalWavetables := DS.ReadByte;
163 for I := 0 to TotalWavetables-1 do 166 for I := 0 to TotalWavetables-1 do
164 DS.Seek(DS.ReadQWord * 4, soCurrent); 167 DS.Seek(DS.ReadDWord * 4, soCurrent);
165 168
166 for I := Low(TOrderMatrix) to High(TOrderMatrix) do begin 169 for I := Low(TOrderMatrix) to High(TOrderMatrix) do begin
167 if DS.ReadByte <> 1 then 170 Temp := DS.readbyte;
171 writeln('fx columns ', temp);
172 if Temp <> 1 then
168 raise EDMFException.Create('DMF file contains patterns with more than one effect column!'); 173 raise EDMFException.Create('DMF file contains patterns with more than one effect column!');
169 174
175 writeln('iterating '+inttostr(High(Result.OrderMatrix[I]) - Low(Result.OrderMatrix[I]) + 1), ' times');
170 for J := Low(Result.OrderMatrix[I]) to High(Result.OrderMatrix[I]) do begin 176 for J := Low(Result.OrderMatrix[I]) to High(Result.OrderMatrix[I]) do begin
171 Pat := Result.Patterns.GetOrCreateNew(((I+1)*100) + J); 177 Pat := Result.Patterns.GetOrCreateNew(((I+1)*100) + J);
172 for Row := Low(TPattern) to High(TPattern) do begin 178 for Row := Low(TPattern) to High(TPattern) do begin
173 with Pat^[Row] do begin 179 with Pat^[Row] do begin
174 Note := DS.ReadWord + (12*DS.ReadWord); 180 DmfNote := DS.ReadWord;
175 EffectCode := DS.ReadWord; 181 DmfOctave := DS.ReadWord;
176 EffectParams.Value := DS.ReadWord; 182 if (DmfNote = 0) and (DmfOctave = 0) then
177 Instrument := DS.ReadWord; 183 Note := NO_NOTE
184 else
185 Note := DmfNote + (12*DmfOctave) - (12*3);
186
187 DS.Seek(2,soCurrent); //volume
188
189 EffectCode := Byte(DS.ReadWord);
190 if EffectCode = High(Byte) then
191 EffectCode := 0;
192
193 EffectParams.Value := Byte(DS.ReadWord);
194 if EffectParams.Value = High(Byte) then
195 EffectParams.Value := 0;
196
197 Instrument := Byte(DS.ReadWord);
198 if Instrument = High(Byte) then
199 Instrument := 0;
178 end; 200 end;
179 end; 201 end;
180 end; 202 end;
Modifiedtracker.pas +1−1
@@ -1826,7 +1826,7 @@ begin
1826 if True then begin 1826 if True then begin
1827 DestroySong(Song); 1827 DestroySong(Song);
1828 1828
1829 Stream := TFileStream.Create('C:/test/pokemon2.dmf', fmOpenRead); 1829 Stream := TFileStream.Create('C:/test/pokemon3.dmf', fmOpenRead);
1830 Song := LoadSongFromDmfStream(Stream); 1830 Song := LoadSongFromDmfStream(Stream);
1831 1831
1832 Stream.Free; 1832 Stream.Free;
Modifiedtrackergrid.pas +4−1
@@ -965,7 +965,10 @@ begin
965 end 965 end
966 else begin 966 else begin
967 Font.Color := clDots; 967 Font.Color := clDots;
968 TextOut(PenPos.X, PenPos.Y, '...'); 968 if Cell.Note = NO_NOTE then
969 TextOut(PenPos.X, PenPos.Y, '...')
970 else
971 TextOut(PenPos.X, PenPos.Y, '???');
969 end; 972 end;
970 973
971 TextOut(PenPos.X, PenPos.Y, ' '); 974 TextOut(PenPos.X, PenPos.Y, ' ');