NES emulator in FreeBASIC

User projects written in or related to FreeBASIC.
Mike Chambers
Posts: 85
Joined: Jun 18, 2006 19:48

NES emulator in FreeBASIC

Post by Mike Chambers »

EDIT 5-1-11: skip down to my new post containing a complete rewrite! do not download the link at the bottom of this post. get this instead: http://rubbermallet.org/moarnes-0.11.5.7.zip

i started working on this about a month ago, and it's built around the 6502 core used in my FB apple 2 emulator that i posted some time ago.

it's far from finished, but it's getting there. thought some people here might be interested in this project. :)

currently it only will work with mapper 0 and 2 ROMs. very few games actually go completely in-game, and the ones that do can be glitchy. i have the best luck so far with "Starship Hector" and "3D Battles of World Runner"

here are some screenshots to give you an idea of the progress:

Image Image Image Image Image Image Image Image Image Image ImageImage

aaaaand, here is the source code:
http://irc.rubbermallet.org/extranes-freebasic.rar
Last edited by Mike Chambers on May 13, 2011 17:14, edited 3 times in total.
angros47
Posts: 2323
Joined: Jun 21, 2005 19:04

Post by angros47 »

I always like these programs...

Great work!
badmrbox
Posts: 664
Joined: Oct 27, 2005 14:40
Location: Sweden
Contact:

Post by badmrbox »

Me likey :).
Keep up the work.
agamemnus
Posts: 1842
Joined: Jun 02, 2005 4:48

Post by agamemnus »

Nice.

It always amazes me how those programs from over 20 years ago were actually written by teams of programmers and artists, with hundreds of thousands and sometimes millions of dollars spent on some of them, and with gaggles of marketeers and execs looking over the programmers' shoulders!
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Post by D.J.Peters »

good job

Joshy
Mike Chambers
Posts: 85
Joined: Jun 18, 2006 19:48

Post by Mike Chambers »

thanks for the comments guys. :)

i've officially abandoned this as of a couple days ago. i love FB, but i thought it was a good idea to can this and start over in C. i've already gotten much farther and i can even completely play all of mega man 1.

plus i'm using SDL, and i've been able to compile it in windows, linux, OS X (on a G3), and even on an ANCIENT powermac 6100/60. (1st gen PPC)

it seems to work fine on any platform SDL can be used on. portability is the biggest reason for the switch, but it's also so much faster than the FB version it's crazy.

screenshot of it on a linux box:

Image
Mike Chambers
Posts: 85
Joined: Jun 18, 2006 19:48

Post by Mike Chambers »

hey all, bumping this after a long time because even though i moved my NES emu to C, recently i decided to give it another go in FB, and the results are looking okay right now.

Image

current status:
-most mapper 0, 1, 2 games are working more or less fine
-audio emulation is working (and it sounds pretty decent)
-a few graphical bugs in some games, occasional palette weirdness, sprite priority problems in some games
-possible 6502 CPU core glitches, but mostly seems fine

need to do:
-add a lot of other game mapper chips support!!
-speed up the PPU engine
-improve the audio emulation

well-tested games:
-mega man 2 (other mega man games should be good as well)
-contra
-starship hector
-donkey kong
-chip and dale rescue rangers
-many others should work as well

the biggest problem right now is how SLOW the PPU engine is. the actual rendering to screen is very fast, that uses SDL. the slow part is the code to emulate the NES hardware parts that looks at whats supposed to be on the screen and evaluates/draws it to a buffer. any dual core machine should run it FINE but i've found that all but the fastest pentium 4 systems need to use frameskip to run full speed. i really need to work on that. it's the stuff in modPPU.bas if you look at the source.

download:
compiled win32 binary - http://rubbermallet.org/moarnes-0.5.1.11.zip
sourcce code - http://rubbermallet.org/moarnes-0.5.1.11-source.zip

just run moarnes.exe to see how to use the command line. the first time you run a game it will ask you to configure your control keys.

i'd love to get comments and suggestions! enjoy! :)

my C version is far more advanced but i like the idea of having a pure FreeBASIC NES emu that is viable as well!
Mihail_B
Posts: 273
Joined: Jan 29, 2008 11:20
Location: Romania
Contact:

Post by Mihail_B »

Mikey this seems not to work ...
http://irc.rubbermallet.org/extranes-freebasic.rar
Mirror ?
Mike Chambers
Posts: 85
Joined: Jun 18, 2006 19:48

Post by Mike Chambers »

Mihail_B wrote:Mikey this seems not to work ...
http://irc.rubbermallet.org/extranes-freebasic.rar
Mirror ?
hi mihal, yes that was the link to my very old first try at this last year. check my last post, it has the current link http://rubbermallet.org/moarnes-0.5.1.11.zip

thanks for checking it out! :)
kiyotewolf
Posts: 1009
Joined: Oct 11, 2008 7:42
Location: ABQ, NM
Contact:

Post by kiyotewolf »

"-possible 6502 CPU core glitches, but mostly seems fine"
Some games may be tricking the CPU using undocumented features.
I found just today, a 6502 glitch list, on an old apple website.
/
http://www.textfiles.com/apple/6502.bugs.txt



~Kiyote!

[edit 2more]

"looks at whats supposed to be on the screen and evaluates/draws it to a buffer. any dual core machine should run it FINE"

You should ask me in email.
I can go into detail how I figured out the NES sprite priority trick, it's how my 7x7x16 trick works from back in the day.
It requires an 8-bit 256 color palette, and works by making plaid stripes in the palette, to achieve sprite vs background priorities.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Post by D.J.Peters »

Mike i changed your NESi :-)

download: moarnes_fb_mode.zip

for the -lang FB mode
but i don't get the bolder dash ROM working.
Do you know what are wrong with your emulator ?

Before i can help you to make it really fast
the logic must be ok, you know?

Joshy
Mike Chambers
Posts: 85
Joined: Jun 18, 2006 19:48

Post by Mike Chambers »

D.J.Peters wrote:Mike i changed your NESi :-)

download: moarnes_fb_mode.zip

for the -lang FB mode
but i don't get the bolder dash ROM working.
Do you know what are wrong with your emulator ?

Before i can help you to make it really fast
the logic must be ok, you know?

Joshy
hi joshy, just peeked in that zip file - good stuff thanks. i have a nasty habit of writing everything in fblite. you should have a look at this latest version.. lots of bug fixes and the background rendering code has been optimized by changing it to mostly assembly.

http://rubbermallet.org/moarnes-0.11.5.6.zip

not sure why boulder dash doesn't work. it does work in the C version of MoarNES though. i'll have to compare the code from the two and see what the deal is there.

thanks for havin a peek at the emu, i think it's a solid start to having a decent FB NES emu! :) plenty of work to go though..
Last edited by Mike Chambers on May 06, 2011 15:38, edited 1 time in total.
Mike Chambers
Posts: 85
Joined: Jun 18, 2006 19:48

Post by Mike Chambers »

kiyotewolf wrote:"-possible 6502 CPU core glitches, but mostly seems fine"
Some games may be tricking the CPU using undocumented features.
I found just today, a 6502 glitch list, on an old apple website.
/
http://www.textfiles.com/apple/6502.bugs.txt



~Kiyote!

[edit 2more]

"looks at whats supposed to be on the screen and evaluates/draws it to a buffer. any dual core machine should run it FINE"

You should ask me in email.
I can go into detail how I figured out the NES sprite priority trick, it's how my 7x7x16 trick works from back in the day.
It requires an 8-bit 256 color palette, and works by making plaid stripes in the palette, to achieve sprite vs background priorities.
hey kiyote you just reminded me to actually check my email i hadn't in a few days! lol. i didn't know you did any NES deving.
kiyotewolf
Posts: 1009
Joined: Oct 11, 2008 7:42
Location: ABQ, NM
Contact:

Post by kiyotewolf »

i didn't know you did any NES deving.
I do it coming at it perpendicularly.
I found out that MCGA and the NES PPU graphics chip, the Mode 19h 320x200x256 mode specifically, have alot in common.



~Kiyote!

Plus, I know 6502 like english.
super_castle
Posts: 289
Joined: Oct 10, 2006 7:19

Post by super_castle »

Post Reply