[net.micro.mac] Possible bug in megamax C

gwe@cbdkc1.UUCP ( George Erhart x4021 CB 3D288 WDS ) (11/03/85)

[ here little buggie ... <crunch> ]

I was playing with the macintalk speech stuff this weekend and discovered
a bug in the megamax C implementations of SetSoundVol() and GetSoundVol().
(This was using version 2.1b!) I don't have the sources for syslib, however
I attempted to crank the volume before starting the speech. A call to 
SetSoundVol(7) resulted in no change. So i disassembled the library file
sound.o and took a look. What I found did not make a lot of sense compared
to what IM said. So, I wrote two replacement routines SetSoundLevel() and
GetSoundLevel(), and they work. So here they are:


#include <os.h>

int
getsoundlevel()
{
	syspptr stuff;
	int retval;
	
	stuff = getsyspptr();
	retval = stuff->volclik & 0x0700;
	return(retval>>8 );
}

setsoundlevel(level)
int level;
{
	syspptr stuff;
	int current,ret;
	
	stuff = getsyspptr();
	current = stuff->volclik;
	current = current & 0xf8ff;
	level =  ((level&7)<<8);
	stuff->volclik = current | level;
	ret = writeparam();
}

-- 
George Erhart at AT&T Bell Laboratories Columbus, Ohio 
614-860-4021 {ihnp4,cbosgd}!cbdkc1!gwe