Super Mario and Zelda emulation issues

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

CaptainMuscles
Posts: 10
Joined: Tue Jul 14, 2009 4:10 pm

Super Mario and Zelda emulation issues

Post by CaptainMuscles » Sun Jul 19, 2009 3:00 am

I've been writing my own NES emulator for fun over the last couple of weeks. I really only intended for it to play one game at first (Final Fantasy I, and thanks a million Disch for the commented assembly, it was priceless for my early debugging.)

After getting FF1 to where it seemed like it was working fine, I got the itch to try to see if I could get it to run a handful of other games well.

Shortly afterward, I got Super Mario Bros. working and looking great, except for one issue. Whenever Mario dies and falls off of the screen, he continues falling from the top of the screen, all the way down and wrapping back to the top again, all the while flashing colors kinda like when he is invincible after picking up a star, although the game still goes on to the next life when the death music ends. When Mario dies from falling into a pit, the same thing happens, except that Mario can still be steered left and right while falling until the death music ends.

When playing the Legend of Zelda 1, the title and explanation screens look correct, but when entering the character's name, there is no response to any buttons other than Start, 'A' and 'B'. Therefore the player can not use Select to move down to end registration nor move the cursor with the d-pad to select letters other than a.

Other than the mentioned issues, everything seems to work fine in FF1 and Super Mario Bros, and all legal-opcode tests pass in nestest.nes. Has anyone experienced similar problems and have some insight into what is happening here?

P.S. Many thanks go out to everyone on these boards whose documents and forum posts have helped me so far. Way too many to remember and list at the moment.

User avatar
hap
Posts: 355
Joined: Thu Mar 24, 2005 3:17 pm
Contact:

Post by hap » Sun Jul 19, 2009 5:30 am

Even though nestest passes, the SMB problem still sounds like a CPU bug to me. Try blargg's CPU test too.

CaptainMuscles
Posts: 10
Joined: Tue Jul 14, 2009 4:10 pm

Post by CaptainMuscles » Sun Jul 19, 2009 11:36 am

I was only able to find cpu timing test roms, is this the one you were referring to?

User avatar
koitsu
Posts: 4218
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Post by koitsu » Sun Jul 19, 2009 11:48 am

CaptainMuscles wrote:I was only able to find cpu timing test roms, is this the one you were referring to?
http://www.fly.net/~ant/misc/

User avatar
hap
Posts: 355
Joined: Thu Mar 24, 2005 3:17 pm
Contact:

Post by hap » Sun Jul 19, 2009 1:15 pm


User avatar
MrSketch
Posts: 4
Joined: Mon Jun 15, 2009 9:48 am

Post by MrSketch » Mon Jul 20, 2009 9:52 am

Just out of curiosity, what is the trick to getting the vertical scrolling to work in Final Fantasy? I have a bug in my emulator where when you scroll vertically in that game there are graphical glitches at the top and bottom, but horizontal scrolling works just fine. Zelda 2 and Metroid both scroll vertically just fine.

It goes through 3 distinct phases (ex: scrolling up):
The bottom tiles show at the top (for 8 frames)
Then the top tiles show up at the top and bottom. The top tiles are correct, but with incorrect attribute data (only for 1 frame)
The top tiles still show up at the bottom (for 7 frames)

I don't feel too bad since Nestopia v1.40h doesn't scroll it correctly either, but I'd like to know if you got it scrolling right and what the trick was.

User avatar
tokumaru
Posts: 12003
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru » Mon Jul 20, 2009 11:58 am

MrSketch wrote: I have a bug in my emulator where when you scroll vertically in that game there are graphical glitches at the top and bottom, but horizontal scrolling works just fine.
This is probably correct (specially since other emulators are showing the same thing). Many commercial games have vertical scrolling glitches. It is quite hard to have glitch-free scrolling in both directions with the NES. Most games that scroll in both directions have glitches either vertically or horizontally.

User avatar
MrSketch
Posts: 4
Joined: Mon Jun 15, 2009 9:48 am

Post by MrSketch » Mon Jul 20, 2009 1:24 pm

I guess I find it hard to believe that this really popular game has this bad of a glitch that isn't talked about more or mentioned on the wiki. I also checked Nintendulator which has the same problem. Here are some screenshots of what I'm talking about:
Image Image Image

According to the entry on emuverse, my dump has the correct CRC and MD5 so it should be a good dump.
http://dorando.emuverse.com/html/final-fantasy.html#na

Edit: This page on the wiki explains the overscan issues present with the NTSC PPU and that the top and bottom 8 rows are sometimes not displayed on NTSC TVs.
Last edited by MrSketch on Mon Jul 20, 2009 1:45 pm, edited 1 time in total.

tepples
Posts: 22288
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Mon Jul 20, 2009 1:42 pm

There isn't enough VRAM in the PAL NES for glitch-free scrolling in all directions. The issue is alluded to in Mirroring, and I just added an example of a mirroring glitch in a different game to Game Bugs.

NTSC NES games' scrolling engines were designed to run on NTSC television sets that crop the picture at the top and bottom, and you'll see occasional glitches like this unless either A. your emulator emulates NTSC overscan (like pretty much everything since Nesticle), or B. your game uses raster effects to crop the glitches off (like Jurassic Park).

User avatar
MrSketch
Posts: 4
Joined: Mon Jun 15, 2009 9:48 am

Post by MrSketch » Mon Jul 20, 2009 1:59 pm

Thank you tepples for clearing this up. I always wondered why Virtual NES had a one tile border around the edges and I guess this explains why.

CaptainMuscles
Posts: 10
Joined: Tue Jul 14, 2009 4:10 pm

Post by CaptainMuscles » Mon Jul 20, 2009 2:27 pm

NTSC NES games' scrolling engines were designed to run on NTSC television sets that crop the picture at the top and bottom, and you'll see occasional glitches like this unless either A. your emulator emulates NTSC overscan (like pretty much everything since Nesticle), or B. your game uses raster effects to crop the glitches off (like Jurassic Park).
What he said. My screen looked just like yours before I started skipping the top and bottom 8 scanlines to emulate the visibile NTSC area.

User avatar
tokumaru
Posts: 12003
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru » Tue Jul 21, 2009 9:37 am

tepples wrote:NTSC NES games' scrolling engines were designed to run on NTSC television sets that crop the picture at the top and bottom
Except that they don't always crop. My personal experience is that most of the time the TVs are miscalibrated or something and the glitches are quite visible, either at the top or at the bottom.
MrSketch wrote:I find it hard to believe that this really popular game has this bad of a glitch
Don't you find hard to believe that the following also popular games have such bad glitches at the left and/or right sides of the screen?

Image Image Image

Image Image Image

Image Image

Image Image Image

Image Image Image

I find these glitches terribly distracting when I'm playing, even though in practive they are not as big as the vertical ones because the leftmost column is hidden by hardware.

IMO, people think too high of the programmers of the time. They were not better than the hobbist programmers of today (generally speaking), they just had a consistent working schedule and the financial incentive to get things done, even if that meant doing some sloppy coding to simplify things and get the games out in time.

User avatar
Banshaku
Posts: 2396
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Post by Banshaku » Tue Jul 21, 2009 6:58 pm

tokumaru wrote:IMO, people think too high of the programmers of the time. They were not better than the hobbist programmers of today (generally speaking), they just had a consistent working schedule and the financial incentive to get things done, even if that meant doing some sloppy coding to simplify things and get the games out in time.
I'm on the same opinion about this part too. If you read what Neil said, they didn't even have an english instruction manual when they started to work on it and they had to figure out how it work by guessing.

So any team of programmers with enough time and pressure from their publisher will be about to churn out a game. The difference with us is that we don't have the team, time and money to put on it.

CaptainMuscles
Posts: 10
Joined: Tue Jul 14, 2009 4:10 pm

Post by CaptainMuscles » Tue Jul 21, 2009 8:58 pm

Thanks for the references to Blargg's test roms. It turns out that the issue was caused by the way I am handling the functions for my operations. ASL, LSR, ROL, and ROR were all handling a zeropage, x that pointed to the memory location $00 as the accumulator version of those commands.

Also, as I mentioned in the CPU test thread, anyone experiencing massive failures in Blargg's test rom number 5 despite a seemingly working emulator should take a look at how they are handling the setting of processor status flags 5 and 6 during IRQ/NMI/BRK/PHP. As per a post I found by Disch somewhere on these boards, Flag 5 should be pushed as set for BRK/PHP and clear for NMI/IRQ. Flag 6 should be pushed as set for all four commands.

User avatar
TSK
Posts: 7
Joined: Thu May 21, 2009 5:33 pm

Post by TSK » Tue Jul 21, 2009 9:16 pm

MrSketch wrote:Thank you tepples for clearing this up. I always wondered why Virtual NES had a one tile border around the edges and I guess this explains why.
I think, that if I didn't, I'd get complaints from the users, and they're a fickle bunch. This is why you don't do things in Java. I can't even really change the palette much without a dozen emails in my inbox.

But really, it provides a more user-friendly experience, but for an actual program with menus and settings, it's probably worth it to have an option to turn this on and off.

Post Reply