@@ -244,7 +244,7 @@ end; |
| 244 |
|
244 |
|
| 245 |
function RenderInstruments(Instruments: TInstrumentBank): string; |
245 |
function RenderInstruments(Instruments: TInstrumentBank): string; |
| 246 |
var |
246 |
var |
| 247 |
SL, ResultSL: TStringList; |
247 |
ResultSL: TStringList; |
| 248 |
AsmInstrument: TAsmInstrument; |
248 |
AsmInstrument: TAsmInstrument; |
| 249 |
I, J: integer; |
249 |
I, J: integer; |
| 250 |
TypePrefix: string; |
250 |
TypePrefix: string; |
@@ -254,37 +254,33 @@ begin |
| 254 |
|
254 |
|
| 255 |
for I := Low(Instruments) to High(Instruments) do |
255 |
for I := Low(Instruments) to High(Instruments) do |
| 256 |
begin |
256 |
begin |
|
|
257 |
WriteStr(TypePrefix, Instruments[I].Type_); |
|
|
258 |
ResultSL.Add(Format('%s%s:', [TypePrefix, 'inst' + IntToStr(I)])); |
|
|
259 |
|
| 257 |
AsmInstrument := InstrumentToBytes(Instruments[I]); |
260 |
AsmInstrument := InstrumentToBytes(Instruments[I]); |
| 258 |
SL := TStringList.Create; |
|
|
| 259 |
SL.StrictDelimiter := True; |
|
|
| 260 |
SL.Delimiter := ','; |
|
|
| 261 |
|
261 |
|
| 262 |
if Instruments[I].Type_ = itNoise then |
262 |
if Instruments[I].Type_ = itNoise then |
| 263 |
begin |
263 |
begin |
| 264 |
SL.Add(IntToStr(AsmInstrument[1])); // envelope |
264 |
ResultSL.Add('db '+IntToStr(AsmInstrument[1])); // envelope |
| 265 |
|
265 |
|
| 266 |
HighMask := AsmInstrument[0]; |
266 |
HighMask := AsmInstrument[0]; |
| 267 |
if Instruments[I].LengthEnabled then |
267 |
if Instruments[I].LengthEnabled then |
| 268 |
HighMask := HighMask or %01000000; |
268 |
HighMask := HighMask or %01000000; |
| 269 |
if Instruments[I].CounterStep = swSeven then |
269 |
if Instruments[I].CounterStep = swSeven then |
| 270 |
HighMask := HighMask or %10000000; |
270 |
HighMask := HighMask or %10000000; |
| 271 |
SL.Add(IntToStr(HighMask)); |
271 |
ResultSL.Add('db '+IntToStr(HighMask)); |
| 272 |
end |
272 |
end |
| 273 |
else begin |
273 |
else begin |
| 274 |
for J := Low(AsmInstrument) to High(AsmInstrument) do |
274 |
for J := Low(AsmInstrument) to High(AsmInstrument) do |
| 275 |
SL.Add(IntToStr(AsmInstrument[J])); |
275 |
ResultSL.Add('db '+IntToStr(AsmInstrument[J])); |
| 276 |
end; |
276 |
end; |
| 277 |
|
277 |
|
| 278 |
WriteStr(TypePrefix, Instruments[I].Type_); |
|
|
| 279 |
ResultSL.Add(Format('%s%s:'+LineEnding+'db %s', [TypePrefix, 'inst' + IntToStr(I), |
|
|
| 280 |
SL.DelimitedText])); |
|
|
| 281 |
SL.Free; |
|
|
| 282 |
|
|
|
| 283 |
if Instruments[I].SubpatternEnabled then |
278 |
if Instruments[I].SubpatternEnabled then |
| 284 |
ResultSL.Add(Format('dw %sSP%d', [TypePrefix, I])) |
279 |
ResultSL.Insert(ResultSL.Count-1, Format('dw %sSP%d', [TypePrefix, I])) |
| 285 |
else |
280 |
else |
| 286 |
ResultSL.Add('dw 0'); |
281 |
ResultSL.Insert(ResultSL.Count-1, 'db 0'); |
| 287 |
ResultSL.Add('ds '+IfThen(Instruments[I].Type_ = itNoise, '4', '2')); |
282 |
ResultSL.Add('ds '+IfThen(Instruments[I].Type_ = itNoise, '5', '3')); |
|
|
283 |
ResultSL.Add(''); |
| 288 |
end; |
284 |
end; |
| 289 |
|
285 |
|
| 290 |
Result := ResultSL.Text; |
286 |
Result := ResultSL.Text; |
@@ -331,6 +327,43 @@ begin |
| 331 |
SL.Free; |
327 |
SL.Free; |
| 332 |
end; |
328 |
end; |
| 333 |
|
329 |
|
|
|
330 |
function RenderTableCell(Cell: TCell): string; |
|
|
331 |
var |
|
|
332 |
SL: TStringList; |
|
|
333 |
begin |
|
|
334 |
SL := TStringList.Create; |
|
|
335 |
SL.Delimiter := ','; |
|
|
336 |
SL.StrictDelimiter := True; |
|
|
337 |
|
|
|
338 |
if (Cell.Note = NO_NOTE) or (Cell.Note = MIDDLE_NOTE) then |
|
|
339 |
SL.Add('___') |
|
|
340 |
else |
|
|
341 |
SL.Add(IntToStr(Abs(Cell.Note - MIDDLE_NOTE))); |
|
|
342 |
|
|
|
343 |
SL.Add(IntToStr(Cell.Volume)); |
|
|
344 |
|
|
|
345 |
SL.Add('$' + EffectCodeToStr(Cell.EffectCode, Cell.EffectParams)); |
|
|
346 |
|
|
|
347 |
// RGBDS thinks you're defining a new macro if you don't have a space first. |
|
|
348 |
Result := ' dn ' + SL.DelimitedText; |
|
|
349 |
SL.Free; |
|
|
350 |
end; |
|
|
351 |
|
|
|
352 |
function RenderTablePattern(Name: string; Pattern: TPattern): string; |
|
|
353 |
var |
|
|
354 |
SL: TStringList; |
|
|
355 |
I: integer; |
|
|
356 |
begin |
|
|
357 |
SL := TStringList.Create; |
|
|
358 |
SL.Add(Name + ':'); |
|
|
359 |
|
|
|
360 |
for I := Low(TPattern) to High(TPattern) do |
|
|
361 |
SL.Add(RenderTableCell(Pattern[I])); |
|
|
362 |
|
|
|
363 |
Result := SL.Text; |
|
|
364 |
SL.Free; |
|
|
365 |
end; |
|
|
366 |
|
| 334 |
function RenderWaveforms(Waves: TWaveBank): string; |
367 |
function RenderWaveforms(Waves: TWaveBank): string; |
| 335 |
var |
368 |
var |
| 336 |
SL, ResultSL: TStringList; |
369 |
SL, ResultSL: TStringList; |
@@ -564,7 +597,7 @@ begin |
| 564 |
with Song.Instruments.All[I] do begin |
597 |
with Song.Instruments.All[I] do begin |
| 565 |
if SubpatternEnabled then begin |
598 |
if SubpatternEnabled then begin |
| 566 |
WriteStr(TypePrefix, Type_); |
599 |
WriteStr(TypePrefix, Type_); |
| 567 |
Write(OutFile, RenderPattern(TypePrefix+'SP' + IntToStr(I), Subpattern)); |
600 |
Write(OutFile, RenderTablePattern(TypePrefix+'SP' + IntToStr(I), Subpattern)); |
| 568 |
end; |
601 |
end; |
| 569 |
end; |
602 |
end; |
| 570 |
|
603 |
|