使用开源SNES模拟器代码将rom文件变成独立的可执行游戏

发布于 2024-09-06 00:56:36 字数 140 浏览 8 评论 0原文

是否可以从 SNES 模拟器(或任何其他游戏系统模拟器)和系统的游戏 ROM 中获取源代码,并以某种方式创建一个独立的可执行文件,让您无需使用特定的 ROM 即可玩该程序是单独的rom还是模拟器自己玩?假设您已经有了可以使用的 ROM 和模拟器源代码,这会很困难吗?

Would it be possible to take the source code from a SNES emulator (or any other game system emulator for that matter) and a game ROM for the system, and somehow create a single self-contained executable that lets you play that particular ROM without needing either the individual rom or the emulator itself to play? Would it be difficult, assuming you've already got the rom and the emulator source code to work with?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

樱花细雨 2024-09-13 00:56:36

如果您有模拟器源代码,这应该不会太困难。您可以使用通常用于在 c 源文件中存储图像的方法。

基本上,您需要做的是在头文件中创建一个 char * 变量,并将 rom 文件的内容存储在该变量中。您可能需要编写一个脚本来自动执行此操作。

然后,您需要更改源代码,以便它不是从文件中读取 ROM,而是使用 ROM 的内存版本,存储在变量中并包含在头文件中。

如果您需要模拟文件指针等,可能需要做一些工作,或者您可能很幸运,发现 rom 加载函数只是一次加载整个文件。在这种情况下,它可能就像用返回指针的函数替换文件加载函数一样简单。

但是,请注意许可问题。如果模拟器根据 GPL 获得许可,则法律上可能不允许您在可执行文件中存储专有文件,因此值得检查这一点,特别是在发布/分发它之前(如果您打算这样做)。

It shouldn't be too difficult if you have the emulator source code. You can use a method that is often used to store images in c source files.

Basically, what you need to do is create a char * variable in a header file, and store the contents of the rom file in that variable. You may want to write a script to automate this for you.

Then, you will need to alter the source code so that instead of reading the rom in from a file, it uses the in memory version of the rom, stored in your variable and included from your header file.

It may require a little bit of work if you need to emulate file pointers and such, or you may be lucky and find that the rom loading function just loads the whole file in at once. In this case it would probably be as simple as replacing the file load function with a function to return your pointer.

However, be careful for licensing issues. If the emulator is licensed under the GPL, you may not be legally allowed to store a proprietary file in the executable, so it would be worth checking that, especially before you release / distribute it (if you plan to do so).

暮凉 2024-09-13 00:56:36

是的,超出了可能,已经做过很多次了。谷歌:静态二进制翻译。 Graham Toal 有一篇关于这个主题的很好的指导论文,应该会出现在热门文章的早期。那里可能有一些代码,我可能已经留下了一些代码。

完全删除 rom 可能比您想象的要多一些工作,但不使用模拟器,绝对是可能的。实际上,这两种要求都是可能的,您可能会惊讶地发现有多少手持游戏机游戏或机顶盒游戏是经过翻译而不是模拟的。 Esp 平台(例如任天堂的平台)没有足够的处理能力来实时模拟。

您需要一个好的模拟器作为参考和/或编写自己的模拟器作为参考。然后你需要编写一个反汇编器,然后让该反汇编器生成 C 代码(请不要尝试直接翻译到另一个目标,我曾经犯过这个错误,C 是可移植的,编译器会消除大量死代码你)。因此,假装指令集的指令可能是:

add r0,r0,#2

这可能会翻译成:

//add r0,r0,#2
r0=r0+2;
do_zflag(r0);
do_nflag(r0);

看起来 SNES 与 Asteroids 使用的 6502 有关,这也是我断断续续工作了一段时间的翻译作为一种爱好。您使用的模拟器可能是针对运行时性能而编写和调整的,并且最多可能很难用作参考并检查翻译代码的锁定步骤。 6502 很好,因为与 z80 相比,确实没有那么多指令。与任何可变字长指令集一样,反汇编程序是您的第一个大障碍。不要线性思考,思考执行顺序,像模拟器一样思考,你不能将指令从零线性转换到 N 或 N 到零。您必须遵循所有可能的执行路径,将 ROM 中的字节标记为指令的第一个字节,而不是指令的第一个字节。您可以将某些字节解码为数据,如果您选择标记这些字节,否则假设所有其他字节都是数据或填充。弄清楚如何处理这些数据来摆脱 rom 是摆脱 rom 的问题。有些代码直接寻址数据,其他代码则在翻译时使用寄存器间接含义,您不知道该数据在哪里或有多少。一旦你标记了指令的所有起始字节,那么将 ROM 从 0 到 N 反汇编和/或翻译就是一项简单的任务。

祝你好运,享受,非常值得体验。

Yes, more than possible, been done many times. Google: static binary translation. Graham Toal has a good howto paper on the subject, should show up early in the hits. There may be some code out there I may have left some code out there.

Completely removing the rom may be a bit more work than you think, but not using an emulator, definitely possible. Actually, both requirements are possible and you may be surprised how many of the handheld console games or set top box games are translated and not emulated. Esp platforms like those from Nintendo where there isnt enough processing power to emulate in real time.

You need a good emulator as a reference and/or write your own emulator as a reference. Then you need to write a disassembler, then you have that disassembler generate C code (please dont try to translate directly to another target, I made that mistake once, C is portable and the compilers will take care of a lot of dead code elimination for you). So an instruction of a make believe instruction set might be:

add r0,r0,#2

And that may translate into:

//add r0,r0,#2
r0=r0+2;
do_zflag(r0);
do_nflag(r0);

It looks like the SNES is related to the 6502 which is what Asteroids used, which is the translation I have been working on off and on for a while now as a hobby. The emulator you are using is probably written and tuned for runtime performance and may be difficult at best to use as a reference and to check in lock step with the translated code. The 6502 is nice because compared to say the z80 there really are not that many instructions. As with any variable word length instruction set the disassembler is your first big hurdle. Do not think linearly, think execution order, think like an emulator, you cannot linearly translate instructions from zero to N or N down to zero. You have to follow all the possible execution paths, marking bytes in the rom as being the first byte of an instruction, and not the first byte of an instruction. Some bytes you can decode as data and if you choose mark those, otherwise assume all other bytes are data or fill. Figuring out what to do with this data to get rid of the rom is the problem with getting rid of the rom. Some code addresses data directly others use register indirect meaning at translation time you have no idea where that data is or how much of it there is. Once you have marked all the starting bytes for instructions then it is a trivial task to walk the rom from zero to N disassembling and or translating.

Good luck, enjoy, it is well worth the experience.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文