diff options
author | Simon Howard | 2009-08-30 01:56:33 +0000 |
---|---|---|
committer | Simon Howard | 2009-08-30 01:56:33 +0000 |
commit | f6ce7dfea99cf32beb2afc8e7b02fb5f19f7544f (patch) | |
tree | 6d4106cd453c61b5dec49419bef6479ae4249b1d /src | |
parent | f2f36117c889c19b643058a0af33070baf4b48be (diff) | |
download | chocolate-doom-f6ce7dfea99cf32beb2afc8e7b02fb5f19f7544f.tar.gz chocolate-doom-f6ce7dfea99cf32beb2afc8e7b02fb5f19f7544f.tar.bz2 chocolate-doom-f6ce7dfea99cf32beb2afc8e7b02fb5f19f7544f.zip |
Make some noise.
Subversion-branch: /branches/opl-branch
Subversion-revision: 1640
Diffstat (limited to 'src')
-rw-r--r-- | src/i_oplmusic.c | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/src/i_oplmusic.c b/src/i_oplmusic.c index 0e1b69a3..2c0efa92 100644 --- a/src/i_oplmusic.c +++ b/src/i_oplmusic.c @@ -42,6 +42,8 @@ #include "opl.h" #include "midifile.h" +#define TEST + #define MAXMIDLENGTH (96 * 1024) #define GENMIDI_NUM_INSTRS 128 @@ -405,6 +407,30 @@ static void I_OPL_ShutdownMusic(void) } } +#ifdef TEST +static void TestCallback(void *arg) +{ + opl_voice_t *voice = arg; + int note; + int wait_time; + + // Set level: + WriteRegister(OPL_REGS_LEVEL + voice->op2, 0); + + // Note off: + + WriteRegister(OPL_REGS_FREQ_2 + voice->index, 0x00); + // Note on: + + note = (rand() % (0x2ae - 0x16b)) + 0x16b; + WriteRegister(OPL_REGS_FREQ_1 + voice->index, note & 0xff); + WriteRegister(OPL_REGS_FREQ_2 + voice->index, 0x30 + (note >> 8)); + + wait_time = (rand() % 700) + 50; + OPL_SetCallback(wait_time, TestCallback, arg); +} +#endif + // Initialise music subsystem static boolean I_OPL_InitMusic(void) @@ -443,17 +469,19 @@ static boolean I_OPL_InitMusic(void) #ifdef TEST { + int i; opl_voice_t *voice; + int instr_num; - voice = GetFreeVoice(); - SetVoiceInstrument(voice, &main_instrs[34].opl2_voice); + for (i=0; i<3; ++i) + { + voice = GetFreeVoice(); + instr_num = rand() % 100; - // Set level: - WriteRegister(OPL_REGS_LEVEL + voice->op2, 0x94); + SetVoiceInstrument(voice, &main_instrs[instr_num].opl2_voice); - // Note on: - WriteRegister(OPL_REGS_FREQ_1 + voice->index, 0x65); - WriteRegister(OPL_REGS_FREQ_2 + voice->index, 0x2b); + OPL_SetCallback(0, TestCallback, voice); + } } #endif |