It is currently Sun Dec 17, 2017 5:15 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: Thu Aug 18, 2016 6:39 pm 
Offline

Joined: Sat Jun 27, 2015 1:09 pm
Posts: 70
Hi ! After 2 weeks of programming my first NES emulator, I managed to get Donkey Kong working, Karateka working, and probably some others.

Super Mario Bros demanded lots of changes, I had to rewrite my entire video handling since the top bar keep flickering and missing sprite 0 hits, but now it works perfectly.

Except, for some weird reason, Mario has too many momentum, and if I run, he will only stop after 2 seconds. I have no idea what is causing this.

I think it should be logic related, but my cpu is passing all the official opcodes with that nestest rom.

Also, in the demo, Mario dies with the first goomba, again, probably because he cannot stop quick enough to jump !

Since most people here know every emulation bug on SMB, do you have any hints or idea of what may be causing this weird behaviour ?


Top
 Profile  
 
PostPosted: Thu Aug 18, 2016 7:45 pm 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2983
Location: Tampere, Finland
NESTest is not conclusive. Try blargg's CPU test ROMs.

It definitely sounds like a CPU bug.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Fri Aug 19, 2016 1:28 pm 
Offline

Joined: Thu Feb 28, 2013 11:14 am
Posts: 43
My first step would be verifying ROM checksums and checking if it is runs the same way in other emulators. It is definitely CPU bug assuming you have a good rom.


Top
 Profile  
 
PostPosted: Fri Aug 19, 2016 4:42 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3969
Even if the instructions are executed correctly, sometimes the RAM or memory map implementation might have bugs. Not sure if that's the case here or not.

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


Top
 Profile  
 
PostPosted: Fri Aug 19, 2016 5:05 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3076
Location: Brazil
Perhaps non-sense, but did you check your joypad polling ($4016/17)?


Top
 Profile  
 
PostPosted: Tue Aug 23, 2016 9:08 am 
Offline

Joined: Sat Jun 27, 2015 1:09 pm
Posts: 70
I'm trying to implement MMC1 for that test rom, since it requires it.

I'm gonna check the joypad inputs, weird since they seem to work correctly for other games. I'll see what I can find


Top
 Profile  
 
PostPosted: Tue Aug 23, 2016 9:58 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10169
Location: Rio de Janeiro - Brazil
DarkMoe wrote:
I'm gonna check the joypad inputs, weird since they seem to work correctly for other games. I'll see what I can find

Games read the controllers in different ways... Some rely on open bus, or use more than 1 bit from the byte read from the controller register, or expect different results when reading them more than 8 times... There's plenty that can go wrong with input handling, even if it works fine in most games.


Top
 Profile  
 
PostPosted: Tue Aug 23, 2016 10:14 am 
Offline

Joined: Sat Jun 27, 2015 1:09 pm
Posts: 70
Ok so my current logic is this:

when writting to 4016, bit 0 is strobe bit.
When reading 4016, I have an internal pointer that gets a bit from my buttons status, if strobe is 1, returns the current bit of the buttons (ored with 0x40, read somewhere that paperboy needed that), increment the pointer (wraps at 8). If strobe is 0, always return the first bit of the buttons status (A button).

Seems like Mario is always writting 0 and 1 to strobe, and then proceeds to read the 8 bits for the buttons, so it doesn't look like it relies on weird behaviour. But you are the experts =)

any leads ?


Top
 Profile  
 
PostPosted: Tue Aug 23, 2016 10:22 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5899
Location: Canada
It doesn't wrap at 8. Usually it will start returning all 1 bits after 8 (though some devices have other behaviour).

Games don't normally read more than 8, though, unless because of the DPCM glitch.


Top
 Profile  
 
PostPosted: Tue Aug 23, 2016 10:44 am 
Offline

Joined: Sat Jun 27, 2015 1:09 pm
Posts: 70
Ok, changed the behaviour for not wrapping that pointer. Of course this didn't fix Mario's movement but thanks


Top
 Profile  
 
PostPosted: Tue Aug 23, 2016 10:52 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
I'd still maintain this is a CPU emulation instruction or addressing mode bug.

An alternate approach would be to implement a trace log identical to Nintendulator or FCEUX, then compare the results to your emulator.

Also, are you zeroing the memory contents of $0000-07FF in your emulator before the game starts up? Uninitialised areas of allocated memory could result in odd behaviour.


Top
 Profile  
 
PostPosted: Tue Aug 23, 2016 11:05 am 
Offline

Joined: Sat Jun 27, 2015 1:09 pm
Posts: 70
Yes sir, Im doing all that.

I will come back with results once I can run those cpu tests, again, I need to implement MMC1.

Thanks for your help !


Top
 Profile  
 
PostPosted: Wed Aug 24, 2016 4:56 pm 
Offline

Joined: Fri Dec 30, 2011 7:15 am
Posts: 43
Location: Sweden
All the "rom_singles" tests in instr_test do not need MMC1, so you could try that.


Top
 Profile  
 
PostPosted: Wed Aug 24, 2016 5:25 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1393
DarkMoe wrote:
When reading 4016, I have an internal pointer that gets a bit from my buttons status, if strobe is 1, returns the current bit of the buttons (ored with 0x40, read somewhere that paperboy needed that), increment the pointer (wraps at 8). If strobe is 0, always return the first bit of the buttons status (A button).

Er, I'm pretty sure that's backwards - strobe=1 is when the button states are copied into the shift register, and strobe=0 is what allows them to be read back.

DarkMoe wrote:
Seems like Mario is always writting 0 and 1 to strobe, and then proceeds to read the 8 bits for the buttons.

Actually, it writes 1 followed by 0, just like every other NES game which uses standard controllers.

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


Top
 Profile  
 
PostPosted: Thu Sep 22, 2016 6:23 am 
Offline

Joined: Sat Jun 27, 2015 1:09 pm
Posts: 70
Managed to fix it.

Turns out my shift left function, was setting carry flag from bit 7 of Accumulator, instead of using the operator passed to the function.

Figured it out implementing unofficial opcodes that use the ASL function.


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google [Bot], sdm 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