New NES emulator!

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
New NES emulator!
by on (#76048)
Hello,

My name is ultimate_coder. I am 13 and me and two of my friends have started making a new NES emulator. It's made in C and it's called UltiNES. Our goal is 100% compatibility and support for OpenGL. We need some help with sound, but my cousin knows how to make MIDI files, so he'll probably write that part.

We started the day after Christmas. My friend showed me an emulator, nestopia, and I knew we could make a better one. We got pretty far since then but need just a little bit of help. Can someone tell me where we should go from here? This is a part of our code. This is the part that does the emulating (but I didn't show our cpu code because it's super-fast and I think we're going to sell it to other emulator coders:


Code:
FILE *fp;

fp = fopen("mario.nes", "r");
{
 printf("File is open\r\n");
 
 //ignore ines header because it doesn't work for
 //so many games.  hx0r is writing ZapFC support
 fseek(fp, 16, SEEK_SET);

 do {
  //read in operation code and next parameters
  //void execute_operation_code(int *code, int *next_byte1, int *next_byte2)
  int code = fgetc(fp);
  int next_byte1 = fgetc(fp);
  int next_byte2 = fgetc(fp);

  execute_operation_code(&code, &next_byte1, &next_byte2);

  if (code == 'H' && next_byte1 == 'L' && next_byte2 == 'T')
   return -1;
 
  //this doesn't do anything yet.  we're going to need a couple of more days
  //to write 100% accurate graphics.
  execute_ppu_integrated_circuit();

  if (artificial_intelligence == 4/1)
   autoplay_mario();

  get_keyboard_presses();
  draw_to_opengl();
 
  //my cousin will write this
  //play_sound();
 } while (true);
}


We made a ppu but it didn't work well, so we're going to start over. Can someone send us some sample code? We looked at other emulator source code, but they're way too complex. How do I get in touch with Loopy and Brad Taylor. I think they can help.

Also, I don't think our cpu is working right yet, but it makes my task manager show high cpu usage, so it must be working correctly. Does anyone have any ideas?

Oh if you want to join our team, we're looking for good developers. Let me know and we'll look at your code to see if you're good enough for the team.

bye! :D

by on (#76049)
This looks great guys. I'm surprised no one has taken this approach yet, so simple. Simple and elegant solutions are sometimes the best. I don't have a lot of free time, but I'm very interested in joining your team.

by on (#76050)
Any chance you could make the code QBasic compatible because that's all I use? Just an idea.

by on (#76052)
thefox wrote:
Any chance you could make the code QBasic compatible because that's all I use? Just an idea.


Good point. C is hard to understand when you are used to Basic.

by on (#76053)
cartlemmy wrote:
I don't have a lot of free time, but I'm very interested in joining your team.

Did you make your avatar with a ppu? Can you send us the code?

by on (#76054)
ultimate_coder wrote:
cartlemmy wrote:
I don't have a lot of free time, but I'm very interested in joining your team.

Did you make your avatar with a ppu? Can you send us the code?


Yes, it is my own custom PPU code. I can send a part of the code (It is in Perl, you think you can port it to C?) so you can decide if I am the sort of programmer you are looking for. (PMed)

by on (#76055)
thefox wrote:
Any chance you could make the code QBasic compatible because that's all I use? Just an idea.


COOL -- I just looked at this on google and it's so much easier! We're going to switch! THANKS!!!

p.s. that Nibbles game looks awesome!

by on (#76056)
ultimate_coder wrote:
p.s. that Nibbles game looks awesome!


Woah, Nibbles is in Basic??? Somebody told me that basic couldn't do good graphics. They were WRONG!

by on (#76057)
cartlemmy wrote:
I can send a part of the code (It is in Perl, you think you can port it to C?) so you can decide if I am the sort of programmer you are looking for. (PMed)

Thanks for the code. We voted and you can be on the team.

We're trying to convert it to QBasic. What does this part do?
Code:
print pack('H*', '486170707920417072696c20466f6f6c73272044617921');

by on (#76058)
ultimate_coder wrote:
cartlemmy wrote:
I can send a part of the code (It is in Perl, you think you can port it to C?) so you can decide if I am the sort of programmer you are looking for. (PMed)

Thanks for the code. We voted and you can be on the team.

We're trying to convert it to QBasic. What does this part do?
Code:
print pack('H*', '486170707920417072696c20466f6f6c73272044617921');


Hoo-rah!
Yeah, that part clears the screen buffer. In QBasic it is much simpler. You need to convert it like so:

Code:
  Private Function HexToString(Value As String)
    Dim szTemp As String
    szTemp = Value
   
    Dim szData As String
    szData = ""
    While Len(szTemp) > 0
        szData = Chr(CLng("&h" & Right(szTemp, 2))) & szData
        If (Len(szTemp) = 1) Then
            szTemp = Left(szTemp, Len(szTemp) - 1)
        Else
            szTemp = Left(szTemp, Len(szTemp) - 2)
        End If
    Wend
    HexToString = szData
End Function

PRINT HexToString("49204c4f4c65642e205468652066756e6e79207468696e67206973207468617420746869732069736e2774206661722066726f6d207265616c20706f7374732e")


I'm a little rusty at Qbasic, so this may need some tweaking. The cool thing about QBasic is you get to create your own function for something like this. It goes down smooth, like an everclear habenero glass smoothie.

by on (#76059)
Something must be wrong. I'm testing your perl and qbasic code on my linux box. I was stupid and ran it as root, there was a shitload of disk activity, and now my kernel panicked. :( Please send help fast.

by on (#76060)
:shock:


This whole thread is a joke, right?

by on (#76061)
qbradq wrote:
:shock:
This whole thread is a joke, right?


I hope not. I really want to see this new emu that is better than nestopia. I already lost 3 boxes to testing it. I've only got 25 more at our DR site left. Then I suppose I'll have to start testing in production. They get kinda pissy when I do that.

Hurry up with the code fixes!

by on (#76062)
clueless wrote:
Something must be wrong. I'm testing your perl and qbasic code on my linux box. I was stupid and ran it as root, there was a shitload of disk activity, and now my kernel panicked. :( Please send help fast.


Yeah, I run it under my linux box in Wine, and then run dos box inside of Wine for that extra layer of protection. It works great that way.

by on (#76063)
cartlemmy wrote:
clueless wrote:
Something must be wrong. I'm testing your perl and qbasic code on my linux box. I was stupid and ran it as root, there was a shitload of disk activity, and now my kernel panicked. :( Please send help fast.


Yeah, I run it under my linux box in Wine, and then run dos box inside of Wine for that extra layer of protection. It works great that way.


I don't have wine, I don't like to drink.

But I can run dos in softpc inside a Mac LC-ii emulated on Basilisk running on my surviving linux box. Is that enough protection?

by on (#76064)
clueless wrote:
...But I can run dos in softpc inside a Mac LC-ii emulated on Basilisk running on my surviving linux box. Is that enough protection?


Now don't I feel like an idiot. Yes, that's far better than my method. Let us know how it works.

by on (#76065)
Well if it's being re-written in QBasic you could run it in interpreted mode inside FreeDOS running on a VirtualBox instance inside Open Solaris running on top of a Xen hyperviser.

by on (#76066)
I managed to hack into ultimate_coder's PC and grab his emu source code (the full beta). I gave it a whirl. Tried my yars game in it. The emu is still a bit buggy, as Yar fly off the screen and across the room. My cat is currently chasing it. I hope that yar doesn't launch the cannon at my cat.

by on (#76067)
Holy cow! It's like that episode of Star Trek: TNG where the holographic Professor Moriarty steps off the holodeck and becomes real, only he didn't really become real but really tricked Captain Picard and Will Riker into thinking he really became real when in reallity they were really all still on the holodeck and talking to non-real holo-clones of the crew, but then got wise to what was really real and tricked Moriarty and his wife (that chick from Dr. Quinn, which was a totally real show BTW, not holo-real like she was in this episode, but really real) into thinking they were on the real ship, when really they were inside another holo-real holodeck on the holodeck Moriarty trapped them in to begin with, but they didn't know, and the then holo-holo-real Moriarty and not really Dr. Quinn chick thought they were really really for real and flying in a real (but in fact holo-holo-real) shuttle to Alpha Centauri?

Like that?

I wounder what would happen if you loaded up the SNES version of Star Trek: TNG into that thing.

On second thought, you'd better not try it. The Universe might implode on itself :shock:

Go feed your cat.

by on (#76072)
happy april fools

by on (#76074)
I figured out how to do that that "print pack" stuff in Python too:
Code:
import binascii
binascii.a2b_hex('596f7520676f74205269636b20526f6c6c656421')


Even apart from AFD, there have been times when I've had to resort to running nested emulators, such as when the movie-to-AVI of both Nestopia and Nintendulator refused to work with either of my installed lossless video codecs but PocketNES in VisualBoyAdvance handled it fine.
Re: New NES emulator!
by on (#76095)
ultimate_coder wrote:
Code:
  if (artificial_intelligence == 4/1)
   autoplay_mario();

What do you know? Someone else had this idea too (or got it from me). I'm planning an autoplay ai feature for all games in my emulator NESFaCE. I'm sort of wondering what the significance of 4/1 is, and also why it's not written just 4. I also have to say I'm fairly skeptical of this emulator that you've only posted a tiny bit of code for, announced on April 1, and claim will be better than Nestopia. Of course, I'm hoping my emulator too will be better than Nestopia, but I think it will take several years. But hey, if this project is for real, by all means go for it. I welcome the competition.
Re: New NES emulator!
by on (#76112)
6T4 wrote:
ultimate_coder wrote:
Code:
  if (artificial_intelligence == 4/1)
   autoplay_mario();

What do you know? Someone else had this idea too (or got it from me). I'm planning an autoplay ai feature for all games in my emulator NESFaCE. I'm sort of wondering what the significance of 4/1 is, and also why it's not written just 4. I also have to say I'm fairly skeptical of this emulator that you've only posted a tiny bit of code for, announced on April 1, and claim will be better than Nestopia. Of course, I'm hoping my emulator too will be better than Nestopia, but I think it will take several years. But hey, if this project is for real, by all means go for it. I welcome the competition.

Image
Re: New NES emulator!
by on (#76170)
6T4 wrote:
I'm sort of wondering what the significance of 4/1 is, and also why it's not written just 4.
I also have to say I'm fairly skeptical of this emulator ... announced on April 1 ...

I think you have your answer as to why it's written "4/1" :)

by on (#76202)
This is the only thing I almost fell for. It didn't even cross my mind at first that this might be an April Fool's post, given that there are legitimate posts exactly like this all the time :/

by on (#76206)
going.to/nowhere :(
Re: New NES emulator!
by on (#76207)
teaguecl wrote:
6T4 wrote:
I'm sort of wondering what the significance of 4/1 is, and also why it's not written just 4.
I also have to say I'm fairly skeptical of this emulator ... announced on April 1 ...

I think you have your answer as to why it's written "4/1" :)

Ah, I didn't make the connection that 4/1 = April 1 the first time I read this... I'm a little disappointed in myself.

by on (#76226)
No wonder I didn't get this thread*, that particular day had already ended here when the OP posted this.


*Actually I thought this was an old thread and I didn't pay much attention to it.

by on (#76243)
It's fun you guys took so long to get that this is a joke. After reading 3 lines of the first post I immediately got that this was an april fool.

by on (#76443)
Aww crap i was hoping that this was real because i dont like most nes emulators.

by on (#76449)
gamax92 wrote:
Aww crap i was hoping that this was real because i dont like most nes emulators.

What's wrong with most of them, specifically?

by on (#76452)
I dont know i personally use Jnes because it has worked great for me but ... i actually dont know any other nes emus. but Jnes has worked great for me. So i was hoping that someone made something better.

by on (#76455)
tepples wrote:
What's wrong with most of them, specifically?

None of them play the games themselves, so they suck. I absolutely need an emulator that will play the games for me, because after years of playing the games myself I feel very tired.

Also, all emulators have very poor graphics, like they're stuck in the 80's... All new movies and games are in 3D, but those stupid NES emulators keep displaying old 2D images, how come? This is 2011 for God's sake, how can those stupid NES graphics still be 2D? The next NES emulator better be able to render everything with high-resolution polygons or else I'll abandon retro gaming for good.

by on (#76456)
Well we can tecnically do that with the graphic filters.
Hack the roms to make an ai that plays the game but thats based on the rom.

Use Super2xSal it makes things eaiser on the eyes. If only emus came with a cheat file containing about every single cheat in the world for a game.

by on (#76461)
tokumaru wrote:
tepples wrote:
What's wrong with most of them, specifically?

None of them play the games themselves, so they suck. I absolutely need an emulator that will play the games for me, because after years of playing the games myself I feel very tired.

Then check out a web site called TAS Videos.

Quote:
Also, all emulators have very poor graphics, like they're stuck in the 80's... All new movies and games are in 3D, but those stupid NES emulators keep displaying old 2D images, how come?

Because none of the current emulators map tile numbers to pieces of polygon mesh. If they did, SMB1 could be made to look like it does in Brawl. That would be an interesting research project: imagine the "high resolution texture packs" for N64 games taken up to 11.

by on (#76462)
i just love it when Super2xSal makes a blocky circle into a block circle with smooth corners.

I would be happy if someone made an emulator or graphic plugin that makes a blocky circle into a circle and a image that was blocky but now enlarged into a enlarged version of the smoothed original sized version.

It would make gaming much more awesome. Also what layer is the background image.
You could examine whats on that layer and possibly make shading to the other objects.

EDIT: Its called fake 3D.

by on (#76463)
tepples wrote:
Then check out a web site called TAS Videos.

I just did (although I feel very tired), but it appears I have to download such videos on a game-per-game basis, and that's very troublesome. I'd rather just download an emulator once, and have it play all the games automatically. Surely this can't be hard.

Quote:
Because none of the current emulators map tile numbers to pieces of polygon mesh.

Which is exactly why they suck. I mean, I look at Mario's sprite and I can easily tell it's a fat plumber, so an emulator should be capable of realizing that too, and automatically swap Mario with a high-resolution 3D fat plumber. How hard can this be?

I mean, I look at the NESemdev section of this site and it looks like all conversations are about boring things like IRQs, timing, DMA, OAM, tests, registers and other obsolete, useless things... That forum would be much more useful if we discussed about automatically improving graphics and audio to make the old games look like new games, so that everyone could download a single emulator and play their existing ROM collection (or watch it being played, automatically) without bothering to download anything else.

by on (#76464)
Your forgetting about making the emulator improve the sound of the games. like instead of the choppy decent of a sound, how about a smooth decent of a sound.
Plus the graphical part is actually makeable but don't you wanna play your reborn classic instead of having it play a brand new game?

by on (#76467)
gamax92 wrote:
Your forgetting about making the emulator improve the sound of the games. like instead of the choppy decent of a sound, how about a smooth decent of a sound.

That's entirely doable even on the Famicom hardware. Make a mapper that plays MP3 out the expansion audio pins, then mapper hack your games to use OCRemix music. A lot of early PC Engine CD and Sega CD games were ports from cartridge that did almost exactly this.

by on (#76470)
tepples wrote:
OCRemix music

Can such music be automatically generated by a software based on the original data? Because if a human is necessary to convert the music then I must say this is a very crappy solution.

by on (#76471)
Well i mean like when a sound drops down it usually goes like 255-0 as 255 155 55 0 really choppy. well why don't we smoothen out the drops.

by on (#76478)
This thread is painful. But rather funny.

by on (#76480)
cartlemmy wrote:
This thread is painful. But rather funny.


Its painful to know its an April foolz joke.

by on (#76481)
tokumaru wrote:
I mean, I look at Mario's sprite and I can easily tell it's a fat plumber, so an emulator should be capable of realizing that too, and automatically swap Mario with a high-resolution 3D fat plumber. How hard can this be?


Any idea? Before flamming the "poor" 2D graphics with sprites, have you some idea about improving the things? Any C++ example of yourself, instead of always mentioning the very old NTSC filtering? ;)

Also, don't expect to run SMB1 in 3D (or 2.5D) mode using polygons. It's all about replacement & creation of each polygon. Meh.

There was an MAME-based emulator that used improved gfx and music for games, like for Donkey Kong 1. I don't remember his name.

Go play your Dolphin emulator for good.

by on (#76482)
I think you're referring to EmuDX. its DX packs are currently supported by Raine, IIRC

by on (#76483)
gamax92 wrote:
Well i mean like when a sound drops down it usually goes like 255-0 as 255 155 55 0 really choppy. well why don't we smoothen out the drops.

Because only the game knows what the sound is doing, so the emulator can't do anything, because that'd defeat the purpose of the emulator. It's not called an "Improver." :wink:


And yeah, as soon as you get on the way to tell what a character would look like in 3D from a 2D perspective, I'll be all over it with you.
(Nobody has ever done this for a reason)

by on (#76484)
font-size: 3px?!!! Be careful, that's the kind of stuff that can collapse the space-time continuum.

by on (#76521)
I guess I must improve my sarcasm skills. I've been posting in this board for over 5 years, and some of you actually believe I'd say those things for real.

by on (#76522)
tokumaru wrote:
I guess I must improve my sarcasm skills. I've been posting in this board for over 5 years, and some of you actually believe I'd say those things for real.

I found it pretty obvious :o
(I actually can't believe that people are still going on about this thread xD)

by on (#76526)
I was only playing along to your joke.

by on (#76528)
tokumaru wrote:
I guess I must improve my sarcasm skills. I've been posting in this board for over 5 years, and some of you actually believe I'd say those things for real.


Rolling to nowhere, tepples..?

by on (#76541)
At this point, I'm beginning to agree that everything that could be said has been said. I played along by suggesting some experimental emulator features, but the suggestions didn't spark insightful discussion. Feel free to make new serious topics about such features though.

Image

image credit: Phrekwenci