Creating remakes of games with emulation: proof of concept

Original author: Gabriel Gambetta
  • Transfer
image

Introduction


“In my time, the games were better. They were more interesting because the gameplay was considered more important than the graphics. "

- Gamers born in any decade

Whatever “your time” may be, I think you to some extent agree with this opinion. For me it was a period from the mid-80s to the mid-90s, when I spent countless hours for Sir Fred , Atic Atac , Airborne Ranger , Monkey Island , Twilight: 2000 , Stunts , Gunship 2000 , Twinsen's Adventure , Dark Sun , Challenge for Ancient Empires , the X-Wing series and so many other games.

Sometimes we experience bouts of nostalgia and we want to play one of those games again. In this case, we have several options to choose from.

Play the remastered version . Some games are so awesome and have gathered such a loyal fan base that the official “new edition” is being released. This is exactly the same game, but with modern graphics. A great example of such games can be the wonderful Monkey Island Special Edition .

This is an ideal option. Unfortunately, only very few games are redone , the reason for this is the cost, the lost source code of the original, or even insufficient interest in the case of relatively little-known games.

A similar category includes games whose source code is open, such as id's first person shooters. There are projects creating new graphic resources for these games, but they are rare, and few developers open the source code for their games.

Play a remake . Some games are so awesome and have gathered such a loyal fan base that someone decides to rewrite the game from scratch, usually without the slightest support from the original authors. If you manage to find a good remake, then you get an almost original game, but with modern graphics.

This is a good alternative, but, again, not many games have remakes. This happened because remakes are usually created by fans, and the task is incredibly difficult - as complex as creating the game again, and this adds to the difficulty of accurately reproducing the original gameplay. The only way to achieve a high degree of accuracy is to disassemble the original code and recreate its logic.

Run the emulator . You can always use DOSBox and special solutions for some games, for example ScummVM. It works well, but to be honest, the graphics of most games are not like wine, which gets better over time. However, you still play the original game.

Total


If the game you want to play has a remastered version, then this is great! But for the vast majority of games that do not have remasters, there are only two options: to use the emulator (it is widely available, provides perfect gameplay and outdated graphics) or to hope that someone will create a remake (relatively rare, imperfect gameplay, modern graphics )

New approach


But what if we can run immutable binary, only with improved graphics?

Suppose you run the game in an emulator. You do not have the source code, but you can be sure that somewhere in the binary code the "draw sprite" method is hidden . Or the "deduce symbol" method . Or the “play sound effect” method . Or the "render polygon" method .

What if I could use a debugger / disassembler integrated with the emulator to find the input points of these methods? What if we find out which registers which parameters contain, or their order on the stack?

What if we can program the emulator to call an arbitrary C ++ method when these input points must be executed, extract the state of the registers at that moment and execute our own sprite drawing code? Or a TrueType font rendering code? Or an MP3 playback code? Or a few OpenGL calls?

If we succeed in replacing all these methods with C ++ implementations, then as a result we get a game that exactly follows the logic of the original, but looks modern. We will get an emulated remake with accurately reproduced gameplay, which can be gradually supplemented, and for this a very superficial understanding of the disassembled code is enough.

I researched the issue a bit and it turned out to be a fairly fresh idea. Why has no one tried to do this before?

Will this work?

Validation Concept


I decided to check out this crazy idea. I wrote an 8086 + CGA emulator with only 44 implemented opcodes, which are barely enough to launch the Goody splash screen:



I wrote two tools - a disassembler and a launcher with a gdb-like interface, allowing you to step through the code, set breakpoints, and so on.

How do we find interesting features without complete disassembly? I used many ways - setting breakpoints and studying registers, executing code in small fragments, accidentally filling in the contents of the simulated video memory to see what would be rendered, patching the code to skip some calls to see what stopped working, and studying disassembled code, to add comments useful to me.

Thanks to these techniques, I managed to find some interesting “features”:





I added a C ++ interceptor to do my own rendering in a separate window:



I added some rough graphics, crossed my fingers, and ...



... and behold, I have a "remake"! Look, the "old" window runs next to the "new" window; this is not a static image, but a new graphic driven by the original X86 code!

See for yourself


The entire demo (x86 emulator / disassembler / debugger, Goody interceptors and draft graphics) is available on GitHub . It works on Linux and Mac; SDL2 and the C ++ 0x compiler are required.

The source code is released under the Whatever / Credit license : you can do anything with the code; if you create something cool, then I will be grateful for the indication of my authorship . If anything, the code is not even of alpha quality - this is the “concept check / works on my machine” quality.

The repository contains the original game (goody.com) - I received an unofficial blessing from one of the authors of the original Gonzo Suarez for its distribution, moreover, it is easy to find on any site with outdated software; if someone is against it, I will remove the game from the repository.

I sketched the graphics using my terrible Gimp skills and resources in the public domain or with a Creative Commons license with OpenGameArt : 1 , 2 , 3 , 4 , 5 . If an artist reading this article wants to share the original graphics for this demo, I will be very grateful.

Answers to Expected Questions


Q: Are you aware that there is a great remake of Goody?

Oh yeah. But I chose Goody to test the concept, because I liked this game the most from the CGA era, because it is contained in a COM file, that is, it does not need an EXE loader, and because it is obviously based on tiles, that is, I considered that it will be quite simple to work with her.

Q: Why didn’t you use any available x86 emulators or even DOSBox?

A: Because writing an x86 emulator is an interesting task. After the concept verification phase, I intend to fully adapt the DOSBox for this.

Thoughts in conclusion


Is the system scalable?


Can these techniques be used for more complex games? I see no obstacles. You can always start with DOSBox and replace, say, sound. This will be the beginning of a partial remake.

Another question is where to draw the line - at what level of abstraction add interceptors. To some extent, you can create interceptors in DOSBox at the lowest level - to draw individual pixels. My concept check performs intercepts at the level of "tile rendering" and "glyph rendering" . But take fonts, for example. Rendering glyph by glyph is quite suitable for aspects such as money and life counters, but for the instructions on the main screen you can think of something better, for example, an interceptor at the level of “line drawing”, and use FreeType to get a proportional font with beautiful kerning.

Similar considerations apply to 3D games with software rendering such as X-Wing or Stunts. Maybe it will be possible to intercept the "render triangle" function , and in this case, very low-poly models will be rendered in the video processor, or intercept the "render model" function and use new 3D models. Or you can take the original Wing Commander, which does not even use 3D models - instead of them there are bitmaps of high-resolution ships, and actually render 3D ships.

Another example is sound. You can intercept the programmable timer and speaker I / O ports to generate the corresponding waves on the fly (I assume that DOSBox does), or intercept the function “play sound effect” and play MP3 files instead of sounds.

What about frame rate? Goody's death animation takes two frames and lasts about a second. Even with beautiful resources, the animation will still look torn. I think that the solution to problems of this type will be more intelligent processing of state rendering - ideally, you could write a completely new renderer based on the state of the game read from memory without the need to directly intercept any rendering methods.

Applicability Beyond Games


This idea can be applied not only in games. Some systems use very old software because over the years so many details of the business logic have been added that it is impossible or impractical to rewrite such systems from scratch. But thanks to these techniques, it will be possible to execute logic without changes and replace the I / O / database code with something more modern.

Legality


Although this is not legal advice, because I am not a lawyer , I can’t think of any reason why the technique itself may be illegal, because the original remake of the game does not come with a remake (only if the game itself is not distributed for free).

Graphics are harder. The remake cannot have original resources; artists and musicians will have to redo them from scratch. But even then, I’m not sure if creating, say, X-Wing 3D models or Darth Vader’s images is legal. Perhaps they can be considered fan art?

Additional reading


If you like reverse engineering, old games, or both, then you should check out Fabien Sanglar's website .

Summarize


Verification of the concept confirms the viability of the idea; in the end, it turned out that she wasn’t so crazy. Remakes can be done by connecting a modern rendering / sound / network code to an emulator / virtual machine in which the original game is running.

Will this revolutionize the way remakes are created? I really hope so! I would love to play games of the past with modern graphics and original gameplay.

Also popular now: