Post subject: Universal TAS virtual machine
Former player
Joined: 1/29/2007
Posts: 116
Just a thought I had the other day. I have no idea if this is even remotely possible as I know next to nothing about how modern OSes and emulators work. Anyways, here's the idea: If you fitted a virtual machine with rerecording capabilities, should that not result in having rerecording on all emulators available on that platform?
Emulator Coder
Joined: 3/9/2004
Posts: 4588
Location: In his lab studying psychology to find new ways to torture TASers and forumers
Yes. I heartily believe we should do this. It'll save a lot of time an effort. Although it won't necessarily make finding memory addresses for watching easy.
Warning: Opinions expressed by Nach or others in this post do not necessarily reflect the views, opinions, or position of Nach himself on the matter(s) being discussed therein.
Joined: 7/2/2007
Posts: 3960
The theory sounds good; in practice, operating systems are incredibly more complex than the consoles we're generally concerned with emulating, to the extent that I suspect that getting a movie that plays on two different peoples' setups would be problematic. It's also a huge undertaking -- imagine a savestate for your entire computer. Still, I'd love to hear if anything like this has been tried before.
Pyrel - an open-source rewrite of the Angband roguelike game in Python.
Emulator Coder
Joined: 3/9/2004
Posts: 4588
Location: In his lab studying psychology to find new ways to torture TASers and forumers
Derakon wrote:
The theory sounds good; in practice, operating systems are incredibly more complex than the consoles we're generally concerned with emulating, to the extent that I suspect that getting a movie that plays on two different peoples' setups would be problematic. It's also a huge undertaking -- imagine a savestate for your entire computer.
Some of the existing virtual machines already have save state support.
Warning: Opinions expressed by Nach or others in this post do not necessarily reflect the views, opinions, or position of Nach himself on the matter(s) being discussed therein.
Lex
Joined: 6/25/2007
Posts: 732
Location: Vancouver, British Columbia, Canada
CyberShadow, a friend of mine who posted on this forum, used a virtual machine to save his states in Cave Story or Within a Deep Forest (not sure which game it was, but both are great) when he played through them. It's definitely possible and probably not too hard for an experienced coder. If someone wrote the tools and started a WIP TAS of Cave Story or a similarly awesome freeware game, I would definitely set up the VM to play it back! Such an awesome idea. :D
Player (6)
Joined: 10/25/2009
Posts: 22
Beep. I have a separate tiny project of (truely) TASing a PC game without using emulation (not Worms Armageddon). Might post about it soon. (This isn't really related anyway.) On topic: I don't think this is a good idea, because video/input frames on VMs wouldn't correspond to those on emulators. It'd be hell to time the keystrokes correctly to correspond to emulator input frames.
Lex
Joined: 6/25/2007
Posts: 732
Location: Vancouver, British Columbia, Canada
CyberShadow wrote:
On topic: I don't think this is a good idea, because video/input frames on VMs wouldn't correspond to those on emulators. It'd be hell to time the keystrokes correctly to correspond to emulator input frames.
Could the movie format be written to include exact time points for each input, like video subtitle formats are, and have the VM CPU stop until that input is processed completely? Or is that not the issue you were talking about?
Player (6)
Joined: 10/25/2009
Posts: 22
Yes, but you would need to first determine those points (which would involve either reverse-engineering or source modification of the emulators anyway), and then you'd need to strap on something to the VM software itself to work on those input frames, rather than whatever it uses for recording. Also all this is extremely oversimplifying - a keystroke goes through MANY layers of code until it reaches the emulator (BIOS -> OS kernel-space -> OS userspace -> Windows messages -> Emulator input handling code to name a few), so factoring in these delays would be an additional problem.
Lex
Joined: 6/25/2007
Posts: 732
Location: Vancouver, British Columbia, Canada
We're talking about modifying the VM software to add rudimentary TAS support, so yes, you'd have to modify the VM's source. By modifying the VM's source, you can have full control over every CPU cycle, and have input trigger at a specific CPU cycle, making the VM play back the input perfectly. At least, that seems right to me. Computers are predictable, right? I don't think they're as chaotic as you make it seem. I might be wrong, though. The VM might be trying to emulate as fast as possible by not caring about sequencing of events by using multiple CPU cores on its host (non-virtual) machine. I know debugging through each step of any executable is possible. You could use similar technology for input recording/playback in VMs. Just treat each input point the same as you would treat a breakpoint. The lag present on an actual NES is present in NES emulators, and the movies still play back perfectly with the same lag, reproduced. I don't see how a PC VM should act differently from this. If you do the PC emulation right, you really don't have to consider the whole cascading effect input has to go through to get to the game you're trying to play in the operating system your PC VM is running. Maybe I'm just talking nonsense, like usual. I like to think what I'm saying has some merit, though. :x
Former player
Joined: 2/19/2007
Posts: 424
Location: UK
Making a rerecording PC emulator is possible. But it is hard. First of all, most popular PC emulators use various speed tricks which involve passing instructions through to the underlying machine, or using its interrupts etc. This breaks the encapsulation of the emulated machine, and makes it nondeterministic. Not all PC emulators do this, though, and for those that do, it should be possible to rewrite those parts (a huge project, though smaller for somebody already deeply familiar with that emulator). Secondly, a PC has lots of different parts: Network interfaces, com ports, sound cards, graphics cards, various buses and bridghes on the mainboard, etc. etc. Even if the emulator actually emulates these, instead of using those of the underlying system, saving the state of all of these correctly is difficult unless the emulator was designed with savestates in mind from the bottom up. And incomplete savestates lead to desyncs, just like nondeterministic emulation does. Thirdly, the state of a PC is larger than that of a typical console. By a factor of a million or so. This means that, unless differential savestates are implemented, each savestate will take up gigabytes, and take significant time read and write. Which would make tasing irritating. On the positive side: If differential savestates are implemented, the step to non-linear rerecording, with a branching tree of savestates you can jump between, is pretty short. Fourthly: The concept of roms is more complicated here, but as discussed in a (relatively) recent thread, it is still possible to reach a setup that will allow movies to sync without having to distribute the whole state of the VM (which would contain copyrighted software). However, the presence of license keys etc. prevents this from working, so this could only legally be done with license-key-less software. Fifthly: The movie would have to contain a set of inputs for every device on the emulated PC which could accept input from the outside, for example the network card, mic, mouse, keyboard, power button, dvd eject key, etc. This isn't a big problem, though. That said, I would also like to see such an emulator. I recall speaking to somebody who was making a rerecording version of JPC, which he said was already deterministic (which is the greatest hurdle in my opinion). I haven't heard anything since then, though. Do any of you know of any other rerecording PC emulator projects?
Player (6)
Joined: 10/25/2009
Posts: 22
Lex: I was talking about the idea of using a rerecording PC emulator running various console emulators for TAS-ing. It's not practical, it's a lot less work to reverse-engineer a closed-source emulator and add TAS capabilities.
Lex
Joined: 6/25/2007
Posts: 732
Location: Vancouver, British Columbia, Canada
Speaking of which, please reverse-engineer Cave Story and add TAS capabilites. Thanks. ;D
Player (6)
Joined: 10/25/2009
Posts: 22
I'll put it on my list :P
upthorn
He/Him
Emulator Coder, Active player (392)
Joined: 3/24/2006
Posts: 1802
I'd like to announce a similar project which has been quietly in the works for a while. The end result won't be quite as all-encompassing, but it should be much simpler to use, to time, and to implement.
How fleeting are all human passions compared with the massive continuity of ducks.
Former player
Joined: 1/29/2007
Posts: 116
Thanks for the insightful comments guys! I guess "possible but infeasible" is better than impossible, but will have the same result in the end.