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)
_______________________________