|
@@ -46,7 +46,7 @@
|
46
|
46
|
.equ ARG_BUFFER_POS, 0x8 @ stores the current output buffer pointer
|
47
|
47
|
.equ ARG_LOOP_START_POS, 0xC @ stores wave loop start position in channel loop
|
48
|
48
|
.equ ARG_LOOP_LENGTH, 0x10 @ '' '' '' end position
|
49
|
|
-@ .equ ARG_UKNOWN, 0x14
|
|
49
|
+ .equ ARG_BUFFER_POS_INDEX_HINT, 0x14
|
50
|
50
|
.equ ARG_PCM_STRUCT, 0x18 @ pointer to engine the main work area
|
51
|
51
|
|
52
|
52
|
/* channel struct */
|
|
@@ -110,8 +110,7 @@
|
110
|
110
|
.equ REG_DMA3_SRC, 0x040000D4
|
111
|
111
|
.equ ARM_OP_LEN, 0x4
|
112
|
112
|
|
113
|
|
-@#######################################
|
114
|
|
-@*********** GAME CONFIGS **************
|
|
113
|
+@########### GAME CONFIGS ##############
|
115
|
114
|
@ add the game's name above to the ASM .equ-s before creating new configs
|
116
|
115
|
@#######################################
|
117
|
116
|
|
|
@@ -178,99 +177,70 @@
|
178
|
177
|
@***********
|
179
|
178
|
|
180
|
179
|
.thumb
|
181
|
|
-
|
182
|
|
-main_mixer:
|
183
|
|
- /* load Reverb level and check if we need to apply it */
|
184
|
|
- LDRB R3, [R0, #VAR_REVERB]
|
185
|
|
- LSR R3, R3, #2
|
186
|
|
- BEQ C_clear_hq_buffer
|
187
|
|
-
|
188
|
|
- ADR R1, C_setup_reverb_loop
|
189
|
|
- BX R1
|
190
|
|
-
|
191
|
|
- .arm
|
192
|
180
|
.align 2
|
193
|
181
|
|
194
|
|
-C_setup_reverb_loop:
|
195
|
182
|
/*
|
196
|
|
- * reverb is calculated by the following: new_sample = old_sample * reverb_level / 127
|
197
|
|
- * note that reverb is mono (both sides get mixed together)
|
198
|
|
- *
|
199
|
|
- * reverb get's applied to the frame we are currently looking at and the one after that
|
200
|
|
- * the magic below simply calculateds the pointer for the one after the current one
|
|
183
|
+ * main_mixer initial registers:
|
|
184
|
+ * R0 = PCM Area
|
|
185
|
+ * R1 = unknown, independant
|
|
186
|
+ * R2 = unknown, independant
|
|
187
|
+ * R3 = unknown, independant
|
|
188
|
+ * R4 = if == 2 then this is last frame in out buffer
|
|
189
|
+ * R5 = current output buffer position
|
|
190
|
+ * R6 = buffer spaceing = 0x630
|
|
191
|
+ * R7 = unknown, independent
|
|
192
|
+ * R8 = samples per buffer
|
|
193
|
+ * R9 = unknown, independent
|
|
194
|
+ * R10 = unknown, independent
|
|
195
|
+ * R11 = unknown, independent
|
|
196
|
+ * R12 = unknown, independent
|
201
|
197
|
*/
|
202
|
|
- CMP R4, #2
|
203
|
|
- ADDEQ R7, R0, #0x350
|
204
|
|
- ADDNE R7, R5, R8
|
205
|
|
- MOV R4, R8
|
206
|
|
- ORR R3, R3, R3, LSL#16
|
207
|
|
- STMFD SP!, {R8, LR}
|
208
|
|
- LDR LR, hq_buffer
|
209
|
|
-
|
210
|
|
-C_reverb_loop:
|
211
|
|
- /* This loop does the reverb processing */
|
212
|
|
- LDRSB R0, [R5, R6]
|
213
|
|
- LDRSB R1, [R5], #1
|
214
|
|
- LDRSB R2, [R7, R6]
|
215
|
|
- LDRSB R8, [R7], #1
|
216
|
|
- LDRSB R9, [R5, R6]
|
217
|
|
- LDRSB R10, [R5], #1
|
218
|
|
- LDRSB R11, [R7, R6]
|
219
|
|
- LDRSB R12, [R7], #1
|
220
|
|
- ADD R0, R0, R1
|
221
|
|
- ADD R0, R0, R2
|
222
|
|
- ADDS R0, R0, R8
|
223
|
|
- ADDMI R0, R0, #0x4
|
224
|
|
- ADD R1, R9, R10
|
225
|
|
- ADD R1, R1, R11
|
226
|
|
- ADDS R1, R1, R12
|
227
|
|
- ADDMI R1, R1, #0x4
|
228
|
|
- MUL R0, R3, R0
|
229
|
|
- MUL R1, R3, R1
|
230
|
|
- STMIA LR!, {R0, R1}
|
231
|
|
- SUBS R4, R4, #2
|
232
|
|
- BGT C_reverb_loop
|
233
|
|
- /* end of loop */
|
234
|
|
- LDMFD SP!, {R8, LR}
|
235
|
|
- ADR R0, (C_setup_channel_state_loop+1)
|
236
|
|
- BX R0
|
237
|
|
-
|
238
|
|
- .thumb
|
239
|
198
|
|
240
|
|
-C_clear_hq_buffer:
|
241
|
|
- /* Incase reverb is disabled the buffer get's set to zero */
|
|
199
|
+main_mixer:
|
|
200
|
+ /* load Reverb level and check if we need to apply it */
|
|
201
|
+ STR R4, [SP, #ARG_BUFFER_POS_INDEX_HINT]
|
|
202
|
+ ADR R2, is_buffer_init
|
|
203
|
+ LDRB R0, [R2]
|
|
204
|
+ CMP R0, #0
|
|
205
|
+ BNE C_setup_channel_state_loop
|
|
206
|
+ /* if buffer not initialized, clear first */
|
242
|
207
|
LDR R3, hq_buffer
|
243
|
208
|
MOV R1, R8
|
244
|
209
|
MOV R4, #0
|
245
|
210
|
MOV R5, #0
|
246
|
211
|
MOV R6, #0
|
247
|
212
|
MOV R7, #0
|
248
|
|
- /*
|
249
|
|
- * Setting the buffer to zero happens in a very efficient loop
|
250
|
|
- * Depending on the alignment of the buffer length, twice or quadruple the amount of bytes
|
251
|
|
- * get cleared at once
|
252
|
|
- */
|
|
213
|
+
|
253
|
214
|
LSR R1, #3
|
254
|
|
- BCC C_clr_hq_buffer_align_8
|
|
215
|
+ BCC C_clear_buffer_align_8
|
255
|
216
|
|
256
|
217
|
STMIA R3!, {R4, R5, R6, R7}
|
257
|
218
|
|
258
|
|
-C_clr_hq_buffer_align_8:
|
|
219
|
+C_clear_buffer_align_8:
|
259
|
220
|
LSR R1, #1
|
260
|
|
- BCC C_clr_hq_buffer_align_16
|
|
221
|
+ BCC C_clear_buffer_align_16
|
261
|
222
|
|
262
|
223
|
STMIA R3!, {R4, R5, R6, R7}
|
263
|
224
|
STMIA R3!, {R4, R5, R6, R7}
|
264
|
225
|
|
265
|
|
-C_clr_hq_buffer_align_16:
|
266
|
|
- /* This repeats until the buffer has been cleared */
|
|
226
|
+C_clear_buffer_align_16:
|
267
|
227
|
STMIA R3!, {R4, R5, R6, R7}
|
268
|
228
|
STMIA R3!, {R4, R5, R6, R7}
|
269
|
229
|
STMIA R3!, {R4, R5, R6, R7}
|
270
|
230
|
STMIA R3!, {R4, R5, R6, R7}
|
|
231
|
+
|
271
|
232
|
SUB R1, #1
|
272
|
|
- BGT C_clr_hq_buffer_align_16
|
273
|
|
- /* loop end */
|
|
233
|
+ BGT C_clear_buffer_align_16
|
|
234
|
+ MOV R1, #1
|
|
235
|
+ STRB R1, [R2]
|
|
236
|
+ B C_setup_channel_state_loop
|
|
237
|
+
|
|
238
|
+ .align 2
|
|
239
|
+is_buffer_init:
|
|
240
|
+ .byte 0x0
|
|
241
|
+
|
|
242
|
+ .align 1
|
|
243
|
+
|
274
|
244
|
C_setup_channel_state_loop:
|
275
|
245
|
/*
|
276
|
246
|
* okay, before the actual mixing starts
|
|
@@ -898,19 +868,22 @@ C_main_mixer_return:
|
898
|
868
|
.align 2
|
899
|
869
|
|
900
|
870
|
C_downsampler:
|
901
|
|
- LDR R10, hq_buffer
|
902
|
|
- LDR R9, [SP, #ARG_BUFFER_POS]
|
|
871
|
+ MOV R4, #0
|
|
872
|
+ MOV R5, #0
|
903
|
873
|
LDR R8, hq_buffer_length
|
|
874
|
+ LDR R9, [SP, #ARG_BUFFER_POS]
|
|
875
|
+ LDR R10, hq_buffer
|
904
|
876
|
MOV R11, #0xFF
|
905
|
877
|
MOV R12, #0xFFFFFFFF
|
906
|
878
|
MOV R12, R12, LSL#14
|
907
|
879
|
MOV R7, #0x630
|
908
|
880
|
|
909
|
881
|
C_downsampler_loop:
|
910
|
|
- LDRSH R2, [R10], #2
|
911
|
|
- LDRSH R0, [R10], #2
|
912
|
|
- LDRSH R3, [R10], #2
|
913
|
|
- LDRSH R1, [R10], #2
|
|
882
|
+ LDRSH R2, [R10]
|
|
883
|
+ LDRSH R0, [R10, #2]
|
|
884
|
+ LDRSH R3, [R10, #4]
|
|
885
|
+ LDRSH R1, [R10, #6]
|
|
886
|
+ STMIA R10!, {R4, R5}
|
914
|
887
|
|
915
|
888
|
CMP R0, #0x4000
|
916
|
889
|
MOVGE R0, #0x3F80
|