OSDN Git Service

polished 16_vrs.h and put into make file AND! updated copyright to add yakui lover...
[proj16/16.git] / src / sountest.c
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
3  *\r
4  * This file is part of Project 16.\r
5  *\r
6  * Project 16 is free software; you can redistribute it and/or modify\r
7  * it under the terms of the GNU General Public License as published by\r
8  * the Free Software Foundation; either version 3 of the License, or\r
9  * (at your option) any later version.\r
10  *\r
11  * Project 16 is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  *\r
16  * You should have received a copy of the GNU General Public License\r
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
19  * Fifth Floor, Boston, MA 02110-1301 USA.\r
20  *\r
21  */\r
22 \r
23 #include <stdio.h>\r
24 \r
25 #include "src/lib/16_in.h"\r
26 //#include "src/lib/16_snd.h"\r
27 #include "src/lib/doslib/adlib.h"\r
28 #include "src/lib/doslib/8254.h"                /* 8254 timer */\r
29 \r
30 static unsigned int musical_scale[18] = {\r
31         0x1B0,                  /* E */\r
32         0x1CA,                  /* F */\r
33         0x1E5,                  /* f# */\r
34         0x202,                  /* G */\r
35         0x220,                  /* G# */\r
36         0x241,                  /* A */\r
37         0x263,                  /* A# */\r
38         0x287,                  /* B */\r
39         0x2AE,                  /* C */\r
40 \r
41         0x2B0,                  /* E */\r
42         0x2CA,                  /* F */\r
43         0x2E5,                  /* f# */\r
44         0x302,                  /* G */\r
45         0x320,                  /* G# */\r
46         0x341,                  /* A */\r
47         0x363,                  /* A# */\r
48         0x387,                  /* B */\r
49         0x3AE,                  /* C */\r
50 };\r
51 \r
52 void main(int argc, char near *argv[])\r
53 {\r
54         word i;\r
55 //      static FMInstrument testInst =\r
56 //{\r
57 //0x00, 0x01,   /* modulator frequency multiple... 0x20 */\r
58 //0x00, 0x00,   /* modulator frequency level...    0x40 */\r
59 //0xF0, 0xF0,   /* modulator attack/decay...       0x60 */\r
60 //0x73, 0x73,   /* modulator sustain/release...    0x80 */\r
61 //0x03, 0x00,   /* output waveform distortion      0xE0 */\r
62 //0x36,                         /* feedback algorithm and strength 0xC0 */\r
63 //};\r
64 \r
65         IN_Startup();\r
66         //FMReset();\r
67         //FMSetVoice(0, &testInst);\r
68         if(!init_adlib())\r
69         {\r
70                 printf("Cannot init library\n");\r
71                 exit(-5);\r
72         }\r
73 \r
74         if (adlib_fm_voices > 9)\r
75                 printf("OPL3!\n");\r
76 //              vga_bios_set_80x50_text();\r
77 \r
78         memset(adlib_fm,0,sizeof(adlib_fm));\r
79         memset(&adlib_reg_bd,0,sizeof(adlib_reg_bd));\r
80         for (i=0;i < adlib_fm_voices;i++) {\r
81                 struct adlib_fm_operator *f;\r
82                 f = &adlib_fm[i].mod;\r
83                 f->ch_a = f->ch_b = f->ch_c = f->ch_d = 1;\r
84                 f = &adlib_fm[i].car;\r
85                 f->ch_a = f->ch_b = f->ch_c = f->ch_d = 1;\r
86         }\r
87 \r
88         for (i=0;i < /*adlib_fm_voices*/1;i++) {\r
89                 struct adlib_fm_operator *f;\r
90 \r
91                 f = &adlib_fm[i].mod;\r
92                 f->mod_multiple = 1;\r
93                 f->total_level = 63 - 16;\r
94                 f->attack_rate = 15;\r
95                 f->decay_rate = 0;\r
96                 f->sustain_level = 7;\r
97                 f->release_rate = 7;\r
98                 f->f_number = musical_scale[i%18];\r
99                 f->octave = 4;\r
100                 f->key_on = 0;\r
101 \r
102                 f = &adlib_fm[i].car;\r
103                 f->mod_multiple = 1;\r
104                 f->total_level = 63 - 16;\r
105                 f->attack_rate = 15;\r
106                 f->decay_rate = 0;\r
107                 f->sustain_level = 7;\r
108                 f->release_rate = 7;\r
109                 f->f_number = 0;\r
110                 f->octave = 0;\r
111                 f->key_on = 0;\r
112         }\r
113 \r
114         adlib_apply_all();\r
115 \r
116         printf("press Z!  to noise\npress ESC to quit");\r
117         printf("p");\r
118         while(!IN_qb(1))\r
119         {\r
120                 if(IN_qb(44))\r
121                 {\r
122                         printf("e");\r
123                         adlib_fm[0].mod.key_on = 1;\r
124                         //FMKeyOn(0, 0x106, 4);\r
125                 }\r
126                 else\r
127                 {\r
128                         adlib_fm[0].mod.key_on = 0;\r
129                         //FMKeyOff(0);\r
130                 }\r
131                 adlib_update_groupA0(0,&adlib_fm[0]);\r
132         }\r
133         printf("!\n");\r
134         shutdown_adlib();\r
135         IN_Shutdown();\r
136 }\r