Jump to content
IGNORED

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


Recommended Posts

Double POKEY preview!

 

This is the famous Brinstar theme from the NES metroid.  Here is the desired setup:

 

POKEY1: AUDCTL1=$78

 

00 and 01 - $Cx 16-bit (sawtooth, harmony, RMT E)

02 and 03 - $Cx 16-bit (sawtoth, lead, RMT E)

 

POKEY2:  AUDCTL2=$50

 

00 and 01 - $Ax square 16-bit (bass)

02 - $8x 8-bit percussion

03 - free

 

I am still enlisting help in rendering code to play double POKEY ... a new SD cart called dragonfly which has double POKEY, plus Covox (for samples) is the target hardware.

 

Below is a rendered mixed wav using output from two Prosystem emulators.

 

Advantages to double POKEY:  You can play four 16-bit channels in all distortions without tuning errors.  The $Cx channels make a reasonable emulation of the NES pulse wave, while $Ax stands in for the triangle channel.  One 8-bit channel for percussion, and one 8-bit channel is free for sound fx.

 

Fingers crossed this comes off ...

 

Also including, code for the two POKEY's, seperately.  These should be played in Prosystem.  The goal is to merge these two into a single double POKEY binary, with POKEY1 at $440 and POKEY2 at $450.

 

 

 

 

 

 

metroid - atari.wav metroid - nes.wav metroid-brinstar-bass-perc.A78 metroid-brinstar-bass-perc.asm metroid-brinstar-lead-harmony.A78 metroid-brinstar-lead-harmony.asm

  • Like 3
Link to comment
Share on other sites

Another preliminary double POKEY preview ... the famous Krayt lair music from Metroid.   The planned setup:

 

POKEY 1:

 

AUDCTL=$7A (double 16-bit, 1.79 mhz on 0 and 2, plus hi pass filter channel 3 over channel 1)

 

00 and 01 - $Ax 16 bit - lead

02 and 03 - silent - filter modulation over first two channels

 

POKEY 2:

 

AUDCTL=$50 (16-bit on 0 and 1, 1.79 mhz on 0)

 

00 and 01 - $Ax 16-bit bass

02 - $Ax standard - lead

03 - $Ax standard - delayed lead

 

How this works:

 

On POKEY 1, we burn all four channels to make a SID type filter in 16-bit.  Notes from the $Ax 16-bit table are played, but transposed down an octave.  The same notes are also played in the filtered channels 02 and 03, but stepped up by 2, to make the swirling filter.  0's are introduced into all four channels, to control the swirling effect.

 

This makes for a better effect than 8-bit mode, because you have finer control over the modulation.

 

On POKEY 2, we have a 16-bit $Ax bass on the first two channels.  The lead on the third channel is a standard $Ax square in 8-bit, and the 4th plays the same as the third channel, but decreased in volume and delayed by 8 cycles, to make an echo delay like in the original NES tune.

 

Emulator issues:

 

Only happens with POKEY1.  Prosystem won't do the filtering and plays it an octave too low.  A7800 plays it exactly like real hardware.  POKEY2, both emulators play without error.

 

Attached are binaries for POKEY1 and POKEY2.  Also $450 binaries.  Please test on real hardware.

 

Also:  A mixed .wav from Altirra emulator, what it should sound like with a double POKEY binary.

 

Again, the goal will be to merge the two binaries into one binary, with POKEYs located at $440 and $450, for testing on the dragonfly cart. An.y ideas on how to do this would be appreciated

 

 

 

 

metroid-krayt-bass-lead.A78 metroid-krayt-bass-lead.asm metroid-krayt-bass-lead.bin metroid-krayt-bass-lead-450.A78 metroid-krayt-bass-lead-450.asm metroid-krayt-bass-lead-450.bin metroid-krayt-filtered-lead.asm metroid-krayt-filtered-lead-450.A78 metroid-krayt-filtered-lead-450.asm metroid-krayt-filtered-lead-450.bin metroid-krayt-filtered-lead.A78 metroid - krayt's lair - double pokey mix.wav

  • Like 1
Link to comment
Share on other sites

18 minutes ago, Synthpopalooza said:

Again, the goal will be to merge the two binaries into one binary, with POKEYs located at $440 and $450, for testing on the dragonfly cart. An.y ideas on how to do this would be appreciated

 

Sounds great!

 

I think the easiest way to merge the players is replace all of the labels (both definitions and references) with specialized labels and update the main loop to call both players. Not beautiful or space-efficient, but that's okay for a gameless audio player. I can take a stab at that if you want.

Link to comment
Share on other sites

Yes, if you would ... just remember we'll need duplicates for AUDCTL, AUDCx, AUDFx, SKCTLS, and STIMER (should we need to reset polycounters on both POKEY's) ... for now, we can probably just ignore updating the POLY reset code.

 

This is just for demo purposes.  If someone then decides to port Metroid to 7800 using double POKEY, then we'll need to rethink things ;)

Link to comment
Share on other sites

14 hours ago, Synthpopalooza said:

Yes, if you would ... just remember we'll need duplicates for AUDCTL, AUDCx, AUDFx, SKCTLS, and STIMER (should we need to reset polycounters on both POKEY's) ... for now, we can probably just ignore updating the POLY reset code.

 

This is just for demo purposes.  If someone then decides to port Metroid to 7800 using double POKEY, then we'll need to rethink things ;)

 

Right, need to do those POKEY labels and also the code that uses them. I don't see any STIMER — is that the same as RANDOM?

 

The real problem is that the .a78 header format does not currently support dual-POKEY. It supports POKEY@450 and POKEY@4000, but even if we enable both, I doubt a7800 or Dragonfly will treat those as separate POKEY chips. I know some single-POKEY games blindly write to both sets of addresses for maximum compatibility.

 

@RevEng any thoughts?

Link to comment
Share on other sites

STIMER is only used when we do polycounter resets, when using $Cx distortion mod 3 notes.  It randomly outputs 3 timbres unless you do polycounter reset before each note play.  It's at $459 or $4009 using conventional 7800 mappings.

 

I may have a solution ... someone on the 8-bit forum has coded a dual POKEY modification.   Will post this momentarily. 

Link to comment
Share on other sites

3 hours ago, Pat Brady said:

The real problem is that the .a78 header format does not currently support dual-POKEY. It supports POKEY@450 and POKEY@4000, but even if we enable both, I doubt a7800 or Dragonfly will treat those as separate POKEY chips. I know some single-POKEY games blindly write to both sets of addresses for maximum compatibility.

 

@RevEng any thoughts?

Yeah, for sure. This would require a new bit allocated in the a78 header, and emulator+device support coded. While it's doable for a7800 in theory, I don't have time to take it on right now.

Link to comment
Share on other sites

5 hours ago, RevEng said:

Yeah, for sure. This would require a new bit allocated in the a78 header, and emulator+device support coded. While it's doable for a7800 in theory, I don't have time to take it on right now.

Can we still get a .bin file that will work on real hardware?  If so, I don't mind a bit to keep cross developing on Altirra like I have been, and then test it on real HW.  Emulator support  for double POKEY would be great down the road, once we have a stable POKEY emulation in A7800.

Link to comment
Share on other sites

On 11/29/2020 at 9:00 PM, Synthpopalooza said:

Can we still get a .bin file that will work on real hardware?  If so, I don't mind a bit to keep cross developing on Altirra like I have been, and then test it on real HW.  Emulator support  for double POKEY would be great down the road, once we have a stable POKEY emulation in A7800.

 

On 11/29/2020 at 9:43 PM, RevEng said:

I don't see why you couldn't. It should just be a matter of changing your double pokey driver to access the pokeys where dragonfly has them.

 

OK, I will continue with it, hope to find time tomorrow to finish it.

 

EDIT: I got it to a point where it can be tested. One of the routines works correctly, the other doesn't. I will sort that out.

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

On 11/30/2020 at 12:51 AM, Pat Brady said:

 

 

OK, I will continue with it, hope to find time tomorrow to finish it.

 

EDIT: I got it to a point where it can be tested. One of the routines works correctly, the other doesn't. I will sort that out.

Meantime:  I may have a go at porting the .xex assembly source I now have, to 7800 and see where that gets me as well.  We're close ...

 

I fully expect double POKEY games to come from these experiments, now.

Link to comment
Share on other sites

OK, I think I have hacked out something ... including the .bin and .a78 files

 

Someone try putting this into Dragonfly and see what we get. :)

 

If this doesn't work, attached is the source .asm to hack around with and see what's going on

metroid-brinstar-lead-harmony-dblpokey.A78 metroid-brinstar-lead-harmony-dblpokey.asm metroid-brinstar-lead-harmony-dblpokey.bat metroid-brinstar-lead-harmony-dblpokey.bin

Link to comment
Share on other sites

  • 1 year later...

@Synthpopalooza when you have the opportunity, try giving your demos a listen under the newly released v5.0 of A7800. 

 

Previously noted issues have been rectified and thank you for providing them.  They were leveraged as part of the testing towards the improved POKEY emulation. :)

 

Huge thanks to @RevEng as he performed his magic once again.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

OK, the verdict:

 

Much improved!  :)  There are still a few minor imperfections, but nothing that makes the ears bleed too much ...

 

I listened to Bubble Bobble ... the inaccuracy with this one, happens when you use $2x distortion at 1.79 mhz.  It plays the channel an octave too high.  I may also check any tunes that use $Cx distortion the same way.

 

EXO area 1, area 2, area 3, area 4, and area 5 ... sound a lot closer to the actual hardware.  On area 1, there are still a few high pitched tings that show up on the $2x hi pass channel.  On area 2, a bit closer, though the two tone channel on $4x has a few inaccuracies, and the fuzz distortion isn't there.  But it does sound a lot more pleasant to listen to!  Improvement :)  Area 5 ... the same issues with the $2x 1.79 channel (octave too high) and some of the two tone notes miss a little bit.  But it is sounding a lot better!

 

On area 3, the 1.79+64 two tone $Ax distortion:  The CSAVE bell sound is perfect, when it gets to the saw wave table though, there are a few notes that still miss some.  Everything else is great.

 

Area 4:  Wow.  You got that crunchy sounds on $4x 1.79 plus 15khz two tone, and those guitars.  Still a bit of tinging going on there, but otherwise great!

 

I'll go through all my examples when I get more time, and compile a list.  So far, everything is much better!

 

Oh also:  two-tone mode with $Ax distortion at the standard 64khz clock, sounds 100% like real hardware.  You have nailed that perfectly, no issues at all!  Bravo ... I tested it with the Zanac music.

  • Like 4
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...