@@ -6,11 +6,11 @@ interface |
| 6 |
uses |
6 |
uses |
| 7 |
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ComCtrls, |
7 |
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ComCtrls, |
| 8 |
Menus, Spin, StdCtrls, ActnList, StdActns, SynEdit, SynHighlighterAny, |
8 |
Menus, Spin, StdCtrls, ActnList, StdActns, SynEdit, SynHighlighterAny, |
| 9 |
FileUtil, math, Instruments, Song, Utils, Constants, |
9 |
FileUtil, math, Instruments, Song, Utils, Constants, sound, vars, machine, |
| 10 |
sound, vars, machine, about_hugetracker, TrackerGrid, lclintf, lmessages, |
10 |
about_hugetracker, TrackerGrid, lclintf, lmessages, Buttons, Grids, DBCtrls, |
| 11 |
Buttons, Grids, DBCtrls, HugeDatatypes, LCLType, Clipbrd, RackCtls, Codegen, |
11 |
HugeDatatypes, LCLType, Clipbrd, RackCtls, Codegen, SymParser, options, |
| 12 |
SymParser, options, bgrabitmap, effecteditor, RenderToWave, |
12 |
bgrabitmap, effecteditor, RenderToWave, modimport, mainloop, strutils, Types, |
| 13 |
modimport, mainloop, strutils, Types, Keymap, hUGESettings, vgm, TBMImport; |
13 |
Keymap, hUGESettings, vgm, TBMImport, InstrumentPreview; |
| 14 |
|
14 |
|
| 15 |
// TODO: Move to config file? |
15 |
// TODO: Move to config file? |
| 16 |
const |
16 |
const |
@@ -841,61 +841,23 @@ end; |
| 841 |
procedure TfrmTracker.PreviewInstrument(Note: Integer; Instr: TInstrument; |
841 |
procedure TfrmTracker.PreviewInstrument(Note: Integer; Instr: TInstrument; |
| 842 |
SquareOnCh2: Boolean = False); |
842 |
SquareOnCh2: Boolean = False); |
| 843 |
var |
843 |
var |
| 844 |
Regs: TRegisters; |
844 |
Addr: Integer; |
| 845 |
AsmInstrument: TAsmInstrument; |
845 |
Wave: TWave; |
| 846 |
I, Addr, Freq: Integer; |
|
|
| 847 |
HighMask: Integer; |
|
|
| 848 |
begin |
846 |
begin |
| 849 |
Freq := NotesToFreqs.KeyData[Note]; |
|
|
| 850 |
AsmInstrument := InstrumentToBytes(Instr); |
|
|
| 851 |
|
|
|
| 852 |
LockPlayback; |
847 |
LockPlayback; |
| 853 |
|
848 |
|
| 854 |
with Instr do |
849 |
if Instr.Type_ = itWave then begin |
| 855 |
begin |
850 |
CopyWaveIntoWaveRam(Instr.Waveform); |
| 856 |
case Type_ of |
|
|
| 857 |
itSquare: begin |
|
|
| 858 |
WriteBufferToSymbol('instrument1', AsmInstrument, SizeOf(TAsmInstrument)); |
|
|
| 859 |
WordPokeSymbol('channel_period1', NotesToFreqs.KeyData[Note]); |
|
|
| 860 |
PokeSymbol('channel_note1', Note); |
|
|
| 861 |
WriteBufferToSymbol('subpattern1', SubpatternToBytes(Instr.Subpattern), SizeOf(TSubpatternBytes)); |
|
|
| 862 |
|
|
|
| 863 |
PokeSymbol('start_ch1', 1); |
|
|
| 864 |
if Instr.SubpatternEnabled then |
|
|
| 865 |
PokeSymbol('running_ch1', 1); |
|
|
| 866 |
end; |
|
|
| 867 |
itWave: begin |
|
|
| 868 |
CopyWaveIntoWaveRam(Waveform); |
|
|
| 869 |
|
|
|
| 870 |
WriteBufferToSymbol('instrument3', AsmInstrument, SizeOf(TAsmInstrument)); |
|
|
| 871 |
WordPokeSymbol('channel_period3', NotesToFreqs.KeyData[Note]); |
|
|
| 872 |
PokeSymbol('channel_note3', Note); |
|
|
| 873 |
WriteBufferToSymbol('subpattern3', SubpatternToBytes(Instr.Subpattern), SizeOf(TSubpatternBytes)); |
|
|
| 874 |
|
851 |
|
| 875 |
PokeSymbol('start_ch3', 1); |
852 |
Addr := SymbolAddress(SYM_HALT_WAVEFORMS); |
| 876 |
if Instr.SubpatternEnabled then |
853 |
for Wave in Song.Waves do begin |
| 877 |
PokeSymbol('running_ch3', 1); |
854 |
WriteBufferToAddress(Addr, ConvertWaveform(Wave), SizeOf(T4bitWave)); |
| 878 |
end; |
855 |
Inc(Addr, SizeOf(T4bitWave)); |
| 879 |
itNoise: begin |
|
|
| 880 |
Addr := SymbolAddress('instrument4'); |
|
|
| 881 |
spokeb(Addr, AsmInstrument[1]); |
|
|
| 882 |
|
|
|
| 883 |
HighMask := AsmInstrument[0]; |
|
|
| 884 |
if Instr.LengthEnabled then |
|
|
| 885 |
HighMask := HighMask or %01000000; |
|
|
| 886 |
if Instr.CounterStep = swSeven then |
|
|
| 887 |
HighMask := HighMask or %10000000; |
|
|
| 888 |
spokeb(Addr+3, HighMask); |
|
|
| 889 |
|
|
|
| 890 |
PokeSymbol('channel_note4', Note); |
|
|
| 891 |
WriteBufferToSymbol('subpattern4', SubpatternToBytes(Instr.Subpattern), SizeOf(TSubpatternBytes)); |
|
|
| 892 |
|
|
|
| 893 |
PokeSymbol('start_ch4', 1); |
|
|
| 894 |
if Instr.SubpatternEnabled then |
|
|
| 895 |
PokeSymbol('running_ch4', 1); |
|
|
| 896 |
end; |
|
|
| 897 |
end; |
856 |
end; |
| 898 |
end; |
857 |
end; |
|
|
858 |
|
|
|
859 |
StartInstrumentPreview(Instr, Note, SquareOnCh2); |
|
|
860 |
|
| 899 |
UnlockPlayback; |
861 |
UnlockPlayback; |
| 900 |
end; |
862 |
end; |
| 901 |
|
863 |
|
@@ -926,11 +888,10 @@ begin |
| 926 |
Spokeb(NR42, 0); |
888 |
Spokeb(NR42, 0); |
| 927 |
Spokeb(NR44, %10000000); |
889 |
Spokeb(NR44, %10000000); |
| 928 |
|
890 |
|
| 929 |
// Stop running subpatterns |
891 |
StopInstrumentPreview(1); |
| 930 |
PokeSymbol('running_ch1', 0); |
892 |
StopInstrumentPreview(2); |
| 931 |
PokeSymbol('running_ch2', 0); |
893 |
StopInstrumentPreview(3); |
| 932 |
PokeSymbol('running_ch3', 0); |
894 |
StopInstrumentPreview(4); |
| 933 |
PokeSymbol('running_ch4', 0); |
|
|
| 934 |
|
895 |
|
| 935 |
UnlockPlayback; |
896 |
UnlockPlayback; |
| 936 |
end; |
897 |
end; |