Re: [Inform] Sound


1 Dec 1995 10:53:44 -0000

In article <19951127.172021.41@arnod.arnod.demon.co.uk> jools@arnod.demon.co.uk (Julian Arnold) writes:

>The SZM 0.2 says,
> In Version 5 and later, a game should have bit 7 of `Flags 2' set in its
> story file if it wants to use sound effects. The interpreter should then
> clear this bit if it cannot oblige.
>
>Just when, and indeed how, should I set this bit? Do I do something like
>`0->16=0->16 & 7;' in the Initialise routine? Or is that totally wrong?
>

I believe Inform does not have the capability of setting header bits. Indeed,
if you look at the "Header.inf" program supplied with SZM 0.2, you have
to set the bits manually. Zip 2000 doesn't mind whether the bit is set or
not, so just leave it during development, but when you make a release
version, load the compiled version into a byte-editor and set the bit
yourself.

BTW, I think you mean (0->16=0->16 | 128), but that won't work as the interpreter
will deal with the header bits the moment the game is loaded, before the
Initialise routine is called.

When the time comes to make a sound, you can do something like

if (0->16 & 128) { PlaySound(4); }

checking whether the interpreter has cleared the bit.

>Also, when should I "finish with" a sound? Just after starting it, or does
>this stop it immediately? Should I instead finish with it at a point where I
>know for certain it has stopped "naturally"?
>

"Finishing" it will stop it and throw it out of memory. The two Infocom
games don't seem to use this, probably because the loading time for a sample
from floppy (on the Amiga) is so long, so it's best to keep the last sample
in memory just in case. They only seem to use it on a restart or quit.
(Maybe a few other places). Finish with a sound when you're certain it's
finished, if you feel it's worthwhile.

There's no need to "Prepare" a sound either. But you can do so if you don't
want a loading delay the first time you actually play it.

>Should I `@sound_effect 1 #r$Routine;' or `@sound_effect 1 0 0 #r$Routine;'?

You're asking this because of the recent @read_char confusion, aren't you?
This confusion arises because Inform does not actually mark the parameters
to an opcode as input or output.

@read_char 1 key;

means call read_char with 1 parameter (namely 1), and put the result in key;

@read_char 1 0 0 key;

means call read_char with 3 parameters (1,0,0), and put the result in key.

However,

@sound_effect 1 0 0 #r$Routine;

means call sound_effect with 4 parameters (1,0,0,#r$Routine). It has no result.

That's a nonsense command, anyway; I would suggest you mean

@sound_effect 3 2 $0108 #r$Routine;

which means play sound effect 3 once at volume 8, calling Routine when finished.

Kevin
=====