Emuforums.com

Go Back   Emuforums.com > General Discussion > Web development / Programming
Register FAQ Members List Calendar Mark Forums Read

Login to remove all ads!
Reply
 
LinkBack Thread Tools Display Modes
Old March 26th, 2008   #1 (permalink)
Prototype
 
Shendo's Avatar
 
Join Date: Feb 2006
Location: Croatia
Posts: 3,666
Chip-8 emu

Probably everyone has done one so I figured I might try as well.
After reading a few documents and a thread at EmuTalk I was able to do a really buggy Chip-8 emulator which properly runs about 1% of the games

Since this was just to get a basic idea how emulators work I didn't bother to polish the emu or fix the bugs.

Now it might be a while until I start anything similar or fix the issues on this emulator but I was wondering about one thing:
How to actually emulate (make) a sound?
Can anyone post links to some docs about that?
For Chip-8 I simply used system beep which was enough but for any more advanced system (eg. Game Boy) that simply won't cut it.

Thanks in advance for any help on that subject.

Btw: If you decide to download this alpha (should be pre-alpha really) emulator i hope that you will have fun laughing at glitches like I did.
Attached Images
File Type: jpg c8blizt.jpg (14.2 KB, 32 views)
File Type: jpg c8pong.jpg (10.7 KB, 24 views)
File Type: jpg c8breakout.jpg (17.2 KB, 21 views)
File Type: jpg c8blitzdisassm.jpg (55.6 KB, 29 views)
Attached Files
File Type: 7z c8emu_alpha.7z (12.8 KB, 26 views)
Shendo is offline   Reply With Quote
Old March 26th, 2008   #2 (permalink)
Menthol Flavored
 
TheCloudOfSmoke's Avatar
 
Join Date: Mar 2005
Location: In your butt. If I'm not there, I'm in Maryland, USA.
Posts: 2,685
Best of luck with your emulation projects. It's good to see more aspiring emu authors out there. It gives me hope for the scene. I hope to see a really awesome emu from you one day Shendo. Good luck. Sorry if my post didn't help you whatsoever.
__________________
http://thecloudofsmoke.deviantart.com/
http://thecloudofsmoke.deviantart.com/gallery/

Quote:
Originally Posted by Ryu2 View Post
Unfortunately I'm back already with another dumb question. How do I activate the stylus? >_<

(I tried jabbing at the computer screen with the nds stylus but it didn't work).
TheCloudOfSmoke is offline   Reply With Quote
Old March 26th, 2008   #3 (permalink)
Shogun3D Interactive (TM)
 
blueshogun96's Avatar
 
Join Date: Jun 2004
Location: Unidentified
Posts: 2,065
Okay, there's not much out there related to emulating sound and you'll soon find out the google is not your friend on this subject. I'll do my best to answer your question.

1. Before learning about sound emulation, it's highly recommended that you learn about how sound works (if you don't know already). First learn a low-level sound API such as DirectSound, OpenAL or XAudio (which is still in beta stages) and create some sound programs that can output sound by sending some raw data to a sound buffer. DirectSound is so far the most prominent while sound emulation with OpenAL is rather hard and XAudio... I don't know because I haven't seen it used for anything yet. Finding tutorials on low level sound APIs are very hard to find (except OpenAL which is more for 3D games) and once again Google might not be your friend on this subject. If you want you can either read the docs on the sound API such as the microsoft SDK documentation or MSDN. If you need tutorials on DirectSound, ask me and I will write them for you personally.

2. As far as tutorials on how to emulate sound, this is the best I can find to date: Blargg's Video Game Sound Emulation
Here's another: How to write an emulator It's an overall tutorial on emulation, but the sound emulation section is the largest and it shows some actual DirectSound code being used.

3. Be sure to have the documentation on the sound hardware you're trying to emulate!

4. I'm not sure how far indepth you want to get with sound emulation, but let me tell you this, emulating sound [usually] gets harder and harder as the console gets more advanced VERY quickly (sometimes more then the CPU itself). While GameBoy, SpaceInvaders, and NES usually aren't so bad, other old consoles such as Atari2600 and SNES have certain issues to be dealt with (for Atari usually has to deal with Pitfall II, for SNES the DSP) in order to get accurate emulation. The newer consoles and arcade hardware such as SegaSaturn/Titan Video, GC, PS2 have very advanced audio systems with either more than one core or advanced and undocumented DSPs. Instead of using basic PSG or FM based audio chips that generate simple waveforms (i.e. sin and cos for wave generation), these are APUs that create more complex audio effects and uses more complex methods (i.e. envelopes, KON/KOF, attack - sustain - decay rates, etc.). So far the most complex audio system I've seen [actual] specs on to date is Xbox1 with(at least 3 DSPs, an AC'97 Audio codec, and an NVIDIA SoundStorm APU. I know that PS3's audio system is the most advanced (where every object can have it's own sound channel!), but I don't think you'll be trying to emulate anytime soon (or even in your lifetime) Anyone can feel free to correct me if I'm wrong about any of this.

So if you need anything else, feel free to ask me anytime. Know this, I don't know everything

And about your emulator, what APIs are you using? btw, nice debugger! Looking great!
__________________

[Sagat] Windows XP x64 Pro | AMD Athlon 3000+ (~2.0GHz) | NVIDIA GeForce 6600 PCI-E | Realtek AC97 Audio | 512MB Ram | NVIDIA NForce 4-4X chipset | Seagate HDD 160GB | LG 8614 DVD-ROM | HP DVD 1040d CD/DVD -/+ RW w/ LightScribe

GeneralEmu - December 27, 2005 and beyond!
My programming, emulation and Xbox blog! - Click or die! (Updated June 26, 2008)
Visit my YouTube page! http://www.youtube.com/blueshogun96

Last edited by blueshogun96; March 26th, 2008 at 05:42. Reason: Added more information that might be useful, informative, or overall educational for that matter.
blueshogun96 is offline   Reply With Quote
Old March 26th, 2008   #4 (permalink)
PCSX3 Coder
 
Phil's Avatar
 
Join Date: Oct 2007
Location: Maryland, where the big boys play.
Posts: 2,928
well direct sound is not supported in Vista...only XP downwords..stick with OpenAL
__________________
Antec P182 Special Edition (Chrome Finish) : Intel e8400 : Thermaltake ToughPower 650 watt PSU : Corsair Dominater DHX 1066 DDR2 Ram : Asus P5K : 500 Gb Seagate : 74 GB Raptor : Samsung 20x DVD optical Drive : Soyo Topaz 24" LCD : Windows 95 : XFX 8800gt
Cooling: Swiftech Apogee GTX Special Edition (Copper Finish) : Feser X-Changer Dual 120mm Radiator : XSPC Bay Resevoir : Danger den Chrome Barbs : Feser UV anti kink 1/2" ID tubing : Danger Den D5

Phil is offline   Reply With Quote
Old March 26th, 2008   #5 (permalink)
Shogun3D Interactive (TM)
 
blueshogun96's Avatar
 
Join Date: Jun 2004
Location: Unidentified
Posts: 2,065
Quote:
Originally Posted by Phil View Post
well direct sound is not supported in Vista...only XP downwords..stick with OpenAL
Yes it is. DirectSound only can be used in software mode, but it still works just fine. EAX support has been resurrected but only for the Creative Audigy users. I wouldn't recommend using OpenAL for sound emulation for beginners because it's harder for beginners to grasp it.
__________________

[Sagat] Windows XP x64 Pro | AMD Athlon 3000+ (~2.0GHz) | NVIDIA GeForce 6600 PCI-E | Realtek AC97 Audio | 512MB Ram | NVIDIA NForce 4-4X chipset | Seagate HDD 160GB | LG 8614 DVD-ROM | HP DVD 1040d CD/DVD -/+ RW w/ LightScribe

GeneralEmu - December 27, 2005 and beyond!
My programming, emulation and Xbox blog! - Click or die! (Updated June 26, 2008)
Visit my YouTube page! http://www.youtube.com/blueshogun96
blueshogun96 is offline   Reply With Quote
Old March 26th, 2008   #6 (permalink)
PCSX3 Coder
 
Phil's Avatar
 
Join Date: Oct 2007
Location: Maryland, where the big boys play.
Posts: 2,928
that's what i meant. A card using directsound will have to run on software mode...which sucks as i was going to get the Auzentech Prelude specifically for it's hardware mode...I still might get it....just waiting till Auzentech sorts out Creative's drivers
__________________
Antec P182 Special Edition (Chrome Finish) : Intel e8400 : Thermaltake ToughPower 650 watt PSU : Corsair Dominater DHX 1066 DDR2 Ram : Asus P5K : 500 Gb Seagate : 74 GB Raptor : Samsung 20x DVD optical Drive : Soyo Topaz 24" LCD : Windows 95 : XFX 8800gt
Cooling: Swiftech Apogee GTX Special Edition (Copper Finish) : Feser X-Changer Dual 120mm Radiator : XSPC Bay Resevoir : Danger den Chrome Barbs : Feser UV anti kink 1/2" ID tubing : Danger Den D5

Phil is offline   Reply With Quote
Old March 26th, 2008   #7 (permalink)
Shogun3D Interactive (TM)
 
blueshogun96's Avatar
 
Join Date: Jun 2004
Location: Unidentified
Posts: 2,065
But for emulation it's not too critical, unless the hardware you're trying to emulate uses features that can only be emulated in hardware (which so far no situation like that has come up yet afaik). Besides, using low-level DirectSound is still great for beginners to learn because the APIs and interfaces are usually self explanatory.
__________________

[Sagat] Windows XP x64 Pro | AMD Athlon 3000+ (~2.0GHz) | NVIDIA GeForce 6600 PCI-E | Realtek AC97 Audio | 512MB Ram | NVIDIA NForce 4-4X chipset | Seagate HDD 160GB | LG 8614 DVD-ROM | HP DVD 1040d CD/DVD -/+ RW w/ LightScribe

GeneralEmu - December 27, 2005 and beyond!
My programming, emulation and Xbox blog! - Click or die! (Updated June 26, 2008)
Visit my YouTube page! http://www.youtube.com/blueshogun96
blueshogun96 is offline   Reply With Quote
Old March 26th, 2008   #8 (permalink)
PCSX3 Coder
 
Phil's Avatar
 
Join Date: Oct 2007
Location: Maryland, where the big boys play.
Posts: 2,928
you have a point...
__________________
Antec P182 Special Edition (Chrome Finish) : Intel e8400 : Thermaltake ToughPower 650 watt PSU : Corsair Dominater DHX 1066 DDR2 Ram : Asus P5K : 500 Gb Seagate : 74 GB Raptor : Samsung 20x DVD optical Drive : Soyo Topaz 24" LCD : Windows 95 : XFX 8800gt
Cooling: Swiftech Apogee GTX Special Edition (Copper Finish) : Feser X-Changer Dual 120mm Radiator : XSPC Bay Resevoir : Danger den Chrome Barbs : Feser UV anti kink 1/2" ID tubing : Danger Den D5

Phil is offline   Reply With Quote
Old March 26th, 2008   #9 (permalink)
Emu author
 
@ruantec's Avatar
 
Join Date: Nov 2002
Location: Austria (originally from the most beautiful island of the caribbean "Dominican Republic")
Posts: 1,294
Looks like you progressed well since last time we talked about it

Directsound should be fine to reproduce the sounds and it works with Vista. i don´t know if you worked with directsound before.... but i think it shouldn´t be a problem for you
__________________

Current development tools:

Visual C++.net, Visual C#.net
Visual VB.net, Visual Webdeveloper.net
Bloodshed Dev C++, Borland C++
Visual Basic 6
@ruantec is offline   Reply With Quote
Old March 26th, 2008   #10 (permalink)
PCSX2 Coder
 
refraction's Avatar
 
Join Date: Jan 2004
Location: Plymouth, UK
Posts: 9,586
when i first made a chip8 emu with sound, i basically sent a load of rubbish in to the SDL buffer, but it made random buzzes, as the original system only had a buzzer, so it was no need to be impressive

altho my current (newest) one isnt quite as advanced as yours, it works pretty well, you can see it here with games and source ;p
RefChip8 - Chip8 Emulator
__________________

http://www.generalemu.net/
Intel Core 2 Quad Q6600 @ 3.4Ghz (425x8), eVGA 8800GTX 768mb, 996Gb HDs, 2Gb Corsair DDR2-800 @ DDR2-1020 5-5-5-18 Dual Channel, 14605 3dMark 06 Points
CPU-Z Link
3dMark06 Score Link
Dont PM me for help, use the forums, thats what its for!



refraction is offline   Reply With Quote
Old March 26th, 2008   #11 (permalink)
PCSX3 Coder
 
Phil's Avatar
 
Join Date: Oct 2007
Location: Maryland, where the big boys play.
Posts: 2,928
Ref i love the deflicker system.
Nice (if basic) emu though
__________________
Antec P182 Special Edition (Chrome Finish) : Intel e8400 : Thermaltake ToughPower 650 watt PSU : Corsair Dominater DHX 1066 DDR2 Ram : Asus P5K : 500 Gb Seagate : 74 GB Raptor : Samsung 20x DVD optical Drive : Soyo Topaz 24" LCD : Windows 95 : XFX 8800gt
Cooling: Swiftech Apogee GTX Special Edition (Copper Finish) : Feser X-Changer Dual 120mm Radiator : XSPC Bay Resevoir : Danger den Chrome Barbs : Feser UV anti kink 1/2" ID tubing : Danger Den D5

Phil is offline   Reply With Quote
Old March 26th, 2008   #12 (permalink)
Prototype
 
Shendo's Avatar
 
Join Date: Feb 2006
Location: Croatia
Posts: 3,666
@TheCloudOfSmoke: Thanks. Though it will take a lot of time before/if I even make something that can be measured with other emulators.

@blueshogun96: Thank you for the links, I'll check them out.
As for API it's GDI+. That probably is not suited for emulation but in this case I think it's ok.

@@ruantec-Man: Yeah I got rid of the most graphic glitches.

@refraction: Nice emu.
Shendo is offline   Reply With Quote
Old March 26th, 2008   #13 (permalink)
PCSX2 Coder
 
refraction's Avatar
 
Join Date: Jan 2004
Location: Plymouth, UK
Posts: 9,586
Quote:
Originally Posted by Phil View Post
Ref i love the deflicker system.
Nice (if basic) emu though
cheap as hell but i worked Chip8 is very simplistic, so it uses 1 frame to draw the sprites, then the next to clear them, then the next to draw them in the new location, etc.

Quote:
Originally Posted by Shendo View Post
@refraction: Nice emu.

thanks, i know its nothing special, but i literally threw it together for an australian magazine thingy, so budding authors have something to go off. But if it helps with your emu thats all that matters
__________________

http://www.generalemu.net/
Intel Core 2 Quad Q6600 @ 3.4Ghz (425x8), eVGA 8800GTX 768mb, 996Gb HDs, 2Gb Corsair DDR2-800 @ DDR2-1020 5-5-5-18 Dual Channel, 14605 3dMark 06 Points
CPU-Z Link
3dMark06 Score Link
Dont PM me for help, use the forums, thats what its for!



refraction is offline   Reply With Quote
Old March 26th, 2008   #14 (permalink)
Emu author
 
@ruantec's Avatar
 
Join Date: Nov 2002
Location: Austria (originally from the most beautiful island of the caribbean "Dominican Republic")
Posts: 1,294
Quote:
Originally Posted by refraction View Post
cheap as hell but i worked Chip8 is very simplistic, so it uses 1 frame to draw the sprites, then the next to clear them, then the next to draw them in the new location, etc.




thanks, i know its nothing special, but i literally threw it together for an australian magazine thingy, so budding authors have something to go off. But if it helps with your emu thats all that matters
i think we shouldn´t understimate a Chip8 emulator........ indeed is nothing special(in comparation to emulators for consoles etc) but if you think what we learn from it then you will realize is actually very special because most of us started with a chip8 emulator that help us get the idea how emulation works.
__________________

Current development tools:

Visual C++.net, Visual C#.net
Visual VB.net, Visual Webdeveloper.net
Bloodshed Dev C++, Borland C++
Visual Basic 6
@ruantec is offline   Reply With Quote
Old March 26th, 2008   #15 (permalink)
PCSX2 Coder
 
refraction's Avatar
 
Join Date: Jan 2004
Location: Plymouth, UK
Posts: 9,586
Quote:
Originally Posted by @ruantec-Man View Post
i think we shouldn´t understimate a Chip8 emulator........ indeed is nothing special(in comparation to emulators for consoles etc) but if you think what we learn from it then you will realize is actually very special because most of us started with a chip8 emulator that help us get the idea how emulation works.
that was the whole concept i worked on

i did intend on commenting it more but i couldnt be arsed lol. But the idea was keep it reasonably simple so people can work out for themselves how the emulator actually works.

can you see the copy and pasta from sdl tutorials? *hides*
__________________

http://www.generalemu.net/
Intel Core 2 Quad Q6600 @ 3.4Ghz (425x8), eVGA 8800GTX 768mb, 996Gb HDs, 2Gb Corsair DDR2-800 @ DDR2-1020 5-5-5-18 Dual Channel, 14605 3dMark 06 Points
CPU-Z Link
3dMark06 Score Link
Dont PM me for help, use the forums, thats what its for!



refraction is offline   Reply With Quote
Old March 26th, 2008   #16 (permalink)
Emu author
 
@ruantec's Avatar
 
Join Date: Nov 2002
Location: Austria (originally from the most beautiful island of the caribbean "Dominican Republic")
Posts: 1,294
"Copy and pasta" that was a good one anyways i think every chip8 emula8r is another step to a better emulation world

btw nice chip8 emu
__________________

Current development tools:

Visual C++.net, Visual C#.net
Visual VB.net, Visual Webdeveloper.net
Bloodshed Dev C++, Borland C++
Visual Basic 6
@ruantec is offline   Reply With Quote
Old March 26th, 2008   #17 (permalink)
PCSX2 Coder
 
refraction's Avatar
 
Join Date: Jan 2004
Location: Plymouth, UK
Posts: 9,586
thx ;p but really, i think it sucks it just does the job lol

ill appreciate it more if people learnt from it
__________________

http://www.generalemu.net/
Intel Core 2 Quad Q6600 @ 3.4Ghz (425x8), eVGA 8800GTX 768mb, 996Gb HDs, 2Gb Corsair DDR2-800 @ DDR2-1020 5-5-5-18 Dual Channel, 14605 3dMark 06 Points
CPU-Z Link
3dMark06 Score Link
Dont PM me for help, use the forums, thats what its for!



refraction is offline   Reply With Quote
Old March 27th, 2008   #18 (permalink)
NGemu's Kawaii Imoutochan
 
cottonvibes's Avatar
 
Join Date: Sep 2007
Location: Super Mario World
Posts: 2,475
cool emulators, i might try to make one for the learning experience as well. (well, thats after i become more familiar with c++ :/)


Shendo do you mind posting links to the documentation you used?
__________________
PC Specs: AMD X2 4400+ @ 2.921 Ghz, 1.47 vCore | G92 8800 GTS 512mb @ 740/1944| 4GB Dual Channel OCZ Memory @ 835 Mhz (5-4-4-15-2T) | 700 Watt PSU | DVD-RW Drive | 500 GB Hitachi SATA II Hard Drive, 30 GB & 40 GB Western Digital IDE Hard Drives | 1920x1080 40" LCD Flat Pannel HDTV monitor |
Consoles: 1 PS3 (60 GB), 2 PS2s, 1 PS, 3 GBAs, 1 GB, and 1 old school NES

Having troubles with PCSX2? Check out my guide to get it running correctly.
Running PCSX2 Guide for Noobs
cottonvibes is online now   Reply With Quote
Old March 27th, 2008   #19 (permalink)
Prototype
 
Shendo's Avatar
 
Join Date: Feb 2006
Location: Croatia
Posts: 3,666
Chip 8 instruction set
CHIP8 documentation by David Winter.

There is also a great thread at EmuTalk which contains a lot of information.
Shendo is offline   Reply With Quote
Old March 27th, 2008   #20 (permalink)
Shogun3D Interactive (TM)