It is currently Mon Oct 16, 2017 9:10 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: MoarNES 0.11.12.12 alpha
PostPosted: Mon Dec 12, 2011 12:02 pm 
Offline
User avatar

Joined: Thu Sep 23, 2010 7:28 pm
Posts: 232
as if the world needs another NES emu, this is the current version of my new attempt at a NES emulator. it's still very much an alpha-quality program, but i thought i would upload it because i really wanted to get some opinions/suggestions/comments on it as-is.

features:
-load/save state from/to files
-quick-save slots (four of them F1 through F4 saves, F5 through F8 loads)
-authentic game genie support (GG ROM is included)
-supports mappers 0, 1, 2, 3, 4, 7, 9, 10, 11, and 13 (i think this covers most of the common ones)


there are a good number of problems/bugs in it still, some of the known ones:
-APU sweeps do not work (i wasn't able to get it to sound right)
-mike tyson's punch out background color is incorrect for some reason. menu and versus screens show some graphical glitching (but the actual fights look fine)
-mapper 4 IRQ stuff doesn't work quite right, but lots of the games still play
-audio output is sometimes a little jittery. it's not the APU code, it's an output buffering problem. it's not that bad.
-was having problems with sprite 0 hit intermittently not working, so there's a cheap band-aid hack for now that always flips the sprite 0 hit flag on the last scanline of the sprite without checking if it collides with a background pixel.
-when you load a saved state from file, usually the audio sounds strange but it does fix itself within a few seconds.

win32 binary: http://rubbermallet.org/MoarNES-0.11.12.12.zip
(it runs great in WINE on linux too, i will eventually make native linux bins)

source (VS 2003 solution): http://rubbermallet.org/MoarNES-0.11.12.12-source.zip


in spite of the problems, lots of games play perfectly. i'd love to hear opinions/ideas if you try it. a couple screenshots:

Image

Image

if you decide to give it a shot, thank you! :D


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2011 12:43 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3940
I can clearly see that scrolling is emulated completely incorrectly. The proper way to do it is to just use "loopy_t" and "loopy_v", and the rules for updating/incrementing them. Throw out whatever algorithm you are using, and use that instead.

Battletoads is broken (it's not scrolling), NES Chu Chu Rocket shows a gray screen, Bad News Baseball is screwed up, tons of bugs here.
Super Mario Bros 3's status bar screws up when you fly (Nesticle 0.1's readme also described this bug), and stomped enemies are missing sprites. Sounds like CPU flaws for the missing sprites problem, since other flipped sprites work fine.

Sound is at the wrong pitch, sounds like a PAL system, even though the emulator is emulating an NTSC system.

Right now, it feels like the reincarnation of Nesticle, just without the high performance of Nesticle.

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2011 3:04 pm 
Offline
User avatar

Joined: Thu Sep 23, 2010 7:28 pm
Posts: 232
Dwedit wrote:
I can clearly see that scrolling is emulated completely incorrectly. The proper way to do it is to just use "loopy_t" and "loopy_v", and the rules for updating/incrementing them. Throw out whatever algorithm you are using, and use that instead.

Battletoads is broken (it's not scrolling), NES Chu Chu Rocket shows a gray screen, Bad News Baseball is screwed up, tons of bugs here.
Super Mario Bros 3's status bar screws up when you fly (Nesticle 0.1's readme also described this bug), and stomped enemies are missing sprites. Sounds like CPU flaws for the missing sprites problem, since other flipped sprites work fine.

Sound is at the wrong pitch, sounds like a PAL system, even though the emulator is emulating an NTSC system.

Right now, it feels like the reincarnation of Nesticle, just without the high performance of Nesticle.


thanks, this is exactly why i posted it. i don't think it's a good emu and i'm not fishing for compliments, you guys will be able to point things out that i didn't realize were bad - i'm pretty new to this.

the SMB3 status bar i was aware of, but was not sure why; i'm not able to find that old version of NESticle anywhere to check the readme, either.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2011 3:14 pm 
Offline

Joined: Thu Jul 24, 2008 3:23 pm
Posts: 12
Location: Moscow, Russia
Dwedit wrote:
(Nesticle 0.1's readme also described this bug)


I thought 0.2 was the initial version. Do you have a copy of 0.1? If so, could you please upload this piece of antiquity?

miker00lz wrote:
i'm not able to find that old version of NESticle anywhere to check the readme, either.


Here's the link to 0.2:
http://web.archive.org/web/200511151120 ... stc020.zip


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2011 3:23 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3940
I didn't remember the version number, so I was guessing. Sorry.

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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 14, 2011 2:42 am 
Offline
User avatar

Joined: Thu Sep 23, 2010 7:28 pm
Posts: 232
alright, well.. a couple things, first of all i'm going for pixel-accuracy now. JUST about got it, as you can see from this marble madness screenshot. as you probably know that game needs very precise timing for the nametables to switch mid-scanline to display the text box at the beginning of levels.

Image


i also understand the relationship between the scroll and address registers now, and i'm going to implement the new scrolling method tomorrow. a bit too tired to get to it now.

the too-low audio pitch is as easy fix as well. i will also search for the CPU bug that causes the SMB3 flipped sprites issue. it seems to only be on crushed enemies.

i think if i get all that taken care of i think i will have a fairly respectable emu here. i think the scroll registers/VRAM pointer stuff will also fix the flashing status bar in SMB1.

my other plan, after that stuff, is to add movie record/playable capability including frame-stepping backwards so it can be used to make "tool-assisted" runs.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 14, 2011 7:25 pm 
Offline

Joined: Thu Apr 14, 2011 9:27 pm
Posts: 85
I tested a few games.
Solstice:
-There seems to be random corrupt graphics appearing on the title screen, which change if another game is loaded first. This suggests that memory is not being cleared properly when a game is unloaded.
-The demo desyncs and freezes
-Something seems to be wrong with the physics code since it's possible to jump on spikes without getting hurt, and getting the first key causes the character to fall through the level and die.
Donkey Kong:
It's impossible to jump. I remember having this problem as well in my emulator and there was a specific CPU bug that caused it.
Teenage Mutant Ninja Turtles:
Backgrounds are missing in the intro. The game sets a negative scroll value so that needs to be handled correctly.
Teenage Mutant Ninja Turtles 3:
Won't start - this has something to do with the APU frame counter IRQ firing too early.
Super Mario Bros:
You're absolutely right that the flickery status bar is due to the fake Sprite 0 hit. Another thing that you might not have noticed is that if you hit a coin block in World 1-2 the sound keeps playing forever. It took me months to find out why that was happening myself: if an APU channel is disabled from the status register, the length counter for that channel needs to immediately be forced to zero.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 16, 2011 2:24 am 
Offline
User avatar

Joined: Thu Sep 23, 2010 7:28 pm
Posts: 232
Grapeshot wrote:
I tested a few games.
Solstice:
-There seems to be random corrupt graphics appearing on the title screen, which change if another game is loaded first. This suggests that memory is not being cleared properly when a game is unloaded.
-The demo desyncs and freezes
-Something seems to be wrong with the physics code since it's possible to jump on spikes without getting hurt, and getting the first key causes the character to fall through the level and die.
Donkey Kong:
It's impossible to jump. I remember having this problem as well in my emulator and there was a specific CPU bug that caused it.
Teenage Mutant Ninja Turtles:
Backgrounds are missing in the intro. The game sets a negative scroll value so that needs to be handled correctly.
Teenage Mutant Ninja Turtles 3:
Won't start - this has something to do with the APU frame counter IRQ firing too early.
Super Mario Bros:
You're absolutely right that the flickery status bar is due to the fake Sprite 0 hit. Another thing that you might not have noticed is that if you hit a coin block in World 1-2 the sound keeps playing forever. It took me months to find out why that was happening myself: if an APU channel is disabled from the status register, the length counter for that channel needs to immediately be forced to zero.


thanks for giving it a try!

you don't happen to remember what the bug in your CPU code was, do you? i definitely have an issue with it somewhere, but it passes whatever tests i throw at it. if i drop neil bradley's CPU core into my emu, that donkey kong bug as well as the missing flipped sprites on the crushed enemies in SMB3 are both fixed.

the SMB1 flickering status bar wasn't caused by the fake sprite zero hit, it was actually because the game changes the scroll registers occasionally via port $2006. i didn't realize until recently that writes to $2006 also affect the scroll regs. after adding that, my sprite zero hit works correctly without my cheap hack and the status bar is now solid.

that was also causing the scroll problems in battletoads. i'm getting pretty close to that one working correctly now too.

Image

the status bar isn't visible for some reason though, and sometimes the vscroll is about 10 scanlines off or so. it's progress, at least! the intro sequence and the part where it shows the ship and the toad going down to the surface on the rope is all flawless.

to get the vscroll value for the frame, i'm reading it at 256 PPU clocks into the pre-render scanline. i read that this is correct, but maybe i had bad info. do i have it right?

if i can get battletoads and SMB3 working perfectly, i think that i'll have this emu in decent shape and then i can go from there. BT is supposedly one of the most difficult games to emulate properly. :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 16, 2011 9:33 am 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3940
Battletoads also requires you to emulate the 1 CPU Cycle Penalty for page crossing nnnn,Y instructions, otherwise the screen shakes.
Then for the Snake Pit level, you need to ignore Sprite 0 hits that happen at X=255.

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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 16, 2011 1:41 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3064
Location: Brazil
Dwedit wrote:
Then for the Snake Pit level, you need to ignore Sprite 0 hits that happen at X=255.


News to me. Is this a game-specific thing?

_________________
Zepper
RockNES developer


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 16, 2011 2:05 pm 
Offline
User avatar

Joined: Thu Sep 23, 2010 7:28 pm
Posts: 232
Zepper wrote:
Dwedit wrote:
Then for the Snake Pit level, you need to ignore Sprite 0 hits that happen at X=255.


News to me. Is this a game-specific thing?


i'd guess this is the only game that it matters for, but the real NES doesn't set the sprite zero hit flag on pixel 255.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 16, 2011 2:16 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3064
Location: Brazil
miker00lz wrote:
Zepper wrote:
Dwedit wrote:
Then for the Snake Pit level, you need to ignore Sprite 0 hits that happen at X=255.


News to me. Is this a game-specific thing?


i'd guess this is the only game that it matters for, but the real NES doesn't set the sprite zero hit flag on pixel 255.


Oh my... you're right.
Code:
06.right_edge
-------------
Tests sprite 0 hit with regard to column 255 (ignored) and off right
edge of screen.

_________________
Zepper
RockNES developer


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 17, 2011 1:19 pm 
Offline

Joined: Thu Apr 14, 2011 9:27 pm
Posts: 85
I checked in my old code (which took some work because I fixed that bug before I had posted any of my code to SVN), and the CPU bug is that the BIT opcode needs to set the negative flag and overflow flag to bits 7 and 6 (respectively) of the value read from memory. For some reason NESTest doesn't test this, but Blargg's individual instruction tests do. You should try running those, even though the messages for failures are less than helpful.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 17, 2011 2:29 pm 
Offline
User avatar

Joined: Thu Sep 23, 2010 7:28 pm
Posts: 232
Grapeshot wrote:
I checked in my old code (which took some work because I fixed that bug before I had posted any of my code to SVN), and the CPU bug is that the BIT opcode needs to set the negative flag and overflow flag to bits 7 and 6 (respectively) of the value read from memory. For some reason NESTest doesn't test this, but Blargg's individual instruction tests do. You should try running those, even though the messages for failures are less than helpful.


Image AWESOME Image

that you very much for checking, that was my problem as well. i actually did try to implement that behavior when i first wrote the BIT opcode, but i had made a small typo. it looked like this:

Code:
static void bit() {
    value = getvalue();
    result = (uint16_t)a & value;
   
    zerocalc(result);
    status = (status & 0xBF) | (uint8_t)(value & 0xC0);
}


the error is on that last line... (status & 0xBF) should have been (status & 0x3F) SMB3 and donkey kong now work correctly. another problem it caused was SMB2 would just stuck in an endless loop right after selecting your character. that works now too. a few other games that showed grey screens before (one was 3-D World Runner) now run.

does the AND opcode do the same thing, or is it just BIT? i ask because in the x86 instruction set, AND and TEST (which is like the 6502's BIT) both do identical things to the flags except TEST doesn't store the result anywhere.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 17, 2011 2:57 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19084
Location: NE Indiana, USA (NTSC)
AND doesn't touch V, and it sets N to the value of bit 7 after the calculation, not the value of bit 7 straight from memory.


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 6 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