GUS Programmer's Digest Tue Aug 17 00:07 Volume 3: Issue 4 Today's Topics: GUS Programmer's Digest V3 #3 Removing UltraStopVoice from IRQ handler. Standard Info: - Meta-info about the GUS can be found at the end of the Digest. - Before you ask a question, please READ THE FAQ. ---------------------------------------------------------------------- Date: Mon, 16 Aug 93 10:53:36 PDT From: dedmunds@sfu.ca Subject: Re: GUS Programmer's Digest V3 #3 Message-ID: <9308161753.AA23567@beaufort.sfu.ca> I'm programming a DOS based game in mode 13h and I'd like to add GUS support. For adding basic music, is there a simple way of playing midi files as the game runs? If I want to work at such a high level (I'm a programming team of 1 which means I can't spend a tremendous amount of time on this), should I be looking at 3rd party drivers? Once you have sound effects loaded into the GUS ram, is it as simple as a single function call or interrupt to generate the sound? I.e. is the hard work constructing your sound effect and loading it onto the card? Darran Edmundson dedmunds@sfu.ca ------------------------------ Date: Mon, 16 Aug 93 13:45:35 EST From: devel@fortech.com (UltraSound Developer Support) Subject: Removing UltraStopVoice from IRQ handler. Message-ID: <9308161345.0.UUL1.3#16204@fortech.com> > From: Robert Bielik > Just read the SDK-DIG. Vol-2 #17 about Wave IRQ handling. > Wouldn't it be better to skip the UltraStopVoice() in irq.c and point > out to the programmer to put it in his/hers own wave-handler if > he/she thinks it's necessary ? There is a better way to solve this problem. An UltraStopVoice() MUSt be called if yo are supposed to get and IRQ and the voice is then supposed to stop (not loop or rollover...). If the stop is not done, you will get constant irqs and hang the machine. It would be better to check to see if looping is on or if its supposed to rollover and not do the stop. I have already fixed this problem in the new code, but have not released it yet. Here is the pertinient section of irq.c that should be replaced. ========================================================================== static void handle_voice() { unsigned char irq_source; unsigned int voice; unsigned long wave_ignore; unsigned long volume_ignore; unsigned long voice_bit; unsigned char temp1; unsigned char temp2; /* clear the ignore flags. These flags are needed because we get lots of */ /* 'double' interrupts. This will only allow one interrupt per voice */ wave_ignore = 0L; volume_ignore = 0L; /* The GF1 has a fifo (sort of) of all pending wave table irq's. You */ /* should stay here & service ALL pending waveform IRQ's before returning. */ while (TRUE) { PUSH_IRQ_STATE (); outportb(_gf1_data.reg_select,GET_IRQV); irq_source = inportb(_gf1_data.data_hi); POP_IRQ_STATE (); voice = irq_source & 0x1F; /* pick off the voice # */ irq_source &= (VOICE_VOLUME_IRQ | VOICE_WAVE_IRQ);/* isolate the irq bits */ if (irq_source == (VOICE_VOLUME_IRQ | VOICE_WAVE_IRQ))/* negative logic */ { break; /* No pending irqs left ... */ } voice_bit = 1 << voice; /* See if any waveform irqs first */ if (!(irq_source & VOICE_WAVE_IRQ)) { /* See if we have already serviced this voice ... */ if (!(wave_ignore & voice_bit)) { outportb(_gf1_data.voice_select,voice); outportb(_gf1_data.reg_select,GET_CONTROL); temp1 = inportb (_gf1_data.data_hi); outportb(_gf1_data.reg_select,GET_VOLUME_CONTROL); temp2 = inportb (_gf1_data.data_hi); /* If EITHER looping is on OR ROLLOVER is on, don't stop voice */ if (!((temp1 & VC_LOOP_ENABLE) || (temp2 & VC_ROLLOVER))) { UltraStopVoice(voice); wave_ignore |= voice_bit; } /* Call waveform processing function.... */ _gf1_data.wavetable_func(voice); } } if (!(irq_source & VOICE_VOLUME_IRQ)) { if (!(volume_ignore & voice_bit)) { outportb(_gf1_data.voice_select,voice); outportb(_gf1_data.reg_select,GET_VOLUME_CONTROL); temp1 = inportb (_gf1_data.data_hi); /* If volume looping is enabled, don't stop it */ if (!(temp1 & VL_LOOP_ENABLE)) { UltraStopVolume(voice); volume_ignore |= voice_bit; } /* Call envelope processing function.... */ _gf1_data.volume_func(voice); } } } } =========================================================================== If anybody has problems getting this to work, post a message here and I'll see what I can do. Forte Developer Support ------------------------------ End of GUS Programmer's Digest V3 #4 ************************************ To post to tomorrow's digest: To (un)subscribe or get help: To contact a human (last resort): FTP sites: archive.epas.utoronto.ca pub/pc/ultrasound wuarchive.wustl.edu systems/msdos/ultrasound Hints: - Get the FAQ from the FTP sites or the request server. - Mail to for info about other GUS related mailing lists (UNIX, OS/2, GUS-MIDI, etc.)