<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.temlib.org/AtariForumWiki/index.php?action=history&amp;feed=atom&amp;title=Earxtutchap3</id>
	<title>Earxtutchap3 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.temlib.org/AtariForumWiki/index.php?action=history&amp;feed=atom&amp;title=Earxtutchap3"/>
	<link rel="alternate" type="text/html" href="https://www.temlib.org/AtariForumWiki/index.php?title=Earxtutchap3&amp;action=history"/>
	<updated>2026-05-13T17:46:30Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.2</generator>
	<entry>
		<id>https://www.temlib.org/AtariForumWiki/index.php?title=Earxtutchap3&amp;diff=13014&amp;oldid=prev</id>
		<title>&gt;Wongck at 15:30, 12 October 2011</title>
		<link rel="alternate" type="text/html" href="https://www.temlib.org/AtariForumWiki/index.php?title=Earxtutchap3&amp;diff=13014&amp;oldid=prev"/>
		<updated>2011-10-12T15:30:16Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 11:30, 12 October 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l237&quot;&gt;Line 237:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 237:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Back to [[ASM_Tutorial]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Back to [[ASM_Tutorial]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Programming&lt;/del&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Making optimized assembly code by Earx&lt;/ins&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>&gt;Wongck</name></author>
	</entry>
	<entry>
		<id>https://www.temlib.org/AtariForumWiki/index.php?title=Earxtutchap3&amp;diff=13013&amp;oldid=prev</id>
		<title>&gt;Silver Surfer: Added category</title>
		<link rel="alternate" type="text/html" href="https://www.temlib.org/AtariForumWiki/index.php?title=Earxtutchap3&amp;diff=13013&amp;oldid=prev"/>
		<updated>2009-05-02T17:10:35Z</updated>

		<summary type="html">&lt;p&gt;Added category&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 13:10, 2 May 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l237&quot;&gt;Line 237:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 237:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Back to [[ASM_Tutorial]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Back to [[ASM_Tutorial]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Programming]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>&gt;Silver Surfer</name></author>
	</entry>
	<entry>
		<id>https://www.temlib.org/AtariForumWiki/index.php?title=Earxtutchap3&amp;diff=13012&amp;oldid=prev</id>
		<title>&gt;Zorro 2 at 08:07, 9 October 2006</title>
		<link rel="alternate" type="text/html" href="https://www.temlib.org/AtariForumWiki/index.php?title=Earxtutchap3&amp;diff=13012&amp;oldid=prev"/>
		<updated>2006-10-09T08:07:40Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 04:07, 9 October 2006&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l235&quot;&gt;Line 235:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 235:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;                        produce some blips and blops and other noise.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;                        produce some blips and blops and other noise.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Back to [[ASM_Tutorial]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>&gt;Zorro 2</name></author>
	</entry>
	<entry>
		<id>https://www.temlib.org/AtariForumWiki/index.php?title=Earxtutchap3&amp;diff=13011&amp;oldid=prev</id>
		<title>&gt;Simonsunnyboy at 17:46, 6 October 2006</title>
		<link rel="alternate" type="text/html" href="https://www.temlib.org/AtariForumWiki/index.php?title=Earxtutchap3&amp;diff=13011&amp;oldid=prev"/>
		<updated>2006-10-06T17:46:12Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
                          CHAPTER 3 : CODING SOUND&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This little part is aimed at the DMA-sound of the STe and newer machines.&lt;br /&gt;
I diliberately chose to skip the Yamaha soundchip, because this is&lt;br /&gt;
actually a bit more diffcult than the DMA-chip. The old Yammy can only&lt;br /&gt;
produce crap sound anyway... (though what some people got out of that thing&lt;br /&gt;
is incredible!!) Take a peek at chapter 11 to find out a bit more about the&lt;br /&gt;
Yammy there.&lt;br /&gt;
&lt;br /&gt;
Let's say we want something like a sample of an explosion coming out of&lt;br /&gt;
your speakers/monitor. What do you need:&lt;br /&gt;
&lt;br /&gt;
* a signed 8-bit sample at 12.5, 25 or 50 KHz&lt;br /&gt;
* an STe or better (TT/Falcon)&lt;br /&gt;
* a piece of assembly code to control the DMA chip&lt;br /&gt;
&lt;br /&gt;
I just suppose you all have the required machine, otherwise you can just&lt;br /&gt;
skip this chapter. You can get samples anywhere and convert them to the&lt;br /&gt;
above specifications. Now you need to include the sample in your code like&lt;br /&gt;
this:&lt;br /&gt;
&lt;br /&gt;
sample:   INCBIN         D:\SOUNDS\EXPLO.SPL&lt;br /&gt;
^         ^              ^&lt;br /&gt;
|         |              |&lt;br /&gt;
labelname actual command path/name of sample&lt;br /&gt;
&lt;br /&gt;
This will include the binairy data of the file into the assembled&lt;br /&gt;
executable. It's quite easy and you can do it with pictures, sprites and&lt;br /&gt;
text too.&lt;br /&gt;
OK, now you need the rest of the code. First you need to include the&lt;br /&gt;
supervisor-mode routines listed in chapter 1. In order to access the DMA-&lt;br /&gt;
chip you'll need to be in supervisor-mode.&lt;br /&gt;
Now comes the important part. The actual controlling of the DMA-chip and&lt;br /&gt;
getting it to play our sample. The chip is represented by various hardware-&lt;br /&gt;
registers that are located in high memory. I'll explain some here:&lt;br /&gt;
&lt;br /&gt;
$ffff8900: DMA-control register. This is a word that contains bits that can&lt;br /&gt;
be set that let the chip begin to play a sample or loop a sample. Here's&lt;br /&gt;
the exact layout:&lt;br /&gt;
&lt;br /&gt;
               +------- bit 1: loop sample (1=on 0=off)&lt;br /&gt;
               |+------ bit 0: play sample (1=on 0=off)&lt;br /&gt;
               ||&lt;br /&gt;
+----------------+&lt;br /&gt;
|iiiixxxxxxxxxxlp|&lt;br /&gt;
+----------------+&lt;br /&gt;
 ||||&lt;br /&gt;
bits 12 to 15:&lt;br /&gt;
interrupt thingies (not really interesting for us)&lt;br /&gt;
&lt;br /&gt;
Note: I've not included the falcon-extended bits. I just want to show you&lt;br /&gt;
the basics and not all the details.&lt;br /&gt;
&lt;br /&gt;
$ffff8921: sound-mode control register. This is a byte that contains the&lt;br /&gt;
bits that control the replay frequency and stereo/mono stuff.&lt;br /&gt;
&lt;br /&gt;
       ++--11 = 50 KHz&lt;br /&gt;
       ++--10 = 25 KHz&lt;br /&gt;
       ++--01 = 12.5 KHz&lt;br /&gt;
       ++--00 = 6.25 KHz&lt;br /&gt;
       ||&lt;br /&gt;
+--------+&lt;br /&gt;
|sxxxxxff|&lt;br /&gt;
+--------+&lt;br /&gt;
 |&lt;br /&gt;
bit 7: stereo/mono select (1=mono 0=stereo)&lt;br /&gt;
&lt;br /&gt;
$ffff8903: frame start address - high byte: contains bits 16 to 23 of the&lt;br /&gt;
24 bits sample beginaddress.&lt;br /&gt;
$ffff8905: frame start address - mid byte: Same as high byte only for bits&lt;br /&gt;
8 to 15.&lt;br /&gt;
$ffff8907: frame start address - low byte: Same as high byte only for bits&lt;br /&gt;
0 to 7.&lt;br /&gt;
&lt;br /&gt;
$ffff890f: frame end address - high byte: contains bits 16 to 23 of the&lt;br /&gt;
24 bits sample endaddress.&lt;br /&gt;
$ffff8911: frame end address - mid byte: Same as high byte only for bits&lt;br /&gt;
8 to 15.&lt;br /&gt;
$ffff8913: frame end address - low byte: Same as high byte only for bits&lt;br /&gt;
0 to 7.&lt;br /&gt;
&lt;br /&gt;
Now that I've explained all the usefull registers let's get on with the&lt;br /&gt;
code. First I need to note that in order to play the sample you need to give&lt;br /&gt;
the frame-end-address-register the endaddress of your sample. You get the&lt;br /&gt;
address by doing this:&lt;br /&gt;
&lt;br /&gt;
sample: INCBIN  D:\SOUND\ARSEWIPE.SPL&lt;br /&gt;
end:&lt;br /&gt;
&lt;br /&gt;
That's right! Simply put a label behind your incbin and there you have it!&lt;br /&gt;
Now let's get on with the rest of the code:&lt;br /&gt;
&lt;br /&gt;
* First we set the sound-mode control register. We set it to mono, 25 KHz.&lt;br /&gt;
* We set bit 7, set the bit 1 and clear bit 0.&lt;br /&gt;
        andi.b  #%11111110,$ffff8921&lt;br /&gt;
        ori.b   #%10000010,$ffff8921&lt;br /&gt;
* Then we set the startaddress&lt;br /&gt;
        move.l  #sample,d0              * Move startaddress into d0.&lt;br /&gt;
        swap    d0                      * Bring the high byte in d0.b.&lt;br /&gt;
* I moved the high byte into d0.b because first of all we MUST do the high&lt;br /&gt;
* byte!&lt;br /&gt;
        move.b  d0,$ffff8903            * Move the high byte of the address.&lt;br /&gt;
* Then we do the mid byte of the address.&lt;br /&gt;
        rol.l   #8,d0                   * Bring the mid byte in d0.b.&lt;br /&gt;
        move.b  d0,$ffff8905            * Move the mid byte of the address.&lt;br /&gt;
* Finally, we do the low byte.&lt;br /&gt;
        rol.l   #8,d0                   * Bring the low byte in d0.b.&lt;br /&gt;
        move.b  d0,$ffff8907            * Move the low byte of the address.&lt;br /&gt;
* OK, the startaddress is done, now for the endaddress.&lt;br /&gt;
* It's basicly the same as the startaddress, but with a different label and&lt;br /&gt;
* different registers.&lt;br /&gt;
        move.l  #end,d0                 * Move endaddress into d0.&lt;br /&gt;
        swap    d0                      * Bring the high byte in d0.b.&lt;br /&gt;
* I moved the high byte into d0.b because first of all we MUST do the high&lt;br /&gt;
* byte!&lt;br /&gt;
        move.b  d0,$ffff890f            * Move the high byte of the address&lt;br /&gt;
* Then we do the mid byte of the address.&lt;br /&gt;
        rol.l   #8,d0                   * Bring the mid byte in d0.b.&lt;br /&gt;
        move.b  d0,$ffff8911            * Move the mid byte of the address.&lt;br /&gt;
* Finally, we do the low byte.&lt;br /&gt;
        rol.l   #8,d0                   * Bring the low byte in d0.b.&lt;br /&gt;
        move.b  d0,$ffff8913            * Move the low byte of the address.&lt;br /&gt;
* Now to trigger the playback of the sample.&lt;br /&gt;
* We set bit 0 to trigger playback and clear bit 1 to turn looping off.&lt;br /&gt;
        andi.w  #%1111111111111101,$ffff8900&lt;br /&gt;
        ori.w   #%0000000000000001,$ffff8900&lt;br /&gt;
&lt;br /&gt;
That's it! You replayed a sample. This is so simple! Just compare it to&lt;br /&gt;
a system like a PC.&lt;br /&gt;
About the order of high/mid/low bytes: the DMA-chip expects you to first&lt;br /&gt;
do the high one and later on the lower ones. Otherwise it just won't work!&lt;br /&gt;
&lt;br /&gt;
There you have it. But now I'm gonna go a bit deeper into the whole thing.&lt;br /&gt;
If you think you're up to editing samples with programs you can continue&lt;br /&gt;
reading....&lt;br /&gt;
&lt;br /&gt;
OK, that's all very nice, but what if we want two or maybe four channel&lt;br /&gt;
sound just like in those groovy MOD-thingies. Then you need to mix a few&lt;br /&gt;
samples together. What you do is average every byte in the samples and&lt;br /&gt;
make a new sample of it.&lt;br /&gt;
Hold on, stop, stop, whats goin' on here! Oh, you don't understand, I'll&lt;br /&gt;
explain a bit better. Every sample consists of load of bytes. Each byte&lt;br /&gt;
represents the heigth of the soundwave at a certain moment. Like this:&lt;br /&gt;
&lt;br /&gt;
This is a normal soundwave(in a funky ASCII drawing):&lt;br /&gt;
&lt;br /&gt;
   --               ^&lt;br /&gt;
  /  \              | amplitudo (heigth of soundwave)&lt;br /&gt;
 /    \             |&lt;br /&gt;
|------|------      ---&amp;gt; time&lt;br /&gt;
        \    /&lt;br /&gt;
         \  /&lt;br /&gt;
          --&lt;br /&gt;
&lt;br /&gt;
Now if you sample this you get the following bytes:&lt;br /&gt;
&lt;br /&gt;
$00,$28,$50,$7f,$7f,$50,$28,$00,-$28,-$50,-$80,-$80,-$50,-$28,$00&lt;br /&gt;
&lt;br /&gt;
Every byte simply represents the amplitudo at each interval. OK, that's the&lt;br /&gt;
basics of sampling. But now you want to mix. The only thing you need to do&lt;br /&gt;
now is add the amplitudo's of the samples to eachother and divide them&lt;br /&gt;
through the number of channels your using. Suppose you wanted to mix two&lt;br /&gt;
channels together:&lt;br /&gt;
&lt;br /&gt;
amplitudo of sample 1 at interval 0 = $34&lt;br /&gt;
amplitudo of sample 2 at interval 0 = $1a&lt;br /&gt;
&lt;br /&gt;
Now you add them together: $34 + $1a = $4d (just some hexa-calculation)&lt;br /&gt;
                                           (if you don't know what that)&lt;br /&gt;
                                           (is, please skip this theory!)&lt;br /&gt;
&lt;br /&gt;
Now divide it by the number of channels: $4d/2 = $27&lt;br /&gt;
&lt;br /&gt;
Now do this for every byte in the samples and you have your mixed sample&lt;br /&gt;
that you can easily playback with your DMA. The practical aproach to this&lt;br /&gt;
would look like:&lt;br /&gt;
&lt;br /&gt;
        move.l  #sample1,a0             * Move startaddress of spl1 into a0.&lt;br /&gt;
        move.l  #sample2,a1             * Move startaddress of spl2 into a1.&lt;br /&gt;
        move.l  #d_sample,a2            * Move  &amp;quot; of destination spl into a2.&lt;br /&gt;
        move.w  #10000-1,d7             * Suppose the samples have 10000 bytes.&lt;br /&gt;
        moveq   #0,d1                   * Clear d1 for use as adding register.&lt;br /&gt;
        moveq   #0,d0                   * Clear d0 for use as adding register.&lt;br /&gt;
loop:   move.b  (a0)+,d0                * Put amplitudo of spl1 in d0.&lt;br /&gt;
        move.b  (a1)+,d1                * Put amplitudo of spl2 in d1.&lt;br /&gt;
        add.b   d1,d0                   * Add them.&lt;br /&gt;
        lsr.w   #1,d0                   * Divide it by 2 (shift 1 bit right).&lt;br /&gt;
        move.b  d0,(a2)+                * Move result in destination sample.&lt;br /&gt;
        dbra    d7,loop                 * Loop 10000 times.&lt;br /&gt;
&lt;br /&gt;
Now you can put your playback routine underneath this and give it the&lt;br /&gt;
start/end-addresses of d_sample and there you have it!!&lt;br /&gt;
Some of you might be curious why I clear the registers first. Well, when&lt;br /&gt;
you add like $60 and $40 it should make $a0, right? Well, a byte cannot&lt;br /&gt;
hold this! You simply need an extra bit. But if this bit should happen to be&lt;br /&gt;
1 you'd get wrong results:&lt;br /&gt;
&lt;br /&gt;
This is the situation with bit 8 cleared:&lt;br /&gt;
&lt;br /&gt;
$60 + $40 = $a0&lt;br /&gt;
$a0/2= $50&lt;br /&gt;
&lt;br /&gt;
This is the situation when bit 8 accidently isn't cleared:&lt;br /&gt;
&lt;br /&gt;
bit 8 set!!&lt;br /&gt;
 |&lt;br /&gt;
$160 + $40 = $1a0&lt;br /&gt;
$1a0/2 = $208 (The byte can only contain the&lt;br /&gt;
               first two digits so you get $08!!)&lt;br /&gt;
&lt;br /&gt;
As you can see the accidental being set of this can be catastrophic! Now&lt;br /&gt;
I've explained it... Phew, That's I guess.. I could have explained more&lt;br /&gt;
about frequencies, but would take up even more space and time. I'd like to&lt;br /&gt;
keep it a bit more basical. The summary:&lt;br /&gt;
&lt;br /&gt;
Amplitudo:             heigth of a soundwave at a certain interval. In a&lt;br /&gt;
                       sample this is represented with a numerical value.&lt;br /&gt;
DMA-chip:              Soundchip in STe or higher that can play one 8-bit&lt;br /&gt;
                       stereo or mono sample at a time&lt;br /&gt;
DMA-registers:         Registers you control the DMA-chip with. They are&lt;br /&gt;
                       located in high memory and you need supervisor-mode&lt;br /&gt;
                       to access them.&lt;br /&gt;
Funky ASCII drawing:   A bunch of ASCII characters put next to eachother by&lt;br /&gt;
                       somekind of moron who calls it a drawing or even&lt;br /&gt;
                       'art'.&lt;br /&gt;
Incbin:                Easy way to include binairy data (sample, text, etc.)&lt;br /&gt;
                       into your executable file (PRG,TOS,APP,etc.)&lt;br /&gt;
Mixing:                Making more samples in to one sample by averaging&lt;br /&gt;
                       all the bytes.&lt;br /&gt;
Sample:                A string of amplitudo values.&lt;br /&gt;
YM2149:                Also known as the &amp;quot;Yammy&amp;quot;. The oldest soundchip of the&lt;br /&gt;
                       ST. Basicly outdated when the ST was released. Can&lt;br /&gt;
                       produce some blips and blops and other noise.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>&gt;Simonsunnyboy</name></author>
	</entry>
</feed>