General Sound AY Emulator v1.0
(C) Dr.Lion / RSM
Presented below is the copyright of software product domain!
When using it, refer to the author!
This software product is an emulator m / AY-3-8910 by
soundcard General Sound 1.04 (GS). ROM version of GS has
value, since it is only used when loading the internal
Code Emulator AY. In what emulator works directly with the
hardware "GS.
Because with the fact that the performance characteristics of
GS is modest for full-function emulation AY, it was decided to
implement a minimum capacity AY, allows you to play on an
emulator by any standard music player, pre peredelanym under
the exchange of data with the emulator AY.
Below shows the features of the emulator AY:
1.Obmen data
The format of data transmitted to the emulator is in the
format AY,
t.e.suschestvuet port of registry (# BB), which is recorded
but measures selected register and a data port (# B3), which
is written are described by data transmitted to the register.
But unlike the real Nogo AY, emulator can not be instantly
sent to take
his data, since these data have to read almost half
completely loaded generation audio processor GS. Therefore,
for pis data in the register of the emulator is as follows:
....
LD A, register; register number for writing
OUT (# BB), A
LD A, data; data to be written
OUT (# B3), A
CALL WaitDat
....
WaitDat IN A, (# BB); waiting for the emulator to read
RLCA; Slany his data
JR C, WaitDat
RET
Just the emulator does not allow reading from his Regis
ters. The implementation of such a possibility would not be
justified inhibited
the overall speed of data exchange between the ZX and the
emulator AY.
2.Chastota sampling
It is 12500Hz, and allows you to play tones
frequencies in the range 6076,39-26,71 Hz, which corresponds
to the coefficient coefficient of division from 18 to 4095.
6076,39 Hz frequencies above transformation zovyvayutsya in
the frequency of 6076,39 Hz. The range of noise frequencies
goraz to have, because Decimal Coefficient of division for
the frequency noise
is 5 bits (but it's standard AY).
3.Razryadnost and assignment of bits of registers
It remained unchanged except for the registers R12 and
R13. Register R12 may contain numbers from 0 to 3. If the
number of
more than 3, it is converted to 3. Thus chestota ogi
envelope can not be below 6,68 Hz. On the other hand, the
coefficient cient division for the frequency of the envelope
can not be less than 5. R13
can take the values 8, A, C, E, or any other value,
which after conversion will still receive one of four
specified above.
4.Generatory tones, noise, the envelope
They are built on a 24-bit counters, scaling-share
fields in an exemplary way:
.... ; Tone channel A
A_NumA LD HL, 0; lower 16 bits of accumulation
A_SetA LD DE, 0; lower 16 bits of the increment
ADD HL, DE
LD (A_NumA +1), HL; accumulation
A_NumB LD A, 0; older 8-bit accumulation
A_SetB ADC A, 0; older 8-bit increments
LD (A_NumB +1), A; accumulation
JR NC, B_NumA
LD A, C; change of half-wave
XOR% 00000001
LD C, A
B_NumB .... ; Tone channel B
Masshtaboruyuschy ratio is calculated as follows:
K = (NumA +65536 * NumB) / (65536 * 256)
K = 0-0,99999994 accuracy up to 0,01 Hz
Frq = Fgsi * K where Fgsi = 12500Hz
Noise generator is strongly simplified and very far from the
real circuit
generetora noise AY. The situation is further aggravated by
low frequency quency sampling, which allows the use of
coefficients The coefficients for the frequency dividing the
noise only in the range of 18 to 31.
The implementation of the random bit sequence for n
oscillator noise and the mixer:
....
LD (N_NumB +1), A; accumulation
JR NC, Mixer
LD A, R; calculation of pseudo-random
RRCA; bit
LD R, A
JR NC, Mixer
LD A, C; change of half-wave for
XOR% 00111000; all channels
LD C, A
Mixer LD A, C; half-mask bits
MixVal OR 0; bits mixer
LD L, A; bit = 0 - active signal
....
5.Dopolnitelnye opportunities
In the emulator AY implemented two additional registers R14,
R15
perform some additional functions. Register R14 limit
dnaznachen to control the overall loudness of the sound
emulator and
can take values from 0 (minimum) to 15 (maximum). No results
recommends to set values greater than 15. Code volume
transformation razuetsya on exponential scale in the internal
volume of the spacecraft signals GS. Through R15 can specify
one of the 4 laws according to which ring calculated output
values DAC'ov channels GS.
6.DAC GS and channels AY
As is known, GS has four 8-bit channel A, B, C, D. For
Each channel can be set "hardware" volume 0-63. Ka
Nala A and B are merged into the left channel, and C and D -
to the right. Corresponding correspondence AY channels and
channels GS is in the following table:
AY Canal Canal Canal GS GS Volume
A A 100% (63 R14 = 15)
B B, C 50% (31 R14 = 15)
C D 100% (63 R14 = 15)
Register R15 allows you to select a scale of one volume of a
laws :0-linear, 1-square, 2-exponential, hyperbolic 3-
crystal. It should be noted that the exponential law is
Xia "native" to AY, so it is active by default. Square
Act was introduced as an analogue of the exponential law, but
it has
higher and the saturation of the output volume. Other Laws
are rather experimental.
The emulator is available as source code and installation
program. Source can be inserted into your program. The
installation program loads in the GS program and restarts the
emulator AY Speccy. She needs to work some have already adapted
to the emulator software, such as PT3 +69 by Alone Coder.
AY emulator can find very different to demonstrate how. For
example, the image do such a device, like Turbo Sound (two AY).
Already trying write under it 6-channel music editor. But, say,
emulators that support this device is less than emulators,
having in its arsenal, General Sound. Therefore, new program
under the 6-channel FM-sound can be adapted to the usual AY AY
and my emulator on GS. Generally, yuzayte as you allow your
imagination!
Finally give an example of adaptation under the PT3 +69
emulator AY:
- Sequence alterations PRO TRACKER 3.69 under GSAYemul -1. In
pt5_368.H find OUTAY procedure and replace it with:
OUTAY LD HL, frqA; GSAYemul!
LD BC, # 0D00; data transmission in the emulator
OUTAY0 LD A, C
OUT (# BB), A
LD A, (HL)
INC HL
OUT (# B3), A
CALL OUTAY1
INC C
DJNZ OUTAY0
LD A, C
OUT (# BB), A
LD A, (HL)
CP B
RET Z
OUT (# B3), A
LD (HL), 0
RET
OUTAY1 IN A, (# BB)
RLCA
JR C, OUTAY1
RET
2. In pt3D.H find IVOLQ procedure and replace it with:
IVOLQ LD (VOL), A; GSAYemul!
PUSH AF; global volume
LD DE, # 41A6; Editor
CALL PRF8
LD A, # 10
OUT (# BB), A
POP AF
OUT (# B3), A
RET
3. In PTconst.H find GETRG procedure and replace it with:
GETRG LD (ZZC), A; GSAYemul!
PUSH DE; analyzer channels
LD DE, frqA
PUSH HL
LD H, 0
ADD HL, DE
LD A, (HL)
POP HL
LD L, H
LD H, 0
ADD HL, DE
LD E, (HL)
INC HL
LD D, (HL)
LD L, E
CPL
AND # 0F
ADD A, 'SIN
LD H, A
LD A, D
BIT 3, A
CPL
JR Z, $ +3
XOR A
AND 7
POP DE
RET
4. In PT369.H find label tABOUT and replace DB named Reda
Ktorov the new:
DB "- Pro Tracker v3 +69 for GSAYemul v1.0 by Dr.Lion / RSM
-"
5. Run the garbage mkpt3.B and peremenovyvaem the file in
something like PT3 +69 gs.B
3.10.2004