X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Fsountest.c;h=321d06d54cdd216086e30b982794611dc1a5be3e;hb=6021fc3f27b895d382fbd30488ead35657e39196;hp=76ffeaecceca6ab9a6695904d7fec359c9f3e66a;hpb=e6992bf8486caf0f9cd45a8c751e7ee403fb8401;p=16.git diff --git a/src/sountest.c b/src/sountest.c old mode 100644 new mode 100755 index 76ffeaec..321d06d5 --- a/src/sountest.c +++ b/src/sountest.c @@ -1,5 +1,5 @@ /* Project 16 Source Code~ - * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669 + * Copyright (C) 2012-2018 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover * * This file is part of Project 16. * @@ -18,42 +18,131 @@ * write to the Free Software Foundation, Inc., 51 Franklin Street, * Fifth Floor, Boston, MA 02110-1301 USA. * - */ - -#include - -#include "src/lib/16_in.h" -#include "src/lib/16_snd.h" - + */ + +#include + +#include "src/lib/16_in.h" +#include "src/lib/16_snd.h" +//#include /* 8254 timer */ +//#include + +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 */ +}; + void main(int argc, char near *argv[]) -{ - static FMInstrument testInst = { -0x00, 0x01, /* modulator frequency multiple... 0x20 */ -0x00, 0x00, /* modulator frequency level... 0x40 */ -0xF0, 0xF0, /* modulator attack/decay... 0x60 */ -0x73, 0x73, /* modulator sustain/release... 0x80 */ -0x03, 0x00, /* output waveform distortion 0xE0 */ -0x36, /* feedback algorithm and strength 0xC0 */ -}; - - IN_Startup(); - FMReset(); - FMSetVoice(0, &testInst); - printf("press Z! to noise\npress ESC to quit"); - printf("p"); - while(!IN_qb(1)) - { - if(IN_qb(44)) - { - printf("e"); - FMKeyOn(0, 0x106, 4); - } - else - { - FMKeyOff(0); + static global_game_variables_t gvar; + word i; + boolean done; + ScanCode scan; +// static FMInstrument testInst = +//{ +//0x00, 0x01, /* modulator frequency multiple... 0x20 */ +//0x00, 0x00, /* modulator frequency level... 0x40 */ +//0xF0, 0xF0, /* modulator attack/decay... 0x60 */ +//0x73, 0x73, /* modulator sustain/release... 0x80 */ +//0x03, 0x00, /* output waveform distortion 0xE0 */ +//0x36, /* feedback algorithm and strength 0xC0 */ +//}; + + //FMReset(); + //FMSetVoice(0, &testInst); + if(!init_adlib()) + { + printf("Cannot init library\n"); + exit(-1); + } + IN_Startup(&gvar); + + 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("\np"); + for (done = false;!done;) + { + while (!(scan = gvar.in.inst->LastScan)) + {} +// SD_Poll(); + + IN_ClearKey(scan); + switch (scan) + { + case sc_Escape: + done = true; + break; + case sc_Z: + adlib_fm[0].mod.key_on = 1; + //FMKeyOn(0, 0x106, 4); + break; + default: + adlib_fm[0].mod.key_on = 0; + //FMKeyOff(0); + break; } - } - printf("!\n"); - IN_Shutdown(); -} \ No newline at end of file + if(adlib_fm[0].mod.key_on) printf("e"); + adlib_update_groupA0(0,&adlib_fm[0]); + } + printf("!\n"); + shutdown_adlib(); + IN_Shutdown(&gvar); +}