Discuss Scratch

GenericHeroGuy
Scratcher
19 posts

Cool NES emulator

Original forum topic: https://scratch.mit.edu/discuss/topic/540166/

Cool NES emulator is an NES emulator that's pretty cool. Check it out:
https://scratch.mit.edu/projects/561973653/

There's a Q&A in the original topic if you're interested!
Also, feel free to ask more questions on my profile!

Last edited by GenericHeroGuy (Oct. 3, 2021 14:27:54)

GenericHeroGuy
Scratcher
19 posts

Cool NES emulator

Alright, version 1.2 is finally out! Here's the list of changes!

  • Added controls for player 2; now TWO people can play Balloon Fight at a ridiculously slow speed!
    You have to map player 2's controls manually, because I couldn't decide on the default controls!
  • Mapper 3 (CNROM) games are a bit faster now, because for some reason I didn't cache the current bank
  • Added publish script to stage, which reduces the file size
  • The GUI code has been (mostly) separated into its own sprite. Still no real GUI though
  • The APU length counter is back, so blargg's instruction timing ROM works again
  • One or two things I forgot about

The next update should hopefully add a GUI, and after that I'll either fix the PPU or add the APU.

Hope you enjoy the new update!

Last edited by GenericHeroGuy (Oct. 4, 2021 18:07:24)

u7p
Scratcher
100+ posts

Cool NES emulator

This is amazing

Excuse my grammer
Kouzeru
Scratcher
22 posts

Cool NES emulator

I went ahead and do the APU for you

There's nothing much changed, except the APU sprite.
Since the remix is from v1.1, you may redo the length counter thing in case you want to take this feature.

I had no urge to share the project as it's just merely for you.
I'm doing this just for fun, to see what I can achieve in two days, to hasten development of this feature.

If you don't want take the whole feature (but instead you want to do the APU by your own research for the sake of learning),
then just take the audio samples I suggest for you, that's my main suggestion
using note blocks sucks for the audio synthesis

no worries, the audio samples doesn't take much space, it's super compressed.

(the APU is partially done for being accurate, im in a hard time to have a proper hardware envelope and sweep; the rest works good)

this apu is currently adopted in oxiti8's remix of your coolnes project

Last edited by Kouzeru (Oct. 5, 2021 22:41:38)

GenericHeroGuy
Scratcher
19 posts

Cool NES emulator

@Kouzeru: Thanks so much for adding an APU to the emulator!
It's really awesome to hear sound from an emulator in Scratch!
Oh, sorry, I mean it's really cool to hear…

Sadly I won't use the APU myself
I'm more interested in creating the APU myself, because I want to truly understand how it works. Hope you'll understand!

Don't worry, you don't have to keep your project a secret. Feel free to share it if you want



Also… WOW, what kinda computer do you have!? Feels weird to hear the game running at full speed! My laptop simply can't go above half speed, even if I disable drawing…
Kouzeru
Scratcher
22 posts

Cool NES emulator

Yep, no worries! That's understandable, I had reckon that you wanna doing it by yourself, hence I suggest this sprite as reference for you to make comparison or something

Free free to take something from it, like the audio stuffs that used to generate the audio

~~and oh yeah, btw, I speedup the coolnes audio by 400% in the preview here, thats why you see the waves muffled there due to the time-shrinking effect from the speedup~~
Paddle2See
Scratch Team
1000+ posts

Cool NES emulator

@Kouzeru - When you get a moment, please remove the link shorteners from the URLs. We like to know where links point before clicking on them so link shorteners aren't allowed on Scratch. Thanks!

Scratch Team Member, kayak and pickleball enthusiast, cat caregiver.

This is my forum signature! On a forum post, it is okay for Scratchers to advertise in their forum signature. The signature is the stuff that shows up below the horizontal line on the post. It will show up on every post I make.
(credit to Za-Chary)



;
Kouzeru
Scratcher
22 posts

Cool NES emulator

Paddle2See wrote:

@Kouzeru - When you get a moment, please remove the link shorteners from the URLs. We like to know where links point before clicking on them so link shorteners aren't allowed on Scratch. Thanks!

I'm removing the whole links since its actually referring to a domain of a site which are doesnt allowed here, as I think its fine to remove them now.
guifernandes
Scratcher
22 posts

Cool NES emulator

faster version: https://turbowarp.org/578387561/fullscreen?fps=250

when green flag clicked
forever
if <has project idea?> then

make project

else
explore the web
end
end
guifernandes
Scratcher
22 posts

Cool NES emulator

nvm wrong link heres correct link https://turbowarp.org/578387561/fullscreen?turbo&fps=250

when green flag clicked
forever
if <has project idea?> then

make project

else
explore the web
end
end
GenericHeroGuy
Scratcher
19 posts

Cool NES emulator

Look, it's a new update! And it's called 2.0!

  • The GUI is finally here!
    Now you can press Space to easily load ROMs, setup controllers and more!
  • Number keys are gone. Deleted. Disappeared without a trace.
    Now you have to embrace your GUI overlords! Muahahaha
    (well, except the debug keys)
  • Added instructions for converting ROMs on the web, courtesy of @oxiti8
  • Performance is a bit better now, thanks to the technical changes below! Though it's hard to tell because the framerate fluctuates a lot between runs…

Now for the technical stuff:

  • New “pause” and “unpause” messages are used to start/stop the CPU when the GUI is displayed.
  • A proper foundation for the APU has been made. Now the CPU will automatically send signals to the APU, instead of the APU manually counting cycles. (not a real APU yet, just the foundation)
    @Kouzeru: Automatic quarter-frames! Let me know if this helps
  • Some other minor changes

I might do one last update to add some extra polish. After that, don't expect anything new for the rest of the month, because I'm REALLY lagging behind in school… unless I can't stay off my laptop

Coming soon: a better PPU, and my version of the APU.
Until then, see you later!



Also, I had to step through CPU instructions for the first time in ages, because I somehow broke the instruction test ROM…
Turns out it was broken because the GUI didn't wait for the emulator to start up properly.

Last edited by GenericHeroGuy (Oct. 8, 2021 22:40:54)

GenericHeroGuy
Scratcher
19 posts

Cool NES emulator

Hotfix: the GUI no longer sends an “unpause” message every time you click the Display button
bobbybee
Scratcher
1000+ posts

Cool NES emulator

Oh, this is lovely to see. I'd be curious about the technical challenges you've faced? I hit some significant walls with PPU and APU when I tried this years ago, but maybe Scratch is more capable now? Would love a write up

“Ooo, can I call you Señorita Bee?” ~Chibi-Matoran
GenericHeroGuy
Scratcher
19 posts

Cool NES emulator

bobbybee wrote:

Oh, this is lovely to see. I'd be curious about the technical challenges you've faced? I hit some significant walls with PPU and APU when I tried this years ago, but maybe Scratch is more capable now? Would love a write up
Alright, how do I make a story that sounds interesting…?

ahem

For as long as I can remember, I've been playing games on emulators. It all started when I was…

…nah, let's tone down the drama a little bit…

I think my three major inspirations were:
  • The will to upload something nice on Scratch for once
  • Another NES emulator that I really liked
  • And of course, TurboWarp
The first one is pretty self-explanatory (6 years on this site with no projects) but as for the others…

One day I decided that I was tired of playing N64 games, so after some quick internet searching I found an NES emulator called Mesen. Doesn't seem that interesting, but what makes it special is its insane level of accuracy! And of course, to achieve this accuracy, it has all sorts of debugging features!

I already had some basic knowledge about the NES, but since the debugger was easy to use, it inspired me to take a look inside some NES games. And that's what got me hooked: it only took a few weeks before I found myself constantly messing around with the debugger, instead of actually playing games!

The debugger taught me all sorts of stuff that I never knew about the NES. Then I discovered the NESdev wiki, read all of its pages, and soon enough I decided it's time for me to make my own emulator!

I made that decision somewhere around early April this year.(according to the earliest backup i have)
After that, the question was… how should I make this emulator? I'd always wanted to try a real programming language, like Python, Java, C++, C#, bla bla bla… then I got the idea to make it in Scratch. But I thought that was pretty silly. Why would I make an emulator that only runs at a single frame per second?

Well a few months prior, while I was briefly experimenting with Scratch, I had discovered the newly released TurboWarp! Not only was it VERY fast, but it also had a built-in editor, so you could make projects and run them at a high speed, all at the same time!

I also knew that there were already emulators made in Scratch, so if other people can make emulators in Scratch, then why not?
I downloaded TurboWarp on my at the time 3-months old Linux laptop. It worked out of the box!
After playing around with it for a while, I was ready to go!

Now, the development of the emulator itself wasn't all that interesting… basically it went like this:
  • Read the wiki
  • Make some code
  • Run test ROMs
  • Repeat the above for 2-3 days
  • Take a 2-week break, come back, and start coding again

After about 4 months of adding opcodes, drawing sprites, scrolling backgrounds, mapping banks, playing Bomberman, Balloon Fight and Kung Fu…
It was done!
…I could go into more detail, but if I did this forum post would be twice as long…

I then spent a month doing some minor improvements, then quietly uploaded it to Scratch. Didn't get much attention, but hey, sooner or later people would discover it right? Besides, I was busy with other stuff, and I'd never used any social features on Scratch at that point. So I just made a forum post and called it a day.

Well, one month passed, and I'd only gotten 8 or 9 views since I uploaded it. I finally decided to do something about that, and that's when I checked some other Scratch emulators and found a studio they all had in common, namely @oxiti8's Scratch Emulation Efforts.

So, having never interacted with anyone on Scratch before, I awkwardly asked for my emulator to be added to the studio… and it worked! It got loads of views, and now I'm famous across the globe for my cool emulator
well, not really


Welp, that's all I can think of. Feel free to ask more (technical) questions!
…if you survived the wall of text, that is…

(man, forum posts make me way too anxious… will make a post about some tech stuff later)

Last edited by GenericHeroGuy (Oct. 15, 2021 07:29:38)

oxiti8
Scratcher
500+ posts

Cool NES emulator

This was a great read. I've heard good things about MESEN's debugger, but had no idea it was really that detailed!

GenericHeroGuy wrote:

Well, one month passed, and I'd only gotten 8 or 9 views since I uploaded it.
I generally do monthly checks for new emulators on scratch to add to the SEE studio by searching “emulator” checking the “Trending” section to see more recent stuff. It likely got buried under the loads of “”“”“emulators”“”“” that are just an unfinished remake of SMB1 or something similar unfortunately (Things in Show and Tell also get buried really fast). It's a good thing you finally posted a comment about Cool NES on the SEE studio, I'd hate to have missed this!

GenericHeroGuy wrote:

@oxidi8's Scratch Emulation Efforts.
Also it's oxiti not oxidi heh
bobbybee
Scratcher
1000+ posts

Cool NES emulator

GenericHeroGuy wrote:

bobbybee wrote:

Oh, this is lovely to see. I'd be curious about the technical challenges you've faced? I hit some significant walls with PPU and APU when I tried this years ago, but maybe Scratch is more capable now? Would love a write up
Alright, how do I make a story that sounds interesting…?

ahem

For as long as I can remember, I've been playing games on emulators. It all started when I was…

…nah, let's tone down the drama a little bit…

I think my three major inspirations were:
  • The will to upload something nice on Scratch for once
  • Another NES emulator that I really liked
  • And of course, TurboWarp
The first one is pretty self-explanatory (6 years on this site with no projects) but as for the others…

One day I decided that I was tired of playing N64 games, so after some quick internet searching I found an NES emulator called Mesen. Doesn't seem that interesting, but what makes it special is its insane level of accuracy! And of course, to achieve this accuracy, it has all sorts of debugging features!

I already had some basic knowledge about the NES, but since the debugger was easy to use, it inspired me to take a look inside some NES games. And that's what got me hooked: it only took a few weeks before I found myself constantly messing around with the debugger, instead of actually playing games!

The debugger taught me all sorts of stuff that I never knew about the NES. Then I discovered the NESdev wiki, read all of its pages, and soon enough I decided it's time for me to make my own emulator!

I made that decision somewhere around early April this year.(according to the earliest backup i have)
After that, the question was… how should I make this emulator? I'd always wanted to try a real programming language, like Python, Java, C++, C#, bla bla bla… then I got the idea to make it in Scratch. But I thought that was pretty silly. Why would I make an emulator that only runs at a single frame per second?

Well a few months prior, while I was briefly experimenting with Scratch, I had discovered the newly released TurboWarp! Not only was it VERY fast, but it also had a built-in editor, so you could make projects and run them at a high speed, all at the same time!

I also knew that there were already emulators made in Scratch, so if other people can make emulators in Scratch, then why not?
I downloaded TurboWarp on my at the time 3-months old Linux laptop. It worked out of the box!
After playing around with it for a while, I was ready to go!

Now, the development of the emulator itself wasn't all that interesting… basically it went like this:
  • Read the wiki
  • Make some code
  • Run test ROMs
  • Repeat the above for 2-3 days
  • Take a 2-week break, come back, and start coding again

After about 4 months of adding opcodes, drawing sprites, scrolling backgrounds, mapping banks, playing Bomberman, Balloon Fight and Kung Fu…
It was done!
…I could go into more detail, but if I did this forum post would be twice as long…

I then spent a month doing some minor improvements, then quietly uploaded it to Scratch. Didn't get much attention, but hey, sooner or later people would discover it right? Besides, I was busy with other stuff, and I'd never used any social features on Scratch at that point. So I just made a forum post and called it a day.

Well, one month passed, and I'd only gotten 8 or 9 views since I uploaded it. I finally decided to do something about that, and that's when I checked some other Scratch emulators and found a studio they all had in common, namely @oxiti8's Scratch Emulation Efforts.

So, having never interacted with anyone on Scratch before, I awkwardly asked for my emulator to be added to the studio… and it worked! It got loads of views, and now I'm famous across the globe for my cool emulator
well, not really


Welp, that's all I can think of. Feel free to ask more (technical) questions!
…if you survived the wall of text, that is…

(man, forum posts make me way too anxious… will make a post about some tech stuff later)
Nice! :-)

“Ooo, can I call you Señorita Bee?” ~Chibi-Matoran
RedSpikeAndCoinBoi
Scratcher
2 posts

Cool NES emulator

GenericHeroGuy wrote:

bobbybee wrote:

Oh, this is lovely to see. I'd be curious about the technical challenges you've faced? I hit some significant walls with PPU and APU when I tried this years ago, but maybe Scratch is more capable now? Would love a write up
Alright, how do I make a story that sounds interesting…?

ahem

For as long as I can remember, I've been playing games on emulators. It all started when I was…

…nah, let's tone down the drama a little bit…

I think my three major inspirations were:
  • The will to upload something nice on Scratch for once
  • Another NES emulator that I really liked
  • And of course, TurboWarp
The first one is pretty self-explanatory (6 years on this site with no projects) but as for the others…

One day I decided that I was tired of playing N64 games, so after some quick internet searching I found an NES emulator called Mesen. Doesn't seem that interesting, but what makes it special is its insane level of accuracy! And of course, to achieve this accuracy, it has all sorts of debugging features!

I already had some basic knowledge about the NES, but since the debugger was easy to use, it inspired me to take a look inside some NES games. And that's what got me hooked: it only took a few weeks before I found myself constantly messing around with the debugger, instead of actually playing games!

The debugger taught me all sorts of stuff that I never knew about the NES. Then I discovered the NESdev wiki, read all of its pages, and soon enough I decided it's time for me to make my own emulator!

I made that decision somewhere around early April this year.(according to the earliest backup i have)
After that, the question was… how should I make this emulator? I'd always wanted to try a real programming language, like Python, Java, C++, C#, bla bla bla… then I got the idea to make it in Scratch. But I thought that was pretty silly. Why would I make an emulator that only runs at a single frame per second?

Well a few months prior, while I was briefly experimenting with Scratch, I had discovered the newly released TurboWarp! Not only was it VERY fast, but it also had a built-in editor, so you could make projects and run them at a high speed, all at the same time!

I also knew that there were already emulators made in Scratch, so if other people can make emulators in Scratch, then why not?
I downloaded TurboWarp on my at the time 3-months old Linux laptop. It worked out of the box!
After playing around with it for a while, I was ready to go!

Now, the development of the emulator itself wasn't all that interesting… basically it went like this:
  • Read the wiki
  • Make some code
  • Run test ROMs
  • Repeat the above for 2-3 days
  • Take a 2-week break, come back, and start coding again

After about 4 months of adding opcodes, drawing sprites, scrolling backgrounds, mapping banks, playing Bomberman, Balloon Fight and Kung Fu…
It was done!
…I could go into more detail, but if I did this forum post would be twice as long…

I then spent a month doing some minor improvements, then quietly uploaded it to Scratch. Didn't get much attention, but hey, sooner or later people would discover it right? Besides, I was busy with other stuff, and I'd never used any social features on Scratch at that point. So I just made a forum post and called it a day.

Well, one month passed, and I'd only gotten 8 or 9 views since I uploaded it. I finally decided to do something about that, and that's when I checked some other Scratch emulators and found a studio they all had in common, namely @oxiti8's Scratch Emulation Efforts.

So, having never interacted with anyone on Scratch before, I awkwardly asked for my emulator to be added to the studio… and it worked! It got loads of views, and now I'm famous across the globe for my cool emulator
well, not really


Welp, that's all I can think of. Feel free to ask more (technical) questions!
…if you survived the wall of text, that is…

(man, forum posts make me way too anxious… will make a post about some tech stuff later)


Hello, I Am A Big fan of your project, And I Want you to continue this emulator, So why Im here is I actually ran some test comparing some NES Game to their GB/GBC Counterparts to see which scratch emulator could run faster, Surprisingly Enough I am sad to say the NES Lost in both games I tested, which were Ducktales, and Super Mario Bros, I was Kinda Expecting The GB Ducktales to win as it has less color and has a smaller file size, but Super Mario Bros Deluxe surprised me, as It “with frameskips” ran to a decent speed I liked, while this emulator it still felt really slow even with frameskips.
so even though it's REALLY cool to play super mario bros the way it was intended without the screen crunch, I'll stick to playing it on the GBC, because it is more functional, now one thing I have to say is that turbo warp was actually to record the NES emulator, while the It crashed when it tried to record the GBC one, so that's a plus in my opinion, now I understand this emulator is in its first updates, so I don't expect full emulation speed on scratch (ever) or anything like that, It would be cool though if you are able to Improve the speed to where the GBC.sb2 emulator is at, because I think there would be more people willing to play the NES emulator then the GBC one. Also I do have one Question, Is it Actually Possible To emulate The Nintendo MMC3 mapper? I know It's the fourth mapper and right now it's unsupported, I just wanted to know if one day in the future it could be supported in the future as It seems like that would be a hard mapper to try and emulate due to It allows bankswapping and more data to be accessed then normally able to with a regular NES cartridge or chip. But if it is possible then I can't wait to try and play SMB3 on scratch and not a Unfinished replica of it. But Hope You Have a great day in the meantime!
GenericHeroGuy
Scratcher
19 posts

Cool NES emulator

RedSpikeAndCoinBoi wrote:

Hello, I Am A Big fan of your project, And I Want you to continue this emulator,

Thanks!

RedSpikeAndCoinBoi wrote:

I actually ran some test comparing some NES Game to their GB/GBC Counterparts to see which scratch emulator could run faster, Surprisingly Enough I am sad to say the NES Lost in both games I tested, which were Ducktales, and Super Mario Bros, I was Kinda Expecting The GB Ducktales to win as it has less color and has a smaller file size, but Super Mario Bros Deluxe surprised me, as It “with frameskips” ran to a decent speed I liked, while this emulator it still felt really slow even with frameskips.

Probably the reason why GBC.sb2 is faster, is because the Game Boy has a smaller screen size and is monochrome, which means that frames can be drawn much faster.
Also, since it's a portable system, games can (and must) halt the CPU whenever possible to conserve power.
This isn't a problem for emulators since they're not running on four AA batteries. In fact, it helps performance since the CPU doesn't have to be emulated all the time!

In contrast, the CPU in the NES can't be halted at all, and that means it must be emulated at all times. Which is a bummer, because games spend a lot of time just waiting for the next frame to start…

(well technically, you can halt the cpu by running the illegal HLT instruction, but that will permanently stop the cpu, so its not very useful…)

Also, some might say that the Z80/8080 hybrid whatever in the Game Boy is faster to emulate than the 6502, but I'm not arguing about that

RedSpikeAndCoinBoi wrote:

now one thing I have to say is that turbo warp was actually to record the NES emulator, while the It crashed when it tried to record the GBC one, so that's a plus in my opinion,

There's a solution for the GBC.sb2 crash:
https://scratch.mit.edu/projects/562335591
Apparently the original version is broken in Scratch 3, because the timer doesn't work properly.

RedSpikeAndCoinBoi wrote:

It would be cool though if you are able to Improve the speed to where the GBC.sb2 emulator is at

It's gonna be really difficult to make it run at full speed, while still maintaning accuracy. Not sure if it'll ever go faster
There's a few improvements I can think of that might speed it up a bit, but I wonder if it will be enough?

RedSpikeAndCoinBoi wrote:

Also I do have one Question, Is it Actually Possible To emulate The Nintendo MMC3 mapper?

Yeah, the MMC3 is pretty complex, with its eight switchable banks (2 for CPU, 6 for PPU) and its weird scanline IRQ…
But hey, if I stare at the unfinished code for long enough, then hours later, everything will suddendly work!

(that reminds me… i havent even added the alternate prg banking modes for the mmc1. i wonder if anyone noticed :P)


Now if anyone's wondering… no, I'm not really interested in making a Game Boy emulator. There's already loads of emulators for that system on Scratch, so I'm thinking about something that also has a 6502 CPU.

Hmm…



Right, need to make more updates for Cool NES first

(yes its the 2600. not a good start so far… spent a whole night just adding variables for all the tia registers. need to get started on the pia too. no stable images yet)
(or maybe i should do a different console? preferably something that doesnt require cycle accuracy)

Last edited by GenericHeroGuy (Nov. 1, 2021 01:42:46)

GenericHeroGuy
Scratcher
19 posts

Cool NES emulator

It is Wednesday, my dudes… time to update Cool NES emulator to version 2.1!

The only addition this time around is…
Support for mappers 4 and 7! (MMC3 and AxROM)

Yep, that's right! Now you can Super Mario Bros. 3 on Scratch!
Not only that, but thanks to the addition of proper banking on the CPU side, it runs faster than ever! This applies to all the other mappers too, so now they're nearly as fast as mapperless games!

Though the MMC3's scanline counter was very difficult to implement, and I only tested with SMB3, so… consider yourself lucky if any other MMC3 games work

(and before you ask: no, battletoads doesn't work… that game requires insane timing to run properly…)

Speaking of CPU's, there's some technical changes too:
  • The first operand fetch is now part of the main CPU loop, which speeds things up
  • As a result, instructions with immediate mode addressing require an extra check before running, which slows things down
  • The implied, accumulator and “special” modes have been combined into one, which again speeds things up
  • The PPU's nametables are now properly mirrored, which allows for single-screen mirroring
  • Sprite rendering has been changed a bit

Welp, that's all for this time! Sorry for the long wait, it only took me a few days in total to add everything, but I was too lazy to upload in time… Until next time!

(i was gonna add banking for the ppu too, but i got discouraged because i thought it would just reduce performance… funny because the cpu banking only reduced performance by like 0.2 fps)

(and hopefully no one notices the awful hack i did for the mmc3 irq… that thing was a real pain to do properly, so i skimped on it)

Powered by DjangoBB

Standard | Mobile