Description

The YM2149 SPI Flash example shows how to use the YM2149 audio chip that is connected to the ZPUino Soft Processor on the Papilio FPGA hardware.

The YM2149 chip is a popular chiptune device that was used in several classic computing/gaming systems. Some of the better known systems include:

  • Atari ST
  • ZX Spectrum 128
  • Intellivision

This example sketch shows how to convert a YM file into a data file that can be loaded to the Papilio's SPI Flash file using the smallfs file system. The converted file then becomes available to be played in an endless loop without any dependency on a computer.

(:youtube sbCybapnKTw width=560 height=349:)

There are vast repositories of ym files that provide 8-bit audio goodness to be found with a little googling.

Supported Hardware

Downloads

Usage

  • Download the latest version of the ZPUino IDE.
  • Download the latest version of the Papilio Sketches and extract them to a folder of your choice.
  • Open the ZPUino IDE and then select the sketch from the sketch directory Audio/YM2149_SPI_Flash.
  • Ensure that you have the ZPUino "Apollo" variant bit file (see download section) that includes the YM2149 audio chip loaded to your Papilio. (We recommend loading it to SPI Flash.)
  • Ensure your MIDI Audio Wing or MegaWing is connected to the Papilio.
  • Plug your Papilio into a USB port.
  • Set the Board Type to the correct board according to what you have.
    • For Papilio One 250K select: "ZPUino on Papilio One (250) board"
    • For Papilio One 500K select: "ZPUino on Papilio One (500) board"
  • Select the Serial Port in the ZPUino IDE.
  • In the code of the sketch you need to define what kind of hardware you are using. There are pre-defined sections for the supported hardware, you will need to check and see that the section that defines your hardware us uncommented.
    • For MIDI-Audio Wing make sure this section is uncommented:(:source lang=c :)
  1. define AUDIOPIN WING_C_8 //For Audio-MIDI Wing connected to CH
  2. define AUDIOPINEXTRA WING_C_9

(:sourcend:)

  • For Arcade MegaWing make sure this section is uncommented:(:source lang=c :)
  1. define AUDIOPIN WING_A_15 //For Arcade MegaWing
  2. define AUDIOPINEXTRA WING_A_13

(:sourcend:)

  • For Audio Wing make sure this section is uncommented:(:source lang=c :)
  1. define AUDIOPIN WING_A_7 //For Audio Wing connected to AL

(:sourcend:)

  • Press the Upload Icon (this will load an already converted ym file).

(Optional) If you want to convert and load your own ym files:

  • Navigate to the examples/ZPUino/Audio/YM2149_SPI_Flash folder.
  • Use the ym files from the ym_files folder or your own ym files.
  • Drag and drop a ym file onto the convert_ym.bat file. (Sorry Linux users, no script file yet.)
  • This will convert the ym file into an audio.dat file in the smallfs directory. Depending on how big your SPI Flash chip is you may need to edit this the audio.dat file to be less then 128KB. If the file is too big you will see an error in the ZPUino IDE when you try to load the sketch.
  • Press upload in the ZPUino IDE to load the new ym file to flash and start playing it.

Reference

Technical Details

The YM2149 vhdl file is an open source recreation of the original YM2149 that was created by the good people at FPGAArcade.com by studying the datasheets and characteristics of actual hardware. Originally used for the VHDL recreations of games like Frogger. Inspired by projects like this one where people physically connected YM2149 chips to the Arduino we decided to make a streamlined ZPUino solution that does not require soldering or use up GPIO pins. Shaz and Alvie ported the chip to a wishbone compatible core that can plug into the ZPUino architecture, providing direct register access without using any of the ZPUino GPIO pins. The power of the ZPUino and the large code base of the Arduino allowed cool applications like this player, a streamer, and a MIDI controlled YM2149 synth to be easily and quickly realized!

Attribution

  • ZPU team for Soft Processor that is the base for the ZPUino.
  • Arduino team for the IDE and Open Source example to learn from.
  • Alvaro Lopes for his amazing work with the ZPUino.
  • MikeJ at FPGAArcade.com for making the YM2149 VHDL files Open Source.
  • Shaz for providing the momentum to port the YM2149 to a wishbone core.
  • Jack Gassett and the Papilio team for the Open Source FPGA hardware and examples.
  • Leonard for the ymtool application used to convert ym files.
  • Sergey Bulba for Delphi source for YMDump tool.

License

The example code and documentation is released under a Creative Commons Attribution license. Please use the code any way you want but do the right thing and mention the ZPUino, Papilio, and FPGAArcade if you are porting this project to other hardware. (Yes, we are looking at you Cyber Cortex.)

The source code for the ZPUino is released as BSD style license.

The source code for the YM2149 core is released as GPL.

Please drop us a line if we are missing any attribution or have any licenses wrong.

  

Share |