problems with mapper 1, and scrolling is backwards.

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
miker00lz
Posts: 235
Joined: Thu Sep 23, 2010 7:28 pm

problems with mapper 1, and scrolling is backwards.

Post by miker00lz » Thu Sep 23, 2010 7:45 pm

i just started working on an emulator a couple weeks ago, my first attempt at one other than a very simple apple 2 emu about a year ago. (could only use ROM, no disk support and only text mode)

i've gotten it to the point where it can start running just about any NES game i try in it, but none of them can ever seem to quite go in-game. there are minor graphics glitches here and there too.

one problem i'm having is that my scrolling routines seem to go backwards and for the life of me i can't get it fixed. for example, the original pacman. when you first turn it on, the title screen scrolls from below and moves upwards. my emulator always has it starting showing it all and it moves upwards off the screen on the top. i thought, okay lemme just add 240 to the pixel location. well it didn't change anything. i don't understand what it is.

here are a collection of screenshots showing what it gives on various ROMs.

Image Image Image Image Image Image Image Image Image Image Image


the pacman, excitebike, and donkey kong pics show where it stops running. thats as far as i can get in any game.

another problem i have is implementing mapper 1. i've been reading everything i can on it, and i'm not sure where i'm going wrong. so as of now, it only works with mapper 0 and mapper 2 roms.

here's a RAR with the compiled win32 exe, along with the source code. it's written for the FreeBASIC compiler. (which can also make DOS and Linux binaries)

http://rubbermallet.org/extranes-0.9.23.10-dev.rar

i appreciate any help! (and i know it doesn't flip sprites, i just haven't added the code yet. that's why pacman looks goofy.) and fwiw, megaman 1 looks flawless graphically, but when i press start and go to the stage select screen, it stays for about half a second then reboots to the title screen again.

User avatar
Dwedit
Posts: 4408
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit » Thu Sep 23, 2010 9:55 pm

You are using a very simplified method of handling scrolling, which is nowhere near how the NES actually does it. Although it will probably work fine for many games which do not use a status bar or other split scrolling effects, but it won't work for games like Super Mario Bros or Zelda.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

User avatar
miker00lz
Posts: 235
Joined: Thu Sep 23, 2010 7:28 pm

Post by miker00lz » Fri Sep 24, 2010 2:25 pm

hmm. where am i going wrong? if you're referring to performing PPU logic per scanline, you can start the emulator with -cycle to perform intra-scanline CPU processing, 1 CPU tick per 3 pixels. that was eventually going to be the default. any clue why megaman might be resetting shortly after showing the stage select screen?

-cycle needs to be after the filename on the command line btw. extranes.exe -? shows more options

User avatar
tineras
Posts: 53
Joined: Mon Jul 05, 2010 7:59 am

Post by tineras » Fri Sep 24, 2010 2:47 pm

It sounds like you need to stop skipping steps and get your core elements working properly. Is your CPU working properly? If not, try to get some of the test roms to pass first. (Like nestest, NEStress, and Blargg's individual cpu tests). http://wiki.nesdev.com/w/index.php/Emulator_tests

There is no point in moving forward with the rest of your code if the CPU is broken. You'll be endlessly chasing problems. And as Dwedit said, implement your ppu and scrolling code properly. It will save you a lot of trouble in the end.

Here is a list the Disch provided as a suggestion of what to get working first: http://nesdev.com/bbs/viewtopic.php?p=42822#42822

- CPU
- PPU and video output
- NMI
- Joypad
- CPU Timing and CPU/PPU interation
- Sprite 0 hit
- Sprite overflow
- $2004 read during rendering trickery
- APU and audio output
- Frame IRQs
- DMC stolen cycles
- DMC IRQs
- then start with mappers and/or other input devices.

Though I would find it tough for anyone to wait until the end to implement any mappers since they are usually itching to see some of the more popular games running on their emu.

"my emulator always has it starting showing it all and it moves upwards off the screen on the top"

It sounds like you are starting from the wrong nametable, which means that your scrolling code is not reading the proper nametable that is being written to ppu register at 0x2000. I believe Pacman starts at nametable 2800 and scrolls until it reaches the top and then the nametable changes to 2000.

User avatar
miker00lz
Posts: 235
Joined: Thu Sep 23, 2010 7:28 pm

Post by miker00lz » Fri Sep 24, 2010 8:29 pm

thanks for the links. i've actually run nestress on it. the results were pretty bleak, this was from a few days ago:

Image

although, i've since gotten the sprite limiter working. i just ran it again to see what it shows, but currently it locks at the main screen. so, thats.... far from good. i need to figure out what happened.

i expect the CPU to be in good shape, it's the 6502 core by neil bradley but i've ported it to freebasic from C. don't believe i altered any functionality but i'll run tests though. you're right i need to concentrate on the core features first. i did find a game it plays without crashing or restarting the ROM though, 3d world runner or whatever the title is of that. the scrolling is screwy though, of course.

User avatar
miker00lz
Posts: 235
Joined: Thu Sep 23, 2010 7:28 pm

Post by miker00lz » Sat Oct 02, 2010 5:12 pm

i was getting fed-up with doing it in FreeBASIC. i had a bunch of bugs i couldn't fix, and it was kind of slow. so i started re-writing it in C the other day. working good so far, still heavy under development of course.

uses SDL, compiles in linux/win32/OS X and probably whatever else gcc and libSDL are available for. here it is on my debian laptop.

Image 8)

Post Reply