PPU accuracy and Battletoads

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
Anes
Posts: 621
Joined: Tue Dec 21, 2004 8:35 pm
Location: Mendoza, Argentina

PPU accuracy and Battletoads

Post by Anes »

The nesdev wiki says:
Battletoads requires fairly precise CPU and PPU timing and a fairly robust sprite zero implementation. It leaves rendering disabled for a number of scanlines into the visible frame to gain extra VRAM manipulation time and then enables it. If the timing is off so that the background image appears too high or too low at this point, a sprite zero hit will fail to trigger, hanging the game. This usually occurs immediately upon entering the first stage if the timing is off by enough, and might cause random hangs at other points otherwise.
Well, my emu is suffering that, the image appears too high and in "Battletoads and Double Dragon" too.

I have been Reading the wiki and according to the "render" diagram/picture:

- Vblank is set on scanline 241 cycle 1? (counting from 0-340)
- Is NMI pulled low (triggered) in that moment?

According to blargg's ppu tests nmi timing throws me error "3) NMI occurred 2 PPU clocks too early".
For that reason i do a hack:

Code: Select all

if (scanline == 241 && cycle == 1)
{    
    on_vblank = 1;
    if (nmi_onvblank)
        nmi_pending = 1;
}

if (scanline == 241 && cycle == 15)
{    
    if (nmi_pending)
    {
        SetCpuNMIPending();
        nmi_pending = 0;
    }
}
That way the NMI timming test throw me error #8, but this this time "BattleToads and Double Dragon" is playable and "Battletoads" hangs ramdomly in the second level.

Any advice? thxs.
ANes
User avatar
ulfalizer
Posts: 349
Joined: Fri Mar 08, 2013 9:55 pm
Location: Linköping, Sweden

Re: PPU accuracy and Battletoads

Post by ulfalizer »

Second level in Battletoads is a bitch. If it's any help, a hang means your CPU is too fast relative your PPU and enables rendering too early (before the vertical bump on that scanline, meaning the vertical bump occurs). Battletoads is only really sensitive in one direction, and having the CPU be relatively too slow makes it perfectly happy, even if it's some way off. I guess that's why some emulators add a fudge factor to the NMI and the like.
User avatar
Anes
Posts: 621
Joined: Tue Dec 21, 2004 8:35 pm
Location: Mendoza, Argentina

Re: PPU accuracy and Battletoads

Post by Anes »

ulfalizer wrote:Second level in Battletoads is a bitch. If it's any help, a hang means your CPU is too fast relative your PPU and enables rendering too early (before the vertical bump on that scanline, meaning the vertical bump occurs). Battletoads is only really sensitive in one direction, and having the CPU be relatively too slow makes it perfectly happy, even if it's some way off. I guess that's why some emulators add a fudge factor to the NMI and the like.
Yeah, you are right is a f***n bitch. But i'll try to make what you are telling me.
ANes
User avatar
blargg
Posts: 3717
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Re: PPU accuracy and Battletoads

Post by blargg »

Be sure you pass the CPU timing test.
User avatar
Anes
Posts: 621
Joined: Tue Dec 21, 2004 8:35 pm
Location: Mendoza, Argentina

Re: PPU accuracy and Battletoads

Post by Anes »

Be sure you pass the CPU timing test
Official passed well. i Fixed Abs(x) NOP's and EB -> nop or sbc?.

Should i implement unofficial instructions?? I mean i know i should, but Battletoads doesn't use them or does it?

Edit: no, it doesn't use unofficial. The problem is elsewhere.
ANes
User avatar
MottZilla
Posts: 2835
Joined: Wed Dec 06, 2006 8:18 pm

Re: PPU accuracy and Battletoads

Post by MottZilla »

Anes wrote: Any advice? thxs.
You can cheat and decide if Mapper == 7, have Sprite Zero set whenever the first visible pixel of the sprite is drawn, rather than when one is drawn along with a background pixel. It will prevent the game from hanging.

Otherwise it's about your CPU, PPU, and NMI timing being just right.
User avatar
Anes
Posts: 621
Joined: Tue Dec 21, 2004 8:35 pm
Location: Mendoza, Argentina

Re: PPU accuracy and Battletoads

Post by Anes »

MottZilla wrote:
Anes wrote: Any advice? thxs.
You can cheat and decide if Mapper == 7, have Sprite Zero set whenever the first visible pixel of the sprite is drawn, rather than when one is drawn along with a background pixel. It will prevent the game from hanging.

Otherwise it's about your CPU, PPU, and NMI timing being just right.
That's what i did before to Battletoads run, but i decided to do it the "hard way", there are still some blargg's test that my emu doesn't pass them well and since my mother tongue is not english, sometimes it's difficult to me to understand things. The same happens to me with the Wiki. :lol:
ANes
User avatar
koitsu
Posts: 4203
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: PPU accuracy and Battletoads

Post by koitsu »

Anes wrote:That's what i did before to Battletoads run, but i decided to do it the "hard way", there are still some blargg's test that my emu doesn't pass them well and since my mother tongue is not english, sometimes it's difficult to me to understand things. The same happens to me with the Wiki. :lol:
Slightly off-topic but not entirely: we have lots of people here who speak fluent Spanish (I can think of 4 off the top of my head), although I don't think any of them speak Argentinian dialect (if that matters). So if you're confused by something here, or from the Wiki, it's perfectly OK to ask if someone who speaks Spanish could translate something for you.
User avatar
Anes
Posts: 621
Joined: Tue Dec 21, 2004 8:35 pm
Location: Mendoza, Argentina

Re: PPU accuracy and Battletoads

Post by Anes »

koitsu wrote:
Anes wrote:That's what i did before to Battletoads run, but i decided to do it the "hard way", there are still some blargg's test that my emu doesn't pass them well and since my mother tongue is not english, sometimes it's difficult to me to understand things. The same happens to me with the Wiki. :lol:
Slightly off-topic but not entirely: we have lots of people here who speak fluent Spanish (I can think of 4 off the top of my head), although I don't think any of them speak Argentinian dialect (if that matters). So if you're confused by something here, or from the Wiki, it's perfectly OK to ask if someone who speaks Spanish could translate something for you.
Maybe i sould said "my english is not good enough" for the docs. That's a different thing :D
But i try, i really try.
ANes
User avatar
koitsu
Posts: 4203
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: PPU accuracy and Battletoads

Post by koitsu »

I understand. And what I'm telling you is: if there is something on the Wiki (written in English) which you don't understand, post here on the forum with a link or quote of the part you do not understand, and someone here can explain it to you in Spanish / translate it into Spanish for you.
User avatar
Anes
Posts: 621
Joined: Tue Dec 21, 2004 8:35 pm
Location: Mendoza, Argentina

Re: PPU accuracy and Battletoads

Post by Anes »

That's really helpfull i won't hesitate to ask. thxs Koitsu!!
ANes
Post Reply