-
Notifications
You must be signed in to change notification settings - Fork 49
ADPCM: fixed address checking on read/write #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ADPCM: fixed address checking on read/write #38
Conversation
Wow, thanks for that great analysis! I'm currently reshuffling the code to align better with what you've discovered so far. Once I get it working, I'll update the code so that we can adjust it from there. |
Thank you for your comment and seeing my memo even in Japanese. I'm happy that you will update the code with my analysis. The charts and memos are summarized from signal and register value (with some guessing). |
Do you have examples of systems/software that actually read or write data through the YM2608? (Or the YM2610?) I'd like to verify the reading and writing with live software if I can find some. |
Ok, I have made my first attempt. Please see the branch adpcm-test. Using a test program I seem to be matching your readings. I am unsure of a few things, such as:
You can try this code in your environment to see if it behaves the way you expect. |
I just pushed an update to the branch that tries to fix some of the flag behaviors. Are these correct assumptions? (I'm guessing from your diagrams):
|
I tried 0565762. I extracted the register access sequence for testing with real chip.
R10:$80 means write 0x80 to FLAG CONTROL REGISTER(0x10) to clear status (make all status flag to "0").
I cannot check in detail because of my environment (slow to read status quickly).
You can refer another analysis memo by KAJA.
No dummy write like behavior. I have logs and will create chart later.
I can check and will try. |
Ok thank you for the logs. I have made some updates. It seems EOS and PLAYING flags are sticky until reset by the chip. There are 3 chips that use the ADPCM-B engine: YM2608, YM2610, and Y8950. I have changed the behavior so that the chips need to explicitly reset these flags. See commit e2cd8df for a new update that matches your test behavior exactly, except for undocumented status flag 0x40, which I do not understand. |
I misunderstood your point as PCM outpu overflow. However, I have created PCM overflow test and captured signals. Reference:
Is it OK to continue this kind of topic on this PR...? |
Discussion on the PR is fine, or we can move to an issue instead if you prefer. |
…set for all chips. Fix write case where start address is written after command
It looks working fine. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've read read/write related code and added some comments.
I have not checked the actual behavior with test code.
So, I'm sorry if I misunderstand the logic.
src/ymfm_adpcm.cpp
Outdated
|
||
// otherwise, add two dummy samples | ||
else | ||
m_nibbles += 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 dummy data are same as last sample at STOP ADDRESS.
It may be stored on REG08.
Maybe nobody cares...
Reference:
https://github.com/hyano/opna-analyze/blob/main/log/mem_rw5_mden/mem_rw5.txt#L24
- READ ADDRESS 0fff-0xfff x 2
O10:00 O10:80 O00:20 O01:02 O02:FF O03:0F O04:FF O05:0F
RDF:48 RDF:48 <---- DUMMY READ
RA0:08 RA1:08 RA2:08 RA3:08 RA4:08 RA5:08 RA6:08 RA7:08
RA8:08 RA9:08 RAA:08 RAB:08 RAC:08 RAD:08 RAE:08 RAF:08
RB0:08 RB1:08 RB2:08 RB3:08 RB4:08 RB5:08 RB6:08 RB7:08
RB8:08 RB9:08 RBA:08 RBB:08 RBC:08 RBD:08 RBE:08 RBF:0C
RBF:08 RBF:08 <---- DUMMY READ
RA0:08 RA1:08 RA2:08 RA3:08 RA4:08 RA5:08 RA6:08 RA7:08
RA8:08 RA9:08 RAA:08 RAB:08 RAC:08 RAD:08 RAE:08 RAF:08
RB0:08 RB1:08 RB2:08 RB3:08 RB4:08 RB5:08 RB6:08 RB7:08
RB8:08 RB9:08 RBA:08 RBB:08 RBC:08 RBD:08 RBE:08 RBF:0C
O00:00 O10:80
O00:01 O00:00
Note:
Rxx:yy means read xx from REG08 and STATUS1 was yy.
STATUS1 is cleared after every Rxx:yy by writing 0x80 to REG10.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was easy to do. I actually think it is not the byte from the stop address, but the last data that was processed.
src/ymfm_adpcm.cpp
Outdated
} | ||
|
||
// register 8 writes over the bus under some conditions | ||
else if (regnum == 0x08) | ||
{ | ||
// if writing from the CPU during execute, clear the ready flag | ||
if (m_regs.execute() && !m_regs.record() && !m_regs.external()) | ||
m_status &= ~STATUS_BRDY; | ||
set_reset_status(0, STATUS_BRDY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not checked this behavior of BRDY.
What I confirmed was that
writing 0x80 into REG10 during playback clears BRDY status and it keeps "0" .
Maybe nobody cares...
- BRDY is "1"
- write 0xa0 to REG00 -- start playback
- write 0x80 to REG10 -- BRDY becomes "0"
- write 0xa1 to REG00 -- stop playback, BRDY keeps "0"
- write 0x80 to REG10 -- BRDY keeps "0"
- write 0x00 to REG00 -- BRDY becomes "1"
New commit on this branch makes all the tests in https://github.com/hyano/opna-analyze/blob/main/log/mem_rw_mden/mem_rw.txt match except for the first two dummy reads in "READ ADDRESS 0fff- CHANGE STOP" -- I do not understand why those would read $08. |
I checked where dummy read data came from. Below are the results of the experiment with some parameters.
I also experimented with checking DUMMY READ after writing too much data with REPEAT=1.
After writing at STOP ADDRESS, it appears to switch to reading even if CPU is writing to REG $08. |
Ok, if you grab the latest adpcm-test branch, it should produce matching results for all the cases you mention above. ade388d I also checked in a C++ version of your rw13/14/15 tests that I used to test it out. |
At this point, I have created a new PR for all this work: #40 Let's move any further discussion over there and close out this PR. |
@aaronsgiles Thanks for merging #35 .
We have changed the definition of at_end() and at_limit() in #33 (comment) .
So, we need to modify the address checking not only on clock(), but also on read()/write().
Please check this patch.
P.S.
I have resumed verification of real YM2608's ADPCM.
https://github.com/hyano/opna-analyze/blob/main/doc/OPNA.md
If I can find the internal behavior I will try to implement and send you another PR.