ATARI POKEY 8-bit Computer Sound on PIC32

A place to document your own projects.

ATARI POKEY 8-bit Computer Sound on PIC32

Postby Markus Gritsch » Thu Apr 19, 2012 1:48 pm

Hi,

I successfully compiled the ASAP (Another Slight Atari Player) library [1] for a PIC32MX795F512H. ASAP emulates a 6502 CPU and the famous POKEY sound chip [2] used for example in the ATARI 400/800 and XL/XE 8-bit computers. To say it with Wikipedia's words: POKEY's sound is distinctive :)

About 60 tunes (worth about 2.5 hours of music) taken from ASMA (Atari SAP Music Archive) [3] are included and stored in the PICs flash memory. D0 is the left and D1 the right PWM channel.

Please find the source code attached below.
The YouTube video can be found here: http://www.youtube.com/watch?v=_CnZ0_yxOpo

[1] http://asap.sourceforge.net/
[2] http://en.wikipedia.org/wiki/POKEY
[3] http://asma.atari.org/
Attachments
asap_2012-04-18.zip
(1.42 MiB) Downloaded 495 times
IMG_1052.JPG
User avatar
Markus Gritsch
Sr. Member
Sr. Member
 
Posts: 265
Joined: Tue Feb 09, 2010 6:54 am

Re: ATARI POKEY 8-bit Computer Sound on PIC32

Postby hak8or » Fri Apr 20, 2012 12:49 am

Awesome! :) The youtube video of it playing is really good, the audio quality specifically. Are you doing direct audio to the computer, or is it speakers to camera?

Very old school, reminds me of playing spider man games on the game boy color, heh. Pokemon also had some really good tunes, especially one of the radio's, though I forget if that was in Pokemon silver on the GBC or Pokemon saphire on the GBA:SP. I am sadly too young to have experienced the joys of the Atari.

A few questions though, it looks the silkscreen is rather packed in places, for example the GND ---- and V+/3.3v---- lines seemed to be really smushed, and the power on the left ontop of the hole. Did you use eagle, diptrace, or something else? It also seems like you did not seem to worry much about PCB size, I am guessing you did not go with batchpacb or dorkbot?
How did you fit all the songs onto the pic? I presume not trying to put the MP3's on the pic, but instead using different "algorithms" for the POKEY sound chip?

Again, awesome board. :) It looks extremely professional, especially the labeling of everything, congrats!
hak8or
Full Member
Full Member
 
Posts: 239
Joined: Mon Jun 06, 2011 11:06 pm

Re: ATARI POKEY 8-bit Computer Sound on PIC32

Postby Markus Gritsch » Fri Apr 20, 2012 3:54 am

@hak8or: IMO the audio quality of the video is not very good. At least the actual audio quality of the hardware sounds much better. For the video it is speaker to iPhone :)

The board is a general purpose PIC32MX795F512H board I made quite some time ago. I did not make it specifically for this project. It is made using Eagle and I used the BatchPCB service. It is open hardware, and you can find the latest version here: http://code.google.com/p/cui32/source/b ... CUI32Stem/
Seeed is also selling it here: http://www.seeedstudio.com/depot/cui32stem-p-1100.html

If you reread the original posting, you will find that there are no MP3s being played back, but the actual 6502 code is run on an emulated 6502 CPU and the sound is rendered by an emulated POKEY sound chip.
User avatar
Markus Gritsch
Sr. Member
Sr. Member
 
Posts: 265
Joined: Tue Feb 09, 2010 6:54 am

Re: ATARI POKEY 8-bit Computer Sound on PIC32

Postby Markus Gritsch » Tue Jun 12, 2012 7:44 am

Hi,

some time ago Ian was so kind and sent me a free QFP proto board [1], and now here is my "free PCB build" of it :) The build instructions and part list for the free PCB were a bit vague, until I figured out that it was meant to be a POKEY player ;)

IMG_6407.JPG

Joking aside, there are one or two things which could be improved on the QFP board: The "fixed" pads of the QFT footprint (on the two sides where the pins of the IC are placed regardless of the pin count used) are a bit short, so heating them up with the soldering iron is a bit hard. Also the holes in the proto-area are quite small. I had to make most of them bigger with a fret saw, which was a bit painful, but doable.

The stereo headphone jack is located at the top left side next to the blue potentiometer which is used to digitally control the volume. A small power switch and the Pause/Play button is at the top right side. The other two buttons select the Next/Previous tune. About 60 tunes worth of over 2 hours of music are stored in the 512 kB flash memory of the PIC32.

The headphones are driven directly with a 38 kHz PWM. Two Schottky diodes are used to cut off the negative spikes from the headphone coils. To decouple the audio output from the quite noisy supply voltage (caused by heavy MCU switching), a 74LS32 logic IC is provided with its own 3.0 V LDO regulator. This way a very clean and noise free audio signal is achieved.

schematic.jpg

The board is supplied via the ICSP pins by directly connecting a LiPo battery [2]. When fully charged, the voltage is a bit higher than the maximum supply voltage specified in the PIC32 data sheet, but it seems to be not an issue in practice. The LiPo is held in place by a double sided sticky tape, and protected from the PCB soldering joints by a thin plastic foil. For ergonomic reasons I screwed some foam rubber onto two nuts which I soldered to the PCB beforehand.

IMG_6410.JPG

IMG_6403.JPG


As always, the source code and the full schematic is attached in the .zip file. (P.S.: After discovering not just one but two (!) bugs in the 'C32 v2.0x' and 'XC32 v1.00' compilers (already approved by Microchip and hopefully being fixed in a future release) I went back to the 'C32 v1.10(B)' compiler and the old MPLAB IDE, which also feels faster and snappier compared to the new MPLAB X IDE written in Java.)

A YouTube video is available here: http://youtu.be/PmmKpeFzlGQ

Have fun,
Markus

[1] http://www.seeedstudio.com/depot/qfp-su ... p-786.html
[2] http://www.seeedstudio.com/depot/lithiu ... p-593.html
Attachments
asap_2012-05-27.zip
(975.03 KiB) Downloaded 263 times
User avatar
Markus Gritsch
Sr. Member
Sr. Member
 
Posts: 265
Joined: Tue Feb 09, 2010 6:54 am

Re: ATARI POKEY 8-bit Computer Sound on PIC32

Postby Sleepwalker3 » Sun Jun 17, 2012 5:55 am

Hi Markus, sounds pretty cool. Does this emulate all of the 6502 instructions, or just a select set of things?
User avatar
Sleepwalker3
Hero Member
Hero Member
 
Posts: 505
Joined: Mon Jan 16, 2012 4:12 am
Location: Down Under

Re: ATARI POKEY 8-bit Computer Sound on PIC32

Postby Markus Gritsch » Mon Jun 18, 2012 12:48 am

I did not write the ASAP library, but you can take a look yourself in the function Cpu6502_DoFrame() in the file asap.c, and see if the instructions you need are handled.
User avatar
Markus Gritsch
Sr. Member
Sr. Member
 
Posts: 265
Joined: Tue Feb 09, 2010 6:54 am

Re: ATARI POKEY 8-bit Computer Sound on PIC32

Postby Squonk » Mon Jun 18, 2012 5:18 am

@Sleepwalker3: if you are looking for a proven 6502 emulation, you may check CPU.c/CPU.h and the whole CPU subdir from the AppleWin project:
http://svn.berlios.de/wsvn/applewin/tru ... urce/CPU.h
http://svn.berlios.de/wsvn/applewin/tru ... ce/CPU.cpp
http://svn.berlios.de/wsvn/applewin/tru ... ource/CPU/

Or the simpler/older one from linapple:
http://linapple.sourceforge.net/
Squonk
Jr. Member
Jr. Member
 
Posts: 94
Joined: Sun Apr 10, 2011 3:23 pm

Re: ATARI POKEY 8-bit Computer Sound on PIC32

Postby ian » Wed Jun 20, 2012 1:48 am

Thanks for sharing and the feedback on the breakouts, we'll update the boards.
User avatar
ian
Crew
Crew
 
Posts: 10499
Joined: Mon Jul 06, 2009 6:14 am

Re: ATARI POKEY 8-bit Computer Sound on PIC32

Postby Markus Gritsch » Wed Jun 20, 2012 6:10 am

Sleepwalker3 wrote:Hi Markus, sounds pretty cool. Does this emulate all of the 6502 instructions, or just a select set of things?

Piotr Fusik, the author of the ASAP library just wrote in: According to him, it emulates all 6502 opcodes, including the undocumented ones. In the 1990s he spent much time reverse-engineering the undocumented instructions, he says :)
User avatar
Markus Gritsch
Sr. Member
Sr. Member
 
Posts: 265
Joined: Tue Feb 09, 2010 6:54 am


Return to Project logs