# Sound and Graphics

In order to write a game using sound or graphics, you will first need a tool to create Blorb files, such as L. Ross Raszewski's iBlorb.

Once you have created your Blorb file and given it the same file name as your game, but with an extension of .blb, you are ready to use the sound and graphics resources in your game.

## Sound

In order to play a sound sample or a piece of music, the sound_effect opcode is used. As an example, the following routine (by Kevin Bracey) can be used to play sounds, with optional volume and repeat parameters:

      [ PlaySound number volume times;

         ! allow user to omit volume & times
         if (volume == 0) volume = 8;
         if (times == 0) times = 1;

         volume = volume + (times * 256);

         @sound_effect number 2 volume;
       ];

In the above number is the Blorb resource number of the sound; volume is the relative volume of the sound, between 1 and 8; and times is the number of times to play the sound, with 1 meaning play the sound once.

Windows Frotz 2002 can play at most one piece of music and one sound sample simultaneously. If the game attempts to play another piece of music (or sound sample), then the currently playing music (or sample) is stopped. Playing and stopping music does not affect sound samples, and vice versa. (As an aside, the restriction of only one piece of music or sound sample playing at once will be lifted when Version 1.1 of the Z-Machine Standard is ratified and implemented.)

Sound samples must be in the AIFF format. Music can be in the MOD format, or the related SONG format, in which the samples used in the music are stored as separate AIFF samples in the Blorb file.

For more information on the sound_effect opcode, see The Z-Machine Standards Document.

## Graphics

In order to draw a picture in a V6 game, the draw_picture opcode is used:

         @draw_picture number y x;

Where number is the Blorb resource number of the picture, and x and y are the co-ordinates to draw the picture at.

Pictures must be in JPEG or PNG format. If the picture is in the PNG format, transparency or alpha channel information is considered, so partially transparent or translucent pictures can be drawn.

For further details of how to use the V6 screen model, see Jason Penney's V6Lib.