It is currently Mon Nov 20, 2017 2:35 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Feb 10, 2016 3:38 pm 
Offline

Joined: Mon Jan 18, 2016 5:36 pm
Posts: 23
Hey,

I recently released a demo (including sources) called GBVisualizer. It's supposed to demonstrate the use of two undocumented hardware registers, nicknamed PCM12 and PCM34, which I previously mentioned in GBDev Wiki.

Basically, these two registers allow reading the current PCM samples of each of the 4 APU channels in real time. This allows me to display real time oscillator-like audio visualization while playing music.

Some interesting notes:
  • Since it's not documented, and as far as I know, never used in any official game or demo, not a single released emulator supports these registers. (My yet-to-be-released emulator does support them)
  • Some emulators read these registers as constant zeros, which are the correct values when sound is not playing.
  • These registers allow an entire different class of test ROMs to be created, which will eventually allow sample-perfect nanosecond-accurate APU emulation.
  • Music for this demo is adapted from another project of mine, a disassembly of Super Bomberman.
  • I actually discovered these registers by coincidence.

Feel free to fork this demo to add more kinds of visualizations (Winamp AVS anyone?), and suggest other uses for these registers. :)

Image


Top
 Profile  
 
PostPosted: Wed Feb 10, 2016 6:05 pm 
Offline

Joined: Sun Mar 19, 2006 9:44 pm
Posts: 919
Location: Japan
That is pretty cool. Does your demo separate out the 4 nybbles at all to make the visualizer?

_________________
http://www.chrismcovell.com


Top
 Profile  
 
PostPosted: Wed Feb 10, 2016 8:27 pm 
Offline
User avatar

Joined: Mon Mar 30, 2015 2:22 pm
Posts: 26
Location: Detroit, MI
Oh wow.
Are the registers Read-only, like flag register?


Top
 Profile  
 
PostPosted: Wed Feb 10, 2016 10:45 pm 
Offline

Joined: Sun Jan 26, 2014 9:31 am
Posts: 256
You're gonna give byuu and gekkio even more to handle on their plates :D

Maybe one of these days, I'll rewrite my entire GB/GBC core to be cycle accurate, but I've got too many other things on my plate right now (like accurately emulating the crappy scaling the GBA does for DMG/GBC games...) Though, forget about test ROMs for a second, think of all the demos you could make. I can see this being GBDEV 2016 compo material.

Great to see some of those undocumented registers actually had some functionality, even if Nintendo never intended people to use them. Cool stuff man 8-)


Top
 Profile  
 
PostPosted: Thu Feb 11, 2016 2:08 am 
Offline

Joined: Mon Jan 18, 2016 5:36 pm
Posts: 23
ccovell wrote:
That is pretty cool. Does your demo separate out the 4 nybbles at all to make the visualizer?

Yes, I separate and sum them, although it is obviously possible to read them individually and visualize each channel separately.

Jazzmarazz wrote:
Oh wow.
Are the registers Read-only, like flag register?


TBH, I never tried writing to them, but I think it's safe to assume they are read only.

Shonumi wrote:
You're gonna give byuu and gekkio even more to handle on their plates :D

Maybe one of these days, I'll rewrite my entire GB/GBC core to be cycle accurate, but I've got too many other things on my plate right now (like accurately emulating the crappy scaling the GBA does for DMG/GBC games...) Though, forget about test ROMs for a second, think of all the demos you could make. I can see this being GBDEV 2016 compo material.

Great to see some of those undocumented registers actually had some functionality, even if Nintendo never intended people to use them. Cool stuff man 8-)


Actually, implementing support for these registers, at least in my emulator, was quite trivial; but potential test ROMs using these registers are definitely going to be a nightmare. And yeah, I'd love seeing more demos using these. :)


Top
 Profile  
 
PostPosted: Thu Feb 11, 2016 3:30 am 
Offline

Joined: Fri Oct 16, 2015 6:18 am
Posts: 41
That's a very nice find!
I'll test this on all my Game Boy devices later today and report my findings.

Quote:
You're gonna give byuu and gekkio even more to handle on their plates :D


Well, if this is GBC-only, it's not immediately interesting for me, but I'll get to GBC eventually ;)

Quote:
TBH, I never tried writing to them, but I think it's safe to assume they are read only.


Yes, my HWIO test ROM confirms that writes do not have an effect (at least from the Game Boy's point of view).
Although it's still possible in theory that it could affect the audio itself...


Top
 Profile  
 
PostPosted: Thu Feb 11, 2016 3:41 am 
Offline

Joined: Mon Jan 18, 2016 5:36 pm
Posts: 23
I don't have a DMG to test it, but I read that these registers read constant FFs on non-CGBs. Btw, the demo assumes it runs on a CGB, so you need to comment out the processor speed change and configure DMG palettes for it to actually run.


Top
 Profile  
 
PostPosted: Thu Feb 11, 2016 9:16 am 
Offline

Joined: Sun Jan 26, 2014 9:31 am
Posts: 256
> Actually, implementing support for these registers, at least in my emulator, was quite trivial; but potential test ROMs using these registers are definitely going to be a nightmare.

I wasn't exactly thinking about the difficulty of supporting them; a cycle-accurate emulator could just grab the sample from the APU whenever it's clocked and pass it to the MMU whenever the registers are read. Seems relatively straightforward. It's just that, if you're OCD, a perfectionist, or someone who just can't sleep at night until your project emulates every little obscure hardware behavior, this is *grumble, grumble* yet another thing you have to look into :P

My DMG/GBC cores were never designed to be accurate in any regards. I'd really have to make a new core, because I'd be grafting so much code trying to get two conflicting designs to work. One of these days though.

> And yeah, I'd love seeing more demos using these. :)

I've always wanted to make full-screen TV-static transitions (like changing a channel) to jump from one scene of a demo to the next. Polling Sound 4's nibble in PCM34 is a lot simpler than coding my own LSFR, and definitely much faster. Setup a couple of writes to Sound 4's registers, initialize it, then read PCM34.

Also, just FYI, GBVisualizer works just fine on GBA units. So, even though this was undocumented and never used in commercial games (at least it's not supposed to be) they still kept it around (probably not worth removing from the GBA honestly).


Top
 Profile  
 
PostPosted: Thu Feb 11, 2016 1:26 pm 
Offline

Joined: Fri Oct 16, 2015 6:18 am
Posts: 41
Quote:
I don't have a DMG to test it, but I read that these registers read constant FFs on non-CGBs. Btw, the demo assumes it runs on a CGB, so you need to comment out the processor speed change and configure DMG palettes for it to actually run.


Yeah, I know...Sorry, I didn't explain myself very clearly, but I just meant all my GBC/AGB/AGS devices. Tested, and it works!

This is a bit off topic, but I tried GBVideoPlayer too a couple of weeks ago, and on my hardware it stops working at around half way. Any ideas? It's probably an issue with the EMS 64Mb cartridge I use (e.g. some incorrect edge case in MBC5 emulation), but I'm wondering if there's something in the code that relies on specific CGB hardware revision or flash cartridge behaviour. Have you received any success or failure reports from other people running it on real hardware?


Top
 Profile  
 
PostPosted: Thu Feb 11, 2016 1:34 pm 
Offline

Joined: Mon Jan 18, 2016 5:36 pm
Posts: 23
A video that stops playing in the middle means the cart does not contain the entire ROM. Is that the cart that allows flashing two ROMs? Because these cart actually supports only 32Mbs per ROM.


Top
 Profile  
 
PostPosted: Thu Feb 11, 2016 2:13 pm 
Offline

Joined: Fri Oct 16, 2015 6:18 am
Posts: 41
Quote:
A video that stops playing in the middle means the cart does not contain the entire ROM. Is that the cart that allows flashing two ROMs? Because these cart actually supports only 32Mbs per ROM.


Ah, that's definitely it. I've never used the paging feature myself but apparently the cart is indeed 2x32Mb and does not work properly with 64Mb ROMs.


Top
 Profile  
 
PostPosted: Thu Feb 11, 2016 4:33 pm 
Offline

Joined: Thu Feb 11, 2016 4:30 pm
Posts: 1
Just a video of this on hardware: https://www.youtube.com/watch?v=rlrqg14q0Oc


Top
 Profile  
 
PostPosted: Fri Feb 12, 2016 12:18 pm 
Offline

Joined: Mon Mar 27, 2006 5:23 pm
Posts: 1339
Can someone please post a compiled .gbc of this demo?

I'm not really interested in the visualization aspect of this, but it's *extremely* promising to use these for better emulation of the APU channels. In the same way that the echo buffer was a lifeline into understanding the SNES DSP.


Top
 Profile  
 
PostPosted: Fri Feb 12, 2016 12:41 pm 
Offline

Joined: Mon Jan 18, 2016 5:36 pm
Posts: 23
Binary versions are available in the repo's releases in Github. :)


Top
 Profile  
 
PostPosted: Tue Feb 16, 2016 1:07 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3950
Do these registers exist in GBC mode on a GBA? What about in GBA mode?

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group