]> 4ch.mooo.com Git - 16.git/blob - src/lib/16_snd.c
started the porting of the adlib tracker playback system
[16.git] / src / lib / 16_snd.c
1 /* Project 16 Source Code~
2  * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
3  *
4  * This file is part of Project 16.
5  *
6  * Project 16 is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Project 16 is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or
19  * write to the Free Software Foundation, Inc., 51 Franklin Street,
20  * Fifth Floor, Boston, MA 02110-1301 USA.
21  *
22  */
23
24 #include "src/lib/16_snd.h"
25
26 void opl2out(word data, word reg)
27 {\r
28         __asm
29         {\r
30                 mov     ax,reg\r
31                 mov     dx,word ptr [OPLPORT]\r
32                 or      ah,ah\r
33                 jz      @@1\r
34                 add     dx,2\r
35 @@1:    out     dx,al\r
36                 mov     cx,6\r
37 @@2:    in      al,dx\r
38                 loop    @@2\r
39                 inc     dl\r
40                 mov     ax,data\r
41                 out     dx,al\r
42                 dec     dl\r
43                 mov     cx,36\r
44 @@3:    in      al,dx\r
45                 loop    @@3\r
46         }
47 }\r
48 \r
49 void opl3out(word data, word reg)
50 {\r
51         __asm
52         {\r
53                 mov     ax,reg\r
54                 mov     dx,word ptr [OPLPORT]\r
55                 or      ah,ah\r
56                 jz      @@1\r
57                 add     dx,2\r
58 @@1:    out     dx,al\r
59                 inc     dl\r
60                 mov     ax,data\r
61                 out     dx,al\r
62                 dec     dl\r
63                 mov     cx,26\r
64 @@2:    in      al,dx\r
65                 loop    @@2\r
66         }
67 }\r
68 \r
69 void opl3exp(word data)
70 {\r
71         __asm
72         {\r
73                 mov     ax,data\r
74                 mov     dx,word ptr [OPLPORT]\r
75                 add     dx,2\r
76                 out     dx,al\r
77                 mov     cx,6\r
78 @@1:    in      al,dx\r
79                 loop    @@1\r
80                 inc     dl\r
81                 mov     al,ah\r
82                 out     dx,al\r
83                 mov     cx,36\r
84 @@2:    in      al,dx\r
85                 loop    @@2
86         }\r
87 }