Commit bcf6302

Nick Faro committed on
Working instrument preview
commit bcf630232cadfd5eb1224447c3f8e0ccfde5d577 parent fd167dc
2 changed files +70−32
Modifiedhalt.asm +42−31
@@ -1,23 +1,6 @@
1 include "hardware.inc" 1 include "hardware.inc"
2 include "hUGE.inc" 2 include "hUGE.inc"
3 3
4 add_a_to_r16: MACRO
5 add \2
6 ld \2, a
7 adc \1
8 sub \2
9 ld \1, a
10 ENDM
11
12 add_a_to_hl: MACRO
13 add_a_to_r16 h, l
14 ENDM
15
16 add_a_to_de: MACRO
17 add_a_to_r16 d, e
18 ENDM
19
20
21 SECTION "LCD controller status interrupt", ROM0[$0048] 4 SECTION "LCD controller status interrupt", ROM0[$0048]
22 ;; HACK!!!!!!!!!!!!! 5 ;; HACK!!!!!!!!!!!!!
23 ;; there's some sort of bug in the emulator which needs to be fixed, 6 ;; there's some sort of bug in the emulator which needs to be fixed,
@@ -84,8 +67,6 @@ init_note1:
84 xor a 67 xor a
85 ld [table_row1], a 68 ld [table_row1], a
86 ld [start_ch1], a 69 ld [start_ch1], a
87 inc a
88 ld [running_ch1], a
89 70
90 jp play_ch1_note 71 jp play_ch1_note
91 72
@@ -102,8 +83,6 @@ init_note2:
102 xor a 83 xor a
103 ld [table_row2], a 84 ld [table_row2], a
104 ld [start_ch2], a 85 ld [start_ch2], a
105 inc a
106 ld [running_ch2], a
107 86
108 jp play_ch2_note 87 jp play_ch2_note
109 88
@@ -121,11 +100,43 @@ init_note3:
121 xor a 100 xor a
122 ld [table_row3], a 101 ld [table_row3], a
123 ld [start_ch3], a 102 ld [start_ch3], a
124 inc a
125 ld [running_ch3], a
126 103
127 jp play_ch3_note 104 jp play_ch3_note
128 105
106 init_note4:
107 ld a, [channel_note4]
108 call get_note_poly
109 ld [channel_period4], a
110
111 ld hl, instrument4
112 ld a, [hl+]
113 ldh [rAUD4ENV], a
114 inc hl
115 inc hl
116 ld a, [hl]
117 and %00111111
118 ldh [rAUD4LEN], a
119
120 ld a, [channel_period4]
121 ld d, a
122 ld a, [hl]
123 and %10000000
124 swap a
125 ld [step_width4], a
126 or d
127 ld [channel_period4], a
128
129 ld a, [hl]
130 and %01000000
131 or %10000000
132 ld [highmask4], a
133
134 xor a
135 ld [table_row4], a
136 ld [start_ch4], a
137
138 jp play_ch4_note
139
129 run_table1: 140 run_table1:
130 ld bc, subpattern1 141 ld bc, subpattern1
131 ld hl, table_row1 142 ld hl, table_row1
@@ -149,7 +160,7 @@ run_table2:
149 run_table3: 160 run_table3:
150 ld bc, subpattern3 161 ld bc, subpattern3
151 ld hl, table_row3 162 ld hl, table_row3
152 ld e, 0 163 ld e, 2
153 164
154 ld a, b 165 ld a, b
155 or c 166 or c
@@ -159,7 +170,7 @@ run_table3:
159 run_table4: 170 run_table4:
160 ld bc, subpattern4 171 ld bc, subpattern4
161 ld hl, table_row4 172 ld hl, table_row4
162 ld e, 0 173 ld e, 3
163 174
164 ld a, b 175 ld a, b
165 or c 176 or c
@@ -226,9 +237,9 @@ _halt:
226 and $FF 237 and $FF
227 call nz, init_note3 238 call nz, init_note3
228 239
229 ; ld a, [start_ch4] 240 ld a, [start_ch4]
230 ; and $FF 241 and $FF
231 ; call nz, init_note4 242 call nz, init_note4
232 243
233 ;;;;;;;;;;;;;;;;;;;;; 244 ;;;;;;;;;;;;;;;;;;;;;
234 245
@@ -236,9 +247,9 @@ _halt:
236 and $FF 247 and $FF
237 call nz, run_table1 248 call nz, run_table1
238 249
239 ; ld a, [running_ch2] 250 ld a, [running_ch2]
240 ; and $FF 251 and $FF
241 ; call nz, run_table2 252 call nz, run_table2
242 253
243 ld a, [running_ch3] 254 ld a, [running_ch3]
244 and $FF 255 and $FF
Modifiedtracker.pas +28−1
@@ -844,6 +844,7 @@ var
844 Regs: TRegisters; 844 Regs: TRegisters;
845 AsmInstrument: TAsmInstrument; 845 AsmInstrument: TAsmInstrument;
846 I, Addr, Freq: Integer; 846 I, Addr, Freq: Integer;
847 HighMask: Integer;
847 begin 848 begin
848 Freq := NotesToFreqs.KeyData[Note]; 849 Freq := NotesToFreqs.KeyData[Note];
849 AsmInstrument := InstrumentToBytes(Instr); 850 AsmInstrument := InstrumentToBytes(Instr);
@@ -860,6 +861,8 @@ begin
860 WriteBufferToSymbol('subpattern1', SubpatternToBytes(Instr.Subpattern), SizeOf(TSubpatternBytes)); 861 WriteBufferToSymbol('subpattern1', SubpatternToBytes(Instr.Subpattern), SizeOf(TSubpatternBytes));
861 862
862 PokeSymbol('start_ch1', 1); 863 PokeSymbol('start_ch1', 1);
864 if Instr.SubpatternEnabled then
865 PokeSymbol('running_ch1', 1);
863 end; 866 end;
864 itWave: begin 867 itWave: begin
865 CopyWaveIntoWaveRam(Waveform); 868 CopyWaveIntoWaveRam(Waveform);
@@ -870,9 +873,26 @@ begin
870 WriteBufferToSymbol('subpattern3', SubpatternToBytes(Instr.Subpattern), SizeOf(TSubpatternBytes)); 873 WriteBufferToSymbol('subpattern3', SubpatternToBytes(Instr.Subpattern), SizeOf(TSubpatternBytes));
871 874
872 PokeSymbol('start_ch3', 1); 875 PokeSymbol('start_ch3', 1);
876 if Instr.SubpatternEnabled then
877 PokeSymbol('running_ch3', 1);
873 end; 878 end;
874 itNoise: begin 879 itNoise: begin
875 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);
876 end; 896 end;
877 end; 897 end;
878 end; 898 end;
@@ -905,6 +925,13 @@ begin
905 // Silence CH4 925 // Silence CH4
906 Spokeb(NR42, 0); 926 Spokeb(NR42, 0);
907 Spokeb(NR44, %10000000); 927 Spokeb(NR44, %10000000);
928
929 // Stop running subpatterns
930 PokeSymbol('running_ch1', 0);
931 PokeSymbol('running_ch2', 0);
932 PokeSymbol('running_ch3', 0);
933 PokeSymbol('running_ch4', 0);
934
908 UnlockPlayback; 935 UnlockPlayback;
909 end; 936 end;
910 937