Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
8bit_chiptune:sn76489 [2019/11/19 15:35]
admin
8bit_chiptune:sn76489 [2019/11/19 16:16] (current)
admin [8. Game Gear stereo extension]
Line 3: Line 3:
  
 This is a document to clear up a few inaccuracies regarding this chip This is a document to clear up a few inaccuracies regarding this chip
-(existing inaccuracies are mentioned in particular, usually marked +(existing inaccuracies are mentioned in particular, usually marked), and also to document everything there is to know about
-> like this <), and also to document everything there is to know about+
 it. it.
  
Line 12: Line 11:
  
 ---- ----
-==== 1. Conventions ====+==== 1. conventions ====
  
 Binary numbers are denoted by a leading "%" and bits are referred to Binary numbers are denoted by a leading "%" and bits are referred to
Line 47: Line 46:
  
  
-3. Accessing the SN76489 from software +==== 3. Accessing the SN76489 from software ====
-======================================+
  
 The SN76489 has an 8-bit write-only data bus, so it is controlled in The SN76489 has an 8-bit write-only data bus, so it is controlled in
 software by writing bytes to it. How this is done depends on the system. software by writing bytes to it. How this is done depends on the system.
  
-Sega Game 1000 (SG-1000) +Sega Game 1000 (SG-1000)\\ 
-Sega Computer 3000 (SC-3000) +Sega Computer 3000 (SC-3000)\\ 
-Sega Master System (SMS) +Sega Master System (SMS)\\ 
-Sega Game Gear (GG) +Sega Game Gear (GG)\\ 
-Sega Mega Drive/Genesis (in Master System compatibility mode) +Sega Mega Drive/Genesis (in Master System compatibility mode)\\ 
-  The SN76489 can be accessed by writing to any I/O port between 0x40 +The SN76489 can be accessed by writing to any I/O port between 0x40 and 0x7f, although officially only 0x7f was recommended. A few games write to 0x7e. 
-  and 0x7f, although officially only 0x7f was recommended. A few games  +- Sega Mega Drive/Genesis\\ 
-  write to 0x7e.+The SN76489is memory-mapped to the 68000 CPU at location 0xc00011, and the Z80 CPU at 0x7f11.\\ 
 +- ColecoVision\\ 
 +- Coleco Adam?\\ 
 +The SN76489 is mapped to I/O port $ff.\\
  
-Sega Mega Drive/Genesis 
-  The SN76489is memory-mapped to the 68000 CPU at location 0xc00011, and 
-  the Z80 CPU at 0x7f11. 
  
-ColecoVision +==== 4. SN76489 registers ====
-Coleco Adam? +
-  The SN76489 is mapped to I/O port $ff. +
- +
-Other systems +
-  Let me know :) +
- +
- +
-4. SN76489 registers +
-====================+
  
 The SN76489 has 8 "registers" - 4 x 4 bit volume registers, 3 x 10 bit The SN76489 has 8 "registers" - 4 x 4 bit volume registers, 3 x 10 bit
Line 82: Line 71:
  
  
-Channel   Volume registers   Tone/noise registers +   Channel   Volume registers   Tone/noise registers 
-0 (%00)        Vol0                 Tone0 +   0 (%00)           Vol0           Tone0 
-1 (%01)        Vol1                 Tone1 +   1 (%01)           Vol1           Tone1 
-2 (%10)        Vol2                 Tone2 +   2 (%10)           Vol2           Tone2 
-3 (%11)        Vol3                 Noise+   3 (%11)           Vol3           Noise
  
  
-Volume registers: +Volume registers:\\ 
-  The value represents the attenuation of the output. Hence, %0000 is +The value represents the attenuation of the output. Hence, %0000 is full volume and %1111 is silence.
-  full volume and %1111 is silence.+
  
-Tone registers: +Tone registers:\\ 
-  These give a counter reset value for the tone generators. Hence, low +These give a counter reset value for the tone generators. Hence, low values give high frequencies and vice versa.
-  values give high frequencies and vice versa.+
  
-Noise register: +Noise register:\\ 
-  One bit selects the mode ("periodic" or "white") and the other two +One bit selects the mode ("periodic" or "white") and the other two select a shift rate.
-  select a shift rate.+
  
  
-It appears the initial state of these registers depends on the hardware: +It appears the initial state of these registers depends on the hardware:\\ 
-- Discrete chips seem to start with random values (an SC-3000 is +- Discrete chips seem to start with random values (an SC-3000 is reported to start with a tone before the chip is written to by the software).\\ 
-  reported to start with a tone before the chip is written to by the +- The Sega integrated versions seem to start initialised with zeroes in the tone/noise registers and ones in the volume registers (silence).\\
-  software). +
-- The Sega integrated versions seem to start initialised with zeroes in +
-  the tone/noise registers and ones in the volume registers (silence).+
  
  
-4.1 SN76489 register writes +==== 4.1 SN76489 register writes ====
-===========================+
  
-When a byte is written to the SN76489, it processes it as follows:+When a byte is written to the SN76489, it processes it as follows:\\
  
-If bit 7 is 1 then the byte is a LATCH/DATA byte.+If bit 7 is 1 then the byte is a LATCH/DATA byte.\\
  
   %1cctdddd   %1cctdddd
Line 122: Line 104:
     ``------- Channel     ``------- Channel
  
-  Bits 6 and 5 ("cc") give the channel to be latched, ALWAYS. This +Bits 6 and 5 ("cc") give the channel to be latched, ALWAYS. This selects the row in the above table. Bit 4 ("t") determines whether to latch volume (1) or tone/noise (0) data - this gives the column.
-  selects the row in the above table. Bit 4 ("t") determines whether to +
-  latch volume (1) or tone/noise (0) data - this gives the column.+
  
-  The remaining 4 bits ("dddd") are placed into the low 4 bits of the +The remaining 4 bits ("dddd") are placed into the low 4 bits of the relevant register. For the three-bit noise register, the highest bit is discarded.\\ 
-  relevant register. For the three-bit noise register, the highest bit +** The latched register is NEVER cleared by a data byte.**
-  is discarded. +
- +
-The latched register is NEVER cleared by a data byte. <+
  
 If bit 7 is 0 then the byte is a DATA byte. If bit 7 is 0 then the byte is a DATA byte.
Line 138: Line 115:
     `-------- Unused     `-------- Unused
  
-  If the currently latched register is a tone register then the low 6 +If the currently latched register is a tone register then the low 6 bits of the byte are placed into the high 6 bits of the latched register. If the latched register is less than 6 bits wide, high bits are discarded.\\
-  bits of the byte are placed into the high 6 bits of the latched +
-  register. If the latched register is less than 6 bits wide, high bits +
-  are discarded.+
  
 The data have the following meanings (described more fully later): The data have the following meanings (described more fully later):
  
-Tone registers:      ddddDDDDDD = cccccccccc +Tone registers:      ddddDDDDDD = cccccccccc\\ 
-  ddddDDDDDD gives the 10-bit half-wave counter reset value. +ddddDDDDDD gives the 10-bit half-wave counter reset value.\\
- +
-Volume registers:    dddd(DDDDDD) = vvvv(--vvvv) +
-  dddd gives the 4-bit volume value. +
-  If a data byte is written, the low 4 bits of DDDDDD update the 4-bit +
-  volume value. However, this is unnecessary.+
  
-Noise register     dddd(DDDDDD) = -trr(---trr+Volume registers   dddd(DDDDDD) = vvvv(--vvvv)\\ 
-  The low 2 bits of dddd select the shift rate and the next highest bit +dddd gives the 4-bit volume value.\\ 
-  (bit 2) selects the mode (white (1) or "periodic" (0))+If a data byte is written, the low bits of DDDDDD update the 4-bit volume value. However, this is unnecessary.\\
-  If a data byte is written, its low bits update the shift rate and +
-  mode in the same way.+
  
 +Noise register:      dddd(DDDDDD) = -trr(---trr)\\
 +The low 2 bits of dddd select the shift rate and the next highest bit (bit 2) selects the mode (white (1) or "periodic" (0)). If a data byte is written, its low 3 bits update the shift rate and mode in the same way.
  
 This means that the following data will have the following effect This means that the following data will have the following effect
-(spacing added for clarity, hopefully):+(spacing added for clarity, hopefully):\\
  
-1. %1 00 0 1110      Latch, channel 0, tone, data %1110 +**1.** %1 00 0 1110      Latch, channel 0, tone, data %1110\\ 
-   %0 0  001111      Data %001111 +%0 0  001111      Data %001111\\ 
-   Set channel 0 tone to %0011111110 = 0xfe (440Hz @ 35976545Hz clock)+Set channel 0 tone to %0011111110 = 0xfe (440Hz @ 35976545Hz clock)\\
  
-2. %1 01 1 1111      Latch, channel 1, volume, data %1111 +**2.** %1 01 1 1111      Latch, channel 1, volume, data %1111\\ 
-   Set channel 1 volume to %1111 = 0xf (silent)+Set channel 1 volume to %1111 = 0xf (silent)\\
  
-3. %1 10 1 1111      Latch, channel 2, volume, data %1111 +**3.** %1 10 1 1111      Latch, channel 2, volume, data %1111\\ 
-   %0 0  000000      Data %000000 +%0 0  000000      Data %000000\\ 
-   Set channel 2 volume to %1111 = 0xf (silent) +Set channel 2 volume to %1111 = 0xf (silent)\\ 
-   THEN update it to %0000 = 0x0 (full) +THEN update it to %0000 = 0x0 (full)\\ 
- The data byte is NOT ignored. <+**The data byte is NOT ignored.**\\
  
-4. %1 11 0 0101      Latch, channel 3, noise, data %0101 +**4.** %1 11 0 0101      Latch, channel 3, noise, data %0101\\ 
-   Set noise register to %101 (white noise, medium shift rate)+Set noise register to %101 (white noise, medium shift rate)\\
  
-5. %1 11 0 0101      Latch, channel 3, noise, data %0101 +**5.** %1 11 0 0101      Latch, channel 3, noise, data %0101\\ 
-   %0 0  000100      Data %000100 +%0 0  000100      Data %000100\\ 
-   Set noise register to %101 (white noise, medium shift rate) +Set noise register to %101 (white noise, medium shift rate)\\ 
-   THEN update it to %100 (white noise, high shift rate) +THEN update it to %100 (white noise, high shift rate)\\ 
- The data byte is NOT ignored. <+** The data byte is NOT ignored.**
  
-Numbers 1, 2 and 4 above are the same as is described in the various +Numbers 1, 2 and 4 above are the same as is described in the various existing docs.
-existing docs.+
  
 Number 3 IS USED - when pausing between text boxes in SMS Alex Kidd in Number 3 IS USED - when pausing between text boxes in SMS Alex Kidd in
Line 202: Line 170:
 Many games also produce the above two unusual behaviours but not Many games also produce the above two unusual behaviours but not
 repeatedly (often when a SFX is first played, for example). repeatedly (often when a SFX is first played, for example).
- 
  
 Also of note is that the tone registers update immediately when a byte Also of note is that the tone registers update immediately when a byte
Line 213: Line 180:
   %0 0  111111    %1111111111   %0 0  111111    %1111111111
  
-There were a couple of ways to handle SN76489 writes before:+There were a couple of ways to handle SN76489 writes before:\\ 
 +**1.** Latch only the tone registers, as above, and leave them latched when other types of data (volume, noise) are written. This gives a "squawk" effect on SMS Micro Machines' title screen, which drowns out the "eek".
  
-1. Latch only the tone registersas above, and leave them latched when +**2.** Latch tone registers as above, and "unlatch" when other types of data are written. When data byte is written with it unlatched, the data is discarded. This fixes the "squawk" but leaves the "eek".
-   other types of data (volume, noise) are written. This gives a +
-   "squawk" effect on SMS Micro Machines' title screen, which drowns out +
-   the "eek".+
  
-2. Latch tone registers as above, and "unlatch" when other types of +---- 
-   data are written. When a data byte is written with it unlatched, the +==== 5. How the SN76489 makes sound ====
-   data is discarded. This fixes the "squawk" but leaves the "eek"+
- +
- +
-5. How the SN76489 makes sound +
-==============================+
  
 This is already well documented, but I'll repeat it again with This is already well documented, but I'll repeat it again with
Line 245: Line 205:
 decremented, it is zero, the following happens: decremented, it is zero, the following happens:
  
-5.1 Tone channels +=== 5.1 Tone channels ===
-=================+
  
 The counter is reset to the value currently in the corresponding The counter is reset to the value currently in the corresponding
Line 268: Line 227:
 This is often used for sample playback on the SN76489. This is often used for sample playback on the SN76489.
  
-5.2 Noise channel +=== 5.2 Noise channel ===
-=================+
  
 The counter is reset according to the low 2 bits of the noise register The counter is reset according to the low 2 bits of the noise register
Line 285: Line 243:
 shift register" (LFSR), which can generate noise or act as a divider. shift register" (LFSR), which can generate noise or act as a divider.
  
-5.2.1 The Linear Feedback Shift Register +=== 5.2.1 The Linear Feedback Shift Register ===
-========================================+
  
 The LFSR is an array of either 15 or 16 bits, depending on the chip The LFSR is an array of either 15 or 16 bits, depending on the chip
Line 313: Line 270:
 For white noise (Noise register bit 2 = 1): For white noise (Noise register bit 2 = 1):
  
-  For the SMS (1 and 2), Genesis and Game Gear, the tapped bits are +For the SMS (1 and 2), Genesis and Game Gear, the tapped bits are bits 0 and 3. For the SC-3000H, the tapped bits are bits 1 and 2. For the BBC Micro, using John Kortink's data, the tapped bits are 15, 2 and 0.
-  bits 0 and 3. For the SC-3000H, the tapped bits are bits 1 and 2. For +
-  the BBC Micro, using John Kortink's data, the tapped bits are 15, 2 +
-  and 0.+
  
-  I would like to confirm the bit pattern for other systems, please +I would like to confirm the bit pattern for other systems, please contact me if you can help by running/coding homebrew code on a real system and sampling the sound.
-  contact me if you can help by running/coding homebrew code on a real +
-  system and sampling the sound.+
  
-  Example (SMS/GG):+Example (SMS/GG):
  
          +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+          +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
Line 338: Line 290:
 For "periodic noise" (Noise register bit 2 = 0): For "periodic noise" (Noise register bit 2 = 0):
  
-  For the SMS, GG and Genesis, only bit 0 is tapped, ie. the output bit +For the SMS, GG and Genesis, only bit 0 is tapped, ie. the output bit is also the input bit. The effect of this is to output the contents of the shift register in a 16-bit long loop.
-  is also the input bit. The effect of this is to output the contents of +
-  the shift register in a 16-bit long loop.+
  
-  For the BBC Micro, bit 1 is tapped, giving a 15-bit long loop.+For the BBC Micro, bit 1 is tapped, giving a 15-bit long loop.
  
-  Other systems need investigation.+Other systems need investigation.
  
          +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+          +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
Line 352: Line 302:
    +----------------------------------------------------+    +----------------------------------------------------+
  
-   Note that this "periodic noise", as it is called in the original +Note that this "periodic noise", as it is called in the original chip's documentation, is in fact not periodic noise as it is defined elsewhere (white noise with a configurable periodicity); it is a duty cycle modifier. For this reason, throughout this document it is always referred to with quotes.
-   chip's documentation, is in fact not periodic noise as it is +
-   defined elsewhere (white noise with a configurable periodicity); it +
-   is a duty cycle modifier. For this reason, throughout this document +
-   it is always referred to with quotes.+
  
 When the noise register is written to, the shift register is reset, When the noise register is written to, the shift register is reset,
Line 363: Line 309:
 important as it affects the sound of white noise. important as it affects the sound of white noise.
  
-5.2.2 The 15-bit shift register +=== 5.2.2 The 15-bit shift register ===
-===============================+
  
 The values given above are for using a 16-bit shift register. However, The values given above are for using a 16-bit shift register. However,
Line 380: Line 325:
  
  
-5.2.3 An implementation of the noise shift register +=== 5.2.3 An implementation of the noise shift register ===
-===================================================+
  
 The method of generating white noise is the most fundamentally incorrect The method of generating white noise is the most fundamentally incorrect
Line 387: Line 331:
 most common method is to do something like: most common method is to do something like:
  
-#define WHITE_NOISE_FEEDBACK 0xf037   ; or some other value +   #define WHITE_NOISE_FEEDBACK 0xf037   ; or some other value 
-#define PERIODIC_NOISE_FEEDBACK 0x8000 +   #define PERIODIC_NOISE_FEEDBACK 0x8000 
-... +   ... 
-    ShiftRegister>>=1; +    
-    ShiftRegister^=(WhiteNoise?WHITE_NOISE_FEEDBACK:PERIODIC_FEEDBACK); +   ShiftRegister>>=1; 
-    Output=ShiftRegister&1;+   ShiftRegister^=(WhiteNoise?WHITE_NOISE_FEEDBACK:PERIODIC_FEEDBACK); 
 +   Output=ShiftRegister&1;
  
 With the correct choice of periodic feedback parameter (depending on With the correct choice of periodic feedback parameter (depending on
Line 417: Line 362:
 parity(): parity():
  
-int parity(int val) {+   int parity(int val) {
     val^=val>>8;     val^=val>>8;
     val^=val>>4;     val^=val>>4;
Line 423: Line 368:
     val^=val>>1;     val^=val>>1;
     return val&1;     return val&1;
-};+   };
  
 Thanks go to Dave (finaldave) for coming up with this. You may get Thanks go to Dave (finaldave) for coming up with this. You may get
Line 430: Line 375:
 built-in parity checking instructions/flags. built-in parity checking instructions/flags.
  
-5.3 Volume/attenuation +=== 5.3 Volume/attenuation ===
-======================+
  
 The mixer then multiplies each channel's output by the corresponding The mixer then multiplies each channel's output by the corresponding
Line 445: Line 389:
 is defined as is defined as
  
-    power 1 +       power 1 
-log ------- +   log ------- 
-    power 2+       power 2
  
 Whether it's positive or negative depends on which way around you put Whether it's positive or negative depends on which way around you put
Line 474: Line 418:
                       (voltage 2)                       (voltage 2)
  
-Rearranging,+Rearranging,\\
  
     voltage 1     (decibels / 20)     voltage 1     (decibels / 20)
Line 484: Line 428:
 build an output table, for example: build an output table, for example:
  
-int volume_table[16]={ +   int volume_table[16]={ 
-  32767, 26028, 20675, 16422, 13045, 10362,  8231,  6568, +    32767, 26028, 20675, 16422, 13045, 10362,  8231,  6568, 
-   5193,  4125,  3277,  2603,  2067,  1642,  1304,     0 +    5193,  4125,  3277,  2603,  2067,  1642,  1304,     0 
-};+   };
  
 These correspond to volume register values 0x0 to 0xf, in that order. These correspond to volume register values 0x0 to 0xf, in that order.
Line 499: Line 443:
 example. example.
  
- +---- 
-6. The imperfect SN76489 +==== 6. The imperfect SN76489 ====
-========================+
  
 Real components aren't perfect. The output of the SN76489 in its Real components aren't perfect. The output of the SN76489 in its
Line 523: Line 466:
 waves from this: waves from this:
  
----------+         +---------+         +---------+         +---------+ +   +---------+         +---------+         +---------+         +---------+ 
-         |                                                 | +             |                                                 | 
-         |                                                 | +             |                                                 | 
-- - - - -|- - - - -|- - - - -|- - - - -|- - - - -|- - - - -|- - - - -|- +   +- - - - -|- - - - -|- - - - -|- - - - -|- - - - -|- - - - -|- - - - -|- 
-         |                                                 | +             |                                                 | 
-         |                                                 | +             |                                                 | 
-         +---------+         +---------+         +---------+         +--+             +---------+         +---------+         +---------+         +--
  
 to something like this: to something like this:
  
--___               +-___               +-___               +-___ +    +-___               +-___               +-___               +-___ 
-    -----+            -----+            -----+            -----+ +        -----+            -----+            -----+            -----+ 
-         |                                                 | +             |                                                 | 
-_ _ _ _ _|_ _ _ _ _|_ _ _ _ _|_ _ _ _ _|_ _ _ _ _|_ _ _ _ _|_ _ _ _ _|_ +   +_ _ _ _ _|_ _ _ _ _|_ _ _ _ _|_ _ _ _ _|_ _ _ _ _|_ _ _ _ _|_ _ _ _ _|_ 
-         |                                                 | +             |                                                 | 
-         |                                                 | +             |                                                 | 
-         | ___-----+         | ___-----+         | ___-----+         | _ +             | ___-----+         | ___-----+         | ___-----+         | _ 
-         +-                  +-                  +-                  +-+             +-                  +-                  +-                  +-
  
 If the tone register value is large enough, they will decay close to If the tone register value is large enough, they will decay close to
Line 554: Line 497:
  
  
-----+    +----+    +----+    +----+    +----+    +----+    +----+    +-- +   +----+    +----+    +----+    +----+    +----+    +----+    +----+    +-- 
-- - | - -|- - | - -|- - | - -|- - | - -|- - | - -|- - | - -|- - | - -|- +   + - - | - -|- - | - -|- - | - -|- - | - -|- - | - -|- - | - -|- - | - -|- 
-    +----+    +----+    +----+    +----+    +----+    +----+    +----++         +----+    +----+    +----+    +----+    +----+    +----+    +----+
  
 Perfect output (assuming output bit pattern of 10100101): Perfect output (assuming output bit pattern of 10100101):
  
----------+         +---------+                   +---------+         +-- +   +---------+         +---------+                   +---------+         +-- 
-         |                                                   | +             |                                                   | 
-         |                                                   | +             |                                                   | 
-- - - - -+---------+- - - - -+-------------------+- - - - -+---------+-+   +- - - - -+---------+- - - - -+-------------------+- - - - -+---------+-
  
 Actual output: Actual output:
  
--___               +-___                         +-___               +-_ +   +-___               +-___                         +-___               +-_ 
-    -----+            -----+                      -----+         | +        -----+            -----+                      -----+         | 
-         |                                                   | +             |                                                   | 
-- - - - -|-___-----+- - - - -|-___---------------+- - - - -|-___-----+- +   +- - - - -|-___-----+- - - - -|-___---------------+- - - - -|-___-----+- 
-         +-                  +-                            +-+             +-                  +-                            +-
  
  
-The empirical effects are: +The empirical effects are:\\ 
-- The sound of tones is changed very slightly +- The sound of tones is changed very slightly\\ 
-- Noise sounds a bit louder +- Noise sounds a bit louder\\ 
-- Voices sound slightly different+- Voices sound slightly different\\
  
 Some games were programmed with the SN76489 considered to be a perfect Some games were programmed with the SN76489 considered to be a perfect
Line 583: Line 526:
  
  
-6.1 Noise volume +=== 6.1 Noise volume ===
-================+
  
 As previously described, the noise output is either 0 or +1, multiplied As previously described, the noise output is either 0 or +1, multiplied
Line 599: Line 541:
 noise volume when mixing the channels together. noise volume when mixing the channels together.
  
- +---- 
-7. Playing samples on the SN76489 +==== 7. Playing samples on the SN76489 ====
-=================================+
  
 This is for the reference of those wishing to put sample playback in This is for the reference of those wishing to put sample playback in
Line 608: Line 549:
 It is possible to play samples in two ways: It is possible to play samples in two ways:
  
-1. Pulse Code Modulation+=== 1. Pulse Code Modulation ===
  
-   This is the usual way to store, process and output waves. The data is +This is the usual way to store, process and output waves. The data is in the form of voltages (corresponding to the desired speaker position which in turn goves corresponding pressure waves in the air) which are stored digitally, often as 16-bit or 8-bit signed numbers.
-   in the form of voltages (corresponding to the desired speaker +
-   position which in turn goves corresponding pressure waves in the air) +
-   which are stored digitally, often as 16-bit or 8-bit signed numbers.+
  
-   On the SN76489, this is done by:+On the SN76489, this is done by:\\ 
 +1. Setting all 3 tone channels to frequency 0x000\\ 
 +2. At rapid, closely timed intervals, setting the output volume of all 3 to values stored in ROM.\\
  
-   1Setting all 3 tone channels to frequency 0x000 +In other words, the volume setting is used as a 4-bit DACAll three tone channels are usually used together to get maximum volume.
-   2. At rapid, closely timed intervals, setting the output volume of +
-      all 3 to values stored in ROM.+
  
-   In other words, the volume setting is used as a 4-bit DAC. All three +The problem is that the output levels of the SN76489 are not linearly scaled:
-   tone channels are usually used together to get maximum volume. +
- +
-   The problem is that the output levels of the SN76489 are not linearly +
-   scaled:+
  
                                  | Linear                                  | Linear
    | ||||| | | |  |      |                             | SN76489    | ||||| | | |  |      |                             | SN76489
  
-   The source wave could be prepared with this in mind, using some +The source wave could be prepared with this in mind, using some specialised software, but I am not aware of any consumer-level wave editor capable of doing this. However, ignoring this and outputting "normal" linear 4-bit data will generally sound good, but significantly quieter than it would be on a linear scale.
-   specialised software, but I am not aware of any consumer-level wave +
-   editor capable of doing this. However, ignoring this and outputting +
-   "normal" linear 4-bit data will generally sound good, but +
-   significantly quieter than it would be on a linear scale.+
  
-   The quality depends on the rate at which data is sent to the chip; on +The quality depends on the rate at which data is sent to the chip; on most systems, the limit is more likely to be memory space than CPU speed (8kHz 4-bit audio will fit 4.1 seconds into 16KB).
-   most systems, the limit is more likely to be memory space than CPU +
-   speed (8kHz 4-bit audio will fit 4.1 seconds into 16KB).+
  
-   One could use the combined logarithmic volume levels of the three +One could use the combined logarithmic volume levels of the three tone channels to give more output levels, but this additional complexity may not be worth the effort and the space these 12-bit samples would take up; it seems not to be found in existing software.
-   tone channels to give more output levels, but this additional +
-   complexity may not be worth the effort and the space these 12-bit +
-   samples would take up; it seems not to be found in existing software.+
  
-2. Pulse Width Modulation+=== 2. Pulse Width Modulation === 
 +This works by outputting pulses at constant volume whose pattern gives the effect of different frequencies and volumes. This is also how samples are played on PC internal speakers and some CD players.
  
-   This works by outputting pulses at constant volume whose pattern +On the SN76489, this is done by:\\ 
-   gives the effect of different frequencies and volumes. This is also +1. Setting all 3 tone channels to frequency 0x000\\ 
-   how samples are played on PC internal speakers and some CD players. +2. At rapid, closely timed intervals, setting the output volume of all 3 to either 0xf (off) or 0x0 (full) depending on valuues stored in ROM.\\
-   On the SN76489, this is done by:+
  
-   1. Setting all 3 tone channels to frequency 0x000 +All three channels are used to get maximum volume.
-   2. At rapid, closely timed intervals, setting the output volume of +
-      all 3 to either 0xf (off) or 0x0 (full) depending on valuues +
-      stored in ROM.+
  
-   All three channels are used to get maximum volume.+This is equivalent to dithering the sound to one bit per sample instead of however many bits per sample are in the input data. Thus, an 8kHz 8-bit sample can be output as a 64kHz 1-bit sample and it will sound much the same. It is somewhat dependent on the output frequency being above the range of hearing.
  
-   This is equivalent to dithering the sound to one bit per sample +The advantage of this is that it allows for a sample based on a linear PCM scale to be output accurately on the SN76489, (allowing for louder sounds) and it can potentially output any bitdepth source audio. The disadvantage is that, with a limited output rate, one is forced to trade off between the bitdepth and sampling rate of the input sample: with a maximum output rate of 20kHzfor example, one may choose a 6.67kHz 3-bit source sample5kHz 4-bit source sample, etcThis can be severely limiting for the qaulity.
-   instead of however many bits per sample are in the input data. Thus, +
-   an 8kHz 8-bit sample can be output as 64kHz 1-bit sample and it +
-   will sound much the sameIt is somewhat dependent on the output +
-   frequency being above the range of hearing.+
  
-   The advantage of this is that it allows for a sample based on a +On the Master SystemPWM is not very good quality (often the sound is unintelligiblefor example Alex Kidd: the Lost Stars' "Find/I'the Miracle Ball" and Shooting Gallery's "Perfect")but it is the loudest way to play samples.
-   linear PCM scale to be output accurately on the SN76489, (allowing +
-   for louder sounds) and it can potentially output any bitdepth source +
-   audio. The disadvantage is thatwith a limited output rate, one is +
-   forced to trade off between the bitdepth and sampling rate of the +
-   input sample: with a maximum output rate of 20kHzfor example, one +
-   may choose a 6.67kHz 3-bit source sample, a 5kHz 4-bit source sample, +
-   etc. This can be severely limiting for the qaulity.+
  
-   On the Master System, PWM is not very good quality (often the sound +---- 
-   is unintelligible, for example Alex Kidd: the Lost Stars' "Find/I'+==== 8. Game Gear stereo extension ====
-   the Miracle Ball" and Shooting Gallery's "Perfect"), but it is the +
-   loudest way to play samples. +
- +
- +
-8. Game Gear stereo extension +
-=============================+
  
 When a byte is written to port 0x06 on the Game Gear, the SN76489 When a byte is written to port 0x06 on the Game Gear, the SN76489
Line 700: Line 605:
 outputs to rhe left side only, etc. outputs to rhe left side only, etc.
  
- +----
-Maxim +
-maxim@mwos.cjb.net +
-27/4/2005 +
- +
-Updated 6/6/2002: +
-Clarification that SN76489 tones update immediately after latch byte. +
-Use of 2-stage volume writes found. +
- +
-Updated 22/8/2002: +
-Charles MacDonald sampled GG and Genesis noise for me, it's the same +
-bit pattern as SMS noise. +
- +
-Updated 20/10/2002: +
-Fixed some typos. +
- +
-Updated 21/3/2003: +
-Added SC-3000H noise feedback pattern, thanks to Charles MacDonald for +
-getting the data for me. +
- +
-Updated 21/4/2003: +
-Charles MacDonald sampled SMS1 noise, it's the same bit pattern as the +
-SMS2, GG and Genesis. +
- +
-Updated 27/4/2005: +
-Added sections on 15-bit shift registers and volume/attenuation. Most  +
-sections tweaked, clarified, corrected and extended. +
- +