Mesen - Emulator

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Mesen - Emulator

Post by rainwarrior »

Sour wrote: Mon Feb 13, 2023 6:39 pmFor the SNES switching resolution during avi recording issue, I'd have to see, but I don't think AVIs can support the resolution changing during the video itself, so it's not a super simple fix. Although, I think if you use the NTSC filter, the output resolution should be identical (e.g always 2x scale) during gameplay, which might let you record it (with all the disadvantages this implies)
Afaik, Mesen-S had the same limitation.
Yes, I do not believe it's possible to change resolution mid-video in a standards compliant way (though I think it has been tried, there may be odd support for it somewhere). That's why I think the best would be an option to force 2x scale on SNES recording so that it can't ever change. Another alternative, which DOSBox does, is to just automatically start a new numbered video segment every time the resolution changes.

The NTSC filter does indeed seem to be able to record through the interlacing change, but the other filters don't?

Mesen-S does have the same limitation, though it appears to at least consider the video recording stopped in the UI once the point is hit.
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Mesen - Emulator

Post by Pokun »

Well the current system "works", but it's worth to consider when you add the possibility to set firmware ROMs in an UI later. The only current problem is that ROM size is forced so Game Express cards won't work.
Note that the player may want to use the "wrong" card to trigger an error screen on purpose as these contains easter-eggs.
creaothceann
Posts: 611
Joined: Mon Jan 23, 2006 7:47 am
Location: Germany
Contact:

Re: Mesen - Emulator

Post by creaothceann »

rainwarrior wrote: Mon Feb 13, 2023 6:58 pm [...] the best would be an option to force 2x scale on SNES recording so that it can't ever change
Technically the SNES only ever outputs 224 or 239 lines, it's the receiver's job to properly align them... :)
But forcing the output to 512x478@60fps would be the best default option imo.
My current setup:
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Mesen - Emulator

Post by rainwarrior »

creaothceann wrote: Tue Feb 14, 2023 3:50 amTechnically the SNES only ever outputs 224 or 239 lines, it's the receiver's job to properly align them... :)
Not really? The alignment is under the SNES' control by how many lines since vsync. It's not arbitrary, and it must be aligned the same way as other television signals. Consumer TVs rarely have an easily accessible vertical positioning adjustment.

Anyway, if the video output can't include the blank 240th line, that's one more processing step I have to add to every video before I can share and publish it. :S This is one of several reasons why I always turn the overscan removal off for NES.
bklD
Posts: 36
Joined: Fri Sep 01, 2017 8:56 am

Re: Mesen - Emulator

Post by bklD »

Sour wrote: Wed Jan 25, 2023 8:08 pm The main goal at the moment is to fix bugs/crashes in the new version. Any feedback about the UI is welcome, too.
Bug:
Start a game boy game, go to options -> game boy -> video -> select prescale "green" -> ok
Go to "debug" -> settings -> close the window -> the filter gets disabled

Suggestions:
- I like the way you automatically add HD Packs to "tools" when a NES game is started.

What do you think about automatically creating a menu for the respective system in the menu bar as well? Like, you boot for example Chrono Trigger and "SNES" gets added where you can see options like "blend high resolution modes", hide backgrounds, choose controllers, power on state options, etc, and when the game is closed, the menu "SNES" will also be closed again. Ares does this as well and it's very intuitive and handy. ^^


- Add video size of 7x and 8x.
6x is simply too small nowadays
Last edited by bklD on Sun Mar 12, 2023 8:20 am, edited 1 time in total.
Sour
Posts: 891
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - Emulator

Post by Sour »

rainwarrior wrote: Mon Feb 13, 2023 6:58 pmThe NTSC filter does indeed seem to be able to record through the interlacing change, but the other filters don't?

Mesen-S does have the same limitation, though it appears to at least consider the video recording stopped in the UI once the point is hit.
blargg's NTSC filter always generates a frame of the same size whether high res is on or off (it's always essentially 2x scale), this is why the recording doesn't stop. When using any other filter, e.g xBRZ 2x, the resolution would be e.g 512x448 normally, and then go up to 1024x896 if high res mode turns on.

Always rendering at 2x is kind of problematic when it comes to filters, since applying xBRZ on top of an already scaled frame will cause the filter to not have the same effect at all, etc. This is why the filters look like they have nearly no effect for PC Engine at the moment - the rendering resolution for that core is always 4x (e.g 1024x968) because of the need to support all 3 resolutions the PC engine can output.

It looks like snes9x's solution for this is to always output the avi at 256x240, which means the high resolution portions look fairly bad in the recording. I'm not sure that's better? Maybe the solution (for both SNES and PCE) would be to have an "internal resolution" setting somewhere to allow to pick the res (e.g SNES could have "Dynamic" or "512x478" as resolution options), which would allow recording properly without breaking the filters for a typical user.

The latest dev build fixes the UI to make it update itself/warn when the recording stops due to resolution/sample rate changes, like the old versions did.
Also fixed the bug that was making the main window a pixel too small in some scenarios.

bklD wrote: Tue Feb 14, 2023 4:44 pm Bug:
Start a game boy game, go to options -> game boy -> video -> select prescale "green" -> ok
Go to "debug" -> settings -> close the window -> the filter gets disabled
Thanks! This is fixed. I've also added scale 7x to 10x shortcuts/menus.

As far as adding a NES/SNES/etc. menu when loading a game, it seems a bit redundant vs the configuration window (and would require deciding which options are worth putting in the dropdown for each core, etc. - it's a fair bit of extra work). Most of the core-specific options are not options that would frequently need to be changed, either, I think. If you need to change core-specific settings quickly, you can keep the settings window opened while changing with them (this is why all settings are in a single non-modal window in the new UI)
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Mesen - Emulator

Post by rainwarrior »

Sour wrote: Tue Feb 14, 2023 6:05 pmAlways rendering at 2x is kind of problematic when it comes to filters, since applying xBRZ on top of an already scaled frame will cause the filter to not have the same effect at all, etc. This is why the filters look like they have nearly no effect for PC Engine at the moment - the rendering resolution for that core is always 4x (e.g 1024x968) because of the need to support all 3 resolutions the PC engine can output.
Yeah, I think default behaviour that's already there is probably the most intuitive for general purposes.

Forcing 512x480 seems like a 3rd variation of the 2 that are already there: default/dynamic-but-hidden, force 256x240 (i.e. the "blend high resolution" option), and force 512x480.

I dunno if anyone would need the forced version except for video output though. If AVI could split and continue a new file when it changes (the DOSBox approach), that would serve that purpose well. Each segment would have exactly the pixels needed. The problem I ran into was mostly just that it terminated without warning, and even knowing that it's hard to work around because I'd have to restart the video on the exact frame.

Either way is pretty good to me, though. This kinda issue has sorta been a plague with SNES emulators since forever, esp. trying to play the Mana games. I think Mesen is already ahead of the curve with what it has now.
creaothceann
Posts: 611
Joined: Mon Jan 23, 2006 7:47 am
Location: Germany
Contact:

Re: Mesen - Emulator

Post by creaothceann »

rainwarrior wrote: Tue Feb 14, 2023 2:40 pm
creaothceann wrote: Tue Feb 14, 2023 3:50 amTechnically the SNES only ever outputs 224 or 239 lines, it's the receiver's job to properly align them... :)
Not really? The alignment is under the SNES' control by how many lines since vsync. It's not arbitrary, and it must be aligned the same way as other television signals. Consumer TVs rarely have an easily accessible vertical positioning adjustment.
The SNES just waits half a line longer in interlace mode before sending the vsync signal. The beam positioning is all done by the TV.

rainwarrior wrote: Tue Feb 14, 2023 2:40 pm Anyway, if the video output can't include the blank 240th line, that's one more processing step I have to add to every video before I can share and publish it. :S This is one of several reasons why I always turn the overscan removal off for NES.
Right, padding the output to 240/480 lines for the recording makes sense.

rainwarrior wrote: Wed Feb 15, 2023 1:54 am If AVI could split and continue a new file when it changes (the DOSBox approach), that would serve that purpose well. Each segment would have exactly the pixels needed.
In practice I found that dealing with the split files was more effort than just recording at the higher resolution, since the latter is only a problem if you have very little drive space left. These days the average amount of free space is probably in the tens or even hundreds of gigabytes.
My current setup:
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
bklD
Posts: 36
Joined: Fri Sep 01, 2017 8:56 am

Re: Mesen - Emulator

Post by bklD »

Sour wrote: Tue Feb 14, 2023 6:05 pm
bklD wrote: Tue Feb 14, 2023 4:44 pm Bug:
Start a game boy game, go to options -> game boy -> video -> select prescale "green" -> ok
Go to "debug" -> settings -> close the window -> the filter gets disabled
Thanks! This is fixed. I've also added scale 7x to 10x shortcuts/menus.

As far as adding a NES/SNES/etc. menu when loading a game, it seems a bit redundant vs the configuration window (and would require deciding which options are worth putting in the dropdown for each core, etc. - it's a fair bit of extra work). Most of the core-specific options are not options that would frequently need to be changed, either, I think. If you need to change core-specific settings quickly, you can keep the settings window opened while changing with them (this is why all settings are in a single non-modal window in the new UI)
Thank you. I really appreciate that you sharing with us such an amazing emulator.
Sour
Posts: 891
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - Emulator

Post by Sour »

rainwarrior wrote: Wed Feb 15, 2023 1:54 amForcing 512x480 seems like a 3rd variation of the 2 that are already there: default/dynamic-but-hidden, force 256x240 (i.e. the "blend high resolution" option), and force 512x480.
"Blend high resolution" doesn't actually reduce the resolution (it only looked like it did, and the effect was changed so this isn't true anymore).

I've added a few options:
-Record system HUD (record avi popup): allows recording stuff like the fps counter, game timer, on-screen messages, etc.
-Record input HUD (record avi popup): allows recording the input state overlay
-Use fixed output resolution (in SNES->Video and PC Engine->Video): When enabled, the SNES core always outputs at 2x (512x478) and the PCE core always outputs at 4x.

This also changes the default behavior for the PCE core, making it behave like the SNES core does (resolution is picked to match the resolution needed by the game) - this makes all the video filters work much better with the PCE core. Turning on the "fixed resolution" option for the PCE essentially reverts to the old behavior.

As far as recording on the SNES, I think the only thing missing now would be recording with an extra blank line to make the vertical resolution 240p? The simplest solution here would probably be to add an option for this in the avi recording options. (e.g a way to pad the recorded video to be a multiple of X lines tall)
User avatar
ISSOtm
Posts: 58
Joined: Fri Jan 04, 2019 5:31 pm
Location: France, right of a pile of consoles
Contact:

Re: Mesen - Emulator

Post by ISSOtm »

Sour wrote: Mon Feb 13, 2023 2:18 pm
ISSOtm wrote: Sun Feb 12, 2023 2:16 pm It seems like "reload ROM" needs to be used twice to have an effect? It seems to behave like a reset the first time, but normally if I use it again.
I can't reproduce this as far as I can tell. If it really is only doing a reset (fyi, on GB "reset" is the same as "power cycle"), I suspect it's the fact the default shortcuts overlap (Ctrl+R vs Ctrl+Shift+R) and that might be causing an issue somehow on your end? (I can't reproduce it)
Does it show e.g "[NTSC] [rom name]" on the screen when you say it's only resetting - this is only shown when reloading the rom. What's making you say it didn't reload, is it the rom content itself that didn't update to match changes you did to the rom, or is it e.g the labels/etc. in the debugger that didn't get reloaded?
"[NTSC] example" did show on reload, yes. The ROM's contents did not seem to get reloaded, and I'm not sure whether the labels did because they weren't changing at that time. I'll reproduce this later to give more details.
I was resetting via the menu option, so it's not a shortcut issue.

Another bug report: the attached ROM displays garbage on power-on; the setting I have is "Auto, prefer GBC". The colours also seem wrong. The former issue seems to be that VRAM is not all zeros on power-on? (I don't know if SameBoot does, but the official boot ROMs clear VRAM.) I can provide a sym file on request.
Attachments
example.gb
(32 KiB) Downloaded 27 times
The French Lord of Laziness (and a huge Legend of Zelda fan)
https://github.com/ISSOtm
ASMu is laifu <3
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Mesen - Emulator

Post by rainwarrior »

creaothceann wrote: Wed Feb 15, 2023 9:32 am
rainwarrior wrote: Tue Feb 14, 2023 2:40 pm
creaothceann wrote: Tue Feb 14, 2023 3:50 amTechnically the SNES only ever outputs 224 or 239 lines, it's the receiver's job to properly align them... :)
Not really? The alignment is under the SNES' control by how many lines since vsync. It's not arbitrary, and it must be aligned the same way as other television signals. Consumer TVs rarely have an easily accessible vertical positioning adjustment.
The SNES just waits half a line longer in interlace mode before sending the vsync signal. The beam positioning is all done by the TV.
Oh, you were referring to the interlacing half-field delay. I interpreted it as a comment on the more coarse positioning of the signal, where 224 lines mode is definitely positioned by the SNES lower than 239 lines. So, sure, on a modern TV or capture that is deinterlacing, it's the TV's job to figure out where it wants to put the fields.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Mesen - Emulator

Post by rainwarrior »

Sour wrote: Wed Feb 15, 2023 9:04 pmI've added a few options:
-Record system HUD (record avi popup): allows recording stuff like the fps counter, game timer, on-screen messages, etc.
-Record input HUD (record avi popup): allows recording the input state overlay
-Use fixed output resolution (in SNES->Video and PC Engine->Video): When enabled, the SNES core always outputs at 2x (512x478) and the PCE core always outputs at 4x.
These work. :)

One issue with the fixed output resolution setting: if you're paused, change the setting, and then immediately after start recording a video without advancing at least 1 frame, the video will fail and stop recording at the first frame when you unpause.
Sour
Posts: 891
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - Emulator

Post by Sour »

ISSOtm wrote: Thu Feb 16, 2023 12:31 am "[NTSC] example" did show on reload, yes. The ROM's contents did not seem to get reloaded, and I'm not sure whether the labels did because they weren't changing at that time. I'll reproduce this later to give more details.
I was resetting via the menu option, so it's not a shortcut issue.

Another bug report: the attached ROM displays garbage on power-on; the setting I have is "Auto, prefer GBC". The colours also seem wrong. The former issue seems to be that VRAM is not all zeros on power-on? (I don't know if SameBoot does, but the official boot ROMs clear VRAM.) I can provide a sym file on request.
If "[NTSC] ..." shows up on the screen, I don't really see any way (by looking at the code) that could make the emulator not reload the file from the disk. Let me know if you can reproduce it.

The example.gb file you attached seems to run fine on my end, I tried on the latest build and on the old "preview1" build and it looks the same, as far as I can tell. I tried on Linux to be safe, too, and it also seemed fine (by "fine" I mean it displays the same way as in other emulators I tried)
As far as I can tell the boot rom seems to be clearing ram, I'm assuming you don't have a custom boot rom installed in the firmware folder, either?

rainwarrior wrote: Thu Feb 16, 2023 11:09 pm One issue with the fixed output resolution setting: if you're paused, change the setting, and then immediately after start recording a video without advancing at least 1 frame, the video will fail and stop recording at the first frame when you unpause.
Thanks, this should be fixed - it'll wait until the next frame is rendered/recorded to "lock" the width/height/sample rate now.
User avatar
ISSOtm
Posts: 58
Joined: Fri Jan 04, 2019 5:31 pm
Location: France, right of a pile of consoles
Contact:

Re: Mesen - Emulator

Post by ISSOtm »

Sour wrote: Fri Feb 17, 2023 6:26 pm The example.gb file you attached seems to run fine on my end, I tried on the latest build and on the old "preview1" build and it looks the same, as far as I can tell. I tried on Linux to be safe, too, and it also seemed fine (by "fine" I mean it displays the same way as in other emulators I tried)
As far as I can tell the boot rom seems to be clearing ram, I'm assuming you don't have a custom boot rom installed in the firmware folder, either?
This turns out to only happen when "resuming" the ROM from the main menu, and reloading the ROM fixed it. I'm not sure why.

I haven't tried reproduce the "wrong ROM reload" yet, sorry.

I've also had Mesen lock up once or twice but couldn't debug it, so I figured out a way to build with ThreadSanitizer (Clang refuses to work, GCC hums along just fine), and also to get symbols in the reports. Haven't had any lockups since then, but I will attach logs when I get one. (I also should submit a PR, building without LTO is currently broken due to __forceinline without visible bodies.)
The French Lord of Laziness (and a huge Legend of Zelda fan)
https://github.com/ISSOtm
ASMu is laifu <3
Post Reply