It is currently Fri Dec 15, 2017 12:44 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue Dec 05, 2017 6:45 pm 
Offline

Joined: Wed Jun 15, 2016 11:49 am
Posts: 65
I see this ROM as part of Gekkio's files, but I can't seem to find a lot of information about it.

So far every emulator I test it on prints the message "Naughty emulator! No presents for you!"

I'm guessing that means it's a failure. It looks like the what it's doing is using the timer and some midframe DMA's to do something, but I have no idea what.

Does anyone know what this ROM is testing and what the expected output is?

I can't even find the origin of this ROM, so any info is appreciated, thanks as always!


Last edited by Alyosha_TAS on Fri Dec 08, 2017 8:12 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Wed Dec 06, 2017 3:57 am 
Offline

Joined: Fri Oct 16, 2015 6:18 am
Posts: 43
It's a silly test ROM I made two years ago around christmas time 8-)

It tests certain special behaviour that no emulator gets right. On real hardware you get just a blank screen instead of the text you saw.
However, this test ROM doesn't fully test that behaviour so some emulators end up with the blank screen without properly emulating this edge case.

I can post further details and the source if you're interested :)
However, I have to warn that emulating the behaviour correctly right now is probably not possible because we don't understand it well enough. IIRC the behaviour wasn't even the same on all models...I think even MGB and DMG were different.


Top
 Profile  
 
PostPosted: Wed Dec 06, 2017 6:16 am 
Offline

Joined: Wed Jun 15, 2016 11:49 am
Posts: 65
gekkio wrote:
I can post further details and the source if you're interested :)
However, I have to warn that emulating the behaviour correctly right now is probably not possible because we don't understand it well enough. IIRC the behaviour wasn't even the same on all models...I think even MGB and DMG were different.


Yes I am very interested about what this mysterious behaviour might be. Even if I don't implement it right away I'd like to have some conceptual understanding about how it would fit into the rest of the emulator.

Also thanks for all your hardware research and test roms, they are awesome!


Top
 Profile  
 
PostPosted: Wed Dec 06, 2017 7:15 am 
Offline

Joined: Fri Oct 16, 2015 6:18 am
Posts: 43
I published the sources here: https://github.com/Gekkio/naughtyemu

The basic idea involves OAM DMA and HALT. If OAM DMA is running when HALT is entered, the OAM DMA is suspended but ends up leaving some internal bus in a busy state.
If HALT is eventually exited, OAM DMA continues from where it stopped.

Now, while the internal bus is in this "busy state", PPU OAM accesses cause internal bus conflicts. This particular test ROM basically relies on this bus conflict to prevent sprites from being drawn.
By using clever timing, I'm making sure that we have a OAM DMA + HALT bus conflict every time the PPU is drawing a sprite, so OAM accesses end up seeing something else than the real sprite data.
It's possible to pass this test simply by not drawing sprites in this bus conflict mode.

However, this is not the real behaviour on real hardware... :twisted:
On real hardware the PPU sees some OAM values, which in some way depend on the model, the real OAM value underneath, and the value OAM DMA is trying to write. It's even possible that individual unit differences come to play here (which would make emulating this in detail completely pointless).
This is also why this in this test a blank screen is considered a "success": I don't fully understand how to control the value the PPU sees, so it's extremely difficult to show something on the screen.

There's a test called madness/mgb_oam_dma_halt_sprites in mooneye-gb tests directory, which shows an example where the screen ends up showing something in this bus conflict case.


Top
 Profile  
 
PostPosted: Wed Dec 06, 2017 8:45 am 
Offline

Joined: Wed Jun 15, 2016 11:49 am
Posts: 65
Ahhh ok that makes sense. So the fundamental behaviour I was missing was the OAM DMA is halted when the CPU is halted, got it. The bus conflict this causes makes OAM unreadable/glitchy mess to the ppu when it's processing sprites.

Cool, implementing that was enough to get the blank screen in naughtyemu.gb, thanks!

I'll worry about the glitchy details at some later point.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 3 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:  
Powered by phpBB® Forum Software © phpBB Group