Mesen - NES Emulator

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
Aclectico
Posts: 4
Joined: Thu Aug 09, 2018 10:56 am

Re: Mesen - NES Emulator

Post by Aclectico » Mon Apr 12, 2021 8:44 am

mkwong98 wrote:
Sun Apr 11, 2021 10:37 pm
I'm adding a new condition for sprite tiles. It works like FrameRange but have separate frame counter for each of the 64 sprites in OAM and the frame counters reset when the graphics changes. So you can sync the HD replacement with the sprite animation. But it won't work if the sprites frequently switch location in OAM.
Interesting - So, would this make it possible to add frames to situations like jumping or shooting animations? I know one of the limitations of current FrameRange conditions is being unable to designate a start and end point. As a result, adding frames for walking or for other looping situations worked, but not much else. It would be a great if this is no longer a significant roadblock anymore.

Fiskbit
Posts: 275
Joined: Sat Nov 18, 2017 9:15 pm

Re: Mesen - NES Emulator

Post by Fiskbit » Mon Apr 12, 2021 12:12 pm

Most games shuffle the position of sprite tiles in OAM every frame, so this might not be as useful as you hope.

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

Re: Mesen - NES Emulator

Post by mkwong98 » Mon Apr 12, 2021 6:12 pm

Aclectico wrote:
Mon Apr 12, 2021 8:44 am
Interesting - So, would this make it possible to add frames to situations like jumping or shooting animations? I know one of the limitations of current FrameRange conditions is being unable to designate a start and end point. As a result, adding frames for walking or for other looping situations worked, but not much else. It would be a great if this is no longer a significant roadblock anymore.
Yes, this is the main use of this feature.
Fiskbit wrote:
Mon Apr 12, 2021 12:12 pm
Most games shuffle the position of sprite tiles in OAM every frame, so this might not be as useful as you hope.
I have considered keeping the counter based on screen position instead of OAM slot too, but OAM based is easier and so I want to get that done first.

User avatar
Dwedit
Posts: 4460
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Mesen - NES Emulator

Post by Dwedit » Tue Apr 13, 2021 12:43 am

I just implemented a new Comment Editor: You press Semicolon, you can type in a comment, then hit Enter, and you've just added in a comment to the debugger. No need to create a Label first, or accidentally on the wrong part of the instruction and create the wrong label.

If you want to review the code, it's available at: https://github.com/dwedit/mesen/tree/comment-editor
I'll probably do a pull request later.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

User avatar
nesrocks
Posts: 495
Joined: Thu Aug 13, 2015 4:40 pm
Location: Rio de Janeiro - Brazil
Contact:

Re: Mesen - NES Emulator

Post by nesrocks » Tue Apr 13, 2021 4:51 am

Context: I currently use emulators for reverse engineering games much more than homebrewing. These issues may seem small but scream to me and the fact that I can't fix them creates a barrier that keeps me from using mesen. I mean, if I can't fix or even understand why these things are here, then that's a red flag to me. Anyway: [/context]

Minor request. Can these two dots be removed? It bugs me so much because usually dots are used to imply omission. The visual message I get from that is that a section of addresses is being omitted. So I look at the addresses before and after the dots, and clearly, there can't be any omission because they are consecutive addresses. So I lose a lot of time checking the addresses. Why add dots?

Image

And a question. Why were these automatic labels added? What is the point of automatic labels? Can anyone ever need them? They are extremely confusing to me and what's worse, I can't find how to turn them off. Should be in Options - Disassembly Options. No? Sure, I can delete them one by one, but that's a huge amount of work when I believe it shouldn't have automatically created them.

Image
https://twitter.com/bitinkstudios <- Follow me on twitter! Thanks!

User avatar
Dwedit
Posts: 4460
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Mesen - NES Emulator

Post by Dwedit » Tue Apr 13, 2021 8:38 am

"Options > Auto Create Jump Labels" turns them on or off. It doesn't destroy the labels it created though.

Edit: Regarding the ".." labels, that's done by a function called "DrawLineNumber":

Code: Select all

...
string lineNumber;
if(string.IsNullOrEmpty(_lineNumberNotes[currentLine])) {
	lineNumber = _lineNumbers[currentLine] >= 0 ? _lineNumbers[currentLine].ToString(_showLineInHex ? "X4" : "") : "..";
} else {
	lineNumber = _lineNumberNotes[currentLine];
}
It's just putting on ".." every time it can't put the address of the code there instead.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

User avatar
nesrocks
Posts: 495
Joined: Thu Aug 13, 2015 4:40 pm
Location: Rio de Janeiro - Brazil
Contact:

Re: Mesen - NES Emulator

Post by nesrocks » Tue Apr 13, 2021 11:33 am

Dwedit wrote:
Tue Apr 13, 2021 8:38 am
"Options > Auto Create Jump Labels" turns them on or off. It doesn't destroy the labels it created though.
Hummm... That setting was already off. So I wasn't understanding what was wrong about that because the debug files are saved in mesen's folder, not along with the game's ROM (which is good actually). Thanks!

About the two dots, thanks, I'll look into that. So it seems there's no differentiation in code for when sections of disassembled addresses are omitted or if it's just a labeled line, which complicates things.
https://twitter.com/bitinkstudios <- Follow me on twitter! Thanks!

User avatar
Dwedit
Posts: 4460
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Mesen - NES Emulator

Post by Dwedit » Tue Apr 13, 2021 1:02 pm

I also just added the "BRK" instruction as a "jump" type instruction to stop the disassembler from proceeding past a BRK. Some games use BRK for special types of calls, so they will put data after the instruction.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

unregistered
Posts: 1184
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: Mesen - NES Emulator

Post by unregistered » Tue Apr 13, 2021 9:24 pm

nesrocks wrote:
Tue Apr 13, 2021 11:33 am
Dwedit wrote:
Tue Apr 13, 2021 8:38 am
"Options > Auto Create Jump Labels" turns them on or off. It doesn't destroy the labels it created though.
Hummm... That setting was already off. So I wasn't understanding what was wrong about that because the debug files are saved in mesen's folder, not along with the game's ROM (which is good actually). Thanks!
You can always destroy the labels created by editing your ROM’s .mlb file.

.mlb files are kept in Mesen’s “Debugger” folder.

1.) The P: lines are all labels. Add/remove whatever pleases you. The .mlb file only affects how your ROM appears in Mesen’s debugger. save.
2.) Then, in Mesen’s Debugger click: File>Workspace>”Import Labels” and find and load your .mlb file.


—-
Also, if you change/move a function start, you can also open your ROM’s .cdl file (kept in the same “Debugger” folder) in a Hex editor and:
1.) Find the 5 digit hex code location of the old function start (listed on the left edge of Mesen’s debugger; if the left edge lists “C26F [3C]”, then the 5 digit .cdl hex location would be $3C26F. Sometimes, with my large RAM mapper, it’s crazy, but always start with the 2 digits inside the brackets followed by the right 3 digits of the actual 16bit address. Ooh, whatever is in the brackets always comes first; that’s always followed by the right 3 digits of the actual 16bit address. i.e. If the left edge lists “BF45 [7]”, then the .cdl hex location would be $7F45. So, .cdl hex locations AREN’T locked to a 5 digit length.)
2.) Search that location in your Hex editor.
3.) Replace the current $81 with $01 (The 7th bit set declares to Mesen’s debugger that a function starts at the specified address; the 0th bit set declares that byte’s address has been executed, so it will be white).

4.) Then search the 5 digit location of the new function start in your Hex editor
5.) change that byte by setting its bit7; save

6.) In Mesen’s debugger: Tools>“Code/Data Logger”>”Load CDL file” and find and load your .cdl file. (Sadly, load cdl files always causes the PC to change to a future spot.)


Note: supposedly, asm6f does all of ^these .cdl updates automatically during each ROM build... if you’d like that.


edit.
final-edit.
Last edited by unregistered on Fri Apr 16, 2021 2:35 pm, edited 2 times in total.

unregistered
Posts: 1184
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: Mesen - NES Emulator

Post by unregistered » Wed Apr 14, 2021 12:45 pm

nesrocks wrote:
Tue Apr 13, 2021 11:33 am
So it seems there's no differentiation in code for when sections of disassembled addresses are omitted or if it's just a labeled line, which complicates things.
Actually, in the .cdl file, if you change a group of bytes, outside a function start and its rts, to $00, that section of code will be represented by a red bar. Its start address and end address will be listed on Mesen’s Debugger’s left side.

So that’s a nice differentiation. :)

—- Also $02 .cdl bytes, outside function start and rtses, make the debugger show those addresses as data (you’ll be able to see each byte value and the data is also displayed in a different color).

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

Re: Mesen - NES Emulator

Post by mkwong98 » Thu Apr 15, 2021 8:46 am

Just added a new release with changes from Dwedit:
https://github.com/mkwong98/Mesen/relea ... 9.9-210415

The new sprite frame range condition is added too. It works like frameRange except it follows frame counters assigned to each sprite. Frame counter picks up the nearest frame counter within 6x6 pixels from the last frame and resets if graphics, palette, bg priority or orientation has changed. The condition can be used by sprite tiles only. For example I made a demo of a droopy Megaman by adding a replacement 60 frames after each blink:

<condition>myCondition,spriteFrameRange,301,60
[myCondition]<tile>0,9CDEDE5C3C000000027979A37E3E0000,FF20380F,0,0,1,N,2618358473,0
Mega Man (U).zip
Droopy Megaman
(3.17 KiB) Downloaded 61 times
There are a few limitation to this condition:
1. It doesn't keep track of graphics before the changes so if the tile changes like A->B->C->B->A, then you can't tell the current B is the first B and the second B in the sequence
2. If sprites overlap then the frame counters may pick the wrong sprite from the last frame
3. Doesn't work for sprites moving too fast on screen (over 6 pixels per frame)
4. Doesn't work for sprites which are not visible, so a sprite flashing intentionally or due to sprite limit will not work.

unregistered
Posts: 1184
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: Mesen - NES Emulator

Post by unregistered » Mon Apr 19, 2021 1:54 pm

unregistered wrote:
Tue Apr 13, 2021 9:24 pm
.mlb files are kept in Mesen’s “Debugger” folder.

1.) The P: lines are all labels.
It just occurred to me that .mlb must stand for: Mesen labels

So, the P: lines are all normal labels. The G: lines are Global labels... so they are valid regardless of what bank is being used. If you’re interested, Sour told me what each of the letters mean somewhere in this thread. (I don’t remember where; maybe close to page 50. :) )


.cdl is a good acronym too: Code/Data Logger

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

Re: Mesen - NES Emulator

Post by mkwong98 » Mon Apr 19, 2021 6:02 pm

unregistered wrote:
Mon Apr 19, 2021 1:54 pm
It just occurred to me that .mlb must stand for: Mesen labels

So, the P: lines are all normal labels. The G: lines are Global labels... so they are valid regardless of what bank is being used. If you’re interested, Sour told me what each of the letters mean somewhere in this thread. (I don’t remember where; maybe close to page 50. :) )


.cdl is a good acronym too: Code/Data Logger
Should we make a copy of the documentation in Github and keep updating it with info like this? I want to add info of the new features too.

unregistered
Posts: 1184
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: Mesen - NES Emulator

Post by unregistered » Wed Apr 21, 2021 4:43 pm

mkwong98 wrote:
Mon Apr 19, 2021 6:02 pm
unregistered wrote:
Mon Apr 19, 2021 1:54 pm
It just occurred to me that .mlb must stand for: Mesen labels

So, the P: lines are all normal labels. The G: lines are Global labels... so they are valid regardless of what bank is being used. If you’re interested, Sour told me what each of the letters mean somewhere in this thread. (I don’t remember where; maybe close to page 50. :) )


.cdl is a good acronym too: Code/Data Logger
Should we make a copy of the documentation in Github and keep updating it with info like this? I want to add info of the new features too.
Hi mkwong98,

Sour never posted this info anywhere public... but it can be found in bits and pieces in Sour’s replies here. In asm6, I’m using some variables (or labels) that are in the same location in each bank.

Code: Select all

label = $
after tokumaru taught me about that.

Sour’s reply about the G: lines extremely helped me to create a global label that is valid regardless of the current bank. It’s so cool to get that to work! 😀

Sure, I guess that would be good to do. Hope you found Sour’s explanation... I don’t have time to find it now... sorry gtg.

CharCorr
Posts: 3
Joined: Tue Jan 12, 2021 10:28 am

Re: Mesen - NES Emulator

Post by CharCorr » Thu Apr 22, 2021 5:21 am

Hello again.

mkwong98, I tried your fork of Mesen. The new one with the changes to the MMC3 IRQ. Sorry to say that in this version, the Mega Man 3 Improvement hack crashes on the title screen every time. No matter what the settings are, it delivers "invalid op code - CPU crashed" and flips out. Darn. :(

Post Reply