Commit 0450394

Nick committed on
Work towards release of noise macros
commit 045039413c807015d9a898edc896a822572c3db4 parent e6e905a
5 changed files +43−19
Modifiedcodegen.pas +10−4
@@ -58,6 +58,7 @@ var
58 AsmInstrument: TAsmInstrument; 58 AsmInstrument: TAsmInstrument;
59 I, J: Integer; 59 I, J: Integer;
60 TypePrefix: String; 60 TypePrefix: String;
61 HighMask: Byte;
61 begin 62 begin
62 ResultSL := TStringList.Create; 63 ResultSL := TStringList.Create;
63 64
@@ -69,10 +70,14 @@ begin
69 70
70 if Instruments[I].Type_ = itNoise then begin 71 if Instruments[I].Type_ = itNoise then begin
71 SL.Add(IntToStr(AsmInstrument[1])); 72 SL.Add(IntToStr(AsmInstrument[1]));
73
74 HighMask := %00000000;
72 if Instruments[I].LengthEnabled then 75 if Instruments[I].LengthEnabled then
73 SL.Add(IntToStr(AsmInstrument[0] or %11000000)) 76 HighMask := HighMask or %01000000;
74 else 77 if Instruments[I].CounterStep = swSeven then
75 SL.Add(IntToStr(AsmInstrument[0] or %10000000)); 78 HighMask := HighMask or %10000000;
79 SL.Add(IntToStr(HighMask));
80
76 for J := Low(TNoiseMacro) to High(TNoiseMacro) do 81 for J := Low(TNoiseMacro) to High(TNoiseMacro) do
77 SL.Add(IntToStr(Instruments[I].NoiseMacro[J])); 82 SL.Add(IntToStr(Instruments[I].NoiseMacro[J]));
78 end 83 end
@@ -259,6 +264,7 @@ begin
259 Proc.Executable := 'rgbasm'; 264 Proc.Executable := 'rgbasm';
260 Proc.Parameters.Clear; 265 Proc.Parameters.Clear;
261 Proc.Parameters.add('-o'+Filename+'_driver.obj'); 266 Proc.Parameters.add('-o'+Filename+'_driver.obj');
267 Proc.Parameters.add('-DPREVIEW_MODE');
262 Proc.Parameters.add('driver.z80'); 268 Proc.Parameters.add('driver.z80');
263 Proc.Execute; 269 Proc.Execute;
264 if Proc.ExitCode <> 0 then goto AssemblyError; 270 if Proc.ExitCode <> 0 then goto AssemblyError;
@@ -354,7 +360,7 @@ begin
354 [mbOK], 360 [mbOK],
355 0); 361 0);
356 362
357 {$ifdef PRODUCTION}OpenURL('https://github.com/SuperDisk/UGE/issues');{$endif} 363 {$ifdef PRODUCTION}OpenURL('https://github.com/SuperDisk/hUGETracker/issues');{$endif}
358 end; 364 end;
359 365
360 Cleanup: 366 Cleanup:
ModifiedhUGEDriver +1−1
@@ -1 +1 @@
1 Subproject commit 4edb44e703704e896b86fa14284ef63cd50e6d19 1 Subproject commit aa31877d2be9be9ca842e3ec1f355b2cc9ea382d
Modifiedtracker.lfm +5−5
@@ -1,7 +1,7 @@
1 object frmTracker: TfrmTracker 1 object frmTracker: TfrmTracker
2 Left = 1028 2 Left = 1394
3 Height = 806 3 Height = 806
4 Top = 207 4 Top = 254
5 Width = 1270 5 Width = 1270
6 AllowDropFiles = True 6 AllowDropFiles = True
7 Caption = 'hUGETracker' 7 Caption = 'hUGETracker'
@@ -61,14 +61,14 @@ object frmTracker: TfrmTracker
61 Height = 674 61 Height = 674
62 Top = 0 62 Top = 0
63 Width = 1072 63 Width = 1072
64 ActivePage = PatternTabSheet 64 ActivePage = InstrumentTabSheet
65 Align = alClient 65 Align = alClient
66 ParentFont = False 66 ParentFont = False
67 TabIndex = 1 67 TabIndex = 2
68 TabOrder = 0 68 TabOrder = 0
69 object GeneralTabSheet: TTabSheet 69 object GeneralTabSheet: TTabSheet
70 Caption = 'General' 70 Caption = 'General'
71 ClientHeight = 641 71 ClientHeight = 646
72 ClientWidth = 1064 72 ClientWidth = 1064
73 ParentFont = False 73 ParentFont = False
74 object SongInformationGroupbox: TGroupBox 74 object SongInformationGroupbox: TGroupBox
Modifiedtracker.pas +21−9
@@ -576,7 +576,7 @@ begin
576 Interval := W div 31; 576 Interval := W div 31;
577 //HInterval := H div $10; 577 //HInterval := H div $10;
578 With PB.Canvas do begin 578 With PB.Canvas do begin
579 Brush.Color := clBlack; 579 Brush.Color := clGameboyBlack;
580 Clear; 580 Clear;
581 581
582 {Pen.Width := 1; 582 {Pen.Width := 1;
@@ -587,8 +587,8 @@ begin
587 for I := 0 to $10 do 587 for I := 0 to $10 do
588 Line(0, I*HInterval, W, I*HInterval);} 588 Line(0, I*HInterval, W, I*HInterval);}
589 589
590 Brush.Color := clTeal; 590 Brush.Color := clGameboyMidGreen;
591 Pen.Color := clTeal; 591 Pen.Color := clGameboyMidGreen;
592 Pen.Width := 2; 592 Pen.Width := 2;
593 MoveTo(0, H); 593 MoveTo(0, H);
594 for I := Low(Wave) to High(Wave) do 594 for I := Low(Wave) to High(Wave) do
@@ -923,7 +923,7 @@ begin
923 // Start emulation on the rendered preview binary 923 // Start emulation on the rendered preview binary
924 LockPlayback; 924 LockPlayback;
925 GetROMReady('hUGEDriver/preview.gb'); 925 GetROMReady('hUGEDriver/preview.gb');
926 PokeSymbol(SYM_TICKS_PER_ROW, Song.TicksPerRow); 926
927 for I := 1 to 4 do 927 for I := 1 to 4 do
928 snd[I].ChannelOFF := HeaderControl1.Sections[I].ImageIndex = 0; 928 snd[I].ChannelOFF := HeaderControl1.Sections[I].ImageIndex = 0;
929 929
@@ -1137,7 +1137,7 @@ procedure TfrmTracker.WavePaintboxPaint(Sender: TObject);
1137 begin 1137 begin
1138 if not WaveGroupBox.Enabled then begin 1138 if not WaveGroupBox.Enabled then begin
1139 with WavePaintbox.Canvas do begin 1139 with WavePaintbox.Canvas do begin
1140 Brush.Color := clBlack; 1140 Brush.Color := clGameboyBlack;
1141 Clear; 1141 Clear;
1142 end; 1142 end;
1143 end 1143 end
@@ -1669,7 +1669,7 @@ var
1669 begin 1669 begin
1670 if DrawingMacro then begin 1670 if DrawingMacro then begin
1671 MacroIdx := EnsureRange(Trunc((X/NoiseMacroPaintbox.Width) * 6), 0, 5); 1671 MacroIdx := EnsureRange(Trunc((X/NoiseMacroPaintbox.Width) * 6), 0, 5);
1672 Val := EnsureRange(Floor((Y/NoiseMacroPaintbox.Height) * 63), 0, 63) - 31; 1672 Val := 32-EnsureRange(Trunc((Y/NoiseMacroPaintbox.Height) * 63), 0, 63);
1673 1673
1674 CurrentInstrument^.NoiseMacro[MacroIdx] := Val; 1674 CurrentInstrument^.NoiseMacro[MacroIdx] := Val;
1675 NoiseMacroPaintbox.Invalidate; 1675 NoiseMacroPaintbox.Invalidate;
@@ -1686,6 +1686,15 @@ procedure TfrmTracker.NoiseMacroPaintboxPaint(Sender: TObject);
1686 var 1686 var
1687 BarWidth, BarStep: Double; 1687 BarWidth, BarStep: Double;
1688 I: Integer; 1688 I: Integer;
1689 Rect: TRect;
1690
1691 function FormatMacroNumber(Val: Integer): string;
1692 begin
1693 if Val = 0 then Exit('')
1694 else if Val > 0 then Exit('+'+IntToStr(Val))
1695 else Exit(IntToStr(Val));
1696 end;
1697
1689 begin 1698 begin
1690 BarWidth := (NoiseMacroPaintbox.Width / 6); // TODO: change this constant? 1699 BarWidth := (NoiseMacroPaintbox.Width / 6); // TODO: change this constant?
1691 BarStep := (NoiseMacroPaintbox.Height / 63); 1700 BarStep := (NoiseMacroPaintbox.Height / 63);
@@ -1693,14 +1702,17 @@ begin
1693 Brush.Color := clGameboyBlack; 1702 Brush.Color := clGameboyBlack;
1694 Clear; 1703 Clear;
1695 1704
1705 Brush.Color := clGameboyMidGreen;
1706 Pen.Color := clGameboyBlack;
1696 for I := Low(TNoiseMacro) to High(TNoiseMacro) do begin 1707 for I := Low(TNoiseMacro) to High(TNoiseMacro) do begin
1697 Brush.Color := clGameboyMidGreen; 1708 Rect := TRect.Create(
1698 FillRect(
1699 Trunc(I*BarWidth), 1709 Trunc(I*BarWidth),
1700 NoiseMacroPaintbox.Height div 2, 1710 NoiseMacroPaintbox.Height div 2,
1701 Trunc((I+1)*BarWidth), 1711 Trunc((I+1)*BarWidth),
1702 Ceil((NoiseMacroPaintbox.Height / 2) + (CurrentInstrument^.NoiseMacro[I] * BarStep)) 1712 Ceil((NoiseMacroPaintbox.Height / 2) - (CurrentInstrument^.NoiseMacro[I] * BarStep))
1703 ); 1713 );
1714 FillRect(Rect);
1715 TextOut(Rect.Left + Trunc(Rect.Width/2.5), Rect.Top + (Rect.Height div 2), FormatMacroNumber(CurrentInstrument^.NoiseMacro[I]));
1704 end; 1716 end;
1705 end; 1717 end;
1706 end; 1718 end;
Modifiedutils.pas +6−0
@@ -30,6 +30,7 @@ type
30 end; 30 end;
31 31
32 function Lerp(v0, v1, t: Double): Double; 32 function Lerp(v0, v1, t: Double): Double;
33 function Snap(Value, Every: Integer): Integer;
33 function ReMap(Value, Istart, Istop, Ostart, Ostop: Double): Double; 34 function ReMap(Value, Istart, Istop, Ostart, Ostop: Double): Double;
34 function IntReMap(Value, Istart, Istop, Ostart, Ostop: Integer): Integer; 35 function IntReMap(Value, Istart, Istop, Ostart, Ostop: Integer): Integer;
35 function ConvertWaveform(Waveform: TWave): T4bitWave; 36 function ConvertWaveform(Waveform: TWave): T4bitWave;
@@ -59,6 +60,11 @@ begin
59 Result := ((1 - t) * v0) + (t * v1); 60 Result := ((1 - t) * v0) + (t * v1);
60 end; 61 end;
61 62
63 function Snap(Value, Every: Integer): Integer;
64 begin
65 Result := Trunc(Value/Every)*Every;
66 end;
67
62 function ReMap(Value, Istart, Istop, Ostart, Ostop: Double): Double; 68 function ReMap(Value, Istart, Istop, Ostart, Ostop: Double): Double;
63 begin 69 begin
64 Result := ostart + ((ostop - ostart) * ((value - istart) / (istop - istart))); 70 Result := ostart + ((ostop - ostart) * ((value - istart) / (istop - istart)));