Learn Multi platform 8086 Assembly
Programming... For World Domination!
Platform Specific Lessons
Lesson
P11 - Sound on the Wonderswan
The wonderswan has pretty powerful sound for a handheld!... With 4
channels capable of playing digital sound samples, we can create
some decent digital music!
Lets make a noise!
WSW_JoypadSprite.asm
The WonderSwan sound hardware
The sound processor uses wave samples at the address defined by
port 08Fh. Each channel uses 16
bytes (32 4 bit samples) If we define the base as being 0D00h
(by writing 34h to port 08Fh) the following addresses will define
the samples used by the sound processor:
Since the earliest of my tutorials,
I've handled sound with a simple sound driver knows as
'ChibiSound'
This takes an 8 bit byte value from 0-255, and make a sound of
selectable pitch, with noise or half volume in a similar way on
all our systems!
This was created for Grime Z80, and allows common sound code to
give similar effects on all the systems!
All we do is load the AL register with a value, and call
ChibiSound!
Of course, this won't be enough to make music (please wait for
ChibiSound Pro - yes really!) but it will give us some simple SFX,
and make it easy to compare doing simple tasks on our various
systems!
AL Value
Effect
00h
Sound Off
01h-3Fh
Quiet tone
40h-7Fh
Loud tone
80h-BFh
Quiet Noise
C0h-FFh
Loud Noise
in all cases, smaller numbers are higher pitch, so 10h is higher
than 11h
Writing ChibiSound
Before we can make a sound we need to do two things!
First we need to set the base memory address of our sound samples
0D00h, we write 34h to port 08Fh to set the memory address.
Next we need to create a wave - We write 16 bytes, one nibble per
sample.... We make a square wave by writing a sequence of 0 and F
bytes
We need to make noise in some cases, so we use Channel 4 in all
cases in this example
First we check if AL=0, if it is, we need to turn off the sound.
We silence the channels by setting bit 3 to zero of port 090h
Next we set the volume, we only have 1 bit setting our volume in
the parameter - bit 6.
we set the bits of port 08Bh to set the volume - 15 is the
maximum - 0 is the minimum volume
We need to set the pitch. The Wonderswan uses a 11 bit
frequency.
We set the pitch using ports 086h (L) and 087h (H)... we only have
6 pitch bits in our chibisound parameter, so we need to bitshift!
If bit 7 of our chibisound parameter is 1, we need to set the
noise to on!
We need to set the Noise on with bit 7 of port 090h (we also
set channel 4 on with bit 3).
We also need to set the noise to ON, and configure it with port
08Eh
If noise is off, we just need to set bit 3 of port 090h to 1 to
enable the channel without noise.
Sound channels 2,3 and 4 on
the Wonderswan all have different capabilities, but at a basic
level they all play digital samples with frequency synthesis.