stella-emu / stella

A multi-platform Atari 2600 Emulator
https://stella-emu.github.io
GNU General Public License v2.0
625 stars 111 forks source link

Input State batch file #212

Open SpiceWare opened 7 years ago

SpiceWare commented 7 years ago

During a discussion about Todd Roger's score in Dragster, it became apparent that a way to play back a sequence of the input state values would be handy. A text file containing something like this:

RESET 10 LEFT 5 FIRE LEFT LEFT FIRE ...

would be used like this:

  1. hold RESET for 1 frame (1 is default if no leading number is found)
  2. nothing for 10 frames
  3. hold left for 1 frame
  4. hold fire for 5 frames
  5. hold left and fire for 1 frame
  6. ...
sa666666 commented 7 years ago

There's already something somewhat similar to this in the code, but it's commented out. I experimented with the ability to do what I called 'event recording'. Basically, when this was turned on, an initial state save was done, and then for every frame, the events generated were also saved. Upon 'replaying' the recording, the state file was reloaded, and the events replayed. In effect, the emulation ran itself, as if someone was inputting the events. But they were synthetic, not from an actual player.

This sounds very much like what is needed here. The only difference is that the events are read from some external file, vs. from an event recording generated by Stella itself. A very cool thing to have, if we ever find time to do it.

thrust26 commented 7 years ago

IMO we should use an universal, editable format e.g. XML

DirtyHairy commented 7 years ago

This would be pretty useful for testing (haven't forgotten about that) and benchmarking as well. As a format: please not XML --- I always get nervous cramps when trying to write XML without a XSD and full IDE support 😉 What about YAML? It is easy to read, easy to write, and there are parsers aplenty out there.

thrust26 commented 7 years ago

An XSD would be no problem. But whatever you prefer, even key/value pairs should work.

SpiceWare commented 7 years ago

Maybe a batch file for the debugger would be simpler/quicker to implement. There's already a frame command so would need new commands to set the bits in SWCHA, SWCHB, INPT4, etc and a new command RUN {batfile} to read in the file and act as if the user typed them in a line at a time.

; frame 1 RESET=ON FRAME ; frame 2 RESET=OFF LEFT=ON FRAME ; frames 3-7 LEFT=OFF FIRE=ON FRAME 5 ; frame 8 FIRE=OFF ...

So the frame would only advance when you issue a FRAME command and values would stay set to whatever you last set them to.

thrust26 commented 7 years ago

What frame command do you mean?

SpiceWare commented 7 years ago

type HELP in the debugger's prompt and you'll see a list of commands, frame is one of them. Type frame by itself to advance the emulation a single frame, or type frame # to advance it multiple frames. # is a hex value so frame 10 would advance 16 frames.

thrust26 commented 7 years ago

Ah, I thought you meant the command line.

SpiceWare commented 7 years ago

Aha - yeah, I was thinking it would be faster to take advantage of the command parser that's already in place than to create a new parser.

thrust26 commented 7 years ago

I think could be further enhanced, e.g.