schellingb / dosbox-pure

DOSBox Pure is a new fork of DOSBox built for RetroArch/Libretro aiming for simplicity and ease of use.
GNU General Public License v2.0
777 stars 65 forks source link

Feature request: cheatX_address in .cht files are inconsistent between DOSBox-pure versions #548

Open AleWin32 opened 1 week ago

AleWin32 commented 1 week ago

I have created some .cht files for some very basic DOS games.

Cheats always work for all the executions of the games I do (the addresses are always the same, so looks they are not allocated dynamically and are allocated in the stack).

But if i update my Batocera 0.38 distro: (RetroArch 1.15.0 and DOSBox-pure 0.9.7 with default options) to: (RetroArch 1.18.0 and DOSBox-pure 0.9.9 with default options)

the addresses remain inusable because they have changed between DOSBox-pure versions.

For example in Batocera 0.38, it was: cheat0_address = "628757"

but for the same cheat in Batocera 0.40 now it must be: cheat0_address = "44565"

This will make all the .cht files that use addresses for DOSBox-pure unusable, how can this be solved? Is there any solution?

Or is there a way to calculate the final address depending on DOSBox-pure version? or using relative adresses (relative to the memory for the game starts) instead of absolute ones?

schellingb commented 1 week ago

Unfortunately 0.9.8 had to change the layout of the memory blocks reported to the frontend. This was done to provide more stable memory addresses. Before certain configuration options (like audio settings) could affect where in memory a game would store its data. Both DOS and DOSBox aren't really well suited for these things. But there have been steps made towards supporting achievements with RetroAchievements which certainly will require memory addresses to be stable on all platforms. Once we get there, cheats also should be stable. I just don't know exactly when that will be.

It should be possible for you to subtract 584192 (628757 - 44565) on every address you have found to update for 0.9.9?

AleWin32 commented 1 week ago

Sorry @schellingb but i don't have the .cht files anymore :-( This was a problem i had months ago so i have posted it now, and i only have tested it with one memory address i have found.

So do you think is technically possible to maintain the same memory address for all future versions of DOSBox-pure? How is this possible if the memory blocks are going to change across versions? Will not the solution be to expose only the memory that the game "see" and not the full memory (some kind of relative memory)?

schellingb commented 1 week ago

It's not that simple with DOS. DOS is an operating system that does offer memory management functionality. On a real computer running real DOS, switching the DOS version, changing system settings or changing drivers or driver settings would lead to memory of games getting laid out differently in RAM. Similarly with DOSBox, if some part of the DOS emulation is changed, or certain emulation settings are modified, the memory locations given to a game by DOS can then change.

So recent efforts have been made to better protect against this going forward. The memory exposed for cheats by DOSBox Pure is split into 3 blocks:

That very first block can change in size between versions of the core (or between different versions of DOSBox) and also depending on certain system settings. To avoid issues, DOSBox Pure now exposes these 3 blocks of memory independently to the libretro frontend so a change in the BIOS/OS area doesn't affect where the game's memory ends up at.

This doesn't solve all issues because DOS extender memory management will act different depending on the amount of conventional memory available to the game. So there is still a possibility for things to shift around but hopefully less.

AleWin32 commented 1 week ago

Thanks @schellingb for your explanation.

I will check if in the next version of DOSBox-pure, memory adresses are still the same. Tell me if you need to so some testing with games with this thing, i'm very interested in it to be improved.

Having a stable memory address across DOSBox-pure versions will allow us to upload DOS game cheats and make them work, at least for the most simple games that does not use extended/expanded/... memory schemes.