ZX Format #06
29 июля 1997

Programmers - General Sound: Programming Guide.

<b>Programmers</b> - General Sound: Programming Guide.
Programming Guide

            General Sound.

 Version 1.03.

music by Jaan
(C) Stinger
_______________________________



 1. Brief technical characteristics of the GS

Processor: Z80, 12MHz, no wait states
ROM: 32k, 27256
RAM: static ram 128k total,

             112k for modules and samples

            in base version
INT: 37. 5 KHz
, Channels: 4 Independent 8 bit channels,

             each with 6 bit Volume Cntrl

 2. Brief description of GS

 GS - musical card, designed to play music modules
 and individual samples (effects).
 Modules for the GS - it is the standard Amiga
PCshnye and 4-channel MOD files, and samples - as Amiga signed 
sample, and PCshnye unsigned sample.

 MOD player file in GS is
practically a complete analog ProTracker'a
on the Amiga was created with intensive use of sources 
ProTracker'a. 

 MOD Player Pro supports all the teams
Tracker'a, except for two things:

 E01 Filter On Amiga-specific commands
                 yes, includes a filter high
                 frequency range in which the GS

                 does not need.
, EFX Invert Loop I have not seen the player,

                 who would have this team

                 supported by.Vozmozhno,

                 it is supported by

                 some old playoff
                 tures.

 GS represents himself, in essence, a complex microprocessor 
with its own CPU, ROM, RAM, and ports, and absolutely no 
depends on the main processor Spectrum, that allows, for 
example, upload your own favorite module, reset the Spectrum, 
download the assembler and create your favorite music. Soft 
inside the GS is fully takes a problem playing sound, the 
interpretation module, etc., and programming GS'a reduces the 
transmission of byte by byte module and / or samples, and then 
required only give commands like: start

module, set the global volume
playback module, run the sample # 09
in the channel # 02, etc.

 If you intend to load the module
together with the samples, make sure you first need to download 
the module, and then samples.


 When you load the module is highly recommended
left free to 2k of memory, ie, load modules with a maximum 
length 110K. This condition is not necessary, but it

performance is very desirable for compatibility with 
poseduyuschimi versions. 

 Similarly, highly recommended to leave
80 bytes for each sample, for example
If you want to download 63-Kbyte
module and 18 samples, we have:

 Total_Sample_Length = 112 * 1024-63 * 1024-2 * 1024-18 * 80 = 
46688 bytes  - Total length of the samples.


 If, for example, is required to compute
as will fit in memory GS'a 2 KB sample, it is calculated
as follows:

N = 112 * 1024 / (2048 +80) = 53 sample.

 In GS'e have 4 physical channels, which are losing the sound. 
Channels 0 and 1 - left, and 2 and 3 - Right.


 3. Interface with Spectrum

GS looks at the world with 4 registers:

 1. Command register - register command

  writable port at 187

  In this register is written commands.

 2. Status register - status register,

  readable port at 187
Register bits:

   7 - Data bit, flag data

   6 - Undefined

   5 - Undefined

   4 - Undefined

   3 - Undefined

   2 - Undefined

   1 - Undefined

   0 - Command bit, flag teams
 This register allows to define the state of GS, in particular 
whether it is possible to read or write the next byte of data, 
or  apply another command, etc.


 3. Data register - data register, dos
  orally available to record the port at 179

  In this case the Spectrum writes data
  nye, for instance, this may be the arguments
  you command.

 4. Output register - register output dos
  orally available for reading at port 179

  From this register reads the Spectrum

  data coming from the GS.

 Command bit in the status register is set by hardware after 
writing the command into the instruction register. Reset to 0, 
he can only be of GS, which signals the

certain stage of execution.

 Data bit in the register states can be
set or reset as optional
Spectrum and optional GS:
When recording in the Spectrum data register it
hardware is set to 1, and after
read GS'om from this register is reset to 0.
When recording a GS in the output register it (all
The same Data bit) is set by hardware to 1, and after reading 
from this port Spectrum cleared by hardware to 0.


Despite the fact that the data register and output register are 
located in space port addresses to the same address and work on 
the same bit data, they are two independent

registers. Value, once recorded
in one of these registers, it remains unchanged until a new 
record. 

Status bits of data are often undefined, and if the 
specification of commands not the values ​​of this bit on 
opredennyh stages of command execution is unacceptable to make 
any assumptions about the value of this bit.


 4. The command system GS

 At first, let me digress from the actual system commands. GS, 
as is known, is primarily intended for

play modules and samples. In this
version (1. 03) GS ROM dopukaetsya download
one module and / or up to 32 samples.
 Each sample loading it into memory
gets a unique identifier
that uniquely identifies the call to
given samples of the teams, which require sample number. The 
first loaded sample receives a number (handle) = 1, the next - 
the number 2, etc.  The same applies to modules and

this one loaded module will have a handle = 1 after boot.
 A feature of this version is also something that must first 
download module, and then sampled.


 Features command descriptions:
Teams are described as follows:

 1. Hex command code
 2. Team Name

   3. Decimal code team
 4. Actions taken in the performance
Team
 5. Instruction format
 6. Comments to the team


  The command format is described as follows
 as follows:

GSCOM EQU 187
GSDAT EQU 179



SC # NN: Send a command code to the register

          teams

 LD A, # NN

          OUT (GSCOM), A

WC: Waiting for relief Command bit

IN A, (GSCOM)

          RRCA

          JR C, WCLP

SD Data: Send data to data register

 LD A, Data

          OUT (GSDAT), A

WD: Waiting for reset Data bit,

          in fact, waiting until GS is not

          will sent him the data

IN A, (GSCOM)

          RLCA

          JR C, WDLP

GD Data: Take the data from the register

          Data

 IN A, (GSDAT)

WN: Waiting for installation Data bit,

          in fact, waiting for the next
 Data from GS

IN A, (GSCOM)

          RLCA

          JR NC, WNLP



Command GS:

# 00 Reset flags (0)

  Resets the flags and Data bit
Command bit.

SC # 00
WC

(Data bit = 0, Command bit = 0)

# 0E Go in Covox mode (14)
Goes into Kovoks directly
copies the data register in the two DACs

  (Right and left) channels.
To exit this mode-entry # 00
into the instruction register.

SC # 0E
WC

SD
SD

  .. / It's conclusion in DACs
SD /

SC # 00
WC

# F3 Warm restart (243)
Resets all GS, but misses
stages of determining the number of pages
memory and their proveki, which greatly
accelerates the process of initialization.

SC # F3
WC

# F4 Cold restart (244)
Full restart of GS with all audits. In fact, JP # 0000

SC # F4
WC

# F5 Busy on (245)
Sets the busy flag in # FF

SC # F5
WC

# F6 Busy off (246)
Sets the busy flag in # 00

SC # F6
WC

Initially, Busy = # 00.
Performance of all teams in the GS performed in the main loop 
shell. This cycle in the conditional 

  form can be represented as:

1. if Command bit = 0 then goto 1
2. Execute Command
3. if Command bit = 1 then goto 2
 4. if Playing = 0 then go to a
5. if Busy = # ff then go to a
6. Process Sound
7. go to a

 Using the command Busy can, for example
initiate playback of samples in all
channels, then, say, change the play in the channels and then 
run it all the time. 

If they are not used, it is possible
this situation: the first is initiated
sample will be played, and only then initiated the second 
sample, etc. 

# 20 Get total RAM (32)
Get the total available memory
on the GS. (In the basic version is 112k)

SC # 20
WC

  GD RAM. L (low part)
WN

  GD RAM. M (middle part)
WN

  GD RAM. H (oldest part)

Total RAM = 65536 * RAM. H +256 * RAM. M + RAM. L

# 21 Get free RAM (33)

Get the total amount of free memory
on the GS.

SC # 20
WC

  GD RAM. L (low part)
WN

  GD RAM. M (middle part)
WN

  GD RAM. H (oldest part)

 Free RAM = 65536 * RAM. H +256 * RAM. M + RAM. L

# 23 Get number of RAM Pages (35)
Get the number of pages on the GS.

SC # 23
WC
GD Number_RAM_Pages

In the basic version of 3 pages.

# 2A Set Module Master Volume
Set the play volume
modules.

SD Module_Master_Volume [# 00 .. # 40]
SC # 2A
WC

   [GD Old_Master_Volume] - Old loudly.

# 2B Set FX Master Volume
Set the play volume
effects.

SD FX_Master_Volume [# 00 .. # 40]
SC # 2B
WC

   [GD Old_FX_Volume] - Old Volume

# 2E Set Current FX
Set the current effect. Just
CURFX assigns this value. If any team requires a number of 
samples (sample handle), then you can instead give her room

# 00 and Larry substitute
this zero value of the variable CURFX.

SD Cur_FX
SC # 2E
WC

# 30 Load Module
Module loading into memory.

SC # 30
WC

   [GD Module_Handle]-module number

   (Command bit = 0, Data bit = 0)
SC # D1 (Open Stream-open stream)
WC

SD
WD
... Bytes module
SD /
WD /

SC # D2 (Close Stream-close stream)
WC

# 31 Play module
Playback module.

SD Module_Handle - module number
SC # 31
WC

# 32 Stop module
Stop playback module.

SC # 32
WC

# 33 Continue module
Continue playing the module after
stop.

SC # 33
WC

# 35 Set module Global Volume
Set global volume of the module.

SD Module_Global_Volume [# 00 .. # 40]
SC # 35
WC

   [GD Old_Global_Volume] - Old loudly.

# 38 Load FX
Download sample effect in memory.
Loads unsigned samples
(PC type)

SC # 38
WC

   [GD FX_Handle]-number sample

   (Command bit = 0, Data bit = 0)
SC # D1 (Open Stream-open stream)
WC

SD
WD
.. Bytes sample
SD /
WD /

SC # D2 (Close Stream-close stream)
WC

When loading each sample in memory
GS is created for this sample header that describes the various
parameters of the sample. After downloading these
parameters are set to certain values, such as:
 Note = 1960, Volume = # 40, FineTune = 0,

  SeekFirst = # 0F, SeekLast = # 0F,
Priority = # 80, No Loop
and internal variable is set to CurFX FX_Handle.
Then the teams # 40, # 41, # 42, # 45, # 46 and
# 47 can these defaults
change on their own. This is required because the team # 39 to 
initiate play sample uses the settings from header sample.




# 39 Play FX
Playing effect.

SD FX_Handle - number of samples
SC # 39
WC

In the performance of this team is as follows: look channels 
specified in the parameters of our SeekFirst sample, and if 
at-least one of them free, and it played

sample, otherwise look
channels specified in SeekLast and if
One of them is free, and it played a sample, if not free, then
looked through all the channels listed
SeekLast, one channel is selected with
lowest priority and compared
with a priority of our sample (there
sample mean, we want to lose) if this sample will be a higher 
priority than the sample, already playing in the channel, then 
playing in a channel sample to be stopped, and our sample will 
be launched in this channel instead of the old sample. Here 
such here priority scheme ...


When the sample is run in a channel, then
his note, volume, etc. The parameters
recorded in the data channel
sample from the title.

In general, something to lose
sample with the desired parameters, you can set these options 
after Download sample and safely use

command # 39.
If the parameters have changed, it is
can proceed as follows:
Team # 2E do you want the current sample, the teams change his 
# 4x options, and then run it

Team # 39.

An alternative method of triggering samples
provide team # 80 .. # 9F, when
execution of these commands you right in the instruction code 
indicates in which channel You need to run a sample, and 
furthermore but you can also specify with which the note and / 
or volume required run the sample.


# 3A Stop FX in channels
ostanovka effects play a preset channels, which are specified in
mask channel (Channel Mask).
In her unit in the n-dimensional bit indicates
that the effect of n-dimensional channel you want to stop

SD Channel_Mask
SC # 3A
WC

# 3D Set FX Global Volume
Set global volume effects.

SD FX_Global_Volume [# 00 .. # 40]
SC # 3d
WC

   [GD Old_Global_Volume] - Old loudly.

# 3E Load FX (Extended version)
Download sample effect in memory.
Allows you to load samples with a sign.
(Amiga type)

SD # 01 (Signed sample)
SC # 3E
WC

   [GD FX_Handle]-number sample

   (Command bit = 0, Data bit = 0)
SC # D1 (Open Stream-open stream)
WC

SD
WD
.. Bytes sample
SD /
WD /

SC # D2 (Close Stream-close stream)
WC

# 40 Set FX Sample Playing Note
Installation notes default
current effect.

SD Note [0 .. 95]
SC # 40
WC

Note:

 0 C-0
 1 C # 0
12 C-1
24 C-2
36 C-3 (C-1 in the Amiga)
48 C-4 (C-2 in the Amiga)
60 C-5 (C-3 in the Amiga)
72 C-6
84 C-7

In this version of the Sound Generators Wave 2,
3 may play an octave 3, 4 and 5,
therefore valid values
Note the range is from 36 to 71.

41 Set FX Sample Volume
Setting the default volume for
current effect.



SD FX_Volume [# 00 .. # 40]
SC # 41
WC

# 42 Set FX Sample Finetune
Finetune for the installation
current effect.



SD FX_Finetune [# 00 .. # 40]
SC # 42
WC

# 45 Set FX Sample Priority
Set a priority for
current effect.



SD FX_Priority [# 01 .. # Fe]
SC # 45
WC

# 46 Set FX Sample Seek First parameter
Setting Seek First to
current effect.



SD FX_SeekFirst
SC # 46
WC

# 47 Set FX Sample Seek Last parameter
Setting Seek Last for
current effect.



SD FX_SeekLast
SC # 47
WC

# 60 Get Song Position
Getting the value of the variable
Song_Position in the current module.

SC # 60
WC

GD Song_Position [# 00 .. # FF]

Can be interpreted as the number of
lost pattern module. After
Start module takes the value 0 and
incremented after playing the next pattern.
This variable can be used
for synchronizing processes in
Spectrum with the playback module. For
This can, for example, at the beginning of procedures for 
handling interrupts do SC # 60, then follow the procedures

various operations on the screen, skrullinga lines, etc. (Ie, 
that was sufficient to meet the team

delay), and then read the value
Port 179 (GD Song_Position), and
compare it with the required and, if
equality, go to the next part
demos, ie if (Song_Position == My_Position) then goto 
Next_Part_Of_Demo 

# 61 Get Pattern Position
Getting the value of the variable
Pattern_Position in the current module.

SC # 61
WC
GD Pattern_Position [# 00 .. # 3F]

Get the value of the bias in the pattern
(No ROW), use similarly to the previous team, but want to note 
that this value is changed rather quickly, and therefore 

if (Pattern_Position> = My_Position)

  then goto Next_Part_Of_Demo

# 62 Get Mixed Position
Get the value Pattern_Position,
slightly mixed with Song_Position.

SC # 62
WC
GD Mixed_Position



Mixed_Position: (in bits)

7 - Song_Position. 1
6 - Song_Position. 0
5 - Pattern_Position. 5
4 - Pattern_Position. 4
3 - Pattern_Position. 3
2 - Pattern_Position. 2
1 - Pattern_Position. 1
0 - Pattern_Position. 0

ie if you get Mixed_Position and
to do with it AND # 3F we obtain
spitting Pattern_Position, and if after receiving his little 
RLCA, RLCA, AND # 02 - it will be two junior

Bit Song_Position. See notes to
teams # 60 and # 61.



# 63 Get Channel Notes
Get the notes of all the channels of the module.

SC # 63
WC
GD Note_of_channel_0
WN
GD Note_of_channel_1
WN
GD Note_of_channel_2
WN
GD Note_of_channel_3

If in any channel value of the notes has changed since the last 
execution Team # 63 then bit 7 is obtained zanacheniya 
Note_of_channel_N will be at zero, and if this value is the 
same, and that was before, then this bit will be

in the unit. Younger seven bits and is
proper note from 0 to 95, and if it
value is 127, it means
that no samples in the channel does not play.
This command is mainly intended to build on its basis the 
various analyzers. 

# 64 Get Channel Volumes
Get the volume of all channels
module.

SC # 64
WC
GD Volume_of_channel_0
WN
GD Volume_of_channel_1
WN
GD Volume_of_channel_2
WN
GD Volume_of_channel_3

See the description of the command # 63

# 80 Direct Play FX Sample (# 80 .. # 83)
Playing the sample in a given channel.

SD Sample_Number
SC # 80 .. # 83 (Junior bits determine

                 neposredstvennonomer

                 channel, which requires

                 is to play a sample)
WC

# 88 Direct Play FX Sample (# 88 .. # 8B)
Playing the sample in a given channel with a given note.

SD Sample_Number
SC # 88 .. # 8B (lower bits define

                 neposredstvennonomer

                 channel, which requires

                 is to play a sample)
WC
SD Note [0 .. 95]
WD

# 90 Direct Play FX Sample (# 90 .. # 93)
Playing the sample in a given channel with a given volume.

SD Sample_Number
SC # 90 .. # 93 (Junior bits determine

                 neposredstvennonomer

                 channel, which requires

                 is to play a sample)
WC
SD Volume [# 00 .. # 40]
WD

# 98 Direct Play FX Sample (# 98 .. # 9B)
Playing the sample in a given channel with a given note and 
volume. 

SD Sample_Number
SC # 88 .. # 8B (lower bits define

                 neposredstvennonomer

                 channel, which requires
                 is to play a sample)
WC
SD Note [0 .. 95]
WD
SD Volume [# 00 .. # 40]
WD

 5. A bit of lyrics ...


   Authors GS: (2 pieces;)


   Glory Dangerous

           (X-Trade)

 He originated the idea of ​​creating GS'a, hardware 
implementation of it, some of suggestions regarding Soft'a GS'a 
and Amiga 1200 on which I have made

all sorts of experiments. On-edinstenny and
unique manufacturer General Sound'a and that he manages the 
production and sale of GS.



            Stinger

 It's me, the author of this opus, and in concurrent heart and 
soul of General Sound'a. I I am a developer of embedded

Soft'a in GS'e and guess to continue doing this act. (Yes, I am 
also the author of some clever bells and whistles in Hardware 
GS'a, and would be author yet many, if not all the time

restrain Slava constantly preoccupied
problem of a reduced price. )

 After writing about 20 kb code for half-year
prizanatsya, I'm a little tired, but I have pretty big plans 
for the next version GS'a, such as: 

 - Wave 4 Sound Generators reproducing
   ing all the octaves.
 - Acceleration due to interest on the add

   30-40 of sound generation.
 - I'd love to play STM'ov

   from the PC.
 - The advanced system commands.
 - Different effects on samples
 - Storing patterns in zakompressovan
   dimensional form (there is about 15% of
   initial volume).
 - And more

 All software should run on later versions of the firmware
if it is written in accordance with my
the above wishes and requirements. Besides these commands in 
GS'e there are plenty of teams that are not documented, and I 
leave behind the right to modify them any way you like and only 
the documentation teams accept the legitimate claims type: "The 
documentation is written in such a way as to firmware is 
working on another ... " 

 I'm planning a significant expansion of the system commands, 
and will be glad to design (Preferably concrete) proposals.


So what if you voiced toy or
write the music editor for the GS and discover that you are 
lacking any team, then call me and offer suggestions. (Phone, I 
think easily learn not be;)


Sanx 4 moral support:
Dima (X-Trade)
 SParker (XLD)

_______________________________




Other articles:

Today in the room - the contents of the magazine.

Authors - The authors of the journal ZX-Format No.6

From the authors - the long awaited event finally happened ...

Toys - The last iron (short story on the game 48 irons).

Toys - Many Adventures of Winnie the Pooh. Part Two.

Toys - the game description The Crypt (Castle Master 2).

Toys - description editor Adeventyur - PAW (Part 1).

Toys - description editor Adeventyur - PAW (Part 2).

Toys - description editor Adeventyur - PAW (Part 3).

Toys - description editor Adeventyur - PAW (part 4).

Toys - description editor Adeventyur - PAW (Part 5).

Programmers - Beta Basic: continued talking about BASIC (Part 2).

Programmers - General Sound: Programming Guide.

Programmers - MMD - the driver. Description of the structure of the modem driver for the terminal program MMD.

Programmers - AI on B. Mednonogova. A detailed description of the "wave of the algorithm" trace (automatic calculation of optimal) path, with an example implementation at Basic.

Programmers - Artificial Intelligence. Continuation of a series of articles about "AI". General basis for finding the way to goal.

Programmers - Tr-Dos for programmers. Max Petrov concludes his story about nontraditional methods of work with the disk.

Programmers - sharing experiences: "3-colour". Description of the effect of colors on 8-point ", help to the viewer, and how many words on the conversion of images in format "3-colour".

Programmers - sharing experiences: "3-colour". A few words about converting images in the format of RGB.

Programmers - the exchange of experience: programming Multicolor effects.

IS-DOS - users: how to personalize your system IS-DOS on a specific model of ZX Spectrum-compatible PC and to perform your tasks.

IS-DOS - users: how to copy the system disk IS-DOS and stay with the dead.

IS-DOS - the programmer: a short course - programming in IS-DOS.

IS-DOS - news: new software IS-DOS.

Iron - A short story about the capabilities of the processor Z-180.

Iron - Multiviewer. Description dorabotochki allowing to measure the speed of programs to curb without climbing in the codes - an easy push of a button.

Iron - A new project the firm Peters - "Sprinter". New Spectrum-compatible PC with a new generation of Speccy.

Iron - Opinions about skorpionovskom controller IDE HDD - SMUC.

Iron - SuperSpectrum: one project Spectrum-compatible machines. Its feature is compatible with the PC.

Iron - X-Trade FAQ. Answers to frequently asked questions on the GS and XTR-modem.

Premiere - Flash tracker. Description 4-channel editor of digital music, working with SoundDrive, from the author SoundDrive - Flash Inc.

Premiere - Description of the latest version of the universal terminal program used in SpbZxNet.

Premiere - Mortal Kombat: what awaits you in the full version of the game and some comments to the demo version.

Premiere - XReversy: presentation of a new toy from the popular family of "Solve puzzle - see the picture."

Interview - An interview with one of the most famous spektrumistov - Andrew Larchenko.

It was you - The story "Absolute Power".

It was you - The story "The Road".

It was you - Lord of the teeth: a parody of a popular trilogy ...

Mail - Contact us: an e-mail Alex'a from Nizhny Tagil, exhibited in the last room at the Corner of lamer. "

Mail - Letters from readers: Andrei Yakovlev, Denis Tokarchuk, Alex Garkulim, Alexander Gordeev, Evgenii Shumilov Nitochkin Vadim, Michael Larkin.

Mail - free advertising and announcements.

Miscellaneous - Scarecrow.: Nemo talks about the place of the PC and Spectrum in the modern Russia.

Miscellaneous - Review of Nemo in the book on digital circuitry. For anyone who has ever ever been tempted to turn on the soldering iron and ...

Miscellaneous - Questionnaire: Results of our poll spektrumistov.

Miscellaneous - Competition. A brief account of our contests.

Miscellaneous - The problems of the software market: when zagnetsya Spectrum. All over whether to blame hackers?

Miscellaneous - Outlook software. A brief overview of the forthcoming software: Fast Tracker, Pro Sound Creator, Black Crow.

Miscellaneous - Outlook software. Adventyura From Beyond or outside. "

Miscellaneous - A Memoir of the Peter modem network for ZX Spectrum - SPbZXNet.

Amiga Club - Between Us, by users: a comparison of characteristics of the Amiga 1200 with the IBM PC.

Amiga Club - compare the performance of Amigo and PC. As far as Amiga relevant in today's games?


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
BBS - list of stations BBS ZXNet.
Iron - Three schemes matching Modem Spectrum'om.
From the Author - He received a diploma ...
We will understand - A detailed report on the passing game Winnie the Pooh & 48 Iron.

В этот день...   21 November