Jump to content
IGNORED

POKEY 16-bit mode and other AUDCTL settings - A7800 emulation


Recommended Posts

Today's update:

 

Played around with $8x distortion using both the 9-bit polycounter and SKCTLS=$8B 2-tone mode.  I generated a note table for more guitar distortions, of the same sort as the $4x table earlier.

 

Also played with $Cx and SKCTLS.  This produces a lot of duty-cycled saw/pulse basses!  More soon.

  • Like 1
Link to comment
Share on other sites

So in summary ... POKEY basically has three clocking systems, 6 waveform settings, and four different filters.

 

Clocks:

 

64 khz - default clock, all 4 channels

15 khz - bass frequencies, all 4 channels

1.79 mhz - ultra high frequencies, 0 and 3 only

 

Waveforms:

 

$0x - pink noise (can use 9-bit poly)

$2x - triangle wave

$4x - car noises or distorted guitars

$8x - white noise (can use 9-bit poly)

$Ax - square wave

$Cx - saw wave (multiple waveforms)

 

Filters:

 

16-bit:  1 and 3, modulated from 0 and 2

Reverse 16-bit:  0 and 2 modulated from 1 and 3

Hi-pass:  0 and 1 modulated from 2 and 3

Two-tone: 1 modulated from 0.

 

Another project on my radar:  Make up an extensive guide to using all the AUDCTL and SKCTLS features of POKEY.  Might go useful for the programming guide by @Random Terrain I think.

Edited by Synthpopalooza
  • Like 3
Link to comment
Share on other sites

So, this happened in Poland recently:

 

 

An enterprising programmer discovered how to stabilize the $Cx distortion (what I termed distortion 12b).  An explanation:

 

When using frequencies divisible by 3 ((freq-1) mod 3 = 0) a smoother tone can be had.  But, one of three timbres is randomly output.  You can hear this in my Bubble Bobble demo.

 

Well, the above has a method to stabilise the tones to any of the three timbres.  It's very complex, and involves a reset of the 4-bit polycounter.  I haven't even begun to dive into this yet, but it looks very interesting!

 

I believe this method will also work on the $8x plus 9-bit, and $4x plus 1.79 mhz settings as well!

  • Like 4
Link to comment
Share on other sites

Here's a repack of that Rolling Thunder intro, POKEY @450.  Please test this on a real HW and let me know how it sounds.

 

This is an example of a reverse-16 bit filter, which is not the normal usage of this function.  In this case, channel 0 plays while channel 1 is silent.  When this is active, Channel 1 acts as a modulator to the frequency of 0.  And with the 9-bit polycounter turned on, it makes for a terrific electric distorted guitar sound.  Channel 1 is fed a constant 0 for the frequency, and the notes are played on channel 0. 

 

As before, emulation (both a7800 and prosystem in this case) fail at this.  The 9-bit polycounter modulation is not done, and white noise plays instead.

 

 

rollingthunder-intro-450.A78 rollingthunder-intro-450.asm rollingthunder-intro-450.bin

  • Like 2
Link to comment
Share on other sites

Currently working up a rendition of the theme from 3D Worldrunner.  It will be using the SKCTLS 2-tone mode, in conjunction with AUDCTL=$20.  This clocks the third channel with 1.79 mhz.  This time, we are using $Cx on that channel with Distortion 12a.  This produces high pitched sawtooth waves starting at A#4 and barely reaching G6, and imitating the duty pulse wave on the original NES version.   Stay tuned ...

Link to comment
Share on other sites

OK, here it is.

 

The following layout was used:

 

AUDCTL=$20, SKCTLS=$8B.  Engages two tone mode and clocks channel 2 at 1.79 mhz

 

00 - $Ax square wave - modulated from channel 1 with two-tone mode.  Lead sound

01 - Silent.  Modulates frequency of 00

02 - $Cx clocked with 1.79 mhz.  Harmony channel

03 - $Ax square wave - no modulations.  Bass channel

 

Notes:

 

As before, to make music in $Ax with 2-tone mode, you must play the base frequency in channel 1, and the same melody in 0 but transposed up a constant amount of semitones.  This helps maintain the pulse width.  In this case, the melody is transposed up 14 semitones (using the standard $Ax note table in 8-bit mode), putting the entire melody up by one octave while maintaining a constant pulse width.

 

On channel 2, we play $Cx saw wave at a 1.79mhz clock.  We also use frequencies not divisible by 3 (Distortion 12a) which are the only audible ones which can be played here.  You have a limited range, from a#4 (at $FF) to about G5, without severe tuning errors.  This imitates very well the pulse wave timbre of the NES original.  This setting is excellent for reaching into the 4th and 5th octaves in 8-bit mode with a minimum of tuning errors.  The notes here are taken from my POKEY note table, listed under Distortion 12a 1.79 mhz.

 

Channel 3 plays a standard unmodified square wave.  This stands in for the NES triangle channel, but modifications had to be made.  The original NES version has an A2 bass note which is outside of the POKEY 8-bit range, so a B2 note (at $FF) is substituted, which maintains the harmony.

 

Emulation issues:

 

As with the other examples using SKCTLS=$8B, emulators will not do the two-tone modulation.  On Prosystem, the main lead is horribly out of tune, but the harmony $Cx channel plays correctly.  On A7800, the same issue exists with the main lead, but the harmony $Cx channel does not even audibly play at all.

 

Attached is a .wav recorded from the Altirra emulator, plus binaries and .asm source, compiled for POKEY @$450 and @$4000.  @TreborA test on this one on real HW will be appreciated.

 

Now ... someone make this game for the 7800 already!  LOL

 

 

 

 

 

 

worldrunner.A78 worldrunner.asm worldrunner.bin worldrunner-450.asm worldrunner-450.A78 worldrunner-450.bin worldrunner.mp3

  • Like 4
Link to comment
Share on other sites

Now, a demonstration of one of the pitfalls of doing Distortion 12b bass.  I have compiled a bass only version of the Bubble Bobble theme to demonstrate.

 

This executable should be played on Prosystem emulator, as A7800 will not play the bass properly.

 

You will notice that the timbre of the bass varies randomly.  There is a very technical explanation ... POKEY samples from the 4-bit polycounter for $Cx distortions.  Periods which are divisible by 3, 5, or 15 produce differing timbres.  In the case of 15, silence is generated, because the period divisor makes the POKEY always sample 0's.  In the case of 5, either a tone or silence will be generated, depending on the system clock.  The other frequencies, ones divisible by 3, generate one of three tones randomly depending on the system timer.

 

A Polish programmer named @pavros has documented a means of controlling these timbres.  Still diving into the material, but there are three sampling tracks that get used.  By resetting SKCTLS and AUDFx and STIMER before each note is played, the polycounter is reset.  This forces the second tone to always be generated whenever called.   One of the other two sampling tracks can also be selected through this method, which will alternately output tone 1 or tone 3 depending on the frequency divisor (whether divisible by 3, 6, 9, or 12).

 

I am looking through the material and figuring out how to employ it in my music code.  But it will offer a better control of this bass setting, and potentially allow the selection of three timbres in this $Cx setting at will.

bubbob7800-bass.A78 bubbob7800-bass.asm bubbob7800-bass.bin

  • Like 3
Link to comment
Share on other sites

On 9/3/2019 at 3:28 AM, Synthpopalooza said:

Here's a repack of that Rolling Thunder intro, POKEY @450.  Please test this on a real HW and let me know how it sounds.

 

On 9/4/2019 at 12:13 AM, Synthpopalooza said:

@TreborA test on this one on real HW will be appreciated.

 

 

Rolling Thunder has a slight issue, 3D Worldrunner sounds great.

3D Worldrunner Theme Melody-RealHW.mp3 Rolling Thunder (Intro Melody)-RealHW.mp3

Link to comment
Share on other sites

So I got three test tunes in progress...

 

1.  Super Mario World overworld theme which will use $Ax with SKCTL plus 1.79 clock.  Also known as the save to cassette sound.

 

2 and 3.  Tracks using the $8x 9-bit reverse 16 SKCTLS mode with the warbling electric guitar distortions.  One will be a rendition of the theme from Stranger things and the other a cover of a classic Deep Purple track. :)

Edited by Synthpopalooza
  • Like 3
Link to comment
Share on other sites

More experimentation ...

 

The music is the Area 1/Area 2 music from the NES and MSX shooter Zanac.

 

I have done two renditions of the theme, which I will explain below.

 

Audio setup:

 

AUDCTL=$00 (no special settings)

SKCTLS=$8B (two-tone)

 

Channel 0:  $Ax (modulated from channel 1)

Channel 1:  $Ax (frequency carrier)

Channel 2:  $Cx (bass - Distortion 12b, aka mod3 bass or RMT C)

Channel 3:  $Ax (normal square wave, arpeggios)

 

In the first example, I completely silenced channel 1 and let channel 0 play the melody.

 

zanac1.mp3

 

In the second, I set the volumes of 0 and 1 to about 5.  This actually plays the carrier frequency on top of the modulated one, and makes it into a semi-pulse wave. The recording here is from the Altirra emulator, and it seems to mute out the other channels a bit, so I wanted to see if this effect happens on real hardware.

 

zanac2.mp3

 

Executables below, including POKEY @450 binaries.  As before, do not try this on emulation, it won't work. :)  Tests on real hardware, as always, are appreciated.

 

 

zanac1-450.asm zanac1-450.bin zanac2.A78 zanac2.asm zanac2.bin zanac2-450.A78 zanac2-450.asm zanac2-450.bin zanac1.A78 zanac1.asm zanac1.bin zanac1-450.A78

  • Like 4
Link to comment
Share on other sites

New one ... the overworld theme from the SNES game Super Mario World

 

super mario world - overworld theme.mp3

 

Settings:

 

AUDCTL=$60 (1.79 mhz on channels 0 and 2)

SKCTLS=$8B (two-tone mode)

 

Channel 0:  $Ax (clocked at 1.79 mhz ... frequency modulation for channel 1)

Channel 1: Silenced.  Frequency carrier for channel 0

Channel 2:  $Cx (clocked at 1.79 mhz.  Rhythmic accompaniment ... high saw notes starting at A#4)

Channel 3:  $Cx (No special settings.  Distortion 12B bass aka mod3 bass or RMT C)

 

When two-tone mode is engaged on $Ax square wave at 1.79 mhz, a very sonorous bell tone is made.  This is the very famous "Save to cassette" sound familiar to Atari 8-bit computer users.  The standard $Ax square wave is fed through a very high frequency modulation. 

 

The note table for this setting is in this post:

https://atariage.com/forums/topic/293427-pokey-16-bit-mode-and-other-audctl-settings-a7800-emulation/?do=findComment&comment=4329762

 

Emulation issues:  As expected, neither Prosystem or A7800 will play the lead sound properly, high frequencies are heard instead.  In addition, A7800 will not properly play the $Cx high frequency saw sounds on channel 2.

 

Binaries attached.  Please test on real HW. :) 

marioworld1.A78 marioworld1.asm marioworld1.bin marioworld1-450.A78 marioworld1-450.asm marioworld1-450.bin

Edited by Synthpopalooza
  • Like 2
Link to comment
Share on other sites

So, made some discoveries this week...

 

First ... SKCTL settings have no effect on 16-bit modes (normal or reverse) so these can be disregarded.

 

Secondly, made progress on documenting the reverse 16-bit modes in $Cx and $Ax distortions. $Cx has at least 6 distinct timbres, many of them sounding like woodwind instruments!  While $Ax offers you an octave of pulse wave NES style notes in addition to the standard 8 bit square wave note table. 

 

So, next steps are to get all the SKCTL and reverse 16-bit modes documented, then start adding in the hi-pass filters to the mix.

  • Like 4
Link to comment
Share on other sites

Played with the hi-pass filter today (AUDCTL=$x4 or $x2).  It's rather poorly named.  More accurately, it is a sync oscillator, where the period of the third channel acts on the first in a sort of PWM duty cycle setup.

 

In addition to warbly synth tones, it may be also possible to set the pulse width at will, and give a full emulation of the NES pulse wave.

 

I have a partial note chart for this setting, and can also report that it also works well with the SKCTLS 2-tone mode as well.  Will post this soon.

  • Like 3
Link to comment
Share on other sites

One tidbit I can reveal ...

 

Channel 0 carries the base frequency.  By setting channel 2 to a frequency either 3, 4, or 12 semitones up from the base, you create the modulations.  Offsetting the modular frequency by a step creates a swirling sound.

Edited by Synthpopalooza
  • Like 2
Link to comment
Share on other sites

Made another discovery ... if you play the same frequency in both channels using the high pass filter, it creates the NES pulse duty cycle wave.  To vary the width, you delay the second note, or play a neighbouring frequency for a cycle.

 

If the cycles overlap inversely, the noise cancels (phase inversion) but anything else makes different pulse widths. :)

  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...