-
Notifications
You must be signed in to change notification settings - Fork 12
/
IT_D_INF.INC
1126 lines (860 loc) · 32.5 KB
/
IT_D_INF.INC
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Proc D_GetSongNameModuleType
LEA DI, [SI+17] ; ES:DI points to deposit point.
Sub SI, 8
Cmp DWord Ptr [DS:60000], 'MPMI'
JNE D_GetSongNameModuleType1
Mov DX, [DS:60000+2Ah]
Mov AX, 3
Cmp DX, TRACKERVERSION
JA D_GSNMTImpulse1
Dec AX
Cmp DX, 214h
JB D_GSNMTImpulse1
Mov AX, 7
D_GSNMTImpulse1:
Mov Word Ptr [SI+23], AX
Mov SI, 60004
Mov CX, 25
Rep MovsB
Ret
D_GetSongNameModuleType1:
; Cmp Word Ptr [DS:60028], 101Ah
; JNE D_GetSongNameModuleType2
Cmp DWord Ptr [DS:60044], 'MRCS'
JNE D_GetSongNameModuleType2
Mov Word Ptr [SI+23], 4
Mov SI, 60000
Mov CX, 25
Rep MovsB
Ret
D_GetSongNameModuleType2:
Push SI ES DI
Push CS
Pop ES
Mov SI, 60000
Mov DI, Offset XMIdentification
Mov CX, 17
RepE CmpsB
Pop DI ES SI
JNE D_GetSongNameModuleTypeNotXM
Mov Word Ptr [SI+23], 5 ; XM
Mov SI, 60000+17
Mov CX, 20
Rep MovsB
Xor AX, AX
; Mov CX, 5
; Rep StosB
Ret
D_GetSongNameModuleTypeNotXM:
Mov AX, [DS:60000]
Cmp AX, 'fi'
JE D_GetSongNameModuleType669
Cmp AX, 'NJ'
JNE D_GetSongNameModuleTypeNot669
D_GetSongNameModuleType669: ; We have a 669 module!
Mov Word Ptr [SI+23], 6 ; 669
Mov SI, 60000+2
Mov CX, 25
Rep MovsB
Ret
D_GetSongNameModuleTypeNot669:
Mov EAX, [DS:61080]
Cmp EAX, '.K.M'
JNE D_GetSongNameModuleType3
Mov Word Ptr [SI+23], 9
Jmp D_GSNMTMod
D_GetSongNameModuleType3:
Cmp EAX, '!K!M'
JNE D_GetSongNameModuleType4
Mov Word Ptr [SI+23], 10
Jmp D_GSNMTMod
D_GetSongNameModuleType4:
Cmp EAX, 'NHC4'
JNE D_GetSongNameModuleType5
Mov Word Ptr [SI+23], 11
Jmp D_GSNMTMod
D_GetSongNameModuleType5:
Cmp EAX, 'NHC6'
JNE D_GetSongNameModuleType6
Mov Word Ptr [SI+23], 12
Jmp D_GSNMTMod
D_GetSongNameModuleType6:
Cmp EAX, 'NHC8'
JNE D_GetSongNameModuleType11
Mov Word Ptr [SI+23], 13
Jmp D_GSNMTMod
D_GetSongNameModuleType11:
Cmp Word Ptr [DS:61082], 'HC'
JNE D_GetSongNameModuleType7
Cmp AL, '0'
JB D_GetSongNameModuleType7
Cmp AL, '9'
JA D_GetSongNameModuleType7
Cmp AH, '0'
JB D_GetSongNameModuleType7
Cmp AH, '9'
JA D_GetSongNameModuleType7
; Generic MOD type.
Sub AX, '00'
Mov BL, AH
Mov AH, 10
Mul AH
Add BL, AL
Mov Word Ptr [SI+23], 17
Mov Byte Ptr [SI+22], BL
Jmp D_GSNMTMod
D_GetSongNameModuleType7:
Cmp EAX, '4TLF'
JNE D_GetSongNameModuleType8
Mov Word Ptr [SI+23], 14
Jmp D_GSNMTMod
D_GetSongNameModuleType8:
; Cmp EAX, '8TLF'
; JNE D_GetSongNameModuleType9
;
; Mov Word Ptr [SI+23], 15
; Jmp D_GSNMTMod
;
; D_GetSongNameModuleType9:
Cmp Byte Ptr [DS:60000+471], 78h
JNE D_GetSongNameModuleType10
Mov Word Ptr [SI+23], 16
Jmp D_GSNMTMod
D_GetSongNameModuleType10:
Cmp Word Ptr [DS:60000], 'M'+256*'T'
JNE D_GetSongNameModuleType12
Cmp Byte Ptr [DS:60002], 'M'
JNE D_GetSongNameModuleType12
Mov Word Ptr [SI+23], 18
Mov SI, 60004
Mov CX, 20
Rep MovsB
Mov CX, 5
Xor AL, AL
Rep StosB
D_GetSongNameModuleType12:
Mov Word Ptr [SI+23], 1
Ret
D_GSNMTMod:
Mov SI, 60000
Mov CX, 20
Rep MovsB
Xor AX, AX
StosW
StosW
StosB
Ret
EndP D_GetSongNameModuleType
;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Proc D_GetInstrumentInfo ; Instrument layout
; 48 bytes per instrument.
; Offset 0 = type of file.
; 0 = Unchecked
; 1 = Directory
; 2 = Unrecognised
; 3 = ITI
; 4 = XI
; 8 = .IT
; 9 = .XM
; Offset 1 = file name
; 15->40 is the instrument name,
; 40 = No. Samples
; 42 = File size.
; 44 = file offset (DWord)
Mov AX, 48
Mul BX
Mov DI, AX
Mov DS, CS:DiskDataArea
Mov SI, 60000
; Check for XM
Push CS
Pop ES
; Comment ~
Push DI
Mov DI, Offset XMIdentification
Mov CX, 17
RepE CmpSB
Pop DI
Mov AL, 9
JE D_InModuleInstrument ; XM module found?
Mov SI, 60000
Cmp DWord Ptr [SI], 'MPMI' ; Impulse Tracker module?
JNE D_GetInstrumentInfoNotIT
Cmp Word Ptr [SI+22h], 0
JE D_GetInstrumentInfoNotIT
Test Byte Ptr [SI+2Ch], 4 ; Instrument mode?
JZ D_GetInstrumentInfoNotIT
Mov AL, 8
D_InModuleInstrument:
Push DS
Pop ES
StosB
Add DI, 14
Push CS
Pop DS
Mov SI, Offset LibraryMsg
Mov CX, 25
Rep MovsB
Xor AX, AX
Ret
D_GetInstrumentInfoNotIT:
; ~
Cmp DWord Ptr [SI], 'IPMI'
JNE D_GetInstrumentInfo1
Push DS
Pop ES
Mov Byte Ptr [DI], 3
Mov AL, [SI+1Eh]
Xor AH, AH
Add DI, 15
Add SI, 20h
Mov CX, 25
Rep MovsB
StosW ; NOS.
ClC
Ret
D_GetInstrumentInfo1: ; Check for XI
Push DI
Mov DI, Offset XIIdentification
Mov CX, 21
RepE CmpsB
Pop DI
JNE D_GetInstrumentInfo2
D_GetInstrumentInfoXI:
Push DS
Pop ES
Mov Byte Ptr [DI], 4 ; XI
Add DI, 15
Mov CX, 22
Rep MovsB
Xor AX, AX
StosW
StosB
Mov AX, [DS:60000+128h] ; AX = number of samples
StosW ; NoS
Ret
D_GetInstrumentInfo2:
Push DS
Pop ES
Mov SI, DI
Mov CX, 48
Mov AX, CS:NumInstruments
Sub AX, BX
Add SI, CX
Mul CX
Mov CX, AX
Rep MovsB
Push CS
Pop DS
Assume DS:Disk
Dec NumInstruments
Mov AX, CurrentInstrument
Cmp AX, NumInstruments
JAE D_GetInstrumentInfo3
Cmp AX, BX
JBE D_GetInstrumentInfoEnd
D_GetInstrumentInfo3:
Sub AX, 1
AdC AX, 0
D_GetInstrumentInfoEnd:
Mov CurrentInstrument, AX
StC
Ret
EndP D_GetInstrumentInfo
;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Proc D_GetSampleInfo ; BX = sample num.
Mov AX, 96
Mul BX
Mov DI, AX
Mov BX, AX
Mov DS, CS:DiskDataArea
Mov SI, 60000
Push DS
Pop ES ; ES:DI points to sample block
; DS:SI points to header
Mov Byte Ptr [BX+90], 2 ; Recognised sample default.
Cmp DWord Ptr [DS:60000], 'SPMI'
JE D_GetSampleInfo1 ; Possibly a IT sample.
Cmp DWord Ptr [DS:60000+4Ch], 'SRCS'
JE D_GetSampleInfo4
Cmp DWord Ptr [DS:60000], 'FFIR'
JE D_GetSampleInfo8 ; AIFF?
Cmp DWord Ptr [DS:60000], 'MROF'
JE D_GetSampleInfo13
Mov AL, 21h
Cmp DWord Ptr [DS:60000], 'MPMI'
JE D_GetSampleInfoModuleTypes1
Mov AL, 23h
Cmp DWord Ptr [DS:60000+44], 'FMTP'
JE D_GetSampleInfoModuleTypes1
Inc AX ; AL = 24h
Mov ECX, [DS:60000]
And ECX, 0FFFFFFh
Cmp ECX, 'M'*10000h+'T'*100h+'M'
JE D_GetSampleInfoModuleTypes1
Inc AX ; AL = 25h
Cmp Word Ptr [DS:60000], 'fi'
JE D_GetSampleInfoModuleTypes1
Cmp Word Ptr [DS:60000], 'NJ'
JE D_GetSampleInfoModuleTypes1
Inc AX ; AL = 26h
Cmp DWord Ptr [DS:60000], 'þRAF'
JE D_GetSampleInfoModuleTypes1
Mov ECX, [DS:60000+1080]
Mov AX, 427h ; MOD Module + 4 channels
Cmp ECX, '.K.M'
JE D_GetSampleInfoModuleTypes1
Cmp ECX, '!K!M'
JE D_GetSampleInfoModuleTypes1
Cmp ECX, '4TLF'
JE D_GetSampleInfoModuleTypes1
Cmp ECX, 'NHC4'
JE D_GetSampleInfoModuleTypes1
Mov AH, 6 ; 6 Channel
Cmp ECX, 'NHC6'
JE D_GetSampleInfoModuleTypes1
Mov AH, 8
Cmp ECX, 'NHC8'
JE D_GetSampleInfoModuleTypes1
Cmp ECX, '8TLF'
JE D_GetSampleInfoModuleTypes1
Cmp Word Ptr [DS:61082], 'HC'
JNE D_GetSampleInfoS3M
Sub CX, '00'
Cmp CL, 9
JA D_GetSampleInfoS3M
Cmp CH, 9
JA D_GetSampleInfoS3M
Mov AL, 10
Mul CL
Add AL, CH
Mov AH, AL
Mov AL, 28h
Jmp D_GetSampleInfoModuleTypes1
D_GetSampleInfoS3M:
Cmp DWord Ptr [DS:60000+2Ch], 'MRCS'
JNE D_GetSampleInfoModuleTypes3
Mov AL, 20h ; ST3?
Jmp D_GetSampleInfoModuleTypes1
; Cmp Word Ptr [DS:60000+1Ch], 101Ah
; JE D_GetSampleInfoModuleTypes1
; Jmp D_GetSampleInfoModuleTypes3
D_GetSampleInfoModuleTypes3: ; KRZ
Cmp DWord Ptr [DS:60000], 'MARP'
JNE D_GetSampleInfoNotKRZ
Cmp Word Ptr [DS:60000+32], 0FFFFh
JNE D_GetSampleInfoNotKRZ
; Check filename for .KRZ
LEA SI, [BX+4]
Mov CX, 9
D_CheckKRZFileName:
Cmp Byte Ptr [SI], 0
JE D_GetSampleInfoNotKRZ
Cmp DWord Ptr [SI], 'ZRK.'
JE D_FoundKRZ
Inc SI
Loop D_CheckKRZFileName
Jmp D_GetSampleInfoNotKRZ
D_FoundKRZ:
Mov AL, 29h
Jmp D_GetSampleInfoModuleTypes1
D_GetSampleInfoNotKRZ: ; FT2 check
Push SI
Push ES
Push DI
Push CS
Pop ES
Mov DI, Offset GUSPATIdentification
Mov CX, 22
RepE CmpsB
Pop DI
Pop ES
Pop SI
JNE D_GetSampleInfoNotPAT
Cmp Byte Ptr [DS:60000+198], 1
JE G_GetSampleInfoPAT
Mov AL, 2Ah
Jmp D_GetSampleInfoModuleTypes1
G_GetSampleInfoPAT:
Mov Byte Ptr [BX+88], 16
Mov EAX, 'SPMI'
StosD
Mov SI, DI
Add DI, 13
Mov AL, 64
StosB ; Global vol = 64
Mov AX, 4001h ; sample present
Mov DL, [DS:60000+239+55] ; modes
Test DL, 1 ; 8/16 bit
JZ GetSampleInfoPATSamples2
Or AL, 2
GetSampleInfoPATSamples2:
Test DL, 4 ; Looping enabled?
JZ GetSampleInfoPATSamples3
Or AL, 10h
GetSampleInfoPATSamples3:
Test DL, 8 ; Ping pong loops?
JZ GetSampleInfoPATSamples4
Or AL, 40h
GetSampleInfoPATSamples4:
StosW ; OK.. now for name.
Mov SI, 60000+131
Mov CX, 16
GetSampleInfoPATSamples5:
LodsB
Test AL, AL
JZ GetSampleInfoPATSamples6
StosB
Loop GetSampleInfoPATSamples5
Xor AL, AL
GetSampleInfoPATSamples6:
Add CX, 10
Rep StosB
; Convert, default pan
Mov AH, 32
Mov AL, [DS:60000+239+55]
And AL, 2
ShR AL, 1
Xor AL, 1
StosW
; Length.
Mov DL, [DS:60000+239+55]
Mov EAX, [DS:60000+239+16] ; LoopEnd -> FileSize
Mov [DI+20h], EAX ; File size
Call StorePATLength
Mov EAX, [DS:60000+239+12] ; LoopBeg
Call StorePATLength
Mov EAX, [DS:60000+239+16] ; LoopEnd
Call StorePATLength
Mov AX, [DS:60000+239+20]
And EAX, 0FFFFh
Comment ~
Push ES DI
Call Music_GetPitchTable ; Returns ES:DI
Mov BP, [DS:60000+239+56]
And BP, 0FFh
ShL BP, 2
Mul DWord Ptr [ES:DI+BP]
SHRD EAX, EDX, 16
Pop DI ES
~
StosD ; C5Spd
Xor EAX, EAX
StosD
StosD
Mov EAX, 14Fh
StosD
Xor AX, AX
StosW
StosW
Ret
D_GetSampleInfoNotPAT:
Push SI
Push ES
Push DI
Push CS
Pop ES
Mov DI, Offset XMIdentification
Mov CX, 17
RepE CmpsB
Pop DI
Pop ES
Pop SI
JNE TXWaveSampleIdentification
Mov AL, 22h ; FT2
D_GetSampleInfoModuleTypes1:
Mov Word Ptr [BX+88], AX
Mov Byte Ptr [BX+90], 1
Push DS
Push CS
Pop DS
Mov SI, Offset LibraryMsg
LEA DI, [BX+14h]
Mov CX, 26/2
Rep MovsW
Pop DS
Ret
TXWaveSampleIdentification:
Push SI
Push ES
Push DI
Push CS
Pop ES
Mov DI, Offset TXWaveIdentification
Mov CX, 16
RepE CmpSB
Pop DI
Pop ES
Pop SI
; OK.. have a TX Wave.
; Now to transfer data.
JNE D_GetSampleInfo2
Mov AL, [DS:60000+16h]
And AL, 7Fh
Cmp AL, 49h
JNE D_GetSampleInfo2
Mov Byte Ptr [BX+88], 13
Mov EAX, 'SPMI'
StosD
Mov SI, DI
Add DI, 13
Mov AL, 64
StosB ; Global vol = 64
Mov AX, 64*256+1+2 ; Flag = sample + 16 bit
; Default volume = 64
Cmp Byte Ptr [DS:60000+16h], 049h
JNE D_GetTXInfo3
Or AL, 10h ; Loop forwards
D_GetTXInfo3:
StosW
Mov CX, 13
D_GetTXInfo1:
LodsB
Test AL, AL
JZ D_GetTXInfo2
StosB
Loop D_GetTXInfo1
D_GetTXInfo2:
Xor AL, AL
Rep StosB
Mov CX, 13
Rep StosB
; Length...
Mov AX, 16+1 ; TX Wave, signed
StosW
Mov EDX, [DS:60000+18h]
Mov ECX, [DS:60000+1Bh]
And EDX, 1FFFFh ; Attack length
And ECX, 1FFFFh ; Loop Length
Mov EAX, ECX
Add EAX, EDX ; Length
StosD
Mov EAX, EDX ; LoopStart
StosD
Add EAX, ECX ; LoopEnd
StosD
Mov EAX, 33000 ; Freq
Cmp Byte Ptr [DS:60000+17h], 2
JB D_GetTXInfo4
Mov AX, 50000
JE D_GetTXInfo4
Mov AX, 16000
D_GetTXInfo4:
StosD ; Frequency
Xor EAX, EAX
StosD
StosD
Mov AX, 20h
StosD
Xor AX, AX
StosD
Ret
D_GetSampleInfo2:
Mov DWord Ptr [BX+88], 30004h ; Unknown Type
Mov EAX, 'SPMI'
StosD
Mov SI, DI
Add DI, 13
Mov AL, 64
StosB ; Global vol = 64
Mov AL, 1
StosB ; Flag = sample.
Mov AL, 64
StosB ; Default vol = 64.
Mov CX, 13
D_GetSampleInfo6:
LodsB
Test AL, AL
JZ D_GetSampleInfo7
StosB
Loop D_GetSampleInfo6
D_GetSampleInfo7:
Xor AL, AL
Rep StosB
Mov CX, 15
Rep StosB
; Length...
Mov EAX, 4177910
Cmp EAX, [BX+80]
JB D_GetSampleInfo3
Mov EAX, [BX+80]
D_GetSampleInfo3:
StosD
Xor AX, AX
StosW
StosW
StosW
StosW
Mov AX, 8363
StosW
Xor AX, AX
Mov CX, 9
Rep StosW
Ret
D_GetSampleInfo1:
Mov Byte Ptr [BX+88], 2
Mov CX, 4
Rep MovsB
Add SI, 12
Add DI, 12
Mov CX, 64
Rep MovsB
Ret
D_GetSampleInfo4:
Mov Byte Ptr [BX+88], 3 ; Scrm
Mov EAX, 'SPMI'
StosD
Add DI, 13
Mov AL, 64
StosB
Mov AL, 1
Mov CL, [DS:60000+1Fh]
Mov CH, CL
And CL, 1
ShL CL, 4
Or AL, CL ; Loop...
And CH, 4
ShR CH, 1
Or AL, CH ; 16 bit.
D_GetSampleInfo5:
StosB
Mov AL, [DS:60000+1Ch]
StosB
Mov SI, 60000+30h
Mov CX, 25
Rep MovsB
Xor AX, AX
StosB
StosW ; Name done... now for length
Mov EAX, [DS:60000+10h]
StosD
Mov EAX, [DS:60000+14h]
StosD
Mov EAX, [DS:60000+18h]
StosD
Mov EAX, [DS:60000+20h] ; C5Spd
StosD
Xor AX, AX
StosW
StosW
StosW
StosW
; Now for sample pointer.
Mov CL, 4
Mov AX, [DS:60000+0Eh]
Mov DL, [DS:60000+0Fh]
Mov DH, [DS:60000+0Dh]
ShL AX, CL
ShR DX, CL
StosW ; Sample pointer in file.
Mov AX, DX
StosW
Xor AX, AX ; Vibrato info
StosW
StosW
Ret
D_GetSampleInfo8: ; WAV Identification
Push SI
Push DI
Push DS
Push CS
Pop DS
Mov SI, Offset WAVEfmtID
Mov DI, 60008
Mov CX, 8
RepE CmpsB
JNE NotWAV
Add DI, 2
Mov CX, 4
RepE CmpsB
NotWAV:
Pop DS
JNE D_GetSampleInfo9
Mov BP, 60000+18h
Add BP, [DS:60000+10h]
Mov CX, 3 ; Only allow 3 blocks
CheckNextWAVE:
Cmp DWord Ptr [DS:BP-4], 'atad'
JE D_GetSampleWaveFound
Mov AX, [DS:BP]
Add AX, 8
Add BP, AX
JC D_GetSampleInfo9
Loop CheckNextWAVE
Jmp D_GetSampleInfo9
D_GetSampleWaveFound:
Mov DL, [DS:60000+22h] ; DL = number of bits.
Mov DH, 1
Cmp DL, 8
JE D_GetSampleInfo9
Mov DH, 3
Cmp DL, 16
D_GetSampleInfo9:
Pop DI
Pop SI
JNE D_GetSampleInfo2
; We have a WAV file!
Cmp Word Ptr [DS:60000+16h], 2
JNE D_GetSampleWAVStereo
Or DH, 4
D_GetSampleWAVStereo:
Mov AL, DH
And AL, 3
Add AL, 4
Mov Byte Ptr [BX+88], AL ; 5 = 8 bit, 7 = 16 bit.
Mov EAX, 'SPMI'
StosD
Mov SI, DI
Add DI, 13
Mov AL, 64
StosB ; Global vol = 64
Mov AL, DH
StosB ; Flag = sample.
Mov AL, 64
StosB ; Default vol = 64.
Mov CX, 13
D_GetSampleInfo10:
LodsB
And AL, AL
JZ D_GetSampleInfo11
StosB
Loop D_GetSampleInfo10
D_GetSampleInfo11:
Xor AX, AX
Add CX, 13
Rep StosB
Mov AL, DH
And AL, 4 ; stereo?
ShL AL, 3
Test DH, 2
JZ D_GetSampleInfo19
Inc AX
D_GetSampleInfo19:
StosW ; Sample format
Mov EAX, 4177910 ; Length
Cmp EAX, [DS:BP]
JB D_GetSampleInfo12
Mov EAX, [DS:BP]
D_GetSampleInfo12:
Test DH, 2
JZ D_GetSampleInfo18
ShR EAX, 1
D_GetSampleInfo18:
Test DH, 4
JZ D_GetSampleWAVStereo2
ShR EAX, 1
D_GetSampleWAVStereo2:
StosD
Xor AX, AX
StosW
StosW
StosW
StosW
Mov AX, [DS:60000+18h] ; Frequency
StosW
Xor AX, AX
Mov CX, 5
Rep StosW
Mov AX, BP
Add AX, 4-60000
; Mov AX, 2Ch
StosW
Xor AX, AX
StosW
StosW
StosW
Ret