TASEmulators / desmume

DeSmuME is a Nintendo DS emulator
http://desmume.org
GNU General Public License v2.0
2.97k stars 544 forks source link

Support the register-based nocashMessage #840

Open lifehackerhansol opened 3 weeks ago

lifehackerhansol commented 3 weeks ago

State your operating system:

Windows 10

DesMuME version

git master (last tested commit 91196788eb6f8543ea395ac1f6ad9e056dc7c5c2)

Issue

No$GBA supports more than the opcode-based debugging (which is already supported); it also supports writing directly to some pseudo-register, either one char at a time, or a pointer to a string in memory to print at once.

GBATEK explains this concept briefly: https://problemkaputt.de/gbatek-ds-debug-registers-emulator-devkits.htm

You may see the below homebrew code to reproduce this functionality (compile with devkitARM): https://gist.github.com/lifehackerhansol/71e714574171919986e8a202183146b6

It would be nice to support this version of nocashMessage as well. (And perhaps implement the "Emulation ID" register as seen in that GBATEK page as well.)

zeromus commented 3 weeks ago

do other emulators support this

lifehackerhansol commented 3 weeks ago

I tested it with no$gba debug emulator.

I am told that melonDS supports it as well, but I did not try it there.

zeromus commented 3 weeks ago

If you post a test rom that exercises each case, I'll do it

lifehackerhansol commented 3 weeks ago

nocash-register-test.zip

zip contains a ROM with char test case, a ROM with string test case, and the source if you needed it.

zeromus commented 3 weeks ago

Hmm maybe you can help get started. We can work on these one at a time.

4FFFA00h..A0Fh R Emulation ID (16 bytes, eg. "no$gba v2.7", padded with 20h)

Set up a global flag following "emulate ensata" which is "emulate nocash". Don't worry about the stupid dialog box unless you're a windows programmer.

4FFFA10h W String Out (raw)

This one is easy

4FFFA14h W String Out (with %param's) 4FFFA18h W String Out (with %param's, plus linefeed)

These must have required hand-programming to approximate normal stdio behaviour? That's pretty crazy, and there's no way he did a perfect job. Making this work in desmume has bureaucratic implications and is a great idea to skip this one for now

4FFFA1Ch W Char Out (nocash)

This one is easy

4FFFA20h..A27h R Clock Cycles (64bit)

This one should not be hard, but getting the same "sense" as nocash (both in terms of which clock and with what sensible granularity) isn't completely trivial. At this point, given how old that code is in desmume, you have as good a shot as anyone else

lifehackerhansol commented 3 weeks ago

So far I got String Out and Char Out: https://github.com/lifehackerhansol/desmume/tree/nocash-register-logging

For the Emulation ID I thought it would make sense to use DESMUME_NAME EMU_DESMUME_VERSION_NUMERIC(), but I don't have the best idea on how to iterate through that.

(As a side note, I don't have any clue what the Clock Cycle stuff is actually intended for...)

zeromus commented 2 weeks ago

I think the clock cycle stuff is intended for measuring how long your game code takes to run. It can help optimize things.

Rather than output the desmume version, I would have it output nocash's string. In other words, it's saying that it's compatible with nocash.

If you want to add an extra signature in there, how about $DD at +3Fh? If you want to stick the version number near that, that's up to you. I don't think it's that important. We are not very disciplined with our version numbers. but I would just use the numeric portion.