Commit df9ecae

Nick committed on
Various changes, fixed waveform selection
commit df9ecae02e163870affe2809f53dcfd48a2e9c5f parent 011029a
4 changed files +79−35
Modifiedsong.pas +38−1
@@ -4,7 +4,7 @@ unit Song;
4 4
5 interface 5 interface
6 6
7 uses Classes, HugeDatatypes; 7 uses Classes, HugeDatatypes, instruments;
8 8
9 type 9 type
10 { TSong } 10 { TSong }
@@ -27,6 +27,7 @@ type
27 27
28 procedure WriteSongToStream(S: TStream; const ASong: TSong); 28 procedure WriteSongToStream(S: TStream; const ASong: TSong);
29 procedure ReadSongFromStream(S: TStream; var ASong: TSong); 29 procedure ReadSongFromStream(S: TStream; var ASong: TSong);
30 procedure InitializeSong(var S: TSong);
30 31
31 implementation 32 implementation
32 33
@@ -96,5 +97,41 @@ begin
96 end; 97 end;
97 end; 98 end;
98 99
100 procedure InitializeSong(var S: TSong);
101 var
102 I, J: Integer;
103 begin
104 with S do begin
105 Version := 1;
106 Name := '';
107 Artist := '';
108 Comment := '';
109 end;
110 for I := Low(S.Instruments) to High(S.Instruments) do
111 with S.Instruments[I] do begin
112 Type_ := Square;
113 Length := 0;
114 LengthEnabled := False;
115 InitialVolume := 63;
116 VolSweepDirection := Down;
117 VolSweepAmount := 0;
118
119 SweepTime := 0;
120 SweepIncDec := Down;
121 SweepShift := 0;
122
123 Duty := 2;
124
125 OutputLevel := 1;
126 end;
127 for I := Low(S.Waves) to High(S.Waves) do begin
128 for J := 0 to 32 do
129 S.Waves[I][J] := random($F);
130 end;
131
132 S.TicksPerRow := 7;
133 S.Patterns := TPatternMap.Create;
134 end;
135
99 end. 136 end.
100 137
Modifiedtracker.lfm +24−2
@@ -1,7 +1,7 @@
1 object frmTracker: TfrmTracker 1 object frmTracker: TfrmTracker
2 Left = 793 2 Left = 800
3 Height = 1376 3 Height = 1376
4 Top = 197 4 Top = 189
5 Width = 2212 5 Width = 2212
6 Caption = 'hUGETracker' 6 Caption = 'hUGETracker'
7 ClientHeight = 1342 7 ClientHeight = 1342
@@ -868,10 +868,30 @@ object frmTracker: TfrmTracker
868 Top = 70 868 Top = 70
869 Width = 308 869 Width = 308
870 ItemHeight = 30 870 ItemHeight = 30
871 ItemIndex = 0
872 Items.Strings = (
873 'Wave #0'
874 'Wave #1'
875 'Wave #2'
876 'Wave #3'
877 'Wave #4'
878 'Wave #5'
879 'Wave #6'
880 'Wave #7'
881 'Wave #8'
882 'Wave #9'
883 'Wave #10'
884 'Wave #11'
885 'Wave #12'
886 'Wave #13'
887 'Wave #14'
888 'Wave #15'
889 )
871 OnChange = WaveformComboboxChange 890 OnChange = WaveformComboboxChange
872 ParentFont = False 891 ParentFont = False
873 Style = csDropDownList 892 Style = csDropDownList
874 TabOrder = 0 893 TabOrder = 0
894 Text = 'Wave #0'
875 end 895 end
876 object Panel4: TPanel 896 object Panel4: TPanel
877 Left = 14 897 Left = 14
@@ -2078,6 +2098,8 @@ object frmTracker: TfrmTracker
2078 object FileSaveAs1: TFileSaveAs 2098 object FileSaveAs1: TFileSaveAs
2079 Category = 'File' 2099 Category = 'File'
2080 Caption = 'Save As ...' 2100 Caption = 'Save As ...'
2101 Dialog.DefaultExt = '.uge'
2102 Dialog.Filter = 'hUGETracker Modules|*.uge'
2081 Hint = 'Save As' 2103 Hint = 'Save As'
2082 ImageIndex = 59 2104 ImageIndex = 59
2083 ShortCut = 16467 2105 ShortCut = 16467
Modifiedtracker.pas +7−25
@@ -541,6 +541,8 @@ begin
541 end; 541 end;
542 542
543 function TfrmTracker.PreparePreview: Boolean; 543 function TfrmTracker.PreparePreview: Boolean;
544 var
545 I: Integer;
544 begin 546 begin
545 if RenderPreviewROM(Song) then begin 547 if RenderPreviewROM(Song) then begin
546 // Load the new symbol table 548 // Load the new symbol table
@@ -552,6 +554,8 @@ begin
552 EmulationThread.Free; 554 EmulationThread.Free;
553 EmulationThread := TEmulationThread.Create('hUGEDriver/preview.gb'); 555 EmulationThread := TEmulationThread.Create('hUGEDriver/preview.gb');
554 PokeSymbol(SYM_TICKS_PER_ROW, Song.TicksPerRow); 556 PokeSymbol(SYM_TICKS_PER_ROW, Song.TicksPerRow);
557 for I := 0 to 3 do
558 snd[I+1].ChannelOFF := HeaderControl1.Sections[I].ImageIndex = 0;
555 559
556 Result := True; 560 Result := True;
557 end 561 end
@@ -743,6 +747,7 @@ end;
743 747
744 procedure TfrmTracker.WaveformComboboxChange(Sender: TObject); 748 procedure TfrmTracker.WaveformComboboxChange(Sender: TObject);
745 begin 749 begin
750 CurrentInstrument^.Waveform:=WaveformCombobox.ItemIndex;
746 WavePaintbox.Invalidate; 751 WavePaintbox.Invalidate;
747 end; 752 end;
748 753
@@ -777,15 +782,14 @@ end;
777 782
778 procedure TfrmTracker.FormCreate(Sender: TObject); 783 procedure TfrmTracker.FormCreate(Sender: TObject);
779 var 784 var
780 I, J: Integer; 785 I: Integer;
781 Section: TCollectionItem; 786 Section: TCollectionItem;
782 begin 787 begin
783 ReturnNilIfGrowHeapFails := False; 788 ReturnNilIfGrowHeapFails := False;
784 789
785 Song.Version := UGE_FORMAT_VERSION; 790 InitializeSong(Song);
786 791
787 // Create pattern editor control 792 // Create pattern editor control
788 Song.Patterns := TPatternMap.Create;
789 RecreateTrackerGrid; 793 RecreateTrackerGrid;
790 794
791 // Initialize ticks per row 795 // Initialize ticks per row
@@ -795,28 +799,6 @@ begin
795 for Section in HeaderControl1.Sections do 799 for Section in HeaderControl1.Sections do
796 (Section as THeaderSection).Width := TrackerGrid.ColumnWidth; 800 (Section as THeaderSection).Width := TrackerGrid.ColumnWidth;
797 801
798 for I := Low(Song.Instruments) to High(Song.Instruments) do
799 with Song.Instruments[I] do begin
800 Type_ := Square;
801 Length := 0;
802 LengthEnabled := False;
803 InitialVolume := 63;
804 VolSweepDirection := Down;
805 VolSweepAmount := 0;
806
807 SweepTime := 0;
808 SweepIncDec := Down;
809 SweepShift := 0;
810
811 Duty := 2;
812 end;
813
814 for I := Low(Song.Waves) to High(Song.Waves) do begin
815 for J := 0 to 32 do
816 Song.Waves[I][J] := random($F);
817 WaveformCombobox.Items.Add('Wave #' + IntToStr(I));
818 end;
819
820 LoadInstrument(1); 802 LoadInstrument(1);
821 LoadWave(0); 803 LoadWave(0);
822 804
Modifiedtrackergrid.pas +10−7
@@ -797,17 +797,20 @@ begin
797 // a lot (every time the FD callback happens) so it needs to be fast. It can 797 // a lot (every time the FD callback happens) so it needs to be fast. It can
798 // sort of lag out the main thread if it just does a full invalidate. 798 // sort of lag out the main thread if it just does a full invalidate.
799 799
800 RenderRow(OldRow);
801 RenderRow(Row);
802
803 R.Left:=0; 800 R.Left:=0;
804 R.Width:=ColumnWidth*4; 801 R.Width:=ColumnWidth*4;
805 R.Height:=RowHeight*2; 802 R.Height:=RowHeight*2;
806 803
807 R.Top:=(Row-1)*RowHeight; 804 if InRange(OldRow, Low(TPattern), High(TPattern)) then begin
808 InvalidateRect(Self.Handle, @R, True); 805 RenderRow(OldRow);
809 R.Top:=(OldRow-1)*RowHeight; 806 R.Top:=(Row-1)*RowHeight;
810 InvalidateRect(Self.Handle, @R, True); 807 InvalidateRect(Self.Handle, @R, True);
808 end;
809 if InRange(Row, Low(TPattern), High(TPattern)) then begin
810 RenderRow(Row);
811 R.Top:=(OldRow-1)*RowHeight;
812 InvalidateRect(Self.Handle, @R, True);
813 end;
811 end; 814 end;
812 815
813 procedure TTrackerGrid.SetSelectionGridRect(R: TRect); 816 procedure TTrackerGrid.SetSelectionGridRect(R: TRect);