OSDN Git Service

updated copyleft and need to test and fix newer version of open watcom
[proj16/16.git] / src / sountest.c
old mode 100644 (file)
new mode 100755 (executable)
index 8fd5b02..9c99e4a
@@ -1,5 +1,5 @@
 /* Project 16 Source Code~\r
- * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669\r
+ * Copyright (C) 2012-2022 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
  *\r
  * This file is part of Project 16.\r
  *\r
  * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
  * Fifth Floor, Boston, MA 02110-1301 USA.\r
  *\r
- */
-
-#include <stdio.h>
-
-#include "src/lib/16_in.h"
-//#include "src/lib/16_snd.h"
-#include "src/lib/doslib/adlib.h"
-#include "src/lib/doslib/8254.h"               /* 8254 timer */
-
-static unsigned int musical_scale[18] = {
-       0x1B0,                  /* E */
-       0x1CA,                  /* F */
-       0x1E5,                  /* f# */
-       0x202,                  /* G */
-       0x220,                  /* G# */
-       0x241,                  /* A */
-       0x263,                  /* A# */
-       0x287,                  /* B */
-       0x2AE,                  /* C */
-
-       0x2B0,                  /* E */
-       0x2CA,                  /* F */
-       0x2E5,                  /* f# */
-       0x302,                  /* G */
-       0x320,                  /* G# */
-       0x341,                  /* A */
-       0x363,                  /* A# */
-       0x387,                  /* B */
-       0x3AE,                  /* C */
-};
-
+ */\r
+\r
+#include <stdio.h>\r
+\r
+#include "src/lib/16_in.h"\r
+#include "src/lib/16_snd.h"\r
+//#include <hw/8254/8254.h>            /* 8254 timer */\r
+//#include <hw/adlib/adlib.h>\r
+\r
+static unsigned int musical_scale[18] = {\r
+       0x1B0,                  /* E */\r
+       0x1CA,                  /* F */\r
+       0x1E5,                  /* f# */\r
+       0x202,                  /* G */\r
+       0x220,                  /* G# */\r
+       0x241,                  /* A */\r
+       0x263,                  /* A# */\r
+       0x287,                  /* B */\r
+       0x2AE,                  /* C */\r
+\r
+       0x2B0,                  /* E */\r
+       0x2CA,                  /* F */\r
+       0x2E5,                  /* f# */\r
+       0x302,                  /* G */\r
+       0x320,                  /* G# */\r
+       0x341,                  /* A */\r
+       0x363,                  /* A# */\r
+       0x387,                  /* B */\r
+       0x3AE,                  /* C */\r
+};\r
+\r
 void main(int argc, char near *argv[])\r
-{
-       word i;
+{\r
+       static global_game_variables_t gvar;\r
+       word i;\r
+       boolean                 done;\r
+       ScanCode                scan;\r
 //     static FMInstrument testInst =\r
 //{\r
 //0x00, 0x01,  /* modulator frequency multiple... 0x20 */\r
@@ -60,77 +63,86 @@ void main(int argc, char near *argv[])
 //0x73, 0x73,  /* modulator sustain/release...    0x80 */\r
 //0x03, 0x00,  /* output waveform distortion      0xE0 */\r
 //0x36,                                /* feedback algorithm and strength 0xC0 */\r
-//};
-
-       IN_Startup();
-       //FMReset();
-       //FMSetVoice(0, &testInst);
-       if(!init_adlib())
-       {
-               printf("Cannot init library\n");
-               exit(-5);
-       }
-
-       if (adlib_fm_voices > 9)
-               printf("OPL3!\n");
-//             vga_bios_set_80x50_text();
-
-       memset(adlib_fm,0,sizeof(adlib_fm));
-       memset(&adlib_reg_bd,0,sizeof(adlib_reg_bd));
-       for (i=0;i < adlib_fm_voices;i++) {
-               struct adlib_fm_operator *f;
-               f = &adlib_fm[i].mod;
-               f->ch_a = f->ch_b = f->ch_c = f->ch_d = 1;
-               f = &adlib_fm[i].car;
-               f->ch_a = f->ch_b = f->ch_c = f->ch_d = 1;
-       }
-
-       for (i=0;i < /*adlib_fm_voices*/1;i++) {
-               struct adlib_fm_operator *f;
-
-               f = &adlib_fm[i].mod;
-               f->mod_multiple = 1;
-               f->total_level = 63 - 16;
-               f->attack_rate = 15;
-               f->decay_rate = 0;
-               f->sustain_level = 7;
-               f->release_rate = 7;
-               f->f_number = musical_scale[i%18];
-               f->octave = 4;
-               f->key_on = 0;
-
-               f = &adlib_fm[i].car;
-               f->mod_multiple = 1;
-               f->total_level = 63 - 16;
-               f->attack_rate = 15;
-               f->decay_rate = 0;
-               f->sustain_level = 7;
-               f->release_rate = 7;
-               f->f_number = 0;
-               f->octave = 0;
-               f->key_on = 0;
-       }
-
-       adlib_apply_all();
-
-       printf("press Z!  to noise\npress ESC to quit");
-       printf("p");
-       while(!IN_qb(1))
-       {
-               if(IN_qb(44))
-               {
-                       printf("e");
-                       adlib_fm[0].mod.key_on = 1;\r
-                       //FMKeyOn(0, 0x106, 4);
-               }
-               else
-               {
-                       adlib_fm[0].mod.key_on = 0;
-                       //FMKeyOff(0);
-               }
+//};\r
+\r
+       //FMReset();\r
+       //FMSetVoice(0, &testInst);\r
+       if(!init_adlib())\r
+       {\r
+               printf("Cannot init library\n");\r
+               exit(-1);\r
+       }\r
+       IN_Startup(&gvar);\r
+\r
+       if (adlib_fm_voices > 9)\r
+               printf("OPL3!\n");\r
+//             vga_bios_set_80x50_text();\r
+\r
+       memset(adlib_fm,0,sizeof(adlib_fm));\r
+       memset(&adlib_reg_bd,0,sizeof(adlib_reg_bd));\r
+       for (i=0;i < adlib_fm_voices;i++) {\r
+               struct adlib_fm_operator *f;\r
+               f = &adlib_fm[i].mod;\r
+               f->ch_a = f->ch_b = f->ch_c = f->ch_d = 1;\r
+               f = &adlib_fm[i].car;\r
+               f->ch_a = f->ch_b = f->ch_c = f->ch_d = 1;\r
+       }\r
+\r
+       for (i=0;i < /*adlib_fm_voices*/1;i++) {\r
+               struct adlib_fm_operator *f;\r
+\r
+               f = &adlib_fm[i].mod;\r
+               f->mod_multiple = 1;\r
+               f->total_level = 63 - 16;\r
+               f->attack_rate = 15;\r
+               f->decay_rate = 0;\r
+               f->sustain_level = 7;\r
+               f->release_rate = 7;\r
+               f->f_number = musical_scale[i%18];\r
+               f->octave = 4;\r
+               f->key_on = 0;\r
+\r
+               f = &adlib_fm[i].car;\r
+               f->mod_multiple = 1;\r
+               f->total_level = 63 - 16;\r
+               f->attack_rate = 15;\r
+               f->decay_rate = 0;\r
+               f->sustain_level = 7;\r
+               f->release_rate = 7;\r
+               f->f_number = 0;\r
+               f->octave = 0;\r
+               f->key_on = 0;\r
+       }\r
+\r
+       adlib_apply_all();\r
+\r
+       printf("press Z!  to noise\npress ESC to quit");\r
+       printf("\np");\r
+       for (done = false;!done;)\r
+       {\r
+               while (!(scan = gvar.in.inst->LastScan))\r
+               {}\r
+//                     SD_Poll();\r
+\r
+               IN_ClearKey(scan);\r
+               switch (scan)\r
+               {\r
+                       case sc_Escape:\r
+                               done = true;\r
+                       break;\r
+                       case sc_Z:\r
+                               adlib_fm[0].mod.key_on = 1;\r
+                               //FMKeyOn(0, 0x106, 4);\r
+                       break;\r
+                       default:\r
+                               adlib_fm[0].mod.key_on = 0;\r
+                               //FMKeyOff(0);\r
+                       break;\r
+               }\r
+               if(adlib_fm[0].mod.key_on) printf("e");\r
                adlib_update_groupA0(0,&adlib_fm[0]);\r
-       }
-       printf("!\n");
-       shutdown_adlib();
-       IN_Shutdown();
-}
+       }\r
+       printf("!\n");\r
+       shutdown_adlib();\r
+       IN_Shutdown(&gvar);\r
+}\r