Mesen - NES Emulator

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
za909
Posts: 207
Joined: Fri Jan 24, 2014 9:05 am
Location: Hungary

Re: Mesen - NES Emulator

Post by za909 » Mon May 04, 2020 11:28 pm

Sour wrote:
Sun May 03, 2020 4:39 pm
za909 wrote:
Sun May 03, 2020 4:24 pm
CHR-ROM is used instead of RAM
This is most likely the cause - Mesen defaults to using the NINA-001 mapper (which is also mapper 34) when there is CHR ROM in the cart (because all commercial BNROM games use CHR RAM.)

You can force mapper 34 to use BNROM by using a NES 2.0 header and specifying a submapper:
http://wiki.nesdev.com/w/index.php/NES_ ... F_NINA-001
Thank you! I have "upgraded" the header to 2.0 and it works perfectly. This emulator has already allowed me to see issues that I would've never known existed in my projects (like incorrect metasprite definitions resulting in extra sprites that were hidden behind other sprites, which the sprite viewer allowed me to discover) or IRQ congestion from OAM DMA... I am in awe and seriously considering supporting this emulator.

Paul_Atreides
Posts: 9
Joined: Mon Apr 13, 2020 5:24 am

Re: Mesen - NES Emulator

Post by Paul_Atreides » Tue May 05, 2020 11:03 pm

This is a very general question and I'd appreciate it if someone took the time to answer.

I'm working on an emulator core and can already correctly emulate some mapper0 games.
I'm using OLC's pixel game engine for rendering the frames, but want to progress to something more powerful.

I want to integrate the emulator's video in a GUI which allows menu items, buttons, and your typical GUI elements. I can see MESEN uses C# with WindowsForms for that.

My question: what technology / library is used by MESEN to render the game's frames?
How's this integrated in the WindowsForms main window (frmMain.cs)?

I came across the SDL library, but it's complicated to integrate into good-looking GUIs, and you have to use a number of alternative solutions, not WFs.

Sour
Posts: 807
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - NES Emulator

Post by Sour » Wed May 06, 2020 6:49 pm

za909 wrote:
Mon May 04, 2020 11:28 pm
Thank you! I have "upgraded" the header to 2.0 and it works perfectly.
No problem, happy to hear you got it working!
Paul_Atreides wrote:
Tue May 05, 2020 11:03 pm
what technology / library is used by MESEN to render the game's frames?
On Windows, Mesen uses DirectX11, on Linux, it uses SDL2. Any graphic library should just let you specify any control as its rendering "window", but I don't really have too much experience there. I wouldn't necessarily recommend going the DX11 route - it's a lot more code to get something on the screen compared to SDL2, in my experience.

User avatar
Jarhmander
Formerly ~J-@D!~
Posts: 497
Joined: Sun Mar 12, 2006 12:36 am
Location: Rive nord de Montréal

Re: Mesen - NES Emulator

Post by Jarhmander » Thu May 07, 2020 4:50 am

Simple question: why is SDL not used on Windows? Is it because it's harder to integrate into window controls? I ask because SDL should be usable on Windows and there would be no need to maintain 2 different rendering codes.
((λ (x) (x x)) (λ (x) (x x)))

Sour
Posts: 807
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - NES Emulator

Post by Sour » Thu May 07, 2020 3:21 pm

Jarhmander wrote:
Thu May 07, 2020 4:50 am
Simple question: why is SDL not used on Windows?
There are a few reasons. Mesen did not have a Linux port for its first 2.5 years of development, for one. I also want to keep both distribution and compilation as simple as possible, so it's easier to rely on Windows APIs that are available on all modern Windows PCs, without requiring external stuff. Plus, it all currently seems to work well for the vast majority of users, so I'm not too keen on changing anything video/audio/input related and risk making something worse for some PCs, and there's virtually no maintenance cost to keeping DX11, as it is all code that I barely ever touch at this point.

mkwong98
Posts: 226
Joined: Mon May 30, 2011 9:01 pm

Re: Mesen - NES Emulator

Post by mkwong98 » Sat May 23, 2020 4:04 am

Hi Sour, several people working with HD packs find it useful to have one of these:
set loop points in the music track in the hires.txt file
set two music files as a single track with one as introduction and one as looping
use specific tags in the ogg file as loop points info like https://rpgmaker.net/tutorials/1341/
Please have a look when you have time. Thanks.

User avatar
Controllerhead
Posts: 55
Joined: Tue Nov 13, 2018 4:58 am
Location: $4016
Contact:

Re: Mesen - NES Emulator

Post by Controllerhead » Thu Jun 04, 2020 5:09 am

Is there a good way to determine PPU nametable mirroring in the Lua API?

I can get xCameraPosition, yCameraPosition, and top left corner nametable info just fine. Mirroring info doesn't seem to be anywhere. I can kind of understand why, from what i gather, cartridges do it through mapping or physically wiring pins to the address lines, and the PPU is kind of oblivious to the situation, so there are no internal registers for it or anything ...is that right?

Anyway, right now, i am writing bytes to the PPU, testing if they change in the mirrored positions, and then changing them back to the original each frame. It works fine, but it's probably not efficient, and i'm wondering if there is a better way or if i am missing something obvious in emu.getState().ppu.state or elsewhere. Now, before you say just check the header, many games change mirroring on the fly, such as Metroid, and i need that information on each frame. Any suggestions / help are appreciated. Thanks!

Sour
Posts: 807
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - NES Emulator

Post by Sour » Thu Jun 04, 2020 1:34 pm

mkwong98 wrote:
Sat May 23, 2020 4:04 am
set loop points in the music track in the hires.txt file
This has been requested before in another thread here, iirc. It's on my list, but like so many other things on my list, I don't always have the time to get to them very quickly. It will hopefully be added before the next major release, though.
Controllerhead wrote:
Thu Jun 04, 2020 5:09 am
Is there a good way to determine PPU nametable mirroring in the Lua API?
There isn't at the moment, from what I can tell (other than reading and comparing the memory)
I thought state.cart.selectedChrPages might work, but it's an old API and only exposes the mappings from $0000-$1FFF. I could probably add another more precise set of values that could give proper access to all the mappings for the PPU, though.

Leonheart
Posts: 3
Joined: Thu Jun 04, 2020 2:33 pm

Re: Mesen - NES Emulator

Post by Leonheart » Thu Jun 04, 2020 2:44 pm

Sour wrote:
Thu Jun 04, 2020 1:34 pm
mkwong98 wrote:
Sat May 23, 2020 4:04 am
set loop points in the music track in the hires.txt file
This has been requested before in another thread here, iirc. It's on my list, but like so many other things on my list, I don't always have the time to get to them very quickly. It will hopefully be added before the next major release, though.
Controllerhead wrote:
Thu Jun 04, 2020 5:09 am
Is there a good way to determine PPU nametable mirroring in the Lua API?
There isn't at the moment, from what I can tell (other than reading and comparing the memory)
I thought state.cart.selectedChrPages might work, but it's an old API and only exposes the mappings from $0000-$1FFF. I could probably add another more precise set of values that could give proper access to all the mappings for the PPU, though.

Hey, sir. I gotta question. I love mesen very much but I have a problem playing a translated rom on it. When it's raw or not patched it plays but as I soon as I patched it.... the screen goes black. The game is DBZ - Kyoushou! Saiyajin. Nes

User avatar
Controllerhead
Posts: 55
Joined: Tue Nov 13, 2018 4:58 am
Location: $4016
Contact:

Re: Mesen - NES Emulator

Post by Controllerhead » Thu Jun 04, 2020 4:30 pm

Sour wrote:
Thu Jun 04, 2020 1:34 pm
Controllerhead wrote:
Thu Jun 04, 2020 5:09 am
Is there a good way to determine PPU nametable mirroring in the Lua API?
There isn't at the moment, from what I can tell (other than reading and comparing the memory)
It's cool man, no worries, what i have works just fine. I just wanted to make sure i wasn't missing something obvious in the emu.getState() tables. It may be helpful to add in the future, but it's not important. Thanks for everything you do!

Post Reply