Viewing Issue Advanced Details
ID Category [?] Severity [?] Reproducibility Date Submitted Last Update
07378 Sound Major Always Jul 17, 2019, 01:59 Sep 1, 2022, 09:18
Tester trebor View Status Public Platform MAME (Official Binary)
Assigned To Resolution Fixed OS
Status [?] Resolved Driver
Version 0.211 Fixed in Version 0.247 Build 64-bit
Fixed in Git Commit ffc0db2 Github Pull Request #
Summary 07378: pokey.cpp: Inaccurate distortion playback.
Description The issue arise when using some distortions values in either 8-bit or 16-bit modes.
When using the pure tone setting (AUDC0=$Ax or $Ex) it sounds fine; however sound problems are present when using other distortion settings on AUDC0.
Values from $2x and $Cx (12a and 12b) in the attached spreadsheet (See zip archive file 'pokey notes.zip'), provides inaccurate results every time.
Steps To Reproduce The issue occurs for any platform utilizing POKEY chip in the ways mentioned in the aforementioned "Description" field.
Nonetheless, A7800 examples are provided in this report. Just load the ROM(s) contained in the zip archive(s) and playback accordingly.
Take note of the real hardware POKEY captures compared to what is heard for POKEY emulation under MAME from the wav files provided.
Additional Information Complete POKEY note table for all distortion settings:
https://atariage.com/forums/topic/216807-complete-pokey-note-table-for-all-distortion-settings/?do=findComment&comment=4315649

A good explanation of the $Cx distortion in POKEY:
https://atariage.com/forums/topic/212280-pokey-question-distortion-12-donkey-kong-bass/

More details and test file cases:
https://atariage.com/forums/topic/293427-pokey-16-bit-mode-and-other-audctl-settings-a7800-emulation/
Github Commit
Flags Verified with Original
Regression Version Always present(?)
Affected Sets / Systems pokey.cpp
Attached Files
zip file icon A7800_AtariAgeJingle_ROMs.zip (2,299 bytes) Jul 17, 2019, 02:03 Uploaded by trebor
ROM files
zip file icon atariage-jingle (20190708) Real HW.zip (2,038,971 bytes) Jul 17, 2019, 02:03 Uploaded by trebor
Real hardware playback of ROM files (x3)
zip file icon atariage-jingle (20190708) MAME 0_211.zip (2,449,664 bytes) Jul 17, 2019, 02:04 Uploaded by trebor
MAME 0.211 playback of ROM files (x3)
zip file icon pokey notes.zip (16,221 bytes) Jul 17, 2019, 02:05 Uploaded by trebor
Frequency values from a POKEY note table, mapped out using actual hardware.
zip file icon Arkanoid2LevelStartSoundDemo.zip (760,042 bytes) Jul 24, 2019, 18:01 Uploaded by trebor
POKEY 8-bit mode sample: Channels 0 and 1 are the lead sound, with SKCTLS put into two tone mode. Channel 2 is $CX base in 8-bit mode. Channel 3 is $AX lead detuned.
zip file icon RollingThunderIntroMelody.zip (3,512,470 bytes) Aug 14, 2019, 00:42 Uploaded by trebor
A rendition of the opening level theme from Namco's Rolling Thunder - See Notes below for more details.
Relationships
related to 08219Resolved  a800xl: Bass voice missing in "Zybex" game music. 
Notes
13
User avatar
No.16687
trebor
Tester
Jul 24, 2019, 18:03
Another sample/test case provided. It is a POKEY sound demo/sample of the Level Start theme of the game Arkanoid 2. The archive file uploaded 'Arkanoid2LevelStartSoundDemo.zip' includes two ROM files (*.BIN and *.A78) as well as two recorded clips. One recording taken from an Atari 7800 console and the other running under MAME.
User avatar
No.16750
trebor
Tester
Aug 13, 2019, 23:56
edited on: Aug 13, 2019, 23:59
At least part of the problems is SKCTL two-tone mode is broken.
This constant is defined for the relevant bit in SKCTL...

#define SK_FM 0x08 /* FM mode */

...but none of the MAME code base uses SK_FM at all.

Additionally, while many MAME devices normally get defined with clocks up front. In this mode, the second voice gets the regular clock, and the first voice is clocked by the second voice's output.
User avatar
No.16751
trebor
Tester
Aug 14, 2019, 00:46
edited on: Aug 14, 2019, 00:53
Regarding the attachment zip for the rendition of the opening level theme from Namco's Rolling Thunder:

Channel layout is as follows:
Channel 0: $8x distortion, 9-bit polycounter, 16-bit mode, clocked at 1.79 mhz - guitar lead
Channel 1: silent. Frequency set to 0.
Channel 2 $Cx distortion, saw wave, no modulation - bass channel
Channel 3 $Ax distortion, square wave, no modulation - accompaniment

AUDCTL is set to $D0 ... engaging the 9-bit poly-counter, 16-bit mode on channels 0 and 1, and clocking channel 0 at 1.79 MHz. Unlike other 16-bit examples, in this case channel 0 is played while channel 1 is silenced, and the frequency set to a constant 0. This is a mostly undocumented POKEY setting.
User avatar
No.16752
Haze
Senior Tester
Aug 14, 2019, 10:17
is this a recent regression, or has MAME always been this way?
User avatar
No.16759
trebor
Tester
Aug 16, 2019, 01:52
Wouldn't state it is necessarily a "recent" regression, as the same POKEY issues exist under MAME 0.162.
However, POKEY sounds better under MESS 0.120, for at least the Rolling Thunder example, so it wasn't "always" as bad as it is now.
User avatar
No.16764
trebor
Tester
Aug 16, 2019, 23:25
edited on: Aug 17, 2019, 01:53
Better breakdown respecting the 3 sample files provided:

AtariAge Jingle = Wrong on MAME 0.211 & MAME 0.162. Correct under MESS 0.120.
Rolling Thunder Intro = Wrong on MAME 0.211 & MAME 0.162. Correct under MESS 0.120.
Arkanoid 2 Level Start = Wrong on MAME 0.211, MAME 0.162, and MESS 0.120.

The short of it is while there has 'always' been some thing(s) inaccurate, it has become worse over time.

*EDIT: I recently realized MAME 0.162 coincidentally was the 'merger' version. So, I tried MESS 0.161. Same results as with MAME 0.162. That at least eliminates anything to do with the merger of the project(s).

EDIT 2: Narrowed down the playing field some more... MESS 0.130 and 0.140 both same as MESS 0.120.
MESS 0.150 same as recent MAME. So, we're down to change(s) sometime between MESS 0.140 and MESS 0.150 that made things worse.

EDIT 3: MESS 0.145 sounds same as MESS 0.120. We're down to updates between MESS 0.145 and MESS 0.150.
User avatar
No.16765
trebor
Tester
Aug 17, 2019, 02:20
edited on: Aug 17, 2019, 02:28
Identified when POKEY audio emulation became worse:

MESS 0.145u8 (Dated 2012/05/07) = Last 'better' POKEY audio emulation version.

MESS 0.146 (Dated 2012/05/21) = Worse POKEY audio emulation - same as recent versions of MAME.

Whatever change(s) took place after MESS v0.145u8 until MESS 0.146 made POKEY emulation worse.

Again, issue(s) "always" existed. I tested as far back as MESS 0.100 and the Arkanoid 2 Level Start sound demo is still wrong, but the other two sound demos tested fine.

Reference guide on what is being leveraged for each of the three demos:

Arkanoid 2 Level Start: "Always" inaccurate:
8-bit mode.
Channels 0 and 1 are the lead sound, with SKCTLS put into two tone mode
Channel 2 is $CX base in 8-bit mode
Channel 3 is $AX lead detuned ...
SOURCE: https://atariage.com/forums/topic/293427-pokey-16-bit-mode-and-other-audctl-settings-a7800-emulation/?do=findComment&comment=4314567


AtariAge Jingle: Fine MESS 0.145u8 and earlier - Inaccurate MESS 0.146 through recent MAME:
Using AUDC0=$2x for the lead sound while $Ax in 8-bit mode does the remaining two voices.
SOURCE: https://atariage.com/forums/topic/293427-pokey-16-bit-mode-and-other-audctl-settings-a7800-emulation/?do=findComment&comment=4311327

Rolling Thunder: Fine MESS 0.145u8 and earlier - Inaccurate MESS 0.146 through recent MAME:
Channel layout is as follows:
Channel 0: $8x distortion, 9-bit polycounter, 16-bit mode, clocked at 1.79 mhz - guitar lead
Channel 1: silent. Frequency set to 0.
Channel 2 $Cx distortion, saw wave, no modulation - bass channel
Channel 3 $Ax distortion, square wave, no modulation - accompaniment

AUDCTL is set to $D0 ... engaging the 9-bit poly-counter, 16-bit mode on channels 0 and 1, and clocking channel 0 at 1.79 mhz. Unlike other 16-bit examples, in this case channel 0 is played while channel 1 is silenced, and the frequency set to a constant 0. This is a mostly undocumented POKEY setting.
SOURCE: https://atariage.com/forums/topic/293427-pokey-16-bit-mode-and-other-audctl-settings-a7800-emulation/?do=findComment&comment=4323784
User avatar
No.18440
trebor
Tester
Feb 5, 2021, 23:14
Possible root cause for these issue (which are still present as of MAME 0.228), can be taken from the POKEY section of the a400/800 Acid Test:

MAME 0.228 with Acid Test 1.2 beta:

Source: https://atariage.com/forums/topic/171296-acid800-an-atari-test-suite/?do=findComment&comment=4325304

-POKEY: Default value...Pass
-POKEY: Noise generators...FAIL. Incorrect 9-bit PRNG value: $AF
-POKEY: IRQ timing...Pass
-POKEY: Timer IRQs...Pass
-POKEY: Timer timing...FAIL. 1.79MHz 8-bit timer triggered too late (loop #1).
-POKEY: 1.79MHz timer granularity...FAIL. Iteration count was 36 (should be 39-49)
-POKEY: Two-tone mode...FAIL. Too many timer 2 interrupts on mark: 48 (should be 16).
-POKEY: Serial output complete IRQ...Pass
-POKEY: Serial clocking modes...FAIL. Timer 3+4 1.79MHz output failed: 1!=40
-POKEY: Direct serial input...FAIL. Timeout while waiting for NAK.
-POKEY: Serial port timing...FAIL. Serial output register was loaded too late.
-POKEY: Serial status...FAIL. Serial input active bit was asserted when idle.
-POKEY: Asynchronous receive mode...FAIL. Timer #4 IRQ fired with async recv mode active.
-POKEY: Address mirroring...Pass
-POKEY: Init timing...FAIL. Incorrect 15KHz cycle count (even): $31
User avatar
No.19986
trebor
Tester
Apr 2, 2022, 17:35
edited on: Apr 3, 2022, 16:00
Many issues mention in this thread for the POKEY chip have been vastly improved, if not completely rectified, under the latest (v5.0) sources for the A7800 emulator, if any are interested for possible inclusion under MAME.

https://github.com/7800-devtools/a7800

Updates include:
-two-tone mode fixes
-fix cycle delay for unlinked 1.79Mhz
-channel 3 corrections
-pokey 16-bit 1.79Mhz improvements
-fix 16-bit tuning
User avatar
No.20242
trebor
Tester
May 27, 2022, 23:10
edited on: May 27, 2022, 23:10
POKEY chip emulator was updated to v4.9 as of May 2, 2022.
Remaining fixes were put in place and tested against real hardware to be accurate as experienced under A7800 v5.1.
Source code available here:
https://github.com/7800-devtools/a7800
User avatar
No.20492
M.A.S.H.
Senior Tester
Aug 28, 2022, 09:56
Improved accuracy of POKEY emulation:
https://git.redump.net/mame/commit/?id=ffc0db2fdc8aac2258877e23fadee5265ad7a1c3
Report says this bug is resolved!
User avatar
No.20499
trebor
Tester
Aug 31, 2022, 11:30
Confirmed. The release of 0.247 which incorporates the improvements, fixes, and overall accuracy of POKEY emulation from the A7800 project, leaves this bug report as now resolved.
User avatar
No.20501
hap
Developer
Sep 1, 2022, 09:18
Ok