Project Nested - NES emulator for SNES

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

ZReport
Posts: 21
Joined: Thu May 31, 2018 11:57 pm

Re: Project Nested - NES emulator for SNES

Post by ZReport »

GyaragaX wrote: Sun Aug 09, 2020 11:04 pm
ZReport wrote: Fri Aug 07, 2020 4:44 am Pretty interesting project!

I got the ROMs working on Snes9x 1.60 as well as the SD2SNES v1.10.3. It also works off of the Super NT SD card slot with jailbreak firmware 6.9. It wouldn't be a stretch to say that it'll work on the MiSTer, but I have a number of chores to do before I can check that out as well.

Will be watching this project with keen interest! :beer: :)
Just wanted to confirm, I tested Super Mario Bros on MiSTer, and it does work. 👍
Awesome! :beer:
ZReport
Posts: 21
Joined: Thu May 31, 2018 11:57 pm

Re: Project Nested - NES emulator for SNES

Post by ZReport »

Btw, I posted a video of this project at work on YouTube... at least on a Super NT.

https://youtu.be/irF8gSVrVOs
Myself086
Posts: 158
Joined: Sat Nov 10, 2018 2:49 pm

Re: Project Nested - NES emulator for SNES

Post by Myself086 »

ZReport wrote: Fri Aug 14, 2020 9:35 am Btw, I posted a video of this project at work on YouTube... at least on a Super NT.

https://youtu.be/irF8gSVrVOs
Awesome! Thanks for uploading! :D

The screen transition full of zeros in Zelda never happened in the pre-release version, I'll have to investigate.
ZReport
Posts: 21
Joined: Thu May 31, 2018 11:57 pm

Re: Project Nested - NES emulator for SNES

Post by ZReport »

Myself086 wrote: Fri Aug 14, 2020 10:38 am
ZReport wrote: Fri Aug 14, 2020 9:35 am Btw, I posted a video of this project at work on YouTube... at least on a Super NT.

https://youtu.be/irF8gSVrVOs
Awesome! Thanks for uploading! :D

The screen transition full of zeros in Zelda never happened in the pre-release version, I'll have to investigate.
Welcome! The video seems to have picked up some buzz from it as well! Hopefully it translated to more people having eyes on such an interesting project!

And yeah, the zeros in the Zelda transition happened on every thing I tested with. Not sure if I was supposed to select an option before compiling. :shock:
GyaragaX
Posts: 2
Joined: Sun Aug 09, 2020 11:01 pm

Re: Project Nested - NES emulator for SNES

Post by GyaragaX »

In the compatibility document, for Crystalis, it says "Requires patch for idle loops". How might I go about enabling that patch?
Myself086
Posts: 158
Joined: Sat Nov 10, 2018 2:49 pm

Re: Project Nested - NES emulator for SNES

Post by Myself086 »

GyaragaX wrote: Fri Aug 21, 2020 9:08 pm In the compatibility document, for Crystalis, it says "Requires patch for idle loops". How might I go about enabling that patch?
The patch was made in collaboration with Steve_Hacks and can be found here: https://github.com/crystalis-randomizer ... es/patches
Download snes.ips and apply it to the NES ROM before converting to SNES.

This patch fixes 2 idle loops and improves performance. Unfortunately, the performance updates aren't compatible with the randomizer.

I just did some digging into the conversations I had with Steve and you should be able to use this patch below for randomizer. Click the "Edit Patches" button on Project Nested's exe and copy these lines:

Code: Select all

[fe:dcac] = d2
[fe:c730] = f2
I noticed a bug with the exe while writing this reply, the patch window doesn't seem to support semi-colon correctly. This is only a problem if copy the patch I added to the spreadsheet.

This game was originally requested to me late last year by Mattrick_ for a potential NES-SNES combo randomizer but we haven't found any developer for the SNES game.
maonaluva
Posts: 1
Joined: Mon Aug 17, 2020 8:14 am

Re: Project Nested - NES emulator for SNES

Post by maonaluva »

Myself086 wrote: Sat Aug 22, 2020 8:18 am
GyaragaX wrote: Fri Aug 21, 2020 9:08 pm In the compatibility document, for Crystalis, it says "Requires patch for idle loops". How might I go about enabling that patch?
The patch was made in collaboration with Steve_Hacks and can be found here: https://github.com/crystalis-randomizer ... es/patches
Download snes.ips and apply it to the NES ROM before converting to SNES.

This patch fixes 2 idle loops and improves performance. Unfortunately, the performance updates aren't compatible with the randomizer.

I just did some digging into the conversations I had with Steve and you should be able to use this patch below for randomizer. Click the "Edit Patches" button on Project Nested's exe and copy these lines:

Code: Select all

[fe:dcac] = d2
[fe:c730] = f2
I noticed a bug with the exe while writing this reply, the patch window doesn't seem to support semi-colon correctly. This is only a problem if copy the patch I added to the spreadsheet.

This game was originally requested to me late last year by Mattrick_ for a potential NES-SNES combo randomizer but we haven't found any developer for the SNES game.
What an amazing project, I sent you a PM, take a look when you can, I will make a video about the emulator for a channel in Brazil.
I even ran Crystalis translated into Brazilian Portuguese and it worked very well.
soniccd123
Posts: 46
Joined: Sat Jun 27, 2020 12:01 pm

Re: Project Nested - NES emulator for SNES

Post by soniccd123 »

Memblers wrote: Mon Aug 03, 2020 6:33 am Has the emulator been tested on a "plain" flash cart yet? I noticed in HIGAN there's usually not much showing up on screen (though the games are running), that makes me wonder if there's some missing S-PPU initialization. By plain I mean just a ROM chip, as the SD2SNES, PowerPak etc, menus won't be leaving the S-PPU in it's power-on default state. Maybe someone here could test that, I can't because I only have an SD2SNES for now.
So firstly, what a wonderful project!

I've tested the emulator with a plain HiROM flashcard containing 256kb of SRAM in a SNS-CPU-RGB-01 Motherboard SNES and the result was exactly the same that you described with HIGAN. Tested Super Mario Bros and while it sounds fine and reacts to the controller inputs (from what i hear), theres absolutely nothing on screen.

So i've decided to test the missing PPU inicialization hypotesis that you proposed, for that (i know this is not advisable), i've booted a cart that i know works to set the PPU, removed it with the SNES running and inserted the flash card, then i reseted the SNES and voila! Video output working!

After that Super Mario Worked as expected, congratulations to Myself086, i would never think that such a project would even be possible!

If you need someone to test in real hardware and plain flashcard, i can do it.

Thanks,

Soniccd123

Edit:

I've investigated the generated rom with bsnes-plus accuracy debugger (which shows the same behavior as HIGAN and the real hardware). I found that, comparing the PPU registers in the accuracy branch with the same on the performance branch, that some of them are not zeroed and only a few are writen during the Nested rom initialization process, leaving some in random states.

To test this, i've hijacked the first jump on program execution and sent the program counter to a empty rom space, which i found at 0x28000:

Code: Select all

FF1E- 5C 00 80 82		JML $828000	//Normally this would jump to $818002
There i wrote a simple routine that zeros all the PPU registers before any initialization is done and, after that, just jumped back to normal execution:

Code: Select all

28000- 9C 01 21		STZ $2101
28003- 9C 02 21		STZ $2102
28006- 9C 03 21		STZ $2103
28009- 9C 05 21		STZ $2105
2800C- 9C 06 21		STZ $2106
2800F- 9C 07 21		STZ $2107
28012- 9C 08 21		STZ $2108
28015- 9C 09 21		STZ $2109
28018- 9C 0A 21		STZ $210A
2801B- 9C 0B 21		STZ $210B
2801E- 9C 0C 21		STZ $210C
28021- 9C 0D 21		STZ $210D
28024- 9C 0E 21		STZ $210E
28027- 9C 0F 21		STZ $210F
2802A- 9C 10 21		STZ $2110
2802D- 9C 11 21		STZ $2111
28030- 9C 12 21		STZ $2112
28033- 9C 13 21		STZ $2113
28036- 9C 15 21		STZ $2115
28039- 9C 16 21		STZ $2116
2803C- 9C 17 21		STZ $2117
2803F- 9C 1A 21		STZ $211A
28042- 9C 1B 21		STZ $211B
28045- 9C 1C 21		STZ $211C
28048- 9C 1D 21		STZ $211D
2804B- 9C 1E 21		STZ $211E
2804E- 9C 1F 21		STZ $211F
28051- 9C 20 21		STZ $2120
28054- 9C 21 21		STZ $2121
28057- 9C 23 21		STZ $2123
2805A- 9C 24 21		STZ $2124
2805D- 9C 25 21		STZ $2125
28060- 9C 26 21		STZ $2126
28063- 9C 27 21		STZ $2127
28066- 9C 28 21		STZ $2128
28069- 9C 29 21		STZ $2129
2806C- 9C 2A 21		STZ $212A
2806F- 9C 2B 21		STZ $212B
28072- 9C 2C 21		STZ $212C
28075- 9C 2D 21		STZ $212D
28078- 9C 2E 21		STZ $211E
2807B- 9C 30 21		STZ $2130
2807E- 9C 31 21		STZ $2131
28081- 9C 32 21		STZ $2132
28084- 9C 33 21		STZ $2133
28087- 5C 00 80 82		JML $818002 //Now that all is set, jump to where it was suposed to
It worked with bsnes-plus accuracy and on real hardware, also did the same to Blaster Master and Donkey Kong and both work.

(I'm not the most knowledgeble person about the SNES hardware and 65816 machine code, so excuse me if theres some problem with the code)
StarkMan8172
Posts: 1
Joined: Sat Sep 05, 2020 10:55 am

Re: Project Nested - NES emulator for SNES

Post by StarkMan8172 »

Once it is in a stable state, I wonder the possibilities romhacking these games would be like if the NES emulator supports the SNES capabilities. Now even the NES games may even have MSU-1 capabilities. :D

Looking forward to this project.

Will FDS games be supported in the future? I know FDS disc works very differently from an NES cart.
Myself086
Posts: 158
Joined: Sat Nov 10, 2018 2:49 pm

Re: Project Nested - NES emulator for SNES

Post by Myself086 »

StarkMan8172 wrote: Sat Sep 05, 2020 11:27 am Once it is in a stable state, I wonder the possibilities romhacking these games would be like if the NES emulator supports the SNES capabilities. Now even the NES games may even have MSU-1 capabilities. :D
Reading controller input has access to all 12 SNES buttons as of the current release.

There's an undocumented supported opcode ($22) which normally crashes the 6502 but can be used as JSL to a SNES address and escape emulation. Other illegal 6502 opcodes either stop the emulator or do something completely different than you'd expect from 6502 or 65816.

All NES CHR data is using 4bpp with its MSB zeroed, I may add the possibility to use full 4bpp CHR data in later builds.

Stability issues are mostly from tricky stack manipulations and missing timing emulation, 2 stack issues are fixed for the upcoming v1.1. There will be a way to patch timings later by setting the virtual scanline.
StarkMan8172 wrote: Sat Sep 05, 2020 11:27 am Will FDS games be supported in the future? I know FDS disc works very differently from an NES cart.
I haven't looked into FDS yet, it all depends how if I can fit everything together.

I expect that caching ROM into SRAM will be required which is something some mapper 5 games will need as well. This method adds more overhead to bank switching and accessing ROM data.
Myself086
Posts: 158
Joined: Sat Nov 10, 2018 2:49 pm

Re: Project Nested - NES emulator for SNES

Post by Myself086 »

I added a blue screen when an exception is thrown. The emulator was designed to trap the CPU with any 8-bit branch pointing to itself which was mainly used to be detected by my private SNES emulator. I finally got around to associating an error message to almost every one of them and showing it on screen.

The line below "Error!" should be reported when updating the compatibility spreadsheet. In the case of "Out of Memory" though, this error should be avoidable most of the time with AOT compilation by following step 5 on the exe's main window.

There's still a bit of work to do for v1.1 as some of the changes are incomplete.
Attachments
BlueScreen.png
User avatar
NovaSquirrel
Posts: 483
Joined: Fri Feb 27, 2009 2:35 pm
Location: Fort Wayne, Indiana
Contact:

Re: Project Nested - NES emulator for SNES

Post by NovaSquirrel »

Myself086 wrote: Mon Aug 10, 2020 10:33 am Mesen-S treats it as open bus but the real hardware has unused DMA memory there.
Turns out this was the only problem keeping it from working. Or at least with that fix in place I can now play Donkey Kong.
Attachments
Mesen-S Donkey Kong.png
Myself086
Posts: 158
Joined: Sat Nov 10, 2018 2:49 pm

Re: Project Nested - NES emulator for SNES

Post by Myself086 »

Update is out!

With the number of games that were tested on v1.0, I decided to hold the update for a bit longer until I get the blue screen ready and a few other things.

I've been very busy after my last post. My next focus is to spend more time understanding Github and start uploading experimental builds. The SMC source will be uploaded shortly after some clean up.

v1.1 changes:
- Fixed sprite pattern table swap made by mappers when sprites are 8x16 in size
- Fixed sprite transfer from pages $08-$1f and $60-$ff
- VramQ is now optionally resizable
- Fixed CHR pattern swapping for mapper 4
- Added nametable mirror select for mapper 4
- Partly fixed nametable mirror select for mapper 1
- Fixed STX/STY to $2000 and $4014
- Sprite size and pattern table are now decided at the beginning of each frame rather than during transfer
- Fixed RTS used as indirect jump
- Fixed pushing constant return address with PHA
- Fixed indirect JMP reading from pages $08-$1f and $60-$ff
- Added blue screen of death
- Fixed black screen on repro carts (thanks to soniccd123)
- Fixed compatibility with Mesen-S
- Added ; as a line separator when editing patches
- Added a reset code to the SPC, necessary for combo randomizers (write $F5 to port $2140)
soniccd123
Posts: 46
Joined: Sat Jun 27, 2020 12:01 pm

Re: Project Nested - NES emulator for SNES

Post by soniccd123 »

As always, amazing project!

Are you updating the compatibility list on your own? I've tested several games and found one or two that worked and aren't on the list, i would be happy to help if you want.

Also, found some blue screens and some that says to report them, would you like them to be reported somewhere? And if so, where?

Again, thanks for the amazing work, looking forward for next developments.

Soniccd123.
User avatar
Quietust
Posts: 1918
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: Project Nested - NES emulator for SNES

Post by Quietust »

Just tried version 1.1, and a lot more of my personal test ROMs are working now.

However, I noticed that the "Sprite limit per scanline" option seems to be off by one, at least when running in bsnes v115 - the 9th sprite (which triggers Sprite Overflow) is still being displayed, while the 10th one (and everything past it) properly gets hidden.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
Post Reply