-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpcmadlib.asm
147 lines (110 loc) · 1.91 KB
/
pcmadlib.asm
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
; Written by Leonardo Ono ([email protected])
; 11/05/2019
; Reference: http://www.dcee.net/Files/Programm/Sound/adldigi.arj
bits 16
org 100h
start:
mov ah, 0eh
mov al, 'A'
int 10h
call reset_all_registers
; bl = register
; bh = value
mov bl, 20h
mov bh, 21h
call write_adlib
mov bl, 60h
mov bh, 0f0h
call write_adlib
mov bl, 80h
mov bh, 0f0h
call write_adlib
mov bl, 0c0h
mov bh, 01h
call write_adlib
mov bl, 0e0h
mov bh, 0
call write_adlib
mov bl, 43h
mov bh, 3fh
call write_adlib
mov bl, 0b0h
mov bh, 1h
call write_adlib
mov bl, 0a0h
mov bh, 8fh
call write_adlib
mov bl, 0b0h
mov bh, 2eh
call write_adlib
mov cx, 40000 ; <-- change this value according to the speed of your computer
.delay3:
nop
loop .delay3
mov bl, 0b0h
mov bh, 20h
call write_adlib
mov bl, 0a0h
mov bh, 0h
call write_adlib
mov si, 0
.loop:
; send byte audio sample
mov bh, [sound_data + si]
mov bl, 255
sub bl, bh ; lowest value has the highest volume
mov bh, bl
shr bh, 2 ; convert to 6-bit sample
; bl = register
; bh = value
mov bl, 40h
; mov bh, -- -> bh already has the 6-bit sample
call write_adlib
mov cx, 10000 ; <-- change this value according to the speed of your computer
.delay:
nop
loop .delay
mov ah, 1
int 16h
jnz .exit
inc si
cmp si, 51529
jb .loop
.exit:
mov ax, 4c00h
int 21h
reset_all_registers:
mov bl, 0h
mov bh, 0
.next_register:
; bl = register
; bh = value
call write_adlib
inc bl
cmp bl, 0f5h
jbe .next_register
.end:
ret
; bl = register
; bh = value
write_adlib:
pusha
mov dx, 388h
mov al, bl
out dx, al
mov cx, 6
.delay_1:
in al, dx
loop .delay_1
mov dx, 389h
mov al, bh
out dx, al
mov dx, 388h
mov cx, 35
.delay_2:
in al, dx
loop .delay_2
popa
ret
sound_data:
incbin "kingsv.wav" ; 51.529 bytes