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:
Channel Address
1 0D00h
2 0D10h
3 0D20h
4 0D30h


Port Direction Function Bits Details
080h RW REG_SND_CH1_PITCH L LLLLLLLL Pitch (Higher number=Higher pitch)
081h RW REG_SND_CH1_PITCH H -----HHH
082h RW REG_SND_CH2_PITCH L LLLLLLLL Pitch (Higher number=Higher pitch)
083h RW REG_SND_CH2_PITCH H -----HHH
084h RW REG_SND_CH3_PITCH L LLLLLLLL Pitch (Higher number=Higher pitch)
085h RW REG_SND_CH3_PITCH H -----HHH
086h RW REG_SND_CH4_PITCH L LLLLLLLL Pitch (Higher number=Higher pitch)
087h RW REG_SND_CH4_PITCH H -----HHH
088h RW REG_SND_CH1_VOL LLLLRRRR L=Left R=Right (15=loud)
089h RW REG_SND_CH2_VOL LLLLRRRR L=Left R=Right (15=loud)
08Ah RW REG_SND_CH3_VOL LLLLRRRR L=Left R=Right (15=loud)
08Bh RW REG_SND_CH4_VOL LLLLRRRR L=Left R=Right (15=loud)
08Ch RW REG_SND_SWEEP_VALUE SSSSSSSS
08Dh RW REG_SND_SWEEP_TIME ---TTTTT
08Eh RW REG_SND_NOISE ---ERMMM E=Enable / R=Reset / M=Mode
08Fh RW REG_SND_WAVE_BASE AAAAAAAA Wave address >>6 (34h= 0D00h)
090h RW REG_SND_CTRL NSV-4321 N= ch4 Noise / S= ch3 Sweep / V= ch2 Voice / M=Channel Modes / 4321 - Channel enable
091h RW REG_SND_OUTPUT

092h R REG_SND_RANDOM L

093h R REG_SND_RANDOM H

094h RW REG_SND_VOICE_CTRL

095h RW REG_SND_HYPERVOICE

096h RW REG_SND_9697 L

097h RW REG_SND_9697 H

098h RW REG_SND_9899 L

099h RW REG_SND_9899 H

09Ah R REG_SND_9A

09Bh R REG_SND_9B

09Ch R REG_SND_9C

09Dh R REG_SND_9D

09Eh R REG_SND_9E


Introducing ChibiSound!

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.






 

View Options
Default Dark
Simple (Hide this menu)
Print Mode (white background)

Top Menu
***Main Menu***
Youtube channel
Patreon
Introduction to Assembly (Basics for absolute beginners)
Amazon Affiliate Link
AkuSprite Editor
ChibiTracker
Dec/Bin/Hex/Oct/Ascii Table

Alt Tech
Archive.org
Bitchute
Odysee
Rumble
DailyMotion
Please note: I wlll upload more content to these alt platforms based on the views they bring in

Z80 Content
***Z80 Tutorial List***
Learn Z80 Assembly (2021)
Learn Z80 Assembly (old)
Hello World
Simple Samples
Advanced Series
Multiplatform Series
Platform Specific Series
ChibiAkumas Series
Grime Z80
Z80 Downloads
Z80 Cheatsheet
Sources.7z
DevTools kit
Z80 Platforms
Amstrad CPC
Elan Enterprise
Gameboy & Gameboy Color
Master System & GameGear
MSX & MSX2
Sam Coupe
TI-83
ZX Spectrum
Spectrum NEXT
Camputers Lynx

6502 Content
***6502 Tutorial List***
Learn 6502 Assembly
Advanced Series
Platform Specific Series
Hello World Series
Simple Samples
Grime 6502
6502 Downloads
6502 Cheatsheet
Sources.7z
DevTools kit
6502 Platforms
Apple IIe
Atari 800 and 5200
Atari Lynx
BBC Micro
Commodore 64
Commodore PET
Commander x16
Super Nintendo (SNES)
Nintendo NES / Famicom
PC Engine (Turbografx-16)
Vic 20

68000 Content
***68000 Tutorial List***
Learn 68000 Assembly
Hello World Series
Platform Specific Series
Simple Samples
Grime 68000
68000 Downloads
68000 Cheatsheet
Sources.7z
DevTools kit
68000 Platforms
Amiga 500
Atari ST
Neo Geo
Sega Genesis / Mega Drive
Sinclair QL
X68000 (Sharp x68k)

8086 Content
Learn 8086 Assembly
Platform Specific Series
Hello World Series
Simple Samples
8086 Downloads
8086 Cheatsheet
Sources.7z
DevTools kit
8086 Platforms
Wonderswan
MsDos

ARM Content
Learn ARM Assembly
Learn ARM Thumb Assembly
Platform Specific Series
Hello World
Simple Samples
ARM Downloads
ARM Cheatsheet
Sources.7z
DevTools kit
ARM Platforms
Gameboy Advance
Nintendo DS
Risc Os

Risc-V Content
Learn Risc-V Assembly
Risc-V Downloads
Risc-V Cheatsheet
Sources.7z
DevTools kit

MIPS Content
Learn Risc-V Assembly
Platform Specific Series
Hello World
Simple Samples
MIPS Downloads
MIPS Cheatsheet
Sources.7z
DevTools kit
MIPS Platforms
Playstation
N64

PDP-11 Content
Learn PDP-11 Assembly
Platform Specific Series
Simple Samples
PDP-11 Downloads
PDP-11 Cheatsheet
Sources.7z
DevTools kit
PDP-11 Platforms
PDP-11
UKNC

TMS9900 Content
Learn TMS9900 Assembly
Platform Specific Series
Hello World
TMS9900 Downloads
TMS9900 Cheatsheet
Sources.7z
DevTools kit
TMS9900 Platforms
Ti 99

6809 Content
Learn 6809 Assembly
Learn 6309 Assembly
Platform Specific Series
Hello World Series
Simple Samples
6809 Downloads
6809/6309 Cheatsheet
Sources.7z
DevTools kit
6809 Platforms
Dragon 32/Tandy Coco
Fujitsu FM7
TRS-80 Coco 3
Vectrex

65816 Content
Learn 65816 Assembly
Hello World
Simple Samples
65816 Downloads
65816 Cheatsheet
Sources.7z
DevTools kit
65816 Platforms
SNES

eZ80 Content
Learn eZ80 Assembly
Platform Specific Series
eZ80 Downloads
eZ80 Cheatsheet
Sources.7z
DevTools kit
eZ80 Platforms
Ti84 PCE

IBM370 Content
Learn IBM370 Assembly
Simple Samples
IBM370 Downloads
IBM370 Cheatsheet
Sources.7z
DevTools kit

Super-H Content
Learn SH2 Assembly
Hello World Series
Simple Samples
SH2 Downloads
SH2 Cheatsheet
Sources.7z
DevTools kit
SH2 Platforms
32x
Saturn

PowerPC Content
Learn PowerPC Assembly
Hello World Series
Simple Samples
PowerPC Downloads
PowerPC Cheatsheet
Sources.7z
DevTools kit
PowerPC Platforms
Gamecube

Work in Progress
ChibiAndroids

Misc bits
Ruby programming









Buy my Assembly programming book
on Amazon in Print or Kindle!


Buy my Assembly programming book





Available worldwide!
Search 'ChibiAkumas' on
your local Amazon website!
Click here for more info!



































































































Buy my Assembly programming book
on Amazon in Print or Kindle!


Buy my Assembly programming book





Available worldwide!
Search 'ChibiAkumas' on
your local Amazon website!
Click here for more info!


























































































Buy my Assembly programming book
on Amazon in Print or Kindle!


Buy my Assembly programming book





Available worldwide!
Search 'ChibiAkumas' on
your local Amazon website!
Click here for more info!



































































































Buy my Assembly programming book
on Amazon in Print or Kindle!


Buy my Assembly programming book





Available worldwide!
Search 'ChibiAkumas' on
your local Amazon website!
Click here for more info!



































































































Buy my Assembly programming book
on Amazon in Print or Kindle!


Buy my Assembly programming book





Available worldwide!
Search 'ChibiAkumas' on
your local Amazon website!
Click here for more info!



































































































Buy my Assembly programming book
on Amazon in Print or Kindle!


Buy my Assembly programming book





Available worldwide!
Search 'ChibiAkumas' on
your local Amazon website!
Click here for more info!


























































































Buy my Assembly programming book
on Amazon in Print or Kindle!


Buy my Assembly programming book





Available worldwide!
Search 'ChibiAkumas' on
your local Amazon website!
Click here for more info!