I'm currently using Mesen as my emulator, and I can't help but missing the printf or similar console output from higher level programming languages.
I'm not sure if anything like this exists, but I keep thinking it would be nice if there were some way an emulator could watch a chunk of memory for changes, and then write that out to a file whenever it is written to. Mesen already highlights in red parts of memory when it is written to. In the 6502 assembly a little macro called "Log" could be written that would just write a short message to the part of memory being monitored. The emulator would then detect the change and dump the contents to a file.
Does something like this exist?
If not, does it make sense that it should exist?
If so what would I need to go about doing to tweak Mesen or some other emulator to add this feature?
You could also put a sprite in the top left corner if something happens, or flip the grayscale bit on 2001, or set a sound channel on or off depending if a thing happens.
I don't do any of that. I use breakpoints and step through the code.
Thanks dougdougeff wrote:Someone wrote a LUA script, I think it was for FCEUX, that put something on the screen depending on a RAM address value.
So do either FCEUX or Mesen support scripting?
I don't have any example code though.
Here's an example of someone using LUA scripts...
This looks like a LUA for FCEUX which displays stats on screen...(river city ransom)
https://github.com/BillyWM/FCEUX-Lua-Sc ... isplay.lua
Sour wrote:For Mesen, you should be able to use the endFrame callback to read the value from ram and print its value on the screen with drawString. There are a number of Lua script examples built into the script editor window, you can take a look at those if you want to get a better understanding of how to write your script. (Don't have access to a computer at the moment, so can't write a proper example, sorry!)
I came up with this:
Code: Select all
prev_string = "unknown" address_start = 0x0300 function logIt() --emu.memType.cpu address = address_start log_string = "" repeat byte_number = emu.read( address, emu.memType.cpu) log_string = log_string .. string.char(byte_number) address = address + 1 until byte_number == 0 -- if log_string ~= prev_string then emu.log("log=" .. log_string) -- end prev_string = log_string end emu.log("begin") emu.addEventCallback(logIt, emu.eventType.endFrame);
Hope this helps.
edit: What really helped me to figure out why animations weren't running at the proper time was after I unchecked the View>"Memory Access Highlighting">Writes box in the Memory Tools part of Mesen. That allowed me to only view the Reads (blue) and that was so helpful to me because my reading logic needed much work. The reds used to overwrite the blues, for me, at least.