Giter VIP home page Giter VIP logo

jtopl's Introduction

JTOPL FPGA Clone of Yamaha OPL hardware

(c) Jose Tejada. You can show your appreciation by supporting Patreon releases.

JTOPL is an FM sound source written in Verilog, fully compatible with YM3526. This project will most likely grow to include other Yamaha chips of the OPL family.

Using JTOPL in a git project

If you are using JTOPL in a git project, the best way to add it to your project is:

  1. Optionally fork JTOPL's repository to your own GitHub account
  2. Add it as a submodule to your git project: git submodule add https://github.com/jotego/jtopl.git
  3. Now you can refer to the RTL files in jtopl/hdl

The advantages of a using a git submodule are:

  1. Your project contains a reference to a commit of the JTOPL repository
  2. As long as you do not manually update the JTOPL submodule, it will keep pointing to the same commit
  3. Each time you make a commit in your project, it will include a pointer to the JTOPL commit used. So you will always know the JTOPL that worked for you
  4. If JTOPL is updated and you want to get the changes, simply update the submodule using git. The new JTOPL commit used will be annotated in your project's next commit. So the history of your project will reflect that change too.
  5. JTOPL files will be intact and you will use the files without altering them.

Features

The implementation tries to be as close to original hardware as possible. Low usage of FPGA resources has also been a design goal.

Accuracy

  • Follows Y8950 block diagram by Yamaha
  • Barrel shift registers used for configuration values
  • Takes note of all known reverse engineered information, particularly die shots
  • Accurate at sample level, and at internal cycle clock where reasonable
  • Original architecture kept as much as possible

Some reference works used:

Modern Design for FPGA

  • Fully synchronous
  • Clock enable input for easy integration
  • Avoids bulky multiplexers

Directories:

  • hdl -> all relevant RTL files, written in verilog
  • ver -> test benches
  • ver/verilator -> test bench that can play vgm files

Usage

Although many files are shared, each chip has its own top level file to instantiate. There are YAML files for each one that detail the list of files used for each file. These files can be easily converted to whatever format you need, like .qip.

Not all the chips of OPL series are implemented yet, so take the following table as a plan which I am working on.

Chip Top Level Cell YAML file Type Patches Implemented Usage
YM3526 jtopl.v jt26.yaml OPL Yes Bubble Bobble
YM3812 jtopl2.v jtopl2.yaml OPL2 Yes Robocop
Y8950 jt8950.v jt8950.yaml OPL+ADPCM Not yet MSX-Audio
YM2413 jt2413.v jt2413.yaml OPL-L Yes WIP Pang!
YM2423 - - OPL-LX Yes No plans Atari ST FM cart
YMF281 - - OPL-LLP Yes No plans Pachinko
YMF262 jt262.v jt262.yaml OPL3 Not yet

Chip differences

Chip Type EG bits Features
YM3526 OPL 9? Basic OPL
YM2413 OPLL 7 Removes depth options for vibrato/tremolo
Y8950 OPL+ADPCM 9? Adds ADPCM
YM3812 OPL2 9? Adds waveform select. Four waveforms
YMF262 OPL3 9 No CSM. More operator modes, more channels

Simulation

There are several simulation test benches in the ver folder. The most important one is in the ver/verilator folder. The simulation script is called with the shell script go in the same folder. The script will compile the file test.cpp together with other files and the design and will simulate the tune specificied with the -f command. It can read vgm tunes and generate .wav output of them.

Tested Features

Each feature is tested with a given .jtt file in the ver/verilator/tests folder.

Feature JTT File Status (commit) Remarks
TL TL
EG rates rates
fnum fnum_abs Passed 4a2c3cc Checks absolute value of a note
FB fb Passed 6e6178d
connection mod
EG type perc
All slots slots no modulation
All slots slots_mod Modulate some channels
KSL ksl1/2/3 Passed 4a2c3cc See note*
AM am Passed fc6ad19
Vibratto vib Passed 44a540f
CSM Not implemented
OPL2 waves tone_w? Passed Implemented
Keyboard split Untested b4345fa Not implemented

Note* values don't match the app notes but implementation follows reverse engineering of OPLL and OPL3. Measuring from first note of an octave to last note of the next seems to fit better the table in the notes.

Rhythm Instruments

They are bass drum, snare drum, tom-tom, high-hat, cymbals and top cymbals. Channels 6,7 and 8 are used for these instruments.

For patch-based OPL chips, there were specific values for each operator register of these instruments. However, for non-patched synthesizers, the user still had to enter register values. So it looks like the benefit from the rhythm feature was:

  • Ability to enter more than one key-on command at once
  • Noisy phase for three instruments
  • Forced no modulation on 5 five instruments
Short name Instrument Slot Phase EG Modulation
BD Bass drum 13 & 16 Drum Normal
HH High hat 14 Special Drum No
TOM Tom tom 15 Drum No
SD Snare drum 17 Special Drum No
TOP-CYM Top cymbal 18 Special Drum No

Related Projects

Other sound chips from the same author (Verilog RTL)

Chip Repository
YM2203, YM2612, YM2610 JT12
YM2151 JT51
YM3526 JTOPL
YM2149 JT49
sn76489an JT89
OKI 6295 JT6295
OKI MSM5205 JT5205

Cycle accurate FM chips from Nuked (software emulation)

Chip Repository
OPLL Nuked-OPLL
OPL3 Nuked-OPL3
YM3438 Nuked-OPN2

jtopl's People

Contributors

gyurco avatar jotego avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jtopl's Issues

Volume issue in MiSTer cores

Hi, Thanks a lot for this great opl implementation :).

I noticed some opl/opl2 tunes from a lot of games do not sound as the original ones.

For example the music from terra cresta:
1 - Recorded from MiSTer core): Terra cresta_JTOPL.zip
2 - Original (vgmrips.net) click on "02 theme of terracresta": https://vgmrips.net/packs/pack/terra-cresta

I noticed the drums have very low volume on jtopl.

This opl implementation has been included in the pcxt core, so I made a vgm player for 8088 cpu, and the result is the same. I found a lot of themes with low volume drums, all of them seem to use the "percussion mode" of ym3526 (terra cresta) and also ym3812.

In percussion mode, the chip can output 6 melodic instruments and 5 percussion ones (which seem to output wrong, or at very low volume in the cores).

Another example is the Wacky Wheels intro theme (ym3812):
1 - Recorded from PCXT core, sorry this also has some clicks and noises, I don't know if this is a problem of the core, or the opl: WWHeels_JTOPL.zip
2 - Original (vgmrips.net) click on "02 Dream": https://vgmrips.net/packs/pack/wacky-wheels-ibm-pc-at

Thanks!.

jtopl.f missing

First of all thanks for making this project and releasing it, is really great.

When playing around with the verilator vgm player, I noticed that the jtopl.f file is missing from the hdl directory.
Both gather.f and jtlopl2.f still refer to this file.

I was able to get things running again by checking out the jtopl.f file from a previous commit.

It seems like commit 8d02416 removed this file.

I assume this was by mistake as it was added explicitly in commit a38aeac.

Timer immediately overflows when 0xff is loaded into it

As soon as 0xff is loaded, overflow will be 1, and at the next cycle, flag will be 1, too.
Changing the flag setting condition fixes it (if it has to be fixed)

else if( cenop && zero && load && overflow) flag<=1'b1;

Also it makes the Adlib detection code in Wolf3d work:
https://github.com/id-Software/wolf3d/blob/05167784ef009d0d0daefe8d012b027f39dc8541/WOLFSRC/ID_SD.C#L1585

I think this bug also makes the timer to fire the irq one count earlier and correcting this will have an effect to the free-running counter, as in your comment:

// Free running counter, resetting
// the value of this part with the load
// event can slow down music, vg Bad Dudes

Plus: are you sure flagen only masks the IRQ, not 'load' (e.g. doesn't stop the timer?)

Bad assignments

Reported by e-mail. This probably refers to 2a44a7f

That commit features the single-cycle write on channels. It causes problems in cores so jtcores is using an earlier commit. This issue report might be related to that.

ERROR:Xst:880 - "jtopl_reg_ch.v" line 108: Cannot mix blocking and non
blocking assignments on signal .
ERROR:Xst:1468 - "jtopl_pg_sum.v" line 39: Unexpected event in always
block sensitivity list.
ERROR:Xst:902 - "jtopl_eg_final.v" line 41: Unexpected ksl_lut event
in always block sensitivity list.

These are minor and are easy to get around...
"jtopl_reg_ch.v"... I just remove line 108

"jtopl_pg_sum.v"... I replace the reg by a wire outside the always block
wire [21:0] phinc_mul = { 5'b0, phinc_pure} * factor[mul];

"jtopl_eg_final.v"... same, I use a wire instead of reg
wire [ 7:0] ksl_base = {1'b0, ksl_lut[fnum]}- { 1'b0, 4'd8-{1'b0,block}, 3'b0 };

Wrong sounds

I've tried to put this OPL2 code to the Next186 SOC here:
https://github.com/gyurco/Next186/tree/jtopl

As this is much more resource-friendly than the original, it looks a great replacement. However there are some issues:

  • sounds are often missing if the CPU writes too fast. That might be not a jtopl2 issue, but the game itself doesn't prepared for fast CPUs. However the original has a kind of FIFO between the CPU and the opl3 (reminds me of the Genesis core). Is it possible somehow to expose a 'busy' bit for implementing such FIFO?
  • some sounds are wrong even if the CPU is slowed down. Example: Buzz Aldrin's Race Into Space. There's a 'ringing' sound where it shouldn't. I can try to export from Dosbox to VGM to check if it helps.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.