aaronsgiles / ymfm

BSD-licensed Yamaha FM sound cores (OPM, OPN, OPL, and others)
BSD 3-Clause "New" or "Revised" License
259 stars 40 forks source link

ADPCM: fixed end/limit address checking and reading external data #31

Closed hyano closed 2 years ago

hyano commented 2 years ago

This patch fixes checking of end and limit addresses in ADPCM.

In the original implementation, loop playback of ADPCM sound was sometimes incorrect because the limit address checking was done first and it changed the data address to 0.

aaronsgiles commented 2 years ago

I like that this gets rid of the dummy reads. Can you point me to some examples I can look at to see this behavior?

hyano commented 2 years ago

@aaronsgiles Thenks for your reply.

Sorry, I cannot show good examples immediately. And sorry this PR contains multiple fixes.

The idea for "dummy read" implementation using read buffer is taken from "fmgen". Fmgen is old&good FM sound engine for M88 which is an old NEC PC-88 emulator. Module version of fmgen is distributed on http://retropc.net/cisc/sound/.

I don't know the actual circuit in the chip, but I feel fmgen's implementation which has 2 bytes internal read buffer is reasonable based on YM2608's application manual (Japanese version). RAM/ROM-READ (外部メモリ(external memory) -> OPNA -> CPU):

YM2608 was used for Japanese PC (PC88/98) and users transfered data between CPU and OPNA/RAM. M88 team researched the behavior of real PC and implemented it when M88 development was active. That's another reason why I think the implementation for this area is good for many sowfwares.

I wish I still had real HW, I could confirm...

aaronsgiles commented 2 years ago

Can you please split these fixes into separate PRs? I would like to consider them independently.

Are you using ymfm in a project? I don't know of good examples for the dummy read case, but it seems that you must have some reason why you think it should be changed. :)

hyano commented 2 years ago

Can you please split these fixes into separate PRs? I would like to consider them independently.

I have small dependency concerns. These are the reason why this PR contains 3 changes.

Anyway I'll try to split and reorder.

Are you using ymfm in a project? I don't know of good examples for the dummy read case, but it seems that you must have some reason why you think it should be changed. :)

Yes, I am using ymfm in my private emulation project (non-commercial) and found current ADPCM implementation doesn't work well for some titles.

Ymfm is excellent. Very thanks for your work!

hyano commented 2 years ago

I've split this PR into new 3 PRs.

But creating PR for dummy read is pending, because:

It's OK to reject this PR and continue on #33, #34, #35.

aaronsgiles commented 2 years ago

Thanks, I'll consider the others individually now.