Project Nested - NES emulator for SNES

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
LucianoTheWindowsFan
Posts: 57
Joined: Mon Jun 22, 2020 9:39 am

Re: Project Nested - NES emulator for SNES

Post by LucianoTheWindowsFan » Sat Nov 21, 2020 7:25 am

Myself086 wrote:
Wed Nov 18, 2020 12:10 pm
marcosmoutta wrote:
Wed Nov 18, 2020 11:36 am
Herzog Zwei wrote:
Sat Oct 10, 2020 10:49 pm
We need to create a pack with patched working roms!
<Removed link>
Unsure on the legality of this, will gladly delete.
Not legal.

You are allowed to share profiles generated by the EXE. They only contain descriptions of the ROM file without actual data.
Luckily, I was able to download those illegal ROMs, so maybe the FBI will raid my house.
The SNES is my favorite console, not only because it is an upgrade to the NES, but because it had some quality games as well (e.g. EarthBound and Kirby's Dream Land 3).

Myself086
Posts: 52
Joined: Sat Nov 10, 2018 2:49 pm

Re: Project Nested - NES emulator for SNES

Post by Myself086 » Sun Nov 22, 2020 8:36 pm

aquasnake wrote:
Fri Nov 20, 2020 6:02 pm
Soon after you released this tool, some smart merchants used your works to pack NES ROM and sell them as SNES multi-carts. Some of them crashed due to imperfect emulation. I wonder if the manufacturer of this kind of cartridge has contacted you? If we are using open source products to do business, I think it is necessary to display a blue screen error after the crash and display a "punishment" warning message such as "this cartridge is unauthorized, please refund it from the seller". :lol:
No seller contacted me directly but I heard about one known seller using my work. If anything, the blue screen shows the name of this emulator so people can research it.
aquasnake wrote:
Fri Nov 20, 2020 6:02 pm
Using the external bank address b0-b7 of SNES to emulate mappers. Using SPC to emulate APU. Very outstanding work
Do you mean banks $b0-$b7 for SRAM? I use $b0 for the game's expanded RAM while $b1 is for caching function entry points for the exe. I never access SRAM through mirrored banks so I can use more later if necessary.

Mapper emulation on the PRG side is done by changing the CPU's register DB whenever data accesses are made to $6000-$ffff.

marcosmoutta
Posts: 3
Joined: Mon Aug 17, 2020 1:41 pm

Re: Project Nested - NES emulator for SNES

Post by marcosmoutta » Fri Nov 27, 2020 7:19 pm

Hey, the Atari VCS also had a 6502! Maybe, just maybe, could there be an Atari emulator akin to project nested? I know the TIA is weird and freaky and kernels control the scanlines directly without a frame buffer, but it has obviously been done on other hardware, so would it be possible?

Myself086
Posts: 52
Joined: Sat Nov 10, 2018 2:49 pm

Re: Project Nested - NES emulator for SNES

Post by Myself086 » Sun Dec 20, 2020 11:11 am

Update is out!

Not a major update in terms of compatibility. Some performance improvement but nothing too major as there isn't much time to save.

Indirect JMP nearly halved its overhead timing by avoiding the use of X/Y registers but at the cost of an entire bank dedicated to code that previously relied on X/Y registers. The average timing should be around 85 to 95 cycles depending on the game.

There's now an option to disable stack optimizations (native return address). Disabling this optimization allows testing which games crash due to stack issues. this option isn't perfect and not meant to run games at full speed. There are some games that I thought had stack issues but can't run with this option disabled. Duck Tales is one such title that starts running with this option disabled.

v1.2 changes:
- Fixed JMP to WRAM
- Added indirect JMP executed from WRAM
- Minor performance improvement when indirect load/store changes bank
- Minor performance improvement to CPU side of sound emulation
- Large performance improvement to indirect JMP
- Added page wrap support to indirect JMP
- Added option to recompile code in PRG RAM
- Fixed indirect JMP into interpreted RAM
- Added some options to disable stack optimizations
- Fixed loading/saving unknown settings in a profile

soniccd123
Posts: 24
Joined: Sat Jun 27, 2020 12:01 pm

Re: Project Nested - NES emulator for SNES

Post by soniccd123 » Sun Dec 20, 2020 3:22 pm

Thanks! Amazing project. Doing some tests already!

User avatar
LucianoTheWindowsFan
Posts: 57
Joined: Mon Jun 22, 2020 9:39 am

Re: Project Nested - NES emulator for SNES

Post by LucianoTheWindowsFan » Mon Jan 11, 2021 4:26 pm

Myself086 wrote:
Sun Dec 20, 2020 11:11 am
Update is out!

Not a major update in terms of compatibility. Some performance improvement but nothing too major as there isn't much time to save.

Indirect JMP nearly halved its overhead timing by avoiding the use of X/Y registers but at the cost of an entire bank dedicated to code that previously relied on X/Y registers. The average timing should be around 85 to 95 cycles depending on the game.

There's now an option to disable stack optimizations (native return address). Disabling this optimization allows testing which games crash due to stack issues. this option isn't perfect and not meant to run games at full speed. There are some games that I thought had stack issues but can't run with this option disabled. Duck Tales is one such title that starts running with this option disabled.

v1.2 changes:
- Fixed JMP to WRAM
- Added indirect JMP executed from WRAM
- Minor performance improvement when indirect load/store changes bank
- Minor performance improvement to CPU side of sound emulation
- Large performance improvement to indirect JMP
- Added page wrap support to indirect JMP
- Added option to recompile code in PRG RAM
- Fixed indirect JMP into interpreted RAM
- Added some options to disable stack optimizations
- Fixed loading/saving unknown settings in a profile
How about fixing these bugs I discovered:
LucianoTheWindowsFan wrote:
Fri Nov 13, 2020 5:45 pm
There are several games that do not work properly:
Ufouria: The Saga (game crashes after starting)
Wagyan Land (game crashes after starting a level)
Kirby's Adventure (game crashes permanently)
Bomberman (game shows a miscolored title screen and freezes permanently)
Bomberman II (game crashes permanently on a blank blue screen)
2048 (homebrew, game crashes after starting)
The SNES is my favorite console, not only because it is an upgrade to the NES, but because it had some quality games as well (e.g. EarthBound and Kirby's Dream Land 3).

Myself086
Posts: 52
Joined: Sat Nov 10, 2018 2:49 pm

Re: Project Nested - NES emulator for SNES

Post by Myself086 » Tue Jan 12, 2021 4:47 pm

LucianoTheWindowsFan wrote:
Mon Jan 11, 2021 4:26 pm
How about fixing these bugs I discovered:
Thanks for letting me know which games you want to see on this emulator. Please be patient as this project is at least 10x more difficult than making a NES emulator for PC. Ufouria, Kirby's Adventure and Bomberman were already games that I want to emulate.

When you get crashes, do you get a blue screen of death?
If so, which error do you get?
If you get "CPU Derailed", have you tried the new option of disabling "native return address"? Disabling this option is for testing purposes for v1.2 but may become more viable in the future.

soniccd123
Posts: 24
Joined: Sat Jun 27, 2020 12:01 pm

Re: Project Nested - NES emulator for SNES

Post by soniccd123 » Tue Jan 12, 2021 5:08 pm

Myself086 wrote:
Tue Jan 12, 2021 4:47 pm
LucianoTheWindowsFan wrote:
Mon Jan 11, 2021 4:26 pm
How about fixing these bugs I discovered:
Thanks for letting me know which games you want to see on this emulator. Please be patient as this project is at least 10x more difficult than making a NES emulator for PC. Ufouria, Kirby's Adventure and Bomberman were already games that I want to emulate.

When you get crashes, do you get a blue screen of death?
If so, which error do you get?
If you get "CPU Derailed", have you tried the new option of disabling "native return address"? Disabling this option is for testing purposes for v1.2 but may become more viable in the future.
Hey Myself086, do you think that compilating a document with the crash errors of each game and details of configuration would help you? At least of the ones that crashes to Blue Screen?

Myself086
Posts: 52
Joined: Sat Nov 10, 2018 2:49 pm

Re: Project Nested - NES emulator for SNES

Post by Myself086 » Wed Jan 13, 2021 6:08 am

soniccd123 wrote:
Tue Jan 12, 2021 5:08 pm
Hey Myself086, do you think that compilating a document with the crash errors of each game and details of configuration would help you? At least of the ones that crashes to Blue Screen?
The spreadsheet already has that. It has just enough information to give me some clues as to what might have gone wrong.

When it comes to demands, I always try to put some small amount of efforts on the person requesting a game. What I ask for depends on the situation. For example, there was a rare crash in Final Fantasy and I told the guy that I couldn't reproduce the crash and it was on him to do it. He streamed for 8 hours and got the crash 5 times, the blue screens gave enough hints for me to find it.

I would really love to see a database for profiles so the exe can download optimized settings for each game. I've seen some users complain about SMB3 not being playable past 1-1 but the blue screen clearly tells them what to do to fix it.

soniccd123
Posts: 24
Joined: Sat Jun 27, 2020 12:01 pm

Re: Project Nested - NES emulator for SNES

Post by soniccd123 » Wed Jan 13, 2021 2:00 pm

Myself086 wrote:
Wed Jan 13, 2021 6:08 am
soniccd123 wrote:
Tue Jan 12, 2021 5:08 pm
Hey Myself086, do you think that compilating a document with the crash errors of each game and details of configuration would help you? At least of the ones that crashes to Blue Screen?
The spreadsheet already has that. It has just enough information to give me some clues as to what might have gone wrong.

When it comes to demands, I always try to put some small amount of efforts on the person requesting a game. What I ask for depends on the situation. For example, there was a rare crash in Final Fantasy and I told the guy that I couldn't reproduce the crash and it was on him to do it. He streamed for 8 hours and got the crash 5 times, the blue screens gave enough hints for me to find it.

I would really love to see a database for profiles so the exe can download optimized settings for each game. I've seen some users complain about SMB3 not being playable past 1-1 but the blue screen clearly tells them what to do to fix it.
I can start one if you want, just need to know how you think should be organized, like a CSV file, a SQL database, a server with files for each game, what do you think?

Myself086
Posts: 52
Joined: Sat Nov 10, 2018 2:49 pm

Re: Project Nested - NES emulator for SNES

Post by Myself086 » Sun Jan 17, 2021 12:14 pm

soniccd123 wrote:
Wed Jan 13, 2021 2:00 pm
I can start one if you want, just need to know how you think should be organized, like a CSV file, a SQL database, a server with files for each game, what do you think?
As of now, the exe loads the profile with the most amount of starting characters to the NES file. Let's take Final Fantasy Randomizer which generates files starting with "FFR" followed by the seed number and something else. A profile by the name "FFR" would be loaded.

I don't have much experience with databases but I want something similar to client asking for file "xyz" and server sending file "xy" instead.

Each profile contains 3 types of data:
- Settings
- Patches
- Known calls (possibly links in a later version)

I don't want just any user to be able to upload profiles because the "known calls" part could be filled with wrong data and possibly cause the AOT compiler to fail or not optimize as much in later versions.

strat
Posts: 388
Joined: Mon Apr 07, 2008 6:08 pm
Location: Missouri

Re: Project Nested - NES emulator for SNES

Post by strat » Mon Jan 25, 2021 3:29 pm

marcosmoutta wrote:
Fri Nov 27, 2020 7:19 pm
Hey, the Atari VCS also had a 6502! Maybe, just maybe, could there be an Atari emulator akin to project nested? I know the TIA is weird and freaky and kernels control the scanlines directly without a frame buffer, but it has obviously been done on other hardware, so would it be possible?
Maybe, not a sure thing. The VCS might be a lot more primitive than SNES at a glance but the way it draws graphics doesn't lend itself very well to being emulated on anything other than a framebuffer and a system fast enough to output whole screens at once -- which the SNES is not.

The Super Gameboy has to DMA transfer 5,760 bytes of screen data to the SNES vram with the Gameboy screen data at 160x144 @ 2 bpp (cite below). The VCS is basically 160x262 @ 1 bpp. That comes out to 5,240 bytes, so if the S-CPU has enough time to cache a whole screen of TIA output I assume it can DMA the result the same way.

A whole frame on the VCS takes 19,912 cycles (262 lines * 76 cpu cycles per line). Since VCS roms are usually no more than 4K it might even be feasible to auto-patch the rom (so i/o port operations are replaced with a corresponding routine) and move it to wram so it can be executed in place. A big problem though is that the horizontal positions of the movable objects are dependent on the TIA's current cycle when it's commanded to display them - that's right, VCS programmers have to count cpu cycles just to position "sprites" correctly. This could be a kiss of death if there's no out-of-the-box solution.

One out-of-the-box solution I just brainstormed would be to offload TIA cycle counting on the SPC. The S-CPU could signal it to start a new timer with every TIA scanline and anytime a value is written to a TIA reg, it goes to the SPC which polls the timer and flags that value as being written on a given cycle. There's no way the whole TIA video image could be constructed on the SPC side but it could build high-level data for the S-CPU to read back and do exactly that. Someone who's done a lot of SPC programming could say how feasible this is - it might just not be possible to reliably sync the SPC timer loop with what's happening on the S-CPU side.

Anyway, this is a rough concept.

http://forums.nesdev.com/viewtopic.php?p=158193#p158193
http://forums.nesdev.com/viewtopic.php?p=259467#p259467

Post Reply